mutation.go 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874458754587645877458784587945880458814588245883458844588545886458874588845889458904589145892458934589445895458964589745898458994590045901459024590345904459054590645907459084590945910459114591245913459144591545916459174591845919459204592145922459234592445925459264592745928459294593045931459324593345934459354593645937459384593945940459414594245943459444594545946459474594845949459504595145952459534595445955459564595745958459594596045961459624596345964459654596645967459684596945970459714597245973459744597545976459774597845979459804598145982459834598445985459864598745988459894599045991459924599345994459954599645997459984599946000460014600246003460044600546006460074600846009460104601146012460134601446015460164601746018
  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. // ResetUserID resets all changes to the "user_id" field.
  9597. func (m *CreditBalanceMutation) ResetUserID() {
  9598. m.user_id = nil
  9599. }
  9600. // SetBalance sets the "balance" field.
  9601. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9602. m.balance = &f
  9603. m.addbalance = nil
  9604. }
  9605. // Balance returns the value of the "balance" field in the mutation.
  9606. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9607. v := m.balance
  9608. if v == nil {
  9609. return
  9610. }
  9611. return *v, true
  9612. }
  9613. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9614. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9616. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9617. if !m.op.Is(OpUpdateOne) {
  9618. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9619. }
  9620. if m.id == nil || m.oldValue == nil {
  9621. return v, errors.New("OldBalance requires an ID field in the mutation")
  9622. }
  9623. oldValue, err := m.oldValue(ctx)
  9624. if err != nil {
  9625. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9626. }
  9627. return oldValue.Balance, nil
  9628. }
  9629. // AddBalance adds f to the "balance" field.
  9630. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9631. if m.addbalance != nil {
  9632. *m.addbalance += f
  9633. } else {
  9634. m.addbalance = &f
  9635. }
  9636. }
  9637. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9638. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9639. v := m.addbalance
  9640. if v == nil {
  9641. return
  9642. }
  9643. return *v, true
  9644. }
  9645. // ResetBalance resets all changes to the "balance" field.
  9646. func (m *CreditBalanceMutation) ResetBalance() {
  9647. m.balance = nil
  9648. m.addbalance = nil
  9649. }
  9650. // SetStatus sets the "status" field.
  9651. func (m *CreditBalanceMutation) SetStatus(i int) {
  9652. m.status = &i
  9653. m.addstatus = nil
  9654. }
  9655. // Status returns the value of the "status" field in the mutation.
  9656. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9657. v := m.status
  9658. if v == nil {
  9659. return
  9660. }
  9661. return *v, true
  9662. }
  9663. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9664. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9666. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9667. if !m.op.Is(OpUpdateOne) {
  9668. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9669. }
  9670. if m.id == nil || m.oldValue == nil {
  9671. return v, errors.New("OldStatus requires an ID field in the mutation")
  9672. }
  9673. oldValue, err := m.oldValue(ctx)
  9674. if err != nil {
  9675. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9676. }
  9677. return oldValue.Status, nil
  9678. }
  9679. // AddStatus adds i to the "status" field.
  9680. func (m *CreditBalanceMutation) AddStatus(i int) {
  9681. if m.addstatus != nil {
  9682. *m.addstatus += i
  9683. } else {
  9684. m.addstatus = &i
  9685. }
  9686. }
  9687. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9688. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9689. v := m.addstatus
  9690. if v == nil {
  9691. return
  9692. }
  9693. return *v, true
  9694. }
  9695. // ClearStatus clears the value of the "status" field.
  9696. func (m *CreditBalanceMutation) ClearStatus() {
  9697. m.status = nil
  9698. m.addstatus = nil
  9699. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9700. }
  9701. // StatusCleared returns if the "status" field was cleared in this mutation.
  9702. func (m *CreditBalanceMutation) StatusCleared() bool {
  9703. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9704. return ok
  9705. }
  9706. // ResetStatus resets all changes to the "status" field.
  9707. func (m *CreditBalanceMutation) ResetStatus() {
  9708. m.status = nil
  9709. m.addstatus = nil
  9710. delete(m.clearedFields, creditbalance.FieldStatus)
  9711. }
  9712. // SetOrganizationID sets the "organization_id" field.
  9713. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9714. m.organization_id = &u
  9715. m.addorganization_id = nil
  9716. }
  9717. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9718. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9719. v := m.organization_id
  9720. if v == nil {
  9721. return
  9722. }
  9723. return *v, true
  9724. }
  9725. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9726. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9728. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9729. if !m.op.Is(OpUpdateOne) {
  9730. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9731. }
  9732. if m.id == nil || m.oldValue == nil {
  9733. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9734. }
  9735. oldValue, err := m.oldValue(ctx)
  9736. if err != nil {
  9737. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9738. }
  9739. return oldValue.OrganizationID, nil
  9740. }
  9741. // AddOrganizationID adds u to the "organization_id" field.
  9742. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9743. if m.addorganization_id != nil {
  9744. *m.addorganization_id += u
  9745. } else {
  9746. m.addorganization_id = &u
  9747. }
  9748. }
  9749. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9750. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9751. v := m.addorganization_id
  9752. if v == nil {
  9753. return
  9754. }
  9755. return *v, true
  9756. }
  9757. // ClearOrganizationID clears the value of the "organization_id" field.
  9758. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9759. m.organization_id = nil
  9760. m.addorganization_id = nil
  9761. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9762. }
  9763. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9764. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9765. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9766. return ok
  9767. }
  9768. // ResetOrganizationID resets all changes to the "organization_id" field.
  9769. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9770. m.organization_id = nil
  9771. m.addorganization_id = nil
  9772. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9773. }
  9774. // Where appends a list predicates to the CreditBalanceMutation builder.
  9775. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9776. m.predicates = append(m.predicates, ps...)
  9777. }
  9778. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9779. // users can use type-assertion to append predicates that do not depend on any generated package.
  9780. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9781. p := make([]predicate.CreditBalance, len(ps))
  9782. for i := range ps {
  9783. p[i] = ps[i]
  9784. }
  9785. m.Where(p...)
  9786. }
  9787. // Op returns the operation name.
  9788. func (m *CreditBalanceMutation) Op() Op {
  9789. return m.op
  9790. }
  9791. // SetOp allows setting the mutation operation.
  9792. func (m *CreditBalanceMutation) SetOp(op Op) {
  9793. m.op = op
  9794. }
  9795. // Type returns the node type of this mutation (CreditBalance).
  9796. func (m *CreditBalanceMutation) Type() string {
  9797. return m.typ
  9798. }
  9799. // Fields returns all fields that were changed during this mutation. Note that in
  9800. // order to get all numeric fields that were incremented/decremented, call
  9801. // AddedFields().
  9802. func (m *CreditBalanceMutation) Fields() []string {
  9803. fields := make([]string, 0, 7)
  9804. if m.created_at != nil {
  9805. fields = append(fields, creditbalance.FieldCreatedAt)
  9806. }
  9807. if m.updated_at != nil {
  9808. fields = append(fields, creditbalance.FieldUpdatedAt)
  9809. }
  9810. if m.deleted_at != nil {
  9811. fields = append(fields, creditbalance.FieldDeletedAt)
  9812. }
  9813. if m.user_id != nil {
  9814. fields = append(fields, creditbalance.FieldUserID)
  9815. }
  9816. if m.balance != nil {
  9817. fields = append(fields, creditbalance.FieldBalance)
  9818. }
  9819. if m.status != nil {
  9820. fields = append(fields, creditbalance.FieldStatus)
  9821. }
  9822. if m.organization_id != nil {
  9823. fields = append(fields, creditbalance.FieldOrganizationID)
  9824. }
  9825. return fields
  9826. }
  9827. // Field returns the value of a field with the given name. The second boolean
  9828. // return value indicates that this field was not set, or was not defined in the
  9829. // schema.
  9830. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9831. switch name {
  9832. case creditbalance.FieldCreatedAt:
  9833. return m.CreatedAt()
  9834. case creditbalance.FieldUpdatedAt:
  9835. return m.UpdatedAt()
  9836. case creditbalance.FieldDeletedAt:
  9837. return m.DeletedAt()
  9838. case creditbalance.FieldUserID:
  9839. return m.UserID()
  9840. case creditbalance.FieldBalance:
  9841. return m.Balance()
  9842. case creditbalance.FieldStatus:
  9843. return m.Status()
  9844. case creditbalance.FieldOrganizationID:
  9845. return m.OrganizationID()
  9846. }
  9847. return nil, false
  9848. }
  9849. // OldField returns the old value of the field from the database. An error is
  9850. // returned if the mutation operation is not UpdateOne, or the query to the
  9851. // database failed.
  9852. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9853. switch name {
  9854. case creditbalance.FieldCreatedAt:
  9855. return m.OldCreatedAt(ctx)
  9856. case creditbalance.FieldUpdatedAt:
  9857. return m.OldUpdatedAt(ctx)
  9858. case creditbalance.FieldDeletedAt:
  9859. return m.OldDeletedAt(ctx)
  9860. case creditbalance.FieldUserID:
  9861. return m.OldUserID(ctx)
  9862. case creditbalance.FieldBalance:
  9863. return m.OldBalance(ctx)
  9864. case creditbalance.FieldStatus:
  9865. return m.OldStatus(ctx)
  9866. case creditbalance.FieldOrganizationID:
  9867. return m.OldOrganizationID(ctx)
  9868. }
  9869. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9870. }
  9871. // SetField sets the value of a field with the given name. It returns an error if
  9872. // the field is not defined in the schema, or if the type mismatched the field
  9873. // type.
  9874. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9875. switch name {
  9876. case creditbalance.FieldCreatedAt:
  9877. v, ok := value.(time.Time)
  9878. if !ok {
  9879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9880. }
  9881. m.SetCreatedAt(v)
  9882. return nil
  9883. case creditbalance.FieldUpdatedAt:
  9884. v, ok := value.(time.Time)
  9885. if !ok {
  9886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9887. }
  9888. m.SetUpdatedAt(v)
  9889. return nil
  9890. case creditbalance.FieldDeletedAt:
  9891. v, ok := value.(time.Time)
  9892. if !ok {
  9893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9894. }
  9895. m.SetDeletedAt(v)
  9896. return nil
  9897. case creditbalance.FieldUserID:
  9898. v, ok := value.(string)
  9899. if !ok {
  9900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9901. }
  9902. m.SetUserID(v)
  9903. return nil
  9904. case creditbalance.FieldBalance:
  9905. v, ok := value.(float32)
  9906. if !ok {
  9907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9908. }
  9909. m.SetBalance(v)
  9910. return nil
  9911. case creditbalance.FieldStatus:
  9912. v, ok := value.(int)
  9913. if !ok {
  9914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9915. }
  9916. m.SetStatus(v)
  9917. return nil
  9918. case creditbalance.FieldOrganizationID:
  9919. v, ok := value.(uint64)
  9920. if !ok {
  9921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9922. }
  9923. m.SetOrganizationID(v)
  9924. return nil
  9925. }
  9926. return fmt.Errorf("unknown CreditBalance field %s", name)
  9927. }
  9928. // AddedFields returns all numeric fields that were incremented/decremented during
  9929. // this mutation.
  9930. func (m *CreditBalanceMutation) AddedFields() []string {
  9931. var fields []string
  9932. if m.addbalance != nil {
  9933. fields = append(fields, creditbalance.FieldBalance)
  9934. }
  9935. if m.addstatus != nil {
  9936. fields = append(fields, creditbalance.FieldStatus)
  9937. }
  9938. if m.addorganization_id != nil {
  9939. fields = append(fields, creditbalance.FieldOrganizationID)
  9940. }
  9941. return fields
  9942. }
  9943. // AddedField returns the numeric value that was incremented/decremented on a field
  9944. // with the given name. The second boolean return value indicates that this field
  9945. // was not set, or was not defined in the schema.
  9946. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9947. switch name {
  9948. case creditbalance.FieldBalance:
  9949. return m.AddedBalance()
  9950. case creditbalance.FieldStatus:
  9951. return m.AddedStatus()
  9952. case creditbalance.FieldOrganizationID:
  9953. return m.AddedOrganizationID()
  9954. }
  9955. return nil, false
  9956. }
  9957. // AddField adds the value to the field with the given name. It returns an error if
  9958. // the field is not defined in the schema, or if the type mismatched the field
  9959. // type.
  9960. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9961. switch name {
  9962. case creditbalance.FieldBalance:
  9963. v, ok := value.(float32)
  9964. if !ok {
  9965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9966. }
  9967. m.AddBalance(v)
  9968. return nil
  9969. case creditbalance.FieldStatus:
  9970. v, ok := value.(int)
  9971. if !ok {
  9972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9973. }
  9974. m.AddStatus(v)
  9975. return nil
  9976. case creditbalance.FieldOrganizationID:
  9977. v, ok := value.(int64)
  9978. if !ok {
  9979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9980. }
  9981. m.AddOrganizationID(v)
  9982. return nil
  9983. }
  9984. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9985. }
  9986. // ClearedFields returns all nullable fields that were cleared during this
  9987. // mutation.
  9988. func (m *CreditBalanceMutation) ClearedFields() []string {
  9989. var fields []string
  9990. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9991. fields = append(fields, creditbalance.FieldDeletedAt)
  9992. }
  9993. if m.FieldCleared(creditbalance.FieldStatus) {
  9994. fields = append(fields, creditbalance.FieldStatus)
  9995. }
  9996. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  9997. fields = append(fields, creditbalance.FieldOrganizationID)
  9998. }
  9999. return fields
  10000. }
  10001. // FieldCleared returns a boolean indicating if a field with the given name was
  10002. // cleared in this mutation.
  10003. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10004. _, ok := m.clearedFields[name]
  10005. return ok
  10006. }
  10007. // ClearField clears the value of the field with the given name. It returns an
  10008. // error if the field is not defined in the schema.
  10009. func (m *CreditBalanceMutation) ClearField(name string) error {
  10010. switch name {
  10011. case creditbalance.FieldDeletedAt:
  10012. m.ClearDeletedAt()
  10013. return nil
  10014. case creditbalance.FieldStatus:
  10015. m.ClearStatus()
  10016. return nil
  10017. case creditbalance.FieldOrganizationID:
  10018. m.ClearOrganizationID()
  10019. return nil
  10020. }
  10021. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10022. }
  10023. // ResetField resets all changes in the mutation for the field with the given name.
  10024. // It returns an error if the field is not defined in the schema.
  10025. func (m *CreditBalanceMutation) ResetField(name string) error {
  10026. switch name {
  10027. case creditbalance.FieldCreatedAt:
  10028. m.ResetCreatedAt()
  10029. return nil
  10030. case creditbalance.FieldUpdatedAt:
  10031. m.ResetUpdatedAt()
  10032. return nil
  10033. case creditbalance.FieldDeletedAt:
  10034. m.ResetDeletedAt()
  10035. return nil
  10036. case creditbalance.FieldUserID:
  10037. m.ResetUserID()
  10038. return nil
  10039. case creditbalance.FieldBalance:
  10040. m.ResetBalance()
  10041. return nil
  10042. case creditbalance.FieldStatus:
  10043. m.ResetStatus()
  10044. return nil
  10045. case creditbalance.FieldOrganizationID:
  10046. m.ResetOrganizationID()
  10047. return nil
  10048. }
  10049. return fmt.Errorf("unknown CreditBalance field %s", name)
  10050. }
  10051. // AddedEdges returns all edge names that were set/added in this mutation.
  10052. func (m *CreditBalanceMutation) AddedEdges() []string {
  10053. edges := make([]string, 0, 0)
  10054. return edges
  10055. }
  10056. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10057. // name in this mutation.
  10058. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10059. return nil
  10060. }
  10061. // RemovedEdges returns all edge names that were removed in this mutation.
  10062. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10063. edges := make([]string, 0, 0)
  10064. return edges
  10065. }
  10066. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10067. // the given name in this mutation.
  10068. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10069. return nil
  10070. }
  10071. // ClearedEdges returns all edge names that were cleared in this mutation.
  10072. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10073. edges := make([]string, 0, 0)
  10074. return edges
  10075. }
  10076. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10077. // was cleared in this mutation.
  10078. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10079. return false
  10080. }
  10081. // ClearEdge clears the value of the edge with the given name. It returns an error
  10082. // if that edge is not defined in the schema.
  10083. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10084. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10085. }
  10086. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10087. // It returns an error if the edge is not defined in the schema.
  10088. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10089. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10090. }
  10091. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10092. type CreditUsageMutation struct {
  10093. config
  10094. op Op
  10095. typ string
  10096. id *uint64
  10097. created_at *time.Time
  10098. updated_at *time.Time
  10099. deleted_at *time.Time
  10100. user_id *string
  10101. number *float32
  10102. addnumber *float32
  10103. status *int
  10104. addstatus *int
  10105. ntype *int
  10106. addntype *int
  10107. table *string
  10108. organization_id *uint64
  10109. addorganization_id *int64
  10110. nid *uint64
  10111. addnid *int64
  10112. reason *string
  10113. operator *string
  10114. clearedFields map[string]struct{}
  10115. done bool
  10116. oldValue func(context.Context) (*CreditUsage, error)
  10117. predicates []predicate.CreditUsage
  10118. }
  10119. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10120. // creditusageOption allows management of the mutation configuration using functional options.
  10121. type creditusageOption func(*CreditUsageMutation)
  10122. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10123. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10124. m := &CreditUsageMutation{
  10125. config: c,
  10126. op: op,
  10127. typ: TypeCreditUsage,
  10128. clearedFields: make(map[string]struct{}),
  10129. }
  10130. for _, opt := range opts {
  10131. opt(m)
  10132. }
  10133. return m
  10134. }
  10135. // withCreditUsageID sets the ID field of the mutation.
  10136. func withCreditUsageID(id uint64) creditusageOption {
  10137. return func(m *CreditUsageMutation) {
  10138. var (
  10139. err error
  10140. once sync.Once
  10141. value *CreditUsage
  10142. )
  10143. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10144. once.Do(func() {
  10145. if m.done {
  10146. err = errors.New("querying old values post mutation is not allowed")
  10147. } else {
  10148. value, err = m.Client().CreditUsage.Get(ctx, id)
  10149. }
  10150. })
  10151. return value, err
  10152. }
  10153. m.id = &id
  10154. }
  10155. }
  10156. // withCreditUsage sets the old CreditUsage of the mutation.
  10157. func withCreditUsage(node *CreditUsage) creditusageOption {
  10158. return func(m *CreditUsageMutation) {
  10159. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10160. return node, nil
  10161. }
  10162. m.id = &node.ID
  10163. }
  10164. }
  10165. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10166. // executed in a transaction (ent.Tx), a transactional client is returned.
  10167. func (m CreditUsageMutation) Client() *Client {
  10168. client := &Client{config: m.config}
  10169. client.init()
  10170. return client
  10171. }
  10172. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10173. // it returns an error otherwise.
  10174. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10175. if _, ok := m.driver.(*txDriver); !ok {
  10176. return nil, errors.New("ent: mutation is not running in a transaction")
  10177. }
  10178. tx := &Tx{config: m.config}
  10179. tx.init()
  10180. return tx, nil
  10181. }
  10182. // SetID sets the value of the id field. Note that this
  10183. // operation is only accepted on creation of CreditUsage entities.
  10184. func (m *CreditUsageMutation) SetID(id uint64) {
  10185. m.id = &id
  10186. }
  10187. // ID returns the ID value in the mutation. Note that the ID is only available
  10188. // if it was provided to the builder or after it was returned from the database.
  10189. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10190. if m.id == nil {
  10191. return
  10192. }
  10193. return *m.id, true
  10194. }
  10195. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10196. // That means, if the mutation is applied within a transaction with an isolation level such
  10197. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10198. // or updated by the mutation.
  10199. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10200. switch {
  10201. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10202. id, exists := m.ID()
  10203. if exists {
  10204. return []uint64{id}, nil
  10205. }
  10206. fallthrough
  10207. case m.op.Is(OpUpdate | OpDelete):
  10208. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10209. default:
  10210. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10211. }
  10212. }
  10213. // SetCreatedAt sets the "created_at" field.
  10214. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10215. m.created_at = &t
  10216. }
  10217. // CreatedAt returns the value of the "created_at" field in the mutation.
  10218. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10219. v := m.created_at
  10220. if v == nil {
  10221. return
  10222. }
  10223. return *v, true
  10224. }
  10225. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10226. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10228. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10229. if !m.op.Is(OpUpdateOne) {
  10230. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10231. }
  10232. if m.id == nil || m.oldValue == nil {
  10233. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10234. }
  10235. oldValue, err := m.oldValue(ctx)
  10236. if err != nil {
  10237. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10238. }
  10239. return oldValue.CreatedAt, nil
  10240. }
  10241. // ResetCreatedAt resets all changes to the "created_at" field.
  10242. func (m *CreditUsageMutation) ResetCreatedAt() {
  10243. m.created_at = nil
  10244. }
  10245. // SetUpdatedAt sets the "updated_at" field.
  10246. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10247. m.updated_at = &t
  10248. }
  10249. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10250. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10251. v := m.updated_at
  10252. if v == nil {
  10253. return
  10254. }
  10255. return *v, true
  10256. }
  10257. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10258. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10260. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10261. if !m.op.Is(OpUpdateOne) {
  10262. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10263. }
  10264. if m.id == nil || m.oldValue == nil {
  10265. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10266. }
  10267. oldValue, err := m.oldValue(ctx)
  10268. if err != nil {
  10269. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10270. }
  10271. return oldValue.UpdatedAt, nil
  10272. }
  10273. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10274. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10275. m.updated_at = nil
  10276. }
  10277. // SetDeletedAt sets the "deleted_at" field.
  10278. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10279. m.deleted_at = &t
  10280. }
  10281. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10282. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10283. v := m.deleted_at
  10284. if v == nil {
  10285. return
  10286. }
  10287. return *v, true
  10288. }
  10289. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10290. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10292. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10293. if !m.op.Is(OpUpdateOne) {
  10294. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10295. }
  10296. if m.id == nil || m.oldValue == nil {
  10297. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10298. }
  10299. oldValue, err := m.oldValue(ctx)
  10300. if err != nil {
  10301. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10302. }
  10303. return oldValue.DeletedAt, nil
  10304. }
  10305. // ClearDeletedAt clears the value of the "deleted_at" field.
  10306. func (m *CreditUsageMutation) ClearDeletedAt() {
  10307. m.deleted_at = nil
  10308. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10309. }
  10310. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10311. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10312. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10313. return ok
  10314. }
  10315. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10316. func (m *CreditUsageMutation) ResetDeletedAt() {
  10317. m.deleted_at = nil
  10318. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10319. }
  10320. // SetUserID sets the "user_id" field.
  10321. func (m *CreditUsageMutation) SetUserID(s string) {
  10322. m.user_id = &s
  10323. }
  10324. // UserID returns the value of the "user_id" field in the mutation.
  10325. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10326. v := m.user_id
  10327. if v == nil {
  10328. return
  10329. }
  10330. return *v, true
  10331. }
  10332. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10333. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10335. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10336. if !m.op.Is(OpUpdateOne) {
  10337. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10338. }
  10339. if m.id == nil || m.oldValue == nil {
  10340. return v, errors.New("OldUserID requires an ID field in the mutation")
  10341. }
  10342. oldValue, err := m.oldValue(ctx)
  10343. if err != nil {
  10344. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10345. }
  10346. return oldValue.UserID, nil
  10347. }
  10348. // ResetUserID resets all changes to the "user_id" field.
  10349. func (m *CreditUsageMutation) ResetUserID() {
  10350. m.user_id = nil
  10351. }
  10352. // SetNumber sets the "number" field.
  10353. func (m *CreditUsageMutation) SetNumber(f float32) {
  10354. m.number = &f
  10355. m.addnumber = nil
  10356. }
  10357. // Number returns the value of the "number" field in the mutation.
  10358. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10359. v := m.number
  10360. if v == nil {
  10361. return
  10362. }
  10363. return *v, true
  10364. }
  10365. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10366. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10368. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10369. if !m.op.Is(OpUpdateOne) {
  10370. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10371. }
  10372. if m.id == nil || m.oldValue == nil {
  10373. return v, errors.New("OldNumber requires an ID field in the mutation")
  10374. }
  10375. oldValue, err := m.oldValue(ctx)
  10376. if err != nil {
  10377. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10378. }
  10379. return oldValue.Number, nil
  10380. }
  10381. // AddNumber adds f to the "number" field.
  10382. func (m *CreditUsageMutation) AddNumber(f float32) {
  10383. if m.addnumber != nil {
  10384. *m.addnumber += f
  10385. } else {
  10386. m.addnumber = &f
  10387. }
  10388. }
  10389. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10390. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10391. v := m.addnumber
  10392. if v == nil {
  10393. return
  10394. }
  10395. return *v, true
  10396. }
  10397. // ResetNumber resets all changes to the "number" field.
  10398. func (m *CreditUsageMutation) ResetNumber() {
  10399. m.number = nil
  10400. m.addnumber = nil
  10401. }
  10402. // SetStatus sets the "status" field.
  10403. func (m *CreditUsageMutation) SetStatus(i int) {
  10404. m.status = &i
  10405. m.addstatus = nil
  10406. }
  10407. // Status returns the value of the "status" field in the mutation.
  10408. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10409. v := m.status
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10416. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10418. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10419. if !m.op.Is(OpUpdateOne) {
  10420. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10421. }
  10422. if m.id == nil || m.oldValue == nil {
  10423. return v, errors.New("OldStatus requires an ID field in the mutation")
  10424. }
  10425. oldValue, err := m.oldValue(ctx)
  10426. if err != nil {
  10427. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10428. }
  10429. return oldValue.Status, nil
  10430. }
  10431. // AddStatus adds i to the "status" field.
  10432. func (m *CreditUsageMutation) AddStatus(i int) {
  10433. if m.addstatus != nil {
  10434. *m.addstatus += i
  10435. } else {
  10436. m.addstatus = &i
  10437. }
  10438. }
  10439. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10440. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10441. v := m.addstatus
  10442. if v == nil {
  10443. return
  10444. }
  10445. return *v, true
  10446. }
  10447. // ClearStatus clears the value of the "status" field.
  10448. func (m *CreditUsageMutation) ClearStatus() {
  10449. m.status = nil
  10450. m.addstatus = nil
  10451. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10452. }
  10453. // StatusCleared returns if the "status" field was cleared in this mutation.
  10454. func (m *CreditUsageMutation) StatusCleared() bool {
  10455. _, ok := m.clearedFields[creditusage.FieldStatus]
  10456. return ok
  10457. }
  10458. // ResetStatus resets all changes to the "status" field.
  10459. func (m *CreditUsageMutation) ResetStatus() {
  10460. m.status = nil
  10461. m.addstatus = nil
  10462. delete(m.clearedFields, creditusage.FieldStatus)
  10463. }
  10464. // SetNtype sets the "ntype" field.
  10465. func (m *CreditUsageMutation) SetNtype(i int) {
  10466. m.ntype = &i
  10467. m.addntype = nil
  10468. }
  10469. // Ntype returns the value of the "ntype" field in the mutation.
  10470. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10471. v := m.ntype
  10472. if v == nil {
  10473. return
  10474. }
  10475. return *v, true
  10476. }
  10477. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10478. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10480. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10481. if !m.op.Is(OpUpdateOne) {
  10482. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10483. }
  10484. if m.id == nil || m.oldValue == nil {
  10485. return v, errors.New("OldNtype requires an ID field in the mutation")
  10486. }
  10487. oldValue, err := m.oldValue(ctx)
  10488. if err != nil {
  10489. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10490. }
  10491. return oldValue.Ntype, nil
  10492. }
  10493. // AddNtype adds i to the "ntype" field.
  10494. func (m *CreditUsageMutation) AddNtype(i int) {
  10495. if m.addntype != nil {
  10496. *m.addntype += i
  10497. } else {
  10498. m.addntype = &i
  10499. }
  10500. }
  10501. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10502. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10503. v := m.addntype
  10504. if v == nil {
  10505. return
  10506. }
  10507. return *v, true
  10508. }
  10509. // ResetNtype resets all changes to the "ntype" field.
  10510. func (m *CreditUsageMutation) ResetNtype() {
  10511. m.ntype = nil
  10512. m.addntype = nil
  10513. }
  10514. // SetTable sets the "table" field.
  10515. func (m *CreditUsageMutation) SetTable(s string) {
  10516. m.table = &s
  10517. }
  10518. // Table returns the value of the "table" field in the mutation.
  10519. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10520. v := m.table
  10521. if v == nil {
  10522. return
  10523. }
  10524. return *v, true
  10525. }
  10526. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10527. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10529. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10530. if !m.op.Is(OpUpdateOne) {
  10531. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10532. }
  10533. if m.id == nil || m.oldValue == nil {
  10534. return v, errors.New("OldTable requires an ID field in the mutation")
  10535. }
  10536. oldValue, err := m.oldValue(ctx)
  10537. if err != nil {
  10538. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10539. }
  10540. return oldValue.Table, nil
  10541. }
  10542. // ResetTable resets all changes to the "table" field.
  10543. func (m *CreditUsageMutation) ResetTable() {
  10544. m.table = nil
  10545. }
  10546. // SetOrganizationID sets the "organization_id" field.
  10547. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10548. m.organization_id = &u
  10549. m.addorganization_id = nil
  10550. }
  10551. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10552. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10553. v := m.organization_id
  10554. if v == nil {
  10555. return
  10556. }
  10557. return *v, true
  10558. }
  10559. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10560. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10562. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10563. if !m.op.Is(OpUpdateOne) {
  10564. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10565. }
  10566. if m.id == nil || m.oldValue == nil {
  10567. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10568. }
  10569. oldValue, err := m.oldValue(ctx)
  10570. if err != nil {
  10571. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10572. }
  10573. return oldValue.OrganizationID, nil
  10574. }
  10575. // AddOrganizationID adds u to the "organization_id" field.
  10576. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10577. if m.addorganization_id != nil {
  10578. *m.addorganization_id += u
  10579. } else {
  10580. m.addorganization_id = &u
  10581. }
  10582. }
  10583. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10584. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10585. v := m.addorganization_id
  10586. if v == nil {
  10587. return
  10588. }
  10589. return *v, true
  10590. }
  10591. // ClearOrganizationID clears the value of the "organization_id" field.
  10592. func (m *CreditUsageMutation) ClearOrganizationID() {
  10593. m.organization_id = nil
  10594. m.addorganization_id = nil
  10595. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10596. }
  10597. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10598. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10599. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10600. return ok
  10601. }
  10602. // ResetOrganizationID resets all changes to the "organization_id" field.
  10603. func (m *CreditUsageMutation) ResetOrganizationID() {
  10604. m.organization_id = nil
  10605. m.addorganization_id = nil
  10606. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10607. }
  10608. // SetNid sets the "nid" field.
  10609. func (m *CreditUsageMutation) SetNid(u uint64) {
  10610. m.nid = &u
  10611. m.addnid = nil
  10612. }
  10613. // Nid returns the value of the "nid" field in the mutation.
  10614. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10615. v := m.nid
  10616. if v == nil {
  10617. return
  10618. }
  10619. return *v, true
  10620. }
  10621. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10622. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10624. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10625. if !m.op.Is(OpUpdateOne) {
  10626. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10627. }
  10628. if m.id == nil || m.oldValue == nil {
  10629. return v, errors.New("OldNid requires an ID field in the mutation")
  10630. }
  10631. oldValue, err := m.oldValue(ctx)
  10632. if err != nil {
  10633. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10634. }
  10635. return oldValue.Nid, nil
  10636. }
  10637. // AddNid adds u to the "nid" field.
  10638. func (m *CreditUsageMutation) AddNid(u int64) {
  10639. if m.addnid != nil {
  10640. *m.addnid += u
  10641. } else {
  10642. m.addnid = &u
  10643. }
  10644. }
  10645. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10646. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10647. v := m.addnid
  10648. if v == nil {
  10649. return
  10650. }
  10651. return *v, true
  10652. }
  10653. // ResetNid resets all changes to the "nid" field.
  10654. func (m *CreditUsageMutation) ResetNid() {
  10655. m.nid = nil
  10656. m.addnid = nil
  10657. }
  10658. // SetReason sets the "reason" field.
  10659. func (m *CreditUsageMutation) SetReason(s string) {
  10660. m.reason = &s
  10661. }
  10662. // Reason returns the value of the "reason" field in the mutation.
  10663. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10664. v := m.reason
  10665. if v == nil {
  10666. return
  10667. }
  10668. return *v, true
  10669. }
  10670. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10671. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10673. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10674. if !m.op.Is(OpUpdateOne) {
  10675. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10676. }
  10677. if m.id == nil || m.oldValue == nil {
  10678. return v, errors.New("OldReason requires an ID field in the mutation")
  10679. }
  10680. oldValue, err := m.oldValue(ctx)
  10681. if err != nil {
  10682. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10683. }
  10684. return oldValue.Reason, nil
  10685. }
  10686. // ResetReason resets all changes to the "reason" field.
  10687. func (m *CreditUsageMutation) ResetReason() {
  10688. m.reason = nil
  10689. }
  10690. // SetOperator sets the "operator" field.
  10691. func (m *CreditUsageMutation) SetOperator(s string) {
  10692. m.operator = &s
  10693. }
  10694. // Operator returns the value of the "operator" field in the mutation.
  10695. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10696. v := m.operator
  10697. if v == nil {
  10698. return
  10699. }
  10700. return *v, true
  10701. }
  10702. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10703. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10705. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10706. if !m.op.Is(OpUpdateOne) {
  10707. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10708. }
  10709. if m.id == nil || m.oldValue == nil {
  10710. return v, errors.New("OldOperator requires an ID field in the mutation")
  10711. }
  10712. oldValue, err := m.oldValue(ctx)
  10713. if err != nil {
  10714. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10715. }
  10716. return oldValue.Operator, nil
  10717. }
  10718. // ResetOperator resets all changes to the "operator" field.
  10719. func (m *CreditUsageMutation) ResetOperator() {
  10720. m.operator = nil
  10721. }
  10722. // Where appends a list predicates to the CreditUsageMutation builder.
  10723. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10724. m.predicates = append(m.predicates, ps...)
  10725. }
  10726. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10727. // users can use type-assertion to append predicates that do not depend on any generated package.
  10728. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10729. p := make([]predicate.CreditUsage, len(ps))
  10730. for i := range ps {
  10731. p[i] = ps[i]
  10732. }
  10733. m.Where(p...)
  10734. }
  10735. // Op returns the operation name.
  10736. func (m *CreditUsageMutation) Op() Op {
  10737. return m.op
  10738. }
  10739. // SetOp allows setting the mutation operation.
  10740. func (m *CreditUsageMutation) SetOp(op Op) {
  10741. m.op = op
  10742. }
  10743. // Type returns the node type of this mutation (CreditUsage).
  10744. func (m *CreditUsageMutation) Type() string {
  10745. return m.typ
  10746. }
  10747. // Fields returns all fields that were changed during this mutation. Note that in
  10748. // order to get all numeric fields that were incremented/decremented, call
  10749. // AddedFields().
  10750. func (m *CreditUsageMutation) Fields() []string {
  10751. fields := make([]string, 0, 12)
  10752. if m.created_at != nil {
  10753. fields = append(fields, creditusage.FieldCreatedAt)
  10754. }
  10755. if m.updated_at != nil {
  10756. fields = append(fields, creditusage.FieldUpdatedAt)
  10757. }
  10758. if m.deleted_at != nil {
  10759. fields = append(fields, creditusage.FieldDeletedAt)
  10760. }
  10761. if m.user_id != nil {
  10762. fields = append(fields, creditusage.FieldUserID)
  10763. }
  10764. if m.number != nil {
  10765. fields = append(fields, creditusage.FieldNumber)
  10766. }
  10767. if m.status != nil {
  10768. fields = append(fields, creditusage.FieldStatus)
  10769. }
  10770. if m.ntype != nil {
  10771. fields = append(fields, creditusage.FieldNtype)
  10772. }
  10773. if m.table != nil {
  10774. fields = append(fields, creditusage.FieldTable)
  10775. }
  10776. if m.organization_id != nil {
  10777. fields = append(fields, creditusage.FieldOrganizationID)
  10778. }
  10779. if m.nid != nil {
  10780. fields = append(fields, creditusage.FieldNid)
  10781. }
  10782. if m.reason != nil {
  10783. fields = append(fields, creditusage.FieldReason)
  10784. }
  10785. if m.operator != nil {
  10786. fields = append(fields, creditusage.FieldOperator)
  10787. }
  10788. return fields
  10789. }
  10790. // Field returns the value of a field with the given name. The second boolean
  10791. // return value indicates that this field was not set, or was not defined in the
  10792. // schema.
  10793. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10794. switch name {
  10795. case creditusage.FieldCreatedAt:
  10796. return m.CreatedAt()
  10797. case creditusage.FieldUpdatedAt:
  10798. return m.UpdatedAt()
  10799. case creditusage.FieldDeletedAt:
  10800. return m.DeletedAt()
  10801. case creditusage.FieldUserID:
  10802. return m.UserID()
  10803. case creditusage.FieldNumber:
  10804. return m.Number()
  10805. case creditusage.FieldStatus:
  10806. return m.Status()
  10807. case creditusage.FieldNtype:
  10808. return m.Ntype()
  10809. case creditusage.FieldTable:
  10810. return m.Table()
  10811. case creditusage.FieldOrganizationID:
  10812. return m.OrganizationID()
  10813. case creditusage.FieldNid:
  10814. return m.Nid()
  10815. case creditusage.FieldReason:
  10816. return m.Reason()
  10817. case creditusage.FieldOperator:
  10818. return m.Operator()
  10819. }
  10820. return nil, false
  10821. }
  10822. // OldField returns the old value of the field from the database. An error is
  10823. // returned if the mutation operation is not UpdateOne, or the query to the
  10824. // database failed.
  10825. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10826. switch name {
  10827. case creditusage.FieldCreatedAt:
  10828. return m.OldCreatedAt(ctx)
  10829. case creditusage.FieldUpdatedAt:
  10830. return m.OldUpdatedAt(ctx)
  10831. case creditusage.FieldDeletedAt:
  10832. return m.OldDeletedAt(ctx)
  10833. case creditusage.FieldUserID:
  10834. return m.OldUserID(ctx)
  10835. case creditusage.FieldNumber:
  10836. return m.OldNumber(ctx)
  10837. case creditusage.FieldStatus:
  10838. return m.OldStatus(ctx)
  10839. case creditusage.FieldNtype:
  10840. return m.OldNtype(ctx)
  10841. case creditusage.FieldTable:
  10842. return m.OldTable(ctx)
  10843. case creditusage.FieldOrganizationID:
  10844. return m.OldOrganizationID(ctx)
  10845. case creditusage.FieldNid:
  10846. return m.OldNid(ctx)
  10847. case creditusage.FieldReason:
  10848. return m.OldReason(ctx)
  10849. case creditusage.FieldOperator:
  10850. return m.OldOperator(ctx)
  10851. }
  10852. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10853. }
  10854. // SetField sets the value of a field with the given name. It returns an error if
  10855. // the field is not defined in the schema, or if the type mismatched the field
  10856. // type.
  10857. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10858. switch name {
  10859. case creditusage.FieldCreatedAt:
  10860. v, ok := value.(time.Time)
  10861. if !ok {
  10862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10863. }
  10864. m.SetCreatedAt(v)
  10865. return nil
  10866. case creditusage.FieldUpdatedAt:
  10867. v, ok := value.(time.Time)
  10868. if !ok {
  10869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10870. }
  10871. m.SetUpdatedAt(v)
  10872. return nil
  10873. case creditusage.FieldDeletedAt:
  10874. v, ok := value.(time.Time)
  10875. if !ok {
  10876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10877. }
  10878. m.SetDeletedAt(v)
  10879. return nil
  10880. case creditusage.FieldUserID:
  10881. v, ok := value.(string)
  10882. if !ok {
  10883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10884. }
  10885. m.SetUserID(v)
  10886. return nil
  10887. case creditusage.FieldNumber:
  10888. v, ok := value.(float32)
  10889. if !ok {
  10890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10891. }
  10892. m.SetNumber(v)
  10893. return nil
  10894. case creditusage.FieldStatus:
  10895. v, ok := value.(int)
  10896. if !ok {
  10897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10898. }
  10899. m.SetStatus(v)
  10900. return nil
  10901. case creditusage.FieldNtype:
  10902. v, ok := value.(int)
  10903. if !ok {
  10904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10905. }
  10906. m.SetNtype(v)
  10907. return nil
  10908. case creditusage.FieldTable:
  10909. v, ok := value.(string)
  10910. if !ok {
  10911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10912. }
  10913. m.SetTable(v)
  10914. return nil
  10915. case creditusage.FieldOrganizationID:
  10916. v, ok := value.(uint64)
  10917. if !ok {
  10918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10919. }
  10920. m.SetOrganizationID(v)
  10921. return nil
  10922. case creditusage.FieldNid:
  10923. v, ok := value.(uint64)
  10924. if !ok {
  10925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10926. }
  10927. m.SetNid(v)
  10928. return nil
  10929. case creditusage.FieldReason:
  10930. v, ok := value.(string)
  10931. if !ok {
  10932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10933. }
  10934. m.SetReason(v)
  10935. return nil
  10936. case creditusage.FieldOperator:
  10937. v, ok := value.(string)
  10938. if !ok {
  10939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10940. }
  10941. m.SetOperator(v)
  10942. return nil
  10943. }
  10944. return fmt.Errorf("unknown CreditUsage field %s", name)
  10945. }
  10946. // AddedFields returns all numeric fields that were incremented/decremented during
  10947. // this mutation.
  10948. func (m *CreditUsageMutation) AddedFields() []string {
  10949. var fields []string
  10950. if m.addnumber != nil {
  10951. fields = append(fields, creditusage.FieldNumber)
  10952. }
  10953. if m.addstatus != nil {
  10954. fields = append(fields, creditusage.FieldStatus)
  10955. }
  10956. if m.addntype != nil {
  10957. fields = append(fields, creditusage.FieldNtype)
  10958. }
  10959. if m.addorganization_id != nil {
  10960. fields = append(fields, creditusage.FieldOrganizationID)
  10961. }
  10962. if m.addnid != nil {
  10963. fields = append(fields, creditusage.FieldNid)
  10964. }
  10965. return fields
  10966. }
  10967. // AddedField returns the numeric value that was incremented/decremented on a field
  10968. // with the given name. The second boolean return value indicates that this field
  10969. // was not set, or was not defined in the schema.
  10970. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10971. switch name {
  10972. case creditusage.FieldNumber:
  10973. return m.AddedNumber()
  10974. case creditusage.FieldStatus:
  10975. return m.AddedStatus()
  10976. case creditusage.FieldNtype:
  10977. return m.AddedNtype()
  10978. case creditusage.FieldOrganizationID:
  10979. return m.AddedOrganizationID()
  10980. case creditusage.FieldNid:
  10981. return m.AddedNid()
  10982. }
  10983. return nil, false
  10984. }
  10985. // AddField adds the value to the field with the given name. It returns an error if
  10986. // the field is not defined in the schema, or if the type mismatched the field
  10987. // type.
  10988. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10989. switch name {
  10990. case creditusage.FieldNumber:
  10991. v, ok := value.(float32)
  10992. if !ok {
  10993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10994. }
  10995. m.AddNumber(v)
  10996. return nil
  10997. case creditusage.FieldStatus:
  10998. v, ok := value.(int)
  10999. if !ok {
  11000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11001. }
  11002. m.AddStatus(v)
  11003. return nil
  11004. case creditusage.FieldNtype:
  11005. v, ok := value.(int)
  11006. if !ok {
  11007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11008. }
  11009. m.AddNtype(v)
  11010. return nil
  11011. case creditusage.FieldOrganizationID:
  11012. v, ok := value.(int64)
  11013. if !ok {
  11014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11015. }
  11016. m.AddOrganizationID(v)
  11017. return nil
  11018. case creditusage.FieldNid:
  11019. v, ok := value.(int64)
  11020. if !ok {
  11021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11022. }
  11023. m.AddNid(v)
  11024. return nil
  11025. }
  11026. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11027. }
  11028. // ClearedFields returns all nullable fields that were cleared during this
  11029. // mutation.
  11030. func (m *CreditUsageMutation) ClearedFields() []string {
  11031. var fields []string
  11032. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11033. fields = append(fields, creditusage.FieldDeletedAt)
  11034. }
  11035. if m.FieldCleared(creditusage.FieldStatus) {
  11036. fields = append(fields, creditusage.FieldStatus)
  11037. }
  11038. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11039. fields = append(fields, creditusage.FieldOrganizationID)
  11040. }
  11041. return fields
  11042. }
  11043. // FieldCleared returns a boolean indicating if a field with the given name was
  11044. // cleared in this mutation.
  11045. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11046. _, ok := m.clearedFields[name]
  11047. return ok
  11048. }
  11049. // ClearField clears the value of the field with the given name. It returns an
  11050. // error if the field is not defined in the schema.
  11051. func (m *CreditUsageMutation) ClearField(name string) error {
  11052. switch name {
  11053. case creditusage.FieldDeletedAt:
  11054. m.ClearDeletedAt()
  11055. return nil
  11056. case creditusage.FieldStatus:
  11057. m.ClearStatus()
  11058. return nil
  11059. case creditusage.FieldOrganizationID:
  11060. m.ClearOrganizationID()
  11061. return nil
  11062. }
  11063. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11064. }
  11065. // ResetField resets all changes in the mutation for the field with the given name.
  11066. // It returns an error if the field is not defined in the schema.
  11067. func (m *CreditUsageMutation) ResetField(name string) error {
  11068. switch name {
  11069. case creditusage.FieldCreatedAt:
  11070. m.ResetCreatedAt()
  11071. return nil
  11072. case creditusage.FieldUpdatedAt:
  11073. m.ResetUpdatedAt()
  11074. return nil
  11075. case creditusage.FieldDeletedAt:
  11076. m.ResetDeletedAt()
  11077. return nil
  11078. case creditusage.FieldUserID:
  11079. m.ResetUserID()
  11080. return nil
  11081. case creditusage.FieldNumber:
  11082. m.ResetNumber()
  11083. return nil
  11084. case creditusage.FieldStatus:
  11085. m.ResetStatus()
  11086. return nil
  11087. case creditusage.FieldNtype:
  11088. m.ResetNtype()
  11089. return nil
  11090. case creditusage.FieldTable:
  11091. m.ResetTable()
  11092. return nil
  11093. case creditusage.FieldOrganizationID:
  11094. m.ResetOrganizationID()
  11095. return nil
  11096. case creditusage.FieldNid:
  11097. m.ResetNid()
  11098. return nil
  11099. case creditusage.FieldReason:
  11100. m.ResetReason()
  11101. return nil
  11102. case creditusage.FieldOperator:
  11103. m.ResetOperator()
  11104. return nil
  11105. }
  11106. return fmt.Errorf("unknown CreditUsage field %s", name)
  11107. }
  11108. // AddedEdges returns all edge names that were set/added in this mutation.
  11109. func (m *CreditUsageMutation) AddedEdges() []string {
  11110. edges := make([]string, 0, 0)
  11111. return edges
  11112. }
  11113. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11114. // name in this mutation.
  11115. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11116. return nil
  11117. }
  11118. // RemovedEdges returns all edge names that were removed in this mutation.
  11119. func (m *CreditUsageMutation) RemovedEdges() []string {
  11120. edges := make([]string, 0, 0)
  11121. return edges
  11122. }
  11123. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11124. // the given name in this mutation.
  11125. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11126. return nil
  11127. }
  11128. // ClearedEdges returns all edge names that were cleared in this mutation.
  11129. func (m *CreditUsageMutation) ClearedEdges() []string {
  11130. edges := make([]string, 0, 0)
  11131. return edges
  11132. }
  11133. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11134. // was cleared in this mutation.
  11135. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11136. return false
  11137. }
  11138. // ClearEdge clears the value of the edge with the given name. It returns an error
  11139. // if that edge is not defined in the schema.
  11140. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11141. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11142. }
  11143. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11144. // It returns an error if the edge is not defined in the schema.
  11145. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11146. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11147. }
  11148. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11149. type EmployeeMutation struct {
  11150. config
  11151. op Op
  11152. typ string
  11153. id *uint64
  11154. created_at *time.Time
  11155. updated_at *time.Time
  11156. deleted_at *time.Time
  11157. title *string
  11158. avatar *string
  11159. tags *string
  11160. hire_count *int
  11161. addhire_count *int
  11162. service_count *int
  11163. addservice_count *int
  11164. achievement_count *int
  11165. addachievement_count *int
  11166. intro *string
  11167. estimate *string
  11168. skill *string
  11169. ability_type *string
  11170. scene *string
  11171. switch_in *string
  11172. video_url *string
  11173. organization_id *uint64
  11174. addorganization_id *int64
  11175. category_id *uint64
  11176. addcategory_id *int64
  11177. api_base *string
  11178. api_key *string
  11179. ai_info *string
  11180. is_vip *int
  11181. addis_vip *int
  11182. chat_url *string
  11183. clearedFields map[string]struct{}
  11184. em_work_experiences map[uint64]struct{}
  11185. removedem_work_experiences map[uint64]struct{}
  11186. clearedem_work_experiences bool
  11187. em_tutorial map[uint64]struct{}
  11188. removedem_tutorial map[uint64]struct{}
  11189. clearedem_tutorial bool
  11190. done bool
  11191. oldValue func(context.Context) (*Employee, error)
  11192. predicates []predicate.Employee
  11193. }
  11194. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11195. // employeeOption allows management of the mutation configuration using functional options.
  11196. type employeeOption func(*EmployeeMutation)
  11197. // newEmployeeMutation creates new mutation for the Employee entity.
  11198. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11199. m := &EmployeeMutation{
  11200. config: c,
  11201. op: op,
  11202. typ: TypeEmployee,
  11203. clearedFields: make(map[string]struct{}),
  11204. }
  11205. for _, opt := range opts {
  11206. opt(m)
  11207. }
  11208. return m
  11209. }
  11210. // withEmployeeID sets the ID field of the mutation.
  11211. func withEmployeeID(id uint64) employeeOption {
  11212. return func(m *EmployeeMutation) {
  11213. var (
  11214. err error
  11215. once sync.Once
  11216. value *Employee
  11217. )
  11218. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11219. once.Do(func() {
  11220. if m.done {
  11221. err = errors.New("querying old values post mutation is not allowed")
  11222. } else {
  11223. value, err = m.Client().Employee.Get(ctx, id)
  11224. }
  11225. })
  11226. return value, err
  11227. }
  11228. m.id = &id
  11229. }
  11230. }
  11231. // withEmployee sets the old Employee of the mutation.
  11232. func withEmployee(node *Employee) employeeOption {
  11233. return func(m *EmployeeMutation) {
  11234. m.oldValue = func(context.Context) (*Employee, error) {
  11235. return node, nil
  11236. }
  11237. m.id = &node.ID
  11238. }
  11239. }
  11240. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11241. // executed in a transaction (ent.Tx), a transactional client is returned.
  11242. func (m EmployeeMutation) Client() *Client {
  11243. client := &Client{config: m.config}
  11244. client.init()
  11245. return client
  11246. }
  11247. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11248. // it returns an error otherwise.
  11249. func (m EmployeeMutation) Tx() (*Tx, error) {
  11250. if _, ok := m.driver.(*txDriver); !ok {
  11251. return nil, errors.New("ent: mutation is not running in a transaction")
  11252. }
  11253. tx := &Tx{config: m.config}
  11254. tx.init()
  11255. return tx, nil
  11256. }
  11257. // SetID sets the value of the id field. Note that this
  11258. // operation is only accepted on creation of Employee entities.
  11259. func (m *EmployeeMutation) SetID(id uint64) {
  11260. m.id = &id
  11261. }
  11262. // ID returns the ID value in the mutation. Note that the ID is only available
  11263. // if it was provided to the builder or after it was returned from the database.
  11264. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11265. if m.id == nil {
  11266. return
  11267. }
  11268. return *m.id, true
  11269. }
  11270. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11271. // That means, if the mutation is applied within a transaction with an isolation level such
  11272. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11273. // or updated by the mutation.
  11274. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11275. switch {
  11276. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11277. id, exists := m.ID()
  11278. if exists {
  11279. return []uint64{id}, nil
  11280. }
  11281. fallthrough
  11282. case m.op.Is(OpUpdate | OpDelete):
  11283. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11284. default:
  11285. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11286. }
  11287. }
  11288. // SetCreatedAt sets the "created_at" field.
  11289. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11290. m.created_at = &t
  11291. }
  11292. // CreatedAt returns the value of the "created_at" field in the mutation.
  11293. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11294. v := m.created_at
  11295. if v == nil {
  11296. return
  11297. }
  11298. return *v, true
  11299. }
  11300. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11301. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11303. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11304. if !m.op.Is(OpUpdateOne) {
  11305. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11306. }
  11307. if m.id == nil || m.oldValue == nil {
  11308. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11309. }
  11310. oldValue, err := m.oldValue(ctx)
  11311. if err != nil {
  11312. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11313. }
  11314. return oldValue.CreatedAt, nil
  11315. }
  11316. // ResetCreatedAt resets all changes to the "created_at" field.
  11317. func (m *EmployeeMutation) ResetCreatedAt() {
  11318. m.created_at = nil
  11319. }
  11320. // SetUpdatedAt sets the "updated_at" field.
  11321. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11322. m.updated_at = &t
  11323. }
  11324. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11325. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11326. v := m.updated_at
  11327. if v == nil {
  11328. return
  11329. }
  11330. return *v, true
  11331. }
  11332. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11333. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11335. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11336. if !m.op.Is(OpUpdateOne) {
  11337. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11338. }
  11339. if m.id == nil || m.oldValue == nil {
  11340. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11341. }
  11342. oldValue, err := m.oldValue(ctx)
  11343. if err != nil {
  11344. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11345. }
  11346. return oldValue.UpdatedAt, nil
  11347. }
  11348. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11349. func (m *EmployeeMutation) ResetUpdatedAt() {
  11350. m.updated_at = nil
  11351. }
  11352. // SetDeletedAt sets the "deleted_at" field.
  11353. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11354. m.deleted_at = &t
  11355. }
  11356. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11357. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11358. v := m.deleted_at
  11359. if v == nil {
  11360. return
  11361. }
  11362. return *v, true
  11363. }
  11364. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11365. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11367. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11368. if !m.op.Is(OpUpdateOne) {
  11369. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11370. }
  11371. if m.id == nil || m.oldValue == nil {
  11372. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11373. }
  11374. oldValue, err := m.oldValue(ctx)
  11375. if err != nil {
  11376. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11377. }
  11378. return oldValue.DeletedAt, nil
  11379. }
  11380. // ClearDeletedAt clears the value of the "deleted_at" field.
  11381. func (m *EmployeeMutation) ClearDeletedAt() {
  11382. m.deleted_at = nil
  11383. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11384. }
  11385. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11386. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11387. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11388. return ok
  11389. }
  11390. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11391. func (m *EmployeeMutation) ResetDeletedAt() {
  11392. m.deleted_at = nil
  11393. delete(m.clearedFields, employee.FieldDeletedAt)
  11394. }
  11395. // SetTitle sets the "title" field.
  11396. func (m *EmployeeMutation) SetTitle(s string) {
  11397. m.title = &s
  11398. }
  11399. // Title returns the value of the "title" field in the mutation.
  11400. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11401. v := m.title
  11402. if v == nil {
  11403. return
  11404. }
  11405. return *v, true
  11406. }
  11407. // OldTitle returns the old "title" field's value of the Employee entity.
  11408. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11410. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11411. if !m.op.Is(OpUpdateOne) {
  11412. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11413. }
  11414. if m.id == nil || m.oldValue == nil {
  11415. return v, errors.New("OldTitle requires an ID field in the mutation")
  11416. }
  11417. oldValue, err := m.oldValue(ctx)
  11418. if err != nil {
  11419. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11420. }
  11421. return oldValue.Title, nil
  11422. }
  11423. // ResetTitle resets all changes to the "title" field.
  11424. func (m *EmployeeMutation) ResetTitle() {
  11425. m.title = nil
  11426. }
  11427. // SetAvatar sets the "avatar" field.
  11428. func (m *EmployeeMutation) SetAvatar(s string) {
  11429. m.avatar = &s
  11430. }
  11431. // Avatar returns the value of the "avatar" field in the mutation.
  11432. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11433. v := m.avatar
  11434. if v == nil {
  11435. return
  11436. }
  11437. return *v, true
  11438. }
  11439. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11440. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11442. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11443. if !m.op.Is(OpUpdateOne) {
  11444. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11445. }
  11446. if m.id == nil || m.oldValue == nil {
  11447. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11448. }
  11449. oldValue, err := m.oldValue(ctx)
  11450. if err != nil {
  11451. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11452. }
  11453. return oldValue.Avatar, nil
  11454. }
  11455. // ResetAvatar resets all changes to the "avatar" field.
  11456. func (m *EmployeeMutation) ResetAvatar() {
  11457. m.avatar = nil
  11458. }
  11459. // SetTags sets the "tags" field.
  11460. func (m *EmployeeMutation) SetTags(s string) {
  11461. m.tags = &s
  11462. }
  11463. // Tags returns the value of the "tags" field in the mutation.
  11464. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11465. v := m.tags
  11466. if v == nil {
  11467. return
  11468. }
  11469. return *v, true
  11470. }
  11471. // OldTags returns the old "tags" field's value of the Employee entity.
  11472. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11474. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11475. if !m.op.Is(OpUpdateOne) {
  11476. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11477. }
  11478. if m.id == nil || m.oldValue == nil {
  11479. return v, errors.New("OldTags requires an ID field in the mutation")
  11480. }
  11481. oldValue, err := m.oldValue(ctx)
  11482. if err != nil {
  11483. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11484. }
  11485. return oldValue.Tags, nil
  11486. }
  11487. // ResetTags resets all changes to the "tags" field.
  11488. func (m *EmployeeMutation) ResetTags() {
  11489. m.tags = nil
  11490. }
  11491. // SetHireCount sets the "hire_count" field.
  11492. func (m *EmployeeMutation) SetHireCount(i int) {
  11493. m.hire_count = &i
  11494. m.addhire_count = nil
  11495. }
  11496. // HireCount returns the value of the "hire_count" field in the mutation.
  11497. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11498. v := m.hire_count
  11499. if v == nil {
  11500. return
  11501. }
  11502. return *v, true
  11503. }
  11504. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11505. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11507. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11508. if !m.op.Is(OpUpdateOne) {
  11509. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11510. }
  11511. if m.id == nil || m.oldValue == nil {
  11512. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11513. }
  11514. oldValue, err := m.oldValue(ctx)
  11515. if err != nil {
  11516. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11517. }
  11518. return oldValue.HireCount, nil
  11519. }
  11520. // AddHireCount adds i to the "hire_count" field.
  11521. func (m *EmployeeMutation) AddHireCount(i int) {
  11522. if m.addhire_count != nil {
  11523. *m.addhire_count += i
  11524. } else {
  11525. m.addhire_count = &i
  11526. }
  11527. }
  11528. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11529. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11530. v := m.addhire_count
  11531. if v == nil {
  11532. return
  11533. }
  11534. return *v, true
  11535. }
  11536. // ResetHireCount resets all changes to the "hire_count" field.
  11537. func (m *EmployeeMutation) ResetHireCount() {
  11538. m.hire_count = nil
  11539. m.addhire_count = nil
  11540. }
  11541. // SetServiceCount sets the "service_count" field.
  11542. func (m *EmployeeMutation) SetServiceCount(i int) {
  11543. m.service_count = &i
  11544. m.addservice_count = nil
  11545. }
  11546. // ServiceCount returns the value of the "service_count" field in the mutation.
  11547. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11548. v := m.service_count
  11549. if v == nil {
  11550. return
  11551. }
  11552. return *v, true
  11553. }
  11554. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11555. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11557. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11558. if !m.op.Is(OpUpdateOne) {
  11559. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11560. }
  11561. if m.id == nil || m.oldValue == nil {
  11562. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11563. }
  11564. oldValue, err := m.oldValue(ctx)
  11565. if err != nil {
  11566. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11567. }
  11568. return oldValue.ServiceCount, nil
  11569. }
  11570. // AddServiceCount adds i to the "service_count" field.
  11571. func (m *EmployeeMutation) AddServiceCount(i int) {
  11572. if m.addservice_count != nil {
  11573. *m.addservice_count += i
  11574. } else {
  11575. m.addservice_count = &i
  11576. }
  11577. }
  11578. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11579. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11580. v := m.addservice_count
  11581. if v == nil {
  11582. return
  11583. }
  11584. return *v, true
  11585. }
  11586. // ResetServiceCount resets all changes to the "service_count" field.
  11587. func (m *EmployeeMutation) ResetServiceCount() {
  11588. m.service_count = nil
  11589. m.addservice_count = nil
  11590. }
  11591. // SetAchievementCount sets the "achievement_count" field.
  11592. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11593. m.achievement_count = &i
  11594. m.addachievement_count = nil
  11595. }
  11596. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11597. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11598. v := m.achievement_count
  11599. if v == nil {
  11600. return
  11601. }
  11602. return *v, true
  11603. }
  11604. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11605. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11607. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11608. if !m.op.Is(OpUpdateOne) {
  11609. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11610. }
  11611. if m.id == nil || m.oldValue == nil {
  11612. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11613. }
  11614. oldValue, err := m.oldValue(ctx)
  11615. if err != nil {
  11616. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11617. }
  11618. return oldValue.AchievementCount, nil
  11619. }
  11620. // AddAchievementCount adds i to the "achievement_count" field.
  11621. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11622. if m.addachievement_count != nil {
  11623. *m.addachievement_count += i
  11624. } else {
  11625. m.addachievement_count = &i
  11626. }
  11627. }
  11628. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11629. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11630. v := m.addachievement_count
  11631. if v == nil {
  11632. return
  11633. }
  11634. return *v, true
  11635. }
  11636. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11637. func (m *EmployeeMutation) ResetAchievementCount() {
  11638. m.achievement_count = nil
  11639. m.addachievement_count = nil
  11640. }
  11641. // SetIntro sets the "intro" field.
  11642. func (m *EmployeeMutation) SetIntro(s string) {
  11643. m.intro = &s
  11644. }
  11645. // Intro returns the value of the "intro" field in the mutation.
  11646. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11647. v := m.intro
  11648. if v == nil {
  11649. return
  11650. }
  11651. return *v, true
  11652. }
  11653. // OldIntro returns the old "intro" field's value of the Employee entity.
  11654. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11656. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11657. if !m.op.Is(OpUpdateOne) {
  11658. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11659. }
  11660. if m.id == nil || m.oldValue == nil {
  11661. return v, errors.New("OldIntro requires an ID field in the mutation")
  11662. }
  11663. oldValue, err := m.oldValue(ctx)
  11664. if err != nil {
  11665. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11666. }
  11667. return oldValue.Intro, nil
  11668. }
  11669. // ResetIntro resets all changes to the "intro" field.
  11670. func (m *EmployeeMutation) ResetIntro() {
  11671. m.intro = nil
  11672. }
  11673. // SetEstimate sets the "estimate" field.
  11674. func (m *EmployeeMutation) SetEstimate(s string) {
  11675. m.estimate = &s
  11676. }
  11677. // Estimate returns the value of the "estimate" field in the mutation.
  11678. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11679. v := m.estimate
  11680. if v == nil {
  11681. return
  11682. }
  11683. return *v, true
  11684. }
  11685. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11686. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11688. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11689. if !m.op.Is(OpUpdateOne) {
  11690. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11691. }
  11692. if m.id == nil || m.oldValue == nil {
  11693. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11694. }
  11695. oldValue, err := m.oldValue(ctx)
  11696. if err != nil {
  11697. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11698. }
  11699. return oldValue.Estimate, nil
  11700. }
  11701. // ResetEstimate resets all changes to the "estimate" field.
  11702. func (m *EmployeeMutation) ResetEstimate() {
  11703. m.estimate = nil
  11704. }
  11705. // SetSkill sets the "skill" field.
  11706. func (m *EmployeeMutation) SetSkill(s string) {
  11707. m.skill = &s
  11708. }
  11709. // Skill returns the value of the "skill" field in the mutation.
  11710. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11711. v := m.skill
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldSkill returns the old "skill" field's value of the Employee entity.
  11718. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldSkill requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11730. }
  11731. return oldValue.Skill, nil
  11732. }
  11733. // ResetSkill resets all changes to the "skill" field.
  11734. func (m *EmployeeMutation) ResetSkill() {
  11735. m.skill = nil
  11736. }
  11737. // SetAbilityType sets the "ability_type" field.
  11738. func (m *EmployeeMutation) SetAbilityType(s string) {
  11739. m.ability_type = &s
  11740. }
  11741. // AbilityType returns the value of the "ability_type" field in the mutation.
  11742. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11743. v := m.ability_type
  11744. if v == nil {
  11745. return
  11746. }
  11747. return *v, true
  11748. }
  11749. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11750. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11752. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11753. if !m.op.Is(OpUpdateOne) {
  11754. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11755. }
  11756. if m.id == nil || m.oldValue == nil {
  11757. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11758. }
  11759. oldValue, err := m.oldValue(ctx)
  11760. if err != nil {
  11761. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11762. }
  11763. return oldValue.AbilityType, nil
  11764. }
  11765. // ResetAbilityType resets all changes to the "ability_type" field.
  11766. func (m *EmployeeMutation) ResetAbilityType() {
  11767. m.ability_type = nil
  11768. }
  11769. // SetScene sets the "scene" field.
  11770. func (m *EmployeeMutation) SetScene(s string) {
  11771. m.scene = &s
  11772. }
  11773. // Scene returns the value of the "scene" field in the mutation.
  11774. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11775. v := m.scene
  11776. if v == nil {
  11777. return
  11778. }
  11779. return *v, true
  11780. }
  11781. // OldScene returns the old "scene" field's value of the Employee entity.
  11782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11784. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11785. if !m.op.Is(OpUpdateOne) {
  11786. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11787. }
  11788. if m.id == nil || m.oldValue == nil {
  11789. return v, errors.New("OldScene requires an ID field in the mutation")
  11790. }
  11791. oldValue, err := m.oldValue(ctx)
  11792. if err != nil {
  11793. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11794. }
  11795. return oldValue.Scene, nil
  11796. }
  11797. // ResetScene resets all changes to the "scene" field.
  11798. func (m *EmployeeMutation) ResetScene() {
  11799. m.scene = nil
  11800. }
  11801. // SetSwitchIn sets the "switch_in" field.
  11802. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11803. m.switch_in = &s
  11804. }
  11805. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11806. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11807. v := m.switch_in
  11808. if v == nil {
  11809. return
  11810. }
  11811. return *v, true
  11812. }
  11813. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11814. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11816. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11817. if !m.op.Is(OpUpdateOne) {
  11818. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11819. }
  11820. if m.id == nil || m.oldValue == nil {
  11821. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11822. }
  11823. oldValue, err := m.oldValue(ctx)
  11824. if err != nil {
  11825. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11826. }
  11827. return oldValue.SwitchIn, nil
  11828. }
  11829. // ResetSwitchIn resets all changes to the "switch_in" field.
  11830. func (m *EmployeeMutation) ResetSwitchIn() {
  11831. m.switch_in = nil
  11832. }
  11833. // SetVideoURL sets the "video_url" field.
  11834. func (m *EmployeeMutation) SetVideoURL(s string) {
  11835. m.video_url = &s
  11836. }
  11837. // VideoURL returns the value of the "video_url" field in the mutation.
  11838. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11839. v := m.video_url
  11840. if v == nil {
  11841. return
  11842. }
  11843. return *v, true
  11844. }
  11845. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11846. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11848. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11849. if !m.op.Is(OpUpdateOne) {
  11850. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11851. }
  11852. if m.id == nil || m.oldValue == nil {
  11853. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11854. }
  11855. oldValue, err := m.oldValue(ctx)
  11856. if err != nil {
  11857. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11858. }
  11859. return oldValue.VideoURL, nil
  11860. }
  11861. // ResetVideoURL resets all changes to the "video_url" field.
  11862. func (m *EmployeeMutation) ResetVideoURL() {
  11863. m.video_url = nil
  11864. }
  11865. // SetOrganizationID sets the "organization_id" field.
  11866. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11867. m.organization_id = &u
  11868. m.addorganization_id = nil
  11869. }
  11870. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11871. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11872. v := m.organization_id
  11873. if v == nil {
  11874. return
  11875. }
  11876. return *v, true
  11877. }
  11878. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11879. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11881. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11882. if !m.op.Is(OpUpdateOne) {
  11883. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11884. }
  11885. if m.id == nil || m.oldValue == nil {
  11886. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11887. }
  11888. oldValue, err := m.oldValue(ctx)
  11889. if err != nil {
  11890. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11891. }
  11892. return oldValue.OrganizationID, nil
  11893. }
  11894. // AddOrganizationID adds u to the "organization_id" field.
  11895. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11896. if m.addorganization_id != nil {
  11897. *m.addorganization_id += u
  11898. } else {
  11899. m.addorganization_id = &u
  11900. }
  11901. }
  11902. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11903. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11904. v := m.addorganization_id
  11905. if v == nil {
  11906. return
  11907. }
  11908. return *v, true
  11909. }
  11910. // ResetOrganizationID resets all changes to the "organization_id" field.
  11911. func (m *EmployeeMutation) ResetOrganizationID() {
  11912. m.organization_id = nil
  11913. m.addorganization_id = nil
  11914. }
  11915. // SetCategoryID sets the "category_id" field.
  11916. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11917. m.category_id = &u
  11918. m.addcategory_id = nil
  11919. }
  11920. // CategoryID returns the value of the "category_id" field in the mutation.
  11921. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11922. v := m.category_id
  11923. if v == nil {
  11924. return
  11925. }
  11926. return *v, true
  11927. }
  11928. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11929. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11931. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11932. if !m.op.Is(OpUpdateOne) {
  11933. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11934. }
  11935. if m.id == nil || m.oldValue == nil {
  11936. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11937. }
  11938. oldValue, err := m.oldValue(ctx)
  11939. if err != nil {
  11940. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11941. }
  11942. return oldValue.CategoryID, nil
  11943. }
  11944. // AddCategoryID adds u to the "category_id" field.
  11945. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11946. if m.addcategory_id != nil {
  11947. *m.addcategory_id += u
  11948. } else {
  11949. m.addcategory_id = &u
  11950. }
  11951. }
  11952. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11953. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11954. v := m.addcategory_id
  11955. if v == nil {
  11956. return
  11957. }
  11958. return *v, true
  11959. }
  11960. // ResetCategoryID resets all changes to the "category_id" field.
  11961. func (m *EmployeeMutation) ResetCategoryID() {
  11962. m.category_id = nil
  11963. m.addcategory_id = nil
  11964. }
  11965. // SetAPIBase sets the "api_base" field.
  11966. func (m *EmployeeMutation) SetAPIBase(s string) {
  11967. m.api_base = &s
  11968. }
  11969. // APIBase returns the value of the "api_base" field in the mutation.
  11970. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11971. v := m.api_base
  11972. if v == nil {
  11973. return
  11974. }
  11975. return *v, true
  11976. }
  11977. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11978. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11980. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11981. if !m.op.Is(OpUpdateOne) {
  11982. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11983. }
  11984. if m.id == nil || m.oldValue == nil {
  11985. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11986. }
  11987. oldValue, err := m.oldValue(ctx)
  11988. if err != nil {
  11989. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11990. }
  11991. return oldValue.APIBase, nil
  11992. }
  11993. // ResetAPIBase resets all changes to the "api_base" field.
  11994. func (m *EmployeeMutation) ResetAPIBase() {
  11995. m.api_base = nil
  11996. }
  11997. // SetAPIKey sets the "api_key" field.
  11998. func (m *EmployeeMutation) SetAPIKey(s string) {
  11999. m.api_key = &s
  12000. }
  12001. // APIKey returns the value of the "api_key" field in the mutation.
  12002. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12003. v := m.api_key
  12004. if v == nil {
  12005. return
  12006. }
  12007. return *v, true
  12008. }
  12009. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12010. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12012. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12013. if !m.op.Is(OpUpdateOne) {
  12014. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12015. }
  12016. if m.id == nil || m.oldValue == nil {
  12017. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12018. }
  12019. oldValue, err := m.oldValue(ctx)
  12020. if err != nil {
  12021. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12022. }
  12023. return oldValue.APIKey, nil
  12024. }
  12025. // ResetAPIKey resets all changes to the "api_key" field.
  12026. func (m *EmployeeMutation) ResetAPIKey() {
  12027. m.api_key = nil
  12028. }
  12029. // SetAiInfo sets the "ai_info" field.
  12030. func (m *EmployeeMutation) SetAiInfo(s string) {
  12031. m.ai_info = &s
  12032. }
  12033. // AiInfo returns the value of the "ai_info" field in the mutation.
  12034. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12035. v := m.ai_info
  12036. if v == nil {
  12037. return
  12038. }
  12039. return *v, true
  12040. }
  12041. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12042. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12044. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12045. if !m.op.Is(OpUpdateOne) {
  12046. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12047. }
  12048. if m.id == nil || m.oldValue == nil {
  12049. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12050. }
  12051. oldValue, err := m.oldValue(ctx)
  12052. if err != nil {
  12053. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12054. }
  12055. return oldValue.AiInfo, nil
  12056. }
  12057. // ClearAiInfo clears the value of the "ai_info" field.
  12058. func (m *EmployeeMutation) ClearAiInfo() {
  12059. m.ai_info = nil
  12060. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12061. }
  12062. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12063. func (m *EmployeeMutation) AiInfoCleared() bool {
  12064. _, ok := m.clearedFields[employee.FieldAiInfo]
  12065. return ok
  12066. }
  12067. // ResetAiInfo resets all changes to the "ai_info" field.
  12068. func (m *EmployeeMutation) ResetAiInfo() {
  12069. m.ai_info = nil
  12070. delete(m.clearedFields, employee.FieldAiInfo)
  12071. }
  12072. // SetIsVip sets the "is_vip" field.
  12073. func (m *EmployeeMutation) SetIsVip(i int) {
  12074. m.is_vip = &i
  12075. m.addis_vip = nil
  12076. }
  12077. // IsVip returns the value of the "is_vip" field in the mutation.
  12078. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12079. v := m.is_vip
  12080. if v == nil {
  12081. return
  12082. }
  12083. return *v, true
  12084. }
  12085. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12086. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12088. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12089. if !m.op.Is(OpUpdateOne) {
  12090. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12091. }
  12092. if m.id == nil || m.oldValue == nil {
  12093. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12094. }
  12095. oldValue, err := m.oldValue(ctx)
  12096. if err != nil {
  12097. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12098. }
  12099. return oldValue.IsVip, nil
  12100. }
  12101. // AddIsVip adds i to the "is_vip" field.
  12102. func (m *EmployeeMutation) AddIsVip(i int) {
  12103. if m.addis_vip != nil {
  12104. *m.addis_vip += i
  12105. } else {
  12106. m.addis_vip = &i
  12107. }
  12108. }
  12109. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12110. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12111. v := m.addis_vip
  12112. if v == nil {
  12113. return
  12114. }
  12115. return *v, true
  12116. }
  12117. // ResetIsVip resets all changes to the "is_vip" field.
  12118. func (m *EmployeeMutation) ResetIsVip() {
  12119. m.is_vip = nil
  12120. m.addis_vip = nil
  12121. }
  12122. // SetChatURL sets the "chat_url" field.
  12123. func (m *EmployeeMutation) SetChatURL(s string) {
  12124. m.chat_url = &s
  12125. }
  12126. // ChatURL returns the value of the "chat_url" field in the mutation.
  12127. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12128. v := m.chat_url
  12129. if v == nil {
  12130. return
  12131. }
  12132. return *v, true
  12133. }
  12134. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12135. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12137. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12138. if !m.op.Is(OpUpdateOne) {
  12139. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12140. }
  12141. if m.id == nil || m.oldValue == nil {
  12142. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12143. }
  12144. oldValue, err := m.oldValue(ctx)
  12145. if err != nil {
  12146. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12147. }
  12148. return oldValue.ChatURL, nil
  12149. }
  12150. // ResetChatURL resets all changes to the "chat_url" field.
  12151. func (m *EmployeeMutation) ResetChatURL() {
  12152. m.chat_url = nil
  12153. }
  12154. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12155. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12156. if m.em_work_experiences == nil {
  12157. m.em_work_experiences = make(map[uint64]struct{})
  12158. }
  12159. for i := range ids {
  12160. m.em_work_experiences[ids[i]] = struct{}{}
  12161. }
  12162. }
  12163. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12164. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12165. m.clearedem_work_experiences = true
  12166. }
  12167. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12168. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12169. return m.clearedem_work_experiences
  12170. }
  12171. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12172. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12173. if m.removedem_work_experiences == nil {
  12174. m.removedem_work_experiences = make(map[uint64]struct{})
  12175. }
  12176. for i := range ids {
  12177. delete(m.em_work_experiences, ids[i])
  12178. m.removedem_work_experiences[ids[i]] = struct{}{}
  12179. }
  12180. }
  12181. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12182. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12183. for id := range m.removedem_work_experiences {
  12184. ids = append(ids, id)
  12185. }
  12186. return
  12187. }
  12188. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12189. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12190. for id := range m.em_work_experiences {
  12191. ids = append(ids, id)
  12192. }
  12193. return
  12194. }
  12195. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12196. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12197. m.em_work_experiences = nil
  12198. m.clearedem_work_experiences = false
  12199. m.removedem_work_experiences = nil
  12200. }
  12201. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12202. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12203. if m.em_tutorial == nil {
  12204. m.em_tutorial = make(map[uint64]struct{})
  12205. }
  12206. for i := range ids {
  12207. m.em_tutorial[ids[i]] = struct{}{}
  12208. }
  12209. }
  12210. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12211. func (m *EmployeeMutation) ClearEmTutorial() {
  12212. m.clearedem_tutorial = true
  12213. }
  12214. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12215. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12216. return m.clearedem_tutorial
  12217. }
  12218. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12219. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12220. if m.removedem_tutorial == nil {
  12221. m.removedem_tutorial = make(map[uint64]struct{})
  12222. }
  12223. for i := range ids {
  12224. delete(m.em_tutorial, ids[i])
  12225. m.removedem_tutorial[ids[i]] = struct{}{}
  12226. }
  12227. }
  12228. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12229. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12230. for id := range m.removedem_tutorial {
  12231. ids = append(ids, id)
  12232. }
  12233. return
  12234. }
  12235. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12236. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12237. for id := range m.em_tutorial {
  12238. ids = append(ids, id)
  12239. }
  12240. return
  12241. }
  12242. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12243. func (m *EmployeeMutation) ResetEmTutorial() {
  12244. m.em_tutorial = nil
  12245. m.clearedem_tutorial = false
  12246. m.removedem_tutorial = nil
  12247. }
  12248. // Where appends a list predicates to the EmployeeMutation builder.
  12249. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12250. m.predicates = append(m.predicates, ps...)
  12251. }
  12252. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12253. // users can use type-assertion to append predicates that do not depend on any generated package.
  12254. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12255. p := make([]predicate.Employee, len(ps))
  12256. for i := range ps {
  12257. p[i] = ps[i]
  12258. }
  12259. m.Where(p...)
  12260. }
  12261. // Op returns the operation name.
  12262. func (m *EmployeeMutation) Op() Op {
  12263. return m.op
  12264. }
  12265. // SetOp allows setting the mutation operation.
  12266. func (m *EmployeeMutation) SetOp(op Op) {
  12267. m.op = op
  12268. }
  12269. // Type returns the node type of this mutation (Employee).
  12270. func (m *EmployeeMutation) Type() string {
  12271. return m.typ
  12272. }
  12273. // Fields returns all fields that were changed during this mutation. Note that in
  12274. // order to get all numeric fields that were incremented/decremented, call
  12275. // AddedFields().
  12276. func (m *EmployeeMutation) Fields() []string {
  12277. fields := make([]string, 0, 23)
  12278. if m.created_at != nil {
  12279. fields = append(fields, employee.FieldCreatedAt)
  12280. }
  12281. if m.updated_at != nil {
  12282. fields = append(fields, employee.FieldUpdatedAt)
  12283. }
  12284. if m.deleted_at != nil {
  12285. fields = append(fields, employee.FieldDeletedAt)
  12286. }
  12287. if m.title != nil {
  12288. fields = append(fields, employee.FieldTitle)
  12289. }
  12290. if m.avatar != nil {
  12291. fields = append(fields, employee.FieldAvatar)
  12292. }
  12293. if m.tags != nil {
  12294. fields = append(fields, employee.FieldTags)
  12295. }
  12296. if m.hire_count != nil {
  12297. fields = append(fields, employee.FieldHireCount)
  12298. }
  12299. if m.service_count != nil {
  12300. fields = append(fields, employee.FieldServiceCount)
  12301. }
  12302. if m.achievement_count != nil {
  12303. fields = append(fields, employee.FieldAchievementCount)
  12304. }
  12305. if m.intro != nil {
  12306. fields = append(fields, employee.FieldIntro)
  12307. }
  12308. if m.estimate != nil {
  12309. fields = append(fields, employee.FieldEstimate)
  12310. }
  12311. if m.skill != nil {
  12312. fields = append(fields, employee.FieldSkill)
  12313. }
  12314. if m.ability_type != nil {
  12315. fields = append(fields, employee.FieldAbilityType)
  12316. }
  12317. if m.scene != nil {
  12318. fields = append(fields, employee.FieldScene)
  12319. }
  12320. if m.switch_in != nil {
  12321. fields = append(fields, employee.FieldSwitchIn)
  12322. }
  12323. if m.video_url != nil {
  12324. fields = append(fields, employee.FieldVideoURL)
  12325. }
  12326. if m.organization_id != nil {
  12327. fields = append(fields, employee.FieldOrganizationID)
  12328. }
  12329. if m.category_id != nil {
  12330. fields = append(fields, employee.FieldCategoryID)
  12331. }
  12332. if m.api_base != nil {
  12333. fields = append(fields, employee.FieldAPIBase)
  12334. }
  12335. if m.api_key != nil {
  12336. fields = append(fields, employee.FieldAPIKey)
  12337. }
  12338. if m.ai_info != nil {
  12339. fields = append(fields, employee.FieldAiInfo)
  12340. }
  12341. if m.is_vip != nil {
  12342. fields = append(fields, employee.FieldIsVip)
  12343. }
  12344. if m.chat_url != nil {
  12345. fields = append(fields, employee.FieldChatURL)
  12346. }
  12347. return fields
  12348. }
  12349. // Field returns the value of a field with the given name. The second boolean
  12350. // return value indicates that this field was not set, or was not defined in the
  12351. // schema.
  12352. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12353. switch name {
  12354. case employee.FieldCreatedAt:
  12355. return m.CreatedAt()
  12356. case employee.FieldUpdatedAt:
  12357. return m.UpdatedAt()
  12358. case employee.FieldDeletedAt:
  12359. return m.DeletedAt()
  12360. case employee.FieldTitle:
  12361. return m.Title()
  12362. case employee.FieldAvatar:
  12363. return m.Avatar()
  12364. case employee.FieldTags:
  12365. return m.Tags()
  12366. case employee.FieldHireCount:
  12367. return m.HireCount()
  12368. case employee.FieldServiceCount:
  12369. return m.ServiceCount()
  12370. case employee.FieldAchievementCount:
  12371. return m.AchievementCount()
  12372. case employee.FieldIntro:
  12373. return m.Intro()
  12374. case employee.FieldEstimate:
  12375. return m.Estimate()
  12376. case employee.FieldSkill:
  12377. return m.Skill()
  12378. case employee.FieldAbilityType:
  12379. return m.AbilityType()
  12380. case employee.FieldScene:
  12381. return m.Scene()
  12382. case employee.FieldSwitchIn:
  12383. return m.SwitchIn()
  12384. case employee.FieldVideoURL:
  12385. return m.VideoURL()
  12386. case employee.FieldOrganizationID:
  12387. return m.OrganizationID()
  12388. case employee.FieldCategoryID:
  12389. return m.CategoryID()
  12390. case employee.FieldAPIBase:
  12391. return m.APIBase()
  12392. case employee.FieldAPIKey:
  12393. return m.APIKey()
  12394. case employee.FieldAiInfo:
  12395. return m.AiInfo()
  12396. case employee.FieldIsVip:
  12397. return m.IsVip()
  12398. case employee.FieldChatURL:
  12399. return m.ChatURL()
  12400. }
  12401. return nil, false
  12402. }
  12403. // OldField returns the old value of the field from the database. An error is
  12404. // returned if the mutation operation is not UpdateOne, or the query to the
  12405. // database failed.
  12406. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12407. switch name {
  12408. case employee.FieldCreatedAt:
  12409. return m.OldCreatedAt(ctx)
  12410. case employee.FieldUpdatedAt:
  12411. return m.OldUpdatedAt(ctx)
  12412. case employee.FieldDeletedAt:
  12413. return m.OldDeletedAt(ctx)
  12414. case employee.FieldTitle:
  12415. return m.OldTitle(ctx)
  12416. case employee.FieldAvatar:
  12417. return m.OldAvatar(ctx)
  12418. case employee.FieldTags:
  12419. return m.OldTags(ctx)
  12420. case employee.FieldHireCount:
  12421. return m.OldHireCount(ctx)
  12422. case employee.FieldServiceCount:
  12423. return m.OldServiceCount(ctx)
  12424. case employee.FieldAchievementCount:
  12425. return m.OldAchievementCount(ctx)
  12426. case employee.FieldIntro:
  12427. return m.OldIntro(ctx)
  12428. case employee.FieldEstimate:
  12429. return m.OldEstimate(ctx)
  12430. case employee.FieldSkill:
  12431. return m.OldSkill(ctx)
  12432. case employee.FieldAbilityType:
  12433. return m.OldAbilityType(ctx)
  12434. case employee.FieldScene:
  12435. return m.OldScene(ctx)
  12436. case employee.FieldSwitchIn:
  12437. return m.OldSwitchIn(ctx)
  12438. case employee.FieldVideoURL:
  12439. return m.OldVideoURL(ctx)
  12440. case employee.FieldOrganizationID:
  12441. return m.OldOrganizationID(ctx)
  12442. case employee.FieldCategoryID:
  12443. return m.OldCategoryID(ctx)
  12444. case employee.FieldAPIBase:
  12445. return m.OldAPIBase(ctx)
  12446. case employee.FieldAPIKey:
  12447. return m.OldAPIKey(ctx)
  12448. case employee.FieldAiInfo:
  12449. return m.OldAiInfo(ctx)
  12450. case employee.FieldIsVip:
  12451. return m.OldIsVip(ctx)
  12452. case employee.FieldChatURL:
  12453. return m.OldChatURL(ctx)
  12454. }
  12455. return nil, fmt.Errorf("unknown Employee field %s", name)
  12456. }
  12457. // SetField sets the value of a field with the given name. It returns an error if
  12458. // the field is not defined in the schema, or if the type mismatched the field
  12459. // type.
  12460. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12461. switch name {
  12462. case employee.FieldCreatedAt:
  12463. v, ok := value.(time.Time)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetCreatedAt(v)
  12468. return nil
  12469. case employee.FieldUpdatedAt:
  12470. v, ok := value.(time.Time)
  12471. if !ok {
  12472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12473. }
  12474. m.SetUpdatedAt(v)
  12475. return nil
  12476. case employee.FieldDeletedAt:
  12477. v, ok := value.(time.Time)
  12478. if !ok {
  12479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12480. }
  12481. m.SetDeletedAt(v)
  12482. return nil
  12483. case employee.FieldTitle:
  12484. v, ok := value.(string)
  12485. if !ok {
  12486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12487. }
  12488. m.SetTitle(v)
  12489. return nil
  12490. case employee.FieldAvatar:
  12491. v, ok := value.(string)
  12492. if !ok {
  12493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12494. }
  12495. m.SetAvatar(v)
  12496. return nil
  12497. case employee.FieldTags:
  12498. v, ok := value.(string)
  12499. if !ok {
  12500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12501. }
  12502. m.SetTags(v)
  12503. return nil
  12504. case employee.FieldHireCount:
  12505. v, ok := value.(int)
  12506. if !ok {
  12507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12508. }
  12509. m.SetHireCount(v)
  12510. return nil
  12511. case employee.FieldServiceCount:
  12512. v, ok := value.(int)
  12513. if !ok {
  12514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12515. }
  12516. m.SetServiceCount(v)
  12517. return nil
  12518. case employee.FieldAchievementCount:
  12519. v, ok := value.(int)
  12520. if !ok {
  12521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12522. }
  12523. m.SetAchievementCount(v)
  12524. return nil
  12525. case employee.FieldIntro:
  12526. v, ok := value.(string)
  12527. if !ok {
  12528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12529. }
  12530. m.SetIntro(v)
  12531. return nil
  12532. case employee.FieldEstimate:
  12533. v, ok := value.(string)
  12534. if !ok {
  12535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12536. }
  12537. m.SetEstimate(v)
  12538. return nil
  12539. case employee.FieldSkill:
  12540. v, ok := value.(string)
  12541. if !ok {
  12542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12543. }
  12544. m.SetSkill(v)
  12545. return nil
  12546. case employee.FieldAbilityType:
  12547. v, ok := value.(string)
  12548. if !ok {
  12549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12550. }
  12551. m.SetAbilityType(v)
  12552. return nil
  12553. case employee.FieldScene:
  12554. v, ok := value.(string)
  12555. if !ok {
  12556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12557. }
  12558. m.SetScene(v)
  12559. return nil
  12560. case employee.FieldSwitchIn:
  12561. v, ok := value.(string)
  12562. if !ok {
  12563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12564. }
  12565. m.SetSwitchIn(v)
  12566. return nil
  12567. case employee.FieldVideoURL:
  12568. v, ok := value.(string)
  12569. if !ok {
  12570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12571. }
  12572. m.SetVideoURL(v)
  12573. return nil
  12574. case employee.FieldOrganizationID:
  12575. v, ok := value.(uint64)
  12576. if !ok {
  12577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12578. }
  12579. m.SetOrganizationID(v)
  12580. return nil
  12581. case employee.FieldCategoryID:
  12582. v, ok := value.(uint64)
  12583. if !ok {
  12584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12585. }
  12586. m.SetCategoryID(v)
  12587. return nil
  12588. case employee.FieldAPIBase:
  12589. v, ok := value.(string)
  12590. if !ok {
  12591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12592. }
  12593. m.SetAPIBase(v)
  12594. return nil
  12595. case employee.FieldAPIKey:
  12596. v, ok := value.(string)
  12597. if !ok {
  12598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12599. }
  12600. m.SetAPIKey(v)
  12601. return nil
  12602. case employee.FieldAiInfo:
  12603. v, ok := value.(string)
  12604. if !ok {
  12605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12606. }
  12607. m.SetAiInfo(v)
  12608. return nil
  12609. case employee.FieldIsVip:
  12610. v, ok := value.(int)
  12611. if !ok {
  12612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12613. }
  12614. m.SetIsVip(v)
  12615. return nil
  12616. case employee.FieldChatURL:
  12617. v, ok := value.(string)
  12618. if !ok {
  12619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12620. }
  12621. m.SetChatURL(v)
  12622. return nil
  12623. }
  12624. return fmt.Errorf("unknown Employee field %s", name)
  12625. }
  12626. // AddedFields returns all numeric fields that were incremented/decremented during
  12627. // this mutation.
  12628. func (m *EmployeeMutation) AddedFields() []string {
  12629. var fields []string
  12630. if m.addhire_count != nil {
  12631. fields = append(fields, employee.FieldHireCount)
  12632. }
  12633. if m.addservice_count != nil {
  12634. fields = append(fields, employee.FieldServiceCount)
  12635. }
  12636. if m.addachievement_count != nil {
  12637. fields = append(fields, employee.FieldAchievementCount)
  12638. }
  12639. if m.addorganization_id != nil {
  12640. fields = append(fields, employee.FieldOrganizationID)
  12641. }
  12642. if m.addcategory_id != nil {
  12643. fields = append(fields, employee.FieldCategoryID)
  12644. }
  12645. if m.addis_vip != nil {
  12646. fields = append(fields, employee.FieldIsVip)
  12647. }
  12648. return fields
  12649. }
  12650. // AddedField returns the numeric value that was incremented/decremented on a field
  12651. // with the given name. The second boolean return value indicates that this field
  12652. // was not set, or was not defined in the schema.
  12653. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12654. switch name {
  12655. case employee.FieldHireCount:
  12656. return m.AddedHireCount()
  12657. case employee.FieldServiceCount:
  12658. return m.AddedServiceCount()
  12659. case employee.FieldAchievementCount:
  12660. return m.AddedAchievementCount()
  12661. case employee.FieldOrganizationID:
  12662. return m.AddedOrganizationID()
  12663. case employee.FieldCategoryID:
  12664. return m.AddedCategoryID()
  12665. case employee.FieldIsVip:
  12666. return m.AddedIsVip()
  12667. }
  12668. return nil, false
  12669. }
  12670. // AddField adds the value to the field with the given name. It returns an error if
  12671. // the field is not defined in the schema, or if the type mismatched the field
  12672. // type.
  12673. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12674. switch name {
  12675. case employee.FieldHireCount:
  12676. v, ok := value.(int)
  12677. if !ok {
  12678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12679. }
  12680. m.AddHireCount(v)
  12681. return nil
  12682. case employee.FieldServiceCount:
  12683. v, ok := value.(int)
  12684. if !ok {
  12685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12686. }
  12687. m.AddServiceCount(v)
  12688. return nil
  12689. case employee.FieldAchievementCount:
  12690. v, ok := value.(int)
  12691. if !ok {
  12692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12693. }
  12694. m.AddAchievementCount(v)
  12695. return nil
  12696. case employee.FieldOrganizationID:
  12697. v, ok := value.(int64)
  12698. if !ok {
  12699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12700. }
  12701. m.AddOrganizationID(v)
  12702. return nil
  12703. case employee.FieldCategoryID:
  12704. v, ok := value.(int64)
  12705. if !ok {
  12706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12707. }
  12708. m.AddCategoryID(v)
  12709. return nil
  12710. case employee.FieldIsVip:
  12711. v, ok := value.(int)
  12712. if !ok {
  12713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12714. }
  12715. m.AddIsVip(v)
  12716. return nil
  12717. }
  12718. return fmt.Errorf("unknown Employee numeric field %s", name)
  12719. }
  12720. // ClearedFields returns all nullable fields that were cleared during this
  12721. // mutation.
  12722. func (m *EmployeeMutation) ClearedFields() []string {
  12723. var fields []string
  12724. if m.FieldCleared(employee.FieldDeletedAt) {
  12725. fields = append(fields, employee.FieldDeletedAt)
  12726. }
  12727. if m.FieldCleared(employee.FieldAiInfo) {
  12728. fields = append(fields, employee.FieldAiInfo)
  12729. }
  12730. return fields
  12731. }
  12732. // FieldCleared returns a boolean indicating if a field with the given name was
  12733. // cleared in this mutation.
  12734. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12735. _, ok := m.clearedFields[name]
  12736. return ok
  12737. }
  12738. // ClearField clears the value of the field with the given name. It returns an
  12739. // error if the field is not defined in the schema.
  12740. func (m *EmployeeMutation) ClearField(name string) error {
  12741. switch name {
  12742. case employee.FieldDeletedAt:
  12743. m.ClearDeletedAt()
  12744. return nil
  12745. case employee.FieldAiInfo:
  12746. m.ClearAiInfo()
  12747. return nil
  12748. }
  12749. return fmt.Errorf("unknown Employee nullable field %s", name)
  12750. }
  12751. // ResetField resets all changes in the mutation for the field with the given name.
  12752. // It returns an error if the field is not defined in the schema.
  12753. func (m *EmployeeMutation) ResetField(name string) error {
  12754. switch name {
  12755. case employee.FieldCreatedAt:
  12756. m.ResetCreatedAt()
  12757. return nil
  12758. case employee.FieldUpdatedAt:
  12759. m.ResetUpdatedAt()
  12760. return nil
  12761. case employee.FieldDeletedAt:
  12762. m.ResetDeletedAt()
  12763. return nil
  12764. case employee.FieldTitle:
  12765. m.ResetTitle()
  12766. return nil
  12767. case employee.FieldAvatar:
  12768. m.ResetAvatar()
  12769. return nil
  12770. case employee.FieldTags:
  12771. m.ResetTags()
  12772. return nil
  12773. case employee.FieldHireCount:
  12774. m.ResetHireCount()
  12775. return nil
  12776. case employee.FieldServiceCount:
  12777. m.ResetServiceCount()
  12778. return nil
  12779. case employee.FieldAchievementCount:
  12780. m.ResetAchievementCount()
  12781. return nil
  12782. case employee.FieldIntro:
  12783. m.ResetIntro()
  12784. return nil
  12785. case employee.FieldEstimate:
  12786. m.ResetEstimate()
  12787. return nil
  12788. case employee.FieldSkill:
  12789. m.ResetSkill()
  12790. return nil
  12791. case employee.FieldAbilityType:
  12792. m.ResetAbilityType()
  12793. return nil
  12794. case employee.FieldScene:
  12795. m.ResetScene()
  12796. return nil
  12797. case employee.FieldSwitchIn:
  12798. m.ResetSwitchIn()
  12799. return nil
  12800. case employee.FieldVideoURL:
  12801. m.ResetVideoURL()
  12802. return nil
  12803. case employee.FieldOrganizationID:
  12804. m.ResetOrganizationID()
  12805. return nil
  12806. case employee.FieldCategoryID:
  12807. m.ResetCategoryID()
  12808. return nil
  12809. case employee.FieldAPIBase:
  12810. m.ResetAPIBase()
  12811. return nil
  12812. case employee.FieldAPIKey:
  12813. m.ResetAPIKey()
  12814. return nil
  12815. case employee.FieldAiInfo:
  12816. m.ResetAiInfo()
  12817. return nil
  12818. case employee.FieldIsVip:
  12819. m.ResetIsVip()
  12820. return nil
  12821. case employee.FieldChatURL:
  12822. m.ResetChatURL()
  12823. return nil
  12824. }
  12825. return fmt.Errorf("unknown Employee field %s", name)
  12826. }
  12827. // AddedEdges returns all edge names that were set/added in this mutation.
  12828. func (m *EmployeeMutation) AddedEdges() []string {
  12829. edges := make([]string, 0, 2)
  12830. if m.em_work_experiences != nil {
  12831. edges = append(edges, employee.EdgeEmWorkExperiences)
  12832. }
  12833. if m.em_tutorial != nil {
  12834. edges = append(edges, employee.EdgeEmTutorial)
  12835. }
  12836. return edges
  12837. }
  12838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12839. // name in this mutation.
  12840. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12841. switch name {
  12842. case employee.EdgeEmWorkExperiences:
  12843. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12844. for id := range m.em_work_experiences {
  12845. ids = append(ids, id)
  12846. }
  12847. return ids
  12848. case employee.EdgeEmTutorial:
  12849. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12850. for id := range m.em_tutorial {
  12851. ids = append(ids, id)
  12852. }
  12853. return ids
  12854. }
  12855. return nil
  12856. }
  12857. // RemovedEdges returns all edge names that were removed in this mutation.
  12858. func (m *EmployeeMutation) RemovedEdges() []string {
  12859. edges := make([]string, 0, 2)
  12860. if m.removedem_work_experiences != nil {
  12861. edges = append(edges, employee.EdgeEmWorkExperiences)
  12862. }
  12863. if m.removedem_tutorial != nil {
  12864. edges = append(edges, employee.EdgeEmTutorial)
  12865. }
  12866. return edges
  12867. }
  12868. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12869. // the given name in this mutation.
  12870. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12871. switch name {
  12872. case employee.EdgeEmWorkExperiences:
  12873. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12874. for id := range m.removedem_work_experiences {
  12875. ids = append(ids, id)
  12876. }
  12877. return ids
  12878. case employee.EdgeEmTutorial:
  12879. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12880. for id := range m.removedem_tutorial {
  12881. ids = append(ids, id)
  12882. }
  12883. return ids
  12884. }
  12885. return nil
  12886. }
  12887. // ClearedEdges returns all edge names that were cleared in this mutation.
  12888. func (m *EmployeeMutation) ClearedEdges() []string {
  12889. edges := make([]string, 0, 2)
  12890. if m.clearedem_work_experiences {
  12891. edges = append(edges, employee.EdgeEmWorkExperiences)
  12892. }
  12893. if m.clearedem_tutorial {
  12894. edges = append(edges, employee.EdgeEmTutorial)
  12895. }
  12896. return edges
  12897. }
  12898. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12899. // was cleared in this mutation.
  12900. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12901. switch name {
  12902. case employee.EdgeEmWorkExperiences:
  12903. return m.clearedem_work_experiences
  12904. case employee.EdgeEmTutorial:
  12905. return m.clearedem_tutorial
  12906. }
  12907. return false
  12908. }
  12909. // ClearEdge clears the value of the edge with the given name. It returns an error
  12910. // if that edge is not defined in the schema.
  12911. func (m *EmployeeMutation) ClearEdge(name string) error {
  12912. switch name {
  12913. }
  12914. return fmt.Errorf("unknown Employee unique edge %s", name)
  12915. }
  12916. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12917. // It returns an error if the edge is not defined in the schema.
  12918. func (m *EmployeeMutation) ResetEdge(name string) error {
  12919. switch name {
  12920. case employee.EdgeEmWorkExperiences:
  12921. m.ResetEmWorkExperiences()
  12922. return nil
  12923. case employee.EdgeEmTutorial:
  12924. m.ResetEmTutorial()
  12925. return nil
  12926. }
  12927. return fmt.Errorf("unknown Employee edge %s", name)
  12928. }
  12929. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12930. type EmployeeConfigMutation struct {
  12931. config
  12932. op Op
  12933. typ string
  12934. id *uint64
  12935. created_at *time.Time
  12936. updated_at *time.Time
  12937. deleted_at *time.Time
  12938. stype *string
  12939. title *string
  12940. photo *string
  12941. organization_id *uint64
  12942. addorganization_id *int64
  12943. clearedFields map[string]struct{}
  12944. done bool
  12945. oldValue func(context.Context) (*EmployeeConfig, error)
  12946. predicates []predicate.EmployeeConfig
  12947. }
  12948. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12949. // employeeconfigOption allows management of the mutation configuration using functional options.
  12950. type employeeconfigOption func(*EmployeeConfigMutation)
  12951. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12952. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12953. m := &EmployeeConfigMutation{
  12954. config: c,
  12955. op: op,
  12956. typ: TypeEmployeeConfig,
  12957. clearedFields: make(map[string]struct{}),
  12958. }
  12959. for _, opt := range opts {
  12960. opt(m)
  12961. }
  12962. return m
  12963. }
  12964. // withEmployeeConfigID sets the ID field of the mutation.
  12965. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12966. return func(m *EmployeeConfigMutation) {
  12967. var (
  12968. err error
  12969. once sync.Once
  12970. value *EmployeeConfig
  12971. )
  12972. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12973. once.Do(func() {
  12974. if m.done {
  12975. err = errors.New("querying old values post mutation is not allowed")
  12976. } else {
  12977. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12978. }
  12979. })
  12980. return value, err
  12981. }
  12982. m.id = &id
  12983. }
  12984. }
  12985. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12986. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12987. return func(m *EmployeeConfigMutation) {
  12988. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12989. return node, nil
  12990. }
  12991. m.id = &node.ID
  12992. }
  12993. }
  12994. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12995. // executed in a transaction (ent.Tx), a transactional client is returned.
  12996. func (m EmployeeConfigMutation) Client() *Client {
  12997. client := &Client{config: m.config}
  12998. client.init()
  12999. return client
  13000. }
  13001. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13002. // it returns an error otherwise.
  13003. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13004. if _, ok := m.driver.(*txDriver); !ok {
  13005. return nil, errors.New("ent: mutation is not running in a transaction")
  13006. }
  13007. tx := &Tx{config: m.config}
  13008. tx.init()
  13009. return tx, nil
  13010. }
  13011. // SetID sets the value of the id field. Note that this
  13012. // operation is only accepted on creation of EmployeeConfig entities.
  13013. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13014. m.id = &id
  13015. }
  13016. // ID returns the ID value in the mutation. Note that the ID is only available
  13017. // if it was provided to the builder or after it was returned from the database.
  13018. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13019. if m.id == nil {
  13020. return
  13021. }
  13022. return *m.id, true
  13023. }
  13024. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13025. // That means, if the mutation is applied within a transaction with an isolation level such
  13026. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13027. // or updated by the mutation.
  13028. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13029. switch {
  13030. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13031. id, exists := m.ID()
  13032. if exists {
  13033. return []uint64{id}, nil
  13034. }
  13035. fallthrough
  13036. case m.op.Is(OpUpdate | OpDelete):
  13037. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13038. default:
  13039. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13040. }
  13041. }
  13042. // SetCreatedAt sets the "created_at" field.
  13043. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13044. m.created_at = &t
  13045. }
  13046. // CreatedAt returns the value of the "created_at" field in the mutation.
  13047. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13048. v := m.created_at
  13049. if v == nil {
  13050. return
  13051. }
  13052. return *v, true
  13053. }
  13054. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13055. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13057. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13058. if !m.op.Is(OpUpdateOne) {
  13059. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13060. }
  13061. if m.id == nil || m.oldValue == nil {
  13062. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13063. }
  13064. oldValue, err := m.oldValue(ctx)
  13065. if err != nil {
  13066. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13067. }
  13068. return oldValue.CreatedAt, nil
  13069. }
  13070. // ResetCreatedAt resets all changes to the "created_at" field.
  13071. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13072. m.created_at = nil
  13073. }
  13074. // SetUpdatedAt sets the "updated_at" field.
  13075. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13076. m.updated_at = &t
  13077. }
  13078. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13079. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13080. v := m.updated_at
  13081. if v == nil {
  13082. return
  13083. }
  13084. return *v, true
  13085. }
  13086. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13087. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13089. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13090. if !m.op.Is(OpUpdateOne) {
  13091. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13092. }
  13093. if m.id == nil || m.oldValue == nil {
  13094. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13095. }
  13096. oldValue, err := m.oldValue(ctx)
  13097. if err != nil {
  13098. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13099. }
  13100. return oldValue.UpdatedAt, nil
  13101. }
  13102. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13103. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13104. m.updated_at = nil
  13105. }
  13106. // SetDeletedAt sets the "deleted_at" field.
  13107. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13108. m.deleted_at = &t
  13109. }
  13110. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13111. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13112. v := m.deleted_at
  13113. if v == nil {
  13114. return
  13115. }
  13116. return *v, true
  13117. }
  13118. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13119. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13121. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13122. if !m.op.Is(OpUpdateOne) {
  13123. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13124. }
  13125. if m.id == nil || m.oldValue == nil {
  13126. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13127. }
  13128. oldValue, err := m.oldValue(ctx)
  13129. if err != nil {
  13130. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13131. }
  13132. return oldValue.DeletedAt, nil
  13133. }
  13134. // ClearDeletedAt clears the value of the "deleted_at" field.
  13135. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13136. m.deleted_at = nil
  13137. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13138. }
  13139. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13140. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13141. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13142. return ok
  13143. }
  13144. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13145. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13146. m.deleted_at = nil
  13147. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13148. }
  13149. // SetStype sets the "stype" field.
  13150. func (m *EmployeeConfigMutation) SetStype(s string) {
  13151. m.stype = &s
  13152. }
  13153. // Stype returns the value of the "stype" field in the mutation.
  13154. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13155. v := m.stype
  13156. if v == nil {
  13157. return
  13158. }
  13159. return *v, true
  13160. }
  13161. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13162. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13164. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13165. if !m.op.Is(OpUpdateOne) {
  13166. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13167. }
  13168. if m.id == nil || m.oldValue == nil {
  13169. return v, errors.New("OldStype requires an ID field in the mutation")
  13170. }
  13171. oldValue, err := m.oldValue(ctx)
  13172. if err != nil {
  13173. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13174. }
  13175. return oldValue.Stype, nil
  13176. }
  13177. // ResetStype resets all changes to the "stype" field.
  13178. func (m *EmployeeConfigMutation) ResetStype() {
  13179. m.stype = nil
  13180. }
  13181. // SetTitle sets the "title" field.
  13182. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13183. m.title = &s
  13184. }
  13185. // Title returns the value of the "title" field in the mutation.
  13186. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13187. v := m.title
  13188. if v == nil {
  13189. return
  13190. }
  13191. return *v, true
  13192. }
  13193. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13194. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13196. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13197. if !m.op.Is(OpUpdateOne) {
  13198. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13199. }
  13200. if m.id == nil || m.oldValue == nil {
  13201. return v, errors.New("OldTitle requires an ID field in the mutation")
  13202. }
  13203. oldValue, err := m.oldValue(ctx)
  13204. if err != nil {
  13205. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13206. }
  13207. return oldValue.Title, nil
  13208. }
  13209. // ResetTitle resets all changes to the "title" field.
  13210. func (m *EmployeeConfigMutation) ResetTitle() {
  13211. m.title = nil
  13212. }
  13213. // SetPhoto sets the "photo" field.
  13214. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13215. m.photo = &s
  13216. }
  13217. // Photo returns the value of the "photo" field in the mutation.
  13218. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13219. v := m.photo
  13220. if v == nil {
  13221. return
  13222. }
  13223. return *v, true
  13224. }
  13225. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13226. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13228. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13229. if !m.op.Is(OpUpdateOne) {
  13230. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13231. }
  13232. if m.id == nil || m.oldValue == nil {
  13233. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13234. }
  13235. oldValue, err := m.oldValue(ctx)
  13236. if err != nil {
  13237. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13238. }
  13239. return oldValue.Photo, nil
  13240. }
  13241. // ResetPhoto resets all changes to the "photo" field.
  13242. func (m *EmployeeConfigMutation) ResetPhoto() {
  13243. m.photo = nil
  13244. }
  13245. // SetOrganizationID sets the "organization_id" field.
  13246. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13247. m.organization_id = &u
  13248. m.addorganization_id = nil
  13249. }
  13250. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13251. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13252. v := m.organization_id
  13253. if v == nil {
  13254. return
  13255. }
  13256. return *v, true
  13257. }
  13258. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13259. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13261. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13262. if !m.op.Is(OpUpdateOne) {
  13263. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13264. }
  13265. if m.id == nil || m.oldValue == nil {
  13266. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13267. }
  13268. oldValue, err := m.oldValue(ctx)
  13269. if err != nil {
  13270. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13271. }
  13272. return oldValue.OrganizationID, nil
  13273. }
  13274. // AddOrganizationID adds u to the "organization_id" field.
  13275. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13276. if m.addorganization_id != nil {
  13277. *m.addorganization_id += u
  13278. } else {
  13279. m.addorganization_id = &u
  13280. }
  13281. }
  13282. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13283. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13284. v := m.addorganization_id
  13285. if v == nil {
  13286. return
  13287. }
  13288. return *v, true
  13289. }
  13290. // ClearOrganizationID clears the value of the "organization_id" field.
  13291. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13292. m.organization_id = nil
  13293. m.addorganization_id = nil
  13294. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13295. }
  13296. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13297. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13298. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13299. return ok
  13300. }
  13301. // ResetOrganizationID resets all changes to the "organization_id" field.
  13302. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13303. m.organization_id = nil
  13304. m.addorganization_id = nil
  13305. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13306. }
  13307. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13308. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13309. m.predicates = append(m.predicates, ps...)
  13310. }
  13311. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13312. // users can use type-assertion to append predicates that do not depend on any generated package.
  13313. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13314. p := make([]predicate.EmployeeConfig, len(ps))
  13315. for i := range ps {
  13316. p[i] = ps[i]
  13317. }
  13318. m.Where(p...)
  13319. }
  13320. // Op returns the operation name.
  13321. func (m *EmployeeConfigMutation) Op() Op {
  13322. return m.op
  13323. }
  13324. // SetOp allows setting the mutation operation.
  13325. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13326. m.op = op
  13327. }
  13328. // Type returns the node type of this mutation (EmployeeConfig).
  13329. func (m *EmployeeConfigMutation) Type() string {
  13330. return m.typ
  13331. }
  13332. // Fields returns all fields that were changed during this mutation. Note that in
  13333. // order to get all numeric fields that were incremented/decremented, call
  13334. // AddedFields().
  13335. func (m *EmployeeConfigMutation) Fields() []string {
  13336. fields := make([]string, 0, 7)
  13337. if m.created_at != nil {
  13338. fields = append(fields, employeeconfig.FieldCreatedAt)
  13339. }
  13340. if m.updated_at != nil {
  13341. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13342. }
  13343. if m.deleted_at != nil {
  13344. fields = append(fields, employeeconfig.FieldDeletedAt)
  13345. }
  13346. if m.stype != nil {
  13347. fields = append(fields, employeeconfig.FieldStype)
  13348. }
  13349. if m.title != nil {
  13350. fields = append(fields, employeeconfig.FieldTitle)
  13351. }
  13352. if m.photo != nil {
  13353. fields = append(fields, employeeconfig.FieldPhoto)
  13354. }
  13355. if m.organization_id != nil {
  13356. fields = append(fields, employeeconfig.FieldOrganizationID)
  13357. }
  13358. return fields
  13359. }
  13360. // Field returns the value of a field with the given name. The second boolean
  13361. // return value indicates that this field was not set, or was not defined in the
  13362. // schema.
  13363. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13364. switch name {
  13365. case employeeconfig.FieldCreatedAt:
  13366. return m.CreatedAt()
  13367. case employeeconfig.FieldUpdatedAt:
  13368. return m.UpdatedAt()
  13369. case employeeconfig.FieldDeletedAt:
  13370. return m.DeletedAt()
  13371. case employeeconfig.FieldStype:
  13372. return m.Stype()
  13373. case employeeconfig.FieldTitle:
  13374. return m.Title()
  13375. case employeeconfig.FieldPhoto:
  13376. return m.Photo()
  13377. case employeeconfig.FieldOrganizationID:
  13378. return m.OrganizationID()
  13379. }
  13380. return nil, false
  13381. }
  13382. // OldField returns the old value of the field from the database. An error is
  13383. // returned if the mutation operation is not UpdateOne, or the query to the
  13384. // database failed.
  13385. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13386. switch name {
  13387. case employeeconfig.FieldCreatedAt:
  13388. return m.OldCreatedAt(ctx)
  13389. case employeeconfig.FieldUpdatedAt:
  13390. return m.OldUpdatedAt(ctx)
  13391. case employeeconfig.FieldDeletedAt:
  13392. return m.OldDeletedAt(ctx)
  13393. case employeeconfig.FieldStype:
  13394. return m.OldStype(ctx)
  13395. case employeeconfig.FieldTitle:
  13396. return m.OldTitle(ctx)
  13397. case employeeconfig.FieldPhoto:
  13398. return m.OldPhoto(ctx)
  13399. case employeeconfig.FieldOrganizationID:
  13400. return m.OldOrganizationID(ctx)
  13401. }
  13402. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13403. }
  13404. // SetField sets the value of a field with the given name. It returns an error if
  13405. // the field is not defined in the schema, or if the type mismatched the field
  13406. // type.
  13407. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13408. switch name {
  13409. case employeeconfig.FieldCreatedAt:
  13410. v, ok := value.(time.Time)
  13411. if !ok {
  13412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13413. }
  13414. m.SetCreatedAt(v)
  13415. return nil
  13416. case employeeconfig.FieldUpdatedAt:
  13417. v, ok := value.(time.Time)
  13418. if !ok {
  13419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13420. }
  13421. m.SetUpdatedAt(v)
  13422. return nil
  13423. case employeeconfig.FieldDeletedAt:
  13424. v, ok := value.(time.Time)
  13425. if !ok {
  13426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13427. }
  13428. m.SetDeletedAt(v)
  13429. return nil
  13430. case employeeconfig.FieldStype:
  13431. v, ok := value.(string)
  13432. if !ok {
  13433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13434. }
  13435. m.SetStype(v)
  13436. return nil
  13437. case employeeconfig.FieldTitle:
  13438. v, ok := value.(string)
  13439. if !ok {
  13440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13441. }
  13442. m.SetTitle(v)
  13443. return nil
  13444. case employeeconfig.FieldPhoto:
  13445. v, ok := value.(string)
  13446. if !ok {
  13447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13448. }
  13449. m.SetPhoto(v)
  13450. return nil
  13451. case employeeconfig.FieldOrganizationID:
  13452. v, ok := value.(uint64)
  13453. if !ok {
  13454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13455. }
  13456. m.SetOrganizationID(v)
  13457. return nil
  13458. }
  13459. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13460. }
  13461. // AddedFields returns all numeric fields that were incremented/decremented during
  13462. // this mutation.
  13463. func (m *EmployeeConfigMutation) AddedFields() []string {
  13464. var fields []string
  13465. if m.addorganization_id != nil {
  13466. fields = append(fields, employeeconfig.FieldOrganizationID)
  13467. }
  13468. return fields
  13469. }
  13470. // AddedField returns the numeric value that was incremented/decremented on a field
  13471. // with the given name. The second boolean return value indicates that this field
  13472. // was not set, or was not defined in the schema.
  13473. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13474. switch name {
  13475. case employeeconfig.FieldOrganizationID:
  13476. return m.AddedOrganizationID()
  13477. }
  13478. return nil, false
  13479. }
  13480. // AddField adds the value to the field with the given name. It returns an error if
  13481. // the field is not defined in the schema, or if the type mismatched the field
  13482. // type.
  13483. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13484. switch name {
  13485. case employeeconfig.FieldOrganizationID:
  13486. v, ok := value.(int64)
  13487. if !ok {
  13488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13489. }
  13490. m.AddOrganizationID(v)
  13491. return nil
  13492. }
  13493. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13494. }
  13495. // ClearedFields returns all nullable fields that were cleared during this
  13496. // mutation.
  13497. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13498. var fields []string
  13499. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13500. fields = append(fields, employeeconfig.FieldDeletedAt)
  13501. }
  13502. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13503. fields = append(fields, employeeconfig.FieldOrganizationID)
  13504. }
  13505. return fields
  13506. }
  13507. // FieldCleared returns a boolean indicating if a field with the given name was
  13508. // cleared in this mutation.
  13509. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13510. _, ok := m.clearedFields[name]
  13511. return ok
  13512. }
  13513. // ClearField clears the value of the field with the given name. It returns an
  13514. // error if the field is not defined in the schema.
  13515. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13516. switch name {
  13517. case employeeconfig.FieldDeletedAt:
  13518. m.ClearDeletedAt()
  13519. return nil
  13520. case employeeconfig.FieldOrganizationID:
  13521. m.ClearOrganizationID()
  13522. return nil
  13523. }
  13524. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13525. }
  13526. // ResetField resets all changes in the mutation for the field with the given name.
  13527. // It returns an error if the field is not defined in the schema.
  13528. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13529. switch name {
  13530. case employeeconfig.FieldCreatedAt:
  13531. m.ResetCreatedAt()
  13532. return nil
  13533. case employeeconfig.FieldUpdatedAt:
  13534. m.ResetUpdatedAt()
  13535. return nil
  13536. case employeeconfig.FieldDeletedAt:
  13537. m.ResetDeletedAt()
  13538. return nil
  13539. case employeeconfig.FieldStype:
  13540. m.ResetStype()
  13541. return nil
  13542. case employeeconfig.FieldTitle:
  13543. m.ResetTitle()
  13544. return nil
  13545. case employeeconfig.FieldPhoto:
  13546. m.ResetPhoto()
  13547. return nil
  13548. case employeeconfig.FieldOrganizationID:
  13549. m.ResetOrganizationID()
  13550. return nil
  13551. }
  13552. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13553. }
  13554. // AddedEdges returns all edge names that were set/added in this mutation.
  13555. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13556. edges := make([]string, 0, 0)
  13557. return edges
  13558. }
  13559. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13560. // name in this mutation.
  13561. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13562. return nil
  13563. }
  13564. // RemovedEdges returns all edge names that were removed in this mutation.
  13565. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13566. edges := make([]string, 0, 0)
  13567. return edges
  13568. }
  13569. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13570. // the given name in this mutation.
  13571. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13572. return nil
  13573. }
  13574. // ClearedEdges returns all edge names that were cleared in this mutation.
  13575. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13576. edges := make([]string, 0, 0)
  13577. return edges
  13578. }
  13579. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13580. // was cleared in this mutation.
  13581. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13582. return false
  13583. }
  13584. // ClearEdge clears the value of the edge with the given name. It returns an error
  13585. // if that edge is not defined in the schema.
  13586. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13587. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13588. }
  13589. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13590. // It returns an error if the edge is not defined in the schema.
  13591. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13592. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13593. }
  13594. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13595. type LabelMutation struct {
  13596. config
  13597. op Op
  13598. typ string
  13599. id *uint64
  13600. created_at *time.Time
  13601. updated_at *time.Time
  13602. status *uint8
  13603. addstatus *int8
  13604. _type *int
  13605. add_type *int
  13606. name *string
  13607. from *int
  13608. addfrom *int
  13609. mode *int
  13610. addmode *int
  13611. conditions *string
  13612. organization_id *uint64
  13613. addorganization_id *int64
  13614. clearedFields map[string]struct{}
  13615. label_relationships map[uint64]struct{}
  13616. removedlabel_relationships map[uint64]struct{}
  13617. clearedlabel_relationships bool
  13618. done bool
  13619. oldValue func(context.Context) (*Label, error)
  13620. predicates []predicate.Label
  13621. }
  13622. var _ ent.Mutation = (*LabelMutation)(nil)
  13623. // labelOption allows management of the mutation configuration using functional options.
  13624. type labelOption func(*LabelMutation)
  13625. // newLabelMutation creates new mutation for the Label entity.
  13626. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13627. m := &LabelMutation{
  13628. config: c,
  13629. op: op,
  13630. typ: TypeLabel,
  13631. clearedFields: make(map[string]struct{}),
  13632. }
  13633. for _, opt := range opts {
  13634. opt(m)
  13635. }
  13636. return m
  13637. }
  13638. // withLabelID sets the ID field of the mutation.
  13639. func withLabelID(id uint64) labelOption {
  13640. return func(m *LabelMutation) {
  13641. var (
  13642. err error
  13643. once sync.Once
  13644. value *Label
  13645. )
  13646. m.oldValue = func(ctx context.Context) (*Label, error) {
  13647. once.Do(func() {
  13648. if m.done {
  13649. err = errors.New("querying old values post mutation is not allowed")
  13650. } else {
  13651. value, err = m.Client().Label.Get(ctx, id)
  13652. }
  13653. })
  13654. return value, err
  13655. }
  13656. m.id = &id
  13657. }
  13658. }
  13659. // withLabel sets the old Label of the mutation.
  13660. func withLabel(node *Label) labelOption {
  13661. return func(m *LabelMutation) {
  13662. m.oldValue = func(context.Context) (*Label, error) {
  13663. return node, nil
  13664. }
  13665. m.id = &node.ID
  13666. }
  13667. }
  13668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13669. // executed in a transaction (ent.Tx), a transactional client is returned.
  13670. func (m LabelMutation) Client() *Client {
  13671. client := &Client{config: m.config}
  13672. client.init()
  13673. return client
  13674. }
  13675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13676. // it returns an error otherwise.
  13677. func (m LabelMutation) Tx() (*Tx, error) {
  13678. if _, ok := m.driver.(*txDriver); !ok {
  13679. return nil, errors.New("ent: mutation is not running in a transaction")
  13680. }
  13681. tx := &Tx{config: m.config}
  13682. tx.init()
  13683. return tx, nil
  13684. }
  13685. // SetID sets the value of the id field. Note that this
  13686. // operation is only accepted on creation of Label entities.
  13687. func (m *LabelMutation) SetID(id uint64) {
  13688. m.id = &id
  13689. }
  13690. // ID returns the ID value in the mutation. Note that the ID is only available
  13691. // if it was provided to the builder or after it was returned from the database.
  13692. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13693. if m.id == nil {
  13694. return
  13695. }
  13696. return *m.id, true
  13697. }
  13698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13699. // That means, if the mutation is applied within a transaction with an isolation level such
  13700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13701. // or updated by the mutation.
  13702. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13703. switch {
  13704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13705. id, exists := m.ID()
  13706. if exists {
  13707. return []uint64{id}, nil
  13708. }
  13709. fallthrough
  13710. case m.op.Is(OpUpdate | OpDelete):
  13711. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13712. default:
  13713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13714. }
  13715. }
  13716. // SetCreatedAt sets the "created_at" field.
  13717. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13718. m.created_at = &t
  13719. }
  13720. // CreatedAt returns the value of the "created_at" field in the mutation.
  13721. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13722. v := m.created_at
  13723. if v == nil {
  13724. return
  13725. }
  13726. return *v, true
  13727. }
  13728. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13729. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13731. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13732. if !m.op.Is(OpUpdateOne) {
  13733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13734. }
  13735. if m.id == nil || m.oldValue == nil {
  13736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13737. }
  13738. oldValue, err := m.oldValue(ctx)
  13739. if err != nil {
  13740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13741. }
  13742. return oldValue.CreatedAt, nil
  13743. }
  13744. // ResetCreatedAt resets all changes to the "created_at" field.
  13745. func (m *LabelMutation) ResetCreatedAt() {
  13746. m.created_at = nil
  13747. }
  13748. // SetUpdatedAt sets the "updated_at" field.
  13749. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13750. m.updated_at = &t
  13751. }
  13752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13753. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13754. v := m.updated_at
  13755. if v == nil {
  13756. return
  13757. }
  13758. return *v, true
  13759. }
  13760. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13761. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13763. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13764. if !m.op.Is(OpUpdateOne) {
  13765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13766. }
  13767. if m.id == nil || m.oldValue == nil {
  13768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13769. }
  13770. oldValue, err := m.oldValue(ctx)
  13771. if err != nil {
  13772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13773. }
  13774. return oldValue.UpdatedAt, nil
  13775. }
  13776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13777. func (m *LabelMutation) ResetUpdatedAt() {
  13778. m.updated_at = nil
  13779. }
  13780. // SetStatus sets the "status" field.
  13781. func (m *LabelMutation) SetStatus(u uint8) {
  13782. m.status = &u
  13783. m.addstatus = nil
  13784. }
  13785. // Status returns the value of the "status" field in the mutation.
  13786. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13787. v := m.status
  13788. if v == nil {
  13789. return
  13790. }
  13791. return *v, true
  13792. }
  13793. // OldStatus returns the old "status" field's value of the Label entity.
  13794. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13796. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13797. if !m.op.Is(OpUpdateOne) {
  13798. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13799. }
  13800. if m.id == nil || m.oldValue == nil {
  13801. return v, errors.New("OldStatus requires an ID field in the mutation")
  13802. }
  13803. oldValue, err := m.oldValue(ctx)
  13804. if err != nil {
  13805. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13806. }
  13807. return oldValue.Status, nil
  13808. }
  13809. // AddStatus adds u to the "status" field.
  13810. func (m *LabelMutation) AddStatus(u int8) {
  13811. if m.addstatus != nil {
  13812. *m.addstatus += u
  13813. } else {
  13814. m.addstatus = &u
  13815. }
  13816. }
  13817. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13818. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13819. v := m.addstatus
  13820. if v == nil {
  13821. return
  13822. }
  13823. return *v, true
  13824. }
  13825. // ClearStatus clears the value of the "status" field.
  13826. func (m *LabelMutation) ClearStatus() {
  13827. m.status = nil
  13828. m.addstatus = nil
  13829. m.clearedFields[label.FieldStatus] = struct{}{}
  13830. }
  13831. // StatusCleared returns if the "status" field was cleared in this mutation.
  13832. func (m *LabelMutation) StatusCleared() bool {
  13833. _, ok := m.clearedFields[label.FieldStatus]
  13834. return ok
  13835. }
  13836. // ResetStatus resets all changes to the "status" field.
  13837. func (m *LabelMutation) ResetStatus() {
  13838. m.status = nil
  13839. m.addstatus = nil
  13840. delete(m.clearedFields, label.FieldStatus)
  13841. }
  13842. // SetType sets the "type" field.
  13843. func (m *LabelMutation) SetType(i int) {
  13844. m._type = &i
  13845. m.add_type = nil
  13846. }
  13847. // GetType returns the value of the "type" field in the mutation.
  13848. func (m *LabelMutation) GetType() (r int, exists bool) {
  13849. v := m._type
  13850. if v == nil {
  13851. return
  13852. }
  13853. return *v, true
  13854. }
  13855. // OldType returns the old "type" field's value of the Label entity.
  13856. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13858. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13859. if !m.op.Is(OpUpdateOne) {
  13860. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13861. }
  13862. if m.id == nil || m.oldValue == nil {
  13863. return v, errors.New("OldType requires an ID field in the mutation")
  13864. }
  13865. oldValue, err := m.oldValue(ctx)
  13866. if err != nil {
  13867. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13868. }
  13869. return oldValue.Type, nil
  13870. }
  13871. // AddType adds i to the "type" field.
  13872. func (m *LabelMutation) AddType(i int) {
  13873. if m.add_type != nil {
  13874. *m.add_type += i
  13875. } else {
  13876. m.add_type = &i
  13877. }
  13878. }
  13879. // AddedType returns the value that was added to the "type" field in this mutation.
  13880. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13881. v := m.add_type
  13882. if v == nil {
  13883. return
  13884. }
  13885. return *v, true
  13886. }
  13887. // ResetType resets all changes to the "type" field.
  13888. func (m *LabelMutation) ResetType() {
  13889. m._type = nil
  13890. m.add_type = nil
  13891. }
  13892. // SetName sets the "name" field.
  13893. func (m *LabelMutation) SetName(s string) {
  13894. m.name = &s
  13895. }
  13896. // Name returns the value of the "name" field in the mutation.
  13897. func (m *LabelMutation) Name() (r string, exists bool) {
  13898. v := m.name
  13899. if v == nil {
  13900. return
  13901. }
  13902. return *v, true
  13903. }
  13904. // OldName returns the old "name" field's value of the Label entity.
  13905. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13907. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13908. if !m.op.Is(OpUpdateOne) {
  13909. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13910. }
  13911. if m.id == nil || m.oldValue == nil {
  13912. return v, errors.New("OldName requires an ID field in the mutation")
  13913. }
  13914. oldValue, err := m.oldValue(ctx)
  13915. if err != nil {
  13916. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13917. }
  13918. return oldValue.Name, nil
  13919. }
  13920. // ResetName resets all changes to the "name" field.
  13921. func (m *LabelMutation) ResetName() {
  13922. m.name = nil
  13923. }
  13924. // SetFrom sets the "from" field.
  13925. func (m *LabelMutation) SetFrom(i int) {
  13926. m.from = &i
  13927. m.addfrom = nil
  13928. }
  13929. // From returns the value of the "from" field in the mutation.
  13930. func (m *LabelMutation) From() (r int, exists bool) {
  13931. v := m.from
  13932. if v == nil {
  13933. return
  13934. }
  13935. return *v, true
  13936. }
  13937. // OldFrom returns the old "from" field's value of the Label entity.
  13938. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13940. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13941. if !m.op.Is(OpUpdateOne) {
  13942. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13943. }
  13944. if m.id == nil || m.oldValue == nil {
  13945. return v, errors.New("OldFrom requires an ID field in the mutation")
  13946. }
  13947. oldValue, err := m.oldValue(ctx)
  13948. if err != nil {
  13949. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13950. }
  13951. return oldValue.From, nil
  13952. }
  13953. // AddFrom adds i to the "from" field.
  13954. func (m *LabelMutation) AddFrom(i int) {
  13955. if m.addfrom != nil {
  13956. *m.addfrom += i
  13957. } else {
  13958. m.addfrom = &i
  13959. }
  13960. }
  13961. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13962. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13963. v := m.addfrom
  13964. if v == nil {
  13965. return
  13966. }
  13967. return *v, true
  13968. }
  13969. // ResetFrom resets all changes to the "from" field.
  13970. func (m *LabelMutation) ResetFrom() {
  13971. m.from = nil
  13972. m.addfrom = nil
  13973. }
  13974. // SetMode sets the "mode" field.
  13975. func (m *LabelMutation) SetMode(i int) {
  13976. m.mode = &i
  13977. m.addmode = nil
  13978. }
  13979. // Mode returns the value of the "mode" field in the mutation.
  13980. func (m *LabelMutation) Mode() (r int, exists bool) {
  13981. v := m.mode
  13982. if v == nil {
  13983. return
  13984. }
  13985. return *v, true
  13986. }
  13987. // OldMode returns the old "mode" field's value of the Label entity.
  13988. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13990. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13991. if !m.op.Is(OpUpdateOne) {
  13992. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13993. }
  13994. if m.id == nil || m.oldValue == nil {
  13995. return v, errors.New("OldMode requires an ID field in the mutation")
  13996. }
  13997. oldValue, err := m.oldValue(ctx)
  13998. if err != nil {
  13999. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14000. }
  14001. return oldValue.Mode, nil
  14002. }
  14003. // AddMode adds i to the "mode" field.
  14004. func (m *LabelMutation) AddMode(i int) {
  14005. if m.addmode != nil {
  14006. *m.addmode += i
  14007. } else {
  14008. m.addmode = &i
  14009. }
  14010. }
  14011. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14012. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14013. v := m.addmode
  14014. if v == nil {
  14015. return
  14016. }
  14017. return *v, true
  14018. }
  14019. // ResetMode resets all changes to the "mode" field.
  14020. func (m *LabelMutation) ResetMode() {
  14021. m.mode = nil
  14022. m.addmode = nil
  14023. }
  14024. // SetConditions sets the "conditions" field.
  14025. func (m *LabelMutation) SetConditions(s string) {
  14026. m.conditions = &s
  14027. }
  14028. // Conditions returns the value of the "conditions" field in the mutation.
  14029. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14030. v := m.conditions
  14031. if v == nil {
  14032. return
  14033. }
  14034. return *v, true
  14035. }
  14036. // OldConditions returns the old "conditions" field's value of the Label entity.
  14037. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14039. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14040. if !m.op.Is(OpUpdateOne) {
  14041. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14042. }
  14043. if m.id == nil || m.oldValue == nil {
  14044. return v, errors.New("OldConditions requires an ID field in the mutation")
  14045. }
  14046. oldValue, err := m.oldValue(ctx)
  14047. if err != nil {
  14048. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14049. }
  14050. return oldValue.Conditions, nil
  14051. }
  14052. // ClearConditions clears the value of the "conditions" field.
  14053. func (m *LabelMutation) ClearConditions() {
  14054. m.conditions = nil
  14055. m.clearedFields[label.FieldConditions] = struct{}{}
  14056. }
  14057. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14058. func (m *LabelMutation) ConditionsCleared() bool {
  14059. _, ok := m.clearedFields[label.FieldConditions]
  14060. return ok
  14061. }
  14062. // ResetConditions resets all changes to the "conditions" field.
  14063. func (m *LabelMutation) ResetConditions() {
  14064. m.conditions = nil
  14065. delete(m.clearedFields, label.FieldConditions)
  14066. }
  14067. // SetOrganizationID sets the "organization_id" field.
  14068. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14069. m.organization_id = &u
  14070. m.addorganization_id = nil
  14071. }
  14072. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14073. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14074. v := m.organization_id
  14075. if v == nil {
  14076. return
  14077. }
  14078. return *v, true
  14079. }
  14080. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14081. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14083. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14084. if !m.op.Is(OpUpdateOne) {
  14085. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14086. }
  14087. if m.id == nil || m.oldValue == nil {
  14088. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14089. }
  14090. oldValue, err := m.oldValue(ctx)
  14091. if err != nil {
  14092. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14093. }
  14094. return oldValue.OrganizationID, nil
  14095. }
  14096. // AddOrganizationID adds u to the "organization_id" field.
  14097. func (m *LabelMutation) AddOrganizationID(u int64) {
  14098. if m.addorganization_id != nil {
  14099. *m.addorganization_id += u
  14100. } else {
  14101. m.addorganization_id = &u
  14102. }
  14103. }
  14104. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14105. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14106. v := m.addorganization_id
  14107. if v == nil {
  14108. return
  14109. }
  14110. return *v, true
  14111. }
  14112. // ClearOrganizationID clears the value of the "organization_id" field.
  14113. func (m *LabelMutation) ClearOrganizationID() {
  14114. m.organization_id = nil
  14115. m.addorganization_id = nil
  14116. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14117. }
  14118. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14119. func (m *LabelMutation) OrganizationIDCleared() bool {
  14120. _, ok := m.clearedFields[label.FieldOrganizationID]
  14121. return ok
  14122. }
  14123. // ResetOrganizationID resets all changes to the "organization_id" field.
  14124. func (m *LabelMutation) ResetOrganizationID() {
  14125. m.organization_id = nil
  14126. m.addorganization_id = nil
  14127. delete(m.clearedFields, label.FieldOrganizationID)
  14128. }
  14129. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14130. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14131. if m.label_relationships == nil {
  14132. m.label_relationships = make(map[uint64]struct{})
  14133. }
  14134. for i := range ids {
  14135. m.label_relationships[ids[i]] = struct{}{}
  14136. }
  14137. }
  14138. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14139. func (m *LabelMutation) ClearLabelRelationships() {
  14140. m.clearedlabel_relationships = true
  14141. }
  14142. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14143. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14144. return m.clearedlabel_relationships
  14145. }
  14146. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14147. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14148. if m.removedlabel_relationships == nil {
  14149. m.removedlabel_relationships = make(map[uint64]struct{})
  14150. }
  14151. for i := range ids {
  14152. delete(m.label_relationships, ids[i])
  14153. m.removedlabel_relationships[ids[i]] = struct{}{}
  14154. }
  14155. }
  14156. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14157. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14158. for id := range m.removedlabel_relationships {
  14159. ids = append(ids, id)
  14160. }
  14161. return
  14162. }
  14163. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14164. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14165. for id := range m.label_relationships {
  14166. ids = append(ids, id)
  14167. }
  14168. return
  14169. }
  14170. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14171. func (m *LabelMutation) ResetLabelRelationships() {
  14172. m.label_relationships = nil
  14173. m.clearedlabel_relationships = false
  14174. m.removedlabel_relationships = nil
  14175. }
  14176. // Where appends a list predicates to the LabelMutation builder.
  14177. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14178. m.predicates = append(m.predicates, ps...)
  14179. }
  14180. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14181. // users can use type-assertion to append predicates that do not depend on any generated package.
  14182. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14183. p := make([]predicate.Label, len(ps))
  14184. for i := range ps {
  14185. p[i] = ps[i]
  14186. }
  14187. m.Where(p...)
  14188. }
  14189. // Op returns the operation name.
  14190. func (m *LabelMutation) Op() Op {
  14191. return m.op
  14192. }
  14193. // SetOp allows setting the mutation operation.
  14194. func (m *LabelMutation) SetOp(op Op) {
  14195. m.op = op
  14196. }
  14197. // Type returns the node type of this mutation (Label).
  14198. func (m *LabelMutation) Type() string {
  14199. return m.typ
  14200. }
  14201. // Fields returns all fields that were changed during this mutation. Note that in
  14202. // order to get all numeric fields that were incremented/decremented, call
  14203. // AddedFields().
  14204. func (m *LabelMutation) Fields() []string {
  14205. fields := make([]string, 0, 9)
  14206. if m.created_at != nil {
  14207. fields = append(fields, label.FieldCreatedAt)
  14208. }
  14209. if m.updated_at != nil {
  14210. fields = append(fields, label.FieldUpdatedAt)
  14211. }
  14212. if m.status != nil {
  14213. fields = append(fields, label.FieldStatus)
  14214. }
  14215. if m._type != nil {
  14216. fields = append(fields, label.FieldType)
  14217. }
  14218. if m.name != nil {
  14219. fields = append(fields, label.FieldName)
  14220. }
  14221. if m.from != nil {
  14222. fields = append(fields, label.FieldFrom)
  14223. }
  14224. if m.mode != nil {
  14225. fields = append(fields, label.FieldMode)
  14226. }
  14227. if m.conditions != nil {
  14228. fields = append(fields, label.FieldConditions)
  14229. }
  14230. if m.organization_id != nil {
  14231. fields = append(fields, label.FieldOrganizationID)
  14232. }
  14233. return fields
  14234. }
  14235. // Field returns the value of a field with the given name. The second boolean
  14236. // return value indicates that this field was not set, or was not defined in the
  14237. // schema.
  14238. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14239. switch name {
  14240. case label.FieldCreatedAt:
  14241. return m.CreatedAt()
  14242. case label.FieldUpdatedAt:
  14243. return m.UpdatedAt()
  14244. case label.FieldStatus:
  14245. return m.Status()
  14246. case label.FieldType:
  14247. return m.GetType()
  14248. case label.FieldName:
  14249. return m.Name()
  14250. case label.FieldFrom:
  14251. return m.From()
  14252. case label.FieldMode:
  14253. return m.Mode()
  14254. case label.FieldConditions:
  14255. return m.Conditions()
  14256. case label.FieldOrganizationID:
  14257. return m.OrganizationID()
  14258. }
  14259. return nil, false
  14260. }
  14261. // OldField returns the old value of the field from the database. An error is
  14262. // returned if the mutation operation is not UpdateOne, or the query to the
  14263. // database failed.
  14264. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14265. switch name {
  14266. case label.FieldCreatedAt:
  14267. return m.OldCreatedAt(ctx)
  14268. case label.FieldUpdatedAt:
  14269. return m.OldUpdatedAt(ctx)
  14270. case label.FieldStatus:
  14271. return m.OldStatus(ctx)
  14272. case label.FieldType:
  14273. return m.OldType(ctx)
  14274. case label.FieldName:
  14275. return m.OldName(ctx)
  14276. case label.FieldFrom:
  14277. return m.OldFrom(ctx)
  14278. case label.FieldMode:
  14279. return m.OldMode(ctx)
  14280. case label.FieldConditions:
  14281. return m.OldConditions(ctx)
  14282. case label.FieldOrganizationID:
  14283. return m.OldOrganizationID(ctx)
  14284. }
  14285. return nil, fmt.Errorf("unknown Label field %s", name)
  14286. }
  14287. // SetField sets the value of a field with the given name. It returns an error if
  14288. // the field is not defined in the schema, or if the type mismatched the field
  14289. // type.
  14290. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14291. switch name {
  14292. case label.FieldCreatedAt:
  14293. v, ok := value.(time.Time)
  14294. if !ok {
  14295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14296. }
  14297. m.SetCreatedAt(v)
  14298. return nil
  14299. case label.FieldUpdatedAt:
  14300. v, ok := value.(time.Time)
  14301. if !ok {
  14302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14303. }
  14304. m.SetUpdatedAt(v)
  14305. return nil
  14306. case label.FieldStatus:
  14307. v, ok := value.(uint8)
  14308. if !ok {
  14309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14310. }
  14311. m.SetStatus(v)
  14312. return nil
  14313. case label.FieldType:
  14314. v, ok := value.(int)
  14315. if !ok {
  14316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14317. }
  14318. m.SetType(v)
  14319. return nil
  14320. case label.FieldName:
  14321. v, ok := value.(string)
  14322. if !ok {
  14323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14324. }
  14325. m.SetName(v)
  14326. return nil
  14327. case label.FieldFrom:
  14328. v, ok := value.(int)
  14329. if !ok {
  14330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14331. }
  14332. m.SetFrom(v)
  14333. return nil
  14334. case label.FieldMode:
  14335. v, ok := value.(int)
  14336. if !ok {
  14337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14338. }
  14339. m.SetMode(v)
  14340. return nil
  14341. case label.FieldConditions:
  14342. v, ok := value.(string)
  14343. if !ok {
  14344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14345. }
  14346. m.SetConditions(v)
  14347. return nil
  14348. case label.FieldOrganizationID:
  14349. v, ok := value.(uint64)
  14350. if !ok {
  14351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14352. }
  14353. m.SetOrganizationID(v)
  14354. return nil
  14355. }
  14356. return fmt.Errorf("unknown Label field %s", name)
  14357. }
  14358. // AddedFields returns all numeric fields that were incremented/decremented during
  14359. // this mutation.
  14360. func (m *LabelMutation) AddedFields() []string {
  14361. var fields []string
  14362. if m.addstatus != nil {
  14363. fields = append(fields, label.FieldStatus)
  14364. }
  14365. if m.add_type != nil {
  14366. fields = append(fields, label.FieldType)
  14367. }
  14368. if m.addfrom != nil {
  14369. fields = append(fields, label.FieldFrom)
  14370. }
  14371. if m.addmode != nil {
  14372. fields = append(fields, label.FieldMode)
  14373. }
  14374. if m.addorganization_id != nil {
  14375. fields = append(fields, label.FieldOrganizationID)
  14376. }
  14377. return fields
  14378. }
  14379. // AddedField returns the numeric value that was incremented/decremented on a field
  14380. // with the given name. The second boolean return value indicates that this field
  14381. // was not set, or was not defined in the schema.
  14382. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14383. switch name {
  14384. case label.FieldStatus:
  14385. return m.AddedStatus()
  14386. case label.FieldType:
  14387. return m.AddedType()
  14388. case label.FieldFrom:
  14389. return m.AddedFrom()
  14390. case label.FieldMode:
  14391. return m.AddedMode()
  14392. case label.FieldOrganizationID:
  14393. return m.AddedOrganizationID()
  14394. }
  14395. return nil, false
  14396. }
  14397. // AddField adds the value to the field with the given name. It returns an error if
  14398. // the field is not defined in the schema, or if the type mismatched the field
  14399. // type.
  14400. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14401. switch name {
  14402. case label.FieldStatus:
  14403. v, ok := value.(int8)
  14404. if !ok {
  14405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14406. }
  14407. m.AddStatus(v)
  14408. return nil
  14409. case label.FieldType:
  14410. v, ok := value.(int)
  14411. if !ok {
  14412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14413. }
  14414. m.AddType(v)
  14415. return nil
  14416. case label.FieldFrom:
  14417. v, ok := value.(int)
  14418. if !ok {
  14419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14420. }
  14421. m.AddFrom(v)
  14422. return nil
  14423. case label.FieldMode:
  14424. v, ok := value.(int)
  14425. if !ok {
  14426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14427. }
  14428. m.AddMode(v)
  14429. return nil
  14430. case label.FieldOrganizationID:
  14431. v, ok := value.(int64)
  14432. if !ok {
  14433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14434. }
  14435. m.AddOrganizationID(v)
  14436. return nil
  14437. }
  14438. return fmt.Errorf("unknown Label numeric field %s", name)
  14439. }
  14440. // ClearedFields returns all nullable fields that were cleared during this
  14441. // mutation.
  14442. func (m *LabelMutation) ClearedFields() []string {
  14443. var fields []string
  14444. if m.FieldCleared(label.FieldStatus) {
  14445. fields = append(fields, label.FieldStatus)
  14446. }
  14447. if m.FieldCleared(label.FieldConditions) {
  14448. fields = append(fields, label.FieldConditions)
  14449. }
  14450. if m.FieldCleared(label.FieldOrganizationID) {
  14451. fields = append(fields, label.FieldOrganizationID)
  14452. }
  14453. return fields
  14454. }
  14455. // FieldCleared returns a boolean indicating if a field with the given name was
  14456. // cleared in this mutation.
  14457. func (m *LabelMutation) FieldCleared(name string) bool {
  14458. _, ok := m.clearedFields[name]
  14459. return ok
  14460. }
  14461. // ClearField clears the value of the field with the given name. It returns an
  14462. // error if the field is not defined in the schema.
  14463. func (m *LabelMutation) ClearField(name string) error {
  14464. switch name {
  14465. case label.FieldStatus:
  14466. m.ClearStatus()
  14467. return nil
  14468. case label.FieldConditions:
  14469. m.ClearConditions()
  14470. return nil
  14471. case label.FieldOrganizationID:
  14472. m.ClearOrganizationID()
  14473. return nil
  14474. }
  14475. return fmt.Errorf("unknown Label nullable field %s", name)
  14476. }
  14477. // ResetField resets all changes in the mutation for the field with the given name.
  14478. // It returns an error if the field is not defined in the schema.
  14479. func (m *LabelMutation) ResetField(name string) error {
  14480. switch name {
  14481. case label.FieldCreatedAt:
  14482. m.ResetCreatedAt()
  14483. return nil
  14484. case label.FieldUpdatedAt:
  14485. m.ResetUpdatedAt()
  14486. return nil
  14487. case label.FieldStatus:
  14488. m.ResetStatus()
  14489. return nil
  14490. case label.FieldType:
  14491. m.ResetType()
  14492. return nil
  14493. case label.FieldName:
  14494. m.ResetName()
  14495. return nil
  14496. case label.FieldFrom:
  14497. m.ResetFrom()
  14498. return nil
  14499. case label.FieldMode:
  14500. m.ResetMode()
  14501. return nil
  14502. case label.FieldConditions:
  14503. m.ResetConditions()
  14504. return nil
  14505. case label.FieldOrganizationID:
  14506. m.ResetOrganizationID()
  14507. return nil
  14508. }
  14509. return fmt.Errorf("unknown Label field %s", name)
  14510. }
  14511. // AddedEdges returns all edge names that were set/added in this mutation.
  14512. func (m *LabelMutation) AddedEdges() []string {
  14513. edges := make([]string, 0, 1)
  14514. if m.label_relationships != nil {
  14515. edges = append(edges, label.EdgeLabelRelationships)
  14516. }
  14517. return edges
  14518. }
  14519. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14520. // name in this mutation.
  14521. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14522. switch name {
  14523. case label.EdgeLabelRelationships:
  14524. ids := make([]ent.Value, 0, len(m.label_relationships))
  14525. for id := range m.label_relationships {
  14526. ids = append(ids, id)
  14527. }
  14528. return ids
  14529. }
  14530. return nil
  14531. }
  14532. // RemovedEdges returns all edge names that were removed in this mutation.
  14533. func (m *LabelMutation) RemovedEdges() []string {
  14534. edges := make([]string, 0, 1)
  14535. if m.removedlabel_relationships != nil {
  14536. edges = append(edges, label.EdgeLabelRelationships)
  14537. }
  14538. return edges
  14539. }
  14540. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14541. // the given name in this mutation.
  14542. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14543. switch name {
  14544. case label.EdgeLabelRelationships:
  14545. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14546. for id := range m.removedlabel_relationships {
  14547. ids = append(ids, id)
  14548. }
  14549. return ids
  14550. }
  14551. return nil
  14552. }
  14553. // ClearedEdges returns all edge names that were cleared in this mutation.
  14554. func (m *LabelMutation) ClearedEdges() []string {
  14555. edges := make([]string, 0, 1)
  14556. if m.clearedlabel_relationships {
  14557. edges = append(edges, label.EdgeLabelRelationships)
  14558. }
  14559. return edges
  14560. }
  14561. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14562. // was cleared in this mutation.
  14563. func (m *LabelMutation) EdgeCleared(name string) bool {
  14564. switch name {
  14565. case label.EdgeLabelRelationships:
  14566. return m.clearedlabel_relationships
  14567. }
  14568. return false
  14569. }
  14570. // ClearEdge clears the value of the edge with the given name. It returns an error
  14571. // if that edge is not defined in the schema.
  14572. func (m *LabelMutation) ClearEdge(name string) error {
  14573. switch name {
  14574. }
  14575. return fmt.Errorf("unknown Label unique edge %s", name)
  14576. }
  14577. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14578. // It returns an error if the edge is not defined in the schema.
  14579. func (m *LabelMutation) ResetEdge(name string) error {
  14580. switch name {
  14581. case label.EdgeLabelRelationships:
  14582. m.ResetLabelRelationships()
  14583. return nil
  14584. }
  14585. return fmt.Errorf("unknown Label edge %s", name)
  14586. }
  14587. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14588. type LabelRelationshipMutation struct {
  14589. config
  14590. op Op
  14591. typ string
  14592. id *uint64
  14593. created_at *time.Time
  14594. updated_at *time.Time
  14595. status *uint8
  14596. addstatus *int8
  14597. organization_id *uint64
  14598. addorganization_id *int64
  14599. clearedFields map[string]struct{}
  14600. contacts *uint64
  14601. clearedcontacts bool
  14602. labels *uint64
  14603. clearedlabels bool
  14604. done bool
  14605. oldValue func(context.Context) (*LabelRelationship, error)
  14606. predicates []predicate.LabelRelationship
  14607. }
  14608. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14609. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14610. type labelrelationshipOption func(*LabelRelationshipMutation)
  14611. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14612. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14613. m := &LabelRelationshipMutation{
  14614. config: c,
  14615. op: op,
  14616. typ: TypeLabelRelationship,
  14617. clearedFields: make(map[string]struct{}),
  14618. }
  14619. for _, opt := range opts {
  14620. opt(m)
  14621. }
  14622. return m
  14623. }
  14624. // withLabelRelationshipID sets the ID field of the mutation.
  14625. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14626. return func(m *LabelRelationshipMutation) {
  14627. var (
  14628. err error
  14629. once sync.Once
  14630. value *LabelRelationship
  14631. )
  14632. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14633. once.Do(func() {
  14634. if m.done {
  14635. err = errors.New("querying old values post mutation is not allowed")
  14636. } else {
  14637. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14638. }
  14639. })
  14640. return value, err
  14641. }
  14642. m.id = &id
  14643. }
  14644. }
  14645. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14646. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14647. return func(m *LabelRelationshipMutation) {
  14648. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14649. return node, nil
  14650. }
  14651. m.id = &node.ID
  14652. }
  14653. }
  14654. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14655. // executed in a transaction (ent.Tx), a transactional client is returned.
  14656. func (m LabelRelationshipMutation) Client() *Client {
  14657. client := &Client{config: m.config}
  14658. client.init()
  14659. return client
  14660. }
  14661. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14662. // it returns an error otherwise.
  14663. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14664. if _, ok := m.driver.(*txDriver); !ok {
  14665. return nil, errors.New("ent: mutation is not running in a transaction")
  14666. }
  14667. tx := &Tx{config: m.config}
  14668. tx.init()
  14669. return tx, nil
  14670. }
  14671. // SetID sets the value of the id field. Note that this
  14672. // operation is only accepted on creation of LabelRelationship entities.
  14673. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14674. m.id = &id
  14675. }
  14676. // ID returns the ID value in the mutation. Note that the ID is only available
  14677. // if it was provided to the builder or after it was returned from the database.
  14678. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14679. if m.id == nil {
  14680. return
  14681. }
  14682. return *m.id, true
  14683. }
  14684. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14685. // That means, if the mutation is applied within a transaction with an isolation level such
  14686. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14687. // or updated by the mutation.
  14688. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14689. switch {
  14690. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14691. id, exists := m.ID()
  14692. if exists {
  14693. return []uint64{id}, nil
  14694. }
  14695. fallthrough
  14696. case m.op.Is(OpUpdate | OpDelete):
  14697. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14698. default:
  14699. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14700. }
  14701. }
  14702. // SetCreatedAt sets the "created_at" field.
  14703. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14704. m.created_at = &t
  14705. }
  14706. // CreatedAt returns the value of the "created_at" field in the mutation.
  14707. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14708. v := m.created_at
  14709. if v == nil {
  14710. return
  14711. }
  14712. return *v, true
  14713. }
  14714. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14715. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14717. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14718. if !m.op.Is(OpUpdateOne) {
  14719. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14720. }
  14721. if m.id == nil || m.oldValue == nil {
  14722. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14723. }
  14724. oldValue, err := m.oldValue(ctx)
  14725. if err != nil {
  14726. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14727. }
  14728. return oldValue.CreatedAt, nil
  14729. }
  14730. // ResetCreatedAt resets all changes to the "created_at" field.
  14731. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14732. m.created_at = nil
  14733. }
  14734. // SetUpdatedAt sets the "updated_at" field.
  14735. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14736. m.updated_at = &t
  14737. }
  14738. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14739. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14740. v := m.updated_at
  14741. if v == nil {
  14742. return
  14743. }
  14744. return *v, true
  14745. }
  14746. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14747. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14749. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14750. if !m.op.Is(OpUpdateOne) {
  14751. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14752. }
  14753. if m.id == nil || m.oldValue == nil {
  14754. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14755. }
  14756. oldValue, err := m.oldValue(ctx)
  14757. if err != nil {
  14758. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14759. }
  14760. return oldValue.UpdatedAt, nil
  14761. }
  14762. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14763. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14764. m.updated_at = nil
  14765. }
  14766. // SetStatus sets the "status" field.
  14767. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14768. m.status = &u
  14769. m.addstatus = nil
  14770. }
  14771. // Status returns the value of the "status" field in the mutation.
  14772. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14773. v := m.status
  14774. if v == nil {
  14775. return
  14776. }
  14777. return *v, true
  14778. }
  14779. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14780. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14782. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14783. if !m.op.Is(OpUpdateOne) {
  14784. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14785. }
  14786. if m.id == nil || m.oldValue == nil {
  14787. return v, errors.New("OldStatus requires an ID field in the mutation")
  14788. }
  14789. oldValue, err := m.oldValue(ctx)
  14790. if err != nil {
  14791. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14792. }
  14793. return oldValue.Status, nil
  14794. }
  14795. // AddStatus adds u to the "status" field.
  14796. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14797. if m.addstatus != nil {
  14798. *m.addstatus += u
  14799. } else {
  14800. m.addstatus = &u
  14801. }
  14802. }
  14803. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14804. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14805. v := m.addstatus
  14806. if v == nil {
  14807. return
  14808. }
  14809. return *v, true
  14810. }
  14811. // ClearStatus clears the value of the "status" field.
  14812. func (m *LabelRelationshipMutation) ClearStatus() {
  14813. m.status = nil
  14814. m.addstatus = nil
  14815. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14816. }
  14817. // StatusCleared returns if the "status" field was cleared in this mutation.
  14818. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14819. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14820. return ok
  14821. }
  14822. // ResetStatus resets all changes to the "status" field.
  14823. func (m *LabelRelationshipMutation) ResetStatus() {
  14824. m.status = nil
  14825. m.addstatus = nil
  14826. delete(m.clearedFields, labelrelationship.FieldStatus)
  14827. }
  14828. // SetLabelID sets the "label_id" field.
  14829. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14830. m.labels = &u
  14831. }
  14832. // LabelID returns the value of the "label_id" field in the mutation.
  14833. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14834. v := m.labels
  14835. if v == nil {
  14836. return
  14837. }
  14838. return *v, true
  14839. }
  14840. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14841. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14843. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14844. if !m.op.Is(OpUpdateOne) {
  14845. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14846. }
  14847. if m.id == nil || m.oldValue == nil {
  14848. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14849. }
  14850. oldValue, err := m.oldValue(ctx)
  14851. if err != nil {
  14852. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14853. }
  14854. return oldValue.LabelID, nil
  14855. }
  14856. // ResetLabelID resets all changes to the "label_id" field.
  14857. func (m *LabelRelationshipMutation) ResetLabelID() {
  14858. m.labels = nil
  14859. }
  14860. // SetContactID sets the "contact_id" field.
  14861. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14862. m.contacts = &u
  14863. }
  14864. // ContactID returns the value of the "contact_id" field in the mutation.
  14865. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14866. v := m.contacts
  14867. if v == nil {
  14868. return
  14869. }
  14870. return *v, true
  14871. }
  14872. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14873. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14875. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14876. if !m.op.Is(OpUpdateOne) {
  14877. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14878. }
  14879. if m.id == nil || m.oldValue == nil {
  14880. return v, errors.New("OldContactID requires an ID field in the mutation")
  14881. }
  14882. oldValue, err := m.oldValue(ctx)
  14883. if err != nil {
  14884. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14885. }
  14886. return oldValue.ContactID, nil
  14887. }
  14888. // ResetContactID resets all changes to the "contact_id" field.
  14889. func (m *LabelRelationshipMutation) ResetContactID() {
  14890. m.contacts = nil
  14891. }
  14892. // SetOrganizationID sets the "organization_id" field.
  14893. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14894. m.organization_id = &u
  14895. m.addorganization_id = nil
  14896. }
  14897. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14898. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14899. v := m.organization_id
  14900. if v == nil {
  14901. return
  14902. }
  14903. return *v, true
  14904. }
  14905. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14906. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14908. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14909. if !m.op.Is(OpUpdateOne) {
  14910. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14911. }
  14912. if m.id == nil || m.oldValue == nil {
  14913. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14914. }
  14915. oldValue, err := m.oldValue(ctx)
  14916. if err != nil {
  14917. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14918. }
  14919. return oldValue.OrganizationID, nil
  14920. }
  14921. // AddOrganizationID adds u to the "organization_id" field.
  14922. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14923. if m.addorganization_id != nil {
  14924. *m.addorganization_id += u
  14925. } else {
  14926. m.addorganization_id = &u
  14927. }
  14928. }
  14929. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14930. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14931. v := m.addorganization_id
  14932. if v == nil {
  14933. return
  14934. }
  14935. return *v, true
  14936. }
  14937. // ClearOrganizationID clears the value of the "organization_id" field.
  14938. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14939. m.organization_id = nil
  14940. m.addorganization_id = nil
  14941. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14942. }
  14943. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14944. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14945. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14946. return ok
  14947. }
  14948. // ResetOrganizationID resets all changes to the "organization_id" field.
  14949. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14950. m.organization_id = nil
  14951. m.addorganization_id = nil
  14952. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14953. }
  14954. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14955. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14956. m.contacts = &id
  14957. }
  14958. // ClearContacts clears the "contacts" edge to the Contact entity.
  14959. func (m *LabelRelationshipMutation) ClearContacts() {
  14960. m.clearedcontacts = true
  14961. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14962. }
  14963. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14964. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14965. return m.clearedcontacts
  14966. }
  14967. // ContactsID returns the "contacts" edge ID in the mutation.
  14968. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14969. if m.contacts != nil {
  14970. return *m.contacts, true
  14971. }
  14972. return
  14973. }
  14974. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14975. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14976. // ContactsID instead. It exists only for internal usage by the builders.
  14977. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14978. if id := m.contacts; id != nil {
  14979. ids = append(ids, *id)
  14980. }
  14981. return
  14982. }
  14983. // ResetContacts resets all changes to the "contacts" edge.
  14984. func (m *LabelRelationshipMutation) ResetContacts() {
  14985. m.contacts = nil
  14986. m.clearedcontacts = false
  14987. }
  14988. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14989. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14990. m.labels = &id
  14991. }
  14992. // ClearLabels clears the "labels" edge to the Label entity.
  14993. func (m *LabelRelationshipMutation) ClearLabels() {
  14994. m.clearedlabels = true
  14995. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14996. }
  14997. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14998. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14999. return m.clearedlabels
  15000. }
  15001. // LabelsID returns the "labels" edge ID in the mutation.
  15002. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15003. if m.labels != nil {
  15004. return *m.labels, true
  15005. }
  15006. return
  15007. }
  15008. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15009. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15010. // LabelsID instead. It exists only for internal usage by the builders.
  15011. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15012. if id := m.labels; id != nil {
  15013. ids = append(ids, *id)
  15014. }
  15015. return
  15016. }
  15017. // ResetLabels resets all changes to the "labels" edge.
  15018. func (m *LabelRelationshipMutation) ResetLabels() {
  15019. m.labels = nil
  15020. m.clearedlabels = false
  15021. }
  15022. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15023. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15024. m.predicates = append(m.predicates, ps...)
  15025. }
  15026. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15027. // users can use type-assertion to append predicates that do not depend on any generated package.
  15028. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15029. p := make([]predicate.LabelRelationship, len(ps))
  15030. for i := range ps {
  15031. p[i] = ps[i]
  15032. }
  15033. m.Where(p...)
  15034. }
  15035. // Op returns the operation name.
  15036. func (m *LabelRelationshipMutation) Op() Op {
  15037. return m.op
  15038. }
  15039. // SetOp allows setting the mutation operation.
  15040. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15041. m.op = op
  15042. }
  15043. // Type returns the node type of this mutation (LabelRelationship).
  15044. func (m *LabelRelationshipMutation) Type() string {
  15045. return m.typ
  15046. }
  15047. // Fields returns all fields that were changed during this mutation. Note that in
  15048. // order to get all numeric fields that were incremented/decremented, call
  15049. // AddedFields().
  15050. func (m *LabelRelationshipMutation) Fields() []string {
  15051. fields := make([]string, 0, 6)
  15052. if m.created_at != nil {
  15053. fields = append(fields, labelrelationship.FieldCreatedAt)
  15054. }
  15055. if m.updated_at != nil {
  15056. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15057. }
  15058. if m.status != nil {
  15059. fields = append(fields, labelrelationship.FieldStatus)
  15060. }
  15061. if m.labels != nil {
  15062. fields = append(fields, labelrelationship.FieldLabelID)
  15063. }
  15064. if m.contacts != nil {
  15065. fields = append(fields, labelrelationship.FieldContactID)
  15066. }
  15067. if m.organization_id != nil {
  15068. fields = append(fields, labelrelationship.FieldOrganizationID)
  15069. }
  15070. return fields
  15071. }
  15072. // Field returns the value of a field with the given name. The second boolean
  15073. // return value indicates that this field was not set, or was not defined in the
  15074. // schema.
  15075. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15076. switch name {
  15077. case labelrelationship.FieldCreatedAt:
  15078. return m.CreatedAt()
  15079. case labelrelationship.FieldUpdatedAt:
  15080. return m.UpdatedAt()
  15081. case labelrelationship.FieldStatus:
  15082. return m.Status()
  15083. case labelrelationship.FieldLabelID:
  15084. return m.LabelID()
  15085. case labelrelationship.FieldContactID:
  15086. return m.ContactID()
  15087. case labelrelationship.FieldOrganizationID:
  15088. return m.OrganizationID()
  15089. }
  15090. return nil, false
  15091. }
  15092. // OldField returns the old value of the field from the database. An error is
  15093. // returned if the mutation operation is not UpdateOne, or the query to the
  15094. // database failed.
  15095. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15096. switch name {
  15097. case labelrelationship.FieldCreatedAt:
  15098. return m.OldCreatedAt(ctx)
  15099. case labelrelationship.FieldUpdatedAt:
  15100. return m.OldUpdatedAt(ctx)
  15101. case labelrelationship.FieldStatus:
  15102. return m.OldStatus(ctx)
  15103. case labelrelationship.FieldLabelID:
  15104. return m.OldLabelID(ctx)
  15105. case labelrelationship.FieldContactID:
  15106. return m.OldContactID(ctx)
  15107. case labelrelationship.FieldOrganizationID:
  15108. return m.OldOrganizationID(ctx)
  15109. }
  15110. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15111. }
  15112. // SetField sets the value of a field with the given name. It returns an error if
  15113. // the field is not defined in the schema, or if the type mismatched the field
  15114. // type.
  15115. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15116. switch name {
  15117. case labelrelationship.FieldCreatedAt:
  15118. v, ok := value.(time.Time)
  15119. if !ok {
  15120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15121. }
  15122. m.SetCreatedAt(v)
  15123. return nil
  15124. case labelrelationship.FieldUpdatedAt:
  15125. v, ok := value.(time.Time)
  15126. if !ok {
  15127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15128. }
  15129. m.SetUpdatedAt(v)
  15130. return nil
  15131. case labelrelationship.FieldStatus:
  15132. v, ok := value.(uint8)
  15133. if !ok {
  15134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15135. }
  15136. m.SetStatus(v)
  15137. return nil
  15138. case labelrelationship.FieldLabelID:
  15139. v, ok := value.(uint64)
  15140. if !ok {
  15141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15142. }
  15143. m.SetLabelID(v)
  15144. return nil
  15145. case labelrelationship.FieldContactID:
  15146. v, ok := value.(uint64)
  15147. if !ok {
  15148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15149. }
  15150. m.SetContactID(v)
  15151. return nil
  15152. case labelrelationship.FieldOrganizationID:
  15153. v, ok := value.(uint64)
  15154. if !ok {
  15155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15156. }
  15157. m.SetOrganizationID(v)
  15158. return nil
  15159. }
  15160. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15161. }
  15162. // AddedFields returns all numeric fields that were incremented/decremented during
  15163. // this mutation.
  15164. func (m *LabelRelationshipMutation) AddedFields() []string {
  15165. var fields []string
  15166. if m.addstatus != nil {
  15167. fields = append(fields, labelrelationship.FieldStatus)
  15168. }
  15169. if m.addorganization_id != nil {
  15170. fields = append(fields, labelrelationship.FieldOrganizationID)
  15171. }
  15172. return fields
  15173. }
  15174. // AddedField returns the numeric value that was incremented/decremented on a field
  15175. // with the given name. The second boolean return value indicates that this field
  15176. // was not set, or was not defined in the schema.
  15177. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15178. switch name {
  15179. case labelrelationship.FieldStatus:
  15180. return m.AddedStatus()
  15181. case labelrelationship.FieldOrganizationID:
  15182. return m.AddedOrganizationID()
  15183. }
  15184. return nil, false
  15185. }
  15186. // AddField adds the value to the field with the given name. It returns an error if
  15187. // the field is not defined in the schema, or if the type mismatched the field
  15188. // type.
  15189. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15190. switch name {
  15191. case labelrelationship.FieldStatus:
  15192. v, ok := value.(int8)
  15193. if !ok {
  15194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15195. }
  15196. m.AddStatus(v)
  15197. return nil
  15198. case labelrelationship.FieldOrganizationID:
  15199. v, ok := value.(int64)
  15200. if !ok {
  15201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15202. }
  15203. m.AddOrganizationID(v)
  15204. return nil
  15205. }
  15206. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15207. }
  15208. // ClearedFields returns all nullable fields that were cleared during this
  15209. // mutation.
  15210. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15211. var fields []string
  15212. if m.FieldCleared(labelrelationship.FieldStatus) {
  15213. fields = append(fields, labelrelationship.FieldStatus)
  15214. }
  15215. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15216. fields = append(fields, labelrelationship.FieldOrganizationID)
  15217. }
  15218. return fields
  15219. }
  15220. // FieldCleared returns a boolean indicating if a field with the given name was
  15221. // cleared in this mutation.
  15222. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15223. _, ok := m.clearedFields[name]
  15224. return ok
  15225. }
  15226. // ClearField clears the value of the field with the given name. It returns an
  15227. // error if the field is not defined in the schema.
  15228. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15229. switch name {
  15230. case labelrelationship.FieldStatus:
  15231. m.ClearStatus()
  15232. return nil
  15233. case labelrelationship.FieldOrganizationID:
  15234. m.ClearOrganizationID()
  15235. return nil
  15236. }
  15237. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15238. }
  15239. // ResetField resets all changes in the mutation for the field with the given name.
  15240. // It returns an error if the field is not defined in the schema.
  15241. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15242. switch name {
  15243. case labelrelationship.FieldCreatedAt:
  15244. m.ResetCreatedAt()
  15245. return nil
  15246. case labelrelationship.FieldUpdatedAt:
  15247. m.ResetUpdatedAt()
  15248. return nil
  15249. case labelrelationship.FieldStatus:
  15250. m.ResetStatus()
  15251. return nil
  15252. case labelrelationship.FieldLabelID:
  15253. m.ResetLabelID()
  15254. return nil
  15255. case labelrelationship.FieldContactID:
  15256. m.ResetContactID()
  15257. return nil
  15258. case labelrelationship.FieldOrganizationID:
  15259. m.ResetOrganizationID()
  15260. return nil
  15261. }
  15262. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15263. }
  15264. // AddedEdges returns all edge names that were set/added in this mutation.
  15265. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15266. edges := make([]string, 0, 2)
  15267. if m.contacts != nil {
  15268. edges = append(edges, labelrelationship.EdgeContacts)
  15269. }
  15270. if m.labels != nil {
  15271. edges = append(edges, labelrelationship.EdgeLabels)
  15272. }
  15273. return edges
  15274. }
  15275. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15276. // name in this mutation.
  15277. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15278. switch name {
  15279. case labelrelationship.EdgeContacts:
  15280. if id := m.contacts; id != nil {
  15281. return []ent.Value{*id}
  15282. }
  15283. case labelrelationship.EdgeLabels:
  15284. if id := m.labels; id != nil {
  15285. return []ent.Value{*id}
  15286. }
  15287. }
  15288. return nil
  15289. }
  15290. // RemovedEdges returns all edge names that were removed in this mutation.
  15291. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15292. edges := make([]string, 0, 2)
  15293. return edges
  15294. }
  15295. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15296. // the given name in this mutation.
  15297. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15298. return nil
  15299. }
  15300. // ClearedEdges returns all edge names that were cleared in this mutation.
  15301. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15302. edges := make([]string, 0, 2)
  15303. if m.clearedcontacts {
  15304. edges = append(edges, labelrelationship.EdgeContacts)
  15305. }
  15306. if m.clearedlabels {
  15307. edges = append(edges, labelrelationship.EdgeLabels)
  15308. }
  15309. return edges
  15310. }
  15311. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15312. // was cleared in this mutation.
  15313. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15314. switch name {
  15315. case labelrelationship.EdgeContacts:
  15316. return m.clearedcontacts
  15317. case labelrelationship.EdgeLabels:
  15318. return m.clearedlabels
  15319. }
  15320. return false
  15321. }
  15322. // ClearEdge clears the value of the edge with the given name. It returns an error
  15323. // if that edge is not defined in the schema.
  15324. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15325. switch name {
  15326. case labelrelationship.EdgeContacts:
  15327. m.ClearContacts()
  15328. return nil
  15329. case labelrelationship.EdgeLabels:
  15330. m.ClearLabels()
  15331. return nil
  15332. }
  15333. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15334. }
  15335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15336. // It returns an error if the edge is not defined in the schema.
  15337. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15338. switch name {
  15339. case labelrelationship.EdgeContacts:
  15340. m.ResetContacts()
  15341. return nil
  15342. case labelrelationship.EdgeLabels:
  15343. m.ResetLabels()
  15344. return nil
  15345. }
  15346. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15347. }
  15348. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15349. type LabelTaggingMutation struct {
  15350. config
  15351. op Op
  15352. typ string
  15353. id *uint64
  15354. created_at *time.Time
  15355. updated_at *time.Time
  15356. status *uint8
  15357. addstatus *int8
  15358. deleted_at *time.Time
  15359. organization_id *uint64
  15360. addorganization_id *int64
  15361. _type *int
  15362. add_type *int
  15363. conditions *string
  15364. action_label_add *[]uint64
  15365. appendaction_label_add []uint64
  15366. action_label_del *[]uint64
  15367. appendaction_label_del []uint64
  15368. clearedFields map[string]struct{}
  15369. done bool
  15370. oldValue func(context.Context) (*LabelTagging, error)
  15371. predicates []predicate.LabelTagging
  15372. }
  15373. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15374. // labeltaggingOption allows management of the mutation configuration using functional options.
  15375. type labeltaggingOption func(*LabelTaggingMutation)
  15376. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15377. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15378. m := &LabelTaggingMutation{
  15379. config: c,
  15380. op: op,
  15381. typ: TypeLabelTagging,
  15382. clearedFields: make(map[string]struct{}),
  15383. }
  15384. for _, opt := range opts {
  15385. opt(m)
  15386. }
  15387. return m
  15388. }
  15389. // withLabelTaggingID sets the ID field of the mutation.
  15390. func withLabelTaggingID(id uint64) labeltaggingOption {
  15391. return func(m *LabelTaggingMutation) {
  15392. var (
  15393. err error
  15394. once sync.Once
  15395. value *LabelTagging
  15396. )
  15397. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15398. once.Do(func() {
  15399. if m.done {
  15400. err = errors.New("querying old values post mutation is not allowed")
  15401. } else {
  15402. value, err = m.Client().LabelTagging.Get(ctx, id)
  15403. }
  15404. })
  15405. return value, err
  15406. }
  15407. m.id = &id
  15408. }
  15409. }
  15410. // withLabelTagging sets the old LabelTagging of the mutation.
  15411. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15412. return func(m *LabelTaggingMutation) {
  15413. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15414. return node, nil
  15415. }
  15416. m.id = &node.ID
  15417. }
  15418. }
  15419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15420. // executed in a transaction (ent.Tx), a transactional client is returned.
  15421. func (m LabelTaggingMutation) Client() *Client {
  15422. client := &Client{config: m.config}
  15423. client.init()
  15424. return client
  15425. }
  15426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15427. // it returns an error otherwise.
  15428. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15429. if _, ok := m.driver.(*txDriver); !ok {
  15430. return nil, errors.New("ent: mutation is not running in a transaction")
  15431. }
  15432. tx := &Tx{config: m.config}
  15433. tx.init()
  15434. return tx, nil
  15435. }
  15436. // SetID sets the value of the id field. Note that this
  15437. // operation is only accepted on creation of LabelTagging entities.
  15438. func (m *LabelTaggingMutation) SetID(id uint64) {
  15439. m.id = &id
  15440. }
  15441. // ID returns the ID value in the mutation. Note that the ID is only available
  15442. // if it was provided to the builder or after it was returned from the database.
  15443. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15444. if m.id == nil {
  15445. return
  15446. }
  15447. return *m.id, true
  15448. }
  15449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15450. // That means, if the mutation is applied within a transaction with an isolation level such
  15451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15452. // or updated by the mutation.
  15453. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15454. switch {
  15455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15456. id, exists := m.ID()
  15457. if exists {
  15458. return []uint64{id}, nil
  15459. }
  15460. fallthrough
  15461. case m.op.Is(OpUpdate | OpDelete):
  15462. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15463. default:
  15464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15465. }
  15466. }
  15467. // SetCreatedAt sets the "created_at" field.
  15468. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15469. m.created_at = &t
  15470. }
  15471. // CreatedAt returns the value of the "created_at" field in the mutation.
  15472. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15473. v := m.created_at
  15474. if v == nil {
  15475. return
  15476. }
  15477. return *v, true
  15478. }
  15479. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15480. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15482. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15483. if !m.op.Is(OpUpdateOne) {
  15484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15485. }
  15486. if m.id == nil || m.oldValue == nil {
  15487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15488. }
  15489. oldValue, err := m.oldValue(ctx)
  15490. if err != nil {
  15491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15492. }
  15493. return oldValue.CreatedAt, nil
  15494. }
  15495. // ResetCreatedAt resets all changes to the "created_at" field.
  15496. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15497. m.created_at = nil
  15498. }
  15499. // SetUpdatedAt sets the "updated_at" field.
  15500. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15501. m.updated_at = &t
  15502. }
  15503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15504. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15505. v := m.updated_at
  15506. if v == nil {
  15507. return
  15508. }
  15509. return *v, true
  15510. }
  15511. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15512. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15514. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15515. if !m.op.Is(OpUpdateOne) {
  15516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15517. }
  15518. if m.id == nil || m.oldValue == nil {
  15519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15520. }
  15521. oldValue, err := m.oldValue(ctx)
  15522. if err != nil {
  15523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15524. }
  15525. return oldValue.UpdatedAt, nil
  15526. }
  15527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15528. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15529. m.updated_at = nil
  15530. }
  15531. // SetStatus sets the "status" field.
  15532. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15533. m.status = &u
  15534. m.addstatus = nil
  15535. }
  15536. // Status returns the value of the "status" field in the mutation.
  15537. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15538. v := m.status
  15539. if v == nil {
  15540. return
  15541. }
  15542. return *v, true
  15543. }
  15544. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15545. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15547. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15548. if !m.op.Is(OpUpdateOne) {
  15549. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15550. }
  15551. if m.id == nil || m.oldValue == nil {
  15552. return v, errors.New("OldStatus requires an ID field in the mutation")
  15553. }
  15554. oldValue, err := m.oldValue(ctx)
  15555. if err != nil {
  15556. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15557. }
  15558. return oldValue.Status, nil
  15559. }
  15560. // AddStatus adds u to the "status" field.
  15561. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15562. if m.addstatus != nil {
  15563. *m.addstatus += u
  15564. } else {
  15565. m.addstatus = &u
  15566. }
  15567. }
  15568. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15569. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15570. v := m.addstatus
  15571. if v == nil {
  15572. return
  15573. }
  15574. return *v, true
  15575. }
  15576. // ClearStatus clears the value of the "status" field.
  15577. func (m *LabelTaggingMutation) ClearStatus() {
  15578. m.status = nil
  15579. m.addstatus = nil
  15580. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15581. }
  15582. // StatusCleared returns if the "status" field was cleared in this mutation.
  15583. func (m *LabelTaggingMutation) StatusCleared() bool {
  15584. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15585. return ok
  15586. }
  15587. // ResetStatus resets all changes to the "status" field.
  15588. func (m *LabelTaggingMutation) ResetStatus() {
  15589. m.status = nil
  15590. m.addstatus = nil
  15591. delete(m.clearedFields, labeltagging.FieldStatus)
  15592. }
  15593. // SetDeletedAt sets the "deleted_at" field.
  15594. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15595. m.deleted_at = &t
  15596. }
  15597. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15598. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15599. v := m.deleted_at
  15600. if v == nil {
  15601. return
  15602. }
  15603. return *v, true
  15604. }
  15605. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15606. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15608. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15609. if !m.op.Is(OpUpdateOne) {
  15610. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15611. }
  15612. if m.id == nil || m.oldValue == nil {
  15613. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15614. }
  15615. oldValue, err := m.oldValue(ctx)
  15616. if err != nil {
  15617. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15618. }
  15619. return oldValue.DeletedAt, nil
  15620. }
  15621. // ClearDeletedAt clears the value of the "deleted_at" field.
  15622. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15623. m.deleted_at = nil
  15624. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15625. }
  15626. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15627. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15628. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15629. return ok
  15630. }
  15631. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15632. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15633. m.deleted_at = nil
  15634. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15635. }
  15636. // SetOrganizationID sets the "organization_id" field.
  15637. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15638. m.organization_id = &u
  15639. m.addorganization_id = nil
  15640. }
  15641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15642. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15643. v := m.organization_id
  15644. if v == nil {
  15645. return
  15646. }
  15647. return *v, true
  15648. }
  15649. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15650. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15652. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15653. if !m.op.Is(OpUpdateOne) {
  15654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15655. }
  15656. if m.id == nil || m.oldValue == nil {
  15657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15658. }
  15659. oldValue, err := m.oldValue(ctx)
  15660. if err != nil {
  15661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15662. }
  15663. return oldValue.OrganizationID, nil
  15664. }
  15665. // AddOrganizationID adds u to the "organization_id" field.
  15666. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15667. if m.addorganization_id != nil {
  15668. *m.addorganization_id += u
  15669. } else {
  15670. m.addorganization_id = &u
  15671. }
  15672. }
  15673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15674. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15675. v := m.addorganization_id
  15676. if v == nil {
  15677. return
  15678. }
  15679. return *v, true
  15680. }
  15681. // ResetOrganizationID resets all changes to the "organization_id" field.
  15682. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15683. m.organization_id = nil
  15684. m.addorganization_id = nil
  15685. }
  15686. // SetType sets the "type" field.
  15687. func (m *LabelTaggingMutation) SetType(i int) {
  15688. m._type = &i
  15689. m.add_type = nil
  15690. }
  15691. // GetType returns the value of the "type" field in the mutation.
  15692. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15693. v := m._type
  15694. if v == nil {
  15695. return
  15696. }
  15697. return *v, true
  15698. }
  15699. // OldType returns the old "type" field's value of the LabelTagging entity.
  15700. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15702. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15703. if !m.op.Is(OpUpdateOne) {
  15704. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15705. }
  15706. if m.id == nil || m.oldValue == nil {
  15707. return v, errors.New("OldType requires an ID field in the mutation")
  15708. }
  15709. oldValue, err := m.oldValue(ctx)
  15710. if err != nil {
  15711. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15712. }
  15713. return oldValue.Type, nil
  15714. }
  15715. // AddType adds i to the "type" field.
  15716. func (m *LabelTaggingMutation) AddType(i int) {
  15717. if m.add_type != nil {
  15718. *m.add_type += i
  15719. } else {
  15720. m.add_type = &i
  15721. }
  15722. }
  15723. // AddedType returns the value that was added to the "type" field in this mutation.
  15724. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15725. v := m.add_type
  15726. if v == nil {
  15727. return
  15728. }
  15729. return *v, true
  15730. }
  15731. // ResetType resets all changes to the "type" field.
  15732. func (m *LabelTaggingMutation) ResetType() {
  15733. m._type = nil
  15734. m.add_type = nil
  15735. }
  15736. // SetConditions sets the "conditions" field.
  15737. func (m *LabelTaggingMutation) SetConditions(s string) {
  15738. m.conditions = &s
  15739. }
  15740. // Conditions returns the value of the "conditions" field in the mutation.
  15741. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15742. v := m.conditions
  15743. if v == nil {
  15744. return
  15745. }
  15746. return *v, true
  15747. }
  15748. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15749. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15751. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15752. if !m.op.Is(OpUpdateOne) {
  15753. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15754. }
  15755. if m.id == nil || m.oldValue == nil {
  15756. return v, errors.New("OldConditions requires an ID field in the mutation")
  15757. }
  15758. oldValue, err := m.oldValue(ctx)
  15759. if err != nil {
  15760. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15761. }
  15762. return oldValue.Conditions, nil
  15763. }
  15764. // ResetConditions resets all changes to the "conditions" field.
  15765. func (m *LabelTaggingMutation) ResetConditions() {
  15766. m.conditions = nil
  15767. }
  15768. // SetActionLabelAdd sets the "action_label_add" field.
  15769. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15770. m.action_label_add = &u
  15771. m.appendaction_label_add = nil
  15772. }
  15773. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15774. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15775. v := m.action_label_add
  15776. if v == nil {
  15777. return
  15778. }
  15779. return *v, true
  15780. }
  15781. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15782. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15784. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15785. if !m.op.Is(OpUpdateOne) {
  15786. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15787. }
  15788. if m.id == nil || m.oldValue == nil {
  15789. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15790. }
  15791. oldValue, err := m.oldValue(ctx)
  15792. if err != nil {
  15793. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15794. }
  15795. return oldValue.ActionLabelAdd, nil
  15796. }
  15797. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15798. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15799. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15800. }
  15801. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15802. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15803. if len(m.appendaction_label_add) == 0 {
  15804. return nil, false
  15805. }
  15806. return m.appendaction_label_add, true
  15807. }
  15808. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15809. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15810. m.action_label_add = nil
  15811. m.appendaction_label_add = nil
  15812. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15813. }
  15814. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15815. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15816. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15817. return ok
  15818. }
  15819. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15820. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15821. m.action_label_add = nil
  15822. m.appendaction_label_add = nil
  15823. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15824. }
  15825. // SetActionLabelDel sets the "action_label_del" field.
  15826. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15827. m.action_label_del = &u
  15828. m.appendaction_label_del = nil
  15829. }
  15830. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15831. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15832. v := m.action_label_del
  15833. if v == nil {
  15834. return
  15835. }
  15836. return *v, true
  15837. }
  15838. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15839. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15841. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15842. if !m.op.Is(OpUpdateOne) {
  15843. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15844. }
  15845. if m.id == nil || m.oldValue == nil {
  15846. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15847. }
  15848. oldValue, err := m.oldValue(ctx)
  15849. if err != nil {
  15850. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15851. }
  15852. return oldValue.ActionLabelDel, nil
  15853. }
  15854. // AppendActionLabelDel adds u to the "action_label_del" field.
  15855. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15856. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15857. }
  15858. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15859. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15860. if len(m.appendaction_label_del) == 0 {
  15861. return nil, false
  15862. }
  15863. return m.appendaction_label_del, true
  15864. }
  15865. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15866. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15867. m.action_label_del = nil
  15868. m.appendaction_label_del = nil
  15869. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15870. }
  15871. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15872. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15873. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15874. return ok
  15875. }
  15876. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15877. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15878. m.action_label_del = nil
  15879. m.appendaction_label_del = nil
  15880. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15881. }
  15882. // Where appends a list predicates to the LabelTaggingMutation builder.
  15883. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15884. m.predicates = append(m.predicates, ps...)
  15885. }
  15886. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15887. // users can use type-assertion to append predicates that do not depend on any generated package.
  15888. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15889. p := make([]predicate.LabelTagging, len(ps))
  15890. for i := range ps {
  15891. p[i] = ps[i]
  15892. }
  15893. m.Where(p...)
  15894. }
  15895. // Op returns the operation name.
  15896. func (m *LabelTaggingMutation) Op() Op {
  15897. return m.op
  15898. }
  15899. // SetOp allows setting the mutation operation.
  15900. func (m *LabelTaggingMutation) SetOp(op Op) {
  15901. m.op = op
  15902. }
  15903. // Type returns the node type of this mutation (LabelTagging).
  15904. func (m *LabelTaggingMutation) Type() string {
  15905. return m.typ
  15906. }
  15907. // Fields returns all fields that were changed during this mutation. Note that in
  15908. // order to get all numeric fields that were incremented/decremented, call
  15909. // AddedFields().
  15910. func (m *LabelTaggingMutation) Fields() []string {
  15911. fields := make([]string, 0, 9)
  15912. if m.created_at != nil {
  15913. fields = append(fields, labeltagging.FieldCreatedAt)
  15914. }
  15915. if m.updated_at != nil {
  15916. fields = append(fields, labeltagging.FieldUpdatedAt)
  15917. }
  15918. if m.status != nil {
  15919. fields = append(fields, labeltagging.FieldStatus)
  15920. }
  15921. if m.deleted_at != nil {
  15922. fields = append(fields, labeltagging.FieldDeletedAt)
  15923. }
  15924. if m.organization_id != nil {
  15925. fields = append(fields, labeltagging.FieldOrganizationID)
  15926. }
  15927. if m._type != nil {
  15928. fields = append(fields, labeltagging.FieldType)
  15929. }
  15930. if m.conditions != nil {
  15931. fields = append(fields, labeltagging.FieldConditions)
  15932. }
  15933. if m.action_label_add != nil {
  15934. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15935. }
  15936. if m.action_label_del != nil {
  15937. fields = append(fields, labeltagging.FieldActionLabelDel)
  15938. }
  15939. return fields
  15940. }
  15941. // Field returns the value of a field with the given name. The second boolean
  15942. // return value indicates that this field was not set, or was not defined in the
  15943. // schema.
  15944. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15945. switch name {
  15946. case labeltagging.FieldCreatedAt:
  15947. return m.CreatedAt()
  15948. case labeltagging.FieldUpdatedAt:
  15949. return m.UpdatedAt()
  15950. case labeltagging.FieldStatus:
  15951. return m.Status()
  15952. case labeltagging.FieldDeletedAt:
  15953. return m.DeletedAt()
  15954. case labeltagging.FieldOrganizationID:
  15955. return m.OrganizationID()
  15956. case labeltagging.FieldType:
  15957. return m.GetType()
  15958. case labeltagging.FieldConditions:
  15959. return m.Conditions()
  15960. case labeltagging.FieldActionLabelAdd:
  15961. return m.ActionLabelAdd()
  15962. case labeltagging.FieldActionLabelDel:
  15963. return m.ActionLabelDel()
  15964. }
  15965. return nil, false
  15966. }
  15967. // OldField returns the old value of the field from the database. An error is
  15968. // returned if the mutation operation is not UpdateOne, or the query to the
  15969. // database failed.
  15970. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15971. switch name {
  15972. case labeltagging.FieldCreatedAt:
  15973. return m.OldCreatedAt(ctx)
  15974. case labeltagging.FieldUpdatedAt:
  15975. return m.OldUpdatedAt(ctx)
  15976. case labeltagging.FieldStatus:
  15977. return m.OldStatus(ctx)
  15978. case labeltagging.FieldDeletedAt:
  15979. return m.OldDeletedAt(ctx)
  15980. case labeltagging.FieldOrganizationID:
  15981. return m.OldOrganizationID(ctx)
  15982. case labeltagging.FieldType:
  15983. return m.OldType(ctx)
  15984. case labeltagging.FieldConditions:
  15985. return m.OldConditions(ctx)
  15986. case labeltagging.FieldActionLabelAdd:
  15987. return m.OldActionLabelAdd(ctx)
  15988. case labeltagging.FieldActionLabelDel:
  15989. return m.OldActionLabelDel(ctx)
  15990. }
  15991. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15992. }
  15993. // SetField sets the value of a field with the given name. It returns an error if
  15994. // the field is not defined in the schema, or if the type mismatched the field
  15995. // type.
  15996. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15997. switch name {
  15998. case labeltagging.FieldCreatedAt:
  15999. v, ok := value.(time.Time)
  16000. if !ok {
  16001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16002. }
  16003. m.SetCreatedAt(v)
  16004. return nil
  16005. case labeltagging.FieldUpdatedAt:
  16006. v, ok := value.(time.Time)
  16007. if !ok {
  16008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16009. }
  16010. m.SetUpdatedAt(v)
  16011. return nil
  16012. case labeltagging.FieldStatus:
  16013. v, ok := value.(uint8)
  16014. if !ok {
  16015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16016. }
  16017. m.SetStatus(v)
  16018. return nil
  16019. case labeltagging.FieldDeletedAt:
  16020. v, ok := value.(time.Time)
  16021. if !ok {
  16022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16023. }
  16024. m.SetDeletedAt(v)
  16025. return nil
  16026. case labeltagging.FieldOrganizationID:
  16027. v, ok := value.(uint64)
  16028. if !ok {
  16029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16030. }
  16031. m.SetOrganizationID(v)
  16032. return nil
  16033. case labeltagging.FieldType:
  16034. v, ok := value.(int)
  16035. if !ok {
  16036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16037. }
  16038. m.SetType(v)
  16039. return nil
  16040. case labeltagging.FieldConditions:
  16041. v, ok := value.(string)
  16042. if !ok {
  16043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16044. }
  16045. m.SetConditions(v)
  16046. return nil
  16047. case labeltagging.FieldActionLabelAdd:
  16048. v, ok := value.([]uint64)
  16049. if !ok {
  16050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16051. }
  16052. m.SetActionLabelAdd(v)
  16053. return nil
  16054. case labeltagging.FieldActionLabelDel:
  16055. v, ok := value.([]uint64)
  16056. if !ok {
  16057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16058. }
  16059. m.SetActionLabelDel(v)
  16060. return nil
  16061. }
  16062. return fmt.Errorf("unknown LabelTagging field %s", name)
  16063. }
  16064. // AddedFields returns all numeric fields that were incremented/decremented during
  16065. // this mutation.
  16066. func (m *LabelTaggingMutation) AddedFields() []string {
  16067. var fields []string
  16068. if m.addstatus != nil {
  16069. fields = append(fields, labeltagging.FieldStatus)
  16070. }
  16071. if m.addorganization_id != nil {
  16072. fields = append(fields, labeltagging.FieldOrganizationID)
  16073. }
  16074. if m.add_type != nil {
  16075. fields = append(fields, labeltagging.FieldType)
  16076. }
  16077. return fields
  16078. }
  16079. // AddedField returns the numeric value that was incremented/decremented on a field
  16080. // with the given name. The second boolean return value indicates that this field
  16081. // was not set, or was not defined in the schema.
  16082. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16083. switch name {
  16084. case labeltagging.FieldStatus:
  16085. return m.AddedStatus()
  16086. case labeltagging.FieldOrganizationID:
  16087. return m.AddedOrganizationID()
  16088. case labeltagging.FieldType:
  16089. return m.AddedType()
  16090. }
  16091. return nil, false
  16092. }
  16093. // AddField adds the value to the field with the given name. It returns an error if
  16094. // the field is not defined in the schema, or if the type mismatched the field
  16095. // type.
  16096. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16097. switch name {
  16098. case labeltagging.FieldStatus:
  16099. v, ok := value.(int8)
  16100. if !ok {
  16101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16102. }
  16103. m.AddStatus(v)
  16104. return nil
  16105. case labeltagging.FieldOrganizationID:
  16106. v, ok := value.(int64)
  16107. if !ok {
  16108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16109. }
  16110. m.AddOrganizationID(v)
  16111. return nil
  16112. case labeltagging.FieldType:
  16113. v, ok := value.(int)
  16114. if !ok {
  16115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16116. }
  16117. m.AddType(v)
  16118. return nil
  16119. }
  16120. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16121. }
  16122. // ClearedFields returns all nullable fields that were cleared during this
  16123. // mutation.
  16124. func (m *LabelTaggingMutation) ClearedFields() []string {
  16125. var fields []string
  16126. if m.FieldCleared(labeltagging.FieldStatus) {
  16127. fields = append(fields, labeltagging.FieldStatus)
  16128. }
  16129. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16130. fields = append(fields, labeltagging.FieldDeletedAt)
  16131. }
  16132. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16133. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16134. }
  16135. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16136. fields = append(fields, labeltagging.FieldActionLabelDel)
  16137. }
  16138. return fields
  16139. }
  16140. // FieldCleared returns a boolean indicating if a field with the given name was
  16141. // cleared in this mutation.
  16142. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16143. _, ok := m.clearedFields[name]
  16144. return ok
  16145. }
  16146. // ClearField clears the value of the field with the given name. It returns an
  16147. // error if the field is not defined in the schema.
  16148. func (m *LabelTaggingMutation) ClearField(name string) error {
  16149. switch name {
  16150. case labeltagging.FieldStatus:
  16151. m.ClearStatus()
  16152. return nil
  16153. case labeltagging.FieldDeletedAt:
  16154. m.ClearDeletedAt()
  16155. return nil
  16156. case labeltagging.FieldActionLabelAdd:
  16157. m.ClearActionLabelAdd()
  16158. return nil
  16159. case labeltagging.FieldActionLabelDel:
  16160. m.ClearActionLabelDel()
  16161. return nil
  16162. }
  16163. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16164. }
  16165. // ResetField resets all changes in the mutation for the field with the given name.
  16166. // It returns an error if the field is not defined in the schema.
  16167. func (m *LabelTaggingMutation) ResetField(name string) error {
  16168. switch name {
  16169. case labeltagging.FieldCreatedAt:
  16170. m.ResetCreatedAt()
  16171. return nil
  16172. case labeltagging.FieldUpdatedAt:
  16173. m.ResetUpdatedAt()
  16174. return nil
  16175. case labeltagging.FieldStatus:
  16176. m.ResetStatus()
  16177. return nil
  16178. case labeltagging.FieldDeletedAt:
  16179. m.ResetDeletedAt()
  16180. return nil
  16181. case labeltagging.FieldOrganizationID:
  16182. m.ResetOrganizationID()
  16183. return nil
  16184. case labeltagging.FieldType:
  16185. m.ResetType()
  16186. return nil
  16187. case labeltagging.FieldConditions:
  16188. m.ResetConditions()
  16189. return nil
  16190. case labeltagging.FieldActionLabelAdd:
  16191. m.ResetActionLabelAdd()
  16192. return nil
  16193. case labeltagging.FieldActionLabelDel:
  16194. m.ResetActionLabelDel()
  16195. return nil
  16196. }
  16197. return fmt.Errorf("unknown LabelTagging field %s", name)
  16198. }
  16199. // AddedEdges returns all edge names that were set/added in this mutation.
  16200. func (m *LabelTaggingMutation) AddedEdges() []string {
  16201. edges := make([]string, 0, 0)
  16202. return edges
  16203. }
  16204. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16205. // name in this mutation.
  16206. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16207. return nil
  16208. }
  16209. // RemovedEdges returns all edge names that were removed in this mutation.
  16210. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16211. edges := make([]string, 0, 0)
  16212. return edges
  16213. }
  16214. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16215. // the given name in this mutation.
  16216. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16217. return nil
  16218. }
  16219. // ClearedEdges returns all edge names that were cleared in this mutation.
  16220. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16221. edges := make([]string, 0, 0)
  16222. return edges
  16223. }
  16224. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16225. // was cleared in this mutation.
  16226. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16227. return false
  16228. }
  16229. // ClearEdge clears the value of the edge with the given name. It returns an error
  16230. // if that edge is not defined in the schema.
  16231. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16232. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16233. }
  16234. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16235. // It returns an error if the edge is not defined in the schema.
  16236. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16237. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16238. }
  16239. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16240. type MessageMutation struct {
  16241. config
  16242. op Op
  16243. typ string
  16244. id *int
  16245. wx_wxid *string
  16246. wxid *string
  16247. content *string
  16248. clearedFields map[string]struct{}
  16249. done bool
  16250. oldValue func(context.Context) (*Message, error)
  16251. predicates []predicate.Message
  16252. }
  16253. var _ ent.Mutation = (*MessageMutation)(nil)
  16254. // messageOption allows management of the mutation configuration using functional options.
  16255. type messageOption func(*MessageMutation)
  16256. // newMessageMutation creates new mutation for the Message entity.
  16257. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16258. m := &MessageMutation{
  16259. config: c,
  16260. op: op,
  16261. typ: TypeMessage,
  16262. clearedFields: make(map[string]struct{}),
  16263. }
  16264. for _, opt := range opts {
  16265. opt(m)
  16266. }
  16267. return m
  16268. }
  16269. // withMessageID sets the ID field of the mutation.
  16270. func withMessageID(id int) messageOption {
  16271. return func(m *MessageMutation) {
  16272. var (
  16273. err error
  16274. once sync.Once
  16275. value *Message
  16276. )
  16277. m.oldValue = func(ctx context.Context) (*Message, error) {
  16278. once.Do(func() {
  16279. if m.done {
  16280. err = errors.New("querying old values post mutation is not allowed")
  16281. } else {
  16282. value, err = m.Client().Message.Get(ctx, id)
  16283. }
  16284. })
  16285. return value, err
  16286. }
  16287. m.id = &id
  16288. }
  16289. }
  16290. // withMessage sets the old Message of the mutation.
  16291. func withMessage(node *Message) messageOption {
  16292. return func(m *MessageMutation) {
  16293. m.oldValue = func(context.Context) (*Message, error) {
  16294. return node, nil
  16295. }
  16296. m.id = &node.ID
  16297. }
  16298. }
  16299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16300. // executed in a transaction (ent.Tx), a transactional client is returned.
  16301. func (m MessageMutation) Client() *Client {
  16302. client := &Client{config: m.config}
  16303. client.init()
  16304. return client
  16305. }
  16306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16307. // it returns an error otherwise.
  16308. func (m MessageMutation) Tx() (*Tx, error) {
  16309. if _, ok := m.driver.(*txDriver); !ok {
  16310. return nil, errors.New("ent: mutation is not running in a transaction")
  16311. }
  16312. tx := &Tx{config: m.config}
  16313. tx.init()
  16314. return tx, nil
  16315. }
  16316. // ID returns the ID value in the mutation. Note that the ID is only available
  16317. // if it was provided to the builder or after it was returned from the database.
  16318. func (m *MessageMutation) ID() (id int, exists bool) {
  16319. if m.id == nil {
  16320. return
  16321. }
  16322. return *m.id, true
  16323. }
  16324. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16325. // That means, if the mutation is applied within a transaction with an isolation level such
  16326. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16327. // or updated by the mutation.
  16328. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16329. switch {
  16330. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16331. id, exists := m.ID()
  16332. if exists {
  16333. return []int{id}, nil
  16334. }
  16335. fallthrough
  16336. case m.op.Is(OpUpdate | OpDelete):
  16337. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16338. default:
  16339. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16340. }
  16341. }
  16342. // SetWxWxid sets the "wx_wxid" field.
  16343. func (m *MessageMutation) SetWxWxid(s string) {
  16344. m.wx_wxid = &s
  16345. }
  16346. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16347. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16348. v := m.wx_wxid
  16349. if v == nil {
  16350. return
  16351. }
  16352. return *v, true
  16353. }
  16354. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16355. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16357. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16358. if !m.op.Is(OpUpdateOne) {
  16359. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16360. }
  16361. if m.id == nil || m.oldValue == nil {
  16362. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16363. }
  16364. oldValue, err := m.oldValue(ctx)
  16365. if err != nil {
  16366. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16367. }
  16368. return oldValue.WxWxid, nil
  16369. }
  16370. // ClearWxWxid clears the value of the "wx_wxid" field.
  16371. func (m *MessageMutation) ClearWxWxid() {
  16372. m.wx_wxid = nil
  16373. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16374. }
  16375. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16376. func (m *MessageMutation) WxWxidCleared() bool {
  16377. _, ok := m.clearedFields[message.FieldWxWxid]
  16378. return ok
  16379. }
  16380. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16381. func (m *MessageMutation) ResetWxWxid() {
  16382. m.wx_wxid = nil
  16383. delete(m.clearedFields, message.FieldWxWxid)
  16384. }
  16385. // SetWxid sets the "wxid" field.
  16386. func (m *MessageMutation) SetWxid(s string) {
  16387. m.wxid = &s
  16388. }
  16389. // Wxid returns the value of the "wxid" field in the mutation.
  16390. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16391. v := m.wxid
  16392. if v == nil {
  16393. return
  16394. }
  16395. return *v, true
  16396. }
  16397. // OldWxid returns the old "wxid" field's value of the Message entity.
  16398. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16400. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16401. if !m.op.Is(OpUpdateOne) {
  16402. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16403. }
  16404. if m.id == nil || m.oldValue == nil {
  16405. return v, errors.New("OldWxid requires an ID field in the mutation")
  16406. }
  16407. oldValue, err := m.oldValue(ctx)
  16408. if err != nil {
  16409. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16410. }
  16411. return oldValue.Wxid, nil
  16412. }
  16413. // ResetWxid resets all changes to the "wxid" field.
  16414. func (m *MessageMutation) ResetWxid() {
  16415. m.wxid = nil
  16416. }
  16417. // SetContent sets the "content" field.
  16418. func (m *MessageMutation) SetContent(s string) {
  16419. m.content = &s
  16420. }
  16421. // Content returns the value of the "content" field in the mutation.
  16422. func (m *MessageMutation) Content() (r string, exists bool) {
  16423. v := m.content
  16424. if v == nil {
  16425. return
  16426. }
  16427. return *v, true
  16428. }
  16429. // OldContent returns the old "content" field's value of the Message entity.
  16430. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16432. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16433. if !m.op.Is(OpUpdateOne) {
  16434. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16435. }
  16436. if m.id == nil || m.oldValue == nil {
  16437. return v, errors.New("OldContent requires an ID field in the mutation")
  16438. }
  16439. oldValue, err := m.oldValue(ctx)
  16440. if err != nil {
  16441. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16442. }
  16443. return oldValue.Content, nil
  16444. }
  16445. // ResetContent resets all changes to the "content" field.
  16446. func (m *MessageMutation) ResetContent() {
  16447. m.content = nil
  16448. }
  16449. // Where appends a list predicates to the MessageMutation builder.
  16450. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16451. m.predicates = append(m.predicates, ps...)
  16452. }
  16453. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16454. // users can use type-assertion to append predicates that do not depend on any generated package.
  16455. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16456. p := make([]predicate.Message, len(ps))
  16457. for i := range ps {
  16458. p[i] = ps[i]
  16459. }
  16460. m.Where(p...)
  16461. }
  16462. // Op returns the operation name.
  16463. func (m *MessageMutation) Op() Op {
  16464. return m.op
  16465. }
  16466. // SetOp allows setting the mutation operation.
  16467. func (m *MessageMutation) SetOp(op Op) {
  16468. m.op = op
  16469. }
  16470. // Type returns the node type of this mutation (Message).
  16471. func (m *MessageMutation) Type() string {
  16472. return m.typ
  16473. }
  16474. // Fields returns all fields that were changed during this mutation. Note that in
  16475. // order to get all numeric fields that were incremented/decremented, call
  16476. // AddedFields().
  16477. func (m *MessageMutation) Fields() []string {
  16478. fields := make([]string, 0, 3)
  16479. if m.wx_wxid != nil {
  16480. fields = append(fields, message.FieldWxWxid)
  16481. }
  16482. if m.wxid != nil {
  16483. fields = append(fields, message.FieldWxid)
  16484. }
  16485. if m.content != nil {
  16486. fields = append(fields, message.FieldContent)
  16487. }
  16488. return fields
  16489. }
  16490. // Field returns the value of a field with the given name. The second boolean
  16491. // return value indicates that this field was not set, or was not defined in the
  16492. // schema.
  16493. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16494. switch name {
  16495. case message.FieldWxWxid:
  16496. return m.WxWxid()
  16497. case message.FieldWxid:
  16498. return m.Wxid()
  16499. case message.FieldContent:
  16500. return m.Content()
  16501. }
  16502. return nil, false
  16503. }
  16504. // OldField returns the old value of the field from the database. An error is
  16505. // returned if the mutation operation is not UpdateOne, or the query to the
  16506. // database failed.
  16507. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16508. switch name {
  16509. case message.FieldWxWxid:
  16510. return m.OldWxWxid(ctx)
  16511. case message.FieldWxid:
  16512. return m.OldWxid(ctx)
  16513. case message.FieldContent:
  16514. return m.OldContent(ctx)
  16515. }
  16516. return nil, fmt.Errorf("unknown Message field %s", name)
  16517. }
  16518. // SetField sets the value of a field with the given name. It returns an error if
  16519. // the field is not defined in the schema, or if the type mismatched the field
  16520. // type.
  16521. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16522. switch name {
  16523. case message.FieldWxWxid:
  16524. v, ok := value.(string)
  16525. if !ok {
  16526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16527. }
  16528. m.SetWxWxid(v)
  16529. return nil
  16530. case message.FieldWxid:
  16531. v, ok := value.(string)
  16532. if !ok {
  16533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16534. }
  16535. m.SetWxid(v)
  16536. return nil
  16537. case message.FieldContent:
  16538. v, ok := value.(string)
  16539. if !ok {
  16540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16541. }
  16542. m.SetContent(v)
  16543. return nil
  16544. }
  16545. return fmt.Errorf("unknown Message field %s", name)
  16546. }
  16547. // AddedFields returns all numeric fields that were incremented/decremented during
  16548. // this mutation.
  16549. func (m *MessageMutation) AddedFields() []string {
  16550. return nil
  16551. }
  16552. // AddedField returns the numeric value that was incremented/decremented on a field
  16553. // with the given name. The second boolean return value indicates that this field
  16554. // was not set, or was not defined in the schema.
  16555. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16556. return nil, false
  16557. }
  16558. // AddField adds the value to the field with the given name. It returns an error if
  16559. // the field is not defined in the schema, or if the type mismatched the field
  16560. // type.
  16561. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16562. switch name {
  16563. }
  16564. return fmt.Errorf("unknown Message numeric field %s", name)
  16565. }
  16566. // ClearedFields returns all nullable fields that were cleared during this
  16567. // mutation.
  16568. func (m *MessageMutation) ClearedFields() []string {
  16569. var fields []string
  16570. if m.FieldCleared(message.FieldWxWxid) {
  16571. fields = append(fields, message.FieldWxWxid)
  16572. }
  16573. return fields
  16574. }
  16575. // FieldCleared returns a boolean indicating if a field with the given name was
  16576. // cleared in this mutation.
  16577. func (m *MessageMutation) FieldCleared(name string) bool {
  16578. _, ok := m.clearedFields[name]
  16579. return ok
  16580. }
  16581. // ClearField clears the value of the field with the given name. It returns an
  16582. // error if the field is not defined in the schema.
  16583. func (m *MessageMutation) ClearField(name string) error {
  16584. switch name {
  16585. case message.FieldWxWxid:
  16586. m.ClearWxWxid()
  16587. return nil
  16588. }
  16589. return fmt.Errorf("unknown Message nullable field %s", name)
  16590. }
  16591. // ResetField resets all changes in the mutation for the field with the given name.
  16592. // It returns an error if the field is not defined in the schema.
  16593. func (m *MessageMutation) ResetField(name string) error {
  16594. switch name {
  16595. case message.FieldWxWxid:
  16596. m.ResetWxWxid()
  16597. return nil
  16598. case message.FieldWxid:
  16599. m.ResetWxid()
  16600. return nil
  16601. case message.FieldContent:
  16602. m.ResetContent()
  16603. return nil
  16604. }
  16605. return fmt.Errorf("unknown Message field %s", name)
  16606. }
  16607. // AddedEdges returns all edge names that were set/added in this mutation.
  16608. func (m *MessageMutation) AddedEdges() []string {
  16609. edges := make([]string, 0, 0)
  16610. return edges
  16611. }
  16612. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16613. // name in this mutation.
  16614. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16615. return nil
  16616. }
  16617. // RemovedEdges returns all edge names that were removed in this mutation.
  16618. func (m *MessageMutation) RemovedEdges() []string {
  16619. edges := make([]string, 0, 0)
  16620. return edges
  16621. }
  16622. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16623. // the given name in this mutation.
  16624. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16625. return nil
  16626. }
  16627. // ClearedEdges returns all edge names that were cleared in this mutation.
  16628. func (m *MessageMutation) ClearedEdges() []string {
  16629. edges := make([]string, 0, 0)
  16630. return edges
  16631. }
  16632. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16633. // was cleared in this mutation.
  16634. func (m *MessageMutation) EdgeCleared(name string) bool {
  16635. return false
  16636. }
  16637. // ClearEdge clears the value of the edge with the given name. It returns an error
  16638. // if that edge is not defined in the schema.
  16639. func (m *MessageMutation) ClearEdge(name string) error {
  16640. return fmt.Errorf("unknown Message unique edge %s", name)
  16641. }
  16642. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16643. // It returns an error if the edge is not defined in the schema.
  16644. func (m *MessageMutation) ResetEdge(name string) error {
  16645. return fmt.Errorf("unknown Message edge %s", name)
  16646. }
  16647. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16648. type MessageRecordsMutation struct {
  16649. config
  16650. op Op
  16651. typ string
  16652. id *uint64
  16653. created_at *time.Time
  16654. updated_at *time.Time
  16655. status *uint8
  16656. addstatus *int8
  16657. bot_wxid *string
  16658. contact_type *int
  16659. addcontact_type *int
  16660. contact_wxid *string
  16661. content_type *int
  16662. addcontent_type *int
  16663. content *string
  16664. meta *custom_types.Meta
  16665. error_detail *string
  16666. send_time *time.Time
  16667. source_type *int
  16668. addsource_type *int
  16669. organization_id *uint64
  16670. addorganization_id *int64
  16671. clearedFields map[string]struct{}
  16672. sop_stage *uint64
  16673. clearedsop_stage bool
  16674. sop_node *uint64
  16675. clearedsop_node bool
  16676. message_contact *uint64
  16677. clearedmessage_contact bool
  16678. done bool
  16679. oldValue func(context.Context) (*MessageRecords, error)
  16680. predicates []predicate.MessageRecords
  16681. }
  16682. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16683. // messagerecordsOption allows management of the mutation configuration using functional options.
  16684. type messagerecordsOption func(*MessageRecordsMutation)
  16685. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16686. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16687. m := &MessageRecordsMutation{
  16688. config: c,
  16689. op: op,
  16690. typ: TypeMessageRecords,
  16691. clearedFields: make(map[string]struct{}),
  16692. }
  16693. for _, opt := range opts {
  16694. opt(m)
  16695. }
  16696. return m
  16697. }
  16698. // withMessageRecordsID sets the ID field of the mutation.
  16699. func withMessageRecordsID(id uint64) messagerecordsOption {
  16700. return func(m *MessageRecordsMutation) {
  16701. var (
  16702. err error
  16703. once sync.Once
  16704. value *MessageRecords
  16705. )
  16706. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16707. once.Do(func() {
  16708. if m.done {
  16709. err = errors.New("querying old values post mutation is not allowed")
  16710. } else {
  16711. value, err = m.Client().MessageRecords.Get(ctx, id)
  16712. }
  16713. })
  16714. return value, err
  16715. }
  16716. m.id = &id
  16717. }
  16718. }
  16719. // withMessageRecords sets the old MessageRecords of the mutation.
  16720. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16721. return func(m *MessageRecordsMutation) {
  16722. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16723. return node, nil
  16724. }
  16725. m.id = &node.ID
  16726. }
  16727. }
  16728. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16729. // executed in a transaction (ent.Tx), a transactional client is returned.
  16730. func (m MessageRecordsMutation) Client() *Client {
  16731. client := &Client{config: m.config}
  16732. client.init()
  16733. return client
  16734. }
  16735. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16736. // it returns an error otherwise.
  16737. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16738. if _, ok := m.driver.(*txDriver); !ok {
  16739. return nil, errors.New("ent: mutation is not running in a transaction")
  16740. }
  16741. tx := &Tx{config: m.config}
  16742. tx.init()
  16743. return tx, nil
  16744. }
  16745. // SetID sets the value of the id field. Note that this
  16746. // operation is only accepted on creation of MessageRecords entities.
  16747. func (m *MessageRecordsMutation) SetID(id uint64) {
  16748. m.id = &id
  16749. }
  16750. // ID returns the ID value in the mutation. Note that the ID is only available
  16751. // if it was provided to the builder or after it was returned from the database.
  16752. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16753. if m.id == nil {
  16754. return
  16755. }
  16756. return *m.id, true
  16757. }
  16758. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16759. // That means, if the mutation is applied within a transaction with an isolation level such
  16760. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16761. // or updated by the mutation.
  16762. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16763. switch {
  16764. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16765. id, exists := m.ID()
  16766. if exists {
  16767. return []uint64{id}, nil
  16768. }
  16769. fallthrough
  16770. case m.op.Is(OpUpdate | OpDelete):
  16771. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16772. default:
  16773. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16774. }
  16775. }
  16776. // SetCreatedAt sets the "created_at" field.
  16777. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16778. m.created_at = &t
  16779. }
  16780. // CreatedAt returns the value of the "created_at" field in the mutation.
  16781. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16782. v := m.created_at
  16783. if v == nil {
  16784. return
  16785. }
  16786. return *v, true
  16787. }
  16788. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16789. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16791. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16792. if !m.op.Is(OpUpdateOne) {
  16793. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16794. }
  16795. if m.id == nil || m.oldValue == nil {
  16796. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16797. }
  16798. oldValue, err := m.oldValue(ctx)
  16799. if err != nil {
  16800. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16801. }
  16802. return oldValue.CreatedAt, nil
  16803. }
  16804. // ResetCreatedAt resets all changes to the "created_at" field.
  16805. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16806. m.created_at = nil
  16807. }
  16808. // SetUpdatedAt sets the "updated_at" field.
  16809. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16810. m.updated_at = &t
  16811. }
  16812. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16813. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16814. v := m.updated_at
  16815. if v == nil {
  16816. return
  16817. }
  16818. return *v, true
  16819. }
  16820. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16821. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16823. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16824. if !m.op.Is(OpUpdateOne) {
  16825. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16826. }
  16827. if m.id == nil || m.oldValue == nil {
  16828. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16829. }
  16830. oldValue, err := m.oldValue(ctx)
  16831. if err != nil {
  16832. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16833. }
  16834. return oldValue.UpdatedAt, nil
  16835. }
  16836. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16837. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16838. m.updated_at = nil
  16839. }
  16840. // SetStatus sets the "status" field.
  16841. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16842. m.status = &u
  16843. m.addstatus = nil
  16844. }
  16845. // Status returns the value of the "status" field in the mutation.
  16846. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16847. v := m.status
  16848. if v == nil {
  16849. return
  16850. }
  16851. return *v, true
  16852. }
  16853. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16854. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16856. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16857. if !m.op.Is(OpUpdateOne) {
  16858. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16859. }
  16860. if m.id == nil || m.oldValue == nil {
  16861. return v, errors.New("OldStatus requires an ID field in the mutation")
  16862. }
  16863. oldValue, err := m.oldValue(ctx)
  16864. if err != nil {
  16865. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16866. }
  16867. return oldValue.Status, nil
  16868. }
  16869. // AddStatus adds u to the "status" field.
  16870. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16871. if m.addstatus != nil {
  16872. *m.addstatus += u
  16873. } else {
  16874. m.addstatus = &u
  16875. }
  16876. }
  16877. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16878. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16879. v := m.addstatus
  16880. if v == nil {
  16881. return
  16882. }
  16883. return *v, true
  16884. }
  16885. // ClearStatus clears the value of the "status" field.
  16886. func (m *MessageRecordsMutation) ClearStatus() {
  16887. m.status = nil
  16888. m.addstatus = nil
  16889. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16890. }
  16891. // StatusCleared returns if the "status" field was cleared in this mutation.
  16892. func (m *MessageRecordsMutation) StatusCleared() bool {
  16893. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16894. return ok
  16895. }
  16896. // ResetStatus resets all changes to the "status" field.
  16897. func (m *MessageRecordsMutation) ResetStatus() {
  16898. m.status = nil
  16899. m.addstatus = nil
  16900. delete(m.clearedFields, messagerecords.FieldStatus)
  16901. }
  16902. // SetBotWxid sets the "bot_wxid" field.
  16903. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16904. m.bot_wxid = &s
  16905. }
  16906. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16907. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16908. v := m.bot_wxid
  16909. if v == nil {
  16910. return
  16911. }
  16912. return *v, true
  16913. }
  16914. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16915. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16917. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16918. if !m.op.Is(OpUpdateOne) {
  16919. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16920. }
  16921. if m.id == nil || m.oldValue == nil {
  16922. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16923. }
  16924. oldValue, err := m.oldValue(ctx)
  16925. if err != nil {
  16926. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16927. }
  16928. return oldValue.BotWxid, nil
  16929. }
  16930. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16931. func (m *MessageRecordsMutation) ResetBotWxid() {
  16932. m.bot_wxid = nil
  16933. }
  16934. // SetContactID sets the "contact_id" field.
  16935. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16936. m.message_contact = &u
  16937. }
  16938. // ContactID returns the value of the "contact_id" field in the mutation.
  16939. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16940. v := m.message_contact
  16941. if v == nil {
  16942. return
  16943. }
  16944. return *v, true
  16945. }
  16946. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16947. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16949. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16950. if !m.op.Is(OpUpdateOne) {
  16951. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16952. }
  16953. if m.id == nil || m.oldValue == nil {
  16954. return v, errors.New("OldContactID requires an ID field in the mutation")
  16955. }
  16956. oldValue, err := m.oldValue(ctx)
  16957. if err != nil {
  16958. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16959. }
  16960. return oldValue.ContactID, nil
  16961. }
  16962. // ClearContactID clears the value of the "contact_id" field.
  16963. func (m *MessageRecordsMutation) ClearContactID() {
  16964. m.message_contact = nil
  16965. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16966. }
  16967. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16968. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16969. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16970. return ok
  16971. }
  16972. // ResetContactID resets all changes to the "contact_id" field.
  16973. func (m *MessageRecordsMutation) ResetContactID() {
  16974. m.message_contact = nil
  16975. delete(m.clearedFields, messagerecords.FieldContactID)
  16976. }
  16977. // SetContactType sets the "contact_type" field.
  16978. func (m *MessageRecordsMutation) SetContactType(i int) {
  16979. m.contact_type = &i
  16980. m.addcontact_type = nil
  16981. }
  16982. // ContactType returns the value of the "contact_type" field in the mutation.
  16983. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16984. v := m.contact_type
  16985. if v == nil {
  16986. return
  16987. }
  16988. return *v, true
  16989. }
  16990. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16991. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16993. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16994. if !m.op.Is(OpUpdateOne) {
  16995. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16996. }
  16997. if m.id == nil || m.oldValue == nil {
  16998. return v, errors.New("OldContactType requires an ID field in the mutation")
  16999. }
  17000. oldValue, err := m.oldValue(ctx)
  17001. if err != nil {
  17002. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17003. }
  17004. return oldValue.ContactType, nil
  17005. }
  17006. // AddContactType adds i to the "contact_type" field.
  17007. func (m *MessageRecordsMutation) AddContactType(i int) {
  17008. if m.addcontact_type != nil {
  17009. *m.addcontact_type += i
  17010. } else {
  17011. m.addcontact_type = &i
  17012. }
  17013. }
  17014. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17015. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17016. v := m.addcontact_type
  17017. if v == nil {
  17018. return
  17019. }
  17020. return *v, true
  17021. }
  17022. // ResetContactType resets all changes to the "contact_type" field.
  17023. func (m *MessageRecordsMutation) ResetContactType() {
  17024. m.contact_type = nil
  17025. m.addcontact_type = nil
  17026. }
  17027. // SetContactWxid sets the "contact_wxid" field.
  17028. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17029. m.contact_wxid = &s
  17030. }
  17031. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17032. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17033. v := m.contact_wxid
  17034. if v == nil {
  17035. return
  17036. }
  17037. return *v, true
  17038. }
  17039. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17040. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17042. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17043. if !m.op.Is(OpUpdateOne) {
  17044. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17045. }
  17046. if m.id == nil || m.oldValue == nil {
  17047. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17048. }
  17049. oldValue, err := m.oldValue(ctx)
  17050. if err != nil {
  17051. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17052. }
  17053. return oldValue.ContactWxid, nil
  17054. }
  17055. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17056. func (m *MessageRecordsMutation) ResetContactWxid() {
  17057. m.contact_wxid = nil
  17058. }
  17059. // SetContentType sets the "content_type" field.
  17060. func (m *MessageRecordsMutation) SetContentType(i int) {
  17061. m.content_type = &i
  17062. m.addcontent_type = nil
  17063. }
  17064. // ContentType returns the value of the "content_type" field in the mutation.
  17065. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17066. v := m.content_type
  17067. if v == nil {
  17068. return
  17069. }
  17070. return *v, true
  17071. }
  17072. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17073. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17075. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17076. if !m.op.Is(OpUpdateOne) {
  17077. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17078. }
  17079. if m.id == nil || m.oldValue == nil {
  17080. return v, errors.New("OldContentType requires an ID field in the mutation")
  17081. }
  17082. oldValue, err := m.oldValue(ctx)
  17083. if err != nil {
  17084. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17085. }
  17086. return oldValue.ContentType, nil
  17087. }
  17088. // AddContentType adds i to the "content_type" field.
  17089. func (m *MessageRecordsMutation) AddContentType(i int) {
  17090. if m.addcontent_type != nil {
  17091. *m.addcontent_type += i
  17092. } else {
  17093. m.addcontent_type = &i
  17094. }
  17095. }
  17096. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17097. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17098. v := m.addcontent_type
  17099. if v == nil {
  17100. return
  17101. }
  17102. return *v, true
  17103. }
  17104. // ResetContentType resets all changes to the "content_type" field.
  17105. func (m *MessageRecordsMutation) ResetContentType() {
  17106. m.content_type = nil
  17107. m.addcontent_type = nil
  17108. }
  17109. // SetContent sets the "content" field.
  17110. func (m *MessageRecordsMutation) SetContent(s string) {
  17111. m.content = &s
  17112. }
  17113. // Content returns the value of the "content" field in the mutation.
  17114. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17115. v := m.content
  17116. if v == nil {
  17117. return
  17118. }
  17119. return *v, true
  17120. }
  17121. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17122. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17124. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17125. if !m.op.Is(OpUpdateOne) {
  17126. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17127. }
  17128. if m.id == nil || m.oldValue == nil {
  17129. return v, errors.New("OldContent requires an ID field in the mutation")
  17130. }
  17131. oldValue, err := m.oldValue(ctx)
  17132. if err != nil {
  17133. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17134. }
  17135. return oldValue.Content, nil
  17136. }
  17137. // ResetContent resets all changes to the "content" field.
  17138. func (m *MessageRecordsMutation) ResetContent() {
  17139. m.content = nil
  17140. }
  17141. // SetMeta sets the "meta" field.
  17142. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17143. m.meta = &ct
  17144. }
  17145. // Meta returns the value of the "meta" field in the mutation.
  17146. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17147. v := m.meta
  17148. if v == nil {
  17149. return
  17150. }
  17151. return *v, true
  17152. }
  17153. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17154. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17156. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17157. if !m.op.Is(OpUpdateOne) {
  17158. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17159. }
  17160. if m.id == nil || m.oldValue == nil {
  17161. return v, errors.New("OldMeta requires an ID field in the mutation")
  17162. }
  17163. oldValue, err := m.oldValue(ctx)
  17164. if err != nil {
  17165. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17166. }
  17167. return oldValue.Meta, nil
  17168. }
  17169. // ClearMeta clears the value of the "meta" field.
  17170. func (m *MessageRecordsMutation) ClearMeta() {
  17171. m.meta = nil
  17172. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17173. }
  17174. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17175. func (m *MessageRecordsMutation) MetaCleared() bool {
  17176. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17177. return ok
  17178. }
  17179. // ResetMeta resets all changes to the "meta" field.
  17180. func (m *MessageRecordsMutation) ResetMeta() {
  17181. m.meta = nil
  17182. delete(m.clearedFields, messagerecords.FieldMeta)
  17183. }
  17184. // SetErrorDetail sets the "error_detail" field.
  17185. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17186. m.error_detail = &s
  17187. }
  17188. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17189. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17190. v := m.error_detail
  17191. if v == nil {
  17192. return
  17193. }
  17194. return *v, true
  17195. }
  17196. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17197. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17199. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17200. if !m.op.Is(OpUpdateOne) {
  17201. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17202. }
  17203. if m.id == nil || m.oldValue == nil {
  17204. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17205. }
  17206. oldValue, err := m.oldValue(ctx)
  17207. if err != nil {
  17208. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17209. }
  17210. return oldValue.ErrorDetail, nil
  17211. }
  17212. // ResetErrorDetail resets all changes to the "error_detail" field.
  17213. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17214. m.error_detail = nil
  17215. }
  17216. // SetSendTime sets the "send_time" field.
  17217. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17218. m.send_time = &t
  17219. }
  17220. // SendTime returns the value of the "send_time" field in the mutation.
  17221. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17222. v := m.send_time
  17223. if v == nil {
  17224. return
  17225. }
  17226. return *v, true
  17227. }
  17228. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17229. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17231. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17232. if !m.op.Is(OpUpdateOne) {
  17233. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17234. }
  17235. if m.id == nil || m.oldValue == nil {
  17236. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17237. }
  17238. oldValue, err := m.oldValue(ctx)
  17239. if err != nil {
  17240. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17241. }
  17242. return oldValue.SendTime, nil
  17243. }
  17244. // ClearSendTime clears the value of the "send_time" field.
  17245. func (m *MessageRecordsMutation) ClearSendTime() {
  17246. m.send_time = nil
  17247. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17248. }
  17249. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17250. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17251. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17252. return ok
  17253. }
  17254. // ResetSendTime resets all changes to the "send_time" field.
  17255. func (m *MessageRecordsMutation) ResetSendTime() {
  17256. m.send_time = nil
  17257. delete(m.clearedFields, messagerecords.FieldSendTime)
  17258. }
  17259. // SetSourceType sets the "source_type" field.
  17260. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17261. m.source_type = &i
  17262. m.addsource_type = nil
  17263. }
  17264. // SourceType returns the value of the "source_type" field in the mutation.
  17265. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17266. v := m.source_type
  17267. if v == nil {
  17268. return
  17269. }
  17270. return *v, true
  17271. }
  17272. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17273. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17275. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17276. if !m.op.Is(OpUpdateOne) {
  17277. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17278. }
  17279. if m.id == nil || m.oldValue == nil {
  17280. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17281. }
  17282. oldValue, err := m.oldValue(ctx)
  17283. if err != nil {
  17284. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17285. }
  17286. return oldValue.SourceType, nil
  17287. }
  17288. // AddSourceType adds i to the "source_type" field.
  17289. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17290. if m.addsource_type != nil {
  17291. *m.addsource_type += i
  17292. } else {
  17293. m.addsource_type = &i
  17294. }
  17295. }
  17296. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17297. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17298. v := m.addsource_type
  17299. if v == nil {
  17300. return
  17301. }
  17302. return *v, true
  17303. }
  17304. // ResetSourceType resets all changes to the "source_type" field.
  17305. func (m *MessageRecordsMutation) ResetSourceType() {
  17306. m.source_type = nil
  17307. m.addsource_type = nil
  17308. }
  17309. // SetSourceID sets the "source_id" field.
  17310. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17311. m.sop_stage = &u
  17312. }
  17313. // SourceID returns the value of the "source_id" field in the mutation.
  17314. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17315. v := m.sop_stage
  17316. if v == nil {
  17317. return
  17318. }
  17319. return *v, true
  17320. }
  17321. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17322. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17324. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17325. if !m.op.Is(OpUpdateOne) {
  17326. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17327. }
  17328. if m.id == nil || m.oldValue == nil {
  17329. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17330. }
  17331. oldValue, err := m.oldValue(ctx)
  17332. if err != nil {
  17333. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17334. }
  17335. return oldValue.SourceID, nil
  17336. }
  17337. // ClearSourceID clears the value of the "source_id" field.
  17338. func (m *MessageRecordsMutation) ClearSourceID() {
  17339. m.sop_stage = nil
  17340. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17341. }
  17342. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17343. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17344. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17345. return ok
  17346. }
  17347. // ResetSourceID resets all changes to the "source_id" field.
  17348. func (m *MessageRecordsMutation) ResetSourceID() {
  17349. m.sop_stage = nil
  17350. delete(m.clearedFields, messagerecords.FieldSourceID)
  17351. }
  17352. // SetSubSourceID sets the "sub_source_id" field.
  17353. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17354. m.sop_node = &u
  17355. }
  17356. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17357. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17358. v := m.sop_node
  17359. if v == nil {
  17360. return
  17361. }
  17362. return *v, true
  17363. }
  17364. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17365. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17367. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17368. if !m.op.Is(OpUpdateOne) {
  17369. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17370. }
  17371. if m.id == nil || m.oldValue == nil {
  17372. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17373. }
  17374. oldValue, err := m.oldValue(ctx)
  17375. if err != nil {
  17376. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17377. }
  17378. return oldValue.SubSourceID, nil
  17379. }
  17380. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17381. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17382. m.sop_node = nil
  17383. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17384. }
  17385. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17386. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17387. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17388. return ok
  17389. }
  17390. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17391. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17392. m.sop_node = nil
  17393. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17394. }
  17395. // SetOrganizationID sets the "organization_id" field.
  17396. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17397. m.organization_id = &u
  17398. m.addorganization_id = nil
  17399. }
  17400. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17401. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17402. v := m.organization_id
  17403. if v == nil {
  17404. return
  17405. }
  17406. return *v, true
  17407. }
  17408. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17409. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17411. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17412. if !m.op.Is(OpUpdateOne) {
  17413. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17414. }
  17415. if m.id == nil || m.oldValue == nil {
  17416. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17417. }
  17418. oldValue, err := m.oldValue(ctx)
  17419. if err != nil {
  17420. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17421. }
  17422. return oldValue.OrganizationID, nil
  17423. }
  17424. // AddOrganizationID adds u to the "organization_id" field.
  17425. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17426. if m.addorganization_id != nil {
  17427. *m.addorganization_id += u
  17428. } else {
  17429. m.addorganization_id = &u
  17430. }
  17431. }
  17432. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17433. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17434. v := m.addorganization_id
  17435. if v == nil {
  17436. return
  17437. }
  17438. return *v, true
  17439. }
  17440. // ClearOrganizationID clears the value of the "organization_id" field.
  17441. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17442. m.organization_id = nil
  17443. m.addorganization_id = nil
  17444. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17445. }
  17446. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17447. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17448. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17449. return ok
  17450. }
  17451. // ResetOrganizationID resets all changes to the "organization_id" field.
  17452. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17453. m.organization_id = nil
  17454. m.addorganization_id = nil
  17455. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17456. }
  17457. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17458. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17459. m.sop_stage = &id
  17460. }
  17461. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17462. func (m *MessageRecordsMutation) ClearSopStage() {
  17463. m.clearedsop_stage = true
  17464. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17465. }
  17466. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17467. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17468. return m.SourceIDCleared() || m.clearedsop_stage
  17469. }
  17470. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17471. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17472. if m.sop_stage != nil {
  17473. return *m.sop_stage, true
  17474. }
  17475. return
  17476. }
  17477. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17478. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17479. // SopStageID instead. It exists only for internal usage by the builders.
  17480. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17481. if id := m.sop_stage; id != nil {
  17482. ids = append(ids, *id)
  17483. }
  17484. return
  17485. }
  17486. // ResetSopStage resets all changes to the "sop_stage" edge.
  17487. func (m *MessageRecordsMutation) ResetSopStage() {
  17488. m.sop_stage = nil
  17489. m.clearedsop_stage = false
  17490. }
  17491. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17492. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17493. m.sop_node = &id
  17494. }
  17495. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17496. func (m *MessageRecordsMutation) ClearSopNode() {
  17497. m.clearedsop_node = true
  17498. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17499. }
  17500. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17501. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17502. return m.SubSourceIDCleared() || m.clearedsop_node
  17503. }
  17504. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17505. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17506. if m.sop_node != nil {
  17507. return *m.sop_node, true
  17508. }
  17509. return
  17510. }
  17511. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17512. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17513. // SopNodeID instead. It exists only for internal usage by the builders.
  17514. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17515. if id := m.sop_node; id != nil {
  17516. ids = append(ids, *id)
  17517. }
  17518. return
  17519. }
  17520. // ResetSopNode resets all changes to the "sop_node" edge.
  17521. func (m *MessageRecordsMutation) ResetSopNode() {
  17522. m.sop_node = nil
  17523. m.clearedsop_node = false
  17524. }
  17525. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17526. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17527. m.message_contact = &id
  17528. }
  17529. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17530. func (m *MessageRecordsMutation) ClearMessageContact() {
  17531. m.clearedmessage_contact = true
  17532. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17533. }
  17534. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17535. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17536. return m.ContactIDCleared() || m.clearedmessage_contact
  17537. }
  17538. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17539. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17540. if m.message_contact != nil {
  17541. return *m.message_contact, true
  17542. }
  17543. return
  17544. }
  17545. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17546. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17547. // MessageContactID instead. It exists only for internal usage by the builders.
  17548. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17549. if id := m.message_contact; id != nil {
  17550. ids = append(ids, *id)
  17551. }
  17552. return
  17553. }
  17554. // ResetMessageContact resets all changes to the "message_contact" edge.
  17555. func (m *MessageRecordsMutation) ResetMessageContact() {
  17556. m.message_contact = nil
  17557. m.clearedmessage_contact = false
  17558. }
  17559. // Where appends a list predicates to the MessageRecordsMutation builder.
  17560. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17561. m.predicates = append(m.predicates, ps...)
  17562. }
  17563. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17564. // users can use type-assertion to append predicates that do not depend on any generated package.
  17565. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17566. p := make([]predicate.MessageRecords, len(ps))
  17567. for i := range ps {
  17568. p[i] = ps[i]
  17569. }
  17570. m.Where(p...)
  17571. }
  17572. // Op returns the operation name.
  17573. func (m *MessageRecordsMutation) Op() Op {
  17574. return m.op
  17575. }
  17576. // SetOp allows setting the mutation operation.
  17577. func (m *MessageRecordsMutation) SetOp(op Op) {
  17578. m.op = op
  17579. }
  17580. // Type returns the node type of this mutation (MessageRecords).
  17581. func (m *MessageRecordsMutation) Type() string {
  17582. return m.typ
  17583. }
  17584. // Fields returns all fields that were changed during this mutation. Note that in
  17585. // order to get all numeric fields that were incremented/decremented, call
  17586. // AddedFields().
  17587. func (m *MessageRecordsMutation) Fields() []string {
  17588. fields := make([]string, 0, 16)
  17589. if m.created_at != nil {
  17590. fields = append(fields, messagerecords.FieldCreatedAt)
  17591. }
  17592. if m.updated_at != nil {
  17593. fields = append(fields, messagerecords.FieldUpdatedAt)
  17594. }
  17595. if m.status != nil {
  17596. fields = append(fields, messagerecords.FieldStatus)
  17597. }
  17598. if m.bot_wxid != nil {
  17599. fields = append(fields, messagerecords.FieldBotWxid)
  17600. }
  17601. if m.message_contact != nil {
  17602. fields = append(fields, messagerecords.FieldContactID)
  17603. }
  17604. if m.contact_type != nil {
  17605. fields = append(fields, messagerecords.FieldContactType)
  17606. }
  17607. if m.contact_wxid != nil {
  17608. fields = append(fields, messagerecords.FieldContactWxid)
  17609. }
  17610. if m.content_type != nil {
  17611. fields = append(fields, messagerecords.FieldContentType)
  17612. }
  17613. if m.content != nil {
  17614. fields = append(fields, messagerecords.FieldContent)
  17615. }
  17616. if m.meta != nil {
  17617. fields = append(fields, messagerecords.FieldMeta)
  17618. }
  17619. if m.error_detail != nil {
  17620. fields = append(fields, messagerecords.FieldErrorDetail)
  17621. }
  17622. if m.send_time != nil {
  17623. fields = append(fields, messagerecords.FieldSendTime)
  17624. }
  17625. if m.source_type != nil {
  17626. fields = append(fields, messagerecords.FieldSourceType)
  17627. }
  17628. if m.sop_stage != nil {
  17629. fields = append(fields, messagerecords.FieldSourceID)
  17630. }
  17631. if m.sop_node != nil {
  17632. fields = append(fields, messagerecords.FieldSubSourceID)
  17633. }
  17634. if m.organization_id != nil {
  17635. fields = append(fields, messagerecords.FieldOrganizationID)
  17636. }
  17637. return fields
  17638. }
  17639. // Field returns the value of a field with the given name. The second boolean
  17640. // return value indicates that this field was not set, or was not defined in the
  17641. // schema.
  17642. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17643. switch name {
  17644. case messagerecords.FieldCreatedAt:
  17645. return m.CreatedAt()
  17646. case messagerecords.FieldUpdatedAt:
  17647. return m.UpdatedAt()
  17648. case messagerecords.FieldStatus:
  17649. return m.Status()
  17650. case messagerecords.FieldBotWxid:
  17651. return m.BotWxid()
  17652. case messagerecords.FieldContactID:
  17653. return m.ContactID()
  17654. case messagerecords.FieldContactType:
  17655. return m.ContactType()
  17656. case messagerecords.FieldContactWxid:
  17657. return m.ContactWxid()
  17658. case messagerecords.FieldContentType:
  17659. return m.ContentType()
  17660. case messagerecords.FieldContent:
  17661. return m.Content()
  17662. case messagerecords.FieldMeta:
  17663. return m.Meta()
  17664. case messagerecords.FieldErrorDetail:
  17665. return m.ErrorDetail()
  17666. case messagerecords.FieldSendTime:
  17667. return m.SendTime()
  17668. case messagerecords.FieldSourceType:
  17669. return m.SourceType()
  17670. case messagerecords.FieldSourceID:
  17671. return m.SourceID()
  17672. case messagerecords.FieldSubSourceID:
  17673. return m.SubSourceID()
  17674. case messagerecords.FieldOrganizationID:
  17675. return m.OrganizationID()
  17676. }
  17677. return nil, false
  17678. }
  17679. // OldField returns the old value of the field from the database. An error is
  17680. // returned if the mutation operation is not UpdateOne, or the query to the
  17681. // database failed.
  17682. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17683. switch name {
  17684. case messagerecords.FieldCreatedAt:
  17685. return m.OldCreatedAt(ctx)
  17686. case messagerecords.FieldUpdatedAt:
  17687. return m.OldUpdatedAt(ctx)
  17688. case messagerecords.FieldStatus:
  17689. return m.OldStatus(ctx)
  17690. case messagerecords.FieldBotWxid:
  17691. return m.OldBotWxid(ctx)
  17692. case messagerecords.FieldContactID:
  17693. return m.OldContactID(ctx)
  17694. case messagerecords.FieldContactType:
  17695. return m.OldContactType(ctx)
  17696. case messagerecords.FieldContactWxid:
  17697. return m.OldContactWxid(ctx)
  17698. case messagerecords.FieldContentType:
  17699. return m.OldContentType(ctx)
  17700. case messagerecords.FieldContent:
  17701. return m.OldContent(ctx)
  17702. case messagerecords.FieldMeta:
  17703. return m.OldMeta(ctx)
  17704. case messagerecords.FieldErrorDetail:
  17705. return m.OldErrorDetail(ctx)
  17706. case messagerecords.FieldSendTime:
  17707. return m.OldSendTime(ctx)
  17708. case messagerecords.FieldSourceType:
  17709. return m.OldSourceType(ctx)
  17710. case messagerecords.FieldSourceID:
  17711. return m.OldSourceID(ctx)
  17712. case messagerecords.FieldSubSourceID:
  17713. return m.OldSubSourceID(ctx)
  17714. case messagerecords.FieldOrganizationID:
  17715. return m.OldOrganizationID(ctx)
  17716. }
  17717. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17718. }
  17719. // SetField sets the value of a field with the given name. It returns an error if
  17720. // the field is not defined in the schema, or if the type mismatched the field
  17721. // type.
  17722. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17723. switch name {
  17724. case messagerecords.FieldCreatedAt:
  17725. v, ok := value.(time.Time)
  17726. if !ok {
  17727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17728. }
  17729. m.SetCreatedAt(v)
  17730. return nil
  17731. case messagerecords.FieldUpdatedAt:
  17732. v, ok := value.(time.Time)
  17733. if !ok {
  17734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17735. }
  17736. m.SetUpdatedAt(v)
  17737. return nil
  17738. case messagerecords.FieldStatus:
  17739. v, ok := value.(uint8)
  17740. if !ok {
  17741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17742. }
  17743. m.SetStatus(v)
  17744. return nil
  17745. case messagerecords.FieldBotWxid:
  17746. v, ok := value.(string)
  17747. if !ok {
  17748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17749. }
  17750. m.SetBotWxid(v)
  17751. return nil
  17752. case messagerecords.FieldContactID:
  17753. v, ok := value.(uint64)
  17754. if !ok {
  17755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17756. }
  17757. m.SetContactID(v)
  17758. return nil
  17759. case messagerecords.FieldContactType:
  17760. v, ok := value.(int)
  17761. if !ok {
  17762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17763. }
  17764. m.SetContactType(v)
  17765. return nil
  17766. case messagerecords.FieldContactWxid:
  17767. v, ok := value.(string)
  17768. if !ok {
  17769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17770. }
  17771. m.SetContactWxid(v)
  17772. return nil
  17773. case messagerecords.FieldContentType:
  17774. v, ok := value.(int)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.SetContentType(v)
  17779. return nil
  17780. case messagerecords.FieldContent:
  17781. v, ok := value.(string)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.SetContent(v)
  17786. return nil
  17787. case messagerecords.FieldMeta:
  17788. v, ok := value.(custom_types.Meta)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.SetMeta(v)
  17793. return nil
  17794. case messagerecords.FieldErrorDetail:
  17795. v, ok := value.(string)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.SetErrorDetail(v)
  17800. return nil
  17801. case messagerecords.FieldSendTime:
  17802. v, ok := value.(time.Time)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.SetSendTime(v)
  17807. return nil
  17808. case messagerecords.FieldSourceType:
  17809. v, ok := value.(int)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.SetSourceType(v)
  17814. return nil
  17815. case messagerecords.FieldSourceID:
  17816. v, ok := value.(uint64)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.SetSourceID(v)
  17821. return nil
  17822. case messagerecords.FieldSubSourceID:
  17823. v, ok := value.(uint64)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.SetSubSourceID(v)
  17828. return nil
  17829. case messagerecords.FieldOrganizationID:
  17830. v, ok := value.(uint64)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.SetOrganizationID(v)
  17835. return nil
  17836. }
  17837. return fmt.Errorf("unknown MessageRecords field %s", name)
  17838. }
  17839. // AddedFields returns all numeric fields that were incremented/decremented during
  17840. // this mutation.
  17841. func (m *MessageRecordsMutation) AddedFields() []string {
  17842. var fields []string
  17843. if m.addstatus != nil {
  17844. fields = append(fields, messagerecords.FieldStatus)
  17845. }
  17846. if m.addcontact_type != nil {
  17847. fields = append(fields, messagerecords.FieldContactType)
  17848. }
  17849. if m.addcontent_type != nil {
  17850. fields = append(fields, messagerecords.FieldContentType)
  17851. }
  17852. if m.addsource_type != nil {
  17853. fields = append(fields, messagerecords.FieldSourceType)
  17854. }
  17855. if m.addorganization_id != nil {
  17856. fields = append(fields, messagerecords.FieldOrganizationID)
  17857. }
  17858. return fields
  17859. }
  17860. // AddedField returns the numeric value that was incremented/decremented on a field
  17861. // with the given name. The second boolean return value indicates that this field
  17862. // was not set, or was not defined in the schema.
  17863. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17864. switch name {
  17865. case messagerecords.FieldStatus:
  17866. return m.AddedStatus()
  17867. case messagerecords.FieldContactType:
  17868. return m.AddedContactType()
  17869. case messagerecords.FieldContentType:
  17870. return m.AddedContentType()
  17871. case messagerecords.FieldSourceType:
  17872. return m.AddedSourceType()
  17873. case messagerecords.FieldOrganizationID:
  17874. return m.AddedOrganizationID()
  17875. }
  17876. return nil, false
  17877. }
  17878. // AddField adds the value to the field with the given name. It returns an error if
  17879. // the field is not defined in the schema, or if the type mismatched the field
  17880. // type.
  17881. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17882. switch name {
  17883. case messagerecords.FieldStatus:
  17884. v, ok := value.(int8)
  17885. if !ok {
  17886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17887. }
  17888. m.AddStatus(v)
  17889. return nil
  17890. case messagerecords.FieldContactType:
  17891. v, ok := value.(int)
  17892. if !ok {
  17893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17894. }
  17895. m.AddContactType(v)
  17896. return nil
  17897. case messagerecords.FieldContentType:
  17898. v, ok := value.(int)
  17899. if !ok {
  17900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17901. }
  17902. m.AddContentType(v)
  17903. return nil
  17904. case messagerecords.FieldSourceType:
  17905. v, ok := value.(int)
  17906. if !ok {
  17907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17908. }
  17909. m.AddSourceType(v)
  17910. return nil
  17911. case messagerecords.FieldOrganizationID:
  17912. v, ok := value.(int64)
  17913. if !ok {
  17914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17915. }
  17916. m.AddOrganizationID(v)
  17917. return nil
  17918. }
  17919. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17920. }
  17921. // ClearedFields returns all nullable fields that were cleared during this
  17922. // mutation.
  17923. func (m *MessageRecordsMutation) ClearedFields() []string {
  17924. var fields []string
  17925. if m.FieldCleared(messagerecords.FieldStatus) {
  17926. fields = append(fields, messagerecords.FieldStatus)
  17927. }
  17928. if m.FieldCleared(messagerecords.FieldContactID) {
  17929. fields = append(fields, messagerecords.FieldContactID)
  17930. }
  17931. if m.FieldCleared(messagerecords.FieldMeta) {
  17932. fields = append(fields, messagerecords.FieldMeta)
  17933. }
  17934. if m.FieldCleared(messagerecords.FieldSendTime) {
  17935. fields = append(fields, messagerecords.FieldSendTime)
  17936. }
  17937. if m.FieldCleared(messagerecords.FieldSourceID) {
  17938. fields = append(fields, messagerecords.FieldSourceID)
  17939. }
  17940. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17941. fields = append(fields, messagerecords.FieldSubSourceID)
  17942. }
  17943. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17944. fields = append(fields, messagerecords.FieldOrganizationID)
  17945. }
  17946. return fields
  17947. }
  17948. // FieldCleared returns a boolean indicating if a field with the given name was
  17949. // cleared in this mutation.
  17950. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17951. _, ok := m.clearedFields[name]
  17952. return ok
  17953. }
  17954. // ClearField clears the value of the field with the given name. It returns an
  17955. // error if the field is not defined in the schema.
  17956. func (m *MessageRecordsMutation) ClearField(name string) error {
  17957. switch name {
  17958. case messagerecords.FieldStatus:
  17959. m.ClearStatus()
  17960. return nil
  17961. case messagerecords.FieldContactID:
  17962. m.ClearContactID()
  17963. return nil
  17964. case messagerecords.FieldMeta:
  17965. m.ClearMeta()
  17966. return nil
  17967. case messagerecords.FieldSendTime:
  17968. m.ClearSendTime()
  17969. return nil
  17970. case messagerecords.FieldSourceID:
  17971. m.ClearSourceID()
  17972. return nil
  17973. case messagerecords.FieldSubSourceID:
  17974. m.ClearSubSourceID()
  17975. return nil
  17976. case messagerecords.FieldOrganizationID:
  17977. m.ClearOrganizationID()
  17978. return nil
  17979. }
  17980. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17981. }
  17982. // ResetField resets all changes in the mutation for the field with the given name.
  17983. // It returns an error if the field is not defined in the schema.
  17984. func (m *MessageRecordsMutation) ResetField(name string) error {
  17985. switch name {
  17986. case messagerecords.FieldCreatedAt:
  17987. m.ResetCreatedAt()
  17988. return nil
  17989. case messagerecords.FieldUpdatedAt:
  17990. m.ResetUpdatedAt()
  17991. return nil
  17992. case messagerecords.FieldStatus:
  17993. m.ResetStatus()
  17994. return nil
  17995. case messagerecords.FieldBotWxid:
  17996. m.ResetBotWxid()
  17997. return nil
  17998. case messagerecords.FieldContactID:
  17999. m.ResetContactID()
  18000. return nil
  18001. case messagerecords.FieldContactType:
  18002. m.ResetContactType()
  18003. return nil
  18004. case messagerecords.FieldContactWxid:
  18005. m.ResetContactWxid()
  18006. return nil
  18007. case messagerecords.FieldContentType:
  18008. m.ResetContentType()
  18009. return nil
  18010. case messagerecords.FieldContent:
  18011. m.ResetContent()
  18012. return nil
  18013. case messagerecords.FieldMeta:
  18014. m.ResetMeta()
  18015. return nil
  18016. case messagerecords.FieldErrorDetail:
  18017. m.ResetErrorDetail()
  18018. return nil
  18019. case messagerecords.FieldSendTime:
  18020. m.ResetSendTime()
  18021. return nil
  18022. case messagerecords.FieldSourceType:
  18023. m.ResetSourceType()
  18024. return nil
  18025. case messagerecords.FieldSourceID:
  18026. m.ResetSourceID()
  18027. return nil
  18028. case messagerecords.FieldSubSourceID:
  18029. m.ResetSubSourceID()
  18030. return nil
  18031. case messagerecords.FieldOrganizationID:
  18032. m.ResetOrganizationID()
  18033. return nil
  18034. }
  18035. return fmt.Errorf("unknown MessageRecords field %s", name)
  18036. }
  18037. // AddedEdges returns all edge names that were set/added in this mutation.
  18038. func (m *MessageRecordsMutation) AddedEdges() []string {
  18039. edges := make([]string, 0, 3)
  18040. if m.sop_stage != nil {
  18041. edges = append(edges, messagerecords.EdgeSopStage)
  18042. }
  18043. if m.sop_node != nil {
  18044. edges = append(edges, messagerecords.EdgeSopNode)
  18045. }
  18046. if m.message_contact != nil {
  18047. edges = append(edges, messagerecords.EdgeMessageContact)
  18048. }
  18049. return edges
  18050. }
  18051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18052. // name in this mutation.
  18053. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18054. switch name {
  18055. case messagerecords.EdgeSopStage:
  18056. if id := m.sop_stage; id != nil {
  18057. return []ent.Value{*id}
  18058. }
  18059. case messagerecords.EdgeSopNode:
  18060. if id := m.sop_node; id != nil {
  18061. return []ent.Value{*id}
  18062. }
  18063. case messagerecords.EdgeMessageContact:
  18064. if id := m.message_contact; id != nil {
  18065. return []ent.Value{*id}
  18066. }
  18067. }
  18068. return nil
  18069. }
  18070. // RemovedEdges returns all edge names that were removed in this mutation.
  18071. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18072. edges := make([]string, 0, 3)
  18073. return edges
  18074. }
  18075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18076. // the given name in this mutation.
  18077. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18078. return nil
  18079. }
  18080. // ClearedEdges returns all edge names that were cleared in this mutation.
  18081. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18082. edges := make([]string, 0, 3)
  18083. if m.clearedsop_stage {
  18084. edges = append(edges, messagerecords.EdgeSopStage)
  18085. }
  18086. if m.clearedsop_node {
  18087. edges = append(edges, messagerecords.EdgeSopNode)
  18088. }
  18089. if m.clearedmessage_contact {
  18090. edges = append(edges, messagerecords.EdgeMessageContact)
  18091. }
  18092. return edges
  18093. }
  18094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18095. // was cleared in this mutation.
  18096. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18097. switch name {
  18098. case messagerecords.EdgeSopStage:
  18099. return m.clearedsop_stage
  18100. case messagerecords.EdgeSopNode:
  18101. return m.clearedsop_node
  18102. case messagerecords.EdgeMessageContact:
  18103. return m.clearedmessage_contact
  18104. }
  18105. return false
  18106. }
  18107. // ClearEdge clears the value of the edge with the given name. It returns an error
  18108. // if that edge is not defined in the schema.
  18109. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18110. switch name {
  18111. case messagerecords.EdgeSopStage:
  18112. m.ClearSopStage()
  18113. return nil
  18114. case messagerecords.EdgeSopNode:
  18115. m.ClearSopNode()
  18116. return nil
  18117. case messagerecords.EdgeMessageContact:
  18118. m.ClearMessageContact()
  18119. return nil
  18120. }
  18121. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18122. }
  18123. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18124. // It returns an error if the edge is not defined in the schema.
  18125. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18126. switch name {
  18127. case messagerecords.EdgeSopStage:
  18128. m.ResetSopStage()
  18129. return nil
  18130. case messagerecords.EdgeSopNode:
  18131. m.ResetSopNode()
  18132. return nil
  18133. case messagerecords.EdgeMessageContact:
  18134. m.ResetMessageContact()
  18135. return nil
  18136. }
  18137. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18138. }
  18139. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18140. type MsgMutation struct {
  18141. config
  18142. op Op
  18143. typ string
  18144. id *uint64
  18145. created_at *time.Time
  18146. updated_at *time.Time
  18147. deleted_at *time.Time
  18148. status *uint8
  18149. addstatus *int8
  18150. fromwxid *string
  18151. toid *string
  18152. msgtype *int32
  18153. addmsgtype *int32
  18154. msg *string
  18155. batch_no *string
  18156. clearedFields map[string]struct{}
  18157. done bool
  18158. oldValue func(context.Context) (*Msg, error)
  18159. predicates []predicate.Msg
  18160. }
  18161. var _ ent.Mutation = (*MsgMutation)(nil)
  18162. // msgOption allows management of the mutation configuration using functional options.
  18163. type msgOption func(*MsgMutation)
  18164. // newMsgMutation creates new mutation for the Msg entity.
  18165. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18166. m := &MsgMutation{
  18167. config: c,
  18168. op: op,
  18169. typ: TypeMsg,
  18170. clearedFields: make(map[string]struct{}),
  18171. }
  18172. for _, opt := range opts {
  18173. opt(m)
  18174. }
  18175. return m
  18176. }
  18177. // withMsgID sets the ID field of the mutation.
  18178. func withMsgID(id uint64) msgOption {
  18179. return func(m *MsgMutation) {
  18180. var (
  18181. err error
  18182. once sync.Once
  18183. value *Msg
  18184. )
  18185. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18186. once.Do(func() {
  18187. if m.done {
  18188. err = errors.New("querying old values post mutation is not allowed")
  18189. } else {
  18190. value, err = m.Client().Msg.Get(ctx, id)
  18191. }
  18192. })
  18193. return value, err
  18194. }
  18195. m.id = &id
  18196. }
  18197. }
  18198. // withMsg sets the old Msg of the mutation.
  18199. func withMsg(node *Msg) msgOption {
  18200. return func(m *MsgMutation) {
  18201. m.oldValue = func(context.Context) (*Msg, error) {
  18202. return node, nil
  18203. }
  18204. m.id = &node.ID
  18205. }
  18206. }
  18207. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18208. // executed in a transaction (ent.Tx), a transactional client is returned.
  18209. func (m MsgMutation) Client() *Client {
  18210. client := &Client{config: m.config}
  18211. client.init()
  18212. return client
  18213. }
  18214. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18215. // it returns an error otherwise.
  18216. func (m MsgMutation) Tx() (*Tx, error) {
  18217. if _, ok := m.driver.(*txDriver); !ok {
  18218. return nil, errors.New("ent: mutation is not running in a transaction")
  18219. }
  18220. tx := &Tx{config: m.config}
  18221. tx.init()
  18222. return tx, nil
  18223. }
  18224. // SetID sets the value of the id field. Note that this
  18225. // operation is only accepted on creation of Msg entities.
  18226. func (m *MsgMutation) SetID(id uint64) {
  18227. m.id = &id
  18228. }
  18229. // ID returns the ID value in the mutation. Note that the ID is only available
  18230. // if it was provided to the builder or after it was returned from the database.
  18231. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18232. if m.id == nil {
  18233. return
  18234. }
  18235. return *m.id, true
  18236. }
  18237. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18238. // That means, if the mutation is applied within a transaction with an isolation level such
  18239. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18240. // or updated by the mutation.
  18241. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18242. switch {
  18243. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18244. id, exists := m.ID()
  18245. if exists {
  18246. return []uint64{id}, nil
  18247. }
  18248. fallthrough
  18249. case m.op.Is(OpUpdate | OpDelete):
  18250. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18251. default:
  18252. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18253. }
  18254. }
  18255. // SetCreatedAt sets the "created_at" field.
  18256. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18257. m.created_at = &t
  18258. }
  18259. // CreatedAt returns the value of the "created_at" field in the mutation.
  18260. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18261. v := m.created_at
  18262. if v == nil {
  18263. return
  18264. }
  18265. return *v, true
  18266. }
  18267. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18268. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18270. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18271. if !m.op.Is(OpUpdateOne) {
  18272. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18273. }
  18274. if m.id == nil || m.oldValue == nil {
  18275. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18276. }
  18277. oldValue, err := m.oldValue(ctx)
  18278. if err != nil {
  18279. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18280. }
  18281. return oldValue.CreatedAt, nil
  18282. }
  18283. // ResetCreatedAt resets all changes to the "created_at" field.
  18284. func (m *MsgMutation) ResetCreatedAt() {
  18285. m.created_at = nil
  18286. }
  18287. // SetUpdatedAt sets the "updated_at" field.
  18288. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18289. m.updated_at = &t
  18290. }
  18291. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18292. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18293. v := m.updated_at
  18294. if v == nil {
  18295. return
  18296. }
  18297. return *v, true
  18298. }
  18299. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18300. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18302. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18303. if !m.op.Is(OpUpdateOne) {
  18304. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18305. }
  18306. if m.id == nil || m.oldValue == nil {
  18307. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18308. }
  18309. oldValue, err := m.oldValue(ctx)
  18310. if err != nil {
  18311. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18312. }
  18313. return oldValue.UpdatedAt, nil
  18314. }
  18315. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18316. func (m *MsgMutation) ResetUpdatedAt() {
  18317. m.updated_at = nil
  18318. }
  18319. // SetDeletedAt sets the "deleted_at" field.
  18320. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18321. m.deleted_at = &t
  18322. }
  18323. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18324. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18325. v := m.deleted_at
  18326. if v == nil {
  18327. return
  18328. }
  18329. return *v, true
  18330. }
  18331. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18332. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18334. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18335. if !m.op.Is(OpUpdateOne) {
  18336. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18337. }
  18338. if m.id == nil || m.oldValue == nil {
  18339. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18340. }
  18341. oldValue, err := m.oldValue(ctx)
  18342. if err != nil {
  18343. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18344. }
  18345. return oldValue.DeletedAt, nil
  18346. }
  18347. // ClearDeletedAt clears the value of the "deleted_at" field.
  18348. func (m *MsgMutation) ClearDeletedAt() {
  18349. m.deleted_at = nil
  18350. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18351. }
  18352. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18353. func (m *MsgMutation) DeletedAtCleared() bool {
  18354. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18355. return ok
  18356. }
  18357. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18358. func (m *MsgMutation) ResetDeletedAt() {
  18359. m.deleted_at = nil
  18360. delete(m.clearedFields, msg.FieldDeletedAt)
  18361. }
  18362. // SetStatus sets the "status" field.
  18363. func (m *MsgMutation) SetStatus(u uint8) {
  18364. m.status = &u
  18365. m.addstatus = nil
  18366. }
  18367. // Status returns the value of the "status" field in the mutation.
  18368. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18369. v := m.status
  18370. if v == nil {
  18371. return
  18372. }
  18373. return *v, true
  18374. }
  18375. // OldStatus returns the old "status" field's value of the Msg entity.
  18376. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18378. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18379. if !m.op.Is(OpUpdateOne) {
  18380. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18381. }
  18382. if m.id == nil || m.oldValue == nil {
  18383. return v, errors.New("OldStatus requires an ID field in the mutation")
  18384. }
  18385. oldValue, err := m.oldValue(ctx)
  18386. if err != nil {
  18387. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18388. }
  18389. return oldValue.Status, nil
  18390. }
  18391. // AddStatus adds u to the "status" field.
  18392. func (m *MsgMutation) AddStatus(u int8) {
  18393. if m.addstatus != nil {
  18394. *m.addstatus += u
  18395. } else {
  18396. m.addstatus = &u
  18397. }
  18398. }
  18399. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18400. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18401. v := m.addstatus
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // ClearStatus clears the value of the "status" field.
  18408. func (m *MsgMutation) ClearStatus() {
  18409. m.status = nil
  18410. m.addstatus = nil
  18411. m.clearedFields[msg.FieldStatus] = struct{}{}
  18412. }
  18413. // StatusCleared returns if the "status" field was cleared in this mutation.
  18414. func (m *MsgMutation) StatusCleared() bool {
  18415. _, ok := m.clearedFields[msg.FieldStatus]
  18416. return ok
  18417. }
  18418. // ResetStatus resets all changes to the "status" field.
  18419. func (m *MsgMutation) ResetStatus() {
  18420. m.status = nil
  18421. m.addstatus = nil
  18422. delete(m.clearedFields, msg.FieldStatus)
  18423. }
  18424. // SetFromwxid sets the "fromwxid" field.
  18425. func (m *MsgMutation) SetFromwxid(s string) {
  18426. m.fromwxid = &s
  18427. }
  18428. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18429. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18430. v := m.fromwxid
  18431. if v == nil {
  18432. return
  18433. }
  18434. return *v, true
  18435. }
  18436. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18437. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18439. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18440. if !m.op.Is(OpUpdateOne) {
  18441. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18442. }
  18443. if m.id == nil || m.oldValue == nil {
  18444. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18445. }
  18446. oldValue, err := m.oldValue(ctx)
  18447. if err != nil {
  18448. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18449. }
  18450. return oldValue.Fromwxid, nil
  18451. }
  18452. // ClearFromwxid clears the value of the "fromwxid" field.
  18453. func (m *MsgMutation) ClearFromwxid() {
  18454. m.fromwxid = nil
  18455. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18456. }
  18457. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18458. func (m *MsgMutation) FromwxidCleared() bool {
  18459. _, ok := m.clearedFields[msg.FieldFromwxid]
  18460. return ok
  18461. }
  18462. // ResetFromwxid resets all changes to the "fromwxid" field.
  18463. func (m *MsgMutation) ResetFromwxid() {
  18464. m.fromwxid = nil
  18465. delete(m.clearedFields, msg.FieldFromwxid)
  18466. }
  18467. // SetToid sets the "toid" field.
  18468. func (m *MsgMutation) SetToid(s string) {
  18469. m.toid = &s
  18470. }
  18471. // Toid returns the value of the "toid" field in the mutation.
  18472. func (m *MsgMutation) Toid() (r string, exists bool) {
  18473. v := m.toid
  18474. if v == nil {
  18475. return
  18476. }
  18477. return *v, true
  18478. }
  18479. // OldToid returns the old "toid" field's value of the Msg entity.
  18480. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18482. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18483. if !m.op.Is(OpUpdateOne) {
  18484. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18485. }
  18486. if m.id == nil || m.oldValue == nil {
  18487. return v, errors.New("OldToid requires an ID field in the mutation")
  18488. }
  18489. oldValue, err := m.oldValue(ctx)
  18490. if err != nil {
  18491. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18492. }
  18493. return oldValue.Toid, nil
  18494. }
  18495. // ClearToid clears the value of the "toid" field.
  18496. func (m *MsgMutation) ClearToid() {
  18497. m.toid = nil
  18498. m.clearedFields[msg.FieldToid] = struct{}{}
  18499. }
  18500. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18501. func (m *MsgMutation) ToidCleared() bool {
  18502. _, ok := m.clearedFields[msg.FieldToid]
  18503. return ok
  18504. }
  18505. // ResetToid resets all changes to the "toid" field.
  18506. func (m *MsgMutation) ResetToid() {
  18507. m.toid = nil
  18508. delete(m.clearedFields, msg.FieldToid)
  18509. }
  18510. // SetMsgtype sets the "msgtype" field.
  18511. func (m *MsgMutation) SetMsgtype(i int32) {
  18512. m.msgtype = &i
  18513. m.addmsgtype = nil
  18514. }
  18515. // Msgtype returns the value of the "msgtype" field in the mutation.
  18516. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18517. v := m.msgtype
  18518. if v == nil {
  18519. return
  18520. }
  18521. return *v, true
  18522. }
  18523. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18524. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18526. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18527. if !m.op.Is(OpUpdateOne) {
  18528. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18529. }
  18530. if m.id == nil || m.oldValue == nil {
  18531. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18532. }
  18533. oldValue, err := m.oldValue(ctx)
  18534. if err != nil {
  18535. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18536. }
  18537. return oldValue.Msgtype, nil
  18538. }
  18539. // AddMsgtype adds i to the "msgtype" field.
  18540. func (m *MsgMutation) AddMsgtype(i int32) {
  18541. if m.addmsgtype != nil {
  18542. *m.addmsgtype += i
  18543. } else {
  18544. m.addmsgtype = &i
  18545. }
  18546. }
  18547. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18548. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18549. v := m.addmsgtype
  18550. if v == nil {
  18551. return
  18552. }
  18553. return *v, true
  18554. }
  18555. // ClearMsgtype clears the value of the "msgtype" field.
  18556. func (m *MsgMutation) ClearMsgtype() {
  18557. m.msgtype = nil
  18558. m.addmsgtype = nil
  18559. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18560. }
  18561. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18562. func (m *MsgMutation) MsgtypeCleared() bool {
  18563. _, ok := m.clearedFields[msg.FieldMsgtype]
  18564. return ok
  18565. }
  18566. // ResetMsgtype resets all changes to the "msgtype" field.
  18567. func (m *MsgMutation) ResetMsgtype() {
  18568. m.msgtype = nil
  18569. m.addmsgtype = nil
  18570. delete(m.clearedFields, msg.FieldMsgtype)
  18571. }
  18572. // SetMsg sets the "msg" field.
  18573. func (m *MsgMutation) SetMsg(s string) {
  18574. m.msg = &s
  18575. }
  18576. // Msg returns the value of the "msg" field in the mutation.
  18577. func (m *MsgMutation) Msg() (r string, exists bool) {
  18578. v := m.msg
  18579. if v == nil {
  18580. return
  18581. }
  18582. return *v, true
  18583. }
  18584. // OldMsg returns the old "msg" field's value of the Msg entity.
  18585. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18587. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18588. if !m.op.Is(OpUpdateOne) {
  18589. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18590. }
  18591. if m.id == nil || m.oldValue == nil {
  18592. return v, errors.New("OldMsg requires an ID field in the mutation")
  18593. }
  18594. oldValue, err := m.oldValue(ctx)
  18595. if err != nil {
  18596. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18597. }
  18598. return oldValue.Msg, nil
  18599. }
  18600. // ClearMsg clears the value of the "msg" field.
  18601. func (m *MsgMutation) ClearMsg() {
  18602. m.msg = nil
  18603. m.clearedFields[msg.FieldMsg] = struct{}{}
  18604. }
  18605. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18606. func (m *MsgMutation) MsgCleared() bool {
  18607. _, ok := m.clearedFields[msg.FieldMsg]
  18608. return ok
  18609. }
  18610. // ResetMsg resets all changes to the "msg" field.
  18611. func (m *MsgMutation) ResetMsg() {
  18612. m.msg = nil
  18613. delete(m.clearedFields, msg.FieldMsg)
  18614. }
  18615. // SetBatchNo sets the "batch_no" field.
  18616. func (m *MsgMutation) SetBatchNo(s string) {
  18617. m.batch_no = &s
  18618. }
  18619. // BatchNo returns the value of the "batch_no" field in the mutation.
  18620. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18621. v := m.batch_no
  18622. if v == nil {
  18623. return
  18624. }
  18625. return *v, true
  18626. }
  18627. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18628. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18630. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18631. if !m.op.Is(OpUpdateOne) {
  18632. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18633. }
  18634. if m.id == nil || m.oldValue == nil {
  18635. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18636. }
  18637. oldValue, err := m.oldValue(ctx)
  18638. if err != nil {
  18639. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18640. }
  18641. return oldValue.BatchNo, nil
  18642. }
  18643. // ClearBatchNo clears the value of the "batch_no" field.
  18644. func (m *MsgMutation) ClearBatchNo() {
  18645. m.batch_no = nil
  18646. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18647. }
  18648. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18649. func (m *MsgMutation) BatchNoCleared() bool {
  18650. _, ok := m.clearedFields[msg.FieldBatchNo]
  18651. return ok
  18652. }
  18653. // ResetBatchNo resets all changes to the "batch_no" field.
  18654. func (m *MsgMutation) ResetBatchNo() {
  18655. m.batch_no = nil
  18656. delete(m.clearedFields, msg.FieldBatchNo)
  18657. }
  18658. // Where appends a list predicates to the MsgMutation builder.
  18659. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18660. m.predicates = append(m.predicates, ps...)
  18661. }
  18662. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18663. // users can use type-assertion to append predicates that do not depend on any generated package.
  18664. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18665. p := make([]predicate.Msg, len(ps))
  18666. for i := range ps {
  18667. p[i] = ps[i]
  18668. }
  18669. m.Where(p...)
  18670. }
  18671. // Op returns the operation name.
  18672. func (m *MsgMutation) Op() Op {
  18673. return m.op
  18674. }
  18675. // SetOp allows setting the mutation operation.
  18676. func (m *MsgMutation) SetOp(op Op) {
  18677. m.op = op
  18678. }
  18679. // Type returns the node type of this mutation (Msg).
  18680. func (m *MsgMutation) Type() string {
  18681. return m.typ
  18682. }
  18683. // Fields returns all fields that were changed during this mutation. Note that in
  18684. // order to get all numeric fields that were incremented/decremented, call
  18685. // AddedFields().
  18686. func (m *MsgMutation) Fields() []string {
  18687. fields := make([]string, 0, 9)
  18688. if m.created_at != nil {
  18689. fields = append(fields, msg.FieldCreatedAt)
  18690. }
  18691. if m.updated_at != nil {
  18692. fields = append(fields, msg.FieldUpdatedAt)
  18693. }
  18694. if m.deleted_at != nil {
  18695. fields = append(fields, msg.FieldDeletedAt)
  18696. }
  18697. if m.status != nil {
  18698. fields = append(fields, msg.FieldStatus)
  18699. }
  18700. if m.fromwxid != nil {
  18701. fields = append(fields, msg.FieldFromwxid)
  18702. }
  18703. if m.toid != nil {
  18704. fields = append(fields, msg.FieldToid)
  18705. }
  18706. if m.msgtype != nil {
  18707. fields = append(fields, msg.FieldMsgtype)
  18708. }
  18709. if m.msg != nil {
  18710. fields = append(fields, msg.FieldMsg)
  18711. }
  18712. if m.batch_no != nil {
  18713. fields = append(fields, msg.FieldBatchNo)
  18714. }
  18715. return fields
  18716. }
  18717. // Field returns the value of a field with the given name. The second boolean
  18718. // return value indicates that this field was not set, or was not defined in the
  18719. // schema.
  18720. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18721. switch name {
  18722. case msg.FieldCreatedAt:
  18723. return m.CreatedAt()
  18724. case msg.FieldUpdatedAt:
  18725. return m.UpdatedAt()
  18726. case msg.FieldDeletedAt:
  18727. return m.DeletedAt()
  18728. case msg.FieldStatus:
  18729. return m.Status()
  18730. case msg.FieldFromwxid:
  18731. return m.Fromwxid()
  18732. case msg.FieldToid:
  18733. return m.Toid()
  18734. case msg.FieldMsgtype:
  18735. return m.Msgtype()
  18736. case msg.FieldMsg:
  18737. return m.Msg()
  18738. case msg.FieldBatchNo:
  18739. return m.BatchNo()
  18740. }
  18741. return nil, false
  18742. }
  18743. // OldField returns the old value of the field from the database. An error is
  18744. // returned if the mutation operation is not UpdateOne, or the query to the
  18745. // database failed.
  18746. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18747. switch name {
  18748. case msg.FieldCreatedAt:
  18749. return m.OldCreatedAt(ctx)
  18750. case msg.FieldUpdatedAt:
  18751. return m.OldUpdatedAt(ctx)
  18752. case msg.FieldDeletedAt:
  18753. return m.OldDeletedAt(ctx)
  18754. case msg.FieldStatus:
  18755. return m.OldStatus(ctx)
  18756. case msg.FieldFromwxid:
  18757. return m.OldFromwxid(ctx)
  18758. case msg.FieldToid:
  18759. return m.OldToid(ctx)
  18760. case msg.FieldMsgtype:
  18761. return m.OldMsgtype(ctx)
  18762. case msg.FieldMsg:
  18763. return m.OldMsg(ctx)
  18764. case msg.FieldBatchNo:
  18765. return m.OldBatchNo(ctx)
  18766. }
  18767. return nil, fmt.Errorf("unknown Msg field %s", name)
  18768. }
  18769. // SetField sets the value of a field with the given name. It returns an error if
  18770. // the field is not defined in the schema, or if the type mismatched the field
  18771. // type.
  18772. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18773. switch name {
  18774. case msg.FieldCreatedAt:
  18775. v, ok := value.(time.Time)
  18776. if !ok {
  18777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18778. }
  18779. m.SetCreatedAt(v)
  18780. return nil
  18781. case msg.FieldUpdatedAt:
  18782. v, ok := value.(time.Time)
  18783. if !ok {
  18784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18785. }
  18786. m.SetUpdatedAt(v)
  18787. return nil
  18788. case msg.FieldDeletedAt:
  18789. v, ok := value.(time.Time)
  18790. if !ok {
  18791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18792. }
  18793. m.SetDeletedAt(v)
  18794. return nil
  18795. case msg.FieldStatus:
  18796. v, ok := value.(uint8)
  18797. if !ok {
  18798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18799. }
  18800. m.SetStatus(v)
  18801. return nil
  18802. case msg.FieldFromwxid:
  18803. v, ok := value.(string)
  18804. if !ok {
  18805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18806. }
  18807. m.SetFromwxid(v)
  18808. return nil
  18809. case msg.FieldToid:
  18810. v, ok := value.(string)
  18811. if !ok {
  18812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18813. }
  18814. m.SetToid(v)
  18815. return nil
  18816. case msg.FieldMsgtype:
  18817. v, ok := value.(int32)
  18818. if !ok {
  18819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18820. }
  18821. m.SetMsgtype(v)
  18822. return nil
  18823. case msg.FieldMsg:
  18824. v, ok := value.(string)
  18825. if !ok {
  18826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18827. }
  18828. m.SetMsg(v)
  18829. return nil
  18830. case msg.FieldBatchNo:
  18831. v, ok := value.(string)
  18832. if !ok {
  18833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18834. }
  18835. m.SetBatchNo(v)
  18836. return nil
  18837. }
  18838. return fmt.Errorf("unknown Msg field %s", name)
  18839. }
  18840. // AddedFields returns all numeric fields that were incremented/decremented during
  18841. // this mutation.
  18842. func (m *MsgMutation) AddedFields() []string {
  18843. var fields []string
  18844. if m.addstatus != nil {
  18845. fields = append(fields, msg.FieldStatus)
  18846. }
  18847. if m.addmsgtype != nil {
  18848. fields = append(fields, msg.FieldMsgtype)
  18849. }
  18850. return fields
  18851. }
  18852. // AddedField returns the numeric value that was incremented/decremented on a field
  18853. // with the given name. The second boolean return value indicates that this field
  18854. // was not set, or was not defined in the schema.
  18855. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18856. switch name {
  18857. case msg.FieldStatus:
  18858. return m.AddedStatus()
  18859. case msg.FieldMsgtype:
  18860. return m.AddedMsgtype()
  18861. }
  18862. return nil, false
  18863. }
  18864. // AddField adds the value to the field with the given name. It returns an error if
  18865. // the field is not defined in the schema, or if the type mismatched the field
  18866. // type.
  18867. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18868. switch name {
  18869. case msg.FieldStatus:
  18870. v, ok := value.(int8)
  18871. if !ok {
  18872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18873. }
  18874. m.AddStatus(v)
  18875. return nil
  18876. case msg.FieldMsgtype:
  18877. v, ok := value.(int32)
  18878. if !ok {
  18879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18880. }
  18881. m.AddMsgtype(v)
  18882. return nil
  18883. }
  18884. return fmt.Errorf("unknown Msg numeric field %s", name)
  18885. }
  18886. // ClearedFields returns all nullable fields that were cleared during this
  18887. // mutation.
  18888. func (m *MsgMutation) ClearedFields() []string {
  18889. var fields []string
  18890. if m.FieldCleared(msg.FieldDeletedAt) {
  18891. fields = append(fields, msg.FieldDeletedAt)
  18892. }
  18893. if m.FieldCleared(msg.FieldStatus) {
  18894. fields = append(fields, msg.FieldStatus)
  18895. }
  18896. if m.FieldCleared(msg.FieldFromwxid) {
  18897. fields = append(fields, msg.FieldFromwxid)
  18898. }
  18899. if m.FieldCleared(msg.FieldToid) {
  18900. fields = append(fields, msg.FieldToid)
  18901. }
  18902. if m.FieldCleared(msg.FieldMsgtype) {
  18903. fields = append(fields, msg.FieldMsgtype)
  18904. }
  18905. if m.FieldCleared(msg.FieldMsg) {
  18906. fields = append(fields, msg.FieldMsg)
  18907. }
  18908. if m.FieldCleared(msg.FieldBatchNo) {
  18909. fields = append(fields, msg.FieldBatchNo)
  18910. }
  18911. return fields
  18912. }
  18913. // FieldCleared returns a boolean indicating if a field with the given name was
  18914. // cleared in this mutation.
  18915. func (m *MsgMutation) FieldCleared(name string) bool {
  18916. _, ok := m.clearedFields[name]
  18917. return ok
  18918. }
  18919. // ClearField clears the value of the field with the given name. It returns an
  18920. // error if the field is not defined in the schema.
  18921. func (m *MsgMutation) ClearField(name string) error {
  18922. switch name {
  18923. case msg.FieldDeletedAt:
  18924. m.ClearDeletedAt()
  18925. return nil
  18926. case msg.FieldStatus:
  18927. m.ClearStatus()
  18928. return nil
  18929. case msg.FieldFromwxid:
  18930. m.ClearFromwxid()
  18931. return nil
  18932. case msg.FieldToid:
  18933. m.ClearToid()
  18934. return nil
  18935. case msg.FieldMsgtype:
  18936. m.ClearMsgtype()
  18937. return nil
  18938. case msg.FieldMsg:
  18939. m.ClearMsg()
  18940. return nil
  18941. case msg.FieldBatchNo:
  18942. m.ClearBatchNo()
  18943. return nil
  18944. }
  18945. return fmt.Errorf("unknown Msg nullable field %s", name)
  18946. }
  18947. // ResetField resets all changes in the mutation for the field with the given name.
  18948. // It returns an error if the field is not defined in the schema.
  18949. func (m *MsgMutation) ResetField(name string) error {
  18950. switch name {
  18951. case msg.FieldCreatedAt:
  18952. m.ResetCreatedAt()
  18953. return nil
  18954. case msg.FieldUpdatedAt:
  18955. m.ResetUpdatedAt()
  18956. return nil
  18957. case msg.FieldDeletedAt:
  18958. m.ResetDeletedAt()
  18959. return nil
  18960. case msg.FieldStatus:
  18961. m.ResetStatus()
  18962. return nil
  18963. case msg.FieldFromwxid:
  18964. m.ResetFromwxid()
  18965. return nil
  18966. case msg.FieldToid:
  18967. m.ResetToid()
  18968. return nil
  18969. case msg.FieldMsgtype:
  18970. m.ResetMsgtype()
  18971. return nil
  18972. case msg.FieldMsg:
  18973. m.ResetMsg()
  18974. return nil
  18975. case msg.FieldBatchNo:
  18976. m.ResetBatchNo()
  18977. return nil
  18978. }
  18979. return fmt.Errorf("unknown Msg field %s", name)
  18980. }
  18981. // AddedEdges returns all edge names that were set/added in this mutation.
  18982. func (m *MsgMutation) AddedEdges() []string {
  18983. edges := make([]string, 0, 0)
  18984. return edges
  18985. }
  18986. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18987. // name in this mutation.
  18988. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18989. return nil
  18990. }
  18991. // RemovedEdges returns all edge names that were removed in this mutation.
  18992. func (m *MsgMutation) RemovedEdges() []string {
  18993. edges := make([]string, 0, 0)
  18994. return edges
  18995. }
  18996. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18997. // the given name in this mutation.
  18998. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18999. return nil
  19000. }
  19001. // ClearedEdges returns all edge names that were cleared in this mutation.
  19002. func (m *MsgMutation) ClearedEdges() []string {
  19003. edges := make([]string, 0, 0)
  19004. return edges
  19005. }
  19006. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19007. // was cleared in this mutation.
  19008. func (m *MsgMutation) EdgeCleared(name string) bool {
  19009. return false
  19010. }
  19011. // ClearEdge clears the value of the edge with the given name. It returns an error
  19012. // if that edge is not defined in the schema.
  19013. func (m *MsgMutation) ClearEdge(name string) error {
  19014. return fmt.Errorf("unknown Msg unique edge %s", name)
  19015. }
  19016. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19017. // It returns an error if the edge is not defined in the schema.
  19018. func (m *MsgMutation) ResetEdge(name string) error {
  19019. return fmt.Errorf("unknown Msg edge %s", name)
  19020. }
  19021. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19022. type PayRechargeMutation struct {
  19023. config
  19024. op Op
  19025. typ string
  19026. id *uint64
  19027. created_at *time.Time
  19028. updated_at *time.Time
  19029. deleted_at *time.Time
  19030. user_id *string
  19031. number *float32
  19032. addnumber *float32
  19033. status *int
  19034. addstatus *int
  19035. money *float32
  19036. addmoney *float32
  19037. out_trade_no *string
  19038. organization_id *uint64
  19039. addorganization_id *int64
  19040. clearedFields map[string]struct{}
  19041. done bool
  19042. oldValue func(context.Context) (*PayRecharge, error)
  19043. predicates []predicate.PayRecharge
  19044. }
  19045. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19046. // payrechargeOption allows management of the mutation configuration using functional options.
  19047. type payrechargeOption func(*PayRechargeMutation)
  19048. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19049. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19050. m := &PayRechargeMutation{
  19051. config: c,
  19052. op: op,
  19053. typ: TypePayRecharge,
  19054. clearedFields: make(map[string]struct{}),
  19055. }
  19056. for _, opt := range opts {
  19057. opt(m)
  19058. }
  19059. return m
  19060. }
  19061. // withPayRechargeID sets the ID field of the mutation.
  19062. func withPayRechargeID(id uint64) payrechargeOption {
  19063. return func(m *PayRechargeMutation) {
  19064. var (
  19065. err error
  19066. once sync.Once
  19067. value *PayRecharge
  19068. )
  19069. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19070. once.Do(func() {
  19071. if m.done {
  19072. err = errors.New("querying old values post mutation is not allowed")
  19073. } else {
  19074. value, err = m.Client().PayRecharge.Get(ctx, id)
  19075. }
  19076. })
  19077. return value, err
  19078. }
  19079. m.id = &id
  19080. }
  19081. }
  19082. // withPayRecharge sets the old PayRecharge of the mutation.
  19083. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19084. return func(m *PayRechargeMutation) {
  19085. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19086. return node, nil
  19087. }
  19088. m.id = &node.ID
  19089. }
  19090. }
  19091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19092. // executed in a transaction (ent.Tx), a transactional client is returned.
  19093. func (m PayRechargeMutation) Client() *Client {
  19094. client := &Client{config: m.config}
  19095. client.init()
  19096. return client
  19097. }
  19098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19099. // it returns an error otherwise.
  19100. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19101. if _, ok := m.driver.(*txDriver); !ok {
  19102. return nil, errors.New("ent: mutation is not running in a transaction")
  19103. }
  19104. tx := &Tx{config: m.config}
  19105. tx.init()
  19106. return tx, nil
  19107. }
  19108. // SetID sets the value of the id field. Note that this
  19109. // operation is only accepted on creation of PayRecharge entities.
  19110. func (m *PayRechargeMutation) SetID(id uint64) {
  19111. m.id = &id
  19112. }
  19113. // ID returns the ID value in the mutation. Note that the ID is only available
  19114. // if it was provided to the builder or after it was returned from the database.
  19115. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19116. if m.id == nil {
  19117. return
  19118. }
  19119. return *m.id, true
  19120. }
  19121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19122. // That means, if the mutation is applied within a transaction with an isolation level such
  19123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19124. // or updated by the mutation.
  19125. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19126. switch {
  19127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19128. id, exists := m.ID()
  19129. if exists {
  19130. return []uint64{id}, nil
  19131. }
  19132. fallthrough
  19133. case m.op.Is(OpUpdate | OpDelete):
  19134. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19135. default:
  19136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19137. }
  19138. }
  19139. // SetCreatedAt sets the "created_at" field.
  19140. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19141. m.created_at = &t
  19142. }
  19143. // CreatedAt returns the value of the "created_at" field in the mutation.
  19144. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19145. v := m.created_at
  19146. if v == nil {
  19147. return
  19148. }
  19149. return *v, true
  19150. }
  19151. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19152. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19154. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19155. if !m.op.Is(OpUpdateOne) {
  19156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19157. }
  19158. if m.id == nil || m.oldValue == nil {
  19159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19160. }
  19161. oldValue, err := m.oldValue(ctx)
  19162. if err != nil {
  19163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19164. }
  19165. return oldValue.CreatedAt, nil
  19166. }
  19167. // ResetCreatedAt resets all changes to the "created_at" field.
  19168. func (m *PayRechargeMutation) ResetCreatedAt() {
  19169. m.created_at = nil
  19170. }
  19171. // SetUpdatedAt sets the "updated_at" field.
  19172. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19173. m.updated_at = &t
  19174. }
  19175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19176. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19177. v := m.updated_at
  19178. if v == nil {
  19179. return
  19180. }
  19181. return *v, true
  19182. }
  19183. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19184. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19186. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19187. if !m.op.Is(OpUpdateOne) {
  19188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19189. }
  19190. if m.id == nil || m.oldValue == nil {
  19191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19192. }
  19193. oldValue, err := m.oldValue(ctx)
  19194. if err != nil {
  19195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19196. }
  19197. return oldValue.UpdatedAt, nil
  19198. }
  19199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19200. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19201. m.updated_at = nil
  19202. }
  19203. // SetDeletedAt sets the "deleted_at" field.
  19204. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19205. m.deleted_at = &t
  19206. }
  19207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19208. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19209. v := m.deleted_at
  19210. if v == nil {
  19211. return
  19212. }
  19213. return *v, true
  19214. }
  19215. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19216. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19218. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19219. if !m.op.Is(OpUpdateOne) {
  19220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19221. }
  19222. if m.id == nil || m.oldValue == nil {
  19223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19224. }
  19225. oldValue, err := m.oldValue(ctx)
  19226. if err != nil {
  19227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19228. }
  19229. return oldValue.DeletedAt, nil
  19230. }
  19231. // ClearDeletedAt clears the value of the "deleted_at" field.
  19232. func (m *PayRechargeMutation) ClearDeletedAt() {
  19233. m.deleted_at = nil
  19234. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19235. }
  19236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19237. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19238. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19239. return ok
  19240. }
  19241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19242. func (m *PayRechargeMutation) ResetDeletedAt() {
  19243. m.deleted_at = nil
  19244. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19245. }
  19246. // SetUserID sets the "user_id" field.
  19247. func (m *PayRechargeMutation) SetUserID(s string) {
  19248. m.user_id = &s
  19249. }
  19250. // UserID returns the value of the "user_id" field in the mutation.
  19251. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19252. v := m.user_id
  19253. if v == nil {
  19254. return
  19255. }
  19256. return *v, true
  19257. }
  19258. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19259. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19261. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19262. if !m.op.Is(OpUpdateOne) {
  19263. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19264. }
  19265. if m.id == nil || m.oldValue == nil {
  19266. return v, errors.New("OldUserID requires an ID field in the mutation")
  19267. }
  19268. oldValue, err := m.oldValue(ctx)
  19269. if err != nil {
  19270. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19271. }
  19272. return oldValue.UserID, nil
  19273. }
  19274. // ResetUserID resets all changes to the "user_id" field.
  19275. func (m *PayRechargeMutation) ResetUserID() {
  19276. m.user_id = nil
  19277. }
  19278. // SetNumber sets the "number" field.
  19279. func (m *PayRechargeMutation) SetNumber(f float32) {
  19280. m.number = &f
  19281. m.addnumber = nil
  19282. }
  19283. // Number returns the value of the "number" field in the mutation.
  19284. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19285. v := m.number
  19286. if v == nil {
  19287. return
  19288. }
  19289. return *v, true
  19290. }
  19291. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19292. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19294. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19295. if !m.op.Is(OpUpdateOne) {
  19296. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19297. }
  19298. if m.id == nil || m.oldValue == nil {
  19299. return v, errors.New("OldNumber requires an ID field in the mutation")
  19300. }
  19301. oldValue, err := m.oldValue(ctx)
  19302. if err != nil {
  19303. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19304. }
  19305. return oldValue.Number, nil
  19306. }
  19307. // AddNumber adds f to the "number" field.
  19308. func (m *PayRechargeMutation) AddNumber(f float32) {
  19309. if m.addnumber != nil {
  19310. *m.addnumber += f
  19311. } else {
  19312. m.addnumber = &f
  19313. }
  19314. }
  19315. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19316. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19317. v := m.addnumber
  19318. if v == nil {
  19319. return
  19320. }
  19321. return *v, true
  19322. }
  19323. // ResetNumber resets all changes to the "number" field.
  19324. func (m *PayRechargeMutation) ResetNumber() {
  19325. m.number = nil
  19326. m.addnumber = nil
  19327. }
  19328. // SetStatus sets the "status" field.
  19329. func (m *PayRechargeMutation) SetStatus(i int) {
  19330. m.status = &i
  19331. m.addstatus = nil
  19332. }
  19333. // Status returns the value of the "status" field in the mutation.
  19334. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19335. v := m.status
  19336. if v == nil {
  19337. return
  19338. }
  19339. return *v, true
  19340. }
  19341. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19342. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19344. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19345. if !m.op.Is(OpUpdateOne) {
  19346. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19347. }
  19348. if m.id == nil || m.oldValue == nil {
  19349. return v, errors.New("OldStatus requires an ID field in the mutation")
  19350. }
  19351. oldValue, err := m.oldValue(ctx)
  19352. if err != nil {
  19353. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19354. }
  19355. return oldValue.Status, nil
  19356. }
  19357. // AddStatus adds i to the "status" field.
  19358. func (m *PayRechargeMutation) AddStatus(i int) {
  19359. if m.addstatus != nil {
  19360. *m.addstatus += i
  19361. } else {
  19362. m.addstatus = &i
  19363. }
  19364. }
  19365. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19366. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19367. v := m.addstatus
  19368. if v == nil {
  19369. return
  19370. }
  19371. return *v, true
  19372. }
  19373. // ClearStatus clears the value of the "status" field.
  19374. func (m *PayRechargeMutation) ClearStatus() {
  19375. m.status = nil
  19376. m.addstatus = nil
  19377. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19378. }
  19379. // StatusCleared returns if the "status" field was cleared in this mutation.
  19380. func (m *PayRechargeMutation) StatusCleared() bool {
  19381. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19382. return ok
  19383. }
  19384. // ResetStatus resets all changes to the "status" field.
  19385. func (m *PayRechargeMutation) ResetStatus() {
  19386. m.status = nil
  19387. m.addstatus = nil
  19388. delete(m.clearedFields, payrecharge.FieldStatus)
  19389. }
  19390. // SetMoney sets the "money" field.
  19391. func (m *PayRechargeMutation) SetMoney(f float32) {
  19392. m.money = &f
  19393. m.addmoney = nil
  19394. }
  19395. // Money returns the value of the "money" field in the mutation.
  19396. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19397. v := m.money
  19398. if v == nil {
  19399. return
  19400. }
  19401. return *v, true
  19402. }
  19403. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19404. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19406. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19407. if !m.op.Is(OpUpdateOne) {
  19408. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19409. }
  19410. if m.id == nil || m.oldValue == nil {
  19411. return v, errors.New("OldMoney requires an ID field in the mutation")
  19412. }
  19413. oldValue, err := m.oldValue(ctx)
  19414. if err != nil {
  19415. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19416. }
  19417. return oldValue.Money, nil
  19418. }
  19419. // AddMoney adds f to the "money" field.
  19420. func (m *PayRechargeMutation) AddMoney(f float32) {
  19421. if m.addmoney != nil {
  19422. *m.addmoney += f
  19423. } else {
  19424. m.addmoney = &f
  19425. }
  19426. }
  19427. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19428. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19429. v := m.addmoney
  19430. if v == nil {
  19431. return
  19432. }
  19433. return *v, true
  19434. }
  19435. // ClearMoney clears the value of the "money" field.
  19436. func (m *PayRechargeMutation) ClearMoney() {
  19437. m.money = nil
  19438. m.addmoney = nil
  19439. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19440. }
  19441. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19442. func (m *PayRechargeMutation) MoneyCleared() bool {
  19443. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19444. return ok
  19445. }
  19446. // ResetMoney resets all changes to the "money" field.
  19447. func (m *PayRechargeMutation) ResetMoney() {
  19448. m.money = nil
  19449. m.addmoney = nil
  19450. delete(m.clearedFields, payrecharge.FieldMoney)
  19451. }
  19452. // SetOutTradeNo sets the "out_trade_no" field.
  19453. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19454. m.out_trade_no = &s
  19455. }
  19456. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19457. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19458. v := m.out_trade_no
  19459. if v == nil {
  19460. return
  19461. }
  19462. return *v, true
  19463. }
  19464. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19465. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19467. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19468. if !m.op.Is(OpUpdateOne) {
  19469. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19470. }
  19471. if m.id == nil || m.oldValue == nil {
  19472. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19473. }
  19474. oldValue, err := m.oldValue(ctx)
  19475. if err != nil {
  19476. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19477. }
  19478. return oldValue.OutTradeNo, nil
  19479. }
  19480. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19481. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19482. m.out_trade_no = nil
  19483. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19484. }
  19485. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19486. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19487. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19488. return ok
  19489. }
  19490. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19491. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19492. m.out_trade_no = nil
  19493. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19494. }
  19495. // SetOrganizationID sets the "organization_id" field.
  19496. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19497. m.organization_id = &u
  19498. m.addorganization_id = nil
  19499. }
  19500. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19501. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19502. v := m.organization_id
  19503. if v == nil {
  19504. return
  19505. }
  19506. return *v, true
  19507. }
  19508. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19509. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19511. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19512. if !m.op.Is(OpUpdateOne) {
  19513. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19514. }
  19515. if m.id == nil || m.oldValue == nil {
  19516. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19517. }
  19518. oldValue, err := m.oldValue(ctx)
  19519. if err != nil {
  19520. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19521. }
  19522. return oldValue.OrganizationID, nil
  19523. }
  19524. // AddOrganizationID adds u to the "organization_id" field.
  19525. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19526. if m.addorganization_id != nil {
  19527. *m.addorganization_id += u
  19528. } else {
  19529. m.addorganization_id = &u
  19530. }
  19531. }
  19532. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19533. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19534. v := m.addorganization_id
  19535. if v == nil {
  19536. return
  19537. }
  19538. return *v, true
  19539. }
  19540. // ResetOrganizationID resets all changes to the "organization_id" field.
  19541. func (m *PayRechargeMutation) ResetOrganizationID() {
  19542. m.organization_id = nil
  19543. m.addorganization_id = nil
  19544. }
  19545. // Where appends a list predicates to the PayRechargeMutation builder.
  19546. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19547. m.predicates = append(m.predicates, ps...)
  19548. }
  19549. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19550. // users can use type-assertion to append predicates that do not depend on any generated package.
  19551. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19552. p := make([]predicate.PayRecharge, len(ps))
  19553. for i := range ps {
  19554. p[i] = ps[i]
  19555. }
  19556. m.Where(p...)
  19557. }
  19558. // Op returns the operation name.
  19559. func (m *PayRechargeMutation) Op() Op {
  19560. return m.op
  19561. }
  19562. // SetOp allows setting the mutation operation.
  19563. func (m *PayRechargeMutation) SetOp(op Op) {
  19564. m.op = op
  19565. }
  19566. // Type returns the node type of this mutation (PayRecharge).
  19567. func (m *PayRechargeMutation) Type() string {
  19568. return m.typ
  19569. }
  19570. // Fields returns all fields that were changed during this mutation. Note that in
  19571. // order to get all numeric fields that were incremented/decremented, call
  19572. // AddedFields().
  19573. func (m *PayRechargeMutation) Fields() []string {
  19574. fields := make([]string, 0, 9)
  19575. if m.created_at != nil {
  19576. fields = append(fields, payrecharge.FieldCreatedAt)
  19577. }
  19578. if m.updated_at != nil {
  19579. fields = append(fields, payrecharge.FieldUpdatedAt)
  19580. }
  19581. if m.deleted_at != nil {
  19582. fields = append(fields, payrecharge.FieldDeletedAt)
  19583. }
  19584. if m.user_id != nil {
  19585. fields = append(fields, payrecharge.FieldUserID)
  19586. }
  19587. if m.number != nil {
  19588. fields = append(fields, payrecharge.FieldNumber)
  19589. }
  19590. if m.status != nil {
  19591. fields = append(fields, payrecharge.FieldStatus)
  19592. }
  19593. if m.money != nil {
  19594. fields = append(fields, payrecharge.FieldMoney)
  19595. }
  19596. if m.out_trade_no != nil {
  19597. fields = append(fields, payrecharge.FieldOutTradeNo)
  19598. }
  19599. if m.organization_id != nil {
  19600. fields = append(fields, payrecharge.FieldOrganizationID)
  19601. }
  19602. return fields
  19603. }
  19604. // Field returns the value of a field with the given name. The second boolean
  19605. // return value indicates that this field was not set, or was not defined in the
  19606. // schema.
  19607. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19608. switch name {
  19609. case payrecharge.FieldCreatedAt:
  19610. return m.CreatedAt()
  19611. case payrecharge.FieldUpdatedAt:
  19612. return m.UpdatedAt()
  19613. case payrecharge.FieldDeletedAt:
  19614. return m.DeletedAt()
  19615. case payrecharge.FieldUserID:
  19616. return m.UserID()
  19617. case payrecharge.FieldNumber:
  19618. return m.Number()
  19619. case payrecharge.FieldStatus:
  19620. return m.Status()
  19621. case payrecharge.FieldMoney:
  19622. return m.Money()
  19623. case payrecharge.FieldOutTradeNo:
  19624. return m.OutTradeNo()
  19625. case payrecharge.FieldOrganizationID:
  19626. return m.OrganizationID()
  19627. }
  19628. return nil, false
  19629. }
  19630. // OldField returns the old value of the field from the database. An error is
  19631. // returned if the mutation operation is not UpdateOne, or the query to the
  19632. // database failed.
  19633. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19634. switch name {
  19635. case payrecharge.FieldCreatedAt:
  19636. return m.OldCreatedAt(ctx)
  19637. case payrecharge.FieldUpdatedAt:
  19638. return m.OldUpdatedAt(ctx)
  19639. case payrecharge.FieldDeletedAt:
  19640. return m.OldDeletedAt(ctx)
  19641. case payrecharge.FieldUserID:
  19642. return m.OldUserID(ctx)
  19643. case payrecharge.FieldNumber:
  19644. return m.OldNumber(ctx)
  19645. case payrecharge.FieldStatus:
  19646. return m.OldStatus(ctx)
  19647. case payrecharge.FieldMoney:
  19648. return m.OldMoney(ctx)
  19649. case payrecharge.FieldOutTradeNo:
  19650. return m.OldOutTradeNo(ctx)
  19651. case payrecharge.FieldOrganizationID:
  19652. return m.OldOrganizationID(ctx)
  19653. }
  19654. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19655. }
  19656. // SetField sets the value of a field with the given name. It returns an error if
  19657. // the field is not defined in the schema, or if the type mismatched the field
  19658. // type.
  19659. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19660. switch name {
  19661. case payrecharge.FieldCreatedAt:
  19662. v, ok := value.(time.Time)
  19663. if !ok {
  19664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19665. }
  19666. m.SetCreatedAt(v)
  19667. return nil
  19668. case payrecharge.FieldUpdatedAt:
  19669. v, ok := value.(time.Time)
  19670. if !ok {
  19671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19672. }
  19673. m.SetUpdatedAt(v)
  19674. return nil
  19675. case payrecharge.FieldDeletedAt:
  19676. v, ok := value.(time.Time)
  19677. if !ok {
  19678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19679. }
  19680. m.SetDeletedAt(v)
  19681. return nil
  19682. case payrecharge.FieldUserID:
  19683. v, ok := value.(string)
  19684. if !ok {
  19685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19686. }
  19687. m.SetUserID(v)
  19688. return nil
  19689. case payrecharge.FieldNumber:
  19690. v, ok := value.(float32)
  19691. if !ok {
  19692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19693. }
  19694. m.SetNumber(v)
  19695. return nil
  19696. case payrecharge.FieldStatus:
  19697. v, ok := value.(int)
  19698. if !ok {
  19699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19700. }
  19701. m.SetStatus(v)
  19702. return nil
  19703. case payrecharge.FieldMoney:
  19704. v, ok := value.(float32)
  19705. if !ok {
  19706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19707. }
  19708. m.SetMoney(v)
  19709. return nil
  19710. case payrecharge.FieldOutTradeNo:
  19711. v, ok := value.(string)
  19712. if !ok {
  19713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19714. }
  19715. m.SetOutTradeNo(v)
  19716. return nil
  19717. case payrecharge.FieldOrganizationID:
  19718. v, ok := value.(uint64)
  19719. if !ok {
  19720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19721. }
  19722. m.SetOrganizationID(v)
  19723. return nil
  19724. }
  19725. return fmt.Errorf("unknown PayRecharge field %s", name)
  19726. }
  19727. // AddedFields returns all numeric fields that were incremented/decremented during
  19728. // this mutation.
  19729. func (m *PayRechargeMutation) AddedFields() []string {
  19730. var fields []string
  19731. if m.addnumber != nil {
  19732. fields = append(fields, payrecharge.FieldNumber)
  19733. }
  19734. if m.addstatus != nil {
  19735. fields = append(fields, payrecharge.FieldStatus)
  19736. }
  19737. if m.addmoney != nil {
  19738. fields = append(fields, payrecharge.FieldMoney)
  19739. }
  19740. if m.addorganization_id != nil {
  19741. fields = append(fields, payrecharge.FieldOrganizationID)
  19742. }
  19743. return fields
  19744. }
  19745. // AddedField returns the numeric value that was incremented/decremented on a field
  19746. // with the given name. The second boolean return value indicates that this field
  19747. // was not set, or was not defined in the schema.
  19748. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19749. switch name {
  19750. case payrecharge.FieldNumber:
  19751. return m.AddedNumber()
  19752. case payrecharge.FieldStatus:
  19753. return m.AddedStatus()
  19754. case payrecharge.FieldMoney:
  19755. return m.AddedMoney()
  19756. case payrecharge.FieldOrganizationID:
  19757. return m.AddedOrganizationID()
  19758. }
  19759. return nil, false
  19760. }
  19761. // AddField adds the value to the field with the given name. It returns an error if
  19762. // the field is not defined in the schema, or if the type mismatched the field
  19763. // type.
  19764. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19765. switch name {
  19766. case payrecharge.FieldNumber:
  19767. v, ok := value.(float32)
  19768. if !ok {
  19769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19770. }
  19771. m.AddNumber(v)
  19772. return nil
  19773. case payrecharge.FieldStatus:
  19774. v, ok := value.(int)
  19775. if !ok {
  19776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19777. }
  19778. m.AddStatus(v)
  19779. return nil
  19780. case payrecharge.FieldMoney:
  19781. v, ok := value.(float32)
  19782. if !ok {
  19783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19784. }
  19785. m.AddMoney(v)
  19786. return nil
  19787. case payrecharge.FieldOrganizationID:
  19788. v, ok := value.(int64)
  19789. if !ok {
  19790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19791. }
  19792. m.AddOrganizationID(v)
  19793. return nil
  19794. }
  19795. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19796. }
  19797. // ClearedFields returns all nullable fields that were cleared during this
  19798. // mutation.
  19799. func (m *PayRechargeMutation) ClearedFields() []string {
  19800. var fields []string
  19801. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19802. fields = append(fields, payrecharge.FieldDeletedAt)
  19803. }
  19804. if m.FieldCleared(payrecharge.FieldStatus) {
  19805. fields = append(fields, payrecharge.FieldStatus)
  19806. }
  19807. if m.FieldCleared(payrecharge.FieldMoney) {
  19808. fields = append(fields, payrecharge.FieldMoney)
  19809. }
  19810. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19811. fields = append(fields, payrecharge.FieldOutTradeNo)
  19812. }
  19813. return fields
  19814. }
  19815. // FieldCleared returns a boolean indicating if a field with the given name was
  19816. // cleared in this mutation.
  19817. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19818. _, ok := m.clearedFields[name]
  19819. return ok
  19820. }
  19821. // ClearField clears the value of the field with the given name. It returns an
  19822. // error if the field is not defined in the schema.
  19823. func (m *PayRechargeMutation) ClearField(name string) error {
  19824. switch name {
  19825. case payrecharge.FieldDeletedAt:
  19826. m.ClearDeletedAt()
  19827. return nil
  19828. case payrecharge.FieldStatus:
  19829. m.ClearStatus()
  19830. return nil
  19831. case payrecharge.FieldMoney:
  19832. m.ClearMoney()
  19833. return nil
  19834. case payrecharge.FieldOutTradeNo:
  19835. m.ClearOutTradeNo()
  19836. return nil
  19837. }
  19838. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19839. }
  19840. // ResetField resets all changes in the mutation for the field with the given name.
  19841. // It returns an error if the field is not defined in the schema.
  19842. func (m *PayRechargeMutation) ResetField(name string) error {
  19843. switch name {
  19844. case payrecharge.FieldCreatedAt:
  19845. m.ResetCreatedAt()
  19846. return nil
  19847. case payrecharge.FieldUpdatedAt:
  19848. m.ResetUpdatedAt()
  19849. return nil
  19850. case payrecharge.FieldDeletedAt:
  19851. m.ResetDeletedAt()
  19852. return nil
  19853. case payrecharge.FieldUserID:
  19854. m.ResetUserID()
  19855. return nil
  19856. case payrecharge.FieldNumber:
  19857. m.ResetNumber()
  19858. return nil
  19859. case payrecharge.FieldStatus:
  19860. m.ResetStatus()
  19861. return nil
  19862. case payrecharge.FieldMoney:
  19863. m.ResetMoney()
  19864. return nil
  19865. case payrecharge.FieldOutTradeNo:
  19866. m.ResetOutTradeNo()
  19867. return nil
  19868. case payrecharge.FieldOrganizationID:
  19869. m.ResetOrganizationID()
  19870. return nil
  19871. }
  19872. return fmt.Errorf("unknown PayRecharge field %s", name)
  19873. }
  19874. // AddedEdges returns all edge names that were set/added in this mutation.
  19875. func (m *PayRechargeMutation) AddedEdges() []string {
  19876. edges := make([]string, 0, 0)
  19877. return edges
  19878. }
  19879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19880. // name in this mutation.
  19881. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19882. return nil
  19883. }
  19884. // RemovedEdges returns all edge names that were removed in this mutation.
  19885. func (m *PayRechargeMutation) RemovedEdges() []string {
  19886. edges := make([]string, 0, 0)
  19887. return edges
  19888. }
  19889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19890. // the given name in this mutation.
  19891. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19892. return nil
  19893. }
  19894. // ClearedEdges returns all edge names that were cleared in this mutation.
  19895. func (m *PayRechargeMutation) ClearedEdges() []string {
  19896. edges := make([]string, 0, 0)
  19897. return edges
  19898. }
  19899. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19900. // was cleared in this mutation.
  19901. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19902. return false
  19903. }
  19904. // ClearEdge clears the value of the edge with the given name. It returns an error
  19905. // if that edge is not defined in the schema.
  19906. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19907. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19908. }
  19909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19910. // It returns an error if the edge is not defined in the schema.
  19911. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19912. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19913. }
  19914. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19915. type ServerMutation struct {
  19916. config
  19917. op Op
  19918. typ string
  19919. id *uint64
  19920. created_at *time.Time
  19921. updated_at *time.Time
  19922. status *uint8
  19923. addstatus *int8
  19924. deleted_at *time.Time
  19925. name *string
  19926. public_ip *string
  19927. private_ip *string
  19928. admin_port *string
  19929. clearedFields map[string]struct{}
  19930. wxs map[uint64]struct{}
  19931. removedwxs map[uint64]struct{}
  19932. clearedwxs bool
  19933. done bool
  19934. oldValue func(context.Context) (*Server, error)
  19935. predicates []predicate.Server
  19936. }
  19937. var _ ent.Mutation = (*ServerMutation)(nil)
  19938. // serverOption allows management of the mutation configuration using functional options.
  19939. type serverOption func(*ServerMutation)
  19940. // newServerMutation creates new mutation for the Server entity.
  19941. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19942. m := &ServerMutation{
  19943. config: c,
  19944. op: op,
  19945. typ: TypeServer,
  19946. clearedFields: make(map[string]struct{}),
  19947. }
  19948. for _, opt := range opts {
  19949. opt(m)
  19950. }
  19951. return m
  19952. }
  19953. // withServerID sets the ID field of the mutation.
  19954. func withServerID(id uint64) serverOption {
  19955. return func(m *ServerMutation) {
  19956. var (
  19957. err error
  19958. once sync.Once
  19959. value *Server
  19960. )
  19961. m.oldValue = func(ctx context.Context) (*Server, error) {
  19962. once.Do(func() {
  19963. if m.done {
  19964. err = errors.New("querying old values post mutation is not allowed")
  19965. } else {
  19966. value, err = m.Client().Server.Get(ctx, id)
  19967. }
  19968. })
  19969. return value, err
  19970. }
  19971. m.id = &id
  19972. }
  19973. }
  19974. // withServer sets the old Server of the mutation.
  19975. func withServer(node *Server) serverOption {
  19976. return func(m *ServerMutation) {
  19977. m.oldValue = func(context.Context) (*Server, error) {
  19978. return node, nil
  19979. }
  19980. m.id = &node.ID
  19981. }
  19982. }
  19983. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19984. // executed in a transaction (ent.Tx), a transactional client is returned.
  19985. func (m ServerMutation) Client() *Client {
  19986. client := &Client{config: m.config}
  19987. client.init()
  19988. return client
  19989. }
  19990. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19991. // it returns an error otherwise.
  19992. func (m ServerMutation) Tx() (*Tx, error) {
  19993. if _, ok := m.driver.(*txDriver); !ok {
  19994. return nil, errors.New("ent: mutation is not running in a transaction")
  19995. }
  19996. tx := &Tx{config: m.config}
  19997. tx.init()
  19998. return tx, nil
  19999. }
  20000. // SetID sets the value of the id field. Note that this
  20001. // operation is only accepted on creation of Server entities.
  20002. func (m *ServerMutation) SetID(id uint64) {
  20003. m.id = &id
  20004. }
  20005. // ID returns the ID value in the mutation. Note that the ID is only available
  20006. // if it was provided to the builder or after it was returned from the database.
  20007. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20008. if m.id == nil {
  20009. return
  20010. }
  20011. return *m.id, true
  20012. }
  20013. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20014. // That means, if the mutation is applied within a transaction with an isolation level such
  20015. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20016. // or updated by the mutation.
  20017. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20018. switch {
  20019. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20020. id, exists := m.ID()
  20021. if exists {
  20022. return []uint64{id}, nil
  20023. }
  20024. fallthrough
  20025. case m.op.Is(OpUpdate | OpDelete):
  20026. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20027. default:
  20028. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20029. }
  20030. }
  20031. // SetCreatedAt sets the "created_at" field.
  20032. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20033. m.created_at = &t
  20034. }
  20035. // CreatedAt returns the value of the "created_at" field in the mutation.
  20036. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20037. v := m.created_at
  20038. if v == nil {
  20039. return
  20040. }
  20041. return *v, true
  20042. }
  20043. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20044. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20046. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20047. if !m.op.Is(OpUpdateOne) {
  20048. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20049. }
  20050. if m.id == nil || m.oldValue == nil {
  20051. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20052. }
  20053. oldValue, err := m.oldValue(ctx)
  20054. if err != nil {
  20055. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20056. }
  20057. return oldValue.CreatedAt, nil
  20058. }
  20059. // ResetCreatedAt resets all changes to the "created_at" field.
  20060. func (m *ServerMutation) ResetCreatedAt() {
  20061. m.created_at = nil
  20062. }
  20063. // SetUpdatedAt sets the "updated_at" field.
  20064. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20065. m.updated_at = &t
  20066. }
  20067. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20068. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20069. v := m.updated_at
  20070. if v == nil {
  20071. return
  20072. }
  20073. return *v, true
  20074. }
  20075. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20076. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20078. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20079. if !m.op.Is(OpUpdateOne) {
  20080. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20081. }
  20082. if m.id == nil || m.oldValue == nil {
  20083. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20084. }
  20085. oldValue, err := m.oldValue(ctx)
  20086. if err != nil {
  20087. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20088. }
  20089. return oldValue.UpdatedAt, nil
  20090. }
  20091. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20092. func (m *ServerMutation) ResetUpdatedAt() {
  20093. m.updated_at = nil
  20094. }
  20095. // SetStatus sets the "status" field.
  20096. func (m *ServerMutation) SetStatus(u uint8) {
  20097. m.status = &u
  20098. m.addstatus = nil
  20099. }
  20100. // Status returns the value of the "status" field in the mutation.
  20101. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20102. v := m.status
  20103. if v == nil {
  20104. return
  20105. }
  20106. return *v, true
  20107. }
  20108. // OldStatus returns the old "status" field's value of the Server entity.
  20109. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20111. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20112. if !m.op.Is(OpUpdateOne) {
  20113. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20114. }
  20115. if m.id == nil || m.oldValue == nil {
  20116. return v, errors.New("OldStatus requires an ID field in the mutation")
  20117. }
  20118. oldValue, err := m.oldValue(ctx)
  20119. if err != nil {
  20120. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20121. }
  20122. return oldValue.Status, nil
  20123. }
  20124. // AddStatus adds u to the "status" field.
  20125. func (m *ServerMutation) AddStatus(u int8) {
  20126. if m.addstatus != nil {
  20127. *m.addstatus += u
  20128. } else {
  20129. m.addstatus = &u
  20130. }
  20131. }
  20132. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20133. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20134. v := m.addstatus
  20135. if v == nil {
  20136. return
  20137. }
  20138. return *v, true
  20139. }
  20140. // ClearStatus clears the value of the "status" field.
  20141. func (m *ServerMutation) ClearStatus() {
  20142. m.status = nil
  20143. m.addstatus = nil
  20144. m.clearedFields[server.FieldStatus] = struct{}{}
  20145. }
  20146. // StatusCleared returns if the "status" field was cleared in this mutation.
  20147. func (m *ServerMutation) StatusCleared() bool {
  20148. _, ok := m.clearedFields[server.FieldStatus]
  20149. return ok
  20150. }
  20151. // ResetStatus resets all changes to the "status" field.
  20152. func (m *ServerMutation) ResetStatus() {
  20153. m.status = nil
  20154. m.addstatus = nil
  20155. delete(m.clearedFields, server.FieldStatus)
  20156. }
  20157. // SetDeletedAt sets the "deleted_at" field.
  20158. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20159. m.deleted_at = &t
  20160. }
  20161. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20162. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20163. v := m.deleted_at
  20164. if v == nil {
  20165. return
  20166. }
  20167. return *v, true
  20168. }
  20169. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20170. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20172. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20173. if !m.op.Is(OpUpdateOne) {
  20174. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20175. }
  20176. if m.id == nil || m.oldValue == nil {
  20177. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20178. }
  20179. oldValue, err := m.oldValue(ctx)
  20180. if err != nil {
  20181. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20182. }
  20183. return oldValue.DeletedAt, nil
  20184. }
  20185. // ClearDeletedAt clears the value of the "deleted_at" field.
  20186. func (m *ServerMutation) ClearDeletedAt() {
  20187. m.deleted_at = nil
  20188. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20189. }
  20190. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20191. func (m *ServerMutation) DeletedAtCleared() bool {
  20192. _, ok := m.clearedFields[server.FieldDeletedAt]
  20193. return ok
  20194. }
  20195. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20196. func (m *ServerMutation) ResetDeletedAt() {
  20197. m.deleted_at = nil
  20198. delete(m.clearedFields, server.FieldDeletedAt)
  20199. }
  20200. // SetName sets the "name" field.
  20201. func (m *ServerMutation) SetName(s string) {
  20202. m.name = &s
  20203. }
  20204. // Name returns the value of the "name" field in the mutation.
  20205. func (m *ServerMutation) Name() (r string, exists bool) {
  20206. v := m.name
  20207. if v == nil {
  20208. return
  20209. }
  20210. return *v, true
  20211. }
  20212. // OldName returns the old "name" field's value of the Server entity.
  20213. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20215. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20216. if !m.op.Is(OpUpdateOne) {
  20217. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20218. }
  20219. if m.id == nil || m.oldValue == nil {
  20220. return v, errors.New("OldName requires an ID field in the mutation")
  20221. }
  20222. oldValue, err := m.oldValue(ctx)
  20223. if err != nil {
  20224. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20225. }
  20226. return oldValue.Name, nil
  20227. }
  20228. // ResetName resets all changes to the "name" field.
  20229. func (m *ServerMutation) ResetName() {
  20230. m.name = nil
  20231. }
  20232. // SetPublicIP sets the "public_ip" field.
  20233. func (m *ServerMutation) SetPublicIP(s string) {
  20234. m.public_ip = &s
  20235. }
  20236. // PublicIP returns the value of the "public_ip" field in the mutation.
  20237. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20238. v := m.public_ip
  20239. if v == nil {
  20240. return
  20241. }
  20242. return *v, true
  20243. }
  20244. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20245. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20247. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20248. if !m.op.Is(OpUpdateOne) {
  20249. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20250. }
  20251. if m.id == nil || m.oldValue == nil {
  20252. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20253. }
  20254. oldValue, err := m.oldValue(ctx)
  20255. if err != nil {
  20256. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20257. }
  20258. return oldValue.PublicIP, nil
  20259. }
  20260. // ResetPublicIP resets all changes to the "public_ip" field.
  20261. func (m *ServerMutation) ResetPublicIP() {
  20262. m.public_ip = nil
  20263. }
  20264. // SetPrivateIP sets the "private_ip" field.
  20265. func (m *ServerMutation) SetPrivateIP(s string) {
  20266. m.private_ip = &s
  20267. }
  20268. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20269. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20270. v := m.private_ip
  20271. if v == nil {
  20272. return
  20273. }
  20274. return *v, true
  20275. }
  20276. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20277. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20279. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20280. if !m.op.Is(OpUpdateOne) {
  20281. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20282. }
  20283. if m.id == nil || m.oldValue == nil {
  20284. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20285. }
  20286. oldValue, err := m.oldValue(ctx)
  20287. if err != nil {
  20288. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20289. }
  20290. return oldValue.PrivateIP, nil
  20291. }
  20292. // ResetPrivateIP resets all changes to the "private_ip" field.
  20293. func (m *ServerMutation) ResetPrivateIP() {
  20294. m.private_ip = nil
  20295. }
  20296. // SetAdminPort sets the "admin_port" field.
  20297. func (m *ServerMutation) SetAdminPort(s string) {
  20298. m.admin_port = &s
  20299. }
  20300. // AdminPort returns the value of the "admin_port" field in the mutation.
  20301. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20302. v := m.admin_port
  20303. if v == nil {
  20304. return
  20305. }
  20306. return *v, true
  20307. }
  20308. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20309. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20311. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20312. if !m.op.Is(OpUpdateOne) {
  20313. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20314. }
  20315. if m.id == nil || m.oldValue == nil {
  20316. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20317. }
  20318. oldValue, err := m.oldValue(ctx)
  20319. if err != nil {
  20320. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20321. }
  20322. return oldValue.AdminPort, nil
  20323. }
  20324. // ResetAdminPort resets all changes to the "admin_port" field.
  20325. func (m *ServerMutation) ResetAdminPort() {
  20326. m.admin_port = nil
  20327. }
  20328. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20329. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20330. if m.wxs == nil {
  20331. m.wxs = make(map[uint64]struct{})
  20332. }
  20333. for i := range ids {
  20334. m.wxs[ids[i]] = struct{}{}
  20335. }
  20336. }
  20337. // ClearWxs clears the "wxs" edge to the Wx entity.
  20338. func (m *ServerMutation) ClearWxs() {
  20339. m.clearedwxs = true
  20340. }
  20341. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20342. func (m *ServerMutation) WxsCleared() bool {
  20343. return m.clearedwxs
  20344. }
  20345. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20346. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20347. if m.removedwxs == nil {
  20348. m.removedwxs = make(map[uint64]struct{})
  20349. }
  20350. for i := range ids {
  20351. delete(m.wxs, ids[i])
  20352. m.removedwxs[ids[i]] = struct{}{}
  20353. }
  20354. }
  20355. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20356. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20357. for id := range m.removedwxs {
  20358. ids = append(ids, id)
  20359. }
  20360. return
  20361. }
  20362. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20363. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20364. for id := range m.wxs {
  20365. ids = append(ids, id)
  20366. }
  20367. return
  20368. }
  20369. // ResetWxs resets all changes to the "wxs" edge.
  20370. func (m *ServerMutation) ResetWxs() {
  20371. m.wxs = nil
  20372. m.clearedwxs = false
  20373. m.removedwxs = nil
  20374. }
  20375. // Where appends a list predicates to the ServerMutation builder.
  20376. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20377. m.predicates = append(m.predicates, ps...)
  20378. }
  20379. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20380. // users can use type-assertion to append predicates that do not depend on any generated package.
  20381. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20382. p := make([]predicate.Server, len(ps))
  20383. for i := range ps {
  20384. p[i] = ps[i]
  20385. }
  20386. m.Where(p...)
  20387. }
  20388. // Op returns the operation name.
  20389. func (m *ServerMutation) Op() Op {
  20390. return m.op
  20391. }
  20392. // SetOp allows setting the mutation operation.
  20393. func (m *ServerMutation) SetOp(op Op) {
  20394. m.op = op
  20395. }
  20396. // Type returns the node type of this mutation (Server).
  20397. func (m *ServerMutation) Type() string {
  20398. return m.typ
  20399. }
  20400. // Fields returns all fields that were changed during this mutation. Note that in
  20401. // order to get all numeric fields that were incremented/decremented, call
  20402. // AddedFields().
  20403. func (m *ServerMutation) Fields() []string {
  20404. fields := make([]string, 0, 8)
  20405. if m.created_at != nil {
  20406. fields = append(fields, server.FieldCreatedAt)
  20407. }
  20408. if m.updated_at != nil {
  20409. fields = append(fields, server.FieldUpdatedAt)
  20410. }
  20411. if m.status != nil {
  20412. fields = append(fields, server.FieldStatus)
  20413. }
  20414. if m.deleted_at != nil {
  20415. fields = append(fields, server.FieldDeletedAt)
  20416. }
  20417. if m.name != nil {
  20418. fields = append(fields, server.FieldName)
  20419. }
  20420. if m.public_ip != nil {
  20421. fields = append(fields, server.FieldPublicIP)
  20422. }
  20423. if m.private_ip != nil {
  20424. fields = append(fields, server.FieldPrivateIP)
  20425. }
  20426. if m.admin_port != nil {
  20427. fields = append(fields, server.FieldAdminPort)
  20428. }
  20429. return fields
  20430. }
  20431. // Field returns the value of a field with the given name. The second boolean
  20432. // return value indicates that this field was not set, or was not defined in the
  20433. // schema.
  20434. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20435. switch name {
  20436. case server.FieldCreatedAt:
  20437. return m.CreatedAt()
  20438. case server.FieldUpdatedAt:
  20439. return m.UpdatedAt()
  20440. case server.FieldStatus:
  20441. return m.Status()
  20442. case server.FieldDeletedAt:
  20443. return m.DeletedAt()
  20444. case server.FieldName:
  20445. return m.Name()
  20446. case server.FieldPublicIP:
  20447. return m.PublicIP()
  20448. case server.FieldPrivateIP:
  20449. return m.PrivateIP()
  20450. case server.FieldAdminPort:
  20451. return m.AdminPort()
  20452. }
  20453. return nil, false
  20454. }
  20455. // OldField returns the old value of the field from the database. An error is
  20456. // returned if the mutation operation is not UpdateOne, or the query to the
  20457. // database failed.
  20458. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20459. switch name {
  20460. case server.FieldCreatedAt:
  20461. return m.OldCreatedAt(ctx)
  20462. case server.FieldUpdatedAt:
  20463. return m.OldUpdatedAt(ctx)
  20464. case server.FieldStatus:
  20465. return m.OldStatus(ctx)
  20466. case server.FieldDeletedAt:
  20467. return m.OldDeletedAt(ctx)
  20468. case server.FieldName:
  20469. return m.OldName(ctx)
  20470. case server.FieldPublicIP:
  20471. return m.OldPublicIP(ctx)
  20472. case server.FieldPrivateIP:
  20473. return m.OldPrivateIP(ctx)
  20474. case server.FieldAdminPort:
  20475. return m.OldAdminPort(ctx)
  20476. }
  20477. return nil, fmt.Errorf("unknown Server field %s", name)
  20478. }
  20479. // SetField sets the value of a field with the given name. It returns an error if
  20480. // the field is not defined in the schema, or if the type mismatched the field
  20481. // type.
  20482. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20483. switch name {
  20484. case server.FieldCreatedAt:
  20485. v, ok := value.(time.Time)
  20486. if !ok {
  20487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20488. }
  20489. m.SetCreatedAt(v)
  20490. return nil
  20491. case server.FieldUpdatedAt:
  20492. v, ok := value.(time.Time)
  20493. if !ok {
  20494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20495. }
  20496. m.SetUpdatedAt(v)
  20497. return nil
  20498. case server.FieldStatus:
  20499. v, ok := value.(uint8)
  20500. if !ok {
  20501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20502. }
  20503. m.SetStatus(v)
  20504. return nil
  20505. case server.FieldDeletedAt:
  20506. v, ok := value.(time.Time)
  20507. if !ok {
  20508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20509. }
  20510. m.SetDeletedAt(v)
  20511. return nil
  20512. case server.FieldName:
  20513. v, ok := value.(string)
  20514. if !ok {
  20515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20516. }
  20517. m.SetName(v)
  20518. return nil
  20519. case server.FieldPublicIP:
  20520. v, ok := value.(string)
  20521. if !ok {
  20522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20523. }
  20524. m.SetPublicIP(v)
  20525. return nil
  20526. case server.FieldPrivateIP:
  20527. v, ok := value.(string)
  20528. if !ok {
  20529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20530. }
  20531. m.SetPrivateIP(v)
  20532. return nil
  20533. case server.FieldAdminPort:
  20534. v, ok := value.(string)
  20535. if !ok {
  20536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20537. }
  20538. m.SetAdminPort(v)
  20539. return nil
  20540. }
  20541. return fmt.Errorf("unknown Server field %s", name)
  20542. }
  20543. // AddedFields returns all numeric fields that were incremented/decremented during
  20544. // this mutation.
  20545. func (m *ServerMutation) AddedFields() []string {
  20546. var fields []string
  20547. if m.addstatus != nil {
  20548. fields = append(fields, server.FieldStatus)
  20549. }
  20550. return fields
  20551. }
  20552. // AddedField returns the numeric value that was incremented/decremented on a field
  20553. // with the given name. The second boolean return value indicates that this field
  20554. // was not set, or was not defined in the schema.
  20555. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20556. switch name {
  20557. case server.FieldStatus:
  20558. return m.AddedStatus()
  20559. }
  20560. return nil, false
  20561. }
  20562. // AddField adds the value to the field with the given name. It returns an error if
  20563. // the field is not defined in the schema, or if the type mismatched the field
  20564. // type.
  20565. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20566. switch name {
  20567. case server.FieldStatus:
  20568. v, ok := value.(int8)
  20569. if !ok {
  20570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20571. }
  20572. m.AddStatus(v)
  20573. return nil
  20574. }
  20575. return fmt.Errorf("unknown Server numeric field %s", name)
  20576. }
  20577. // ClearedFields returns all nullable fields that were cleared during this
  20578. // mutation.
  20579. func (m *ServerMutation) ClearedFields() []string {
  20580. var fields []string
  20581. if m.FieldCleared(server.FieldStatus) {
  20582. fields = append(fields, server.FieldStatus)
  20583. }
  20584. if m.FieldCleared(server.FieldDeletedAt) {
  20585. fields = append(fields, server.FieldDeletedAt)
  20586. }
  20587. return fields
  20588. }
  20589. // FieldCleared returns a boolean indicating if a field with the given name was
  20590. // cleared in this mutation.
  20591. func (m *ServerMutation) FieldCleared(name string) bool {
  20592. _, ok := m.clearedFields[name]
  20593. return ok
  20594. }
  20595. // ClearField clears the value of the field with the given name. It returns an
  20596. // error if the field is not defined in the schema.
  20597. func (m *ServerMutation) ClearField(name string) error {
  20598. switch name {
  20599. case server.FieldStatus:
  20600. m.ClearStatus()
  20601. return nil
  20602. case server.FieldDeletedAt:
  20603. m.ClearDeletedAt()
  20604. return nil
  20605. }
  20606. return fmt.Errorf("unknown Server nullable field %s", name)
  20607. }
  20608. // ResetField resets all changes in the mutation for the field with the given name.
  20609. // It returns an error if the field is not defined in the schema.
  20610. func (m *ServerMutation) ResetField(name string) error {
  20611. switch name {
  20612. case server.FieldCreatedAt:
  20613. m.ResetCreatedAt()
  20614. return nil
  20615. case server.FieldUpdatedAt:
  20616. m.ResetUpdatedAt()
  20617. return nil
  20618. case server.FieldStatus:
  20619. m.ResetStatus()
  20620. return nil
  20621. case server.FieldDeletedAt:
  20622. m.ResetDeletedAt()
  20623. return nil
  20624. case server.FieldName:
  20625. m.ResetName()
  20626. return nil
  20627. case server.FieldPublicIP:
  20628. m.ResetPublicIP()
  20629. return nil
  20630. case server.FieldPrivateIP:
  20631. m.ResetPrivateIP()
  20632. return nil
  20633. case server.FieldAdminPort:
  20634. m.ResetAdminPort()
  20635. return nil
  20636. }
  20637. return fmt.Errorf("unknown Server field %s", name)
  20638. }
  20639. // AddedEdges returns all edge names that were set/added in this mutation.
  20640. func (m *ServerMutation) AddedEdges() []string {
  20641. edges := make([]string, 0, 1)
  20642. if m.wxs != nil {
  20643. edges = append(edges, server.EdgeWxs)
  20644. }
  20645. return edges
  20646. }
  20647. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20648. // name in this mutation.
  20649. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20650. switch name {
  20651. case server.EdgeWxs:
  20652. ids := make([]ent.Value, 0, len(m.wxs))
  20653. for id := range m.wxs {
  20654. ids = append(ids, id)
  20655. }
  20656. return ids
  20657. }
  20658. return nil
  20659. }
  20660. // RemovedEdges returns all edge names that were removed in this mutation.
  20661. func (m *ServerMutation) RemovedEdges() []string {
  20662. edges := make([]string, 0, 1)
  20663. if m.removedwxs != nil {
  20664. edges = append(edges, server.EdgeWxs)
  20665. }
  20666. return edges
  20667. }
  20668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20669. // the given name in this mutation.
  20670. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20671. switch name {
  20672. case server.EdgeWxs:
  20673. ids := make([]ent.Value, 0, len(m.removedwxs))
  20674. for id := range m.removedwxs {
  20675. ids = append(ids, id)
  20676. }
  20677. return ids
  20678. }
  20679. return nil
  20680. }
  20681. // ClearedEdges returns all edge names that were cleared in this mutation.
  20682. func (m *ServerMutation) ClearedEdges() []string {
  20683. edges := make([]string, 0, 1)
  20684. if m.clearedwxs {
  20685. edges = append(edges, server.EdgeWxs)
  20686. }
  20687. return edges
  20688. }
  20689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20690. // was cleared in this mutation.
  20691. func (m *ServerMutation) EdgeCleared(name string) bool {
  20692. switch name {
  20693. case server.EdgeWxs:
  20694. return m.clearedwxs
  20695. }
  20696. return false
  20697. }
  20698. // ClearEdge clears the value of the edge with the given name. It returns an error
  20699. // if that edge is not defined in the schema.
  20700. func (m *ServerMutation) ClearEdge(name string) error {
  20701. switch name {
  20702. }
  20703. return fmt.Errorf("unknown Server unique edge %s", name)
  20704. }
  20705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20706. // It returns an error if the edge is not defined in the schema.
  20707. func (m *ServerMutation) ResetEdge(name string) error {
  20708. switch name {
  20709. case server.EdgeWxs:
  20710. m.ResetWxs()
  20711. return nil
  20712. }
  20713. return fmt.Errorf("unknown Server edge %s", name)
  20714. }
  20715. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20716. type SopNodeMutation struct {
  20717. config
  20718. op Op
  20719. typ string
  20720. id *uint64
  20721. created_at *time.Time
  20722. updated_at *time.Time
  20723. status *uint8
  20724. addstatus *int8
  20725. deleted_at *time.Time
  20726. parent_id *uint64
  20727. addparent_id *int64
  20728. name *string
  20729. condition_type *int
  20730. addcondition_type *int
  20731. condition_list *[]string
  20732. appendcondition_list []string
  20733. no_reply_condition *uint64
  20734. addno_reply_condition *int64
  20735. no_reply_unit *string
  20736. action_message *[]custom_types.Action
  20737. appendaction_message []custom_types.Action
  20738. action_label_add *[]uint64
  20739. appendaction_label_add []uint64
  20740. action_label_del *[]uint64
  20741. appendaction_label_del []uint64
  20742. action_forward **custom_types.ActionForward
  20743. clearedFields map[string]struct{}
  20744. sop_stage *uint64
  20745. clearedsop_stage bool
  20746. node_messages map[uint64]struct{}
  20747. removednode_messages map[uint64]struct{}
  20748. clearednode_messages bool
  20749. done bool
  20750. oldValue func(context.Context) (*SopNode, error)
  20751. predicates []predicate.SopNode
  20752. }
  20753. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20754. // sopnodeOption allows management of the mutation configuration using functional options.
  20755. type sopnodeOption func(*SopNodeMutation)
  20756. // newSopNodeMutation creates new mutation for the SopNode entity.
  20757. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20758. m := &SopNodeMutation{
  20759. config: c,
  20760. op: op,
  20761. typ: TypeSopNode,
  20762. clearedFields: make(map[string]struct{}),
  20763. }
  20764. for _, opt := range opts {
  20765. opt(m)
  20766. }
  20767. return m
  20768. }
  20769. // withSopNodeID sets the ID field of the mutation.
  20770. func withSopNodeID(id uint64) sopnodeOption {
  20771. return func(m *SopNodeMutation) {
  20772. var (
  20773. err error
  20774. once sync.Once
  20775. value *SopNode
  20776. )
  20777. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20778. once.Do(func() {
  20779. if m.done {
  20780. err = errors.New("querying old values post mutation is not allowed")
  20781. } else {
  20782. value, err = m.Client().SopNode.Get(ctx, id)
  20783. }
  20784. })
  20785. return value, err
  20786. }
  20787. m.id = &id
  20788. }
  20789. }
  20790. // withSopNode sets the old SopNode of the mutation.
  20791. func withSopNode(node *SopNode) sopnodeOption {
  20792. return func(m *SopNodeMutation) {
  20793. m.oldValue = func(context.Context) (*SopNode, error) {
  20794. return node, nil
  20795. }
  20796. m.id = &node.ID
  20797. }
  20798. }
  20799. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20800. // executed in a transaction (ent.Tx), a transactional client is returned.
  20801. func (m SopNodeMutation) Client() *Client {
  20802. client := &Client{config: m.config}
  20803. client.init()
  20804. return client
  20805. }
  20806. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20807. // it returns an error otherwise.
  20808. func (m SopNodeMutation) Tx() (*Tx, error) {
  20809. if _, ok := m.driver.(*txDriver); !ok {
  20810. return nil, errors.New("ent: mutation is not running in a transaction")
  20811. }
  20812. tx := &Tx{config: m.config}
  20813. tx.init()
  20814. return tx, nil
  20815. }
  20816. // SetID sets the value of the id field. Note that this
  20817. // operation is only accepted on creation of SopNode entities.
  20818. func (m *SopNodeMutation) SetID(id uint64) {
  20819. m.id = &id
  20820. }
  20821. // ID returns the ID value in the mutation. Note that the ID is only available
  20822. // if it was provided to the builder or after it was returned from the database.
  20823. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20824. if m.id == nil {
  20825. return
  20826. }
  20827. return *m.id, true
  20828. }
  20829. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20830. // That means, if the mutation is applied within a transaction with an isolation level such
  20831. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20832. // or updated by the mutation.
  20833. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20834. switch {
  20835. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20836. id, exists := m.ID()
  20837. if exists {
  20838. return []uint64{id}, nil
  20839. }
  20840. fallthrough
  20841. case m.op.Is(OpUpdate | OpDelete):
  20842. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20843. default:
  20844. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20845. }
  20846. }
  20847. // SetCreatedAt sets the "created_at" field.
  20848. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20849. m.created_at = &t
  20850. }
  20851. // CreatedAt returns the value of the "created_at" field in the mutation.
  20852. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20853. v := m.created_at
  20854. if v == nil {
  20855. return
  20856. }
  20857. return *v, true
  20858. }
  20859. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20860. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20862. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20863. if !m.op.Is(OpUpdateOne) {
  20864. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20865. }
  20866. if m.id == nil || m.oldValue == nil {
  20867. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20868. }
  20869. oldValue, err := m.oldValue(ctx)
  20870. if err != nil {
  20871. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20872. }
  20873. return oldValue.CreatedAt, nil
  20874. }
  20875. // ResetCreatedAt resets all changes to the "created_at" field.
  20876. func (m *SopNodeMutation) ResetCreatedAt() {
  20877. m.created_at = nil
  20878. }
  20879. // SetUpdatedAt sets the "updated_at" field.
  20880. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20881. m.updated_at = &t
  20882. }
  20883. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20884. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20885. v := m.updated_at
  20886. if v == nil {
  20887. return
  20888. }
  20889. return *v, true
  20890. }
  20891. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20892. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20894. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20895. if !m.op.Is(OpUpdateOne) {
  20896. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20897. }
  20898. if m.id == nil || m.oldValue == nil {
  20899. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20900. }
  20901. oldValue, err := m.oldValue(ctx)
  20902. if err != nil {
  20903. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20904. }
  20905. return oldValue.UpdatedAt, nil
  20906. }
  20907. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20908. func (m *SopNodeMutation) ResetUpdatedAt() {
  20909. m.updated_at = nil
  20910. }
  20911. // SetStatus sets the "status" field.
  20912. func (m *SopNodeMutation) SetStatus(u uint8) {
  20913. m.status = &u
  20914. m.addstatus = nil
  20915. }
  20916. // Status returns the value of the "status" field in the mutation.
  20917. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20918. v := m.status
  20919. if v == nil {
  20920. return
  20921. }
  20922. return *v, true
  20923. }
  20924. // OldStatus returns the old "status" field's value of the SopNode entity.
  20925. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20927. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20928. if !m.op.Is(OpUpdateOne) {
  20929. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20930. }
  20931. if m.id == nil || m.oldValue == nil {
  20932. return v, errors.New("OldStatus requires an ID field in the mutation")
  20933. }
  20934. oldValue, err := m.oldValue(ctx)
  20935. if err != nil {
  20936. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20937. }
  20938. return oldValue.Status, nil
  20939. }
  20940. // AddStatus adds u to the "status" field.
  20941. func (m *SopNodeMutation) AddStatus(u int8) {
  20942. if m.addstatus != nil {
  20943. *m.addstatus += u
  20944. } else {
  20945. m.addstatus = &u
  20946. }
  20947. }
  20948. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20949. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20950. v := m.addstatus
  20951. if v == nil {
  20952. return
  20953. }
  20954. return *v, true
  20955. }
  20956. // ClearStatus clears the value of the "status" field.
  20957. func (m *SopNodeMutation) ClearStatus() {
  20958. m.status = nil
  20959. m.addstatus = nil
  20960. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20961. }
  20962. // StatusCleared returns if the "status" field was cleared in this mutation.
  20963. func (m *SopNodeMutation) StatusCleared() bool {
  20964. _, ok := m.clearedFields[sopnode.FieldStatus]
  20965. return ok
  20966. }
  20967. // ResetStatus resets all changes to the "status" field.
  20968. func (m *SopNodeMutation) ResetStatus() {
  20969. m.status = nil
  20970. m.addstatus = nil
  20971. delete(m.clearedFields, sopnode.FieldStatus)
  20972. }
  20973. // SetDeletedAt sets the "deleted_at" field.
  20974. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20975. m.deleted_at = &t
  20976. }
  20977. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20978. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20979. v := m.deleted_at
  20980. if v == nil {
  20981. return
  20982. }
  20983. return *v, true
  20984. }
  20985. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20986. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20988. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20989. if !m.op.Is(OpUpdateOne) {
  20990. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20991. }
  20992. if m.id == nil || m.oldValue == nil {
  20993. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20994. }
  20995. oldValue, err := m.oldValue(ctx)
  20996. if err != nil {
  20997. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20998. }
  20999. return oldValue.DeletedAt, nil
  21000. }
  21001. // ClearDeletedAt clears the value of the "deleted_at" field.
  21002. func (m *SopNodeMutation) ClearDeletedAt() {
  21003. m.deleted_at = nil
  21004. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21005. }
  21006. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21007. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21008. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21009. return ok
  21010. }
  21011. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21012. func (m *SopNodeMutation) ResetDeletedAt() {
  21013. m.deleted_at = nil
  21014. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21015. }
  21016. // SetStageID sets the "stage_id" field.
  21017. func (m *SopNodeMutation) SetStageID(u uint64) {
  21018. m.sop_stage = &u
  21019. }
  21020. // StageID returns the value of the "stage_id" field in the mutation.
  21021. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21022. v := m.sop_stage
  21023. if v == nil {
  21024. return
  21025. }
  21026. return *v, true
  21027. }
  21028. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21029. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21031. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21032. if !m.op.Is(OpUpdateOne) {
  21033. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21034. }
  21035. if m.id == nil || m.oldValue == nil {
  21036. return v, errors.New("OldStageID requires an ID field in the mutation")
  21037. }
  21038. oldValue, err := m.oldValue(ctx)
  21039. if err != nil {
  21040. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21041. }
  21042. return oldValue.StageID, nil
  21043. }
  21044. // ResetStageID resets all changes to the "stage_id" field.
  21045. func (m *SopNodeMutation) ResetStageID() {
  21046. m.sop_stage = nil
  21047. }
  21048. // SetParentID sets the "parent_id" field.
  21049. func (m *SopNodeMutation) SetParentID(u uint64) {
  21050. m.parent_id = &u
  21051. m.addparent_id = nil
  21052. }
  21053. // ParentID returns the value of the "parent_id" field in the mutation.
  21054. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21055. v := m.parent_id
  21056. if v == nil {
  21057. return
  21058. }
  21059. return *v, true
  21060. }
  21061. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21062. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21064. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21065. if !m.op.Is(OpUpdateOne) {
  21066. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21067. }
  21068. if m.id == nil || m.oldValue == nil {
  21069. return v, errors.New("OldParentID requires an ID field in the mutation")
  21070. }
  21071. oldValue, err := m.oldValue(ctx)
  21072. if err != nil {
  21073. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21074. }
  21075. return oldValue.ParentID, nil
  21076. }
  21077. // AddParentID adds u to the "parent_id" field.
  21078. func (m *SopNodeMutation) AddParentID(u int64) {
  21079. if m.addparent_id != nil {
  21080. *m.addparent_id += u
  21081. } else {
  21082. m.addparent_id = &u
  21083. }
  21084. }
  21085. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21086. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21087. v := m.addparent_id
  21088. if v == nil {
  21089. return
  21090. }
  21091. return *v, true
  21092. }
  21093. // ResetParentID resets all changes to the "parent_id" field.
  21094. func (m *SopNodeMutation) ResetParentID() {
  21095. m.parent_id = nil
  21096. m.addparent_id = nil
  21097. }
  21098. // SetName sets the "name" field.
  21099. func (m *SopNodeMutation) SetName(s string) {
  21100. m.name = &s
  21101. }
  21102. // Name returns the value of the "name" field in the mutation.
  21103. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21104. v := m.name
  21105. if v == nil {
  21106. return
  21107. }
  21108. return *v, true
  21109. }
  21110. // OldName returns the old "name" field's value of the SopNode entity.
  21111. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21113. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21114. if !m.op.Is(OpUpdateOne) {
  21115. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21116. }
  21117. if m.id == nil || m.oldValue == nil {
  21118. return v, errors.New("OldName requires an ID field in the mutation")
  21119. }
  21120. oldValue, err := m.oldValue(ctx)
  21121. if err != nil {
  21122. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21123. }
  21124. return oldValue.Name, nil
  21125. }
  21126. // ResetName resets all changes to the "name" field.
  21127. func (m *SopNodeMutation) ResetName() {
  21128. m.name = nil
  21129. }
  21130. // SetConditionType sets the "condition_type" field.
  21131. func (m *SopNodeMutation) SetConditionType(i int) {
  21132. m.condition_type = &i
  21133. m.addcondition_type = nil
  21134. }
  21135. // ConditionType returns the value of the "condition_type" field in the mutation.
  21136. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21137. v := m.condition_type
  21138. if v == nil {
  21139. return
  21140. }
  21141. return *v, true
  21142. }
  21143. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21144. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21146. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21147. if !m.op.Is(OpUpdateOne) {
  21148. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21149. }
  21150. if m.id == nil || m.oldValue == nil {
  21151. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21152. }
  21153. oldValue, err := m.oldValue(ctx)
  21154. if err != nil {
  21155. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21156. }
  21157. return oldValue.ConditionType, nil
  21158. }
  21159. // AddConditionType adds i to the "condition_type" field.
  21160. func (m *SopNodeMutation) AddConditionType(i int) {
  21161. if m.addcondition_type != nil {
  21162. *m.addcondition_type += i
  21163. } else {
  21164. m.addcondition_type = &i
  21165. }
  21166. }
  21167. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21168. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21169. v := m.addcondition_type
  21170. if v == nil {
  21171. return
  21172. }
  21173. return *v, true
  21174. }
  21175. // ResetConditionType resets all changes to the "condition_type" field.
  21176. func (m *SopNodeMutation) ResetConditionType() {
  21177. m.condition_type = nil
  21178. m.addcondition_type = nil
  21179. }
  21180. // SetConditionList sets the "condition_list" field.
  21181. func (m *SopNodeMutation) SetConditionList(s []string) {
  21182. m.condition_list = &s
  21183. m.appendcondition_list = nil
  21184. }
  21185. // ConditionList returns the value of the "condition_list" field in the mutation.
  21186. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21187. v := m.condition_list
  21188. if v == nil {
  21189. return
  21190. }
  21191. return *v, true
  21192. }
  21193. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21194. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21196. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21197. if !m.op.Is(OpUpdateOne) {
  21198. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21199. }
  21200. if m.id == nil || m.oldValue == nil {
  21201. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21202. }
  21203. oldValue, err := m.oldValue(ctx)
  21204. if err != nil {
  21205. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21206. }
  21207. return oldValue.ConditionList, nil
  21208. }
  21209. // AppendConditionList adds s to the "condition_list" field.
  21210. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21211. m.appendcondition_list = append(m.appendcondition_list, s...)
  21212. }
  21213. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21214. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21215. if len(m.appendcondition_list) == 0 {
  21216. return nil, false
  21217. }
  21218. return m.appendcondition_list, true
  21219. }
  21220. // ClearConditionList clears the value of the "condition_list" field.
  21221. func (m *SopNodeMutation) ClearConditionList() {
  21222. m.condition_list = nil
  21223. m.appendcondition_list = nil
  21224. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21225. }
  21226. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21227. func (m *SopNodeMutation) ConditionListCleared() bool {
  21228. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21229. return ok
  21230. }
  21231. // ResetConditionList resets all changes to the "condition_list" field.
  21232. func (m *SopNodeMutation) ResetConditionList() {
  21233. m.condition_list = nil
  21234. m.appendcondition_list = nil
  21235. delete(m.clearedFields, sopnode.FieldConditionList)
  21236. }
  21237. // SetNoReplyCondition sets the "no_reply_condition" field.
  21238. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21239. m.no_reply_condition = &u
  21240. m.addno_reply_condition = nil
  21241. }
  21242. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21243. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21244. v := m.no_reply_condition
  21245. if v == nil {
  21246. return
  21247. }
  21248. return *v, true
  21249. }
  21250. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21251. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21253. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21254. if !m.op.Is(OpUpdateOne) {
  21255. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21256. }
  21257. if m.id == nil || m.oldValue == nil {
  21258. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21259. }
  21260. oldValue, err := m.oldValue(ctx)
  21261. if err != nil {
  21262. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21263. }
  21264. return oldValue.NoReplyCondition, nil
  21265. }
  21266. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21267. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21268. if m.addno_reply_condition != nil {
  21269. *m.addno_reply_condition += u
  21270. } else {
  21271. m.addno_reply_condition = &u
  21272. }
  21273. }
  21274. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21275. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21276. v := m.addno_reply_condition
  21277. if v == nil {
  21278. return
  21279. }
  21280. return *v, true
  21281. }
  21282. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21283. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21284. m.no_reply_condition = nil
  21285. m.addno_reply_condition = nil
  21286. }
  21287. // SetNoReplyUnit sets the "no_reply_unit" field.
  21288. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21289. m.no_reply_unit = &s
  21290. }
  21291. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21292. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21293. v := m.no_reply_unit
  21294. if v == nil {
  21295. return
  21296. }
  21297. return *v, true
  21298. }
  21299. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21300. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21302. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21303. if !m.op.Is(OpUpdateOne) {
  21304. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21305. }
  21306. if m.id == nil || m.oldValue == nil {
  21307. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21308. }
  21309. oldValue, err := m.oldValue(ctx)
  21310. if err != nil {
  21311. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21312. }
  21313. return oldValue.NoReplyUnit, nil
  21314. }
  21315. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21316. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21317. m.no_reply_unit = nil
  21318. }
  21319. // SetActionMessage sets the "action_message" field.
  21320. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21321. m.action_message = &ct
  21322. m.appendaction_message = nil
  21323. }
  21324. // ActionMessage returns the value of the "action_message" field in the mutation.
  21325. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21326. v := m.action_message
  21327. if v == nil {
  21328. return
  21329. }
  21330. return *v, true
  21331. }
  21332. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21333. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21335. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21336. if !m.op.Is(OpUpdateOne) {
  21337. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21338. }
  21339. if m.id == nil || m.oldValue == nil {
  21340. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21341. }
  21342. oldValue, err := m.oldValue(ctx)
  21343. if err != nil {
  21344. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21345. }
  21346. return oldValue.ActionMessage, nil
  21347. }
  21348. // AppendActionMessage adds ct to the "action_message" field.
  21349. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21350. m.appendaction_message = append(m.appendaction_message, ct...)
  21351. }
  21352. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21353. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21354. if len(m.appendaction_message) == 0 {
  21355. return nil, false
  21356. }
  21357. return m.appendaction_message, true
  21358. }
  21359. // ClearActionMessage clears the value of the "action_message" field.
  21360. func (m *SopNodeMutation) ClearActionMessage() {
  21361. m.action_message = nil
  21362. m.appendaction_message = nil
  21363. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21364. }
  21365. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21366. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21367. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21368. return ok
  21369. }
  21370. // ResetActionMessage resets all changes to the "action_message" field.
  21371. func (m *SopNodeMutation) ResetActionMessage() {
  21372. m.action_message = nil
  21373. m.appendaction_message = nil
  21374. delete(m.clearedFields, sopnode.FieldActionMessage)
  21375. }
  21376. // SetActionLabelAdd sets the "action_label_add" field.
  21377. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21378. m.action_label_add = &u
  21379. m.appendaction_label_add = nil
  21380. }
  21381. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21382. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21383. v := m.action_label_add
  21384. if v == nil {
  21385. return
  21386. }
  21387. return *v, true
  21388. }
  21389. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21390. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21392. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21393. if !m.op.Is(OpUpdateOne) {
  21394. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21395. }
  21396. if m.id == nil || m.oldValue == nil {
  21397. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21398. }
  21399. oldValue, err := m.oldValue(ctx)
  21400. if err != nil {
  21401. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21402. }
  21403. return oldValue.ActionLabelAdd, nil
  21404. }
  21405. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21406. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21407. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21408. }
  21409. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21410. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21411. if len(m.appendaction_label_add) == 0 {
  21412. return nil, false
  21413. }
  21414. return m.appendaction_label_add, true
  21415. }
  21416. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21417. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21418. m.action_label_add = nil
  21419. m.appendaction_label_add = nil
  21420. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21421. }
  21422. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21423. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21424. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21425. return ok
  21426. }
  21427. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21428. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21429. m.action_label_add = nil
  21430. m.appendaction_label_add = nil
  21431. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21432. }
  21433. // SetActionLabelDel sets the "action_label_del" field.
  21434. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21435. m.action_label_del = &u
  21436. m.appendaction_label_del = nil
  21437. }
  21438. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21439. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21440. v := m.action_label_del
  21441. if v == nil {
  21442. return
  21443. }
  21444. return *v, true
  21445. }
  21446. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21447. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21449. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21450. if !m.op.Is(OpUpdateOne) {
  21451. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21452. }
  21453. if m.id == nil || m.oldValue == nil {
  21454. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21455. }
  21456. oldValue, err := m.oldValue(ctx)
  21457. if err != nil {
  21458. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21459. }
  21460. return oldValue.ActionLabelDel, nil
  21461. }
  21462. // AppendActionLabelDel adds u to the "action_label_del" field.
  21463. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21464. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21465. }
  21466. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21467. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21468. if len(m.appendaction_label_del) == 0 {
  21469. return nil, false
  21470. }
  21471. return m.appendaction_label_del, true
  21472. }
  21473. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21474. func (m *SopNodeMutation) ClearActionLabelDel() {
  21475. m.action_label_del = nil
  21476. m.appendaction_label_del = nil
  21477. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21478. }
  21479. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21480. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21481. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21482. return ok
  21483. }
  21484. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21485. func (m *SopNodeMutation) ResetActionLabelDel() {
  21486. m.action_label_del = nil
  21487. m.appendaction_label_del = nil
  21488. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21489. }
  21490. // SetActionForward sets the "action_forward" field.
  21491. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21492. m.action_forward = &ctf
  21493. }
  21494. // ActionForward returns the value of the "action_forward" field in the mutation.
  21495. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21496. v := m.action_forward
  21497. if v == nil {
  21498. return
  21499. }
  21500. return *v, true
  21501. }
  21502. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21503. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21505. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21506. if !m.op.Is(OpUpdateOne) {
  21507. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21508. }
  21509. if m.id == nil || m.oldValue == nil {
  21510. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21511. }
  21512. oldValue, err := m.oldValue(ctx)
  21513. if err != nil {
  21514. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21515. }
  21516. return oldValue.ActionForward, nil
  21517. }
  21518. // ClearActionForward clears the value of the "action_forward" field.
  21519. func (m *SopNodeMutation) ClearActionForward() {
  21520. m.action_forward = nil
  21521. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21522. }
  21523. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21524. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21525. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21526. return ok
  21527. }
  21528. // ResetActionForward resets all changes to the "action_forward" field.
  21529. func (m *SopNodeMutation) ResetActionForward() {
  21530. m.action_forward = nil
  21531. delete(m.clearedFields, sopnode.FieldActionForward)
  21532. }
  21533. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21534. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21535. m.sop_stage = &id
  21536. }
  21537. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21538. func (m *SopNodeMutation) ClearSopStage() {
  21539. m.clearedsop_stage = true
  21540. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21541. }
  21542. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21543. func (m *SopNodeMutation) SopStageCleared() bool {
  21544. return m.clearedsop_stage
  21545. }
  21546. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21547. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21548. if m.sop_stage != nil {
  21549. return *m.sop_stage, true
  21550. }
  21551. return
  21552. }
  21553. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21554. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21555. // SopStageID instead. It exists only for internal usage by the builders.
  21556. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21557. if id := m.sop_stage; id != nil {
  21558. ids = append(ids, *id)
  21559. }
  21560. return
  21561. }
  21562. // ResetSopStage resets all changes to the "sop_stage" edge.
  21563. func (m *SopNodeMutation) ResetSopStage() {
  21564. m.sop_stage = nil
  21565. m.clearedsop_stage = false
  21566. }
  21567. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21568. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21569. if m.node_messages == nil {
  21570. m.node_messages = make(map[uint64]struct{})
  21571. }
  21572. for i := range ids {
  21573. m.node_messages[ids[i]] = struct{}{}
  21574. }
  21575. }
  21576. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21577. func (m *SopNodeMutation) ClearNodeMessages() {
  21578. m.clearednode_messages = true
  21579. }
  21580. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21581. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21582. return m.clearednode_messages
  21583. }
  21584. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21585. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21586. if m.removednode_messages == nil {
  21587. m.removednode_messages = make(map[uint64]struct{})
  21588. }
  21589. for i := range ids {
  21590. delete(m.node_messages, ids[i])
  21591. m.removednode_messages[ids[i]] = struct{}{}
  21592. }
  21593. }
  21594. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21595. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21596. for id := range m.removednode_messages {
  21597. ids = append(ids, id)
  21598. }
  21599. return
  21600. }
  21601. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21602. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21603. for id := range m.node_messages {
  21604. ids = append(ids, id)
  21605. }
  21606. return
  21607. }
  21608. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21609. func (m *SopNodeMutation) ResetNodeMessages() {
  21610. m.node_messages = nil
  21611. m.clearednode_messages = false
  21612. m.removednode_messages = nil
  21613. }
  21614. // Where appends a list predicates to the SopNodeMutation builder.
  21615. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21616. m.predicates = append(m.predicates, ps...)
  21617. }
  21618. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21619. // users can use type-assertion to append predicates that do not depend on any generated package.
  21620. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21621. p := make([]predicate.SopNode, len(ps))
  21622. for i := range ps {
  21623. p[i] = ps[i]
  21624. }
  21625. m.Where(p...)
  21626. }
  21627. // Op returns the operation name.
  21628. func (m *SopNodeMutation) Op() Op {
  21629. return m.op
  21630. }
  21631. // SetOp allows setting the mutation operation.
  21632. func (m *SopNodeMutation) SetOp(op Op) {
  21633. m.op = op
  21634. }
  21635. // Type returns the node type of this mutation (SopNode).
  21636. func (m *SopNodeMutation) Type() string {
  21637. return m.typ
  21638. }
  21639. // Fields returns all fields that were changed during this mutation. Note that in
  21640. // order to get all numeric fields that were incremented/decremented, call
  21641. // AddedFields().
  21642. func (m *SopNodeMutation) Fields() []string {
  21643. fields := make([]string, 0, 15)
  21644. if m.created_at != nil {
  21645. fields = append(fields, sopnode.FieldCreatedAt)
  21646. }
  21647. if m.updated_at != nil {
  21648. fields = append(fields, sopnode.FieldUpdatedAt)
  21649. }
  21650. if m.status != nil {
  21651. fields = append(fields, sopnode.FieldStatus)
  21652. }
  21653. if m.deleted_at != nil {
  21654. fields = append(fields, sopnode.FieldDeletedAt)
  21655. }
  21656. if m.sop_stage != nil {
  21657. fields = append(fields, sopnode.FieldStageID)
  21658. }
  21659. if m.parent_id != nil {
  21660. fields = append(fields, sopnode.FieldParentID)
  21661. }
  21662. if m.name != nil {
  21663. fields = append(fields, sopnode.FieldName)
  21664. }
  21665. if m.condition_type != nil {
  21666. fields = append(fields, sopnode.FieldConditionType)
  21667. }
  21668. if m.condition_list != nil {
  21669. fields = append(fields, sopnode.FieldConditionList)
  21670. }
  21671. if m.no_reply_condition != nil {
  21672. fields = append(fields, sopnode.FieldNoReplyCondition)
  21673. }
  21674. if m.no_reply_unit != nil {
  21675. fields = append(fields, sopnode.FieldNoReplyUnit)
  21676. }
  21677. if m.action_message != nil {
  21678. fields = append(fields, sopnode.FieldActionMessage)
  21679. }
  21680. if m.action_label_add != nil {
  21681. fields = append(fields, sopnode.FieldActionLabelAdd)
  21682. }
  21683. if m.action_label_del != nil {
  21684. fields = append(fields, sopnode.FieldActionLabelDel)
  21685. }
  21686. if m.action_forward != nil {
  21687. fields = append(fields, sopnode.FieldActionForward)
  21688. }
  21689. return fields
  21690. }
  21691. // Field returns the value of a field with the given name. The second boolean
  21692. // return value indicates that this field was not set, or was not defined in the
  21693. // schema.
  21694. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21695. switch name {
  21696. case sopnode.FieldCreatedAt:
  21697. return m.CreatedAt()
  21698. case sopnode.FieldUpdatedAt:
  21699. return m.UpdatedAt()
  21700. case sopnode.FieldStatus:
  21701. return m.Status()
  21702. case sopnode.FieldDeletedAt:
  21703. return m.DeletedAt()
  21704. case sopnode.FieldStageID:
  21705. return m.StageID()
  21706. case sopnode.FieldParentID:
  21707. return m.ParentID()
  21708. case sopnode.FieldName:
  21709. return m.Name()
  21710. case sopnode.FieldConditionType:
  21711. return m.ConditionType()
  21712. case sopnode.FieldConditionList:
  21713. return m.ConditionList()
  21714. case sopnode.FieldNoReplyCondition:
  21715. return m.NoReplyCondition()
  21716. case sopnode.FieldNoReplyUnit:
  21717. return m.NoReplyUnit()
  21718. case sopnode.FieldActionMessage:
  21719. return m.ActionMessage()
  21720. case sopnode.FieldActionLabelAdd:
  21721. return m.ActionLabelAdd()
  21722. case sopnode.FieldActionLabelDel:
  21723. return m.ActionLabelDel()
  21724. case sopnode.FieldActionForward:
  21725. return m.ActionForward()
  21726. }
  21727. return nil, false
  21728. }
  21729. // OldField returns the old value of the field from the database. An error is
  21730. // returned if the mutation operation is not UpdateOne, or the query to the
  21731. // database failed.
  21732. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21733. switch name {
  21734. case sopnode.FieldCreatedAt:
  21735. return m.OldCreatedAt(ctx)
  21736. case sopnode.FieldUpdatedAt:
  21737. return m.OldUpdatedAt(ctx)
  21738. case sopnode.FieldStatus:
  21739. return m.OldStatus(ctx)
  21740. case sopnode.FieldDeletedAt:
  21741. return m.OldDeletedAt(ctx)
  21742. case sopnode.FieldStageID:
  21743. return m.OldStageID(ctx)
  21744. case sopnode.FieldParentID:
  21745. return m.OldParentID(ctx)
  21746. case sopnode.FieldName:
  21747. return m.OldName(ctx)
  21748. case sopnode.FieldConditionType:
  21749. return m.OldConditionType(ctx)
  21750. case sopnode.FieldConditionList:
  21751. return m.OldConditionList(ctx)
  21752. case sopnode.FieldNoReplyCondition:
  21753. return m.OldNoReplyCondition(ctx)
  21754. case sopnode.FieldNoReplyUnit:
  21755. return m.OldNoReplyUnit(ctx)
  21756. case sopnode.FieldActionMessage:
  21757. return m.OldActionMessage(ctx)
  21758. case sopnode.FieldActionLabelAdd:
  21759. return m.OldActionLabelAdd(ctx)
  21760. case sopnode.FieldActionLabelDel:
  21761. return m.OldActionLabelDel(ctx)
  21762. case sopnode.FieldActionForward:
  21763. return m.OldActionForward(ctx)
  21764. }
  21765. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21766. }
  21767. // SetField sets the value of a field with the given name. It returns an error if
  21768. // the field is not defined in the schema, or if the type mismatched the field
  21769. // type.
  21770. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21771. switch name {
  21772. case sopnode.FieldCreatedAt:
  21773. v, ok := value.(time.Time)
  21774. if !ok {
  21775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21776. }
  21777. m.SetCreatedAt(v)
  21778. return nil
  21779. case sopnode.FieldUpdatedAt:
  21780. v, ok := value.(time.Time)
  21781. if !ok {
  21782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21783. }
  21784. m.SetUpdatedAt(v)
  21785. return nil
  21786. case sopnode.FieldStatus:
  21787. v, ok := value.(uint8)
  21788. if !ok {
  21789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21790. }
  21791. m.SetStatus(v)
  21792. return nil
  21793. case sopnode.FieldDeletedAt:
  21794. v, ok := value.(time.Time)
  21795. if !ok {
  21796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21797. }
  21798. m.SetDeletedAt(v)
  21799. return nil
  21800. case sopnode.FieldStageID:
  21801. v, ok := value.(uint64)
  21802. if !ok {
  21803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21804. }
  21805. m.SetStageID(v)
  21806. return nil
  21807. case sopnode.FieldParentID:
  21808. v, ok := value.(uint64)
  21809. if !ok {
  21810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21811. }
  21812. m.SetParentID(v)
  21813. return nil
  21814. case sopnode.FieldName:
  21815. v, ok := value.(string)
  21816. if !ok {
  21817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21818. }
  21819. m.SetName(v)
  21820. return nil
  21821. case sopnode.FieldConditionType:
  21822. v, ok := value.(int)
  21823. if !ok {
  21824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21825. }
  21826. m.SetConditionType(v)
  21827. return nil
  21828. case sopnode.FieldConditionList:
  21829. v, ok := value.([]string)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.SetConditionList(v)
  21834. return nil
  21835. case sopnode.FieldNoReplyCondition:
  21836. v, ok := value.(uint64)
  21837. if !ok {
  21838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21839. }
  21840. m.SetNoReplyCondition(v)
  21841. return nil
  21842. case sopnode.FieldNoReplyUnit:
  21843. v, ok := value.(string)
  21844. if !ok {
  21845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21846. }
  21847. m.SetNoReplyUnit(v)
  21848. return nil
  21849. case sopnode.FieldActionMessage:
  21850. v, ok := value.([]custom_types.Action)
  21851. if !ok {
  21852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21853. }
  21854. m.SetActionMessage(v)
  21855. return nil
  21856. case sopnode.FieldActionLabelAdd:
  21857. v, ok := value.([]uint64)
  21858. if !ok {
  21859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21860. }
  21861. m.SetActionLabelAdd(v)
  21862. return nil
  21863. case sopnode.FieldActionLabelDel:
  21864. v, ok := value.([]uint64)
  21865. if !ok {
  21866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21867. }
  21868. m.SetActionLabelDel(v)
  21869. return nil
  21870. case sopnode.FieldActionForward:
  21871. v, ok := value.(*custom_types.ActionForward)
  21872. if !ok {
  21873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21874. }
  21875. m.SetActionForward(v)
  21876. return nil
  21877. }
  21878. return fmt.Errorf("unknown SopNode field %s", name)
  21879. }
  21880. // AddedFields returns all numeric fields that were incremented/decremented during
  21881. // this mutation.
  21882. func (m *SopNodeMutation) AddedFields() []string {
  21883. var fields []string
  21884. if m.addstatus != nil {
  21885. fields = append(fields, sopnode.FieldStatus)
  21886. }
  21887. if m.addparent_id != nil {
  21888. fields = append(fields, sopnode.FieldParentID)
  21889. }
  21890. if m.addcondition_type != nil {
  21891. fields = append(fields, sopnode.FieldConditionType)
  21892. }
  21893. if m.addno_reply_condition != nil {
  21894. fields = append(fields, sopnode.FieldNoReplyCondition)
  21895. }
  21896. return fields
  21897. }
  21898. // AddedField returns the numeric value that was incremented/decremented on a field
  21899. // with the given name. The second boolean return value indicates that this field
  21900. // was not set, or was not defined in the schema.
  21901. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21902. switch name {
  21903. case sopnode.FieldStatus:
  21904. return m.AddedStatus()
  21905. case sopnode.FieldParentID:
  21906. return m.AddedParentID()
  21907. case sopnode.FieldConditionType:
  21908. return m.AddedConditionType()
  21909. case sopnode.FieldNoReplyCondition:
  21910. return m.AddedNoReplyCondition()
  21911. }
  21912. return nil, false
  21913. }
  21914. // AddField adds the value to the field with the given name. It returns an error if
  21915. // the field is not defined in the schema, or if the type mismatched the field
  21916. // type.
  21917. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21918. switch name {
  21919. case sopnode.FieldStatus:
  21920. v, ok := value.(int8)
  21921. if !ok {
  21922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21923. }
  21924. m.AddStatus(v)
  21925. return nil
  21926. case sopnode.FieldParentID:
  21927. v, ok := value.(int64)
  21928. if !ok {
  21929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21930. }
  21931. m.AddParentID(v)
  21932. return nil
  21933. case sopnode.FieldConditionType:
  21934. v, ok := value.(int)
  21935. if !ok {
  21936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21937. }
  21938. m.AddConditionType(v)
  21939. return nil
  21940. case sopnode.FieldNoReplyCondition:
  21941. v, ok := value.(int64)
  21942. if !ok {
  21943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21944. }
  21945. m.AddNoReplyCondition(v)
  21946. return nil
  21947. }
  21948. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21949. }
  21950. // ClearedFields returns all nullable fields that were cleared during this
  21951. // mutation.
  21952. func (m *SopNodeMutation) ClearedFields() []string {
  21953. var fields []string
  21954. if m.FieldCleared(sopnode.FieldStatus) {
  21955. fields = append(fields, sopnode.FieldStatus)
  21956. }
  21957. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21958. fields = append(fields, sopnode.FieldDeletedAt)
  21959. }
  21960. if m.FieldCleared(sopnode.FieldConditionList) {
  21961. fields = append(fields, sopnode.FieldConditionList)
  21962. }
  21963. if m.FieldCleared(sopnode.FieldActionMessage) {
  21964. fields = append(fields, sopnode.FieldActionMessage)
  21965. }
  21966. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21967. fields = append(fields, sopnode.FieldActionLabelAdd)
  21968. }
  21969. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21970. fields = append(fields, sopnode.FieldActionLabelDel)
  21971. }
  21972. if m.FieldCleared(sopnode.FieldActionForward) {
  21973. fields = append(fields, sopnode.FieldActionForward)
  21974. }
  21975. return fields
  21976. }
  21977. // FieldCleared returns a boolean indicating if a field with the given name was
  21978. // cleared in this mutation.
  21979. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21980. _, ok := m.clearedFields[name]
  21981. return ok
  21982. }
  21983. // ClearField clears the value of the field with the given name. It returns an
  21984. // error if the field is not defined in the schema.
  21985. func (m *SopNodeMutation) ClearField(name string) error {
  21986. switch name {
  21987. case sopnode.FieldStatus:
  21988. m.ClearStatus()
  21989. return nil
  21990. case sopnode.FieldDeletedAt:
  21991. m.ClearDeletedAt()
  21992. return nil
  21993. case sopnode.FieldConditionList:
  21994. m.ClearConditionList()
  21995. return nil
  21996. case sopnode.FieldActionMessage:
  21997. m.ClearActionMessage()
  21998. return nil
  21999. case sopnode.FieldActionLabelAdd:
  22000. m.ClearActionLabelAdd()
  22001. return nil
  22002. case sopnode.FieldActionLabelDel:
  22003. m.ClearActionLabelDel()
  22004. return nil
  22005. case sopnode.FieldActionForward:
  22006. m.ClearActionForward()
  22007. return nil
  22008. }
  22009. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22010. }
  22011. // ResetField resets all changes in the mutation for the field with the given name.
  22012. // It returns an error if the field is not defined in the schema.
  22013. func (m *SopNodeMutation) ResetField(name string) error {
  22014. switch name {
  22015. case sopnode.FieldCreatedAt:
  22016. m.ResetCreatedAt()
  22017. return nil
  22018. case sopnode.FieldUpdatedAt:
  22019. m.ResetUpdatedAt()
  22020. return nil
  22021. case sopnode.FieldStatus:
  22022. m.ResetStatus()
  22023. return nil
  22024. case sopnode.FieldDeletedAt:
  22025. m.ResetDeletedAt()
  22026. return nil
  22027. case sopnode.FieldStageID:
  22028. m.ResetStageID()
  22029. return nil
  22030. case sopnode.FieldParentID:
  22031. m.ResetParentID()
  22032. return nil
  22033. case sopnode.FieldName:
  22034. m.ResetName()
  22035. return nil
  22036. case sopnode.FieldConditionType:
  22037. m.ResetConditionType()
  22038. return nil
  22039. case sopnode.FieldConditionList:
  22040. m.ResetConditionList()
  22041. return nil
  22042. case sopnode.FieldNoReplyCondition:
  22043. m.ResetNoReplyCondition()
  22044. return nil
  22045. case sopnode.FieldNoReplyUnit:
  22046. m.ResetNoReplyUnit()
  22047. return nil
  22048. case sopnode.FieldActionMessage:
  22049. m.ResetActionMessage()
  22050. return nil
  22051. case sopnode.FieldActionLabelAdd:
  22052. m.ResetActionLabelAdd()
  22053. return nil
  22054. case sopnode.FieldActionLabelDel:
  22055. m.ResetActionLabelDel()
  22056. return nil
  22057. case sopnode.FieldActionForward:
  22058. m.ResetActionForward()
  22059. return nil
  22060. }
  22061. return fmt.Errorf("unknown SopNode field %s", name)
  22062. }
  22063. // AddedEdges returns all edge names that were set/added in this mutation.
  22064. func (m *SopNodeMutation) AddedEdges() []string {
  22065. edges := make([]string, 0, 2)
  22066. if m.sop_stage != nil {
  22067. edges = append(edges, sopnode.EdgeSopStage)
  22068. }
  22069. if m.node_messages != nil {
  22070. edges = append(edges, sopnode.EdgeNodeMessages)
  22071. }
  22072. return edges
  22073. }
  22074. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22075. // name in this mutation.
  22076. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22077. switch name {
  22078. case sopnode.EdgeSopStage:
  22079. if id := m.sop_stage; id != nil {
  22080. return []ent.Value{*id}
  22081. }
  22082. case sopnode.EdgeNodeMessages:
  22083. ids := make([]ent.Value, 0, len(m.node_messages))
  22084. for id := range m.node_messages {
  22085. ids = append(ids, id)
  22086. }
  22087. return ids
  22088. }
  22089. return nil
  22090. }
  22091. // RemovedEdges returns all edge names that were removed in this mutation.
  22092. func (m *SopNodeMutation) RemovedEdges() []string {
  22093. edges := make([]string, 0, 2)
  22094. if m.removednode_messages != nil {
  22095. edges = append(edges, sopnode.EdgeNodeMessages)
  22096. }
  22097. return edges
  22098. }
  22099. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22100. // the given name in this mutation.
  22101. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22102. switch name {
  22103. case sopnode.EdgeNodeMessages:
  22104. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22105. for id := range m.removednode_messages {
  22106. ids = append(ids, id)
  22107. }
  22108. return ids
  22109. }
  22110. return nil
  22111. }
  22112. // ClearedEdges returns all edge names that were cleared in this mutation.
  22113. func (m *SopNodeMutation) ClearedEdges() []string {
  22114. edges := make([]string, 0, 2)
  22115. if m.clearedsop_stage {
  22116. edges = append(edges, sopnode.EdgeSopStage)
  22117. }
  22118. if m.clearednode_messages {
  22119. edges = append(edges, sopnode.EdgeNodeMessages)
  22120. }
  22121. return edges
  22122. }
  22123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22124. // was cleared in this mutation.
  22125. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22126. switch name {
  22127. case sopnode.EdgeSopStage:
  22128. return m.clearedsop_stage
  22129. case sopnode.EdgeNodeMessages:
  22130. return m.clearednode_messages
  22131. }
  22132. return false
  22133. }
  22134. // ClearEdge clears the value of the edge with the given name. It returns an error
  22135. // if that edge is not defined in the schema.
  22136. func (m *SopNodeMutation) ClearEdge(name string) error {
  22137. switch name {
  22138. case sopnode.EdgeSopStage:
  22139. m.ClearSopStage()
  22140. return nil
  22141. }
  22142. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22143. }
  22144. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22145. // It returns an error if the edge is not defined in the schema.
  22146. func (m *SopNodeMutation) ResetEdge(name string) error {
  22147. switch name {
  22148. case sopnode.EdgeSopStage:
  22149. m.ResetSopStage()
  22150. return nil
  22151. case sopnode.EdgeNodeMessages:
  22152. m.ResetNodeMessages()
  22153. return nil
  22154. }
  22155. return fmt.Errorf("unknown SopNode edge %s", name)
  22156. }
  22157. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22158. type SopStageMutation struct {
  22159. config
  22160. op Op
  22161. typ string
  22162. id *uint64
  22163. created_at *time.Time
  22164. updated_at *time.Time
  22165. status *uint8
  22166. addstatus *int8
  22167. deleted_at *time.Time
  22168. name *string
  22169. condition_type *int
  22170. addcondition_type *int
  22171. condition_operator *int
  22172. addcondition_operator *int
  22173. condition_list *[]custom_types.Condition
  22174. appendcondition_list []custom_types.Condition
  22175. action_message *[]custom_types.Action
  22176. appendaction_message []custom_types.Action
  22177. action_label_add *[]uint64
  22178. appendaction_label_add []uint64
  22179. action_label_del *[]uint64
  22180. appendaction_label_del []uint64
  22181. action_forward **custom_types.ActionForward
  22182. index_sort *int
  22183. addindex_sort *int
  22184. clearedFields map[string]struct{}
  22185. sop_task *uint64
  22186. clearedsop_task bool
  22187. stage_nodes map[uint64]struct{}
  22188. removedstage_nodes map[uint64]struct{}
  22189. clearedstage_nodes bool
  22190. stage_messages map[uint64]struct{}
  22191. removedstage_messages map[uint64]struct{}
  22192. clearedstage_messages bool
  22193. done bool
  22194. oldValue func(context.Context) (*SopStage, error)
  22195. predicates []predicate.SopStage
  22196. }
  22197. var _ ent.Mutation = (*SopStageMutation)(nil)
  22198. // sopstageOption allows management of the mutation configuration using functional options.
  22199. type sopstageOption func(*SopStageMutation)
  22200. // newSopStageMutation creates new mutation for the SopStage entity.
  22201. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22202. m := &SopStageMutation{
  22203. config: c,
  22204. op: op,
  22205. typ: TypeSopStage,
  22206. clearedFields: make(map[string]struct{}),
  22207. }
  22208. for _, opt := range opts {
  22209. opt(m)
  22210. }
  22211. return m
  22212. }
  22213. // withSopStageID sets the ID field of the mutation.
  22214. func withSopStageID(id uint64) sopstageOption {
  22215. return func(m *SopStageMutation) {
  22216. var (
  22217. err error
  22218. once sync.Once
  22219. value *SopStage
  22220. )
  22221. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22222. once.Do(func() {
  22223. if m.done {
  22224. err = errors.New("querying old values post mutation is not allowed")
  22225. } else {
  22226. value, err = m.Client().SopStage.Get(ctx, id)
  22227. }
  22228. })
  22229. return value, err
  22230. }
  22231. m.id = &id
  22232. }
  22233. }
  22234. // withSopStage sets the old SopStage of the mutation.
  22235. func withSopStage(node *SopStage) sopstageOption {
  22236. return func(m *SopStageMutation) {
  22237. m.oldValue = func(context.Context) (*SopStage, error) {
  22238. return node, nil
  22239. }
  22240. m.id = &node.ID
  22241. }
  22242. }
  22243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22244. // executed in a transaction (ent.Tx), a transactional client is returned.
  22245. func (m SopStageMutation) Client() *Client {
  22246. client := &Client{config: m.config}
  22247. client.init()
  22248. return client
  22249. }
  22250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22251. // it returns an error otherwise.
  22252. func (m SopStageMutation) Tx() (*Tx, error) {
  22253. if _, ok := m.driver.(*txDriver); !ok {
  22254. return nil, errors.New("ent: mutation is not running in a transaction")
  22255. }
  22256. tx := &Tx{config: m.config}
  22257. tx.init()
  22258. return tx, nil
  22259. }
  22260. // SetID sets the value of the id field. Note that this
  22261. // operation is only accepted on creation of SopStage entities.
  22262. func (m *SopStageMutation) SetID(id uint64) {
  22263. m.id = &id
  22264. }
  22265. // ID returns the ID value in the mutation. Note that the ID is only available
  22266. // if it was provided to the builder or after it was returned from the database.
  22267. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22268. if m.id == nil {
  22269. return
  22270. }
  22271. return *m.id, true
  22272. }
  22273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22274. // That means, if the mutation is applied within a transaction with an isolation level such
  22275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22276. // or updated by the mutation.
  22277. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22278. switch {
  22279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22280. id, exists := m.ID()
  22281. if exists {
  22282. return []uint64{id}, nil
  22283. }
  22284. fallthrough
  22285. case m.op.Is(OpUpdate | OpDelete):
  22286. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22287. default:
  22288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22289. }
  22290. }
  22291. // SetCreatedAt sets the "created_at" field.
  22292. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22293. m.created_at = &t
  22294. }
  22295. // CreatedAt returns the value of the "created_at" field in the mutation.
  22296. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22297. v := m.created_at
  22298. if v == nil {
  22299. return
  22300. }
  22301. return *v, true
  22302. }
  22303. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22304. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22306. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22307. if !m.op.Is(OpUpdateOne) {
  22308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22309. }
  22310. if m.id == nil || m.oldValue == nil {
  22311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22312. }
  22313. oldValue, err := m.oldValue(ctx)
  22314. if err != nil {
  22315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22316. }
  22317. return oldValue.CreatedAt, nil
  22318. }
  22319. // ResetCreatedAt resets all changes to the "created_at" field.
  22320. func (m *SopStageMutation) ResetCreatedAt() {
  22321. m.created_at = nil
  22322. }
  22323. // SetUpdatedAt sets the "updated_at" field.
  22324. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22325. m.updated_at = &t
  22326. }
  22327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22328. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22329. v := m.updated_at
  22330. if v == nil {
  22331. return
  22332. }
  22333. return *v, true
  22334. }
  22335. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22336. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22338. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22339. if !m.op.Is(OpUpdateOne) {
  22340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22341. }
  22342. if m.id == nil || m.oldValue == nil {
  22343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22344. }
  22345. oldValue, err := m.oldValue(ctx)
  22346. if err != nil {
  22347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22348. }
  22349. return oldValue.UpdatedAt, nil
  22350. }
  22351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22352. func (m *SopStageMutation) ResetUpdatedAt() {
  22353. m.updated_at = nil
  22354. }
  22355. // SetStatus sets the "status" field.
  22356. func (m *SopStageMutation) SetStatus(u uint8) {
  22357. m.status = &u
  22358. m.addstatus = nil
  22359. }
  22360. // Status returns the value of the "status" field in the mutation.
  22361. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22362. v := m.status
  22363. if v == nil {
  22364. return
  22365. }
  22366. return *v, true
  22367. }
  22368. // OldStatus returns the old "status" field's value of the SopStage entity.
  22369. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22371. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22372. if !m.op.Is(OpUpdateOne) {
  22373. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22374. }
  22375. if m.id == nil || m.oldValue == nil {
  22376. return v, errors.New("OldStatus requires an ID field in the mutation")
  22377. }
  22378. oldValue, err := m.oldValue(ctx)
  22379. if err != nil {
  22380. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22381. }
  22382. return oldValue.Status, nil
  22383. }
  22384. // AddStatus adds u to the "status" field.
  22385. func (m *SopStageMutation) AddStatus(u int8) {
  22386. if m.addstatus != nil {
  22387. *m.addstatus += u
  22388. } else {
  22389. m.addstatus = &u
  22390. }
  22391. }
  22392. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22393. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22394. v := m.addstatus
  22395. if v == nil {
  22396. return
  22397. }
  22398. return *v, true
  22399. }
  22400. // ClearStatus clears the value of the "status" field.
  22401. func (m *SopStageMutation) ClearStatus() {
  22402. m.status = nil
  22403. m.addstatus = nil
  22404. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22405. }
  22406. // StatusCleared returns if the "status" field was cleared in this mutation.
  22407. func (m *SopStageMutation) StatusCleared() bool {
  22408. _, ok := m.clearedFields[sopstage.FieldStatus]
  22409. return ok
  22410. }
  22411. // ResetStatus resets all changes to the "status" field.
  22412. func (m *SopStageMutation) ResetStatus() {
  22413. m.status = nil
  22414. m.addstatus = nil
  22415. delete(m.clearedFields, sopstage.FieldStatus)
  22416. }
  22417. // SetDeletedAt sets the "deleted_at" field.
  22418. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22419. m.deleted_at = &t
  22420. }
  22421. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22422. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22423. v := m.deleted_at
  22424. if v == nil {
  22425. return
  22426. }
  22427. return *v, true
  22428. }
  22429. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22430. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22432. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22433. if !m.op.Is(OpUpdateOne) {
  22434. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22435. }
  22436. if m.id == nil || m.oldValue == nil {
  22437. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22438. }
  22439. oldValue, err := m.oldValue(ctx)
  22440. if err != nil {
  22441. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22442. }
  22443. return oldValue.DeletedAt, nil
  22444. }
  22445. // ClearDeletedAt clears the value of the "deleted_at" field.
  22446. func (m *SopStageMutation) ClearDeletedAt() {
  22447. m.deleted_at = nil
  22448. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22449. }
  22450. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22451. func (m *SopStageMutation) DeletedAtCleared() bool {
  22452. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22453. return ok
  22454. }
  22455. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22456. func (m *SopStageMutation) ResetDeletedAt() {
  22457. m.deleted_at = nil
  22458. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22459. }
  22460. // SetTaskID sets the "task_id" field.
  22461. func (m *SopStageMutation) SetTaskID(u uint64) {
  22462. m.sop_task = &u
  22463. }
  22464. // TaskID returns the value of the "task_id" field in the mutation.
  22465. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22466. v := m.sop_task
  22467. if v == nil {
  22468. return
  22469. }
  22470. return *v, true
  22471. }
  22472. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22473. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22475. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22476. if !m.op.Is(OpUpdateOne) {
  22477. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22478. }
  22479. if m.id == nil || m.oldValue == nil {
  22480. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22481. }
  22482. oldValue, err := m.oldValue(ctx)
  22483. if err != nil {
  22484. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22485. }
  22486. return oldValue.TaskID, nil
  22487. }
  22488. // ResetTaskID resets all changes to the "task_id" field.
  22489. func (m *SopStageMutation) ResetTaskID() {
  22490. m.sop_task = nil
  22491. }
  22492. // SetName sets the "name" field.
  22493. func (m *SopStageMutation) SetName(s string) {
  22494. m.name = &s
  22495. }
  22496. // Name returns the value of the "name" field in the mutation.
  22497. func (m *SopStageMutation) Name() (r string, exists bool) {
  22498. v := m.name
  22499. if v == nil {
  22500. return
  22501. }
  22502. return *v, true
  22503. }
  22504. // OldName returns the old "name" field's value of the SopStage entity.
  22505. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22507. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22508. if !m.op.Is(OpUpdateOne) {
  22509. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22510. }
  22511. if m.id == nil || m.oldValue == nil {
  22512. return v, errors.New("OldName requires an ID field in the mutation")
  22513. }
  22514. oldValue, err := m.oldValue(ctx)
  22515. if err != nil {
  22516. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22517. }
  22518. return oldValue.Name, nil
  22519. }
  22520. // ResetName resets all changes to the "name" field.
  22521. func (m *SopStageMutation) ResetName() {
  22522. m.name = nil
  22523. }
  22524. // SetConditionType sets the "condition_type" field.
  22525. func (m *SopStageMutation) SetConditionType(i int) {
  22526. m.condition_type = &i
  22527. m.addcondition_type = nil
  22528. }
  22529. // ConditionType returns the value of the "condition_type" field in the mutation.
  22530. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22531. v := m.condition_type
  22532. if v == nil {
  22533. return
  22534. }
  22535. return *v, true
  22536. }
  22537. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22538. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22540. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22541. if !m.op.Is(OpUpdateOne) {
  22542. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22543. }
  22544. if m.id == nil || m.oldValue == nil {
  22545. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22546. }
  22547. oldValue, err := m.oldValue(ctx)
  22548. if err != nil {
  22549. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22550. }
  22551. return oldValue.ConditionType, nil
  22552. }
  22553. // AddConditionType adds i to the "condition_type" field.
  22554. func (m *SopStageMutation) AddConditionType(i int) {
  22555. if m.addcondition_type != nil {
  22556. *m.addcondition_type += i
  22557. } else {
  22558. m.addcondition_type = &i
  22559. }
  22560. }
  22561. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22562. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22563. v := m.addcondition_type
  22564. if v == nil {
  22565. return
  22566. }
  22567. return *v, true
  22568. }
  22569. // ResetConditionType resets all changes to the "condition_type" field.
  22570. func (m *SopStageMutation) ResetConditionType() {
  22571. m.condition_type = nil
  22572. m.addcondition_type = nil
  22573. }
  22574. // SetConditionOperator sets the "condition_operator" field.
  22575. func (m *SopStageMutation) SetConditionOperator(i int) {
  22576. m.condition_operator = &i
  22577. m.addcondition_operator = nil
  22578. }
  22579. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22580. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22581. v := m.condition_operator
  22582. if v == nil {
  22583. return
  22584. }
  22585. return *v, true
  22586. }
  22587. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22588. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22590. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22591. if !m.op.Is(OpUpdateOne) {
  22592. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22593. }
  22594. if m.id == nil || m.oldValue == nil {
  22595. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22596. }
  22597. oldValue, err := m.oldValue(ctx)
  22598. if err != nil {
  22599. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22600. }
  22601. return oldValue.ConditionOperator, nil
  22602. }
  22603. // AddConditionOperator adds i to the "condition_operator" field.
  22604. func (m *SopStageMutation) AddConditionOperator(i int) {
  22605. if m.addcondition_operator != nil {
  22606. *m.addcondition_operator += i
  22607. } else {
  22608. m.addcondition_operator = &i
  22609. }
  22610. }
  22611. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22612. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22613. v := m.addcondition_operator
  22614. if v == nil {
  22615. return
  22616. }
  22617. return *v, true
  22618. }
  22619. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22620. func (m *SopStageMutation) ResetConditionOperator() {
  22621. m.condition_operator = nil
  22622. m.addcondition_operator = nil
  22623. }
  22624. // SetConditionList sets the "condition_list" field.
  22625. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22626. m.condition_list = &ct
  22627. m.appendcondition_list = nil
  22628. }
  22629. // ConditionList returns the value of the "condition_list" field in the mutation.
  22630. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22631. v := m.condition_list
  22632. if v == nil {
  22633. return
  22634. }
  22635. return *v, true
  22636. }
  22637. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22638. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22640. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22641. if !m.op.Is(OpUpdateOne) {
  22642. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22643. }
  22644. if m.id == nil || m.oldValue == nil {
  22645. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22646. }
  22647. oldValue, err := m.oldValue(ctx)
  22648. if err != nil {
  22649. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22650. }
  22651. return oldValue.ConditionList, nil
  22652. }
  22653. // AppendConditionList adds ct to the "condition_list" field.
  22654. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22655. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22656. }
  22657. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22658. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22659. if len(m.appendcondition_list) == 0 {
  22660. return nil, false
  22661. }
  22662. return m.appendcondition_list, true
  22663. }
  22664. // ResetConditionList resets all changes to the "condition_list" field.
  22665. func (m *SopStageMutation) ResetConditionList() {
  22666. m.condition_list = nil
  22667. m.appendcondition_list = nil
  22668. }
  22669. // SetActionMessage sets the "action_message" field.
  22670. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22671. m.action_message = &ct
  22672. m.appendaction_message = nil
  22673. }
  22674. // ActionMessage returns the value of the "action_message" field in the mutation.
  22675. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22676. v := m.action_message
  22677. if v == nil {
  22678. return
  22679. }
  22680. return *v, true
  22681. }
  22682. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22683. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22685. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22686. if !m.op.Is(OpUpdateOne) {
  22687. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22688. }
  22689. if m.id == nil || m.oldValue == nil {
  22690. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22691. }
  22692. oldValue, err := m.oldValue(ctx)
  22693. if err != nil {
  22694. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22695. }
  22696. return oldValue.ActionMessage, nil
  22697. }
  22698. // AppendActionMessage adds ct to the "action_message" field.
  22699. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22700. m.appendaction_message = append(m.appendaction_message, ct...)
  22701. }
  22702. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22703. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22704. if len(m.appendaction_message) == 0 {
  22705. return nil, false
  22706. }
  22707. return m.appendaction_message, true
  22708. }
  22709. // ClearActionMessage clears the value of the "action_message" field.
  22710. func (m *SopStageMutation) ClearActionMessage() {
  22711. m.action_message = nil
  22712. m.appendaction_message = nil
  22713. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22714. }
  22715. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22716. func (m *SopStageMutation) ActionMessageCleared() bool {
  22717. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22718. return ok
  22719. }
  22720. // ResetActionMessage resets all changes to the "action_message" field.
  22721. func (m *SopStageMutation) ResetActionMessage() {
  22722. m.action_message = nil
  22723. m.appendaction_message = nil
  22724. delete(m.clearedFields, sopstage.FieldActionMessage)
  22725. }
  22726. // SetActionLabelAdd sets the "action_label_add" field.
  22727. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22728. m.action_label_add = &u
  22729. m.appendaction_label_add = nil
  22730. }
  22731. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22732. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22733. v := m.action_label_add
  22734. if v == nil {
  22735. return
  22736. }
  22737. return *v, true
  22738. }
  22739. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22740. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22742. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22743. if !m.op.Is(OpUpdateOne) {
  22744. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22745. }
  22746. if m.id == nil || m.oldValue == nil {
  22747. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22748. }
  22749. oldValue, err := m.oldValue(ctx)
  22750. if err != nil {
  22751. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22752. }
  22753. return oldValue.ActionLabelAdd, nil
  22754. }
  22755. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22756. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22757. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22758. }
  22759. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22760. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22761. if len(m.appendaction_label_add) == 0 {
  22762. return nil, false
  22763. }
  22764. return m.appendaction_label_add, true
  22765. }
  22766. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22767. func (m *SopStageMutation) ClearActionLabelAdd() {
  22768. m.action_label_add = nil
  22769. m.appendaction_label_add = nil
  22770. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22771. }
  22772. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22773. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22774. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22775. return ok
  22776. }
  22777. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22778. func (m *SopStageMutation) ResetActionLabelAdd() {
  22779. m.action_label_add = nil
  22780. m.appendaction_label_add = nil
  22781. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22782. }
  22783. // SetActionLabelDel sets the "action_label_del" field.
  22784. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22785. m.action_label_del = &u
  22786. m.appendaction_label_del = nil
  22787. }
  22788. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22789. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22790. v := m.action_label_del
  22791. if v == nil {
  22792. return
  22793. }
  22794. return *v, true
  22795. }
  22796. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22797. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22799. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22800. if !m.op.Is(OpUpdateOne) {
  22801. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22802. }
  22803. if m.id == nil || m.oldValue == nil {
  22804. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22805. }
  22806. oldValue, err := m.oldValue(ctx)
  22807. if err != nil {
  22808. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22809. }
  22810. return oldValue.ActionLabelDel, nil
  22811. }
  22812. // AppendActionLabelDel adds u to the "action_label_del" field.
  22813. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22814. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22815. }
  22816. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22817. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22818. if len(m.appendaction_label_del) == 0 {
  22819. return nil, false
  22820. }
  22821. return m.appendaction_label_del, true
  22822. }
  22823. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22824. func (m *SopStageMutation) ClearActionLabelDel() {
  22825. m.action_label_del = nil
  22826. m.appendaction_label_del = nil
  22827. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22828. }
  22829. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22830. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22831. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22832. return ok
  22833. }
  22834. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22835. func (m *SopStageMutation) ResetActionLabelDel() {
  22836. m.action_label_del = nil
  22837. m.appendaction_label_del = nil
  22838. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22839. }
  22840. // SetActionForward sets the "action_forward" field.
  22841. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22842. m.action_forward = &ctf
  22843. }
  22844. // ActionForward returns the value of the "action_forward" field in the mutation.
  22845. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22846. v := m.action_forward
  22847. if v == nil {
  22848. return
  22849. }
  22850. return *v, true
  22851. }
  22852. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22853. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22855. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22856. if !m.op.Is(OpUpdateOne) {
  22857. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22858. }
  22859. if m.id == nil || m.oldValue == nil {
  22860. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22861. }
  22862. oldValue, err := m.oldValue(ctx)
  22863. if err != nil {
  22864. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22865. }
  22866. return oldValue.ActionForward, nil
  22867. }
  22868. // ClearActionForward clears the value of the "action_forward" field.
  22869. func (m *SopStageMutation) ClearActionForward() {
  22870. m.action_forward = nil
  22871. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22872. }
  22873. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22874. func (m *SopStageMutation) ActionForwardCleared() bool {
  22875. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22876. return ok
  22877. }
  22878. // ResetActionForward resets all changes to the "action_forward" field.
  22879. func (m *SopStageMutation) ResetActionForward() {
  22880. m.action_forward = nil
  22881. delete(m.clearedFields, sopstage.FieldActionForward)
  22882. }
  22883. // SetIndexSort sets the "index_sort" field.
  22884. func (m *SopStageMutation) SetIndexSort(i int) {
  22885. m.index_sort = &i
  22886. m.addindex_sort = nil
  22887. }
  22888. // IndexSort returns the value of the "index_sort" field in the mutation.
  22889. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22890. v := m.index_sort
  22891. if v == nil {
  22892. return
  22893. }
  22894. return *v, true
  22895. }
  22896. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22897. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22899. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22900. if !m.op.Is(OpUpdateOne) {
  22901. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22902. }
  22903. if m.id == nil || m.oldValue == nil {
  22904. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22905. }
  22906. oldValue, err := m.oldValue(ctx)
  22907. if err != nil {
  22908. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22909. }
  22910. return oldValue.IndexSort, nil
  22911. }
  22912. // AddIndexSort adds i to the "index_sort" field.
  22913. func (m *SopStageMutation) AddIndexSort(i int) {
  22914. if m.addindex_sort != nil {
  22915. *m.addindex_sort += i
  22916. } else {
  22917. m.addindex_sort = &i
  22918. }
  22919. }
  22920. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22921. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22922. v := m.addindex_sort
  22923. if v == nil {
  22924. return
  22925. }
  22926. return *v, true
  22927. }
  22928. // ClearIndexSort clears the value of the "index_sort" field.
  22929. func (m *SopStageMutation) ClearIndexSort() {
  22930. m.index_sort = nil
  22931. m.addindex_sort = nil
  22932. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22933. }
  22934. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22935. func (m *SopStageMutation) IndexSortCleared() bool {
  22936. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22937. return ok
  22938. }
  22939. // ResetIndexSort resets all changes to the "index_sort" field.
  22940. func (m *SopStageMutation) ResetIndexSort() {
  22941. m.index_sort = nil
  22942. m.addindex_sort = nil
  22943. delete(m.clearedFields, sopstage.FieldIndexSort)
  22944. }
  22945. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22946. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22947. m.sop_task = &id
  22948. }
  22949. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22950. func (m *SopStageMutation) ClearSopTask() {
  22951. m.clearedsop_task = true
  22952. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22953. }
  22954. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22955. func (m *SopStageMutation) SopTaskCleared() bool {
  22956. return m.clearedsop_task
  22957. }
  22958. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22959. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22960. if m.sop_task != nil {
  22961. return *m.sop_task, true
  22962. }
  22963. return
  22964. }
  22965. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22966. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22967. // SopTaskID instead. It exists only for internal usage by the builders.
  22968. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22969. if id := m.sop_task; id != nil {
  22970. ids = append(ids, *id)
  22971. }
  22972. return
  22973. }
  22974. // ResetSopTask resets all changes to the "sop_task" edge.
  22975. func (m *SopStageMutation) ResetSopTask() {
  22976. m.sop_task = nil
  22977. m.clearedsop_task = false
  22978. }
  22979. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22980. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22981. if m.stage_nodes == nil {
  22982. m.stage_nodes = make(map[uint64]struct{})
  22983. }
  22984. for i := range ids {
  22985. m.stage_nodes[ids[i]] = struct{}{}
  22986. }
  22987. }
  22988. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22989. func (m *SopStageMutation) ClearStageNodes() {
  22990. m.clearedstage_nodes = true
  22991. }
  22992. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22993. func (m *SopStageMutation) StageNodesCleared() bool {
  22994. return m.clearedstage_nodes
  22995. }
  22996. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22997. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22998. if m.removedstage_nodes == nil {
  22999. m.removedstage_nodes = make(map[uint64]struct{})
  23000. }
  23001. for i := range ids {
  23002. delete(m.stage_nodes, ids[i])
  23003. m.removedstage_nodes[ids[i]] = struct{}{}
  23004. }
  23005. }
  23006. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23007. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23008. for id := range m.removedstage_nodes {
  23009. ids = append(ids, id)
  23010. }
  23011. return
  23012. }
  23013. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23014. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23015. for id := range m.stage_nodes {
  23016. ids = append(ids, id)
  23017. }
  23018. return
  23019. }
  23020. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23021. func (m *SopStageMutation) ResetStageNodes() {
  23022. m.stage_nodes = nil
  23023. m.clearedstage_nodes = false
  23024. m.removedstage_nodes = nil
  23025. }
  23026. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23027. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23028. if m.stage_messages == nil {
  23029. m.stage_messages = make(map[uint64]struct{})
  23030. }
  23031. for i := range ids {
  23032. m.stage_messages[ids[i]] = struct{}{}
  23033. }
  23034. }
  23035. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23036. func (m *SopStageMutation) ClearStageMessages() {
  23037. m.clearedstage_messages = true
  23038. }
  23039. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23040. func (m *SopStageMutation) StageMessagesCleared() bool {
  23041. return m.clearedstage_messages
  23042. }
  23043. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23044. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23045. if m.removedstage_messages == nil {
  23046. m.removedstage_messages = make(map[uint64]struct{})
  23047. }
  23048. for i := range ids {
  23049. delete(m.stage_messages, ids[i])
  23050. m.removedstage_messages[ids[i]] = struct{}{}
  23051. }
  23052. }
  23053. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23054. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23055. for id := range m.removedstage_messages {
  23056. ids = append(ids, id)
  23057. }
  23058. return
  23059. }
  23060. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23061. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23062. for id := range m.stage_messages {
  23063. ids = append(ids, id)
  23064. }
  23065. return
  23066. }
  23067. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23068. func (m *SopStageMutation) ResetStageMessages() {
  23069. m.stage_messages = nil
  23070. m.clearedstage_messages = false
  23071. m.removedstage_messages = nil
  23072. }
  23073. // Where appends a list predicates to the SopStageMutation builder.
  23074. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23075. m.predicates = append(m.predicates, ps...)
  23076. }
  23077. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23078. // users can use type-assertion to append predicates that do not depend on any generated package.
  23079. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23080. p := make([]predicate.SopStage, len(ps))
  23081. for i := range ps {
  23082. p[i] = ps[i]
  23083. }
  23084. m.Where(p...)
  23085. }
  23086. // Op returns the operation name.
  23087. func (m *SopStageMutation) Op() Op {
  23088. return m.op
  23089. }
  23090. // SetOp allows setting the mutation operation.
  23091. func (m *SopStageMutation) SetOp(op Op) {
  23092. m.op = op
  23093. }
  23094. // Type returns the node type of this mutation (SopStage).
  23095. func (m *SopStageMutation) Type() string {
  23096. return m.typ
  23097. }
  23098. // Fields returns all fields that were changed during this mutation. Note that in
  23099. // order to get all numeric fields that were incremented/decremented, call
  23100. // AddedFields().
  23101. func (m *SopStageMutation) Fields() []string {
  23102. fields := make([]string, 0, 14)
  23103. if m.created_at != nil {
  23104. fields = append(fields, sopstage.FieldCreatedAt)
  23105. }
  23106. if m.updated_at != nil {
  23107. fields = append(fields, sopstage.FieldUpdatedAt)
  23108. }
  23109. if m.status != nil {
  23110. fields = append(fields, sopstage.FieldStatus)
  23111. }
  23112. if m.deleted_at != nil {
  23113. fields = append(fields, sopstage.FieldDeletedAt)
  23114. }
  23115. if m.sop_task != nil {
  23116. fields = append(fields, sopstage.FieldTaskID)
  23117. }
  23118. if m.name != nil {
  23119. fields = append(fields, sopstage.FieldName)
  23120. }
  23121. if m.condition_type != nil {
  23122. fields = append(fields, sopstage.FieldConditionType)
  23123. }
  23124. if m.condition_operator != nil {
  23125. fields = append(fields, sopstage.FieldConditionOperator)
  23126. }
  23127. if m.condition_list != nil {
  23128. fields = append(fields, sopstage.FieldConditionList)
  23129. }
  23130. if m.action_message != nil {
  23131. fields = append(fields, sopstage.FieldActionMessage)
  23132. }
  23133. if m.action_label_add != nil {
  23134. fields = append(fields, sopstage.FieldActionLabelAdd)
  23135. }
  23136. if m.action_label_del != nil {
  23137. fields = append(fields, sopstage.FieldActionLabelDel)
  23138. }
  23139. if m.action_forward != nil {
  23140. fields = append(fields, sopstage.FieldActionForward)
  23141. }
  23142. if m.index_sort != nil {
  23143. fields = append(fields, sopstage.FieldIndexSort)
  23144. }
  23145. return fields
  23146. }
  23147. // Field returns the value of a field with the given name. The second boolean
  23148. // return value indicates that this field was not set, or was not defined in the
  23149. // schema.
  23150. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23151. switch name {
  23152. case sopstage.FieldCreatedAt:
  23153. return m.CreatedAt()
  23154. case sopstage.FieldUpdatedAt:
  23155. return m.UpdatedAt()
  23156. case sopstage.FieldStatus:
  23157. return m.Status()
  23158. case sopstage.FieldDeletedAt:
  23159. return m.DeletedAt()
  23160. case sopstage.FieldTaskID:
  23161. return m.TaskID()
  23162. case sopstage.FieldName:
  23163. return m.Name()
  23164. case sopstage.FieldConditionType:
  23165. return m.ConditionType()
  23166. case sopstage.FieldConditionOperator:
  23167. return m.ConditionOperator()
  23168. case sopstage.FieldConditionList:
  23169. return m.ConditionList()
  23170. case sopstage.FieldActionMessage:
  23171. return m.ActionMessage()
  23172. case sopstage.FieldActionLabelAdd:
  23173. return m.ActionLabelAdd()
  23174. case sopstage.FieldActionLabelDel:
  23175. return m.ActionLabelDel()
  23176. case sopstage.FieldActionForward:
  23177. return m.ActionForward()
  23178. case sopstage.FieldIndexSort:
  23179. return m.IndexSort()
  23180. }
  23181. return nil, false
  23182. }
  23183. // OldField returns the old value of the field from the database. An error is
  23184. // returned if the mutation operation is not UpdateOne, or the query to the
  23185. // database failed.
  23186. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23187. switch name {
  23188. case sopstage.FieldCreatedAt:
  23189. return m.OldCreatedAt(ctx)
  23190. case sopstage.FieldUpdatedAt:
  23191. return m.OldUpdatedAt(ctx)
  23192. case sopstage.FieldStatus:
  23193. return m.OldStatus(ctx)
  23194. case sopstage.FieldDeletedAt:
  23195. return m.OldDeletedAt(ctx)
  23196. case sopstage.FieldTaskID:
  23197. return m.OldTaskID(ctx)
  23198. case sopstage.FieldName:
  23199. return m.OldName(ctx)
  23200. case sopstage.FieldConditionType:
  23201. return m.OldConditionType(ctx)
  23202. case sopstage.FieldConditionOperator:
  23203. return m.OldConditionOperator(ctx)
  23204. case sopstage.FieldConditionList:
  23205. return m.OldConditionList(ctx)
  23206. case sopstage.FieldActionMessage:
  23207. return m.OldActionMessage(ctx)
  23208. case sopstage.FieldActionLabelAdd:
  23209. return m.OldActionLabelAdd(ctx)
  23210. case sopstage.FieldActionLabelDel:
  23211. return m.OldActionLabelDel(ctx)
  23212. case sopstage.FieldActionForward:
  23213. return m.OldActionForward(ctx)
  23214. case sopstage.FieldIndexSort:
  23215. return m.OldIndexSort(ctx)
  23216. }
  23217. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23218. }
  23219. // SetField sets the value of a field with the given name. It returns an error if
  23220. // the field is not defined in the schema, or if the type mismatched the field
  23221. // type.
  23222. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23223. switch name {
  23224. case sopstage.FieldCreatedAt:
  23225. v, ok := value.(time.Time)
  23226. if !ok {
  23227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23228. }
  23229. m.SetCreatedAt(v)
  23230. return nil
  23231. case sopstage.FieldUpdatedAt:
  23232. v, ok := value.(time.Time)
  23233. if !ok {
  23234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23235. }
  23236. m.SetUpdatedAt(v)
  23237. return nil
  23238. case sopstage.FieldStatus:
  23239. v, ok := value.(uint8)
  23240. if !ok {
  23241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23242. }
  23243. m.SetStatus(v)
  23244. return nil
  23245. case sopstage.FieldDeletedAt:
  23246. v, ok := value.(time.Time)
  23247. if !ok {
  23248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23249. }
  23250. m.SetDeletedAt(v)
  23251. return nil
  23252. case sopstage.FieldTaskID:
  23253. v, ok := value.(uint64)
  23254. if !ok {
  23255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23256. }
  23257. m.SetTaskID(v)
  23258. return nil
  23259. case sopstage.FieldName:
  23260. v, ok := value.(string)
  23261. if !ok {
  23262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23263. }
  23264. m.SetName(v)
  23265. return nil
  23266. case sopstage.FieldConditionType:
  23267. v, ok := value.(int)
  23268. if !ok {
  23269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23270. }
  23271. m.SetConditionType(v)
  23272. return nil
  23273. case sopstage.FieldConditionOperator:
  23274. v, ok := value.(int)
  23275. if !ok {
  23276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23277. }
  23278. m.SetConditionOperator(v)
  23279. return nil
  23280. case sopstage.FieldConditionList:
  23281. v, ok := value.([]custom_types.Condition)
  23282. if !ok {
  23283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23284. }
  23285. m.SetConditionList(v)
  23286. return nil
  23287. case sopstage.FieldActionMessage:
  23288. v, ok := value.([]custom_types.Action)
  23289. if !ok {
  23290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23291. }
  23292. m.SetActionMessage(v)
  23293. return nil
  23294. case sopstage.FieldActionLabelAdd:
  23295. v, ok := value.([]uint64)
  23296. if !ok {
  23297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23298. }
  23299. m.SetActionLabelAdd(v)
  23300. return nil
  23301. case sopstage.FieldActionLabelDel:
  23302. v, ok := value.([]uint64)
  23303. if !ok {
  23304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23305. }
  23306. m.SetActionLabelDel(v)
  23307. return nil
  23308. case sopstage.FieldActionForward:
  23309. v, ok := value.(*custom_types.ActionForward)
  23310. if !ok {
  23311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23312. }
  23313. m.SetActionForward(v)
  23314. return nil
  23315. case sopstage.FieldIndexSort:
  23316. v, ok := value.(int)
  23317. if !ok {
  23318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23319. }
  23320. m.SetIndexSort(v)
  23321. return nil
  23322. }
  23323. return fmt.Errorf("unknown SopStage field %s", name)
  23324. }
  23325. // AddedFields returns all numeric fields that were incremented/decremented during
  23326. // this mutation.
  23327. func (m *SopStageMutation) AddedFields() []string {
  23328. var fields []string
  23329. if m.addstatus != nil {
  23330. fields = append(fields, sopstage.FieldStatus)
  23331. }
  23332. if m.addcondition_type != nil {
  23333. fields = append(fields, sopstage.FieldConditionType)
  23334. }
  23335. if m.addcondition_operator != nil {
  23336. fields = append(fields, sopstage.FieldConditionOperator)
  23337. }
  23338. if m.addindex_sort != nil {
  23339. fields = append(fields, sopstage.FieldIndexSort)
  23340. }
  23341. return fields
  23342. }
  23343. // AddedField returns the numeric value that was incremented/decremented on a field
  23344. // with the given name. The second boolean return value indicates that this field
  23345. // was not set, or was not defined in the schema.
  23346. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23347. switch name {
  23348. case sopstage.FieldStatus:
  23349. return m.AddedStatus()
  23350. case sopstage.FieldConditionType:
  23351. return m.AddedConditionType()
  23352. case sopstage.FieldConditionOperator:
  23353. return m.AddedConditionOperator()
  23354. case sopstage.FieldIndexSort:
  23355. return m.AddedIndexSort()
  23356. }
  23357. return nil, false
  23358. }
  23359. // AddField adds the value to the field with the given name. It returns an error if
  23360. // the field is not defined in the schema, or if the type mismatched the field
  23361. // type.
  23362. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23363. switch name {
  23364. case sopstage.FieldStatus:
  23365. v, ok := value.(int8)
  23366. if !ok {
  23367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23368. }
  23369. m.AddStatus(v)
  23370. return nil
  23371. case sopstage.FieldConditionType:
  23372. v, ok := value.(int)
  23373. if !ok {
  23374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23375. }
  23376. m.AddConditionType(v)
  23377. return nil
  23378. case sopstage.FieldConditionOperator:
  23379. v, ok := value.(int)
  23380. if !ok {
  23381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23382. }
  23383. m.AddConditionOperator(v)
  23384. return nil
  23385. case sopstage.FieldIndexSort:
  23386. v, ok := value.(int)
  23387. if !ok {
  23388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23389. }
  23390. m.AddIndexSort(v)
  23391. return nil
  23392. }
  23393. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23394. }
  23395. // ClearedFields returns all nullable fields that were cleared during this
  23396. // mutation.
  23397. func (m *SopStageMutation) ClearedFields() []string {
  23398. var fields []string
  23399. if m.FieldCleared(sopstage.FieldStatus) {
  23400. fields = append(fields, sopstage.FieldStatus)
  23401. }
  23402. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23403. fields = append(fields, sopstage.FieldDeletedAt)
  23404. }
  23405. if m.FieldCleared(sopstage.FieldActionMessage) {
  23406. fields = append(fields, sopstage.FieldActionMessage)
  23407. }
  23408. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23409. fields = append(fields, sopstage.FieldActionLabelAdd)
  23410. }
  23411. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23412. fields = append(fields, sopstage.FieldActionLabelDel)
  23413. }
  23414. if m.FieldCleared(sopstage.FieldActionForward) {
  23415. fields = append(fields, sopstage.FieldActionForward)
  23416. }
  23417. if m.FieldCleared(sopstage.FieldIndexSort) {
  23418. fields = append(fields, sopstage.FieldIndexSort)
  23419. }
  23420. return fields
  23421. }
  23422. // FieldCleared returns a boolean indicating if a field with the given name was
  23423. // cleared in this mutation.
  23424. func (m *SopStageMutation) FieldCleared(name string) bool {
  23425. _, ok := m.clearedFields[name]
  23426. return ok
  23427. }
  23428. // ClearField clears the value of the field with the given name. It returns an
  23429. // error if the field is not defined in the schema.
  23430. func (m *SopStageMutation) ClearField(name string) error {
  23431. switch name {
  23432. case sopstage.FieldStatus:
  23433. m.ClearStatus()
  23434. return nil
  23435. case sopstage.FieldDeletedAt:
  23436. m.ClearDeletedAt()
  23437. return nil
  23438. case sopstage.FieldActionMessage:
  23439. m.ClearActionMessage()
  23440. return nil
  23441. case sopstage.FieldActionLabelAdd:
  23442. m.ClearActionLabelAdd()
  23443. return nil
  23444. case sopstage.FieldActionLabelDel:
  23445. m.ClearActionLabelDel()
  23446. return nil
  23447. case sopstage.FieldActionForward:
  23448. m.ClearActionForward()
  23449. return nil
  23450. case sopstage.FieldIndexSort:
  23451. m.ClearIndexSort()
  23452. return nil
  23453. }
  23454. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23455. }
  23456. // ResetField resets all changes in the mutation for the field with the given name.
  23457. // It returns an error if the field is not defined in the schema.
  23458. func (m *SopStageMutation) ResetField(name string) error {
  23459. switch name {
  23460. case sopstage.FieldCreatedAt:
  23461. m.ResetCreatedAt()
  23462. return nil
  23463. case sopstage.FieldUpdatedAt:
  23464. m.ResetUpdatedAt()
  23465. return nil
  23466. case sopstage.FieldStatus:
  23467. m.ResetStatus()
  23468. return nil
  23469. case sopstage.FieldDeletedAt:
  23470. m.ResetDeletedAt()
  23471. return nil
  23472. case sopstage.FieldTaskID:
  23473. m.ResetTaskID()
  23474. return nil
  23475. case sopstage.FieldName:
  23476. m.ResetName()
  23477. return nil
  23478. case sopstage.FieldConditionType:
  23479. m.ResetConditionType()
  23480. return nil
  23481. case sopstage.FieldConditionOperator:
  23482. m.ResetConditionOperator()
  23483. return nil
  23484. case sopstage.FieldConditionList:
  23485. m.ResetConditionList()
  23486. return nil
  23487. case sopstage.FieldActionMessage:
  23488. m.ResetActionMessage()
  23489. return nil
  23490. case sopstage.FieldActionLabelAdd:
  23491. m.ResetActionLabelAdd()
  23492. return nil
  23493. case sopstage.FieldActionLabelDel:
  23494. m.ResetActionLabelDel()
  23495. return nil
  23496. case sopstage.FieldActionForward:
  23497. m.ResetActionForward()
  23498. return nil
  23499. case sopstage.FieldIndexSort:
  23500. m.ResetIndexSort()
  23501. return nil
  23502. }
  23503. return fmt.Errorf("unknown SopStage field %s", name)
  23504. }
  23505. // AddedEdges returns all edge names that were set/added in this mutation.
  23506. func (m *SopStageMutation) AddedEdges() []string {
  23507. edges := make([]string, 0, 3)
  23508. if m.sop_task != nil {
  23509. edges = append(edges, sopstage.EdgeSopTask)
  23510. }
  23511. if m.stage_nodes != nil {
  23512. edges = append(edges, sopstage.EdgeStageNodes)
  23513. }
  23514. if m.stage_messages != nil {
  23515. edges = append(edges, sopstage.EdgeStageMessages)
  23516. }
  23517. return edges
  23518. }
  23519. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23520. // name in this mutation.
  23521. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23522. switch name {
  23523. case sopstage.EdgeSopTask:
  23524. if id := m.sop_task; id != nil {
  23525. return []ent.Value{*id}
  23526. }
  23527. case sopstage.EdgeStageNodes:
  23528. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23529. for id := range m.stage_nodes {
  23530. ids = append(ids, id)
  23531. }
  23532. return ids
  23533. case sopstage.EdgeStageMessages:
  23534. ids := make([]ent.Value, 0, len(m.stage_messages))
  23535. for id := range m.stage_messages {
  23536. ids = append(ids, id)
  23537. }
  23538. return ids
  23539. }
  23540. return nil
  23541. }
  23542. // RemovedEdges returns all edge names that were removed in this mutation.
  23543. func (m *SopStageMutation) RemovedEdges() []string {
  23544. edges := make([]string, 0, 3)
  23545. if m.removedstage_nodes != nil {
  23546. edges = append(edges, sopstage.EdgeStageNodes)
  23547. }
  23548. if m.removedstage_messages != nil {
  23549. edges = append(edges, sopstage.EdgeStageMessages)
  23550. }
  23551. return edges
  23552. }
  23553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23554. // the given name in this mutation.
  23555. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23556. switch name {
  23557. case sopstage.EdgeStageNodes:
  23558. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23559. for id := range m.removedstage_nodes {
  23560. ids = append(ids, id)
  23561. }
  23562. return ids
  23563. case sopstage.EdgeStageMessages:
  23564. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23565. for id := range m.removedstage_messages {
  23566. ids = append(ids, id)
  23567. }
  23568. return ids
  23569. }
  23570. return nil
  23571. }
  23572. // ClearedEdges returns all edge names that were cleared in this mutation.
  23573. func (m *SopStageMutation) ClearedEdges() []string {
  23574. edges := make([]string, 0, 3)
  23575. if m.clearedsop_task {
  23576. edges = append(edges, sopstage.EdgeSopTask)
  23577. }
  23578. if m.clearedstage_nodes {
  23579. edges = append(edges, sopstage.EdgeStageNodes)
  23580. }
  23581. if m.clearedstage_messages {
  23582. edges = append(edges, sopstage.EdgeStageMessages)
  23583. }
  23584. return edges
  23585. }
  23586. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23587. // was cleared in this mutation.
  23588. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23589. switch name {
  23590. case sopstage.EdgeSopTask:
  23591. return m.clearedsop_task
  23592. case sopstage.EdgeStageNodes:
  23593. return m.clearedstage_nodes
  23594. case sopstage.EdgeStageMessages:
  23595. return m.clearedstage_messages
  23596. }
  23597. return false
  23598. }
  23599. // ClearEdge clears the value of the edge with the given name. It returns an error
  23600. // if that edge is not defined in the schema.
  23601. func (m *SopStageMutation) ClearEdge(name string) error {
  23602. switch name {
  23603. case sopstage.EdgeSopTask:
  23604. m.ClearSopTask()
  23605. return nil
  23606. }
  23607. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23608. }
  23609. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23610. // It returns an error if the edge is not defined in the schema.
  23611. func (m *SopStageMutation) ResetEdge(name string) error {
  23612. switch name {
  23613. case sopstage.EdgeSopTask:
  23614. m.ResetSopTask()
  23615. return nil
  23616. case sopstage.EdgeStageNodes:
  23617. m.ResetStageNodes()
  23618. return nil
  23619. case sopstage.EdgeStageMessages:
  23620. m.ResetStageMessages()
  23621. return nil
  23622. }
  23623. return fmt.Errorf("unknown SopStage edge %s", name)
  23624. }
  23625. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23626. type SopTaskMutation struct {
  23627. config
  23628. op Op
  23629. typ string
  23630. id *uint64
  23631. created_at *time.Time
  23632. updated_at *time.Time
  23633. status *uint8
  23634. addstatus *int8
  23635. deleted_at *time.Time
  23636. name *string
  23637. bot_wxid_list *[]string
  23638. appendbot_wxid_list []string
  23639. _type *int
  23640. add_type *int
  23641. plan_start_time *time.Time
  23642. plan_end_time *time.Time
  23643. creator_id *string
  23644. organization_id *uint64
  23645. addorganization_id *int64
  23646. token *[]string
  23647. appendtoken []string
  23648. clearedFields map[string]struct{}
  23649. task_stages map[uint64]struct{}
  23650. removedtask_stages map[uint64]struct{}
  23651. clearedtask_stages bool
  23652. done bool
  23653. oldValue func(context.Context) (*SopTask, error)
  23654. predicates []predicate.SopTask
  23655. }
  23656. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23657. // soptaskOption allows management of the mutation configuration using functional options.
  23658. type soptaskOption func(*SopTaskMutation)
  23659. // newSopTaskMutation creates new mutation for the SopTask entity.
  23660. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23661. m := &SopTaskMutation{
  23662. config: c,
  23663. op: op,
  23664. typ: TypeSopTask,
  23665. clearedFields: make(map[string]struct{}),
  23666. }
  23667. for _, opt := range opts {
  23668. opt(m)
  23669. }
  23670. return m
  23671. }
  23672. // withSopTaskID sets the ID field of the mutation.
  23673. func withSopTaskID(id uint64) soptaskOption {
  23674. return func(m *SopTaskMutation) {
  23675. var (
  23676. err error
  23677. once sync.Once
  23678. value *SopTask
  23679. )
  23680. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23681. once.Do(func() {
  23682. if m.done {
  23683. err = errors.New("querying old values post mutation is not allowed")
  23684. } else {
  23685. value, err = m.Client().SopTask.Get(ctx, id)
  23686. }
  23687. })
  23688. return value, err
  23689. }
  23690. m.id = &id
  23691. }
  23692. }
  23693. // withSopTask sets the old SopTask of the mutation.
  23694. func withSopTask(node *SopTask) soptaskOption {
  23695. return func(m *SopTaskMutation) {
  23696. m.oldValue = func(context.Context) (*SopTask, error) {
  23697. return node, nil
  23698. }
  23699. m.id = &node.ID
  23700. }
  23701. }
  23702. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23703. // executed in a transaction (ent.Tx), a transactional client is returned.
  23704. func (m SopTaskMutation) Client() *Client {
  23705. client := &Client{config: m.config}
  23706. client.init()
  23707. return client
  23708. }
  23709. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23710. // it returns an error otherwise.
  23711. func (m SopTaskMutation) Tx() (*Tx, error) {
  23712. if _, ok := m.driver.(*txDriver); !ok {
  23713. return nil, errors.New("ent: mutation is not running in a transaction")
  23714. }
  23715. tx := &Tx{config: m.config}
  23716. tx.init()
  23717. return tx, nil
  23718. }
  23719. // SetID sets the value of the id field. Note that this
  23720. // operation is only accepted on creation of SopTask entities.
  23721. func (m *SopTaskMutation) SetID(id uint64) {
  23722. m.id = &id
  23723. }
  23724. // ID returns the ID value in the mutation. Note that the ID is only available
  23725. // if it was provided to the builder or after it was returned from the database.
  23726. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23727. if m.id == nil {
  23728. return
  23729. }
  23730. return *m.id, true
  23731. }
  23732. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23733. // That means, if the mutation is applied within a transaction with an isolation level such
  23734. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23735. // or updated by the mutation.
  23736. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23737. switch {
  23738. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23739. id, exists := m.ID()
  23740. if exists {
  23741. return []uint64{id}, nil
  23742. }
  23743. fallthrough
  23744. case m.op.Is(OpUpdate | OpDelete):
  23745. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23746. default:
  23747. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23748. }
  23749. }
  23750. // SetCreatedAt sets the "created_at" field.
  23751. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23752. m.created_at = &t
  23753. }
  23754. // CreatedAt returns the value of the "created_at" field in the mutation.
  23755. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23756. v := m.created_at
  23757. if v == nil {
  23758. return
  23759. }
  23760. return *v, true
  23761. }
  23762. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23763. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23765. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23766. if !m.op.Is(OpUpdateOne) {
  23767. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23768. }
  23769. if m.id == nil || m.oldValue == nil {
  23770. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23771. }
  23772. oldValue, err := m.oldValue(ctx)
  23773. if err != nil {
  23774. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23775. }
  23776. return oldValue.CreatedAt, nil
  23777. }
  23778. // ResetCreatedAt resets all changes to the "created_at" field.
  23779. func (m *SopTaskMutation) ResetCreatedAt() {
  23780. m.created_at = nil
  23781. }
  23782. // SetUpdatedAt sets the "updated_at" field.
  23783. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23784. m.updated_at = &t
  23785. }
  23786. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23787. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23788. v := m.updated_at
  23789. if v == nil {
  23790. return
  23791. }
  23792. return *v, true
  23793. }
  23794. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23795. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23797. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23798. if !m.op.Is(OpUpdateOne) {
  23799. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23800. }
  23801. if m.id == nil || m.oldValue == nil {
  23802. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23803. }
  23804. oldValue, err := m.oldValue(ctx)
  23805. if err != nil {
  23806. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23807. }
  23808. return oldValue.UpdatedAt, nil
  23809. }
  23810. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23811. func (m *SopTaskMutation) ResetUpdatedAt() {
  23812. m.updated_at = nil
  23813. }
  23814. // SetStatus sets the "status" field.
  23815. func (m *SopTaskMutation) SetStatus(u uint8) {
  23816. m.status = &u
  23817. m.addstatus = nil
  23818. }
  23819. // Status returns the value of the "status" field in the mutation.
  23820. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23821. v := m.status
  23822. if v == nil {
  23823. return
  23824. }
  23825. return *v, true
  23826. }
  23827. // OldStatus returns the old "status" field's value of the SopTask entity.
  23828. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23830. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23831. if !m.op.Is(OpUpdateOne) {
  23832. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23833. }
  23834. if m.id == nil || m.oldValue == nil {
  23835. return v, errors.New("OldStatus requires an ID field in the mutation")
  23836. }
  23837. oldValue, err := m.oldValue(ctx)
  23838. if err != nil {
  23839. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23840. }
  23841. return oldValue.Status, nil
  23842. }
  23843. // AddStatus adds u to the "status" field.
  23844. func (m *SopTaskMutation) AddStatus(u int8) {
  23845. if m.addstatus != nil {
  23846. *m.addstatus += u
  23847. } else {
  23848. m.addstatus = &u
  23849. }
  23850. }
  23851. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23852. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23853. v := m.addstatus
  23854. if v == nil {
  23855. return
  23856. }
  23857. return *v, true
  23858. }
  23859. // ClearStatus clears the value of the "status" field.
  23860. func (m *SopTaskMutation) ClearStatus() {
  23861. m.status = nil
  23862. m.addstatus = nil
  23863. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23864. }
  23865. // StatusCleared returns if the "status" field was cleared in this mutation.
  23866. func (m *SopTaskMutation) StatusCleared() bool {
  23867. _, ok := m.clearedFields[soptask.FieldStatus]
  23868. return ok
  23869. }
  23870. // ResetStatus resets all changes to the "status" field.
  23871. func (m *SopTaskMutation) ResetStatus() {
  23872. m.status = nil
  23873. m.addstatus = nil
  23874. delete(m.clearedFields, soptask.FieldStatus)
  23875. }
  23876. // SetDeletedAt sets the "deleted_at" field.
  23877. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23878. m.deleted_at = &t
  23879. }
  23880. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23881. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23882. v := m.deleted_at
  23883. if v == nil {
  23884. return
  23885. }
  23886. return *v, true
  23887. }
  23888. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23889. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23891. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23892. if !m.op.Is(OpUpdateOne) {
  23893. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23894. }
  23895. if m.id == nil || m.oldValue == nil {
  23896. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23897. }
  23898. oldValue, err := m.oldValue(ctx)
  23899. if err != nil {
  23900. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23901. }
  23902. return oldValue.DeletedAt, nil
  23903. }
  23904. // ClearDeletedAt clears the value of the "deleted_at" field.
  23905. func (m *SopTaskMutation) ClearDeletedAt() {
  23906. m.deleted_at = nil
  23907. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23908. }
  23909. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23910. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23911. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23912. return ok
  23913. }
  23914. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23915. func (m *SopTaskMutation) ResetDeletedAt() {
  23916. m.deleted_at = nil
  23917. delete(m.clearedFields, soptask.FieldDeletedAt)
  23918. }
  23919. // SetName sets the "name" field.
  23920. func (m *SopTaskMutation) SetName(s string) {
  23921. m.name = &s
  23922. }
  23923. // Name returns the value of the "name" field in the mutation.
  23924. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23925. v := m.name
  23926. if v == nil {
  23927. return
  23928. }
  23929. return *v, true
  23930. }
  23931. // OldName returns the old "name" field's value of the SopTask entity.
  23932. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23934. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23935. if !m.op.Is(OpUpdateOne) {
  23936. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23937. }
  23938. if m.id == nil || m.oldValue == nil {
  23939. return v, errors.New("OldName requires an ID field in the mutation")
  23940. }
  23941. oldValue, err := m.oldValue(ctx)
  23942. if err != nil {
  23943. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23944. }
  23945. return oldValue.Name, nil
  23946. }
  23947. // ResetName resets all changes to the "name" field.
  23948. func (m *SopTaskMutation) ResetName() {
  23949. m.name = nil
  23950. }
  23951. // SetBotWxidList sets the "bot_wxid_list" field.
  23952. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23953. m.bot_wxid_list = &s
  23954. m.appendbot_wxid_list = nil
  23955. }
  23956. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23957. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23958. v := m.bot_wxid_list
  23959. if v == nil {
  23960. return
  23961. }
  23962. return *v, true
  23963. }
  23964. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23965. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23967. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23968. if !m.op.Is(OpUpdateOne) {
  23969. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23970. }
  23971. if m.id == nil || m.oldValue == nil {
  23972. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23973. }
  23974. oldValue, err := m.oldValue(ctx)
  23975. if err != nil {
  23976. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23977. }
  23978. return oldValue.BotWxidList, nil
  23979. }
  23980. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23981. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23982. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23983. }
  23984. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23985. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23986. if len(m.appendbot_wxid_list) == 0 {
  23987. return nil, false
  23988. }
  23989. return m.appendbot_wxid_list, true
  23990. }
  23991. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23992. func (m *SopTaskMutation) ClearBotWxidList() {
  23993. m.bot_wxid_list = nil
  23994. m.appendbot_wxid_list = nil
  23995. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23996. }
  23997. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23998. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23999. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24000. return ok
  24001. }
  24002. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24003. func (m *SopTaskMutation) ResetBotWxidList() {
  24004. m.bot_wxid_list = nil
  24005. m.appendbot_wxid_list = nil
  24006. delete(m.clearedFields, soptask.FieldBotWxidList)
  24007. }
  24008. // SetType sets the "type" field.
  24009. func (m *SopTaskMutation) SetType(i int) {
  24010. m._type = &i
  24011. m.add_type = nil
  24012. }
  24013. // GetType returns the value of the "type" field in the mutation.
  24014. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24015. v := m._type
  24016. if v == nil {
  24017. return
  24018. }
  24019. return *v, true
  24020. }
  24021. // OldType returns the old "type" field's value of the SopTask entity.
  24022. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24024. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24025. if !m.op.Is(OpUpdateOne) {
  24026. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24027. }
  24028. if m.id == nil || m.oldValue == nil {
  24029. return v, errors.New("OldType requires an ID field in the mutation")
  24030. }
  24031. oldValue, err := m.oldValue(ctx)
  24032. if err != nil {
  24033. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24034. }
  24035. return oldValue.Type, nil
  24036. }
  24037. // AddType adds i to the "type" field.
  24038. func (m *SopTaskMutation) AddType(i int) {
  24039. if m.add_type != nil {
  24040. *m.add_type += i
  24041. } else {
  24042. m.add_type = &i
  24043. }
  24044. }
  24045. // AddedType returns the value that was added to the "type" field in this mutation.
  24046. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24047. v := m.add_type
  24048. if v == nil {
  24049. return
  24050. }
  24051. return *v, true
  24052. }
  24053. // ResetType resets all changes to the "type" field.
  24054. func (m *SopTaskMutation) ResetType() {
  24055. m._type = nil
  24056. m.add_type = nil
  24057. }
  24058. // SetPlanStartTime sets the "plan_start_time" field.
  24059. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24060. m.plan_start_time = &t
  24061. }
  24062. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24063. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24064. v := m.plan_start_time
  24065. if v == nil {
  24066. return
  24067. }
  24068. return *v, true
  24069. }
  24070. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24071. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24073. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24074. if !m.op.Is(OpUpdateOne) {
  24075. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24076. }
  24077. if m.id == nil || m.oldValue == nil {
  24078. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24079. }
  24080. oldValue, err := m.oldValue(ctx)
  24081. if err != nil {
  24082. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24083. }
  24084. return oldValue.PlanStartTime, nil
  24085. }
  24086. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24087. func (m *SopTaskMutation) ClearPlanStartTime() {
  24088. m.plan_start_time = nil
  24089. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24090. }
  24091. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24092. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24093. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24094. return ok
  24095. }
  24096. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24097. func (m *SopTaskMutation) ResetPlanStartTime() {
  24098. m.plan_start_time = nil
  24099. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24100. }
  24101. // SetPlanEndTime sets the "plan_end_time" field.
  24102. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24103. m.plan_end_time = &t
  24104. }
  24105. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24106. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24107. v := m.plan_end_time
  24108. if v == nil {
  24109. return
  24110. }
  24111. return *v, true
  24112. }
  24113. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24114. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24116. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24117. if !m.op.Is(OpUpdateOne) {
  24118. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24119. }
  24120. if m.id == nil || m.oldValue == nil {
  24121. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24122. }
  24123. oldValue, err := m.oldValue(ctx)
  24124. if err != nil {
  24125. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24126. }
  24127. return oldValue.PlanEndTime, nil
  24128. }
  24129. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24130. func (m *SopTaskMutation) ClearPlanEndTime() {
  24131. m.plan_end_time = nil
  24132. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24133. }
  24134. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24135. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24136. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24137. return ok
  24138. }
  24139. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24140. func (m *SopTaskMutation) ResetPlanEndTime() {
  24141. m.plan_end_time = nil
  24142. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24143. }
  24144. // SetCreatorID sets the "creator_id" field.
  24145. func (m *SopTaskMutation) SetCreatorID(s string) {
  24146. m.creator_id = &s
  24147. }
  24148. // CreatorID returns the value of the "creator_id" field in the mutation.
  24149. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24150. v := m.creator_id
  24151. if v == nil {
  24152. return
  24153. }
  24154. return *v, true
  24155. }
  24156. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24157. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24159. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24160. if !m.op.Is(OpUpdateOne) {
  24161. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24162. }
  24163. if m.id == nil || m.oldValue == nil {
  24164. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24165. }
  24166. oldValue, err := m.oldValue(ctx)
  24167. if err != nil {
  24168. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24169. }
  24170. return oldValue.CreatorID, nil
  24171. }
  24172. // ClearCreatorID clears the value of the "creator_id" field.
  24173. func (m *SopTaskMutation) ClearCreatorID() {
  24174. m.creator_id = nil
  24175. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24176. }
  24177. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24178. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24179. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24180. return ok
  24181. }
  24182. // ResetCreatorID resets all changes to the "creator_id" field.
  24183. func (m *SopTaskMutation) ResetCreatorID() {
  24184. m.creator_id = nil
  24185. delete(m.clearedFields, soptask.FieldCreatorID)
  24186. }
  24187. // SetOrganizationID sets the "organization_id" field.
  24188. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24189. m.organization_id = &u
  24190. m.addorganization_id = nil
  24191. }
  24192. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24193. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24194. v := m.organization_id
  24195. if v == nil {
  24196. return
  24197. }
  24198. return *v, true
  24199. }
  24200. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24201. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24203. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24204. if !m.op.Is(OpUpdateOne) {
  24205. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24206. }
  24207. if m.id == nil || m.oldValue == nil {
  24208. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24209. }
  24210. oldValue, err := m.oldValue(ctx)
  24211. if err != nil {
  24212. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24213. }
  24214. return oldValue.OrganizationID, nil
  24215. }
  24216. // AddOrganizationID adds u to the "organization_id" field.
  24217. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24218. if m.addorganization_id != nil {
  24219. *m.addorganization_id += u
  24220. } else {
  24221. m.addorganization_id = &u
  24222. }
  24223. }
  24224. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24225. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24226. v := m.addorganization_id
  24227. if v == nil {
  24228. return
  24229. }
  24230. return *v, true
  24231. }
  24232. // ClearOrganizationID clears the value of the "organization_id" field.
  24233. func (m *SopTaskMutation) ClearOrganizationID() {
  24234. m.organization_id = nil
  24235. m.addorganization_id = nil
  24236. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24237. }
  24238. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24239. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24240. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24241. return ok
  24242. }
  24243. // ResetOrganizationID resets all changes to the "organization_id" field.
  24244. func (m *SopTaskMutation) ResetOrganizationID() {
  24245. m.organization_id = nil
  24246. m.addorganization_id = nil
  24247. delete(m.clearedFields, soptask.FieldOrganizationID)
  24248. }
  24249. // SetToken sets the "token" field.
  24250. func (m *SopTaskMutation) SetToken(s []string) {
  24251. m.token = &s
  24252. m.appendtoken = nil
  24253. }
  24254. // Token returns the value of the "token" field in the mutation.
  24255. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24256. v := m.token
  24257. if v == nil {
  24258. return
  24259. }
  24260. return *v, true
  24261. }
  24262. // OldToken returns the old "token" field's value of the SopTask entity.
  24263. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24265. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24266. if !m.op.Is(OpUpdateOne) {
  24267. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24268. }
  24269. if m.id == nil || m.oldValue == nil {
  24270. return v, errors.New("OldToken requires an ID field in the mutation")
  24271. }
  24272. oldValue, err := m.oldValue(ctx)
  24273. if err != nil {
  24274. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24275. }
  24276. return oldValue.Token, nil
  24277. }
  24278. // AppendToken adds s to the "token" field.
  24279. func (m *SopTaskMutation) AppendToken(s []string) {
  24280. m.appendtoken = append(m.appendtoken, s...)
  24281. }
  24282. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24283. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24284. if len(m.appendtoken) == 0 {
  24285. return nil, false
  24286. }
  24287. return m.appendtoken, true
  24288. }
  24289. // ClearToken clears the value of the "token" field.
  24290. func (m *SopTaskMutation) ClearToken() {
  24291. m.token = nil
  24292. m.appendtoken = nil
  24293. m.clearedFields[soptask.FieldToken] = struct{}{}
  24294. }
  24295. // TokenCleared returns if the "token" field was cleared in this mutation.
  24296. func (m *SopTaskMutation) TokenCleared() bool {
  24297. _, ok := m.clearedFields[soptask.FieldToken]
  24298. return ok
  24299. }
  24300. // ResetToken resets all changes to the "token" field.
  24301. func (m *SopTaskMutation) ResetToken() {
  24302. m.token = nil
  24303. m.appendtoken = nil
  24304. delete(m.clearedFields, soptask.FieldToken)
  24305. }
  24306. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24307. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24308. if m.task_stages == nil {
  24309. m.task_stages = make(map[uint64]struct{})
  24310. }
  24311. for i := range ids {
  24312. m.task_stages[ids[i]] = struct{}{}
  24313. }
  24314. }
  24315. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24316. func (m *SopTaskMutation) ClearTaskStages() {
  24317. m.clearedtask_stages = true
  24318. }
  24319. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24320. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24321. return m.clearedtask_stages
  24322. }
  24323. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24324. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24325. if m.removedtask_stages == nil {
  24326. m.removedtask_stages = make(map[uint64]struct{})
  24327. }
  24328. for i := range ids {
  24329. delete(m.task_stages, ids[i])
  24330. m.removedtask_stages[ids[i]] = struct{}{}
  24331. }
  24332. }
  24333. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24334. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24335. for id := range m.removedtask_stages {
  24336. ids = append(ids, id)
  24337. }
  24338. return
  24339. }
  24340. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24341. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24342. for id := range m.task_stages {
  24343. ids = append(ids, id)
  24344. }
  24345. return
  24346. }
  24347. // ResetTaskStages resets all changes to the "task_stages" edge.
  24348. func (m *SopTaskMutation) ResetTaskStages() {
  24349. m.task_stages = nil
  24350. m.clearedtask_stages = false
  24351. m.removedtask_stages = nil
  24352. }
  24353. // Where appends a list predicates to the SopTaskMutation builder.
  24354. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24355. m.predicates = append(m.predicates, ps...)
  24356. }
  24357. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24358. // users can use type-assertion to append predicates that do not depend on any generated package.
  24359. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24360. p := make([]predicate.SopTask, len(ps))
  24361. for i := range ps {
  24362. p[i] = ps[i]
  24363. }
  24364. m.Where(p...)
  24365. }
  24366. // Op returns the operation name.
  24367. func (m *SopTaskMutation) Op() Op {
  24368. return m.op
  24369. }
  24370. // SetOp allows setting the mutation operation.
  24371. func (m *SopTaskMutation) SetOp(op Op) {
  24372. m.op = op
  24373. }
  24374. // Type returns the node type of this mutation (SopTask).
  24375. func (m *SopTaskMutation) Type() string {
  24376. return m.typ
  24377. }
  24378. // Fields returns all fields that were changed during this mutation. Note that in
  24379. // order to get all numeric fields that were incremented/decremented, call
  24380. // AddedFields().
  24381. func (m *SopTaskMutation) Fields() []string {
  24382. fields := make([]string, 0, 12)
  24383. if m.created_at != nil {
  24384. fields = append(fields, soptask.FieldCreatedAt)
  24385. }
  24386. if m.updated_at != nil {
  24387. fields = append(fields, soptask.FieldUpdatedAt)
  24388. }
  24389. if m.status != nil {
  24390. fields = append(fields, soptask.FieldStatus)
  24391. }
  24392. if m.deleted_at != nil {
  24393. fields = append(fields, soptask.FieldDeletedAt)
  24394. }
  24395. if m.name != nil {
  24396. fields = append(fields, soptask.FieldName)
  24397. }
  24398. if m.bot_wxid_list != nil {
  24399. fields = append(fields, soptask.FieldBotWxidList)
  24400. }
  24401. if m._type != nil {
  24402. fields = append(fields, soptask.FieldType)
  24403. }
  24404. if m.plan_start_time != nil {
  24405. fields = append(fields, soptask.FieldPlanStartTime)
  24406. }
  24407. if m.plan_end_time != nil {
  24408. fields = append(fields, soptask.FieldPlanEndTime)
  24409. }
  24410. if m.creator_id != nil {
  24411. fields = append(fields, soptask.FieldCreatorID)
  24412. }
  24413. if m.organization_id != nil {
  24414. fields = append(fields, soptask.FieldOrganizationID)
  24415. }
  24416. if m.token != nil {
  24417. fields = append(fields, soptask.FieldToken)
  24418. }
  24419. return fields
  24420. }
  24421. // Field returns the value of a field with the given name. The second boolean
  24422. // return value indicates that this field was not set, or was not defined in the
  24423. // schema.
  24424. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24425. switch name {
  24426. case soptask.FieldCreatedAt:
  24427. return m.CreatedAt()
  24428. case soptask.FieldUpdatedAt:
  24429. return m.UpdatedAt()
  24430. case soptask.FieldStatus:
  24431. return m.Status()
  24432. case soptask.FieldDeletedAt:
  24433. return m.DeletedAt()
  24434. case soptask.FieldName:
  24435. return m.Name()
  24436. case soptask.FieldBotWxidList:
  24437. return m.BotWxidList()
  24438. case soptask.FieldType:
  24439. return m.GetType()
  24440. case soptask.FieldPlanStartTime:
  24441. return m.PlanStartTime()
  24442. case soptask.FieldPlanEndTime:
  24443. return m.PlanEndTime()
  24444. case soptask.FieldCreatorID:
  24445. return m.CreatorID()
  24446. case soptask.FieldOrganizationID:
  24447. return m.OrganizationID()
  24448. case soptask.FieldToken:
  24449. return m.Token()
  24450. }
  24451. return nil, false
  24452. }
  24453. // OldField returns the old value of the field from the database. An error is
  24454. // returned if the mutation operation is not UpdateOne, or the query to the
  24455. // database failed.
  24456. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24457. switch name {
  24458. case soptask.FieldCreatedAt:
  24459. return m.OldCreatedAt(ctx)
  24460. case soptask.FieldUpdatedAt:
  24461. return m.OldUpdatedAt(ctx)
  24462. case soptask.FieldStatus:
  24463. return m.OldStatus(ctx)
  24464. case soptask.FieldDeletedAt:
  24465. return m.OldDeletedAt(ctx)
  24466. case soptask.FieldName:
  24467. return m.OldName(ctx)
  24468. case soptask.FieldBotWxidList:
  24469. return m.OldBotWxidList(ctx)
  24470. case soptask.FieldType:
  24471. return m.OldType(ctx)
  24472. case soptask.FieldPlanStartTime:
  24473. return m.OldPlanStartTime(ctx)
  24474. case soptask.FieldPlanEndTime:
  24475. return m.OldPlanEndTime(ctx)
  24476. case soptask.FieldCreatorID:
  24477. return m.OldCreatorID(ctx)
  24478. case soptask.FieldOrganizationID:
  24479. return m.OldOrganizationID(ctx)
  24480. case soptask.FieldToken:
  24481. return m.OldToken(ctx)
  24482. }
  24483. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24484. }
  24485. // SetField sets the value of a field with the given name. It returns an error if
  24486. // the field is not defined in the schema, or if the type mismatched the field
  24487. // type.
  24488. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24489. switch name {
  24490. case soptask.FieldCreatedAt:
  24491. v, ok := value.(time.Time)
  24492. if !ok {
  24493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24494. }
  24495. m.SetCreatedAt(v)
  24496. return nil
  24497. case soptask.FieldUpdatedAt:
  24498. v, ok := value.(time.Time)
  24499. if !ok {
  24500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24501. }
  24502. m.SetUpdatedAt(v)
  24503. return nil
  24504. case soptask.FieldStatus:
  24505. v, ok := value.(uint8)
  24506. if !ok {
  24507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24508. }
  24509. m.SetStatus(v)
  24510. return nil
  24511. case soptask.FieldDeletedAt:
  24512. v, ok := value.(time.Time)
  24513. if !ok {
  24514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24515. }
  24516. m.SetDeletedAt(v)
  24517. return nil
  24518. case soptask.FieldName:
  24519. v, ok := value.(string)
  24520. if !ok {
  24521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24522. }
  24523. m.SetName(v)
  24524. return nil
  24525. case soptask.FieldBotWxidList:
  24526. v, ok := value.([]string)
  24527. if !ok {
  24528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24529. }
  24530. m.SetBotWxidList(v)
  24531. return nil
  24532. case soptask.FieldType:
  24533. v, ok := value.(int)
  24534. if !ok {
  24535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24536. }
  24537. m.SetType(v)
  24538. return nil
  24539. case soptask.FieldPlanStartTime:
  24540. v, ok := value.(time.Time)
  24541. if !ok {
  24542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24543. }
  24544. m.SetPlanStartTime(v)
  24545. return nil
  24546. case soptask.FieldPlanEndTime:
  24547. v, ok := value.(time.Time)
  24548. if !ok {
  24549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24550. }
  24551. m.SetPlanEndTime(v)
  24552. return nil
  24553. case soptask.FieldCreatorID:
  24554. v, ok := value.(string)
  24555. if !ok {
  24556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24557. }
  24558. m.SetCreatorID(v)
  24559. return nil
  24560. case soptask.FieldOrganizationID:
  24561. v, ok := value.(uint64)
  24562. if !ok {
  24563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24564. }
  24565. m.SetOrganizationID(v)
  24566. return nil
  24567. case soptask.FieldToken:
  24568. v, ok := value.([]string)
  24569. if !ok {
  24570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24571. }
  24572. m.SetToken(v)
  24573. return nil
  24574. }
  24575. return fmt.Errorf("unknown SopTask field %s", name)
  24576. }
  24577. // AddedFields returns all numeric fields that were incremented/decremented during
  24578. // this mutation.
  24579. func (m *SopTaskMutation) AddedFields() []string {
  24580. var fields []string
  24581. if m.addstatus != nil {
  24582. fields = append(fields, soptask.FieldStatus)
  24583. }
  24584. if m.add_type != nil {
  24585. fields = append(fields, soptask.FieldType)
  24586. }
  24587. if m.addorganization_id != nil {
  24588. fields = append(fields, soptask.FieldOrganizationID)
  24589. }
  24590. return fields
  24591. }
  24592. // AddedField returns the numeric value that was incremented/decremented on a field
  24593. // with the given name. The second boolean return value indicates that this field
  24594. // was not set, or was not defined in the schema.
  24595. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24596. switch name {
  24597. case soptask.FieldStatus:
  24598. return m.AddedStatus()
  24599. case soptask.FieldType:
  24600. return m.AddedType()
  24601. case soptask.FieldOrganizationID:
  24602. return m.AddedOrganizationID()
  24603. }
  24604. return nil, false
  24605. }
  24606. // AddField adds the value to the field with the given name. It returns an error if
  24607. // the field is not defined in the schema, or if the type mismatched the field
  24608. // type.
  24609. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24610. switch name {
  24611. case soptask.FieldStatus:
  24612. v, ok := value.(int8)
  24613. if !ok {
  24614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24615. }
  24616. m.AddStatus(v)
  24617. return nil
  24618. case soptask.FieldType:
  24619. v, ok := value.(int)
  24620. if !ok {
  24621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24622. }
  24623. m.AddType(v)
  24624. return nil
  24625. case soptask.FieldOrganizationID:
  24626. v, ok := value.(int64)
  24627. if !ok {
  24628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24629. }
  24630. m.AddOrganizationID(v)
  24631. return nil
  24632. }
  24633. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24634. }
  24635. // ClearedFields returns all nullable fields that were cleared during this
  24636. // mutation.
  24637. func (m *SopTaskMutation) ClearedFields() []string {
  24638. var fields []string
  24639. if m.FieldCleared(soptask.FieldStatus) {
  24640. fields = append(fields, soptask.FieldStatus)
  24641. }
  24642. if m.FieldCleared(soptask.FieldDeletedAt) {
  24643. fields = append(fields, soptask.FieldDeletedAt)
  24644. }
  24645. if m.FieldCleared(soptask.FieldBotWxidList) {
  24646. fields = append(fields, soptask.FieldBotWxidList)
  24647. }
  24648. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24649. fields = append(fields, soptask.FieldPlanStartTime)
  24650. }
  24651. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24652. fields = append(fields, soptask.FieldPlanEndTime)
  24653. }
  24654. if m.FieldCleared(soptask.FieldCreatorID) {
  24655. fields = append(fields, soptask.FieldCreatorID)
  24656. }
  24657. if m.FieldCleared(soptask.FieldOrganizationID) {
  24658. fields = append(fields, soptask.FieldOrganizationID)
  24659. }
  24660. if m.FieldCleared(soptask.FieldToken) {
  24661. fields = append(fields, soptask.FieldToken)
  24662. }
  24663. return fields
  24664. }
  24665. // FieldCleared returns a boolean indicating if a field with the given name was
  24666. // cleared in this mutation.
  24667. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24668. _, ok := m.clearedFields[name]
  24669. return ok
  24670. }
  24671. // ClearField clears the value of the field with the given name. It returns an
  24672. // error if the field is not defined in the schema.
  24673. func (m *SopTaskMutation) ClearField(name string) error {
  24674. switch name {
  24675. case soptask.FieldStatus:
  24676. m.ClearStatus()
  24677. return nil
  24678. case soptask.FieldDeletedAt:
  24679. m.ClearDeletedAt()
  24680. return nil
  24681. case soptask.FieldBotWxidList:
  24682. m.ClearBotWxidList()
  24683. return nil
  24684. case soptask.FieldPlanStartTime:
  24685. m.ClearPlanStartTime()
  24686. return nil
  24687. case soptask.FieldPlanEndTime:
  24688. m.ClearPlanEndTime()
  24689. return nil
  24690. case soptask.FieldCreatorID:
  24691. m.ClearCreatorID()
  24692. return nil
  24693. case soptask.FieldOrganizationID:
  24694. m.ClearOrganizationID()
  24695. return nil
  24696. case soptask.FieldToken:
  24697. m.ClearToken()
  24698. return nil
  24699. }
  24700. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24701. }
  24702. // ResetField resets all changes in the mutation for the field with the given name.
  24703. // It returns an error if the field is not defined in the schema.
  24704. func (m *SopTaskMutation) ResetField(name string) error {
  24705. switch name {
  24706. case soptask.FieldCreatedAt:
  24707. m.ResetCreatedAt()
  24708. return nil
  24709. case soptask.FieldUpdatedAt:
  24710. m.ResetUpdatedAt()
  24711. return nil
  24712. case soptask.FieldStatus:
  24713. m.ResetStatus()
  24714. return nil
  24715. case soptask.FieldDeletedAt:
  24716. m.ResetDeletedAt()
  24717. return nil
  24718. case soptask.FieldName:
  24719. m.ResetName()
  24720. return nil
  24721. case soptask.FieldBotWxidList:
  24722. m.ResetBotWxidList()
  24723. return nil
  24724. case soptask.FieldType:
  24725. m.ResetType()
  24726. return nil
  24727. case soptask.FieldPlanStartTime:
  24728. m.ResetPlanStartTime()
  24729. return nil
  24730. case soptask.FieldPlanEndTime:
  24731. m.ResetPlanEndTime()
  24732. return nil
  24733. case soptask.FieldCreatorID:
  24734. m.ResetCreatorID()
  24735. return nil
  24736. case soptask.FieldOrganizationID:
  24737. m.ResetOrganizationID()
  24738. return nil
  24739. case soptask.FieldToken:
  24740. m.ResetToken()
  24741. return nil
  24742. }
  24743. return fmt.Errorf("unknown SopTask field %s", name)
  24744. }
  24745. // AddedEdges returns all edge names that were set/added in this mutation.
  24746. func (m *SopTaskMutation) AddedEdges() []string {
  24747. edges := make([]string, 0, 1)
  24748. if m.task_stages != nil {
  24749. edges = append(edges, soptask.EdgeTaskStages)
  24750. }
  24751. return edges
  24752. }
  24753. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24754. // name in this mutation.
  24755. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24756. switch name {
  24757. case soptask.EdgeTaskStages:
  24758. ids := make([]ent.Value, 0, len(m.task_stages))
  24759. for id := range m.task_stages {
  24760. ids = append(ids, id)
  24761. }
  24762. return ids
  24763. }
  24764. return nil
  24765. }
  24766. // RemovedEdges returns all edge names that were removed in this mutation.
  24767. func (m *SopTaskMutation) RemovedEdges() []string {
  24768. edges := make([]string, 0, 1)
  24769. if m.removedtask_stages != nil {
  24770. edges = append(edges, soptask.EdgeTaskStages)
  24771. }
  24772. return edges
  24773. }
  24774. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24775. // the given name in this mutation.
  24776. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24777. switch name {
  24778. case soptask.EdgeTaskStages:
  24779. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24780. for id := range m.removedtask_stages {
  24781. ids = append(ids, id)
  24782. }
  24783. return ids
  24784. }
  24785. return nil
  24786. }
  24787. // ClearedEdges returns all edge names that were cleared in this mutation.
  24788. func (m *SopTaskMutation) ClearedEdges() []string {
  24789. edges := make([]string, 0, 1)
  24790. if m.clearedtask_stages {
  24791. edges = append(edges, soptask.EdgeTaskStages)
  24792. }
  24793. return edges
  24794. }
  24795. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24796. // was cleared in this mutation.
  24797. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24798. switch name {
  24799. case soptask.EdgeTaskStages:
  24800. return m.clearedtask_stages
  24801. }
  24802. return false
  24803. }
  24804. // ClearEdge clears the value of the edge with the given name. It returns an error
  24805. // if that edge is not defined in the schema.
  24806. func (m *SopTaskMutation) ClearEdge(name string) error {
  24807. switch name {
  24808. }
  24809. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24810. }
  24811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24812. // It returns an error if the edge is not defined in the schema.
  24813. func (m *SopTaskMutation) ResetEdge(name string) error {
  24814. switch name {
  24815. case soptask.EdgeTaskStages:
  24816. m.ResetTaskStages()
  24817. return nil
  24818. }
  24819. return fmt.Errorf("unknown SopTask edge %s", name)
  24820. }
  24821. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24822. type TokenMutation struct {
  24823. config
  24824. op Op
  24825. typ string
  24826. id *uint64
  24827. created_at *time.Time
  24828. updated_at *time.Time
  24829. deleted_at *time.Time
  24830. expire_at *time.Time
  24831. token *string
  24832. mac *string
  24833. organization_id *uint64
  24834. addorganization_id *int64
  24835. custom_agent_base *string
  24836. custom_agent_key *string
  24837. openai_base *string
  24838. openai_key *string
  24839. clearedFields map[string]struct{}
  24840. agent *uint64
  24841. clearedagent bool
  24842. done bool
  24843. oldValue func(context.Context) (*Token, error)
  24844. predicates []predicate.Token
  24845. }
  24846. var _ ent.Mutation = (*TokenMutation)(nil)
  24847. // tokenOption allows management of the mutation configuration using functional options.
  24848. type tokenOption func(*TokenMutation)
  24849. // newTokenMutation creates new mutation for the Token entity.
  24850. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24851. m := &TokenMutation{
  24852. config: c,
  24853. op: op,
  24854. typ: TypeToken,
  24855. clearedFields: make(map[string]struct{}),
  24856. }
  24857. for _, opt := range opts {
  24858. opt(m)
  24859. }
  24860. return m
  24861. }
  24862. // withTokenID sets the ID field of the mutation.
  24863. func withTokenID(id uint64) tokenOption {
  24864. return func(m *TokenMutation) {
  24865. var (
  24866. err error
  24867. once sync.Once
  24868. value *Token
  24869. )
  24870. m.oldValue = func(ctx context.Context) (*Token, error) {
  24871. once.Do(func() {
  24872. if m.done {
  24873. err = errors.New("querying old values post mutation is not allowed")
  24874. } else {
  24875. value, err = m.Client().Token.Get(ctx, id)
  24876. }
  24877. })
  24878. return value, err
  24879. }
  24880. m.id = &id
  24881. }
  24882. }
  24883. // withToken sets the old Token of the mutation.
  24884. func withToken(node *Token) tokenOption {
  24885. return func(m *TokenMutation) {
  24886. m.oldValue = func(context.Context) (*Token, error) {
  24887. return node, nil
  24888. }
  24889. m.id = &node.ID
  24890. }
  24891. }
  24892. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24893. // executed in a transaction (ent.Tx), a transactional client is returned.
  24894. func (m TokenMutation) Client() *Client {
  24895. client := &Client{config: m.config}
  24896. client.init()
  24897. return client
  24898. }
  24899. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24900. // it returns an error otherwise.
  24901. func (m TokenMutation) Tx() (*Tx, error) {
  24902. if _, ok := m.driver.(*txDriver); !ok {
  24903. return nil, errors.New("ent: mutation is not running in a transaction")
  24904. }
  24905. tx := &Tx{config: m.config}
  24906. tx.init()
  24907. return tx, nil
  24908. }
  24909. // SetID sets the value of the id field. Note that this
  24910. // operation is only accepted on creation of Token entities.
  24911. func (m *TokenMutation) SetID(id uint64) {
  24912. m.id = &id
  24913. }
  24914. // ID returns the ID value in the mutation. Note that the ID is only available
  24915. // if it was provided to the builder or after it was returned from the database.
  24916. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24917. if m.id == nil {
  24918. return
  24919. }
  24920. return *m.id, true
  24921. }
  24922. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24923. // That means, if the mutation is applied within a transaction with an isolation level such
  24924. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24925. // or updated by the mutation.
  24926. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24927. switch {
  24928. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24929. id, exists := m.ID()
  24930. if exists {
  24931. return []uint64{id}, nil
  24932. }
  24933. fallthrough
  24934. case m.op.Is(OpUpdate | OpDelete):
  24935. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24936. default:
  24937. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24938. }
  24939. }
  24940. // SetCreatedAt sets the "created_at" field.
  24941. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24942. m.created_at = &t
  24943. }
  24944. // CreatedAt returns the value of the "created_at" field in the mutation.
  24945. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24946. v := m.created_at
  24947. if v == nil {
  24948. return
  24949. }
  24950. return *v, true
  24951. }
  24952. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24953. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24955. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24956. if !m.op.Is(OpUpdateOne) {
  24957. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24958. }
  24959. if m.id == nil || m.oldValue == nil {
  24960. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24961. }
  24962. oldValue, err := m.oldValue(ctx)
  24963. if err != nil {
  24964. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24965. }
  24966. return oldValue.CreatedAt, nil
  24967. }
  24968. // ResetCreatedAt resets all changes to the "created_at" field.
  24969. func (m *TokenMutation) ResetCreatedAt() {
  24970. m.created_at = nil
  24971. }
  24972. // SetUpdatedAt sets the "updated_at" field.
  24973. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24974. m.updated_at = &t
  24975. }
  24976. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24977. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24978. v := m.updated_at
  24979. if v == nil {
  24980. return
  24981. }
  24982. return *v, true
  24983. }
  24984. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24985. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24987. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24988. if !m.op.Is(OpUpdateOne) {
  24989. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24990. }
  24991. if m.id == nil || m.oldValue == nil {
  24992. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24993. }
  24994. oldValue, err := m.oldValue(ctx)
  24995. if err != nil {
  24996. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24997. }
  24998. return oldValue.UpdatedAt, nil
  24999. }
  25000. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25001. func (m *TokenMutation) ResetUpdatedAt() {
  25002. m.updated_at = nil
  25003. }
  25004. // SetDeletedAt sets the "deleted_at" field.
  25005. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25006. m.deleted_at = &t
  25007. }
  25008. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25009. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25010. v := m.deleted_at
  25011. if v == nil {
  25012. return
  25013. }
  25014. return *v, true
  25015. }
  25016. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25017. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25019. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25020. if !m.op.Is(OpUpdateOne) {
  25021. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25022. }
  25023. if m.id == nil || m.oldValue == nil {
  25024. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25025. }
  25026. oldValue, err := m.oldValue(ctx)
  25027. if err != nil {
  25028. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25029. }
  25030. return oldValue.DeletedAt, nil
  25031. }
  25032. // ClearDeletedAt clears the value of the "deleted_at" field.
  25033. func (m *TokenMutation) ClearDeletedAt() {
  25034. m.deleted_at = nil
  25035. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25036. }
  25037. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25038. func (m *TokenMutation) DeletedAtCleared() bool {
  25039. _, ok := m.clearedFields[token.FieldDeletedAt]
  25040. return ok
  25041. }
  25042. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25043. func (m *TokenMutation) ResetDeletedAt() {
  25044. m.deleted_at = nil
  25045. delete(m.clearedFields, token.FieldDeletedAt)
  25046. }
  25047. // SetExpireAt sets the "expire_at" field.
  25048. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25049. m.expire_at = &t
  25050. }
  25051. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25052. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25053. v := m.expire_at
  25054. if v == nil {
  25055. return
  25056. }
  25057. return *v, true
  25058. }
  25059. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25060. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25062. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25063. if !m.op.Is(OpUpdateOne) {
  25064. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25065. }
  25066. if m.id == nil || m.oldValue == nil {
  25067. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25068. }
  25069. oldValue, err := m.oldValue(ctx)
  25070. if err != nil {
  25071. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25072. }
  25073. return oldValue.ExpireAt, nil
  25074. }
  25075. // ClearExpireAt clears the value of the "expire_at" field.
  25076. func (m *TokenMutation) ClearExpireAt() {
  25077. m.expire_at = nil
  25078. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25079. }
  25080. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25081. func (m *TokenMutation) ExpireAtCleared() bool {
  25082. _, ok := m.clearedFields[token.FieldExpireAt]
  25083. return ok
  25084. }
  25085. // ResetExpireAt resets all changes to the "expire_at" field.
  25086. func (m *TokenMutation) ResetExpireAt() {
  25087. m.expire_at = nil
  25088. delete(m.clearedFields, token.FieldExpireAt)
  25089. }
  25090. // SetToken sets the "token" field.
  25091. func (m *TokenMutation) SetToken(s string) {
  25092. m.token = &s
  25093. }
  25094. // Token returns the value of the "token" field in the mutation.
  25095. func (m *TokenMutation) Token() (r string, exists bool) {
  25096. v := m.token
  25097. if v == nil {
  25098. return
  25099. }
  25100. return *v, true
  25101. }
  25102. // OldToken returns the old "token" field's value of the Token entity.
  25103. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25105. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25106. if !m.op.Is(OpUpdateOne) {
  25107. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25108. }
  25109. if m.id == nil || m.oldValue == nil {
  25110. return v, errors.New("OldToken requires an ID field in the mutation")
  25111. }
  25112. oldValue, err := m.oldValue(ctx)
  25113. if err != nil {
  25114. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25115. }
  25116. return oldValue.Token, nil
  25117. }
  25118. // ClearToken clears the value of the "token" field.
  25119. func (m *TokenMutation) ClearToken() {
  25120. m.token = nil
  25121. m.clearedFields[token.FieldToken] = struct{}{}
  25122. }
  25123. // TokenCleared returns if the "token" field was cleared in this mutation.
  25124. func (m *TokenMutation) TokenCleared() bool {
  25125. _, ok := m.clearedFields[token.FieldToken]
  25126. return ok
  25127. }
  25128. // ResetToken resets all changes to the "token" field.
  25129. func (m *TokenMutation) ResetToken() {
  25130. m.token = nil
  25131. delete(m.clearedFields, token.FieldToken)
  25132. }
  25133. // SetMAC sets the "mac" field.
  25134. func (m *TokenMutation) SetMAC(s string) {
  25135. m.mac = &s
  25136. }
  25137. // MAC returns the value of the "mac" field in the mutation.
  25138. func (m *TokenMutation) MAC() (r string, exists bool) {
  25139. v := m.mac
  25140. if v == nil {
  25141. return
  25142. }
  25143. return *v, true
  25144. }
  25145. // OldMAC returns the old "mac" field's value of the Token entity.
  25146. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25148. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25149. if !m.op.Is(OpUpdateOne) {
  25150. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25151. }
  25152. if m.id == nil || m.oldValue == nil {
  25153. return v, errors.New("OldMAC requires an ID field in the mutation")
  25154. }
  25155. oldValue, err := m.oldValue(ctx)
  25156. if err != nil {
  25157. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25158. }
  25159. return oldValue.MAC, nil
  25160. }
  25161. // ClearMAC clears the value of the "mac" field.
  25162. func (m *TokenMutation) ClearMAC() {
  25163. m.mac = nil
  25164. m.clearedFields[token.FieldMAC] = struct{}{}
  25165. }
  25166. // MACCleared returns if the "mac" field was cleared in this mutation.
  25167. func (m *TokenMutation) MACCleared() bool {
  25168. _, ok := m.clearedFields[token.FieldMAC]
  25169. return ok
  25170. }
  25171. // ResetMAC resets all changes to the "mac" field.
  25172. func (m *TokenMutation) ResetMAC() {
  25173. m.mac = nil
  25174. delete(m.clearedFields, token.FieldMAC)
  25175. }
  25176. // SetOrganizationID sets the "organization_id" field.
  25177. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25178. m.organization_id = &u
  25179. m.addorganization_id = nil
  25180. }
  25181. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25182. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25183. v := m.organization_id
  25184. if v == nil {
  25185. return
  25186. }
  25187. return *v, true
  25188. }
  25189. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25190. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25192. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25193. if !m.op.Is(OpUpdateOne) {
  25194. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25195. }
  25196. if m.id == nil || m.oldValue == nil {
  25197. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25198. }
  25199. oldValue, err := m.oldValue(ctx)
  25200. if err != nil {
  25201. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25202. }
  25203. return oldValue.OrganizationID, nil
  25204. }
  25205. // AddOrganizationID adds u to the "organization_id" field.
  25206. func (m *TokenMutation) AddOrganizationID(u int64) {
  25207. if m.addorganization_id != nil {
  25208. *m.addorganization_id += u
  25209. } else {
  25210. m.addorganization_id = &u
  25211. }
  25212. }
  25213. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25214. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25215. v := m.addorganization_id
  25216. if v == nil {
  25217. return
  25218. }
  25219. return *v, true
  25220. }
  25221. // ResetOrganizationID resets all changes to the "organization_id" field.
  25222. func (m *TokenMutation) ResetOrganizationID() {
  25223. m.organization_id = nil
  25224. m.addorganization_id = nil
  25225. }
  25226. // SetAgentID sets the "agent_id" field.
  25227. func (m *TokenMutation) SetAgentID(u uint64) {
  25228. m.agent = &u
  25229. }
  25230. // AgentID returns the value of the "agent_id" field in the mutation.
  25231. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25232. v := m.agent
  25233. if v == nil {
  25234. return
  25235. }
  25236. return *v, true
  25237. }
  25238. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25239. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25241. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25242. if !m.op.Is(OpUpdateOne) {
  25243. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25244. }
  25245. if m.id == nil || m.oldValue == nil {
  25246. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25247. }
  25248. oldValue, err := m.oldValue(ctx)
  25249. if err != nil {
  25250. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25251. }
  25252. return oldValue.AgentID, nil
  25253. }
  25254. // ResetAgentID resets all changes to the "agent_id" field.
  25255. func (m *TokenMutation) ResetAgentID() {
  25256. m.agent = nil
  25257. }
  25258. // SetCustomAgentBase sets the "custom_agent_base" field.
  25259. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25260. m.custom_agent_base = &s
  25261. }
  25262. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25263. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25264. v := m.custom_agent_base
  25265. if v == nil {
  25266. return
  25267. }
  25268. return *v, true
  25269. }
  25270. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25271. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25273. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25274. if !m.op.Is(OpUpdateOne) {
  25275. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25276. }
  25277. if m.id == nil || m.oldValue == nil {
  25278. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25279. }
  25280. oldValue, err := m.oldValue(ctx)
  25281. if err != nil {
  25282. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25283. }
  25284. return oldValue.CustomAgentBase, nil
  25285. }
  25286. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25287. func (m *TokenMutation) ClearCustomAgentBase() {
  25288. m.custom_agent_base = nil
  25289. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25290. }
  25291. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25292. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25293. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25294. return ok
  25295. }
  25296. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25297. func (m *TokenMutation) ResetCustomAgentBase() {
  25298. m.custom_agent_base = nil
  25299. delete(m.clearedFields, token.FieldCustomAgentBase)
  25300. }
  25301. // SetCustomAgentKey sets the "custom_agent_key" field.
  25302. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25303. m.custom_agent_key = &s
  25304. }
  25305. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25306. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25307. v := m.custom_agent_key
  25308. if v == nil {
  25309. return
  25310. }
  25311. return *v, true
  25312. }
  25313. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25314. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25316. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25317. if !m.op.Is(OpUpdateOne) {
  25318. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25319. }
  25320. if m.id == nil || m.oldValue == nil {
  25321. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25322. }
  25323. oldValue, err := m.oldValue(ctx)
  25324. if err != nil {
  25325. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25326. }
  25327. return oldValue.CustomAgentKey, nil
  25328. }
  25329. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25330. func (m *TokenMutation) ClearCustomAgentKey() {
  25331. m.custom_agent_key = nil
  25332. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25333. }
  25334. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25335. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25336. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25337. return ok
  25338. }
  25339. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25340. func (m *TokenMutation) ResetCustomAgentKey() {
  25341. m.custom_agent_key = nil
  25342. delete(m.clearedFields, token.FieldCustomAgentKey)
  25343. }
  25344. // SetOpenaiBase sets the "openai_base" field.
  25345. func (m *TokenMutation) SetOpenaiBase(s string) {
  25346. m.openai_base = &s
  25347. }
  25348. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25349. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25350. v := m.openai_base
  25351. if v == nil {
  25352. return
  25353. }
  25354. return *v, true
  25355. }
  25356. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25357. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25359. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25360. if !m.op.Is(OpUpdateOne) {
  25361. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25362. }
  25363. if m.id == nil || m.oldValue == nil {
  25364. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25365. }
  25366. oldValue, err := m.oldValue(ctx)
  25367. if err != nil {
  25368. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25369. }
  25370. return oldValue.OpenaiBase, nil
  25371. }
  25372. // ClearOpenaiBase clears the value of the "openai_base" field.
  25373. func (m *TokenMutation) ClearOpenaiBase() {
  25374. m.openai_base = nil
  25375. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25376. }
  25377. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25378. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25379. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25380. return ok
  25381. }
  25382. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25383. func (m *TokenMutation) ResetOpenaiBase() {
  25384. m.openai_base = nil
  25385. delete(m.clearedFields, token.FieldOpenaiBase)
  25386. }
  25387. // SetOpenaiKey sets the "openai_key" field.
  25388. func (m *TokenMutation) SetOpenaiKey(s string) {
  25389. m.openai_key = &s
  25390. }
  25391. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25392. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25393. v := m.openai_key
  25394. if v == nil {
  25395. return
  25396. }
  25397. return *v, true
  25398. }
  25399. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25400. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25402. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25403. if !m.op.Is(OpUpdateOne) {
  25404. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25405. }
  25406. if m.id == nil || m.oldValue == nil {
  25407. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25408. }
  25409. oldValue, err := m.oldValue(ctx)
  25410. if err != nil {
  25411. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25412. }
  25413. return oldValue.OpenaiKey, nil
  25414. }
  25415. // ClearOpenaiKey clears the value of the "openai_key" field.
  25416. func (m *TokenMutation) ClearOpenaiKey() {
  25417. m.openai_key = nil
  25418. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25419. }
  25420. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25421. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25422. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25423. return ok
  25424. }
  25425. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25426. func (m *TokenMutation) ResetOpenaiKey() {
  25427. m.openai_key = nil
  25428. delete(m.clearedFields, token.FieldOpenaiKey)
  25429. }
  25430. // ClearAgent clears the "agent" edge to the Agent entity.
  25431. func (m *TokenMutation) ClearAgent() {
  25432. m.clearedagent = true
  25433. m.clearedFields[token.FieldAgentID] = struct{}{}
  25434. }
  25435. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25436. func (m *TokenMutation) AgentCleared() bool {
  25437. return m.clearedagent
  25438. }
  25439. // AgentIDs returns the "agent" edge IDs in the mutation.
  25440. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25441. // AgentID instead. It exists only for internal usage by the builders.
  25442. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25443. if id := m.agent; id != nil {
  25444. ids = append(ids, *id)
  25445. }
  25446. return
  25447. }
  25448. // ResetAgent resets all changes to the "agent" edge.
  25449. func (m *TokenMutation) ResetAgent() {
  25450. m.agent = nil
  25451. m.clearedagent = false
  25452. }
  25453. // Where appends a list predicates to the TokenMutation builder.
  25454. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25455. m.predicates = append(m.predicates, ps...)
  25456. }
  25457. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25458. // users can use type-assertion to append predicates that do not depend on any generated package.
  25459. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25460. p := make([]predicate.Token, len(ps))
  25461. for i := range ps {
  25462. p[i] = ps[i]
  25463. }
  25464. m.Where(p...)
  25465. }
  25466. // Op returns the operation name.
  25467. func (m *TokenMutation) Op() Op {
  25468. return m.op
  25469. }
  25470. // SetOp allows setting the mutation operation.
  25471. func (m *TokenMutation) SetOp(op Op) {
  25472. m.op = op
  25473. }
  25474. // Type returns the node type of this mutation (Token).
  25475. func (m *TokenMutation) Type() string {
  25476. return m.typ
  25477. }
  25478. // Fields returns all fields that were changed during this mutation. Note that in
  25479. // order to get all numeric fields that were incremented/decremented, call
  25480. // AddedFields().
  25481. func (m *TokenMutation) Fields() []string {
  25482. fields := make([]string, 0, 12)
  25483. if m.created_at != nil {
  25484. fields = append(fields, token.FieldCreatedAt)
  25485. }
  25486. if m.updated_at != nil {
  25487. fields = append(fields, token.FieldUpdatedAt)
  25488. }
  25489. if m.deleted_at != nil {
  25490. fields = append(fields, token.FieldDeletedAt)
  25491. }
  25492. if m.expire_at != nil {
  25493. fields = append(fields, token.FieldExpireAt)
  25494. }
  25495. if m.token != nil {
  25496. fields = append(fields, token.FieldToken)
  25497. }
  25498. if m.mac != nil {
  25499. fields = append(fields, token.FieldMAC)
  25500. }
  25501. if m.organization_id != nil {
  25502. fields = append(fields, token.FieldOrganizationID)
  25503. }
  25504. if m.agent != nil {
  25505. fields = append(fields, token.FieldAgentID)
  25506. }
  25507. if m.custom_agent_base != nil {
  25508. fields = append(fields, token.FieldCustomAgentBase)
  25509. }
  25510. if m.custom_agent_key != nil {
  25511. fields = append(fields, token.FieldCustomAgentKey)
  25512. }
  25513. if m.openai_base != nil {
  25514. fields = append(fields, token.FieldOpenaiBase)
  25515. }
  25516. if m.openai_key != nil {
  25517. fields = append(fields, token.FieldOpenaiKey)
  25518. }
  25519. return fields
  25520. }
  25521. // Field returns the value of a field with the given name. The second boolean
  25522. // return value indicates that this field was not set, or was not defined in the
  25523. // schema.
  25524. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25525. switch name {
  25526. case token.FieldCreatedAt:
  25527. return m.CreatedAt()
  25528. case token.FieldUpdatedAt:
  25529. return m.UpdatedAt()
  25530. case token.FieldDeletedAt:
  25531. return m.DeletedAt()
  25532. case token.FieldExpireAt:
  25533. return m.ExpireAt()
  25534. case token.FieldToken:
  25535. return m.Token()
  25536. case token.FieldMAC:
  25537. return m.MAC()
  25538. case token.FieldOrganizationID:
  25539. return m.OrganizationID()
  25540. case token.FieldAgentID:
  25541. return m.AgentID()
  25542. case token.FieldCustomAgentBase:
  25543. return m.CustomAgentBase()
  25544. case token.FieldCustomAgentKey:
  25545. return m.CustomAgentKey()
  25546. case token.FieldOpenaiBase:
  25547. return m.OpenaiBase()
  25548. case token.FieldOpenaiKey:
  25549. return m.OpenaiKey()
  25550. }
  25551. return nil, false
  25552. }
  25553. // OldField returns the old value of the field from the database. An error is
  25554. // returned if the mutation operation is not UpdateOne, or the query to the
  25555. // database failed.
  25556. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25557. switch name {
  25558. case token.FieldCreatedAt:
  25559. return m.OldCreatedAt(ctx)
  25560. case token.FieldUpdatedAt:
  25561. return m.OldUpdatedAt(ctx)
  25562. case token.FieldDeletedAt:
  25563. return m.OldDeletedAt(ctx)
  25564. case token.FieldExpireAt:
  25565. return m.OldExpireAt(ctx)
  25566. case token.FieldToken:
  25567. return m.OldToken(ctx)
  25568. case token.FieldMAC:
  25569. return m.OldMAC(ctx)
  25570. case token.FieldOrganizationID:
  25571. return m.OldOrganizationID(ctx)
  25572. case token.FieldAgentID:
  25573. return m.OldAgentID(ctx)
  25574. case token.FieldCustomAgentBase:
  25575. return m.OldCustomAgentBase(ctx)
  25576. case token.FieldCustomAgentKey:
  25577. return m.OldCustomAgentKey(ctx)
  25578. case token.FieldOpenaiBase:
  25579. return m.OldOpenaiBase(ctx)
  25580. case token.FieldOpenaiKey:
  25581. return m.OldOpenaiKey(ctx)
  25582. }
  25583. return nil, fmt.Errorf("unknown Token field %s", name)
  25584. }
  25585. // SetField sets the value of a field with the given name. It returns an error if
  25586. // the field is not defined in the schema, or if the type mismatched the field
  25587. // type.
  25588. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25589. switch name {
  25590. case token.FieldCreatedAt:
  25591. v, ok := value.(time.Time)
  25592. if !ok {
  25593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25594. }
  25595. m.SetCreatedAt(v)
  25596. return nil
  25597. case token.FieldUpdatedAt:
  25598. v, ok := value.(time.Time)
  25599. if !ok {
  25600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25601. }
  25602. m.SetUpdatedAt(v)
  25603. return nil
  25604. case token.FieldDeletedAt:
  25605. v, ok := value.(time.Time)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.SetDeletedAt(v)
  25610. return nil
  25611. case token.FieldExpireAt:
  25612. v, ok := value.(time.Time)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.SetExpireAt(v)
  25617. return nil
  25618. case token.FieldToken:
  25619. v, ok := value.(string)
  25620. if !ok {
  25621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25622. }
  25623. m.SetToken(v)
  25624. return nil
  25625. case token.FieldMAC:
  25626. v, ok := value.(string)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.SetMAC(v)
  25631. return nil
  25632. case token.FieldOrganizationID:
  25633. v, ok := value.(uint64)
  25634. if !ok {
  25635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25636. }
  25637. m.SetOrganizationID(v)
  25638. return nil
  25639. case token.FieldAgentID:
  25640. v, ok := value.(uint64)
  25641. if !ok {
  25642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25643. }
  25644. m.SetAgentID(v)
  25645. return nil
  25646. case token.FieldCustomAgentBase:
  25647. v, ok := value.(string)
  25648. if !ok {
  25649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25650. }
  25651. m.SetCustomAgentBase(v)
  25652. return nil
  25653. case token.FieldCustomAgentKey:
  25654. v, ok := value.(string)
  25655. if !ok {
  25656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25657. }
  25658. m.SetCustomAgentKey(v)
  25659. return nil
  25660. case token.FieldOpenaiBase:
  25661. v, ok := value.(string)
  25662. if !ok {
  25663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25664. }
  25665. m.SetOpenaiBase(v)
  25666. return nil
  25667. case token.FieldOpenaiKey:
  25668. v, ok := value.(string)
  25669. if !ok {
  25670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25671. }
  25672. m.SetOpenaiKey(v)
  25673. return nil
  25674. }
  25675. return fmt.Errorf("unknown Token field %s", name)
  25676. }
  25677. // AddedFields returns all numeric fields that were incremented/decremented during
  25678. // this mutation.
  25679. func (m *TokenMutation) AddedFields() []string {
  25680. var fields []string
  25681. if m.addorganization_id != nil {
  25682. fields = append(fields, token.FieldOrganizationID)
  25683. }
  25684. return fields
  25685. }
  25686. // AddedField returns the numeric value that was incremented/decremented on a field
  25687. // with the given name. The second boolean return value indicates that this field
  25688. // was not set, or was not defined in the schema.
  25689. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25690. switch name {
  25691. case token.FieldOrganizationID:
  25692. return m.AddedOrganizationID()
  25693. }
  25694. return nil, false
  25695. }
  25696. // AddField adds the value to the field with the given name. It returns an error if
  25697. // the field is not defined in the schema, or if the type mismatched the field
  25698. // type.
  25699. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25700. switch name {
  25701. case token.FieldOrganizationID:
  25702. v, ok := value.(int64)
  25703. if !ok {
  25704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25705. }
  25706. m.AddOrganizationID(v)
  25707. return nil
  25708. }
  25709. return fmt.Errorf("unknown Token numeric field %s", name)
  25710. }
  25711. // ClearedFields returns all nullable fields that were cleared during this
  25712. // mutation.
  25713. func (m *TokenMutation) ClearedFields() []string {
  25714. var fields []string
  25715. if m.FieldCleared(token.FieldDeletedAt) {
  25716. fields = append(fields, token.FieldDeletedAt)
  25717. }
  25718. if m.FieldCleared(token.FieldExpireAt) {
  25719. fields = append(fields, token.FieldExpireAt)
  25720. }
  25721. if m.FieldCleared(token.FieldToken) {
  25722. fields = append(fields, token.FieldToken)
  25723. }
  25724. if m.FieldCleared(token.FieldMAC) {
  25725. fields = append(fields, token.FieldMAC)
  25726. }
  25727. if m.FieldCleared(token.FieldCustomAgentBase) {
  25728. fields = append(fields, token.FieldCustomAgentBase)
  25729. }
  25730. if m.FieldCleared(token.FieldCustomAgentKey) {
  25731. fields = append(fields, token.FieldCustomAgentKey)
  25732. }
  25733. if m.FieldCleared(token.FieldOpenaiBase) {
  25734. fields = append(fields, token.FieldOpenaiBase)
  25735. }
  25736. if m.FieldCleared(token.FieldOpenaiKey) {
  25737. fields = append(fields, token.FieldOpenaiKey)
  25738. }
  25739. return fields
  25740. }
  25741. // FieldCleared returns a boolean indicating if a field with the given name was
  25742. // cleared in this mutation.
  25743. func (m *TokenMutation) FieldCleared(name string) bool {
  25744. _, ok := m.clearedFields[name]
  25745. return ok
  25746. }
  25747. // ClearField clears the value of the field with the given name. It returns an
  25748. // error if the field is not defined in the schema.
  25749. func (m *TokenMutation) ClearField(name string) error {
  25750. switch name {
  25751. case token.FieldDeletedAt:
  25752. m.ClearDeletedAt()
  25753. return nil
  25754. case token.FieldExpireAt:
  25755. m.ClearExpireAt()
  25756. return nil
  25757. case token.FieldToken:
  25758. m.ClearToken()
  25759. return nil
  25760. case token.FieldMAC:
  25761. m.ClearMAC()
  25762. return nil
  25763. case token.FieldCustomAgentBase:
  25764. m.ClearCustomAgentBase()
  25765. return nil
  25766. case token.FieldCustomAgentKey:
  25767. m.ClearCustomAgentKey()
  25768. return nil
  25769. case token.FieldOpenaiBase:
  25770. m.ClearOpenaiBase()
  25771. return nil
  25772. case token.FieldOpenaiKey:
  25773. m.ClearOpenaiKey()
  25774. return nil
  25775. }
  25776. return fmt.Errorf("unknown Token nullable field %s", name)
  25777. }
  25778. // ResetField resets all changes in the mutation for the field with the given name.
  25779. // It returns an error if the field is not defined in the schema.
  25780. func (m *TokenMutation) ResetField(name string) error {
  25781. switch name {
  25782. case token.FieldCreatedAt:
  25783. m.ResetCreatedAt()
  25784. return nil
  25785. case token.FieldUpdatedAt:
  25786. m.ResetUpdatedAt()
  25787. return nil
  25788. case token.FieldDeletedAt:
  25789. m.ResetDeletedAt()
  25790. return nil
  25791. case token.FieldExpireAt:
  25792. m.ResetExpireAt()
  25793. return nil
  25794. case token.FieldToken:
  25795. m.ResetToken()
  25796. return nil
  25797. case token.FieldMAC:
  25798. m.ResetMAC()
  25799. return nil
  25800. case token.FieldOrganizationID:
  25801. m.ResetOrganizationID()
  25802. return nil
  25803. case token.FieldAgentID:
  25804. m.ResetAgentID()
  25805. return nil
  25806. case token.FieldCustomAgentBase:
  25807. m.ResetCustomAgentBase()
  25808. return nil
  25809. case token.FieldCustomAgentKey:
  25810. m.ResetCustomAgentKey()
  25811. return nil
  25812. case token.FieldOpenaiBase:
  25813. m.ResetOpenaiBase()
  25814. return nil
  25815. case token.FieldOpenaiKey:
  25816. m.ResetOpenaiKey()
  25817. return nil
  25818. }
  25819. return fmt.Errorf("unknown Token field %s", name)
  25820. }
  25821. // AddedEdges returns all edge names that were set/added in this mutation.
  25822. func (m *TokenMutation) AddedEdges() []string {
  25823. edges := make([]string, 0, 1)
  25824. if m.agent != nil {
  25825. edges = append(edges, token.EdgeAgent)
  25826. }
  25827. return edges
  25828. }
  25829. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25830. // name in this mutation.
  25831. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25832. switch name {
  25833. case token.EdgeAgent:
  25834. if id := m.agent; id != nil {
  25835. return []ent.Value{*id}
  25836. }
  25837. }
  25838. return nil
  25839. }
  25840. // RemovedEdges returns all edge names that were removed in this mutation.
  25841. func (m *TokenMutation) RemovedEdges() []string {
  25842. edges := make([]string, 0, 1)
  25843. return edges
  25844. }
  25845. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25846. // the given name in this mutation.
  25847. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25848. return nil
  25849. }
  25850. // ClearedEdges returns all edge names that were cleared in this mutation.
  25851. func (m *TokenMutation) ClearedEdges() []string {
  25852. edges := make([]string, 0, 1)
  25853. if m.clearedagent {
  25854. edges = append(edges, token.EdgeAgent)
  25855. }
  25856. return edges
  25857. }
  25858. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25859. // was cleared in this mutation.
  25860. func (m *TokenMutation) EdgeCleared(name string) bool {
  25861. switch name {
  25862. case token.EdgeAgent:
  25863. return m.clearedagent
  25864. }
  25865. return false
  25866. }
  25867. // ClearEdge clears the value of the edge with the given name. It returns an error
  25868. // if that edge is not defined in the schema.
  25869. func (m *TokenMutation) ClearEdge(name string) error {
  25870. switch name {
  25871. case token.EdgeAgent:
  25872. m.ClearAgent()
  25873. return nil
  25874. }
  25875. return fmt.Errorf("unknown Token unique edge %s", name)
  25876. }
  25877. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25878. // It returns an error if the edge is not defined in the schema.
  25879. func (m *TokenMutation) ResetEdge(name string) error {
  25880. switch name {
  25881. case token.EdgeAgent:
  25882. m.ResetAgent()
  25883. return nil
  25884. }
  25885. return fmt.Errorf("unknown Token edge %s", name)
  25886. }
  25887. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25888. type TutorialMutation struct {
  25889. config
  25890. op Op
  25891. typ string
  25892. id *uint64
  25893. created_at *time.Time
  25894. updated_at *time.Time
  25895. deleted_at *time.Time
  25896. index *int
  25897. addindex *int
  25898. title *string
  25899. content *string
  25900. organization_id *uint64
  25901. addorganization_id *int64
  25902. clearedFields map[string]struct{}
  25903. employee *uint64
  25904. clearedemployee bool
  25905. done bool
  25906. oldValue func(context.Context) (*Tutorial, error)
  25907. predicates []predicate.Tutorial
  25908. }
  25909. var _ ent.Mutation = (*TutorialMutation)(nil)
  25910. // tutorialOption allows management of the mutation configuration using functional options.
  25911. type tutorialOption func(*TutorialMutation)
  25912. // newTutorialMutation creates new mutation for the Tutorial entity.
  25913. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25914. m := &TutorialMutation{
  25915. config: c,
  25916. op: op,
  25917. typ: TypeTutorial,
  25918. clearedFields: make(map[string]struct{}),
  25919. }
  25920. for _, opt := range opts {
  25921. opt(m)
  25922. }
  25923. return m
  25924. }
  25925. // withTutorialID sets the ID field of the mutation.
  25926. func withTutorialID(id uint64) tutorialOption {
  25927. return func(m *TutorialMutation) {
  25928. var (
  25929. err error
  25930. once sync.Once
  25931. value *Tutorial
  25932. )
  25933. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25934. once.Do(func() {
  25935. if m.done {
  25936. err = errors.New("querying old values post mutation is not allowed")
  25937. } else {
  25938. value, err = m.Client().Tutorial.Get(ctx, id)
  25939. }
  25940. })
  25941. return value, err
  25942. }
  25943. m.id = &id
  25944. }
  25945. }
  25946. // withTutorial sets the old Tutorial of the mutation.
  25947. func withTutorial(node *Tutorial) tutorialOption {
  25948. return func(m *TutorialMutation) {
  25949. m.oldValue = func(context.Context) (*Tutorial, error) {
  25950. return node, nil
  25951. }
  25952. m.id = &node.ID
  25953. }
  25954. }
  25955. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25956. // executed in a transaction (ent.Tx), a transactional client is returned.
  25957. func (m TutorialMutation) Client() *Client {
  25958. client := &Client{config: m.config}
  25959. client.init()
  25960. return client
  25961. }
  25962. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25963. // it returns an error otherwise.
  25964. func (m TutorialMutation) Tx() (*Tx, error) {
  25965. if _, ok := m.driver.(*txDriver); !ok {
  25966. return nil, errors.New("ent: mutation is not running in a transaction")
  25967. }
  25968. tx := &Tx{config: m.config}
  25969. tx.init()
  25970. return tx, nil
  25971. }
  25972. // SetID sets the value of the id field. Note that this
  25973. // operation is only accepted on creation of Tutorial entities.
  25974. func (m *TutorialMutation) SetID(id uint64) {
  25975. m.id = &id
  25976. }
  25977. // ID returns the ID value in the mutation. Note that the ID is only available
  25978. // if it was provided to the builder or after it was returned from the database.
  25979. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25980. if m.id == nil {
  25981. return
  25982. }
  25983. return *m.id, true
  25984. }
  25985. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25986. // That means, if the mutation is applied within a transaction with an isolation level such
  25987. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25988. // or updated by the mutation.
  25989. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25990. switch {
  25991. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25992. id, exists := m.ID()
  25993. if exists {
  25994. return []uint64{id}, nil
  25995. }
  25996. fallthrough
  25997. case m.op.Is(OpUpdate | OpDelete):
  25998. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25999. default:
  26000. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26001. }
  26002. }
  26003. // SetCreatedAt sets the "created_at" field.
  26004. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26005. m.created_at = &t
  26006. }
  26007. // CreatedAt returns the value of the "created_at" field in the mutation.
  26008. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26009. v := m.created_at
  26010. if v == nil {
  26011. return
  26012. }
  26013. return *v, true
  26014. }
  26015. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26016. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26018. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26019. if !m.op.Is(OpUpdateOne) {
  26020. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26021. }
  26022. if m.id == nil || m.oldValue == nil {
  26023. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26024. }
  26025. oldValue, err := m.oldValue(ctx)
  26026. if err != nil {
  26027. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26028. }
  26029. return oldValue.CreatedAt, nil
  26030. }
  26031. // ResetCreatedAt resets all changes to the "created_at" field.
  26032. func (m *TutorialMutation) ResetCreatedAt() {
  26033. m.created_at = nil
  26034. }
  26035. // SetUpdatedAt sets the "updated_at" field.
  26036. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26037. m.updated_at = &t
  26038. }
  26039. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26040. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26041. v := m.updated_at
  26042. if v == nil {
  26043. return
  26044. }
  26045. return *v, true
  26046. }
  26047. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26048. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26050. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26051. if !m.op.Is(OpUpdateOne) {
  26052. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26053. }
  26054. if m.id == nil || m.oldValue == nil {
  26055. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26056. }
  26057. oldValue, err := m.oldValue(ctx)
  26058. if err != nil {
  26059. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26060. }
  26061. return oldValue.UpdatedAt, nil
  26062. }
  26063. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26064. func (m *TutorialMutation) ResetUpdatedAt() {
  26065. m.updated_at = nil
  26066. }
  26067. // SetDeletedAt sets the "deleted_at" field.
  26068. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26069. m.deleted_at = &t
  26070. }
  26071. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26072. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26073. v := m.deleted_at
  26074. if v == nil {
  26075. return
  26076. }
  26077. return *v, true
  26078. }
  26079. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26080. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26082. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26083. if !m.op.Is(OpUpdateOne) {
  26084. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26085. }
  26086. if m.id == nil || m.oldValue == nil {
  26087. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26088. }
  26089. oldValue, err := m.oldValue(ctx)
  26090. if err != nil {
  26091. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26092. }
  26093. return oldValue.DeletedAt, nil
  26094. }
  26095. // ClearDeletedAt clears the value of the "deleted_at" field.
  26096. func (m *TutorialMutation) ClearDeletedAt() {
  26097. m.deleted_at = nil
  26098. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26099. }
  26100. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26101. func (m *TutorialMutation) DeletedAtCleared() bool {
  26102. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26103. return ok
  26104. }
  26105. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26106. func (m *TutorialMutation) ResetDeletedAt() {
  26107. m.deleted_at = nil
  26108. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26109. }
  26110. // SetEmployeeID sets the "employee_id" field.
  26111. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26112. m.employee = &u
  26113. }
  26114. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26115. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26116. v := m.employee
  26117. if v == nil {
  26118. return
  26119. }
  26120. return *v, true
  26121. }
  26122. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26123. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26125. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26126. if !m.op.Is(OpUpdateOne) {
  26127. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26128. }
  26129. if m.id == nil || m.oldValue == nil {
  26130. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26131. }
  26132. oldValue, err := m.oldValue(ctx)
  26133. if err != nil {
  26134. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26135. }
  26136. return oldValue.EmployeeID, nil
  26137. }
  26138. // ResetEmployeeID resets all changes to the "employee_id" field.
  26139. func (m *TutorialMutation) ResetEmployeeID() {
  26140. m.employee = nil
  26141. }
  26142. // SetIndex sets the "index" field.
  26143. func (m *TutorialMutation) SetIndex(i int) {
  26144. m.index = &i
  26145. m.addindex = nil
  26146. }
  26147. // Index returns the value of the "index" field in the mutation.
  26148. func (m *TutorialMutation) Index() (r int, exists bool) {
  26149. v := m.index
  26150. if v == nil {
  26151. return
  26152. }
  26153. return *v, true
  26154. }
  26155. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26156. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26158. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26159. if !m.op.Is(OpUpdateOne) {
  26160. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26161. }
  26162. if m.id == nil || m.oldValue == nil {
  26163. return v, errors.New("OldIndex requires an ID field in the mutation")
  26164. }
  26165. oldValue, err := m.oldValue(ctx)
  26166. if err != nil {
  26167. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26168. }
  26169. return oldValue.Index, nil
  26170. }
  26171. // AddIndex adds i to the "index" field.
  26172. func (m *TutorialMutation) AddIndex(i int) {
  26173. if m.addindex != nil {
  26174. *m.addindex += i
  26175. } else {
  26176. m.addindex = &i
  26177. }
  26178. }
  26179. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26180. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26181. v := m.addindex
  26182. if v == nil {
  26183. return
  26184. }
  26185. return *v, true
  26186. }
  26187. // ResetIndex resets all changes to the "index" field.
  26188. func (m *TutorialMutation) ResetIndex() {
  26189. m.index = nil
  26190. m.addindex = nil
  26191. }
  26192. // SetTitle sets the "title" field.
  26193. func (m *TutorialMutation) SetTitle(s string) {
  26194. m.title = &s
  26195. }
  26196. // Title returns the value of the "title" field in the mutation.
  26197. func (m *TutorialMutation) Title() (r string, exists bool) {
  26198. v := m.title
  26199. if v == nil {
  26200. return
  26201. }
  26202. return *v, true
  26203. }
  26204. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26205. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26207. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26208. if !m.op.Is(OpUpdateOne) {
  26209. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26210. }
  26211. if m.id == nil || m.oldValue == nil {
  26212. return v, errors.New("OldTitle requires an ID field in the mutation")
  26213. }
  26214. oldValue, err := m.oldValue(ctx)
  26215. if err != nil {
  26216. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26217. }
  26218. return oldValue.Title, nil
  26219. }
  26220. // ResetTitle resets all changes to the "title" field.
  26221. func (m *TutorialMutation) ResetTitle() {
  26222. m.title = nil
  26223. }
  26224. // SetContent sets the "content" field.
  26225. func (m *TutorialMutation) SetContent(s string) {
  26226. m.content = &s
  26227. }
  26228. // Content returns the value of the "content" field in the mutation.
  26229. func (m *TutorialMutation) Content() (r string, exists bool) {
  26230. v := m.content
  26231. if v == nil {
  26232. return
  26233. }
  26234. return *v, true
  26235. }
  26236. // OldContent returns the old "content" field's value of the Tutorial entity.
  26237. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26239. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26240. if !m.op.Is(OpUpdateOne) {
  26241. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26242. }
  26243. if m.id == nil || m.oldValue == nil {
  26244. return v, errors.New("OldContent requires an ID field in the mutation")
  26245. }
  26246. oldValue, err := m.oldValue(ctx)
  26247. if err != nil {
  26248. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26249. }
  26250. return oldValue.Content, nil
  26251. }
  26252. // ResetContent resets all changes to the "content" field.
  26253. func (m *TutorialMutation) ResetContent() {
  26254. m.content = nil
  26255. }
  26256. // SetOrganizationID sets the "organization_id" field.
  26257. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26258. m.organization_id = &u
  26259. m.addorganization_id = nil
  26260. }
  26261. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26262. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26263. v := m.organization_id
  26264. if v == nil {
  26265. return
  26266. }
  26267. return *v, true
  26268. }
  26269. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26270. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26272. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26273. if !m.op.Is(OpUpdateOne) {
  26274. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26275. }
  26276. if m.id == nil || m.oldValue == nil {
  26277. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26278. }
  26279. oldValue, err := m.oldValue(ctx)
  26280. if err != nil {
  26281. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26282. }
  26283. return oldValue.OrganizationID, nil
  26284. }
  26285. // AddOrganizationID adds u to the "organization_id" field.
  26286. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26287. if m.addorganization_id != nil {
  26288. *m.addorganization_id += u
  26289. } else {
  26290. m.addorganization_id = &u
  26291. }
  26292. }
  26293. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26294. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26295. v := m.addorganization_id
  26296. if v == nil {
  26297. return
  26298. }
  26299. return *v, true
  26300. }
  26301. // ResetOrganizationID resets all changes to the "organization_id" field.
  26302. func (m *TutorialMutation) ResetOrganizationID() {
  26303. m.organization_id = nil
  26304. m.addorganization_id = nil
  26305. }
  26306. // ClearEmployee clears the "employee" edge to the Employee entity.
  26307. func (m *TutorialMutation) ClearEmployee() {
  26308. m.clearedemployee = true
  26309. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26310. }
  26311. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26312. func (m *TutorialMutation) EmployeeCleared() bool {
  26313. return m.clearedemployee
  26314. }
  26315. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26316. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26317. // EmployeeID instead. It exists only for internal usage by the builders.
  26318. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26319. if id := m.employee; id != nil {
  26320. ids = append(ids, *id)
  26321. }
  26322. return
  26323. }
  26324. // ResetEmployee resets all changes to the "employee" edge.
  26325. func (m *TutorialMutation) ResetEmployee() {
  26326. m.employee = nil
  26327. m.clearedemployee = false
  26328. }
  26329. // Where appends a list predicates to the TutorialMutation builder.
  26330. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26331. m.predicates = append(m.predicates, ps...)
  26332. }
  26333. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26334. // users can use type-assertion to append predicates that do not depend on any generated package.
  26335. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26336. p := make([]predicate.Tutorial, len(ps))
  26337. for i := range ps {
  26338. p[i] = ps[i]
  26339. }
  26340. m.Where(p...)
  26341. }
  26342. // Op returns the operation name.
  26343. func (m *TutorialMutation) Op() Op {
  26344. return m.op
  26345. }
  26346. // SetOp allows setting the mutation operation.
  26347. func (m *TutorialMutation) SetOp(op Op) {
  26348. m.op = op
  26349. }
  26350. // Type returns the node type of this mutation (Tutorial).
  26351. func (m *TutorialMutation) Type() string {
  26352. return m.typ
  26353. }
  26354. // Fields returns all fields that were changed during this mutation. Note that in
  26355. // order to get all numeric fields that were incremented/decremented, call
  26356. // AddedFields().
  26357. func (m *TutorialMutation) Fields() []string {
  26358. fields := make([]string, 0, 8)
  26359. if m.created_at != nil {
  26360. fields = append(fields, tutorial.FieldCreatedAt)
  26361. }
  26362. if m.updated_at != nil {
  26363. fields = append(fields, tutorial.FieldUpdatedAt)
  26364. }
  26365. if m.deleted_at != nil {
  26366. fields = append(fields, tutorial.FieldDeletedAt)
  26367. }
  26368. if m.employee != nil {
  26369. fields = append(fields, tutorial.FieldEmployeeID)
  26370. }
  26371. if m.index != nil {
  26372. fields = append(fields, tutorial.FieldIndex)
  26373. }
  26374. if m.title != nil {
  26375. fields = append(fields, tutorial.FieldTitle)
  26376. }
  26377. if m.content != nil {
  26378. fields = append(fields, tutorial.FieldContent)
  26379. }
  26380. if m.organization_id != nil {
  26381. fields = append(fields, tutorial.FieldOrganizationID)
  26382. }
  26383. return fields
  26384. }
  26385. // Field returns the value of a field with the given name. The second boolean
  26386. // return value indicates that this field was not set, or was not defined in the
  26387. // schema.
  26388. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26389. switch name {
  26390. case tutorial.FieldCreatedAt:
  26391. return m.CreatedAt()
  26392. case tutorial.FieldUpdatedAt:
  26393. return m.UpdatedAt()
  26394. case tutorial.FieldDeletedAt:
  26395. return m.DeletedAt()
  26396. case tutorial.FieldEmployeeID:
  26397. return m.EmployeeID()
  26398. case tutorial.FieldIndex:
  26399. return m.Index()
  26400. case tutorial.FieldTitle:
  26401. return m.Title()
  26402. case tutorial.FieldContent:
  26403. return m.Content()
  26404. case tutorial.FieldOrganizationID:
  26405. return m.OrganizationID()
  26406. }
  26407. return nil, false
  26408. }
  26409. // OldField returns the old value of the field from the database. An error is
  26410. // returned if the mutation operation is not UpdateOne, or the query to the
  26411. // database failed.
  26412. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26413. switch name {
  26414. case tutorial.FieldCreatedAt:
  26415. return m.OldCreatedAt(ctx)
  26416. case tutorial.FieldUpdatedAt:
  26417. return m.OldUpdatedAt(ctx)
  26418. case tutorial.FieldDeletedAt:
  26419. return m.OldDeletedAt(ctx)
  26420. case tutorial.FieldEmployeeID:
  26421. return m.OldEmployeeID(ctx)
  26422. case tutorial.FieldIndex:
  26423. return m.OldIndex(ctx)
  26424. case tutorial.FieldTitle:
  26425. return m.OldTitle(ctx)
  26426. case tutorial.FieldContent:
  26427. return m.OldContent(ctx)
  26428. case tutorial.FieldOrganizationID:
  26429. return m.OldOrganizationID(ctx)
  26430. }
  26431. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26432. }
  26433. // SetField sets the value of a field with the given name. It returns an error if
  26434. // the field is not defined in the schema, or if the type mismatched the field
  26435. // type.
  26436. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26437. switch name {
  26438. case tutorial.FieldCreatedAt:
  26439. v, ok := value.(time.Time)
  26440. if !ok {
  26441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26442. }
  26443. m.SetCreatedAt(v)
  26444. return nil
  26445. case tutorial.FieldUpdatedAt:
  26446. v, ok := value.(time.Time)
  26447. if !ok {
  26448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26449. }
  26450. m.SetUpdatedAt(v)
  26451. return nil
  26452. case tutorial.FieldDeletedAt:
  26453. v, ok := value.(time.Time)
  26454. if !ok {
  26455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26456. }
  26457. m.SetDeletedAt(v)
  26458. return nil
  26459. case tutorial.FieldEmployeeID:
  26460. v, ok := value.(uint64)
  26461. if !ok {
  26462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26463. }
  26464. m.SetEmployeeID(v)
  26465. return nil
  26466. case tutorial.FieldIndex:
  26467. v, ok := value.(int)
  26468. if !ok {
  26469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26470. }
  26471. m.SetIndex(v)
  26472. return nil
  26473. case tutorial.FieldTitle:
  26474. v, ok := value.(string)
  26475. if !ok {
  26476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26477. }
  26478. m.SetTitle(v)
  26479. return nil
  26480. case tutorial.FieldContent:
  26481. v, ok := value.(string)
  26482. if !ok {
  26483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26484. }
  26485. m.SetContent(v)
  26486. return nil
  26487. case tutorial.FieldOrganizationID:
  26488. v, ok := value.(uint64)
  26489. if !ok {
  26490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26491. }
  26492. m.SetOrganizationID(v)
  26493. return nil
  26494. }
  26495. return fmt.Errorf("unknown Tutorial field %s", name)
  26496. }
  26497. // AddedFields returns all numeric fields that were incremented/decremented during
  26498. // this mutation.
  26499. func (m *TutorialMutation) AddedFields() []string {
  26500. var fields []string
  26501. if m.addindex != nil {
  26502. fields = append(fields, tutorial.FieldIndex)
  26503. }
  26504. if m.addorganization_id != nil {
  26505. fields = append(fields, tutorial.FieldOrganizationID)
  26506. }
  26507. return fields
  26508. }
  26509. // AddedField returns the numeric value that was incremented/decremented on a field
  26510. // with the given name. The second boolean return value indicates that this field
  26511. // was not set, or was not defined in the schema.
  26512. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26513. switch name {
  26514. case tutorial.FieldIndex:
  26515. return m.AddedIndex()
  26516. case tutorial.FieldOrganizationID:
  26517. return m.AddedOrganizationID()
  26518. }
  26519. return nil, false
  26520. }
  26521. // AddField adds the value to the field with the given name. It returns an error if
  26522. // the field is not defined in the schema, or if the type mismatched the field
  26523. // type.
  26524. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26525. switch name {
  26526. case tutorial.FieldIndex:
  26527. v, ok := value.(int)
  26528. if !ok {
  26529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26530. }
  26531. m.AddIndex(v)
  26532. return nil
  26533. case tutorial.FieldOrganizationID:
  26534. v, ok := value.(int64)
  26535. if !ok {
  26536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26537. }
  26538. m.AddOrganizationID(v)
  26539. return nil
  26540. }
  26541. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26542. }
  26543. // ClearedFields returns all nullable fields that were cleared during this
  26544. // mutation.
  26545. func (m *TutorialMutation) ClearedFields() []string {
  26546. var fields []string
  26547. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26548. fields = append(fields, tutorial.FieldDeletedAt)
  26549. }
  26550. return fields
  26551. }
  26552. // FieldCleared returns a boolean indicating if a field with the given name was
  26553. // cleared in this mutation.
  26554. func (m *TutorialMutation) FieldCleared(name string) bool {
  26555. _, ok := m.clearedFields[name]
  26556. return ok
  26557. }
  26558. // ClearField clears the value of the field with the given name. It returns an
  26559. // error if the field is not defined in the schema.
  26560. func (m *TutorialMutation) ClearField(name string) error {
  26561. switch name {
  26562. case tutorial.FieldDeletedAt:
  26563. m.ClearDeletedAt()
  26564. return nil
  26565. }
  26566. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26567. }
  26568. // ResetField resets all changes in the mutation for the field with the given name.
  26569. // It returns an error if the field is not defined in the schema.
  26570. func (m *TutorialMutation) ResetField(name string) error {
  26571. switch name {
  26572. case tutorial.FieldCreatedAt:
  26573. m.ResetCreatedAt()
  26574. return nil
  26575. case tutorial.FieldUpdatedAt:
  26576. m.ResetUpdatedAt()
  26577. return nil
  26578. case tutorial.FieldDeletedAt:
  26579. m.ResetDeletedAt()
  26580. return nil
  26581. case tutorial.FieldEmployeeID:
  26582. m.ResetEmployeeID()
  26583. return nil
  26584. case tutorial.FieldIndex:
  26585. m.ResetIndex()
  26586. return nil
  26587. case tutorial.FieldTitle:
  26588. m.ResetTitle()
  26589. return nil
  26590. case tutorial.FieldContent:
  26591. m.ResetContent()
  26592. return nil
  26593. case tutorial.FieldOrganizationID:
  26594. m.ResetOrganizationID()
  26595. return nil
  26596. }
  26597. return fmt.Errorf("unknown Tutorial field %s", name)
  26598. }
  26599. // AddedEdges returns all edge names that were set/added in this mutation.
  26600. func (m *TutorialMutation) AddedEdges() []string {
  26601. edges := make([]string, 0, 1)
  26602. if m.employee != nil {
  26603. edges = append(edges, tutorial.EdgeEmployee)
  26604. }
  26605. return edges
  26606. }
  26607. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26608. // name in this mutation.
  26609. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26610. switch name {
  26611. case tutorial.EdgeEmployee:
  26612. if id := m.employee; id != nil {
  26613. return []ent.Value{*id}
  26614. }
  26615. }
  26616. return nil
  26617. }
  26618. // RemovedEdges returns all edge names that were removed in this mutation.
  26619. func (m *TutorialMutation) RemovedEdges() []string {
  26620. edges := make([]string, 0, 1)
  26621. return edges
  26622. }
  26623. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26624. // the given name in this mutation.
  26625. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26626. return nil
  26627. }
  26628. // ClearedEdges returns all edge names that were cleared in this mutation.
  26629. func (m *TutorialMutation) ClearedEdges() []string {
  26630. edges := make([]string, 0, 1)
  26631. if m.clearedemployee {
  26632. edges = append(edges, tutorial.EdgeEmployee)
  26633. }
  26634. return edges
  26635. }
  26636. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26637. // was cleared in this mutation.
  26638. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26639. switch name {
  26640. case tutorial.EdgeEmployee:
  26641. return m.clearedemployee
  26642. }
  26643. return false
  26644. }
  26645. // ClearEdge clears the value of the edge with the given name. It returns an error
  26646. // if that edge is not defined in the schema.
  26647. func (m *TutorialMutation) ClearEdge(name string) error {
  26648. switch name {
  26649. case tutorial.EdgeEmployee:
  26650. m.ClearEmployee()
  26651. return nil
  26652. }
  26653. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26654. }
  26655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26656. // It returns an error if the edge is not defined in the schema.
  26657. func (m *TutorialMutation) ResetEdge(name string) error {
  26658. switch name {
  26659. case tutorial.EdgeEmployee:
  26660. m.ResetEmployee()
  26661. return nil
  26662. }
  26663. return fmt.Errorf("unknown Tutorial edge %s", name)
  26664. }
  26665. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26666. type UsageDetailMutation struct {
  26667. config
  26668. op Op
  26669. typ string
  26670. id *uint64
  26671. created_at *time.Time
  26672. updated_at *time.Time
  26673. status *uint8
  26674. addstatus *int8
  26675. _type *int
  26676. add_type *int
  26677. bot_id *string
  26678. receiver_id *string
  26679. app *int
  26680. addapp *int
  26681. session_id *uint64
  26682. addsession_id *int64
  26683. request *string
  26684. response *string
  26685. original_data *custom_types.OriginalData
  26686. total_tokens *uint64
  26687. addtotal_tokens *int64
  26688. prompt_tokens *uint64
  26689. addprompt_tokens *int64
  26690. completion_tokens *uint64
  26691. addcompletion_tokens *int64
  26692. organization_id *uint64
  26693. addorganization_id *int64
  26694. clearedFields map[string]struct{}
  26695. done bool
  26696. oldValue func(context.Context) (*UsageDetail, error)
  26697. predicates []predicate.UsageDetail
  26698. }
  26699. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26700. // usagedetailOption allows management of the mutation configuration using functional options.
  26701. type usagedetailOption func(*UsageDetailMutation)
  26702. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26703. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26704. m := &UsageDetailMutation{
  26705. config: c,
  26706. op: op,
  26707. typ: TypeUsageDetail,
  26708. clearedFields: make(map[string]struct{}),
  26709. }
  26710. for _, opt := range opts {
  26711. opt(m)
  26712. }
  26713. return m
  26714. }
  26715. // withUsageDetailID sets the ID field of the mutation.
  26716. func withUsageDetailID(id uint64) usagedetailOption {
  26717. return func(m *UsageDetailMutation) {
  26718. var (
  26719. err error
  26720. once sync.Once
  26721. value *UsageDetail
  26722. )
  26723. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26724. once.Do(func() {
  26725. if m.done {
  26726. err = errors.New("querying old values post mutation is not allowed")
  26727. } else {
  26728. value, err = m.Client().UsageDetail.Get(ctx, id)
  26729. }
  26730. })
  26731. return value, err
  26732. }
  26733. m.id = &id
  26734. }
  26735. }
  26736. // withUsageDetail sets the old UsageDetail of the mutation.
  26737. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26738. return func(m *UsageDetailMutation) {
  26739. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26740. return node, nil
  26741. }
  26742. m.id = &node.ID
  26743. }
  26744. }
  26745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26746. // executed in a transaction (ent.Tx), a transactional client is returned.
  26747. func (m UsageDetailMutation) Client() *Client {
  26748. client := &Client{config: m.config}
  26749. client.init()
  26750. return client
  26751. }
  26752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26753. // it returns an error otherwise.
  26754. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26755. if _, ok := m.driver.(*txDriver); !ok {
  26756. return nil, errors.New("ent: mutation is not running in a transaction")
  26757. }
  26758. tx := &Tx{config: m.config}
  26759. tx.init()
  26760. return tx, nil
  26761. }
  26762. // SetID sets the value of the id field. Note that this
  26763. // operation is only accepted on creation of UsageDetail entities.
  26764. func (m *UsageDetailMutation) SetID(id uint64) {
  26765. m.id = &id
  26766. }
  26767. // ID returns the ID value in the mutation. Note that the ID is only available
  26768. // if it was provided to the builder or after it was returned from the database.
  26769. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26770. if m.id == nil {
  26771. return
  26772. }
  26773. return *m.id, true
  26774. }
  26775. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26776. // That means, if the mutation is applied within a transaction with an isolation level such
  26777. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26778. // or updated by the mutation.
  26779. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26780. switch {
  26781. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26782. id, exists := m.ID()
  26783. if exists {
  26784. return []uint64{id}, nil
  26785. }
  26786. fallthrough
  26787. case m.op.Is(OpUpdate | OpDelete):
  26788. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26789. default:
  26790. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26791. }
  26792. }
  26793. // SetCreatedAt sets the "created_at" field.
  26794. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26795. m.created_at = &t
  26796. }
  26797. // CreatedAt returns the value of the "created_at" field in the mutation.
  26798. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26799. v := m.created_at
  26800. if v == nil {
  26801. return
  26802. }
  26803. return *v, true
  26804. }
  26805. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26806. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26808. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26809. if !m.op.Is(OpUpdateOne) {
  26810. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26811. }
  26812. if m.id == nil || m.oldValue == nil {
  26813. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26814. }
  26815. oldValue, err := m.oldValue(ctx)
  26816. if err != nil {
  26817. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26818. }
  26819. return oldValue.CreatedAt, nil
  26820. }
  26821. // ResetCreatedAt resets all changes to the "created_at" field.
  26822. func (m *UsageDetailMutation) ResetCreatedAt() {
  26823. m.created_at = nil
  26824. }
  26825. // SetUpdatedAt sets the "updated_at" field.
  26826. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26827. m.updated_at = &t
  26828. }
  26829. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26830. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26831. v := m.updated_at
  26832. if v == nil {
  26833. return
  26834. }
  26835. return *v, true
  26836. }
  26837. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26838. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26840. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26841. if !m.op.Is(OpUpdateOne) {
  26842. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26843. }
  26844. if m.id == nil || m.oldValue == nil {
  26845. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26846. }
  26847. oldValue, err := m.oldValue(ctx)
  26848. if err != nil {
  26849. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26850. }
  26851. return oldValue.UpdatedAt, nil
  26852. }
  26853. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26854. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26855. m.updated_at = nil
  26856. }
  26857. // SetStatus sets the "status" field.
  26858. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26859. m.status = &u
  26860. m.addstatus = nil
  26861. }
  26862. // Status returns the value of the "status" field in the mutation.
  26863. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26864. v := m.status
  26865. if v == nil {
  26866. return
  26867. }
  26868. return *v, true
  26869. }
  26870. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26871. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26873. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26874. if !m.op.Is(OpUpdateOne) {
  26875. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26876. }
  26877. if m.id == nil || m.oldValue == nil {
  26878. return v, errors.New("OldStatus requires an ID field in the mutation")
  26879. }
  26880. oldValue, err := m.oldValue(ctx)
  26881. if err != nil {
  26882. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26883. }
  26884. return oldValue.Status, nil
  26885. }
  26886. // AddStatus adds u to the "status" field.
  26887. func (m *UsageDetailMutation) AddStatus(u int8) {
  26888. if m.addstatus != nil {
  26889. *m.addstatus += u
  26890. } else {
  26891. m.addstatus = &u
  26892. }
  26893. }
  26894. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26895. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26896. v := m.addstatus
  26897. if v == nil {
  26898. return
  26899. }
  26900. return *v, true
  26901. }
  26902. // ClearStatus clears the value of the "status" field.
  26903. func (m *UsageDetailMutation) ClearStatus() {
  26904. m.status = nil
  26905. m.addstatus = nil
  26906. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26907. }
  26908. // StatusCleared returns if the "status" field was cleared in this mutation.
  26909. func (m *UsageDetailMutation) StatusCleared() bool {
  26910. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26911. return ok
  26912. }
  26913. // ResetStatus resets all changes to the "status" field.
  26914. func (m *UsageDetailMutation) ResetStatus() {
  26915. m.status = nil
  26916. m.addstatus = nil
  26917. delete(m.clearedFields, usagedetail.FieldStatus)
  26918. }
  26919. // SetType sets the "type" field.
  26920. func (m *UsageDetailMutation) SetType(i int) {
  26921. m._type = &i
  26922. m.add_type = nil
  26923. }
  26924. // GetType returns the value of the "type" field in the mutation.
  26925. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26926. v := m._type
  26927. if v == nil {
  26928. return
  26929. }
  26930. return *v, true
  26931. }
  26932. // OldType returns the old "type" field's value of the UsageDetail entity.
  26933. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26935. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26936. if !m.op.Is(OpUpdateOne) {
  26937. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26938. }
  26939. if m.id == nil || m.oldValue == nil {
  26940. return v, errors.New("OldType requires an ID field in the mutation")
  26941. }
  26942. oldValue, err := m.oldValue(ctx)
  26943. if err != nil {
  26944. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26945. }
  26946. return oldValue.Type, nil
  26947. }
  26948. // AddType adds i to the "type" field.
  26949. func (m *UsageDetailMutation) AddType(i int) {
  26950. if m.add_type != nil {
  26951. *m.add_type += i
  26952. } else {
  26953. m.add_type = &i
  26954. }
  26955. }
  26956. // AddedType returns the value that was added to the "type" field in this mutation.
  26957. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26958. v := m.add_type
  26959. if v == nil {
  26960. return
  26961. }
  26962. return *v, true
  26963. }
  26964. // ClearType clears the value of the "type" field.
  26965. func (m *UsageDetailMutation) ClearType() {
  26966. m._type = nil
  26967. m.add_type = nil
  26968. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26969. }
  26970. // TypeCleared returns if the "type" field was cleared in this mutation.
  26971. func (m *UsageDetailMutation) TypeCleared() bool {
  26972. _, ok := m.clearedFields[usagedetail.FieldType]
  26973. return ok
  26974. }
  26975. // ResetType resets all changes to the "type" field.
  26976. func (m *UsageDetailMutation) ResetType() {
  26977. m._type = nil
  26978. m.add_type = nil
  26979. delete(m.clearedFields, usagedetail.FieldType)
  26980. }
  26981. // SetBotID sets the "bot_id" field.
  26982. func (m *UsageDetailMutation) SetBotID(s string) {
  26983. m.bot_id = &s
  26984. }
  26985. // BotID returns the value of the "bot_id" field in the mutation.
  26986. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26987. v := m.bot_id
  26988. if v == nil {
  26989. return
  26990. }
  26991. return *v, true
  26992. }
  26993. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26994. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26996. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26997. if !m.op.Is(OpUpdateOne) {
  26998. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26999. }
  27000. if m.id == nil || m.oldValue == nil {
  27001. return v, errors.New("OldBotID requires an ID field in the mutation")
  27002. }
  27003. oldValue, err := m.oldValue(ctx)
  27004. if err != nil {
  27005. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27006. }
  27007. return oldValue.BotID, nil
  27008. }
  27009. // ResetBotID resets all changes to the "bot_id" field.
  27010. func (m *UsageDetailMutation) ResetBotID() {
  27011. m.bot_id = nil
  27012. }
  27013. // SetReceiverID sets the "receiver_id" field.
  27014. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27015. m.receiver_id = &s
  27016. }
  27017. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27018. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27019. v := m.receiver_id
  27020. if v == nil {
  27021. return
  27022. }
  27023. return *v, true
  27024. }
  27025. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27026. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27028. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27029. if !m.op.Is(OpUpdateOne) {
  27030. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27031. }
  27032. if m.id == nil || m.oldValue == nil {
  27033. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27034. }
  27035. oldValue, err := m.oldValue(ctx)
  27036. if err != nil {
  27037. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27038. }
  27039. return oldValue.ReceiverID, nil
  27040. }
  27041. // ResetReceiverID resets all changes to the "receiver_id" field.
  27042. func (m *UsageDetailMutation) ResetReceiverID() {
  27043. m.receiver_id = nil
  27044. }
  27045. // SetApp sets the "app" field.
  27046. func (m *UsageDetailMutation) SetApp(i int) {
  27047. m.app = &i
  27048. m.addapp = nil
  27049. }
  27050. // App returns the value of the "app" field in the mutation.
  27051. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27052. v := m.app
  27053. if v == nil {
  27054. return
  27055. }
  27056. return *v, true
  27057. }
  27058. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27059. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27061. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27062. if !m.op.Is(OpUpdateOne) {
  27063. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27064. }
  27065. if m.id == nil || m.oldValue == nil {
  27066. return v, errors.New("OldApp requires an ID field in the mutation")
  27067. }
  27068. oldValue, err := m.oldValue(ctx)
  27069. if err != nil {
  27070. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27071. }
  27072. return oldValue.App, nil
  27073. }
  27074. // AddApp adds i to the "app" field.
  27075. func (m *UsageDetailMutation) AddApp(i int) {
  27076. if m.addapp != nil {
  27077. *m.addapp += i
  27078. } else {
  27079. m.addapp = &i
  27080. }
  27081. }
  27082. // AddedApp returns the value that was added to the "app" field in this mutation.
  27083. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27084. v := m.addapp
  27085. if v == nil {
  27086. return
  27087. }
  27088. return *v, true
  27089. }
  27090. // ClearApp clears the value of the "app" field.
  27091. func (m *UsageDetailMutation) ClearApp() {
  27092. m.app = nil
  27093. m.addapp = nil
  27094. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27095. }
  27096. // AppCleared returns if the "app" field was cleared in this mutation.
  27097. func (m *UsageDetailMutation) AppCleared() bool {
  27098. _, ok := m.clearedFields[usagedetail.FieldApp]
  27099. return ok
  27100. }
  27101. // ResetApp resets all changes to the "app" field.
  27102. func (m *UsageDetailMutation) ResetApp() {
  27103. m.app = nil
  27104. m.addapp = nil
  27105. delete(m.clearedFields, usagedetail.FieldApp)
  27106. }
  27107. // SetSessionID sets the "session_id" field.
  27108. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27109. m.session_id = &u
  27110. m.addsession_id = nil
  27111. }
  27112. // SessionID returns the value of the "session_id" field in the mutation.
  27113. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27114. v := m.session_id
  27115. if v == nil {
  27116. return
  27117. }
  27118. return *v, true
  27119. }
  27120. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27121. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27123. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27124. if !m.op.Is(OpUpdateOne) {
  27125. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27126. }
  27127. if m.id == nil || m.oldValue == nil {
  27128. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27129. }
  27130. oldValue, err := m.oldValue(ctx)
  27131. if err != nil {
  27132. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27133. }
  27134. return oldValue.SessionID, nil
  27135. }
  27136. // AddSessionID adds u to the "session_id" field.
  27137. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27138. if m.addsession_id != nil {
  27139. *m.addsession_id += u
  27140. } else {
  27141. m.addsession_id = &u
  27142. }
  27143. }
  27144. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27145. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27146. v := m.addsession_id
  27147. if v == nil {
  27148. return
  27149. }
  27150. return *v, true
  27151. }
  27152. // ClearSessionID clears the value of the "session_id" field.
  27153. func (m *UsageDetailMutation) ClearSessionID() {
  27154. m.session_id = nil
  27155. m.addsession_id = nil
  27156. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27157. }
  27158. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27159. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27160. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27161. return ok
  27162. }
  27163. // ResetSessionID resets all changes to the "session_id" field.
  27164. func (m *UsageDetailMutation) ResetSessionID() {
  27165. m.session_id = nil
  27166. m.addsession_id = nil
  27167. delete(m.clearedFields, usagedetail.FieldSessionID)
  27168. }
  27169. // SetRequest sets the "request" field.
  27170. func (m *UsageDetailMutation) SetRequest(s string) {
  27171. m.request = &s
  27172. }
  27173. // Request returns the value of the "request" field in the mutation.
  27174. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27175. v := m.request
  27176. if v == nil {
  27177. return
  27178. }
  27179. return *v, true
  27180. }
  27181. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27182. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27184. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27185. if !m.op.Is(OpUpdateOne) {
  27186. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27187. }
  27188. if m.id == nil || m.oldValue == nil {
  27189. return v, errors.New("OldRequest requires an ID field in the mutation")
  27190. }
  27191. oldValue, err := m.oldValue(ctx)
  27192. if err != nil {
  27193. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27194. }
  27195. return oldValue.Request, nil
  27196. }
  27197. // ResetRequest resets all changes to the "request" field.
  27198. func (m *UsageDetailMutation) ResetRequest() {
  27199. m.request = nil
  27200. }
  27201. // SetResponse sets the "response" field.
  27202. func (m *UsageDetailMutation) SetResponse(s string) {
  27203. m.response = &s
  27204. }
  27205. // Response returns the value of the "response" field in the mutation.
  27206. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27207. v := m.response
  27208. if v == nil {
  27209. return
  27210. }
  27211. return *v, true
  27212. }
  27213. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27214. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27216. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27217. if !m.op.Is(OpUpdateOne) {
  27218. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27219. }
  27220. if m.id == nil || m.oldValue == nil {
  27221. return v, errors.New("OldResponse requires an ID field in the mutation")
  27222. }
  27223. oldValue, err := m.oldValue(ctx)
  27224. if err != nil {
  27225. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27226. }
  27227. return oldValue.Response, nil
  27228. }
  27229. // ResetResponse resets all changes to the "response" field.
  27230. func (m *UsageDetailMutation) ResetResponse() {
  27231. m.response = nil
  27232. }
  27233. // SetOriginalData sets the "original_data" field.
  27234. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27235. m.original_data = &ctd
  27236. }
  27237. // OriginalData returns the value of the "original_data" field in the mutation.
  27238. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27239. v := m.original_data
  27240. if v == nil {
  27241. return
  27242. }
  27243. return *v, true
  27244. }
  27245. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27246. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27248. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27249. if !m.op.Is(OpUpdateOne) {
  27250. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27251. }
  27252. if m.id == nil || m.oldValue == nil {
  27253. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27254. }
  27255. oldValue, err := m.oldValue(ctx)
  27256. if err != nil {
  27257. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27258. }
  27259. return oldValue.OriginalData, nil
  27260. }
  27261. // ResetOriginalData resets all changes to the "original_data" field.
  27262. func (m *UsageDetailMutation) ResetOriginalData() {
  27263. m.original_data = nil
  27264. }
  27265. // SetTotalTokens sets the "total_tokens" field.
  27266. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27267. m.total_tokens = &u
  27268. m.addtotal_tokens = nil
  27269. }
  27270. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27271. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27272. v := m.total_tokens
  27273. if v == nil {
  27274. return
  27275. }
  27276. return *v, true
  27277. }
  27278. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27279. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27281. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27282. if !m.op.Is(OpUpdateOne) {
  27283. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27284. }
  27285. if m.id == nil || m.oldValue == nil {
  27286. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27287. }
  27288. oldValue, err := m.oldValue(ctx)
  27289. if err != nil {
  27290. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27291. }
  27292. return oldValue.TotalTokens, nil
  27293. }
  27294. // AddTotalTokens adds u to the "total_tokens" field.
  27295. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27296. if m.addtotal_tokens != nil {
  27297. *m.addtotal_tokens += u
  27298. } else {
  27299. m.addtotal_tokens = &u
  27300. }
  27301. }
  27302. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27303. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27304. v := m.addtotal_tokens
  27305. if v == nil {
  27306. return
  27307. }
  27308. return *v, true
  27309. }
  27310. // ClearTotalTokens clears the value of the "total_tokens" field.
  27311. func (m *UsageDetailMutation) ClearTotalTokens() {
  27312. m.total_tokens = nil
  27313. m.addtotal_tokens = nil
  27314. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27315. }
  27316. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27317. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27318. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27319. return ok
  27320. }
  27321. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27322. func (m *UsageDetailMutation) ResetTotalTokens() {
  27323. m.total_tokens = nil
  27324. m.addtotal_tokens = nil
  27325. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27326. }
  27327. // SetPromptTokens sets the "prompt_tokens" field.
  27328. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27329. m.prompt_tokens = &u
  27330. m.addprompt_tokens = nil
  27331. }
  27332. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27333. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27334. v := m.prompt_tokens
  27335. if v == nil {
  27336. return
  27337. }
  27338. return *v, true
  27339. }
  27340. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27341. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27343. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27344. if !m.op.Is(OpUpdateOne) {
  27345. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27346. }
  27347. if m.id == nil || m.oldValue == nil {
  27348. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27349. }
  27350. oldValue, err := m.oldValue(ctx)
  27351. if err != nil {
  27352. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27353. }
  27354. return oldValue.PromptTokens, nil
  27355. }
  27356. // AddPromptTokens adds u to the "prompt_tokens" field.
  27357. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27358. if m.addprompt_tokens != nil {
  27359. *m.addprompt_tokens += u
  27360. } else {
  27361. m.addprompt_tokens = &u
  27362. }
  27363. }
  27364. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27365. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27366. v := m.addprompt_tokens
  27367. if v == nil {
  27368. return
  27369. }
  27370. return *v, true
  27371. }
  27372. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27373. func (m *UsageDetailMutation) ClearPromptTokens() {
  27374. m.prompt_tokens = nil
  27375. m.addprompt_tokens = nil
  27376. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27377. }
  27378. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27379. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27380. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27381. return ok
  27382. }
  27383. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27384. func (m *UsageDetailMutation) ResetPromptTokens() {
  27385. m.prompt_tokens = nil
  27386. m.addprompt_tokens = nil
  27387. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27388. }
  27389. // SetCompletionTokens sets the "completion_tokens" field.
  27390. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27391. m.completion_tokens = &u
  27392. m.addcompletion_tokens = nil
  27393. }
  27394. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27395. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27396. v := m.completion_tokens
  27397. if v == nil {
  27398. return
  27399. }
  27400. return *v, true
  27401. }
  27402. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27403. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27405. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27406. if !m.op.Is(OpUpdateOne) {
  27407. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27408. }
  27409. if m.id == nil || m.oldValue == nil {
  27410. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27411. }
  27412. oldValue, err := m.oldValue(ctx)
  27413. if err != nil {
  27414. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27415. }
  27416. return oldValue.CompletionTokens, nil
  27417. }
  27418. // AddCompletionTokens adds u to the "completion_tokens" field.
  27419. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27420. if m.addcompletion_tokens != nil {
  27421. *m.addcompletion_tokens += u
  27422. } else {
  27423. m.addcompletion_tokens = &u
  27424. }
  27425. }
  27426. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27427. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27428. v := m.addcompletion_tokens
  27429. if v == nil {
  27430. return
  27431. }
  27432. return *v, true
  27433. }
  27434. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27435. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27436. m.completion_tokens = nil
  27437. m.addcompletion_tokens = nil
  27438. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27439. }
  27440. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27441. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27442. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27443. return ok
  27444. }
  27445. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27446. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27447. m.completion_tokens = nil
  27448. m.addcompletion_tokens = nil
  27449. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27450. }
  27451. // SetOrganizationID sets the "organization_id" field.
  27452. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27453. m.organization_id = &u
  27454. m.addorganization_id = nil
  27455. }
  27456. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27457. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27458. v := m.organization_id
  27459. if v == nil {
  27460. return
  27461. }
  27462. return *v, true
  27463. }
  27464. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27465. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27467. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27468. if !m.op.Is(OpUpdateOne) {
  27469. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27470. }
  27471. if m.id == nil || m.oldValue == nil {
  27472. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27473. }
  27474. oldValue, err := m.oldValue(ctx)
  27475. if err != nil {
  27476. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27477. }
  27478. return oldValue.OrganizationID, nil
  27479. }
  27480. // AddOrganizationID adds u to the "organization_id" field.
  27481. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27482. if m.addorganization_id != nil {
  27483. *m.addorganization_id += u
  27484. } else {
  27485. m.addorganization_id = &u
  27486. }
  27487. }
  27488. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27489. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27490. v := m.addorganization_id
  27491. if v == nil {
  27492. return
  27493. }
  27494. return *v, true
  27495. }
  27496. // ClearOrganizationID clears the value of the "organization_id" field.
  27497. func (m *UsageDetailMutation) ClearOrganizationID() {
  27498. m.organization_id = nil
  27499. m.addorganization_id = nil
  27500. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27501. }
  27502. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27503. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27504. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27505. return ok
  27506. }
  27507. // ResetOrganizationID resets all changes to the "organization_id" field.
  27508. func (m *UsageDetailMutation) ResetOrganizationID() {
  27509. m.organization_id = nil
  27510. m.addorganization_id = nil
  27511. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27512. }
  27513. // Where appends a list predicates to the UsageDetailMutation builder.
  27514. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27515. m.predicates = append(m.predicates, ps...)
  27516. }
  27517. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27518. // users can use type-assertion to append predicates that do not depend on any generated package.
  27519. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27520. p := make([]predicate.UsageDetail, len(ps))
  27521. for i := range ps {
  27522. p[i] = ps[i]
  27523. }
  27524. m.Where(p...)
  27525. }
  27526. // Op returns the operation name.
  27527. func (m *UsageDetailMutation) Op() Op {
  27528. return m.op
  27529. }
  27530. // SetOp allows setting the mutation operation.
  27531. func (m *UsageDetailMutation) SetOp(op Op) {
  27532. m.op = op
  27533. }
  27534. // Type returns the node type of this mutation (UsageDetail).
  27535. func (m *UsageDetailMutation) Type() string {
  27536. return m.typ
  27537. }
  27538. // Fields returns all fields that were changed during this mutation. Note that in
  27539. // order to get all numeric fields that were incremented/decremented, call
  27540. // AddedFields().
  27541. func (m *UsageDetailMutation) Fields() []string {
  27542. fields := make([]string, 0, 15)
  27543. if m.created_at != nil {
  27544. fields = append(fields, usagedetail.FieldCreatedAt)
  27545. }
  27546. if m.updated_at != nil {
  27547. fields = append(fields, usagedetail.FieldUpdatedAt)
  27548. }
  27549. if m.status != nil {
  27550. fields = append(fields, usagedetail.FieldStatus)
  27551. }
  27552. if m._type != nil {
  27553. fields = append(fields, usagedetail.FieldType)
  27554. }
  27555. if m.bot_id != nil {
  27556. fields = append(fields, usagedetail.FieldBotID)
  27557. }
  27558. if m.receiver_id != nil {
  27559. fields = append(fields, usagedetail.FieldReceiverID)
  27560. }
  27561. if m.app != nil {
  27562. fields = append(fields, usagedetail.FieldApp)
  27563. }
  27564. if m.session_id != nil {
  27565. fields = append(fields, usagedetail.FieldSessionID)
  27566. }
  27567. if m.request != nil {
  27568. fields = append(fields, usagedetail.FieldRequest)
  27569. }
  27570. if m.response != nil {
  27571. fields = append(fields, usagedetail.FieldResponse)
  27572. }
  27573. if m.original_data != nil {
  27574. fields = append(fields, usagedetail.FieldOriginalData)
  27575. }
  27576. if m.total_tokens != nil {
  27577. fields = append(fields, usagedetail.FieldTotalTokens)
  27578. }
  27579. if m.prompt_tokens != nil {
  27580. fields = append(fields, usagedetail.FieldPromptTokens)
  27581. }
  27582. if m.completion_tokens != nil {
  27583. fields = append(fields, usagedetail.FieldCompletionTokens)
  27584. }
  27585. if m.organization_id != nil {
  27586. fields = append(fields, usagedetail.FieldOrganizationID)
  27587. }
  27588. return fields
  27589. }
  27590. // Field returns the value of a field with the given name. The second boolean
  27591. // return value indicates that this field was not set, or was not defined in the
  27592. // schema.
  27593. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27594. switch name {
  27595. case usagedetail.FieldCreatedAt:
  27596. return m.CreatedAt()
  27597. case usagedetail.FieldUpdatedAt:
  27598. return m.UpdatedAt()
  27599. case usagedetail.FieldStatus:
  27600. return m.Status()
  27601. case usagedetail.FieldType:
  27602. return m.GetType()
  27603. case usagedetail.FieldBotID:
  27604. return m.BotID()
  27605. case usagedetail.FieldReceiverID:
  27606. return m.ReceiverID()
  27607. case usagedetail.FieldApp:
  27608. return m.App()
  27609. case usagedetail.FieldSessionID:
  27610. return m.SessionID()
  27611. case usagedetail.FieldRequest:
  27612. return m.Request()
  27613. case usagedetail.FieldResponse:
  27614. return m.Response()
  27615. case usagedetail.FieldOriginalData:
  27616. return m.OriginalData()
  27617. case usagedetail.FieldTotalTokens:
  27618. return m.TotalTokens()
  27619. case usagedetail.FieldPromptTokens:
  27620. return m.PromptTokens()
  27621. case usagedetail.FieldCompletionTokens:
  27622. return m.CompletionTokens()
  27623. case usagedetail.FieldOrganizationID:
  27624. return m.OrganizationID()
  27625. }
  27626. return nil, false
  27627. }
  27628. // OldField returns the old value of the field from the database. An error is
  27629. // returned if the mutation operation is not UpdateOne, or the query to the
  27630. // database failed.
  27631. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27632. switch name {
  27633. case usagedetail.FieldCreatedAt:
  27634. return m.OldCreatedAt(ctx)
  27635. case usagedetail.FieldUpdatedAt:
  27636. return m.OldUpdatedAt(ctx)
  27637. case usagedetail.FieldStatus:
  27638. return m.OldStatus(ctx)
  27639. case usagedetail.FieldType:
  27640. return m.OldType(ctx)
  27641. case usagedetail.FieldBotID:
  27642. return m.OldBotID(ctx)
  27643. case usagedetail.FieldReceiverID:
  27644. return m.OldReceiverID(ctx)
  27645. case usagedetail.FieldApp:
  27646. return m.OldApp(ctx)
  27647. case usagedetail.FieldSessionID:
  27648. return m.OldSessionID(ctx)
  27649. case usagedetail.FieldRequest:
  27650. return m.OldRequest(ctx)
  27651. case usagedetail.FieldResponse:
  27652. return m.OldResponse(ctx)
  27653. case usagedetail.FieldOriginalData:
  27654. return m.OldOriginalData(ctx)
  27655. case usagedetail.FieldTotalTokens:
  27656. return m.OldTotalTokens(ctx)
  27657. case usagedetail.FieldPromptTokens:
  27658. return m.OldPromptTokens(ctx)
  27659. case usagedetail.FieldCompletionTokens:
  27660. return m.OldCompletionTokens(ctx)
  27661. case usagedetail.FieldOrganizationID:
  27662. return m.OldOrganizationID(ctx)
  27663. }
  27664. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27665. }
  27666. // SetField sets the value of a field with the given name. It returns an error if
  27667. // the field is not defined in the schema, or if the type mismatched the field
  27668. // type.
  27669. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27670. switch name {
  27671. case usagedetail.FieldCreatedAt:
  27672. v, ok := value.(time.Time)
  27673. if !ok {
  27674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27675. }
  27676. m.SetCreatedAt(v)
  27677. return nil
  27678. case usagedetail.FieldUpdatedAt:
  27679. v, ok := value.(time.Time)
  27680. if !ok {
  27681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27682. }
  27683. m.SetUpdatedAt(v)
  27684. return nil
  27685. case usagedetail.FieldStatus:
  27686. v, ok := value.(uint8)
  27687. if !ok {
  27688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27689. }
  27690. m.SetStatus(v)
  27691. return nil
  27692. case usagedetail.FieldType:
  27693. v, ok := value.(int)
  27694. if !ok {
  27695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27696. }
  27697. m.SetType(v)
  27698. return nil
  27699. case usagedetail.FieldBotID:
  27700. v, ok := value.(string)
  27701. if !ok {
  27702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27703. }
  27704. m.SetBotID(v)
  27705. return nil
  27706. case usagedetail.FieldReceiverID:
  27707. v, ok := value.(string)
  27708. if !ok {
  27709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27710. }
  27711. m.SetReceiverID(v)
  27712. return nil
  27713. case usagedetail.FieldApp:
  27714. v, ok := value.(int)
  27715. if !ok {
  27716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27717. }
  27718. m.SetApp(v)
  27719. return nil
  27720. case usagedetail.FieldSessionID:
  27721. v, ok := value.(uint64)
  27722. if !ok {
  27723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27724. }
  27725. m.SetSessionID(v)
  27726. return nil
  27727. case usagedetail.FieldRequest:
  27728. v, ok := value.(string)
  27729. if !ok {
  27730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27731. }
  27732. m.SetRequest(v)
  27733. return nil
  27734. case usagedetail.FieldResponse:
  27735. v, ok := value.(string)
  27736. if !ok {
  27737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27738. }
  27739. m.SetResponse(v)
  27740. return nil
  27741. case usagedetail.FieldOriginalData:
  27742. v, ok := value.(custom_types.OriginalData)
  27743. if !ok {
  27744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27745. }
  27746. m.SetOriginalData(v)
  27747. return nil
  27748. case usagedetail.FieldTotalTokens:
  27749. v, ok := value.(uint64)
  27750. if !ok {
  27751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27752. }
  27753. m.SetTotalTokens(v)
  27754. return nil
  27755. case usagedetail.FieldPromptTokens:
  27756. v, ok := value.(uint64)
  27757. if !ok {
  27758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27759. }
  27760. m.SetPromptTokens(v)
  27761. return nil
  27762. case usagedetail.FieldCompletionTokens:
  27763. v, ok := value.(uint64)
  27764. if !ok {
  27765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27766. }
  27767. m.SetCompletionTokens(v)
  27768. return nil
  27769. case usagedetail.FieldOrganizationID:
  27770. v, ok := value.(uint64)
  27771. if !ok {
  27772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27773. }
  27774. m.SetOrganizationID(v)
  27775. return nil
  27776. }
  27777. return fmt.Errorf("unknown UsageDetail field %s", name)
  27778. }
  27779. // AddedFields returns all numeric fields that were incremented/decremented during
  27780. // this mutation.
  27781. func (m *UsageDetailMutation) AddedFields() []string {
  27782. var fields []string
  27783. if m.addstatus != nil {
  27784. fields = append(fields, usagedetail.FieldStatus)
  27785. }
  27786. if m.add_type != nil {
  27787. fields = append(fields, usagedetail.FieldType)
  27788. }
  27789. if m.addapp != nil {
  27790. fields = append(fields, usagedetail.FieldApp)
  27791. }
  27792. if m.addsession_id != nil {
  27793. fields = append(fields, usagedetail.FieldSessionID)
  27794. }
  27795. if m.addtotal_tokens != nil {
  27796. fields = append(fields, usagedetail.FieldTotalTokens)
  27797. }
  27798. if m.addprompt_tokens != nil {
  27799. fields = append(fields, usagedetail.FieldPromptTokens)
  27800. }
  27801. if m.addcompletion_tokens != nil {
  27802. fields = append(fields, usagedetail.FieldCompletionTokens)
  27803. }
  27804. if m.addorganization_id != nil {
  27805. fields = append(fields, usagedetail.FieldOrganizationID)
  27806. }
  27807. return fields
  27808. }
  27809. // AddedField returns the numeric value that was incremented/decremented on a field
  27810. // with the given name. The second boolean return value indicates that this field
  27811. // was not set, or was not defined in the schema.
  27812. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27813. switch name {
  27814. case usagedetail.FieldStatus:
  27815. return m.AddedStatus()
  27816. case usagedetail.FieldType:
  27817. return m.AddedType()
  27818. case usagedetail.FieldApp:
  27819. return m.AddedApp()
  27820. case usagedetail.FieldSessionID:
  27821. return m.AddedSessionID()
  27822. case usagedetail.FieldTotalTokens:
  27823. return m.AddedTotalTokens()
  27824. case usagedetail.FieldPromptTokens:
  27825. return m.AddedPromptTokens()
  27826. case usagedetail.FieldCompletionTokens:
  27827. return m.AddedCompletionTokens()
  27828. case usagedetail.FieldOrganizationID:
  27829. return m.AddedOrganizationID()
  27830. }
  27831. return nil, false
  27832. }
  27833. // AddField adds the value to the field with the given name. It returns an error if
  27834. // the field is not defined in the schema, or if the type mismatched the field
  27835. // type.
  27836. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27837. switch name {
  27838. case usagedetail.FieldStatus:
  27839. v, ok := value.(int8)
  27840. if !ok {
  27841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27842. }
  27843. m.AddStatus(v)
  27844. return nil
  27845. case usagedetail.FieldType:
  27846. v, ok := value.(int)
  27847. if !ok {
  27848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27849. }
  27850. m.AddType(v)
  27851. return nil
  27852. case usagedetail.FieldApp:
  27853. v, ok := value.(int)
  27854. if !ok {
  27855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27856. }
  27857. m.AddApp(v)
  27858. return nil
  27859. case usagedetail.FieldSessionID:
  27860. v, ok := value.(int64)
  27861. if !ok {
  27862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27863. }
  27864. m.AddSessionID(v)
  27865. return nil
  27866. case usagedetail.FieldTotalTokens:
  27867. v, ok := value.(int64)
  27868. if !ok {
  27869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27870. }
  27871. m.AddTotalTokens(v)
  27872. return nil
  27873. case usagedetail.FieldPromptTokens:
  27874. v, ok := value.(int64)
  27875. if !ok {
  27876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27877. }
  27878. m.AddPromptTokens(v)
  27879. return nil
  27880. case usagedetail.FieldCompletionTokens:
  27881. v, ok := value.(int64)
  27882. if !ok {
  27883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27884. }
  27885. m.AddCompletionTokens(v)
  27886. return nil
  27887. case usagedetail.FieldOrganizationID:
  27888. v, ok := value.(int64)
  27889. if !ok {
  27890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27891. }
  27892. m.AddOrganizationID(v)
  27893. return nil
  27894. }
  27895. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27896. }
  27897. // ClearedFields returns all nullable fields that were cleared during this
  27898. // mutation.
  27899. func (m *UsageDetailMutation) ClearedFields() []string {
  27900. var fields []string
  27901. if m.FieldCleared(usagedetail.FieldStatus) {
  27902. fields = append(fields, usagedetail.FieldStatus)
  27903. }
  27904. if m.FieldCleared(usagedetail.FieldType) {
  27905. fields = append(fields, usagedetail.FieldType)
  27906. }
  27907. if m.FieldCleared(usagedetail.FieldApp) {
  27908. fields = append(fields, usagedetail.FieldApp)
  27909. }
  27910. if m.FieldCleared(usagedetail.FieldSessionID) {
  27911. fields = append(fields, usagedetail.FieldSessionID)
  27912. }
  27913. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27914. fields = append(fields, usagedetail.FieldTotalTokens)
  27915. }
  27916. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27917. fields = append(fields, usagedetail.FieldPromptTokens)
  27918. }
  27919. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27920. fields = append(fields, usagedetail.FieldCompletionTokens)
  27921. }
  27922. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27923. fields = append(fields, usagedetail.FieldOrganizationID)
  27924. }
  27925. return fields
  27926. }
  27927. // FieldCleared returns a boolean indicating if a field with the given name was
  27928. // cleared in this mutation.
  27929. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27930. _, ok := m.clearedFields[name]
  27931. return ok
  27932. }
  27933. // ClearField clears the value of the field with the given name. It returns an
  27934. // error if the field is not defined in the schema.
  27935. func (m *UsageDetailMutation) ClearField(name string) error {
  27936. switch name {
  27937. case usagedetail.FieldStatus:
  27938. m.ClearStatus()
  27939. return nil
  27940. case usagedetail.FieldType:
  27941. m.ClearType()
  27942. return nil
  27943. case usagedetail.FieldApp:
  27944. m.ClearApp()
  27945. return nil
  27946. case usagedetail.FieldSessionID:
  27947. m.ClearSessionID()
  27948. return nil
  27949. case usagedetail.FieldTotalTokens:
  27950. m.ClearTotalTokens()
  27951. return nil
  27952. case usagedetail.FieldPromptTokens:
  27953. m.ClearPromptTokens()
  27954. return nil
  27955. case usagedetail.FieldCompletionTokens:
  27956. m.ClearCompletionTokens()
  27957. return nil
  27958. case usagedetail.FieldOrganizationID:
  27959. m.ClearOrganizationID()
  27960. return nil
  27961. }
  27962. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27963. }
  27964. // ResetField resets all changes in the mutation for the field with the given name.
  27965. // It returns an error if the field is not defined in the schema.
  27966. func (m *UsageDetailMutation) ResetField(name string) error {
  27967. switch name {
  27968. case usagedetail.FieldCreatedAt:
  27969. m.ResetCreatedAt()
  27970. return nil
  27971. case usagedetail.FieldUpdatedAt:
  27972. m.ResetUpdatedAt()
  27973. return nil
  27974. case usagedetail.FieldStatus:
  27975. m.ResetStatus()
  27976. return nil
  27977. case usagedetail.FieldType:
  27978. m.ResetType()
  27979. return nil
  27980. case usagedetail.FieldBotID:
  27981. m.ResetBotID()
  27982. return nil
  27983. case usagedetail.FieldReceiverID:
  27984. m.ResetReceiverID()
  27985. return nil
  27986. case usagedetail.FieldApp:
  27987. m.ResetApp()
  27988. return nil
  27989. case usagedetail.FieldSessionID:
  27990. m.ResetSessionID()
  27991. return nil
  27992. case usagedetail.FieldRequest:
  27993. m.ResetRequest()
  27994. return nil
  27995. case usagedetail.FieldResponse:
  27996. m.ResetResponse()
  27997. return nil
  27998. case usagedetail.FieldOriginalData:
  27999. m.ResetOriginalData()
  28000. return nil
  28001. case usagedetail.FieldTotalTokens:
  28002. m.ResetTotalTokens()
  28003. return nil
  28004. case usagedetail.FieldPromptTokens:
  28005. m.ResetPromptTokens()
  28006. return nil
  28007. case usagedetail.FieldCompletionTokens:
  28008. m.ResetCompletionTokens()
  28009. return nil
  28010. case usagedetail.FieldOrganizationID:
  28011. m.ResetOrganizationID()
  28012. return nil
  28013. }
  28014. return fmt.Errorf("unknown UsageDetail field %s", name)
  28015. }
  28016. // AddedEdges returns all edge names that were set/added in this mutation.
  28017. func (m *UsageDetailMutation) AddedEdges() []string {
  28018. edges := make([]string, 0, 0)
  28019. return edges
  28020. }
  28021. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28022. // name in this mutation.
  28023. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28024. return nil
  28025. }
  28026. // RemovedEdges returns all edge names that were removed in this mutation.
  28027. func (m *UsageDetailMutation) RemovedEdges() []string {
  28028. edges := make([]string, 0, 0)
  28029. return edges
  28030. }
  28031. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28032. // the given name in this mutation.
  28033. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28034. return nil
  28035. }
  28036. // ClearedEdges returns all edge names that were cleared in this mutation.
  28037. func (m *UsageDetailMutation) ClearedEdges() []string {
  28038. edges := make([]string, 0, 0)
  28039. return edges
  28040. }
  28041. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28042. // was cleared in this mutation.
  28043. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28044. return false
  28045. }
  28046. // ClearEdge clears the value of the edge with the given name. It returns an error
  28047. // if that edge is not defined in the schema.
  28048. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28049. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28050. }
  28051. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28052. // It returns an error if the edge is not defined in the schema.
  28053. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28054. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28055. }
  28056. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28057. type UsageStatisticDayMutation struct {
  28058. config
  28059. op Op
  28060. typ string
  28061. id *uint64
  28062. created_at *time.Time
  28063. updated_at *time.Time
  28064. status *uint8
  28065. addstatus *int8
  28066. deleted_at *time.Time
  28067. addtime *uint64
  28068. addaddtime *int64
  28069. _type *int
  28070. add_type *int
  28071. bot_id *string
  28072. organization_id *uint64
  28073. addorganization_id *int64
  28074. ai_response *uint64
  28075. addai_response *int64
  28076. sop_run *uint64
  28077. addsop_run *int64
  28078. total_friend *uint64
  28079. addtotal_friend *int64
  28080. total_group *uint64
  28081. addtotal_group *int64
  28082. account_balance *uint64
  28083. addaccount_balance *int64
  28084. consume_token *uint64
  28085. addconsume_token *int64
  28086. active_user *uint64
  28087. addactive_user *int64
  28088. new_user *int64
  28089. addnew_user *int64
  28090. label_dist *[]custom_types.LabelDist
  28091. appendlabel_dist []custom_types.LabelDist
  28092. clearedFields map[string]struct{}
  28093. done bool
  28094. oldValue func(context.Context) (*UsageStatisticDay, error)
  28095. predicates []predicate.UsageStatisticDay
  28096. }
  28097. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28098. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28099. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28100. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28101. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28102. m := &UsageStatisticDayMutation{
  28103. config: c,
  28104. op: op,
  28105. typ: TypeUsageStatisticDay,
  28106. clearedFields: make(map[string]struct{}),
  28107. }
  28108. for _, opt := range opts {
  28109. opt(m)
  28110. }
  28111. return m
  28112. }
  28113. // withUsageStatisticDayID sets the ID field of the mutation.
  28114. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28115. return func(m *UsageStatisticDayMutation) {
  28116. var (
  28117. err error
  28118. once sync.Once
  28119. value *UsageStatisticDay
  28120. )
  28121. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28122. once.Do(func() {
  28123. if m.done {
  28124. err = errors.New("querying old values post mutation is not allowed")
  28125. } else {
  28126. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28127. }
  28128. })
  28129. return value, err
  28130. }
  28131. m.id = &id
  28132. }
  28133. }
  28134. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28135. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28136. return func(m *UsageStatisticDayMutation) {
  28137. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28138. return node, nil
  28139. }
  28140. m.id = &node.ID
  28141. }
  28142. }
  28143. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28144. // executed in a transaction (ent.Tx), a transactional client is returned.
  28145. func (m UsageStatisticDayMutation) Client() *Client {
  28146. client := &Client{config: m.config}
  28147. client.init()
  28148. return client
  28149. }
  28150. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28151. // it returns an error otherwise.
  28152. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28153. if _, ok := m.driver.(*txDriver); !ok {
  28154. return nil, errors.New("ent: mutation is not running in a transaction")
  28155. }
  28156. tx := &Tx{config: m.config}
  28157. tx.init()
  28158. return tx, nil
  28159. }
  28160. // SetID sets the value of the id field. Note that this
  28161. // operation is only accepted on creation of UsageStatisticDay entities.
  28162. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28163. m.id = &id
  28164. }
  28165. // ID returns the ID value in the mutation. Note that the ID is only available
  28166. // if it was provided to the builder or after it was returned from the database.
  28167. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28168. if m.id == nil {
  28169. return
  28170. }
  28171. return *m.id, true
  28172. }
  28173. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28174. // That means, if the mutation is applied within a transaction with an isolation level such
  28175. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28176. // or updated by the mutation.
  28177. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28178. switch {
  28179. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28180. id, exists := m.ID()
  28181. if exists {
  28182. return []uint64{id}, nil
  28183. }
  28184. fallthrough
  28185. case m.op.Is(OpUpdate | OpDelete):
  28186. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28187. default:
  28188. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28189. }
  28190. }
  28191. // SetCreatedAt sets the "created_at" field.
  28192. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28193. m.created_at = &t
  28194. }
  28195. // CreatedAt returns the value of the "created_at" field in the mutation.
  28196. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28197. v := m.created_at
  28198. if v == nil {
  28199. return
  28200. }
  28201. return *v, true
  28202. }
  28203. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28204. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28206. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28207. if !m.op.Is(OpUpdateOne) {
  28208. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28209. }
  28210. if m.id == nil || m.oldValue == nil {
  28211. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28212. }
  28213. oldValue, err := m.oldValue(ctx)
  28214. if err != nil {
  28215. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28216. }
  28217. return oldValue.CreatedAt, nil
  28218. }
  28219. // ResetCreatedAt resets all changes to the "created_at" field.
  28220. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28221. m.created_at = nil
  28222. }
  28223. // SetUpdatedAt sets the "updated_at" field.
  28224. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28225. m.updated_at = &t
  28226. }
  28227. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28228. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28229. v := m.updated_at
  28230. if v == nil {
  28231. return
  28232. }
  28233. return *v, true
  28234. }
  28235. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28236. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28238. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28239. if !m.op.Is(OpUpdateOne) {
  28240. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28241. }
  28242. if m.id == nil || m.oldValue == nil {
  28243. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28244. }
  28245. oldValue, err := m.oldValue(ctx)
  28246. if err != nil {
  28247. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28248. }
  28249. return oldValue.UpdatedAt, nil
  28250. }
  28251. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28252. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28253. m.updated_at = nil
  28254. }
  28255. // SetStatus sets the "status" field.
  28256. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28257. m.status = &u
  28258. m.addstatus = nil
  28259. }
  28260. // Status returns the value of the "status" field in the mutation.
  28261. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28262. v := m.status
  28263. if v == nil {
  28264. return
  28265. }
  28266. return *v, true
  28267. }
  28268. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28269. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28271. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28272. if !m.op.Is(OpUpdateOne) {
  28273. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28274. }
  28275. if m.id == nil || m.oldValue == nil {
  28276. return v, errors.New("OldStatus requires an ID field in the mutation")
  28277. }
  28278. oldValue, err := m.oldValue(ctx)
  28279. if err != nil {
  28280. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28281. }
  28282. return oldValue.Status, nil
  28283. }
  28284. // AddStatus adds u to the "status" field.
  28285. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28286. if m.addstatus != nil {
  28287. *m.addstatus += u
  28288. } else {
  28289. m.addstatus = &u
  28290. }
  28291. }
  28292. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28293. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28294. v := m.addstatus
  28295. if v == nil {
  28296. return
  28297. }
  28298. return *v, true
  28299. }
  28300. // ClearStatus clears the value of the "status" field.
  28301. func (m *UsageStatisticDayMutation) ClearStatus() {
  28302. m.status = nil
  28303. m.addstatus = nil
  28304. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28305. }
  28306. // StatusCleared returns if the "status" field was cleared in this mutation.
  28307. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28308. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28309. return ok
  28310. }
  28311. // ResetStatus resets all changes to the "status" field.
  28312. func (m *UsageStatisticDayMutation) ResetStatus() {
  28313. m.status = nil
  28314. m.addstatus = nil
  28315. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28316. }
  28317. // SetDeletedAt sets the "deleted_at" field.
  28318. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28319. m.deleted_at = &t
  28320. }
  28321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28322. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28323. v := m.deleted_at
  28324. if v == nil {
  28325. return
  28326. }
  28327. return *v, true
  28328. }
  28329. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28330. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28332. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28333. if !m.op.Is(OpUpdateOne) {
  28334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28335. }
  28336. if m.id == nil || m.oldValue == nil {
  28337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28338. }
  28339. oldValue, err := m.oldValue(ctx)
  28340. if err != nil {
  28341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28342. }
  28343. return oldValue.DeletedAt, nil
  28344. }
  28345. // ClearDeletedAt clears the value of the "deleted_at" field.
  28346. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28347. m.deleted_at = nil
  28348. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28349. }
  28350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28351. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28352. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28353. return ok
  28354. }
  28355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28356. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28357. m.deleted_at = nil
  28358. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28359. }
  28360. // SetAddtime sets the "addtime" field.
  28361. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28362. m.addtime = &u
  28363. m.addaddtime = nil
  28364. }
  28365. // Addtime returns the value of the "addtime" field in the mutation.
  28366. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28367. v := m.addtime
  28368. if v == nil {
  28369. return
  28370. }
  28371. return *v, true
  28372. }
  28373. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28374. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28376. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28377. if !m.op.Is(OpUpdateOne) {
  28378. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28379. }
  28380. if m.id == nil || m.oldValue == nil {
  28381. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28382. }
  28383. oldValue, err := m.oldValue(ctx)
  28384. if err != nil {
  28385. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28386. }
  28387. return oldValue.Addtime, nil
  28388. }
  28389. // AddAddtime adds u to the "addtime" field.
  28390. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28391. if m.addaddtime != nil {
  28392. *m.addaddtime += u
  28393. } else {
  28394. m.addaddtime = &u
  28395. }
  28396. }
  28397. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28398. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28399. v := m.addaddtime
  28400. if v == nil {
  28401. return
  28402. }
  28403. return *v, true
  28404. }
  28405. // ResetAddtime resets all changes to the "addtime" field.
  28406. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28407. m.addtime = nil
  28408. m.addaddtime = nil
  28409. }
  28410. // SetType sets the "type" field.
  28411. func (m *UsageStatisticDayMutation) SetType(i int) {
  28412. m._type = &i
  28413. m.add_type = nil
  28414. }
  28415. // GetType returns the value of the "type" field in the mutation.
  28416. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28417. v := m._type
  28418. if v == nil {
  28419. return
  28420. }
  28421. return *v, true
  28422. }
  28423. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28424. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28426. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28427. if !m.op.Is(OpUpdateOne) {
  28428. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28429. }
  28430. if m.id == nil || m.oldValue == nil {
  28431. return v, errors.New("OldType requires an ID field in the mutation")
  28432. }
  28433. oldValue, err := m.oldValue(ctx)
  28434. if err != nil {
  28435. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28436. }
  28437. return oldValue.Type, nil
  28438. }
  28439. // AddType adds i to the "type" field.
  28440. func (m *UsageStatisticDayMutation) AddType(i int) {
  28441. if m.add_type != nil {
  28442. *m.add_type += i
  28443. } else {
  28444. m.add_type = &i
  28445. }
  28446. }
  28447. // AddedType returns the value that was added to the "type" field in this mutation.
  28448. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28449. v := m.add_type
  28450. if v == nil {
  28451. return
  28452. }
  28453. return *v, true
  28454. }
  28455. // ResetType resets all changes to the "type" field.
  28456. func (m *UsageStatisticDayMutation) ResetType() {
  28457. m._type = nil
  28458. m.add_type = nil
  28459. }
  28460. // SetBotID sets the "bot_id" field.
  28461. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28462. m.bot_id = &s
  28463. }
  28464. // BotID returns the value of the "bot_id" field in the mutation.
  28465. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28466. v := m.bot_id
  28467. if v == nil {
  28468. return
  28469. }
  28470. return *v, true
  28471. }
  28472. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28473. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28475. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28476. if !m.op.Is(OpUpdateOne) {
  28477. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28478. }
  28479. if m.id == nil || m.oldValue == nil {
  28480. return v, errors.New("OldBotID requires an ID field in the mutation")
  28481. }
  28482. oldValue, err := m.oldValue(ctx)
  28483. if err != nil {
  28484. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28485. }
  28486. return oldValue.BotID, nil
  28487. }
  28488. // ClearBotID clears the value of the "bot_id" field.
  28489. func (m *UsageStatisticDayMutation) ClearBotID() {
  28490. m.bot_id = nil
  28491. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28492. }
  28493. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28494. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28495. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28496. return ok
  28497. }
  28498. // ResetBotID resets all changes to the "bot_id" field.
  28499. func (m *UsageStatisticDayMutation) ResetBotID() {
  28500. m.bot_id = nil
  28501. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28502. }
  28503. // SetOrganizationID sets the "organization_id" field.
  28504. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28505. m.organization_id = &u
  28506. m.addorganization_id = nil
  28507. }
  28508. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28509. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28510. v := m.organization_id
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28517. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28519. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28525. }
  28526. oldValue, err := m.oldValue(ctx)
  28527. if err != nil {
  28528. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28529. }
  28530. return oldValue.OrganizationID, nil
  28531. }
  28532. // AddOrganizationID adds u to the "organization_id" field.
  28533. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28534. if m.addorganization_id != nil {
  28535. *m.addorganization_id += u
  28536. } else {
  28537. m.addorganization_id = &u
  28538. }
  28539. }
  28540. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28541. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28542. v := m.addorganization_id
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ClearOrganizationID clears the value of the "organization_id" field.
  28549. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28550. m.organization_id = nil
  28551. m.addorganization_id = nil
  28552. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28553. }
  28554. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28555. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28556. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28557. return ok
  28558. }
  28559. // ResetOrganizationID resets all changes to the "organization_id" field.
  28560. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28561. m.organization_id = nil
  28562. m.addorganization_id = nil
  28563. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28564. }
  28565. // SetAiResponse sets the "ai_response" field.
  28566. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28567. m.ai_response = &u
  28568. m.addai_response = nil
  28569. }
  28570. // AiResponse returns the value of the "ai_response" field in the mutation.
  28571. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28572. v := m.ai_response
  28573. if v == nil {
  28574. return
  28575. }
  28576. return *v, true
  28577. }
  28578. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28579. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28581. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28582. if !m.op.Is(OpUpdateOne) {
  28583. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28584. }
  28585. if m.id == nil || m.oldValue == nil {
  28586. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28587. }
  28588. oldValue, err := m.oldValue(ctx)
  28589. if err != nil {
  28590. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28591. }
  28592. return oldValue.AiResponse, nil
  28593. }
  28594. // AddAiResponse adds u to the "ai_response" field.
  28595. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28596. if m.addai_response != nil {
  28597. *m.addai_response += u
  28598. } else {
  28599. m.addai_response = &u
  28600. }
  28601. }
  28602. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28603. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28604. v := m.addai_response
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // ResetAiResponse resets all changes to the "ai_response" field.
  28611. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28612. m.ai_response = nil
  28613. m.addai_response = nil
  28614. }
  28615. // SetSopRun sets the "sop_run" field.
  28616. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28617. m.sop_run = &u
  28618. m.addsop_run = nil
  28619. }
  28620. // SopRun returns the value of the "sop_run" field in the mutation.
  28621. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28622. v := m.sop_run
  28623. if v == nil {
  28624. return
  28625. }
  28626. return *v, true
  28627. }
  28628. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28629. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28631. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28632. if !m.op.Is(OpUpdateOne) {
  28633. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28634. }
  28635. if m.id == nil || m.oldValue == nil {
  28636. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28637. }
  28638. oldValue, err := m.oldValue(ctx)
  28639. if err != nil {
  28640. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28641. }
  28642. return oldValue.SopRun, nil
  28643. }
  28644. // AddSopRun adds u to the "sop_run" field.
  28645. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28646. if m.addsop_run != nil {
  28647. *m.addsop_run += u
  28648. } else {
  28649. m.addsop_run = &u
  28650. }
  28651. }
  28652. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28653. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28654. v := m.addsop_run
  28655. if v == nil {
  28656. return
  28657. }
  28658. return *v, true
  28659. }
  28660. // ResetSopRun resets all changes to the "sop_run" field.
  28661. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28662. m.sop_run = nil
  28663. m.addsop_run = nil
  28664. }
  28665. // SetTotalFriend sets the "total_friend" field.
  28666. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28667. m.total_friend = &u
  28668. m.addtotal_friend = nil
  28669. }
  28670. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28671. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28672. v := m.total_friend
  28673. if v == nil {
  28674. return
  28675. }
  28676. return *v, true
  28677. }
  28678. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28679. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28681. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28682. if !m.op.Is(OpUpdateOne) {
  28683. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28684. }
  28685. if m.id == nil || m.oldValue == nil {
  28686. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28687. }
  28688. oldValue, err := m.oldValue(ctx)
  28689. if err != nil {
  28690. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28691. }
  28692. return oldValue.TotalFriend, nil
  28693. }
  28694. // AddTotalFriend adds u to the "total_friend" field.
  28695. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28696. if m.addtotal_friend != nil {
  28697. *m.addtotal_friend += u
  28698. } else {
  28699. m.addtotal_friend = &u
  28700. }
  28701. }
  28702. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28703. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28704. v := m.addtotal_friend
  28705. if v == nil {
  28706. return
  28707. }
  28708. return *v, true
  28709. }
  28710. // ResetTotalFriend resets all changes to the "total_friend" field.
  28711. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28712. m.total_friend = nil
  28713. m.addtotal_friend = nil
  28714. }
  28715. // SetTotalGroup sets the "total_group" field.
  28716. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28717. m.total_group = &u
  28718. m.addtotal_group = nil
  28719. }
  28720. // TotalGroup returns the value of the "total_group" field in the mutation.
  28721. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28722. v := m.total_group
  28723. if v == nil {
  28724. return
  28725. }
  28726. return *v, true
  28727. }
  28728. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28729. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28731. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28732. if !m.op.Is(OpUpdateOne) {
  28733. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28734. }
  28735. if m.id == nil || m.oldValue == nil {
  28736. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28737. }
  28738. oldValue, err := m.oldValue(ctx)
  28739. if err != nil {
  28740. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28741. }
  28742. return oldValue.TotalGroup, nil
  28743. }
  28744. // AddTotalGroup adds u to the "total_group" field.
  28745. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28746. if m.addtotal_group != nil {
  28747. *m.addtotal_group += u
  28748. } else {
  28749. m.addtotal_group = &u
  28750. }
  28751. }
  28752. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28753. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28754. v := m.addtotal_group
  28755. if v == nil {
  28756. return
  28757. }
  28758. return *v, true
  28759. }
  28760. // ResetTotalGroup resets all changes to the "total_group" field.
  28761. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28762. m.total_group = nil
  28763. m.addtotal_group = nil
  28764. }
  28765. // SetAccountBalance sets the "account_balance" field.
  28766. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28767. m.account_balance = &u
  28768. m.addaccount_balance = nil
  28769. }
  28770. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28771. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28772. v := m.account_balance
  28773. if v == nil {
  28774. return
  28775. }
  28776. return *v, true
  28777. }
  28778. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28779. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28781. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28782. if !m.op.Is(OpUpdateOne) {
  28783. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28784. }
  28785. if m.id == nil || m.oldValue == nil {
  28786. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28787. }
  28788. oldValue, err := m.oldValue(ctx)
  28789. if err != nil {
  28790. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28791. }
  28792. return oldValue.AccountBalance, nil
  28793. }
  28794. // AddAccountBalance adds u to the "account_balance" field.
  28795. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28796. if m.addaccount_balance != nil {
  28797. *m.addaccount_balance += u
  28798. } else {
  28799. m.addaccount_balance = &u
  28800. }
  28801. }
  28802. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28803. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28804. v := m.addaccount_balance
  28805. if v == nil {
  28806. return
  28807. }
  28808. return *v, true
  28809. }
  28810. // ResetAccountBalance resets all changes to the "account_balance" field.
  28811. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28812. m.account_balance = nil
  28813. m.addaccount_balance = nil
  28814. }
  28815. // SetConsumeToken sets the "consume_token" field.
  28816. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28817. m.consume_token = &u
  28818. m.addconsume_token = nil
  28819. }
  28820. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28821. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28822. v := m.consume_token
  28823. if v == nil {
  28824. return
  28825. }
  28826. return *v, true
  28827. }
  28828. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28829. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28831. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28832. if !m.op.Is(OpUpdateOne) {
  28833. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28834. }
  28835. if m.id == nil || m.oldValue == nil {
  28836. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28837. }
  28838. oldValue, err := m.oldValue(ctx)
  28839. if err != nil {
  28840. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28841. }
  28842. return oldValue.ConsumeToken, nil
  28843. }
  28844. // AddConsumeToken adds u to the "consume_token" field.
  28845. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28846. if m.addconsume_token != nil {
  28847. *m.addconsume_token += u
  28848. } else {
  28849. m.addconsume_token = &u
  28850. }
  28851. }
  28852. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28853. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28854. v := m.addconsume_token
  28855. if v == nil {
  28856. return
  28857. }
  28858. return *v, true
  28859. }
  28860. // ResetConsumeToken resets all changes to the "consume_token" field.
  28861. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28862. m.consume_token = nil
  28863. m.addconsume_token = nil
  28864. }
  28865. // SetActiveUser sets the "active_user" field.
  28866. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28867. m.active_user = &u
  28868. m.addactive_user = nil
  28869. }
  28870. // ActiveUser returns the value of the "active_user" field in the mutation.
  28871. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28872. v := m.active_user
  28873. if v == nil {
  28874. return
  28875. }
  28876. return *v, true
  28877. }
  28878. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28879. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28881. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28882. if !m.op.Is(OpUpdateOne) {
  28883. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28884. }
  28885. if m.id == nil || m.oldValue == nil {
  28886. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28887. }
  28888. oldValue, err := m.oldValue(ctx)
  28889. if err != nil {
  28890. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28891. }
  28892. return oldValue.ActiveUser, nil
  28893. }
  28894. // AddActiveUser adds u to the "active_user" field.
  28895. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28896. if m.addactive_user != nil {
  28897. *m.addactive_user += u
  28898. } else {
  28899. m.addactive_user = &u
  28900. }
  28901. }
  28902. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28903. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28904. v := m.addactive_user
  28905. if v == nil {
  28906. return
  28907. }
  28908. return *v, true
  28909. }
  28910. // ResetActiveUser resets all changes to the "active_user" field.
  28911. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28912. m.active_user = nil
  28913. m.addactive_user = nil
  28914. }
  28915. // SetNewUser sets the "new_user" field.
  28916. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28917. m.new_user = &i
  28918. m.addnew_user = nil
  28919. }
  28920. // NewUser returns the value of the "new_user" field in the mutation.
  28921. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28922. v := m.new_user
  28923. if v == nil {
  28924. return
  28925. }
  28926. return *v, true
  28927. }
  28928. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28929. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28931. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28932. if !m.op.Is(OpUpdateOne) {
  28933. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28934. }
  28935. if m.id == nil || m.oldValue == nil {
  28936. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28937. }
  28938. oldValue, err := m.oldValue(ctx)
  28939. if err != nil {
  28940. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28941. }
  28942. return oldValue.NewUser, nil
  28943. }
  28944. // AddNewUser adds i to the "new_user" field.
  28945. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28946. if m.addnew_user != nil {
  28947. *m.addnew_user += i
  28948. } else {
  28949. m.addnew_user = &i
  28950. }
  28951. }
  28952. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28953. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28954. v := m.addnew_user
  28955. if v == nil {
  28956. return
  28957. }
  28958. return *v, true
  28959. }
  28960. // ResetNewUser resets all changes to the "new_user" field.
  28961. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28962. m.new_user = nil
  28963. m.addnew_user = nil
  28964. }
  28965. // SetLabelDist sets the "label_dist" field.
  28966. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28967. m.label_dist = &ctd
  28968. m.appendlabel_dist = nil
  28969. }
  28970. // LabelDist returns the value of the "label_dist" field in the mutation.
  28971. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28972. v := m.label_dist
  28973. if v == nil {
  28974. return
  28975. }
  28976. return *v, true
  28977. }
  28978. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28979. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28981. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28982. if !m.op.Is(OpUpdateOne) {
  28983. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28984. }
  28985. if m.id == nil || m.oldValue == nil {
  28986. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28987. }
  28988. oldValue, err := m.oldValue(ctx)
  28989. if err != nil {
  28990. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28991. }
  28992. return oldValue.LabelDist, nil
  28993. }
  28994. // AppendLabelDist adds ctd to the "label_dist" field.
  28995. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28996. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28997. }
  28998. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28999. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29000. if len(m.appendlabel_dist) == 0 {
  29001. return nil, false
  29002. }
  29003. return m.appendlabel_dist, true
  29004. }
  29005. // ResetLabelDist resets all changes to the "label_dist" field.
  29006. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29007. m.label_dist = nil
  29008. m.appendlabel_dist = nil
  29009. }
  29010. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29011. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29012. m.predicates = append(m.predicates, ps...)
  29013. }
  29014. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29015. // users can use type-assertion to append predicates that do not depend on any generated package.
  29016. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29017. p := make([]predicate.UsageStatisticDay, len(ps))
  29018. for i := range ps {
  29019. p[i] = ps[i]
  29020. }
  29021. m.Where(p...)
  29022. }
  29023. // Op returns the operation name.
  29024. func (m *UsageStatisticDayMutation) Op() Op {
  29025. return m.op
  29026. }
  29027. // SetOp allows setting the mutation operation.
  29028. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29029. m.op = op
  29030. }
  29031. // Type returns the node type of this mutation (UsageStatisticDay).
  29032. func (m *UsageStatisticDayMutation) Type() string {
  29033. return m.typ
  29034. }
  29035. // Fields returns all fields that were changed during this mutation. Note that in
  29036. // order to get all numeric fields that were incremented/decremented, call
  29037. // AddedFields().
  29038. func (m *UsageStatisticDayMutation) Fields() []string {
  29039. fields := make([]string, 0, 17)
  29040. if m.created_at != nil {
  29041. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29042. }
  29043. if m.updated_at != nil {
  29044. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29045. }
  29046. if m.status != nil {
  29047. fields = append(fields, usagestatisticday.FieldStatus)
  29048. }
  29049. if m.deleted_at != nil {
  29050. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29051. }
  29052. if m.addtime != nil {
  29053. fields = append(fields, usagestatisticday.FieldAddtime)
  29054. }
  29055. if m._type != nil {
  29056. fields = append(fields, usagestatisticday.FieldType)
  29057. }
  29058. if m.bot_id != nil {
  29059. fields = append(fields, usagestatisticday.FieldBotID)
  29060. }
  29061. if m.organization_id != nil {
  29062. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29063. }
  29064. if m.ai_response != nil {
  29065. fields = append(fields, usagestatisticday.FieldAiResponse)
  29066. }
  29067. if m.sop_run != nil {
  29068. fields = append(fields, usagestatisticday.FieldSopRun)
  29069. }
  29070. if m.total_friend != nil {
  29071. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29072. }
  29073. if m.total_group != nil {
  29074. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29075. }
  29076. if m.account_balance != nil {
  29077. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29078. }
  29079. if m.consume_token != nil {
  29080. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29081. }
  29082. if m.active_user != nil {
  29083. fields = append(fields, usagestatisticday.FieldActiveUser)
  29084. }
  29085. if m.new_user != nil {
  29086. fields = append(fields, usagestatisticday.FieldNewUser)
  29087. }
  29088. if m.label_dist != nil {
  29089. fields = append(fields, usagestatisticday.FieldLabelDist)
  29090. }
  29091. return fields
  29092. }
  29093. // Field returns the value of a field with the given name. The second boolean
  29094. // return value indicates that this field was not set, or was not defined in the
  29095. // schema.
  29096. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29097. switch name {
  29098. case usagestatisticday.FieldCreatedAt:
  29099. return m.CreatedAt()
  29100. case usagestatisticday.FieldUpdatedAt:
  29101. return m.UpdatedAt()
  29102. case usagestatisticday.FieldStatus:
  29103. return m.Status()
  29104. case usagestatisticday.FieldDeletedAt:
  29105. return m.DeletedAt()
  29106. case usagestatisticday.FieldAddtime:
  29107. return m.Addtime()
  29108. case usagestatisticday.FieldType:
  29109. return m.GetType()
  29110. case usagestatisticday.FieldBotID:
  29111. return m.BotID()
  29112. case usagestatisticday.FieldOrganizationID:
  29113. return m.OrganizationID()
  29114. case usagestatisticday.FieldAiResponse:
  29115. return m.AiResponse()
  29116. case usagestatisticday.FieldSopRun:
  29117. return m.SopRun()
  29118. case usagestatisticday.FieldTotalFriend:
  29119. return m.TotalFriend()
  29120. case usagestatisticday.FieldTotalGroup:
  29121. return m.TotalGroup()
  29122. case usagestatisticday.FieldAccountBalance:
  29123. return m.AccountBalance()
  29124. case usagestatisticday.FieldConsumeToken:
  29125. return m.ConsumeToken()
  29126. case usagestatisticday.FieldActiveUser:
  29127. return m.ActiveUser()
  29128. case usagestatisticday.FieldNewUser:
  29129. return m.NewUser()
  29130. case usagestatisticday.FieldLabelDist:
  29131. return m.LabelDist()
  29132. }
  29133. return nil, false
  29134. }
  29135. // OldField returns the old value of the field from the database. An error is
  29136. // returned if the mutation operation is not UpdateOne, or the query to the
  29137. // database failed.
  29138. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29139. switch name {
  29140. case usagestatisticday.FieldCreatedAt:
  29141. return m.OldCreatedAt(ctx)
  29142. case usagestatisticday.FieldUpdatedAt:
  29143. return m.OldUpdatedAt(ctx)
  29144. case usagestatisticday.FieldStatus:
  29145. return m.OldStatus(ctx)
  29146. case usagestatisticday.FieldDeletedAt:
  29147. return m.OldDeletedAt(ctx)
  29148. case usagestatisticday.FieldAddtime:
  29149. return m.OldAddtime(ctx)
  29150. case usagestatisticday.FieldType:
  29151. return m.OldType(ctx)
  29152. case usagestatisticday.FieldBotID:
  29153. return m.OldBotID(ctx)
  29154. case usagestatisticday.FieldOrganizationID:
  29155. return m.OldOrganizationID(ctx)
  29156. case usagestatisticday.FieldAiResponse:
  29157. return m.OldAiResponse(ctx)
  29158. case usagestatisticday.FieldSopRun:
  29159. return m.OldSopRun(ctx)
  29160. case usagestatisticday.FieldTotalFriend:
  29161. return m.OldTotalFriend(ctx)
  29162. case usagestatisticday.FieldTotalGroup:
  29163. return m.OldTotalGroup(ctx)
  29164. case usagestatisticday.FieldAccountBalance:
  29165. return m.OldAccountBalance(ctx)
  29166. case usagestatisticday.FieldConsumeToken:
  29167. return m.OldConsumeToken(ctx)
  29168. case usagestatisticday.FieldActiveUser:
  29169. return m.OldActiveUser(ctx)
  29170. case usagestatisticday.FieldNewUser:
  29171. return m.OldNewUser(ctx)
  29172. case usagestatisticday.FieldLabelDist:
  29173. return m.OldLabelDist(ctx)
  29174. }
  29175. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29176. }
  29177. // SetField sets the value of a field with the given name. It returns an error if
  29178. // the field is not defined in the schema, or if the type mismatched the field
  29179. // type.
  29180. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29181. switch name {
  29182. case usagestatisticday.FieldCreatedAt:
  29183. v, ok := value.(time.Time)
  29184. if !ok {
  29185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29186. }
  29187. m.SetCreatedAt(v)
  29188. return nil
  29189. case usagestatisticday.FieldUpdatedAt:
  29190. v, ok := value.(time.Time)
  29191. if !ok {
  29192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29193. }
  29194. m.SetUpdatedAt(v)
  29195. return nil
  29196. case usagestatisticday.FieldStatus:
  29197. v, ok := value.(uint8)
  29198. if !ok {
  29199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29200. }
  29201. m.SetStatus(v)
  29202. return nil
  29203. case usagestatisticday.FieldDeletedAt:
  29204. v, ok := value.(time.Time)
  29205. if !ok {
  29206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29207. }
  29208. m.SetDeletedAt(v)
  29209. return nil
  29210. case usagestatisticday.FieldAddtime:
  29211. v, ok := value.(uint64)
  29212. if !ok {
  29213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29214. }
  29215. m.SetAddtime(v)
  29216. return nil
  29217. case usagestatisticday.FieldType:
  29218. v, ok := value.(int)
  29219. if !ok {
  29220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29221. }
  29222. m.SetType(v)
  29223. return nil
  29224. case usagestatisticday.FieldBotID:
  29225. v, ok := value.(string)
  29226. if !ok {
  29227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29228. }
  29229. m.SetBotID(v)
  29230. return nil
  29231. case usagestatisticday.FieldOrganizationID:
  29232. v, ok := value.(uint64)
  29233. if !ok {
  29234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29235. }
  29236. m.SetOrganizationID(v)
  29237. return nil
  29238. case usagestatisticday.FieldAiResponse:
  29239. v, ok := value.(uint64)
  29240. if !ok {
  29241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29242. }
  29243. m.SetAiResponse(v)
  29244. return nil
  29245. case usagestatisticday.FieldSopRun:
  29246. v, ok := value.(uint64)
  29247. if !ok {
  29248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29249. }
  29250. m.SetSopRun(v)
  29251. return nil
  29252. case usagestatisticday.FieldTotalFriend:
  29253. v, ok := value.(uint64)
  29254. if !ok {
  29255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29256. }
  29257. m.SetTotalFriend(v)
  29258. return nil
  29259. case usagestatisticday.FieldTotalGroup:
  29260. v, ok := value.(uint64)
  29261. if !ok {
  29262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29263. }
  29264. m.SetTotalGroup(v)
  29265. return nil
  29266. case usagestatisticday.FieldAccountBalance:
  29267. v, ok := value.(uint64)
  29268. if !ok {
  29269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29270. }
  29271. m.SetAccountBalance(v)
  29272. return nil
  29273. case usagestatisticday.FieldConsumeToken:
  29274. v, ok := value.(uint64)
  29275. if !ok {
  29276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29277. }
  29278. m.SetConsumeToken(v)
  29279. return nil
  29280. case usagestatisticday.FieldActiveUser:
  29281. v, ok := value.(uint64)
  29282. if !ok {
  29283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29284. }
  29285. m.SetActiveUser(v)
  29286. return nil
  29287. case usagestatisticday.FieldNewUser:
  29288. v, ok := value.(int64)
  29289. if !ok {
  29290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29291. }
  29292. m.SetNewUser(v)
  29293. return nil
  29294. case usagestatisticday.FieldLabelDist:
  29295. v, ok := value.([]custom_types.LabelDist)
  29296. if !ok {
  29297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29298. }
  29299. m.SetLabelDist(v)
  29300. return nil
  29301. }
  29302. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29303. }
  29304. // AddedFields returns all numeric fields that were incremented/decremented during
  29305. // this mutation.
  29306. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29307. var fields []string
  29308. if m.addstatus != nil {
  29309. fields = append(fields, usagestatisticday.FieldStatus)
  29310. }
  29311. if m.addaddtime != nil {
  29312. fields = append(fields, usagestatisticday.FieldAddtime)
  29313. }
  29314. if m.add_type != nil {
  29315. fields = append(fields, usagestatisticday.FieldType)
  29316. }
  29317. if m.addorganization_id != nil {
  29318. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29319. }
  29320. if m.addai_response != nil {
  29321. fields = append(fields, usagestatisticday.FieldAiResponse)
  29322. }
  29323. if m.addsop_run != nil {
  29324. fields = append(fields, usagestatisticday.FieldSopRun)
  29325. }
  29326. if m.addtotal_friend != nil {
  29327. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29328. }
  29329. if m.addtotal_group != nil {
  29330. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29331. }
  29332. if m.addaccount_balance != nil {
  29333. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29334. }
  29335. if m.addconsume_token != nil {
  29336. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29337. }
  29338. if m.addactive_user != nil {
  29339. fields = append(fields, usagestatisticday.FieldActiveUser)
  29340. }
  29341. if m.addnew_user != nil {
  29342. fields = append(fields, usagestatisticday.FieldNewUser)
  29343. }
  29344. return fields
  29345. }
  29346. // AddedField returns the numeric value that was incremented/decremented on a field
  29347. // with the given name. The second boolean return value indicates that this field
  29348. // was not set, or was not defined in the schema.
  29349. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29350. switch name {
  29351. case usagestatisticday.FieldStatus:
  29352. return m.AddedStatus()
  29353. case usagestatisticday.FieldAddtime:
  29354. return m.AddedAddtime()
  29355. case usagestatisticday.FieldType:
  29356. return m.AddedType()
  29357. case usagestatisticday.FieldOrganizationID:
  29358. return m.AddedOrganizationID()
  29359. case usagestatisticday.FieldAiResponse:
  29360. return m.AddedAiResponse()
  29361. case usagestatisticday.FieldSopRun:
  29362. return m.AddedSopRun()
  29363. case usagestatisticday.FieldTotalFriend:
  29364. return m.AddedTotalFriend()
  29365. case usagestatisticday.FieldTotalGroup:
  29366. return m.AddedTotalGroup()
  29367. case usagestatisticday.FieldAccountBalance:
  29368. return m.AddedAccountBalance()
  29369. case usagestatisticday.FieldConsumeToken:
  29370. return m.AddedConsumeToken()
  29371. case usagestatisticday.FieldActiveUser:
  29372. return m.AddedActiveUser()
  29373. case usagestatisticday.FieldNewUser:
  29374. return m.AddedNewUser()
  29375. }
  29376. return nil, false
  29377. }
  29378. // AddField adds the value to the field with the given name. It returns an error if
  29379. // the field is not defined in the schema, or if the type mismatched the field
  29380. // type.
  29381. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29382. switch name {
  29383. case usagestatisticday.FieldStatus:
  29384. v, ok := value.(int8)
  29385. if !ok {
  29386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29387. }
  29388. m.AddStatus(v)
  29389. return nil
  29390. case usagestatisticday.FieldAddtime:
  29391. v, ok := value.(int64)
  29392. if !ok {
  29393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29394. }
  29395. m.AddAddtime(v)
  29396. return nil
  29397. case usagestatisticday.FieldType:
  29398. v, ok := value.(int)
  29399. if !ok {
  29400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29401. }
  29402. m.AddType(v)
  29403. return nil
  29404. case usagestatisticday.FieldOrganizationID:
  29405. v, ok := value.(int64)
  29406. if !ok {
  29407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29408. }
  29409. m.AddOrganizationID(v)
  29410. return nil
  29411. case usagestatisticday.FieldAiResponse:
  29412. v, ok := value.(int64)
  29413. if !ok {
  29414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29415. }
  29416. m.AddAiResponse(v)
  29417. return nil
  29418. case usagestatisticday.FieldSopRun:
  29419. v, ok := value.(int64)
  29420. if !ok {
  29421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29422. }
  29423. m.AddSopRun(v)
  29424. return nil
  29425. case usagestatisticday.FieldTotalFriend:
  29426. v, ok := value.(int64)
  29427. if !ok {
  29428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29429. }
  29430. m.AddTotalFriend(v)
  29431. return nil
  29432. case usagestatisticday.FieldTotalGroup:
  29433. v, ok := value.(int64)
  29434. if !ok {
  29435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29436. }
  29437. m.AddTotalGroup(v)
  29438. return nil
  29439. case usagestatisticday.FieldAccountBalance:
  29440. v, ok := value.(int64)
  29441. if !ok {
  29442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29443. }
  29444. m.AddAccountBalance(v)
  29445. return nil
  29446. case usagestatisticday.FieldConsumeToken:
  29447. v, ok := value.(int64)
  29448. if !ok {
  29449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29450. }
  29451. m.AddConsumeToken(v)
  29452. return nil
  29453. case usagestatisticday.FieldActiveUser:
  29454. v, ok := value.(int64)
  29455. if !ok {
  29456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29457. }
  29458. m.AddActiveUser(v)
  29459. return nil
  29460. case usagestatisticday.FieldNewUser:
  29461. v, ok := value.(int64)
  29462. if !ok {
  29463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29464. }
  29465. m.AddNewUser(v)
  29466. return nil
  29467. }
  29468. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29469. }
  29470. // ClearedFields returns all nullable fields that were cleared during this
  29471. // mutation.
  29472. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29473. var fields []string
  29474. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29475. fields = append(fields, usagestatisticday.FieldStatus)
  29476. }
  29477. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29478. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29479. }
  29480. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29481. fields = append(fields, usagestatisticday.FieldBotID)
  29482. }
  29483. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29484. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29485. }
  29486. return fields
  29487. }
  29488. // FieldCleared returns a boolean indicating if a field with the given name was
  29489. // cleared in this mutation.
  29490. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29491. _, ok := m.clearedFields[name]
  29492. return ok
  29493. }
  29494. // ClearField clears the value of the field with the given name. It returns an
  29495. // error if the field is not defined in the schema.
  29496. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29497. switch name {
  29498. case usagestatisticday.FieldStatus:
  29499. m.ClearStatus()
  29500. return nil
  29501. case usagestatisticday.FieldDeletedAt:
  29502. m.ClearDeletedAt()
  29503. return nil
  29504. case usagestatisticday.FieldBotID:
  29505. m.ClearBotID()
  29506. return nil
  29507. case usagestatisticday.FieldOrganizationID:
  29508. m.ClearOrganizationID()
  29509. return nil
  29510. }
  29511. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29512. }
  29513. // ResetField resets all changes in the mutation for the field with the given name.
  29514. // It returns an error if the field is not defined in the schema.
  29515. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29516. switch name {
  29517. case usagestatisticday.FieldCreatedAt:
  29518. m.ResetCreatedAt()
  29519. return nil
  29520. case usagestatisticday.FieldUpdatedAt:
  29521. m.ResetUpdatedAt()
  29522. return nil
  29523. case usagestatisticday.FieldStatus:
  29524. m.ResetStatus()
  29525. return nil
  29526. case usagestatisticday.FieldDeletedAt:
  29527. m.ResetDeletedAt()
  29528. return nil
  29529. case usagestatisticday.FieldAddtime:
  29530. m.ResetAddtime()
  29531. return nil
  29532. case usagestatisticday.FieldType:
  29533. m.ResetType()
  29534. return nil
  29535. case usagestatisticday.FieldBotID:
  29536. m.ResetBotID()
  29537. return nil
  29538. case usagestatisticday.FieldOrganizationID:
  29539. m.ResetOrganizationID()
  29540. return nil
  29541. case usagestatisticday.FieldAiResponse:
  29542. m.ResetAiResponse()
  29543. return nil
  29544. case usagestatisticday.FieldSopRun:
  29545. m.ResetSopRun()
  29546. return nil
  29547. case usagestatisticday.FieldTotalFriend:
  29548. m.ResetTotalFriend()
  29549. return nil
  29550. case usagestatisticday.FieldTotalGroup:
  29551. m.ResetTotalGroup()
  29552. return nil
  29553. case usagestatisticday.FieldAccountBalance:
  29554. m.ResetAccountBalance()
  29555. return nil
  29556. case usagestatisticday.FieldConsumeToken:
  29557. m.ResetConsumeToken()
  29558. return nil
  29559. case usagestatisticday.FieldActiveUser:
  29560. m.ResetActiveUser()
  29561. return nil
  29562. case usagestatisticday.FieldNewUser:
  29563. m.ResetNewUser()
  29564. return nil
  29565. case usagestatisticday.FieldLabelDist:
  29566. m.ResetLabelDist()
  29567. return nil
  29568. }
  29569. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29570. }
  29571. // AddedEdges returns all edge names that were set/added in this mutation.
  29572. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29573. edges := make([]string, 0, 0)
  29574. return edges
  29575. }
  29576. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29577. // name in this mutation.
  29578. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29579. return nil
  29580. }
  29581. // RemovedEdges returns all edge names that were removed in this mutation.
  29582. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29583. edges := make([]string, 0, 0)
  29584. return edges
  29585. }
  29586. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29587. // the given name in this mutation.
  29588. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29589. return nil
  29590. }
  29591. // ClearedEdges returns all edge names that were cleared in this mutation.
  29592. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29593. edges := make([]string, 0, 0)
  29594. return edges
  29595. }
  29596. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29597. // was cleared in this mutation.
  29598. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29599. return false
  29600. }
  29601. // ClearEdge clears the value of the edge with the given name. It returns an error
  29602. // if that edge is not defined in the schema.
  29603. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29604. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29605. }
  29606. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29607. // It returns an error if the edge is not defined in the schema.
  29608. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29609. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29610. }
  29611. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29612. type UsageStatisticHourMutation struct {
  29613. config
  29614. op Op
  29615. typ string
  29616. id *uint64
  29617. created_at *time.Time
  29618. updated_at *time.Time
  29619. status *uint8
  29620. addstatus *int8
  29621. deleted_at *time.Time
  29622. addtime *uint64
  29623. addaddtime *int64
  29624. _type *int
  29625. add_type *int
  29626. bot_id *string
  29627. organization_id *uint64
  29628. addorganization_id *int64
  29629. ai_response *uint64
  29630. addai_response *int64
  29631. sop_run *uint64
  29632. addsop_run *int64
  29633. total_friend *uint64
  29634. addtotal_friend *int64
  29635. total_group *uint64
  29636. addtotal_group *int64
  29637. account_balance *uint64
  29638. addaccount_balance *int64
  29639. consume_token *uint64
  29640. addconsume_token *int64
  29641. active_user *uint64
  29642. addactive_user *int64
  29643. new_user *int64
  29644. addnew_user *int64
  29645. label_dist *[]custom_types.LabelDist
  29646. appendlabel_dist []custom_types.LabelDist
  29647. clearedFields map[string]struct{}
  29648. done bool
  29649. oldValue func(context.Context) (*UsageStatisticHour, error)
  29650. predicates []predicate.UsageStatisticHour
  29651. }
  29652. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29653. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29654. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29655. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29656. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29657. m := &UsageStatisticHourMutation{
  29658. config: c,
  29659. op: op,
  29660. typ: TypeUsageStatisticHour,
  29661. clearedFields: make(map[string]struct{}),
  29662. }
  29663. for _, opt := range opts {
  29664. opt(m)
  29665. }
  29666. return m
  29667. }
  29668. // withUsageStatisticHourID sets the ID field of the mutation.
  29669. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29670. return func(m *UsageStatisticHourMutation) {
  29671. var (
  29672. err error
  29673. once sync.Once
  29674. value *UsageStatisticHour
  29675. )
  29676. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29677. once.Do(func() {
  29678. if m.done {
  29679. err = errors.New("querying old values post mutation is not allowed")
  29680. } else {
  29681. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29682. }
  29683. })
  29684. return value, err
  29685. }
  29686. m.id = &id
  29687. }
  29688. }
  29689. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29690. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29691. return func(m *UsageStatisticHourMutation) {
  29692. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29693. return node, nil
  29694. }
  29695. m.id = &node.ID
  29696. }
  29697. }
  29698. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29699. // executed in a transaction (ent.Tx), a transactional client is returned.
  29700. func (m UsageStatisticHourMutation) Client() *Client {
  29701. client := &Client{config: m.config}
  29702. client.init()
  29703. return client
  29704. }
  29705. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29706. // it returns an error otherwise.
  29707. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29708. if _, ok := m.driver.(*txDriver); !ok {
  29709. return nil, errors.New("ent: mutation is not running in a transaction")
  29710. }
  29711. tx := &Tx{config: m.config}
  29712. tx.init()
  29713. return tx, nil
  29714. }
  29715. // SetID sets the value of the id field. Note that this
  29716. // operation is only accepted on creation of UsageStatisticHour entities.
  29717. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29718. m.id = &id
  29719. }
  29720. // ID returns the ID value in the mutation. Note that the ID is only available
  29721. // if it was provided to the builder or after it was returned from the database.
  29722. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29723. if m.id == nil {
  29724. return
  29725. }
  29726. return *m.id, true
  29727. }
  29728. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29729. // That means, if the mutation is applied within a transaction with an isolation level such
  29730. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29731. // or updated by the mutation.
  29732. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29733. switch {
  29734. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29735. id, exists := m.ID()
  29736. if exists {
  29737. return []uint64{id}, nil
  29738. }
  29739. fallthrough
  29740. case m.op.Is(OpUpdate | OpDelete):
  29741. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29742. default:
  29743. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29744. }
  29745. }
  29746. // SetCreatedAt sets the "created_at" field.
  29747. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29748. m.created_at = &t
  29749. }
  29750. // CreatedAt returns the value of the "created_at" field in the mutation.
  29751. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29752. v := m.created_at
  29753. if v == nil {
  29754. return
  29755. }
  29756. return *v, true
  29757. }
  29758. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29759. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29761. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29762. if !m.op.Is(OpUpdateOne) {
  29763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29764. }
  29765. if m.id == nil || m.oldValue == nil {
  29766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29767. }
  29768. oldValue, err := m.oldValue(ctx)
  29769. if err != nil {
  29770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29771. }
  29772. return oldValue.CreatedAt, nil
  29773. }
  29774. // ResetCreatedAt resets all changes to the "created_at" field.
  29775. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29776. m.created_at = nil
  29777. }
  29778. // SetUpdatedAt sets the "updated_at" field.
  29779. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29780. m.updated_at = &t
  29781. }
  29782. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29783. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29784. v := m.updated_at
  29785. if v == nil {
  29786. return
  29787. }
  29788. return *v, true
  29789. }
  29790. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29791. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29793. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29794. if !m.op.Is(OpUpdateOne) {
  29795. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29796. }
  29797. if m.id == nil || m.oldValue == nil {
  29798. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29799. }
  29800. oldValue, err := m.oldValue(ctx)
  29801. if err != nil {
  29802. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29803. }
  29804. return oldValue.UpdatedAt, nil
  29805. }
  29806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29807. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29808. m.updated_at = nil
  29809. }
  29810. // SetStatus sets the "status" field.
  29811. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29812. m.status = &u
  29813. m.addstatus = nil
  29814. }
  29815. // Status returns the value of the "status" field in the mutation.
  29816. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29817. v := m.status
  29818. if v == nil {
  29819. return
  29820. }
  29821. return *v, true
  29822. }
  29823. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29824. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29826. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29827. if !m.op.Is(OpUpdateOne) {
  29828. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29829. }
  29830. if m.id == nil || m.oldValue == nil {
  29831. return v, errors.New("OldStatus requires an ID field in the mutation")
  29832. }
  29833. oldValue, err := m.oldValue(ctx)
  29834. if err != nil {
  29835. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29836. }
  29837. return oldValue.Status, nil
  29838. }
  29839. // AddStatus adds u to the "status" field.
  29840. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29841. if m.addstatus != nil {
  29842. *m.addstatus += u
  29843. } else {
  29844. m.addstatus = &u
  29845. }
  29846. }
  29847. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29848. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29849. v := m.addstatus
  29850. if v == nil {
  29851. return
  29852. }
  29853. return *v, true
  29854. }
  29855. // ClearStatus clears the value of the "status" field.
  29856. func (m *UsageStatisticHourMutation) ClearStatus() {
  29857. m.status = nil
  29858. m.addstatus = nil
  29859. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29860. }
  29861. // StatusCleared returns if the "status" field was cleared in this mutation.
  29862. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29863. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29864. return ok
  29865. }
  29866. // ResetStatus resets all changes to the "status" field.
  29867. func (m *UsageStatisticHourMutation) ResetStatus() {
  29868. m.status = nil
  29869. m.addstatus = nil
  29870. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29871. }
  29872. // SetDeletedAt sets the "deleted_at" field.
  29873. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29874. m.deleted_at = &t
  29875. }
  29876. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29877. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29878. v := m.deleted_at
  29879. if v == nil {
  29880. return
  29881. }
  29882. return *v, true
  29883. }
  29884. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29885. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29887. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29888. if !m.op.Is(OpUpdateOne) {
  29889. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29890. }
  29891. if m.id == nil || m.oldValue == nil {
  29892. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29893. }
  29894. oldValue, err := m.oldValue(ctx)
  29895. if err != nil {
  29896. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29897. }
  29898. return oldValue.DeletedAt, nil
  29899. }
  29900. // ClearDeletedAt clears the value of the "deleted_at" field.
  29901. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29902. m.deleted_at = nil
  29903. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29904. }
  29905. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29906. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29907. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29908. return ok
  29909. }
  29910. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29911. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29912. m.deleted_at = nil
  29913. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29914. }
  29915. // SetAddtime sets the "addtime" field.
  29916. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29917. m.addtime = &u
  29918. m.addaddtime = nil
  29919. }
  29920. // Addtime returns the value of the "addtime" field in the mutation.
  29921. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29922. v := m.addtime
  29923. if v == nil {
  29924. return
  29925. }
  29926. return *v, true
  29927. }
  29928. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29929. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29931. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29932. if !m.op.Is(OpUpdateOne) {
  29933. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29934. }
  29935. if m.id == nil || m.oldValue == nil {
  29936. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29937. }
  29938. oldValue, err := m.oldValue(ctx)
  29939. if err != nil {
  29940. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29941. }
  29942. return oldValue.Addtime, nil
  29943. }
  29944. // AddAddtime adds u to the "addtime" field.
  29945. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29946. if m.addaddtime != nil {
  29947. *m.addaddtime += u
  29948. } else {
  29949. m.addaddtime = &u
  29950. }
  29951. }
  29952. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29953. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29954. v := m.addaddtime
  29955. if v == nil {
  29956. return
  29957. }
  29958. return *v, true
  29959. }
  29960. // ResetAddtime resets all changes to the "addtime" field.
  29961. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29962. m.addtime = nil
  29963. m.addaddtime = nil
  29964. }
  29965. // SetType sets the "type" field.
  29966. func (m *UsageStatisticHourMutation) SetType(i int) {
  29967. m._type = &i
  29968. m.add_type = nil
  29969. }
  29970. // GetType returns the value of the "type" field in the mutation.
  29971. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29972. v := m._type
  29973. if v == nil {
  29974. return
  29975. }
  29976. return *v, true
  29977. }
  29978. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29979. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29981. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29982. if !m.op.Is(OpUpdateOne) {
  29983. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29984. }
  29985. if m.id == nil || m.oldValue == nil {
  29986. return v, errors.New("OldType requires an ID field in the mutation")
  29987. }
  29988. oldValue, err := m.oldValue(ctx)
  29989. if err != nil {
  29990. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29991. }
  29992. return oldValue.Type, nil
  29993. }
  29994. // AddType adds i to the "type" field.
  29995. func (m *UsageStatisticHourMutation) AddType(i int) {
  29996. if m.add_type != nil {
  29997. *m.add_type += i
  29998. } else {
  29999. m.add_type = &i
  30000. }
  30001. }
  30002. // AddedType returns the value that was added to the "type" field in this mutation.
  30003. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30004. v := m.add_type
  30005. if v == nil {
  30006. return
  30007. }
  30008. return *v, true
  30009. }
  30010. // ResetType resets all changes to the "type" field.
  30011. func (m *UsageStatisticHourMutation) ResetType() {
  30012. m._type = nil
  30013. m.add_type = nil
  30014. }
  30015. // SetBotID sets the "bot_id" field.
  30016. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30017. m.bot_id = &s
  30018. }
  30019. // BotID returns the value of the "bot_id" field in the mutation.
  30020. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30021. v := m.bot_id
  30022. if v == nil {
  30023. return
  30024. }
  30025. return *v, true
  30026. }
  30027. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30028. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30030. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30031. if !m.op.Is(OpUpdateOne) {
  30032. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30033. }
  30034. if m.id == nil || m.oldValue == nil {
  30035. return v, errors.New("OldBotID requires an ID field in the mutation")
  30036. }
  30037. oldValue, err := m.oldValue(ctx)
  30038. if err != nil {
  30039. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30040. }
  30041. return oldValue.BotID, nil
  30042. }
  30043. // ClearBotID clears the value of the "bot_id" field.
  30044. func (m *UsageStatisticHourMutation) ClearBotID() {
  30045. m.bot_id = nil
  30046. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30047. }
  30048. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30049. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30050. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30051. return ok
  30052. }
  30053. // ResetBotID resets all changes to the "bot_id" field.
  30054. func (m *UsageStatisticHourMutation) ResetBotID() {
  30055. m.bot_id = nil
  30056. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30057. }
  30058. // SetOrganizationID sets the "organization_id" field.
  30059. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30060. m.organization_id = &u
  30061. m.addorganization_id = nil
  30062. }
  30063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30064. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30065. v := m.organization_id
  30066. if v == nil {
  30067. return
  30068. }
  30069. return *v, true
  30070. }
  30071. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30072. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30074. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30075. if !m.op.Is(OpUpdateOne) {
  30076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30077. }
  30078. if m.id == nil || m.oldValue == nil {
  30079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30080. }
  30081. oldValue, err := m.oldValue(ctx)
  30082. if err != nil {
  30083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30084. }
  30085. return oldValue.OrganizationID, nil
  30086. }
  30087. // AddOrganizationID adds u to the "organization_id" field.
  30088. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30089. if m.addorganization_id != nil {
  30090. *m.addorganization_id += u
  30091. } else {
  30092. m.addorganization_id = &u
  30093. }
  30094. }
  30095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30096. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30097. v := m.addorganization_id
  30098. if v == nil {
  30099. return
  30100. }
  30101. return *v, true
  30102. }
  30103. // ClearOrganizationID clears the value of the "organization_id" field.
  30104. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30105. m.organization_id = nil
  30106. m.addorganization_id = nil
  30107. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30108. }
  30109. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30110. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30111. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30112. return ok
  30113. }
  30114. // ResetOrganizationID resets all changes to the "organization_id" field.
  30115. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30116. m.organization_id = nil
  30117. m.addorganization_id = nil
  30118. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30119. }
  30120. // SetAiResponse sets the "ai_response" field.
  30121. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30122. m.ai_response = &u
  30123. m.addai_response = nil
  30124. }
  30125. // AiResponse returns the value of the "ai_response" field in the mutation.
  30126. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30127. v := m.ai_response
  30128. if v == nil {
  30129. return
  30130. }
  30131. return *v, true
  30132. }
  30133. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30134. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30136. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30137. if !m.op.Is(OpUpdateOne) {
  30138. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30139. }
  30140. if m.id == nil || m.oldValue == nil {
  30141. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30142. }
  30143. oldValue, err := m.oldValue(ctx)
  30144. if err != nil {
  30145. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30146. }
  30147. return oldValue.AiResponse, nil
  30148. }
  30149. // AddAiResponse adds u to the "ai_response" field.
  30150. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30151. if m.addai_response != nil {
  30152. *m.addai_response += u
  30153. } else {
  30154. m.addai_response = &u
  30155. }
  30156. }
  30157. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30158. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30159. v := m.addai_response
  30160. if v == nil {
  30161. return
  30162. }
  30163. return *v, true
  30164. }
  30165. // ResetAiResponse resets all changes to the "ai_response" field.
  30166. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30167. m.ai_response = nil
  30168. m.addai_response = nil
  30169. }
  30170. // SetSopRun sets the "sop_run" field.
  30171. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30172. m.sop_run = &u
  30173. m.addsop_run = nil
  30174. }
  30175. // SopRun returns the value of the "sop_run" field in the mutation.
  30176. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30177. v := m.sop_run
  30178. if v == nil {
  30179. return
  30180. }
  30181. return *v, true
  30182. }
  30183. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30184. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30186. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30187. if !m.op.Is(OpUpdateOne) {
  30188. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30189. }
  30190. if m.id == nil || m.oldValue == nil {
  30191. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30192. }
  30193. oldValue, err := m.oldValue(ctx)
  30194. if err != nil {
  30195. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30196. }
  30197. return oldValue.SopRun, nil
  30198. }
  30199. // AddSopRun adds u to the "sop_run" field.
  30200. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30201. if m.addsop_run != nil {
  30202. *m.addsop_run += u
  30203. } else {
  30204. m.addsop_run = &u
  30205. }
  30206. }
  30207. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30208. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30209. v := m.addsop_run
  30210. if v == nil {
  30211. return
  30212. }
  30213. return *v, true
  30214. }
  30215. // ResetSopRun resets all changes to the "sop_run" field.
  30216. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30217. m.sop_run = nil
  30218. m.addsop_run = nil
  30219. }
  30220. // SetTotalFriend sets the "total_friend" field.
  30221. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30222. m.total_friend = &u
  30223. m.addtotal_friend = nil
  30224. }
  30225. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30226. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30227. v := m.total_friend
  30228. if v == nil {
  30229. return
  30230. }
  30231. return *v, true
  30232. }
  30233. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30234. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30236. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30237. if !m.op.Is(OpUpdateOne) {
  30238. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30239. }
  30240. if m.id == nil || m.oldValue == nil {
  30241. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30242. }
  30243. oldValue, err := m.oldValue(ctx)
  30244. if err != nil {
  30245. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30246. }
  30247. return oldValue.TotalFriend, nil
  30248. }
  30249. // AddTotalFriend adds u to the "total_friend" field.
  30250. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30251. if m.addtotal_friend != nil {
  30252. *m.addtotal_friend += u
  30253. } else {
  30254. m.addtotal_friend = &u
  30255. }
  30256. }
  30257. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30258. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30259. v := m.addtotal_friend
  30260. if v == nil {
  30261. return
  30262. }
  30263. return *v, true
  30264. }
  30265. // ResetTotalFriend resets all changes to the "total_friend" field.
  30266. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30267. m.total_friend = nil
  30268. m.addtotal_friend = nil
  30269. }
  30270. // SetTotalGroup sets the "total_group" field.
  30271. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30272. m.total_group = &u
  30273. m.addtotal_group = nil
  30274. }
  30275. // TotalGroup returns the value of the "total_group" field in the mutation.
  30276. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30277. v := m.total_group
  30278. if v == nil {
  30279. return
  30280. }
  30281. return *v, true
  30282. }
  30283. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30284. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30286. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30287. if !m.op.Is(OpUpdateOne) {
  30288. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30289. }
  30290. if m.id == nil || m.oldValue == nil {
  30291. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30292. }
  30293. oldValue, err := m.oldValue(ctx)
  30294. if err != nil {
  30295. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30296. }
  30297. return oldValue.TotalGroup, nil
  30298. }
  30299. // AddTotalGroup adds u to the "total_group" field.
  30300. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30301. if m.addtotal_group != nil {
  30302. *m.addtotal_group += u
  30303. } else {
  30304. m.addtotal_group = &u
  30305. }
  30306. }
  30307. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30308. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30309. v := m.addtotal_group
  30310. if v == nil {
  30311. return
  30312. }
  30313. return *v, true
  30314. }
  30315. // ResetTotalGroup resets all changes to the "total_group" field.
  30316. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30317. m.total_group = nil
  30318. m.addtotal_group = nil
  30319. }
  30320. // SetAccountBalance sets the "account_balance" field.
  30321. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30322. m.account_balance = &u
  30323. m.addaccount_balance = nil
  30324. }
  30325. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30326. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30327. v := m.account_balance
  30328. if v == nil {
  30329. return
  30330. }
  30331. return *v, true
  30332. }
  30333. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30334. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30336. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30337. if !m.op.Is(OpUpdateOne) {
  30338. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30339. }
  30340. if m.id == nil || m.oldValue == nil {
  30341. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30342. }
  30343. oldValue, err := m.oldValue(ctx)
  30344. if err != nil {
  30345. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30346. }
  30347. return oldValue.AccountBalance, nil
  30348. }
  30349. // AddAccountBalance adds u to the "account_balance" field.
  30350. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30351. if m.addaccount_balance != nil {
  30352. *m.addaccount_balance += u
  30353. } else {
  30354. m.addaccount_balance = &u
  30355. }
  30356. }
  30357. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30358. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30359. v := m.addaccount_balance
  30360. if v == nil {
  30361. return
  30362. }
  30363. return *v, true
  30364. }
  30365. // ResetAccountBalance resets all changes to the "account_balance" field.
  30366. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30367. m.account_balance = nil
  30368. m.addaccount_balance = nil
  30369. }
  30370. // SetConsumeToken sets the "consume_token" field.
  30371. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30372. m.consume_token = &u
  30373. m.addconsume_token = nil
  30374. }
  30375. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30376. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30377. v := m.consume_token
  30378. if v == nil {
  30379. return
  30380. }
  30381. return *v, true
  30382. }
  30383. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30384. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30386. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30387. if !m.op.Is(OpUpdateOne) {
  30388. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30389. }
  30390. if m.id == nil || m.oldValue == nil {
  30391. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30392. }
  30393. oldValue, err := m.oldValue(ctx)
  30394. if err != nil {
  30395. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30396. }
  30397. return oldValue.ConsumeToken, nil
  30398. }
  30399. // AddConsumeToken adds u to the "consume_token" field.
  30400. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30401. if m.addconsume_token != nil {
  30402. *m.addconsume_token += u
  30403. } else {
  30404. m.addconsume_token = &u
  30405. }
  30406. }
  30407. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30408. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30409. v := m.addconsume_token
  30410. if v == nil {
  30411. return
  30412. }
  30413. return *v, true
  30414. }
  30415. // ResetConsumeToken resets all changes to the "consume_token" field.
  30416. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30417. m.consume_token = nil
  30418. m.addconsume_token = nil
  30419. }
  30420. // SetActiveUser sets the "active_user" field.
  30421. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30422. m.active_user = &u
  30423. m.addactive_user = nil
  30424. }
  30425. // ActiveUser returns the value of the "active_user" field in the mutation.
  30426. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30427. v := m.active_user
  30428. if v == nil {
  30429. return
  30430. }
  30431. return *v, true
  30432. }
  30433. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30434. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30436. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30437. if !m.op.Is(OpUpdateOne) {
  30438. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30439. }
  30440. if m.id == nil || m.oldValue == nil {
  30441. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30442. }
  30443. oldValue, err := m.oldValue(ctx)
  30444. if err != nil {
  30445. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30446. }
  30447. return oldValue.ActiveUser, nil
  30448. }
  30449. // AddActiveUser adds u to the "active_user" field.
  30450. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30451. if m.addactive_user != nil {
  30452. *m.addactive_user += u
  30453. } else {
  30454. m.addactive_user = &u
  30455. }
  30456. }
  30457. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30458. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30459. v := m.addactive_user
  30460. if v == nil {
  30461. return
  30462. }
  30463. return *v, true
  30464. }
  30465. // ResetActiveUser resets all changes to the "active_user" field.
  30466. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30467. m.active_user = nil
  30468. m.addactive_user = nil
  30469. }
  30470. // SetNewUser sets the "new_user" field.
  30471. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30472. m.new_user = &i
  30473. m.addnew_user = nil
  30474. }
  30475. // NewUser returns the value of the "new_user" field in the mutation.
  30476. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30477. v := m.new_user
  30478. if v == nil {
  30479. return
  30480. }
  30481. return *v, true
  30482. }
  30483. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30484. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30486. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30487. if !m.op.Is(OpUpdateOne) {
  30488. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30489. }
  30490. if m.id == nil || m.oldValue == nil {
  30491. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30492. }
  30493. oldValue, err := m.oldValue(ctx)
  30494. if err != nil {
  30495. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30496. }
  30497. return oldValue.NewUser, nil
  30498. }
  30499. // AddNewUser adds i to the "new_user" field.
  30500. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30501. if m.addnew_user != nil {
  30502. *m.addnew_user += i
  30503. } else {
  30504. m.addnew_user = &i
  30505. }
  30506. }
  30507. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30508. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30509. v := m.addnew_user
  30510. if v == nil {
  30511. return
  30512. }
  30513. return *v, true
  30514. }
  30515. // ResetNewUser resets all changes to the "new_user" field.
  30516. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30517. m.new_user = nil
  30518. m.addnew_user = nil
  30519. }
  30520. // SetLabelDist sets the "label_dist" field.
  30521. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30522. m.label_dist = &ctd
  30523. m.appendlabel_dist = nil
  30524. }
  30525. // LabelDist returns the value of the "label_dist" field in the mutation.
  30526. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30527. v := m.label_dist
  30528. if v == nil {
  30529. return
  30530. }
  30531. return *v, true
  30532. }
  30533. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30534. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30536. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30537. if !m.op.Is(OpUpdateOne) {
  30538. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30539. }
  30540. if m.id == nil || m.oldValue == nil {
  30541. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30542. }
  30543. oldValue, err := m.oldValue(ctx)
  30544. if err != nil {
  30545. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30546. }
  30547. return oldValue.LabelDist, nil
  30548. }
  30549. // AppendLabelDist adds ctd to the "label_dist" field.
  30550. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30551. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30552. }
  30553. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30554. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30555. if len(m.appendlabel_dist) == 0 {
  30556. return nil, false
  30557. }
  30558. return m.appendlabel_dist, true
  30559. }
  30560. // ResetLabelDist resets all changes to the "label_dist" field.
  30561. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30562. m.label_dist = nil
  30563. m.appendlabel_dist = nil
  30564. }
  30565. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30566. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30567. m.predicates = append(m.predicates, ps...)
  30568. }
  30569. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30570. // users can use type-assertion to append predicates that do not depend on any generated package.
  30571. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30572. p := make([]predicate.UsageStatisticHour, len(ps))
  30573. for i := range ps {
  30574. p[i] = ps[i]
  30575. }
  30576. m.Where(p...)
  30577. }
  30578. // Op returns the operation name.
  30579. func (m *UsageStatisticHourMutation) Op() Op {
  30580. return m.op
  30581. }
  30582. // SetOp allows setting the mutation operation.
  30583. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30584. m.op = op
  30585. }
  30586. // Type returns the node type of this mutation (UsageStatisticHour).
  30587. func (m *UsageStatisticHourMutation) Type() string {
  30588. return m.typ
  30589. }
  30590. // Fields returns all fields that were changed during this mutation. Note that in
  30591. // order to get all numeric fields that were incremented/decremented, call
  30592. // AddedFields().
  30593. func (m *UsageStatisticHourMutation) Fields() []string {
  30594. fields := make([]string, 0, 17)
  30595. if m.created_at != nil {
  30596. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30597. }
  30598. if m.updated_at != nil {
  30599. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30600. }
  30601. if m.status != nil {
  30602. fields = append(fields, usagestatistichour.FieldStatus)
  30603. }
  30604. if m.deleted_at != nil {
  30605. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30606. }
  30607. if m.addtime != nil {
  30608. fields = append(fields, usagestatistichour.FieldAddtime)
  30609. }
  30610. if m._type != nil {
  30611. fields = append(fields, usagestatistichour.FieldType)
  30612. }
  30613. if m.bot_id != nil {
  30614. fields = append(fields, usagestatistichour.FieldBotID)
  30615. }
  30616. if m.organization_id != nil {
  30617. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30618. }
  30619. if m.ai_response != nil {
  30620. fields = append(fields, usagestatistichour.FieldAiResponse)
  30621. }
  30622. if m.sop_run != nil {
  30623. fields = append(fields, usagestatistichour.FieldSopRun)
  30624. }
  30625. if m.total_friend != nil {
  30626. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30627. }
  30628. if m.total_group != nil {
  30629. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30630. }
  30631. if m.account_balance != nil {
  30632. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30633. }
  30634. if m.consume_token != nil {
  30635. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30636. }
  30637. if m.active_user != nil {
  30638. fields = append(fields, usagestatistichour.FieldActiveUser)
  30639. }
  30640. if m.new_user != nil {
  30641. fields = append(fields, usagestatistichour.FieldNewUser)
  30642. }
  30643. if m.label_dist != nil {
  30644. fields = append(fields, usagestatistichour.FieldLabelDist)
  30645. }
  30646. return fields
  30647. }
  30648. // Field returns the value of a field with the given name. The second boolean
  30649. // return value indicates that this field was not set, or was not defined in the
  30650. // schema.
  30651. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30652. switch name {
  30653. case usagestatistichour.FieldCreatedAt:
  30654. return m.CreatedAt()
  30655. case usagestatistichour.FieldUpdatedAt:
  30656. return m.UpdatedAt()
  30657. case usagestatistichour.FieldStatus:
  30658. return m.Status()
  30659. case usagestatistichour.FieldDeletedAt:
  30660. return m.DeletedAt()
  30661. case usagestatistichour.FieldAddtime:
  30662. return m.Addtime()
  30663. case usagestatistichour.FieldType:
  30664. return m.GetType()
  30665. case usagestatistichour.FieldBotID:
  30666. return m.BotID()
  30667. case usagestatistichour.FieldOrganizationID:
  30668. return m.OrganizationID()
  30669. case usagestatistichour.FieldAiResponse:
  30670. return m.AiResponse()
  30671. case usagestatistichour.FieldSopRun:
  30672. return m.SopRun()
  30673. case usagestatistichour.FieldTotalFriend:
  30674. return m.TotalFriend()
  30675. case usagestatistichour.FieldTotalGroup:
  30676. return m.TotalGroup()
  30677. case usagestatistichour.FieldAccountBalance:
  30678. return m.AccountBalance()
  30679. case usagestatistichour.FieldConsumeToken:
  30680. return m.ConsumeToken()
  30681. case usagestatistichour.FieldActiveUser:
  30682. return m.ActiveUser()
  30683. case usagestatistichour.FieldNewUser:
  30684. return m.NewUser()
  30685. case usagestatistichour.FieldLabelDist:
  30686. return m.LabelDist()
  30687. }
  30688. return nil, false
  30689. }
  30690. // OldField returns the old value of the field from the database. An error is
  30691. // returned if the mutation operation is not UpdateOne, or the query to the
  30692. // database failed.
  30693. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30694. switch name {
  30695. case usagestatistichour.FieldCreatedAt:
  30696. return m.OldCreatedAt(ctx)
  30697. case usagestatistichour.FieldUpdatedAt:
  30698. return m.OldUpdatedAt(ctx)
  30699. case usagestatistichour.FieldStatus:
  30700. return m.OldStatus(ctx)
  30701. case usagestatistichour.FieldDeletedAt:
  30702. return m.OldDeletedAt(ctx)
  30703. case usagestatistichour.FieldAddtime:
  30704. return m.OldAddtime(ctx)
  30705. case usagestatistichour.FieldType:
  30706. return m.OldType(ctx)
  30707. case usagestatistichour.FieldBotID:
  30708. return m.OldBotID(ctx)
  30709. case usagestatistichour.FieldOrganizationID:
  30710. return m.OldOrganizationID(ctx)
  30711. case usagestatistichour.FieldAiResponse:
  30712. return m.OldAiResponse(ctx)
  30713. case usagestatistichour.FieldSopRun:
  30714. return m.OldSopRun(ctx)
  30715. case usagestatistichour.FieldTotalFriend:
  30716. return m.OldTotalFriend(ctx)
  30717. case usagestatistichour.FieldTotalGroup:
  30718. return m.OldTotalGroup(ctx)
  30719. case usagestatistichour.FieldAccountBalance:
  30720. return m.OldAccountBalance(ctx)
  30721. case usagestatistichour.FieldConsumeToken:
  30722. return m.OldConsumeToken(ctx)
  30723. case usagestatistichour.FieldActiveUser:
  30724. return m.OldActiveUser(ctx)
  30725. case usagestatistichour.FieldNewUser:
  30726. return m.OldNewUser(ctx)
  30727. case usagestatistichour.FieldLabelDist:
  30728. return m.OldLabelDist(ctx)
  30729. }
  30730. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30731. }
  30732. // SetField sets the value of a field with the given name. It returns an error if
  30733. // the field is not defined in the schema, or if the type mismatched the field
  30734. // type.
  30735. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30736. switch name {
  30737. case usagestatistichour.FieldCreatedAt:
  30738. v, ok := value.(time.Time)
  30739. if !ok {
  30740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30741. }
  30742. m.SetCreatedAt(v)
  30743. return nil
  30744. case usagestatistichour.FieldUpdatedAt:
  30745. v, ok := value.(time.Time)
  30746. if !ok {
  30747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30748. }
  30749. m.SetUpdatedAt(v)
  30750. return nil
  30751. case usagestatistichour.FieldStatus:
  30752. v, ok := value.(uint8)
  30753. if !ok {
  30754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30755. }
  30756. m.SetStatus(v)
  30757. return nil
  30758. case usagestatistichour.FieldDeletedAt:
  30759. v, ok := value.(time.Time)
  30760. if !ok {
  30761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30762. }
  30763. m.SetDeletedAt(v)
  30764. return nil
  30765. case usagestatistichour.FieldAddtime:
  30766. v, ok := value.(uint64)
  30767. if !ok {
  30768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30769. }
  30770. m.SetAddtime(v)
  30771. return nil
  30772. case usagestatistichour.FieldType:
  30773. v, ok := value.(int)
  30774. if !ok {
  30775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30776. }
  30777. m.SetType(v)
  30778. return nil
  30779. case usagestatistichour.FieldBotID:
  30780. v, ok := value.(string)
  30781. if !ok {
  30782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30783. }
  30784. m.SetBotID(v)
  30785. return nil
  30786. case usagestatistichour.FieldOrganizationID:
  30787. v, ok := value.(uint64)
  30788. if !ok {
  30789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30790. }
  30791. m.SetOrganizationID(v)
  30792. return nil
  30793. case usagestatistichour.FieldAiResponse:
  30794. v, ok := value.(uint64)
  30795. if !ok {
  30796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30797. }
  30798. m.SetAiResponse(v)
  30799. return nil
  30800. case usagestatistichour.FieldSopRun:
  30801. v, ok := value.(uint64)
  30802. if !ok {
  30803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30804. }
  30805. m.SetSopRun(v)
  30806. return nil
  30807. case usagestatistichour.FieldTotalFriend:
  30808. v, ok := value.(uint64)
  30809. if !ok {
  30810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30811. }
  30812. m.SetTotalFriend(v)
  30813. return nil
  30814. case usagestatistichour.FieldTotalGroup:
  30815. v, ok := value.(uint64)
  30816. if !ok {
  30817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30818. }
  30819. m.SetTotalGroup(v)
  30820. return nil
  30821. case usagestatistichour.FieldAccountBalance:
  30822. v, ok := value.(uint64)
  30823. if !ok {
  30824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30825. }
  30826. m.SetAccountBalance(v)
  30827. return nil
  30828. case usagestatistichour.FieldConsumeToken:
  30829. v, ok := value.(uint64)
  30830. if !ok {
  30831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30832. }
  30833. m.SetConsumeToken(v)
  30834. return nil
  30835. case usagestatistichour.FieldActiveUser:
  30836. v, ok := value.(uint64)
  30837. if !ok {
  30838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30839. }
  30840. m.SetActiveUser(v)
  30841. return nil
  30842. case usagestatistichour.FieldNewUser:
  30843. v, ok := value.(int64)
  30844. if !ok {
  30845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30846. }
  30847. m.SetNewUser(v)
  30848. return nil
  30849. case usagestatistichour.FieldLabelDist:
  30850. v, ok := value.([]custom_types.LabelDist)
  30851. if !ok {
  30852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30853. }
  30854. m.SetLabelDist(v)
  30855. return nil
  30856. }
  30857. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30858. }
  30859. // AddedFields returns all numeric fields that were incremented/decremented during
  30860. // this mutation.
  30861. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30862. var fields []string
  30863. if m.addstatus != nil {
  30864. fields = append(fields, usagestatistichour.FieldStatus)
  30865. }
  30866. if m.addaddtime != nil {
  30867. fields = append(fields, usagestatistichour.FieldAddtime)
  30868. }
  30869. if m.add_type != nil {
  30870. fields = append(fields, usagestatistichour.FieldType)
  30871. }
  30872. if m.addorganization_id != nil {
  30873. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30874. }
  30875. if m.addai_response != nil {
  30876. fields = append(fields, usagestatistichour.FieldAiResponse)
  30877. }
  30878. if m.addsop_run != nil {
  30879. fields = append(fields, usagestatistichour.FieldSopRun)
  30880. }
  30881. if m.addtotal_friend != nil {
  30882. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30883. }
  30884. if m.addtotal_group != nil {
  30885. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30886. }
  30887. if m.addaccount_balance != nil {
  30888. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30889. }
  30890. if m.addconsume_token != nil {
  30891. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30892. }
  30893. if m.addactive_user != nil {
  30894. fields = append(fields, usagestatistichour.FieldActiveUser)
  30895. }
  30896. if m.addnew_user != nil {
  30897. fields = append(fields, usagestatistichour.FieldNewUser)
  30898. }
  30899. return fields
  30900. }
  30901. // AddedField returns the numeric value that was incremented/decremented on a field
  30902. // with the given name. The second boolean return value indicates that this field
  30903. // was not set, or was not defined in the schema.
  30904. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30905. switch name {
  30906. case usagestatistichour.FieldStatus:
  30907. return m.AddedStatus()
  30908. case usagestatistichour.FieldAddtime:
  30909. return m.AddedAddtime()
  30910. case usagestatistichour.FieldType:
  30911. return m.AddedType()
  30912. case usagestatistichour.FieldOrganizationID:
  30913. return m.AddedOrganizationID()
  30914. case usagestatistichour.FieldAiResponse:
  30915. return m.AddedAiResponse()
  30916. case usagestatistichour.FieldSopRun:
  30917. return m.AddedSopRun()
  30918. case usagestatistichour.FieldTotalFriend:
  30919. return m.AddedTotalFriend()
  30920. case usagestatistichour.FieldTotalGroup:
  30921. return m.AddedTotalGroup()
  30922. case usagestatistichour.FieldAccountBalance:
  30923. return m.AddedAccountBalance()
  30924. case usagestatistichour.FieldConsumeToken:
  30925. return m.AddedConsumeToken()
  30926. case usagestatistichour.FieldActiveUser:
  30927. return m.AddedActiveUser()
  30928. case usagestatistichour.FieldNewUser:
  30929. return m.AddedNewUser()
  30930. }
  30931. return nil, false
  30932. }
  30933. // AddField adds the value to the field with the given name. It returns an error if
  30934. // the field is not defined in the schema, or if the type mismatched the field
  30935. // type.
  30936. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30937. switch name {
  30938. case usagestatistichour.FieldStatus:
  30939. v, ok := value.(int8)
  30940. if !ok {
  30941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30942. }
  30943. m.AddStatus(v)
  30944. return nil
  30945. case usagestatistichour.FieldAddtime:
  30946. v, ok := value.(int64)
  30947. if !ok {
  30948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30949. }
  30950. m.AddAddtime(v)
  30951. return nil
  30952. case usagestatistichour.FieldType:
  30953. v, ok := value.(int)
  30954. if !ok {
  30955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30956. }
  30957. m.AddType(v)
  30958. return nil
  30959. case usagestatistichour.FieldOrganizationID:
  30960. v, ok := value.(int64)
  30961. if !ok {
  30962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30963. }
  30964. m.AddOrganizationID(v)
  30965. return nil
  30966. case usagestatistichour.FieldAiResponse:
  30967. v, ok := value.(int64)
  30968. if !ok {
  30969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30970. }
  30971. m.AddAiResponse(v)
  30972. return nil
  30973. case usagestatistichour.FieldSopRun:
  30974. v, ok := value.(int64)
  30975. if !ok {
  30976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30977. }
  30978. m.AddSopRun(v)
  30979. return nil
  30980. case usagestatistichour.FieldTotalFriend:
  30981. v, ok := value.(int64)
  30982. if !ok {
  30983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30984. }
  30985. m.AddTotalFriend(v)
  30986. return nil
  30987. case usagestatistichour.FieldTotalGroup:
  30988. v, ok := value.(int64)
  30989. if !ok {
  30990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30991. }
  30992. m.AddTotalGroup(v)
  30993. return nil
  30994. case usagestatistichour.FieldAccountBalance:
  30995. v, ok := value.(int64)
  30996. if !ok {
  30997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30998. }
  30999. m.AddAccountBalance(v)
  31000. return nil
  31001. case usagestatistichour.FieldConsumeToken:
  31002. v, ok := value.(int64)
  31003. if !ok {
  31004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31005. }
  31006. m.AddConsumeToken(v)
  31007. return nil
  31008. case usagestatistichour.FieldActiveUser:
  31009. v, ok := value.(int64)
  31010. if !ok {
  31011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31012. }
  31013. m.AddActiveUser(v)
  31014. return nil
  31015. case usagestatistichour.FieldNewUser:
  31016. v, ok := value.(int64)
  31017. if !ok {
  31018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31019. }
  31020. m.AddNewUser(v)
  31021. return nil
  31022. }
  31023. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31024. }
  31025. // ClearedFields returns all nullable fields that were cleared during this
  31026. // mutation.
  31027. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31028. var fields []string
  31029. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31030. fields = append(fields, usagestatistichour.FieldStatus)
  31031. }
  31032. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31033. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31034. }
  31035. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31036. fields = append(fields, usagestatistichour.FieldBotID)
  31037. }
  31038. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31039. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31040. }
  31041. return fields
  31042. }
  31043. // FieldCleared returns a boolean indicating if a field with the given name was
  31044. // cleared in this mutation.
  31045. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31046. _, ok := m.clearedFields[name]
  31047. return ok
  31048. }
  31049. // ClearField clears the value of the field with the given name. It returns an
  31050. // error if the field is not defined in the schema.
  31051. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31052. switch name {
  31053. case usagestatistichour.FieldStatus:
  31054. m.ClearStatus()
  31055. return nil
  31056. case usagestatistichour.FieldDeletedAt:
  31057. m.ClearDeletedAt()
  31058. return nil
  31059. case usagestatistichour.FieldBotID:
  31060. m.ClearBotID()
  31061. return nil
  31062. case usagestatistichour.FieldOrganizationID:
  31063. m.ClearOrganizationID()
  31064. return nil
  31065. }
  31066. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31067. }
  31068. // ResetField resets all changes in the mutation for the field with the given name.
  31069. // It returns an error if the field is not defined in the schema.
  31070. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31071. switch name {
  31072. case usagestatistichour.FieldCreatedAt:
  31073. m.ResetCreatedAt()
  31074. return nil
  31075. case usagestatistichour.FieldUpdatedAt:
  31076. m.ResetUpdatedAt()
  31077. return nil
  31078. case usagestatistichour.FieldStatus:
  31079. m.ResetStatus()
  31080. return nil
  31081. case usagestatistichour.FieldDeletedAt:
  31082. m.ResetDeletedAt()
  31083. return nil
  31084. case usagestatistichour.FieldAddtime:
  31085. m.ResetAddtime()
  31086. return nil
  31087. case usagestatistichour.FieldType:
  31088. m.ResetType()
  31089. return nil
  31090. case usagestatistichour.FieldBotID:
  31091. m.ResetBotID()
  31092. return nil
  31093. case usagestatistichour.FieldOrganizationID:
  31094. m.ResetOrganizationID()
  31095. return nil
  31096. case usagestatistichour.FieldAiResponse:
  31097. m.ResetAiResponse()
  31098. return nil
  31099. case usagestatistichour.FieldSopRun:
  31100. m.ResetSopRun()
  31101. return nil
  31102. case usagestatistichour.FieldTotalFriend:
  31103. m.ResetTotalFriend()
  31104. return nil
  31105. case usagestatistichour.FieldTotalGroup:
  31106. m.ResetTotalGroup()
  31107. return nil
  31108. case usagestatistichour.FieldAccountBalance:
  31109. m.ResetAccountBalance()
  31110. return nil
  31111. case usagestatistichour.FieldConsumeToken:
  31112. m.ResetConsumeToken()
  31113. return nil
  31114. case usagestatistichour.FieldActiveUser:
  31115. m.ResetActiveUser()
  31116. return nil
  31117. case usagestatistichour.FieldNewUser:
  31118. m.ResetNewUser()
  31119. return nil
  31120. case usagestatistichour.FieldLabelDist:
  31121. m.ResetLabelDist()
  31122. return nil
  31123. }
  31124. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31125. }
  31126. // AddedEdges returns all edge names that were set/added in this mutation.
  31127. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31128. edges := make([]string, 0, 0)
  31129. return edges
  31130. }
  31131. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31132. // name in this mutation.
  31133. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31134. return nil
  31135. }
  31136. // RemovedEdges returns all edge names that were removed in this mutation.
  31137. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31138. edges := make([]string, 0, 0)
  31139. return edges
  31140. }
  31141. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31142. // the given name in this mutation.
  31143. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31144. return nil
  31145. }
  31146. // ClearedEdges returns all edge names that were cleared in this mutation.
  31147. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31148. edges := make([]string, 0, 0)
  31149. return edges
  31150. }
  31151. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31152. // was cleared in this mutation.
  31153. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31154. return false
  31155. }
  31156. // ClearEdge clears the value of the edge with the given name. It returns an error
  31157. // if that edge is not defined in the schema.
  31158. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31159. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31160. }
  31161. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31162. // It returns an error if the edge is not defined in the schema.
  31163. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31164. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31165. }
  31166. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31167. type UsageStatisticMonthMutation struct {
  31168. config
  31169. op Op
  31170. typ string
  31171. id *uint64
  31172. created_at *time.Time
  31173. updated_at *time.Time
  31174. status *uint8
  31175. addstatus *int8
  31176. deleted_at *time.Time
  31177. addtime *uint64
  31178. addaddtime *int64
  31179. _type *int
  31180. add_type *int
  31181. bot_id *string
  31182. organization_id *uint64
  31183. addorganization_id *int64
  31184. ai_response *uint64
  31185. addai_response *int64
  31186. sop_run *uint64
  31187. addsop_run *int64
  31188. total_friend *uint64
  31189. addtotal_friend *int64
  31190. total_group *uint64
  31191. addtotal_group *int64
  31192. account_balance *uint64
  31193. addaccount_balance *int64
  31194. consume_token *uint64
  31195. addconsume_token *int64
  31196. active_user *uint64
  31197. addactive_user *int64
  31198. new_user *int64
  31199. addnew_user *int64
  31200. label_dist *[]custom_types.LabelDist
  31201. appendlabel_dist []custom_types.LabelDist
  31202. clearedFields map[string]struct{}
  31203. done bool
  31204. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31205. predicates []predicate.UsageStatisticMonth
  31206. }
  31207. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31208. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31209. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31210. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31211. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31212. m := &UsageStatisticMonthMutation{
  31213. config: c,
  31214. op: op,
  31215. typ: TypeUsageStatisticMonth,
  31216. clearedFields: make(map[string]struct{}),
  31217. }
  31218. for _, opt := range opts {
  31219. opt(m)
  31220. }
  31221. return m
  31222. }
  31223. // withUsageStatisticMonthID sets the ID field of the mutation.
  31224. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31225. return func(m *UsageStatisticMonthMutation) {
  31226. var (
  31227. err error
  31228. once sync.Once
  31229. value *UsageStatisticMonth
  31230. )
  31231. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31232. once.Do(func() {
  31233. if m.done {
  31234. err = errors.New("querying old values post mutation is not allowed")
  31235. } else {
  31236. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31237. }
  31238. })
  31239. return value, err
  31240. }
  31241. m.id = &id
  31242. }
  31243. }
  31244. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31245. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31246. return func(m *UsageStatisticMonthMutation) {
  31247. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31248. return node, nil
  31249. }
  31250. m.id = &node.ID
  31251. }
  31252. }
  31253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31254. // executed in a transaction (ent.Tx), a transactional client is returned.
  31255. func (m UsageStatisticMonthMutation) Client() *Client {
  31256. client := &Client{config: m.config}
  31257. client.init()
  31258. return client
  31259. }
  31260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31261. // it returns an error otherwise.
  31262. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31263. if _, ok := m.driver.(*txDriver); !ok {
  31264. return nil, errors.New("ent: mutation is not running in a transaction")
  31265. }
  31266. tx := &Tx{config: m.config}
  31267. tx.init()
  31268. return tx, nil
  31269. }
  31270. // SetID sets the value of the id field. Note that this
  31271. // operation is only accepted on creation of UsageStatisticMonth entities.
  31272. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31273. m.id = &id
  31274. }
  31275. // ID returns the ID value in the mutation. Note that the ID is only available
  31276. // if it was provided to the builder or after it was returned from the database.
  31277. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31278. if m.id == nil {
  31279. return
  31280. }
  31281. return *m.id, true
  31282. }
  31283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31284. // That means, if the mutation is applied within a transaction with an isolation level such
  31285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31286. // or updated by the mutation.
  31287. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31288. switch {
  31289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31290. id, exists := m.ID()
  31291. if exists {
  31292. return []uint64{id}, nil
  31293. }
  31294. fallthrough
  31295. case m.op.Is(OpUpdate | OpDelete):
  31296. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31297. default:
  31298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31299. }
  31300. }
  31301. // SetCreatedAt sets the "created_at" field.
  31302. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31303. m.created_at = &t
  31304. }
  31305. // CreatedAt returns the value of the "created_at" field in the mutation.
  31306. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31307. v := m.created_at
  31308. if v == nil {
  31309. return
  31310. }
  31311. return *v, true
  31312. }
  31313. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31314. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31316. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31317. if !m.op.Is(OpUpdateOne) {
  31318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31319. }
  31320. if m.id == nil || m.oldValue == nil {
  31321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31322. }
  31323. oldValue, err := m.oldValue(ctx)
  31324. if err != nil {
  31325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31326. }
  31327. return oldValue.CreatedAt, nil
  31328. }
  31329. // ResetCreatedAt resets all changes to the "created_at" field.
  31330. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31331. m.created_at = nil
  31332. }
  31333. // SetUpdatedAt sets the "updated_at" field.
  31334. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31335. m.updated_at = &t
  31336. }
  31337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31338. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31339. v := m.updated_at
  31340. if v == nil {
  31341. return
  31342. }
  31343. return *v, true
  31344. }
  31345. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31346. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31348. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31349. if !m.op.Is(OpUpdateOne) {
  31350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31351. }
  31352. if m.id == nil || m.oldValue == nil {
  31353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31354. }
  31355. oldValue, err := m.oldValue(ctx)
  31356. if err != nil {
  31357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31358. }
  31359. return oldValue.UpdatedAt, nil
  31360. }
  31361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31362. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31363. m.updated_at = nil
  31364. }
  31365. // SetStatus sets the "status" field.
  31366. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31367. m.status = &u
  31368. m.addstatus = nil
  31369. }
  31370. // Status returns the value of the "status" field in the mutation.
  31371. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31372. v := m.status
  31373. if v == nil {
  31374. return
  31375. }
  31376. return *v, true
  31377. }
  31378. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31379. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31381. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31382. if !m.op.Is(OpUpdateOne) {
  31383. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31384. }
  31385. if m.id == nil || m.oldValue == nil {
  31386. return v, errors.New("OldStatus requires an ID field in the mutation")
  31387. }
  31388. oldValue, err := m.oldValue(ctx)
  31389. if err != nil {
  31390. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31391. }
  31392. return oldValue.Status, nil
  31393. }
  31394. // AddStatus adds u to the "status" field.
  31395. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31396. if m.addstatus != nil {
  31397. *m.addstatus += u
  31398. } else {
  31399. m.addstatus = &u
  31400. }
  31401. }
  31402. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31403. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31404. v := m.addstatus
  31405. if v == nil {
  31406. return
  31407. }
  31408. return *v, true
  31409. }
  31410. // ClearStatus clears the value of the "status" field.
  31411. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31412. m.status = nil
  31413. m.addstatus = nil
  31414. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31415. }
  31416. // StatusCleared returns if the "status" field was cleared in this mutation.
  31417. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31418. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31419. return ok
  31420. }
  31421. // ResetStatus resets all changes to the "status" field.
  31422. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31423. m.status = nil
  31424. m.addstatus = nil
  31425. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31426. }
  31427. // SetDeletedAt sets the "deleted_at" field.
  31428. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31429. m.deleted_at = &t
  31430. }
  31431. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31432. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31433. v := m.deleted_at
  31434. if v == nil {
  31435. return
  31436. }
  31437. return *v, true
  31438. }
  31439. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31440. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31442. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31443. if !m.op.Is(OpUpdateOne) {
  31444. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31445. }
  31446. if m.id == nil || m.oldValue == nil {
  31447. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31448. }
  31449. oldValue, err := m.oldValue(ctx)
  31450. if err != nil {
  31451. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31452. }
  31453. return oldValue.DeletedAt, nil
  31454. }
  31455. // ClearDeletedAt clears the value of the "deleted_at" field.
  31456. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31457. m.deleted_at = nil
  31458. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31459. }
  31460. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31461. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31462. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31463. return ok
  31464. }
  31465. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31466. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31467. m.deleted_at = nil
  31468. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31469. }
  31470. // SetAddtime sets the "addtime" field.
  31471. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31472. m.addtime = &u
  31473. m.addaddtime = nil
  31474. }
  31475. // Addtime returns the value of the "addtime" field in the mutation.
  31476. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31477. v := m.addtime
  31478. if v == nil {
  31479. return
  31480. }
  31481. return *v, true
  31482. }
  31483. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31484. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31486. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31487. if !m.op.Is(OpUpdateOne) {
  31488. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31489. }
  31490. if m.id == nil || m.oldValue == nil {
  31491. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31492. }
  31493. oldValue, err := m.oldValue(ctx)
  31494. if err != nil {
  31495. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31496. }
  31497. return oldValue.Addtime, nil
  31498. }
  31499. // AddAddtime adds u to the "addtime" field.
  31500. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31501. if m.addaddtime != nil {
  31502. *m.addaddtime += u
  31503. } else {
  31504. m.addaddtime = &u
  31505. }
  31506. }
  31507. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31508. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31509. v := m.addaddtime
  31510. if v == nil {
  31511. return
  31512. }
  31513. return *v, true
  31514. }
  31515. // ResetAddtime resets all changes to the "addtime" field.
  31516. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31517. m.addtime = nil
  31518. m.addaddtime = nil
  31519. }
  31520. // SetType sets the "type" field.
  31521. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31522. m._type = &i
  31523. m.add_type = nil
  31524. }
  31525. // GetType returns the value of the "type" field in the mutation.
  31526. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31527. v := m._type
  31528. if v == nil {
  31529. return
  31530. }
  31531. return *v, true
  31532. }
  31533. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31534. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31536. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31537. if !m.op.Is(OpUpdateOne) {
  31538. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31539. }
  31540. if m.id == nil || m.oldValue == nil {
  31541. return v, errors.New("OldType requires an ID field in the mutation")
  31542. }
  31543. oldValue, err := m.oldValue(ctx)
  31544. if err != nil {
  31545. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31546. }
  31547. return oldValue.Type, nil
  31548. }
  31549. // AddType adds i to the "type" field.
  31550. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31551. if m.add_type != nil {
  31552. *m.add_type += i
  31553. } else {
  31554. m.add_type = &i
  31555. }
  31556. }
  31557. // AddedType returns the value that was added to the "type" field in this mutation.
  31558. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31559. v := m.add_type
  31560. if v == nil {
  31561. return
  31562. }
  31563. return *v, true
  31564. }
  31565. // ResetType resets all changes to the "type" field.
  31566. func (m *UsageStatisticMonthMutation) ResetType() {
  31567. m._type = nil
  31568. m.add_type = nil
  31569. }
  31570. // SetBotID sets the "bot_id" field.
  31571. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31572. m.bot_id = &s
  31573. }
  31574. // BotID returns the value of the "bot_id" field in the mutation.
  31575. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31576. v := m.bot_id
  31577. if v == nil {
  31578. return
  31579. }
  31580. return *v, true
  31581. }
  31582. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31583. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31585. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31586. if !m.op.Is(OpUpdateOne) {
  31587. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31588. }
  31589. if m.id == nil || m.oldValue == nil {
  31590. return v, errors.New("OldBotID requires an ID field in the mutation")
  31591. }
  31592. oldValue, err := m.oldValue(ctx)
  31593. if err != nil {
  31594. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31595. }
  31596. return oldValue.BotID, nil
  31597. }
  31598. // ClearBotID clears the value of the "bot_id" field.
  31599. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31600. m.bot_id = nil
  31601. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31602. }
  31603. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31604. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31605. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31606. return ok
  31607. }
  31608. // ResetBotID resets all changes to the "bot_id" field.
  31609. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31610. m.bot_id = nil
  31611. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31612. }
  31613. // SetOrganizationID sets the "organization_id" field.
  31614. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31615. m.organization_id = &u
  31616. m.addorganization_id = nil
  31617. }
  31618. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31619. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31620. v := m.organization_id
  31621. if v == nil {
  31622. return
  31623. }
  31624. return *v, true
  31625. }
  31626. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31627. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31629. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31630. if !m.op.Is(OpUpdateOne) {
  31631. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31632. }
  31633. if m.id == nil || m.oldValue == nil {
  31634. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31635. }
  31636. oldValue, err := m.oldValue(ctx)
  31637. if err != nil {
  31638. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31639. }
  31640. return oldValue.OrganizationID, nil
  31641. }
  31642. // AddOrganizationID adds u to the "organization_id" field.
  31643. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31644. if m.addorganization_id != nil {
  31645. *m.addorganization_id += u
  31646. } else {
  31647. m.addorganization_id = &u
  31648. }
  31649. }
  31650. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31651. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31652. v := m.addorganization_id
  31653. if v == nil {
  31654. return
  31655. }
  31656. return *v, true
  31657. }
  31658. // ClearOrganizationID clears the value of the "organization_id" field.
  31659. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31660. m.organization_id = nil
  31661. m.addorganization_id = nil
  31662. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31663. }
  31664. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31665. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31666. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31667. return ok
  31668. }
  31669. // ResetOrganizationID resets all changes to the "organization_id" field.
  31670. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31671. m.organization_id = nil
  31672. m.addorganization_id = nil
  31673. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31674. }
  31675. // SetAiResponse sets the "ai_response" field.
  31676. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31677. m.ai_response = &u
  31678. m.addai_response = nil
  31679. }
  31680. // AiResponse returns the value of the "ai_response" field in the mutation.
  31681. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31682. v := m.ai_response
  31683. if v == nil {
  31684. return
  31685. }
  31686. return *v, true
  31687. }
  31688. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31689. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31691. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31692. if !m.op.Is(OpUpdateOne) {
  31693. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31694. }
  31695. if m.id == nil || m.oldValue == nil {
  31696. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31697. }
  31698. oldValue, err := m.oldValue(ctx)
  31699. if err != nil {
  31700. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31701. }
  31702. return oldValue.AiResponse, nil
  31703. }
  31704. // AddAiResponse adds u to the "ai_response" field.
  31705. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31706. if m.addai_response != nil {
  31707. *m.addai_response += u
  31708. } else {
  31709. m.addai_response = &u
  31710. }
  31711. }
  31712. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31713. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31714. v := m.addai_response
  31715. if v == nil {
  31716. return
  31717. }
  31718. return *v, true
  31719. }
  31720. // ResetAiResponse resets all changes to the "ai_response" field.
  31721. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31722. m.ai_response = nil
  31723. m.addai_response = nil
  31724. }
  31725. // SetSopRun sets the "sop_run" field.
  31726. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31727. m.sop_run = &u
  31728. m.addsop_run = nil
  31729. }
  31730. // SopRun returns the value of the "sop_run" field in the mutation.
  31731. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31732. v := m.sop_run
  31733. if v == nil {
  31734. return
  31735. }
  31736. return *v, true
  31737. }
  31738. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31739. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31741. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31742. if !m.op.Is(OpUpdateOne) {
  31743. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31744. }
  31745. if m.id == nil || m.oldValue == nil {
  31746. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31747. }
  31748. oldValue, err := m.oldValue(ctx)
  31749. if err != nil {
  31750. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31751. }
  31752. return oldValue.SopRun, nil
  31753. }
  31754. // AddSopRun adds u to the "sop_run" field.
  31755. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31756. if m.addsop_run != nil {
  31757. *m.addsop_run += u
  31758. } else {
  31759. m.addsop_run = &u
  31760. }
  31761. }
  31762. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31763. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31764. v := m.addsop_run
  31765. if v == nil {
  31766. return
  31767. }
  31768. return *v, true
  31769. }
  31770. // ResetSopRun resets all changes to the "sop_run" field.
  31771. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31772. m.sop_run = nil
  31773. m.addsop_run = nil
  31774. }
  31775. // SetTotalFriend sets the "total_friend" field.
  31776. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31777. m.total_friend = &u
  31778. m.addtotal_friend = nil
  31779. }
  31780. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31781. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31782. v := m.total_friend
  31783. if v == nil {
  31784. return
  31785. }
  31786. return *v, true
  31787. }
  31788. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31789. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31791. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31792. if !m.op.Is(OpUpdateOne) {
  31793. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31794. }
  31795. if m.id == nil || m.oldValue == nil {
  31796. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31797. }
  31798. oldValue, err := m.oldValue(ctx)
  31799. if err != nil {
  31800. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31801. }
  31802. return oldValue.TotalFriend, nil
  31803. }
  31804. // AddTotalFriend adds u to the "total_friend" field.
  31805. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31806. if m.addtotal_friend != nil {
  31807. *m.addtotal_friend += u
  31808. } else {
  31809. m.addtotal_friend = &u
  31810. }
  31811. }
  31812. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31813. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31814. v := m.addtotal_friend
  31815. if v == nil {
  31816. return
  31817. }
  31818. return *v, true
  31819. }
  31820. // ResetTotalFriend resets all changes to the "total_friend" field.
  31821. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31822. m.total_friend = nil
  31823. m.addtotal_friend = nil
  31824. }
  31825. // SetTotalGroup sets the "total_group" field.
  31826. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31827. m.total_group = &u
  31828. m.addtotal_group = nil
  31829. }
  31830. // TotalGroup returns the value of the "total_group" field in the mutation.
  31831. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31832. v := m.total_group
  31833. if v == nil {
  31834. return
  31835. }
  31836. return *v, true
  31837. }
  31838. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31839. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31841. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31842. if !m.op.Is(OpUpdateOne) {
  31843. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31844. }
  31845. if m.id == nil || m.oldValue == nil {
  31846. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31847. }
  31848. oldValue, err := m.oldValue(ctx)
  31849. if err != nil {
  31850. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31851. }
  31852. return oldValue.TotalGroup, nil
  31853. }
  31854. // AddTotalGroup adds u to the "total_group" field.
  31855. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31856. if m.addtotal_group != nil {
  31857. *m.addtotal_group += u
  31858. } else {
  31859. m.addtotal_group = &u
  31860. }
  31861. }
  31862. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31863. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31864. v := m.addtotal_group
  31865. if v == nil {
  31866. return
  31867. }
  31868. return *v, true
  31869. }
  31870. // ResetTotalGroup resets all changes to the "total_group" field.
  31871. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31872. m.total_group = nil
  31873. m.addtotal_group = nil
  31874. }
  31875. // SetAccountBalance sets the "account_balance" field.
  31876. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31877. m.account_balance = &u
  31878. m.addaccount_balance = nil
  31879. }
  31880. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31881. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31882. v := m.account_balance
  31883. if v == nil {
  31884. return
  31885. }
  31886. return *v, true
  31887. }
  31888. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31889. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31891. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31892. if !m.op.Is(OpUpdateOne) {
  31893. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31894. }
  31895. if m.id == nil || m.oldValue == nil {
  31896. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31897. }
  31898. oldValue, err := m.oldValue(ctx)
  31899. if err != nil {
  31900. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31901. }
  31902. return oldValue.AccountBalance, nil
  31903. }
  31904. // AddAccountBalance adds u to the "account_balance" field.
  31905. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31906. if m.addaccount_balance != nil {
  31907. *m.addaccount_balance += u
  31908. } else {
  31909. m.addaccount_balance = &u
  31910. }
  31911. }
  31912. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31913. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31914. v := m.addaccount_balance
  31915. if v == nil {
  31916. return
  31917. }
  31918. return *v, true
  31919. }
  31920. // ResetAccountBalance resets all changes to the "account_balance" field.
  31921. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31922. m.account_balance = nil
  31923. m.addaccount_balance = nil
  31924. }
  31925. // SetConsumeToken sets the "consume_token" field.
  31926. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31927. m.consume_token = &u
  31928. m.addconsume_token = nil
  31929. }
  31930. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31931. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31932. v := m.consume_token
  31933. if v == nil {
  31934. return
  31935. }
  31936. return *v, true
  31937. }
  31938. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31939. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31941. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31942. if !m.op.Is(OpUpdateOne) {
  31943. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31944. }
  31945. if m.id == nil || m.oldValue == nil {
  31946. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31947. }
  31948. oldValue, err := m.oldValue(ctx)
  31949. if err != nil {
  31950. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31951. }
  31952. return oldValue.ConsumeToken, nil
  31953. }
  31954. // AddConsumeToken adds u to the "consume_token" field.
  31955. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31956. if m.addconsume_token != nil {
  31957. *m.addconsume_token += u
  31958. } else {
  31959. m.addconsume_token = &u
  31960. }
  31961. }
  31962. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31963. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31964. v := m.addconsume_token
  31965. if v == nil {
  31966. return
  31967. }
  31968. return *v, true
  31969. }
  31970. // ResetConsumeToken resets all changes to the "consume_token" field.
  31971. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31972. m.consume_token = nil
  31973. m.addconsume_token = nil
  31974. }
  31975. // SetActiveUser sets the "active_user" field.
  31976. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31977. m.active_user = &u
  31978. m.addactive_user = nil
  31979. }
  31980. // ActiveUser returns the value of the "active_user" field in the mutation.
  31981. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31982. v := m.active_user
  31983. if v == nil {
  31984. return
  31985. }
  31986. return *v, true
  31987. }
  31988. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31989. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31991. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31992. if !m.op.Is(OpUpdateOne) {
  31993. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31994. }
  31995. if m.id == nil || m.oldValue == nil {
  31996. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31997. }
  31998. oldValue, err := m.oldValue(ctx)
  31999. if err != nil {
  32000. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32001. }
  32002. return oldValue.ActiveUser, nil
  32003. }
  32004. // AddActiveUser adds u to the "active_user" field.
  32005. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32006. if m.addactive_user != nil {
  32007. *m.addactive_user += u
  32008. } else {
  32009. m.addactive_user = &u
  32010. }
  32011. }
  32012. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32013. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32014. v := m.addactive_user
  32015. if v == nil {
  32016. return
  32017. }
  32018. return *v, true
  32019. }
  32020. // ResetActiveUser resets all changes to the "active_user" field.
  32021. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32022. m.active_user = nil
  32023. m.addactive_user = nil
  32024. }
  32025. // SetNewUser sets the "new_user" field.
  32026. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32027. m.new_user = &i
  32028. m.addnew_user = nil
  32029. }
  32030. // NewUser returns the value of the "new_user" field in the mutation.
  32031. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32032. v := m.new_user
  32033. if v == nil {
  32034. return
  32035. }
  32036. return *v, true
  32037. }
  32038. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32039. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32041. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32042. if !m.op.Is(OpUpdateOne) {
  32043. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32044. }
  32045. if m.id == nil || m.oldValue == nil {
  32046. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32047. }
  32048. oldValue, err := m.oldValue(ctx)
  32049. if err != nil {
  32050. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32051. }
  32052. return oldValue.NewUser, nil
  32053. }
  32054. // AddNewUser adds i to the "new_user" field.
  32055. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32056. if m.addnew_user != nil {
  32057. *m.addnew_user += i
  32058. } else {
  32059. m.addnew_user = &i
  32060. }
  32061. }
  32062. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32063. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32064. v := m.addnew_user
  32065. if v == nil {
  32066. return
  32067. }
  32068. return *v, true
  32069. }
  32070. // ResetNewUser resets all changes to the "new_user" field.
  32071. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32072. m.new_user = nil
  32073. m.addnew_user = nil
  32074. }
  32075. // SetLabelDist sets the "label_dist" field.
  32076. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32077. m.label_dist = &ctd
  32078. m.appendlabel_dist = nil
  32079. }
  32080. // LabelDist returns the value of the "label_dist" field in the mutation.
  32081. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32082. v := m.label_dist
  32083. if v == nil {
  32084. return
  32085. }
  32086. return *v, true
  32087. }
  32088. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32089. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32091. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32092. if !m.op.Is(OpUpdateOne) {
  32093. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32094. }
  32095. if m.id == nil || m.oldValue == nil {
  32096. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32097. }
  32098. oldValue, err := m.oldValue(ctx)
  32099. if err != nil {
  32100. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32101. }
  32102. return oldValue.LabelDist, nil
  32103. }
  32104. // AppendLabelDist adds ctd to the "label_dist" field.
  32105. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32106. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32107. }
  32108. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32109. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32110. if len(m.appendlabel_dist) == 0 {
  32111. return nil, false
  32112. }
  32113. return m.appendlabel_dist, true
  32114. }
  32115. // ResetLabelDist resets all changes to the "label_dist" field.
  32116. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32117. m.label_dist = nil
  32118. m.appendlabel_dist = nil
  32119. }
  32120. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32121. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32122. m.predicates = append(m.predicates, ps...)
  32123. }
  32124. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32125. // users can use type-assertion to append predicates that do not depend on any generated package.
  32126. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32127. p := make([]predicate.UsageStatisticMonth, len(ps))
  32128. for i := range ps {
  32129. p[i] = ps[i]
  32130. }
  32131. m.Where(p...)
  32132. }
  32133. // Op returns the operation name.
  32134. func (m *UsageStatisticMonthMutation) Op() Op {
  32135. return m.op
  32136. }
  32137. // SetOp allows setting the mutation operation.
  32138. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32139. m.op = op
  32140. }
  32141. // Type returns the node type of this mutation (UsageStatisticMonth).
  32142. func (m *UsageStatisticMonthMutation) Type() string {
  32143. return m.typ
  32144. }
  32145. // Fields returns all fields that were changed during this mutation. Note that in
  32146. // order to get all numeric fields that were incremented/decremented, call
  32147. // AddedFields().
  32148. func (m *UsageStatisticMonthMutation) Fields() []string {
  32149. fields := make([]string, 0, 17)
  32150. if m.created_at != nil {
  32151. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32152. }
  32153. if m.updated_at != nil {
  32154. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32155. }
  32156. if m.status != nil {
  32157. fields = append(fields, usagestatisticmonth.FieldStatus)
  32158. }
  32159. if m.deleted_at != nil {
  32160. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32161. }
  32162. if m.addtime != nil {
  32163. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32164. }
  32165. if m._type != nil {
  32166. fields = append(fields, usagestatisticmonth.FieldType)
  32167. }
  32168. if m.bot_id != nil {
  32169. fields = append(fields, usagestatisticmonth.FieldBotID)
  32170. }
  32171. if m.organization_id != nil {
  32172. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32173. }
  32174. if m.ai_response != nil {
  32175. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32176. }
  32177. if m.sop_run != nil {
  32178. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32179. }
  32180. if m.total_friend != nil {
  32181. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32182. }
  32183. if m.total_group != nil {
  32184. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32185. }
  32186. if m.account_balance != nil {
  32187. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32188. }
  32189. if m.consume_token != nil {
  32190. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32191. }
  32192. if m.active_user != nil {
  32193. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32194. }
  32195. if m.new_user != nil {
  32196. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32197. }
  32198. if m.label_dist != nil {
  32199. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32200. }
  32201. return fields
  32202. }
  32203. // Field returns the value of a field with the given name. The second boolean
  32204. // return value indicates that this field was not set, or was not defined in the
  32205. // schema.
  32206. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32207. switch name {
  32208. case usagestatisticmonth.FieldCreatedAt:
  32209. return m.CreatedAt()
  32210. case usagestatisticmonth.FieldUpdatedAt:
  32211. return m.UpdatedAt()
  32212. case usagestatisticmonth.FieldStatus:
  32213. return m.Status()
  32214. case usagestatisticmonth.FieldDeletedAt:
  32215. return m.DeletedAt()
  32216. case usagestatisticmonth.FieldAddtime:
  32217. return m.Addtime()
  32218. case usagestatisticmonth.FieldType:
  32219. return m.GetType()
  32220. case usagestatisticmonth.FieldBotID:
  32221. return m.BotID()
  32222. case usagestatisticmonth.FieldOrganizationID:
  32223. return m.OrganizationID()
  32224. case usagestatisticmonth.FieldAiResponse:
  32225. return m.AiResponse()
  32226. case usagestatisticmonth.FieldSopRun:
  32227. return m.SopRun()
  32228. case usagestatisticmonth.FieldTotalFriend:
  32229. return m.TotalFriend()
  32230. case usagestatisticmonth.FieldTotalGroup:
  32231. return m.TotalGroup()
  32232. case usagestatisticmonth.FieldAccountBalance:
  32233. return m.AccountBalance()
  32234. case usagestatisticmonth.FieldConsumeToken:
  32235. return m.ConsumeToken()
  32236. case usagestatisticmonth.FieldActiveUser:
  32237. return m.ActiveUser()
  32238. case usagestatisticmonth.FieldNewUser:
  32239. return m.NewUser()
  32240. case usagestatisticmonth.FieldLabelDist:
  32241. return m.LabelDist()
  32242. }
  32243. return nil, false
  32244. }
  32245. // OldField returns the old value of the field from the database. An error is
  32246. // returned if the mutation operation is not UpdateOne, or the query to the
  32247. // database failed.
  32248. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32249. switch name {
  32250. case usagestatisticmonth.FieldCreatedAt:
  32251. return m.OldCreatedAt(ctx)
  32252. case usagestatisticmonth.FieldUpdatedAt:
  32253. return m.OldUpdatedAt(ctx)
  32254. case usagestatisticmonth.FieldStatus:
  32255. return m.OldStatus(ctx)
  32256. case usagestatisticmonth.FieldDeletedAt:
  32257. return m.OldDeletedAt(ctx)
  32258. case usagestatisticmonth.FieldAddtime:
  32259. return m.OldAddtime(ctx)
  32260. case usagestatisticmonth.FieldType:
  32261. return m.OldType(ctx)
  32262. case usagestatisticmonth.FieldBotID:
  32263. return m.OldBotID(ctx)
  32264. case usagestatisticmonth.FieldOrganizationID:
  32265. return m.OldOrganizationID(ctx)
  32266. case usagestatisticmonth.FieldAiResponse:
  32267. return m.OldAiResponse(ctx)
  32268. case usagestatisticmonth.FieldSopRun:
  32269. return m.OldSopRun(ctx)
  32270. case usagestatisticmonth.FieldTotalFriend:
  32271. return m.OldTotalFriend(ctx)
  32272. case usagestatisticmonth.FieldTotalGroup:
  32273. return m.OldTotalGroup(ctx)
  32274. case usagestatisticmonth.FieldAccountBalance:
  32275. return m.OldAccountBalance(ctx)
  32276. case usagestatisticmonth.FieldConsumeToken:
  32277. return m.OldConsumeToken(ctx)
  32278. case usagestatisticmonth.FieldActiveUser:
  32279. return m.OldActiveUser(ctx)
  32280. case usagestatisticmonth.FieldNewUser:
  32281. return m.OldNewUser(ctx)
  32282. case usagestatisticmonth.FieldLabelDist:
  32283. return m.OldLabelDist(ctx)
  32284. }
  32285. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32286. }
  32287. // SetField sets the value of a field with the given name. It returns an error if
  32288. // the field is not defined in the schema, or if the type mismatched the field
  32289. // type.
  32290. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32291. switch name {
  32292. case usagestatisticmonth.FieldCreatedAt:
  32293. v, ok := value.(time.Time)
  32294. if !ok {
  32295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32296. }
  32297. m.SetCreatedAt(v)
  32298. return nil
  32299. case usagestatisticmonth.FieldUpdatedAt:
  32300. v, ok := value.(time.Time)
  32301. if !ok {
  32302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32303. }
  32304. m.SetUpdatedAt(v)
  32305. return nil
  32306. case usagestatisticmonth.FieldStatus:
  32307. v, ok := value.(uint8)
  32308. if !ok {
  32309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32310. }
  32311. m.SetStatus(v)
  32312. return nil
  32313. case usagestatisticmonth.FieldDeletedAt:
  32314. v, ok := value.(time.Time)
  32315. if !ok {
  32316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32317. }
  32318. m.SetDeletedAt(v)
  32319. return nil
  32320. case usagestatisticmonth.FieldAddtime:
  32321. v, ok := value.(uint64)
  32322. if !ok {
  32323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32324. }
  32325. m.SetAddtime(v)
  32326. return nil
  32327. case usagestatisticmonth.FieldType:
  32328. v, ok := value.(int)
  32329. if !ok {
  32330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32331. }
  32332. m.SetType(v)
  32333. return nil
  32334. case usagestatisticmonth.FieldBotID:
  32335. v, ok := value.(string)
  32336. if !ok {
  32337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32338. }
  32339. m.SetBotID(v)
  32340. return nil
  32341. case usagestatisticmonth.FieldOrganizationID:
  32342. v, ok := value.(uint64)
  32343. if !ok {
  32344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32345. }
  32346. m.SetOrganizationID(v)
  32347. return nil
  32348. case usagestatisticmonth.FieldAiResponse:
  32349. v, ok := value.(uint64)
  32350. if !ok {
  32351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32352. }
  32353. m.SetAiResponse(v)
  32354. return nil
  32355. case usagestatisticmonth.FieldSopRun:
  32356. v, ok := value.(uint64)
  32357. if !ok {
  32358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32359. }
  32360. m.SetSopRun(v)
  32361. return nil
  32362. case usagestatisticmonth.FieldTotalFriend:
  32363. v, ok := value.(uint64)
  32364. if !ok {
  32365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32366. }
  32367. m.SetTotalFriend(v)
  32368. return nil
  32369. case usagestatisticmonth.FieldTotalGroup:
  32370. v, ok := value.(uint64)
  32371. if !ok {
  32372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32373. }
  32374. m.SetTotalGroup(v)
  32375. return nil
  32376. case usagestatisticmonth.FieldAccountBalance:
  32377. v, ok := value.(uint64)
  32378. if !ok {
  32379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32380. }
  32381. m.SetAccountBalance(v)
  32382. return nil
  32383. case usagestatisticmonth.FieldConsumeToken:
  32384. v, ok := value.(uint64)
  32385. if !ok {
  32386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32387. }
  32388. m.SetConsumeToken(v)
  32389. return nil
  32390. case usagestatisticmonth.FieldActiveUser:
  32391. v, ok := value.(uint64)
  32392. if !ok {
  32393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32394. }
  32395. m.SetActiveUser(v)
  32396. return nil
  32397. case usagestatisticmonth.FieldNewUser:
  32398. v, ok := value.(int64)
  32399. if !ok {
  32400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32401. }
  32402. m.SetNewUser(v)
  32403. return nil
  32404. case usagestatisticmonth.FieldLabelDist:
  32405. v, ok := value.([]custom_types.LabelDist)
  32406. if !ok {
  32407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32408. }
  32409. m.SetLabelDist(v)
  32410. return nil
  32411. }
  32412. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32413. }
  32414. // AddedFields returns all numeric fields that were incremented/decremented during
  32415. // this mutation.
  32416. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32417. var fields []string
  32418. if m.addstatus != nil {
  32419. fields = append(fields, usagestatisticmonth.FieldStatus)
  32420. }
  32421. if m.addaddtime != nil {
  32422. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32423. }
  32424. if m.add_type != nil {
  32425. fields = append(fields, usagestatisticmonth.FieldType)
  32426. }
  32427. if m.addorganization_id != nil {
  32428. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32429. }
  32430. if m.addai_response != nil {
  32431. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32432. }
  32433. if m.addsop_run != nil {
  32434. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32435. }
  32436. if m.addtotal_friend != nil {
  32437. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32438. }
  32439. if m.addtotal_group != nil {
  32440. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32441. }
  32442. if m.addaccount_balance != nil {
  32443. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32444. }
  32445. if m.addconsume_token != nil {
  32446. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32447. }
  32448. if m.addactive_user != nil {
  32449. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32450. }
  32451. if m.addnew_user != nil {
  32452. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32453. }
  32454. return fields
  32455. }
  32456. // AddedField returns the numeric value that was incremented/decremented on a field
  32457. // with the given name. The second boolean return value indicates that this field
  32458. // was not set, or was not defined in the schema.
  32459. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32460. switch name {
  32461. case usagestatisticmonth.FieldStatus:
  32462. return m.AddedStatus()
  32463. case usagestatisticmonth.FieldAddtime:
  32464. return m.AddedAddtime()
  32465. case usagestatisticmonth.FieldType:
  32466. return m.AddedType()
  32467. case usagestatisticmonth.FieldOrganizationID:
  32468. return m.AddedOrganizationID()
  32469. case usagestatisticmonth.FieldAiResponse:
  32470. return m.AddedAiResponse()
  32471. case usagestatisticmonth.FieldSopRun:
  32472. return m.AddedSopRun()
  32473. case usagestatisticmonth.FieldTotalFriend:
  32474. return m.AddedTotalFriend()
  32475. case usagestatisticmonth.FieldTotalGroup:
  32476. return m.AddedTotalGroup()
  32477. case usagestatisticmonth.FieldAccountBalance:
  32478. return m.AddedAccountBalance()
  32479. case usagestatisticmonth.FieldConsumeToken:
  32480. return m.AddedConsumeToken()
  32481. case usagestatisticmonth.FieldActiveUser:
  32482. return m.AddedActiveUser()
  32483. case usagestatisticmonth.FieldNewUser:
  32484. return m.AddedNewUser()
  32485. }
  32486. return nil, false
  32487. }
  32488. // AddField adds the value to the field with the given name. It returns an error if
  32489. // the field is not defined in the schema, or if the type mismatched the field
  32490. // type.
  32491. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32492. switch name {
  32493. case usagestatisticmonth.FieldStatus:
  32494. v, ok := value.(int8)
  32495. if !ok {
  32496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32497. }
  32498. m.AddStatus(v)
  32499. return nil
  32500. case usagestatisticmonth.FieldAddtime:
  32501. v, ok := value.(int64)
  32502. if !ok {
  32503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32504. }
  32505. m.AddAddtime(v)
  32506. return nil
  32507. case usagestatisticmonth.FieldType:
  32508. v, ok := value.(int)
  32509. if !ok {
  32510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32511. }
  32512. m.AddType(v)
  32513. return nil
  32514. case usagestatisticmonth.FieldOrganizationID:
  32515. v, ok := value.(int64)
  32516. if !ok {
  32517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32518. }
  32519. m.AddOrganizationID(v)
  32520. return nil
  32521. case usagestatisticmonth.FieldAiResponse:
  32522. v, ok := value.(int64)
  32523. if !ok {
  32524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32525. }
  32526. m.AddAiResponse(v)
  32527. return nil
  32528. case usagestatisticmonth.FieldSopRun:
  32529. v, ok := value.(int64)
  32530. if !ok {
  32531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32532. }
  32533. m.AddSopRun(v)
  32534. return nil
  32535. case usagestatisticmonth.FieldTotalFriend:
  32536. v, ok := value.(int64)
  32537. if !ok {
  32538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32539. }
  32540. m.AddTotalFriend(v)
  32541. return nil
  32542. case usagestatisticmonth.FieldTotalGroup:
  32543. v, ok := value.(int64)
  32544. if !ok {
  32545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32546. }
  32547. m.AddTotalGroup(v)
  32548. return nil
  32549. case usagestatisticmonth.FieldAccountBalance:
  32550. v, ok := value.(int64)
  32551. if !ok {
  32552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32553. }
  32554. m.AddAccountBalance(v)
  32555. return nil
  32556. case usagestatisticmonth.FieldConsumeToken:
  32557. v, ok := value.(int64)
  32558. if !ok {
  32559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32560. }
  32561. m.AddConsumeToken(v)
  32562. return nil
  32563. case usagestatisticmonth.FieldActiveUser:
  32564. v, ok := value.(int64)
  32565. if !ok {
  32566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32567. }
  32568. m.AddActiveUser(v)
  32569. return nil
  32570. case usagestatisticmonth.FieldNewUser:
  32571. v, ok := value.(int64)
  32572. if !ok {
  32573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32574. }
  32575. m.AddNewUser(v)
  32576. return nil
  32577. }
  32578. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32579. }
  32580. // ClearedFields returns all nullable fields that were cleared during this
  32581. // mutation.
  32582. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32583. var fields []string
  32584. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32585. fields = append(fields, usagestatisticmonth.FieldStatus)
  32586. }
  32587. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32588. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32589. }
  32590. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32591. fields = append(fields, usagestatisticmonth.FieldBotID)
  32592. }
  32593. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32594. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32595. }
  32596. return fields
  32597. }
  32598. // FieldCleared returns a boolean indicating if a field with the given name was
  32599. // cleared in this mutation.
  32600. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32601. _, ok := m.clearedFields[name]
  32602. return ok
  32603. }
  32604. // ClearField clears the value of the field with the given name. It returns an
  32605. // error if the field is not defined in the schema.
  32606. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32607. switch name {
  32608. case usagestatisticmonth.FieldStatus:
  32609. m.ClearStatus()
  32610. return nil
  32611. case usagestatisticmonth.FieldDeletedAt:
  32612. m.ClearDeletedAt()
  32613. return nil
  32614. case usagestatisticmonth.FieldBotID:
  32615. m.ClearBotID()
  32616. return nil
  32617. case usagestatisticmonth.FieldOrganizationID:
  32618. m.ClearOrganizationID()
  32619. return nil
  32620. }
  32621. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32622. }
  32623. // ResetField resets all changes in the mutation for the field with the given name.
  32624. // It returns an error if the field is not defined in the schema.
  32625. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32626. switch name {
  32627. case usagestatisticmonth.FieldCreatedAt:
  32628. m.ResetCreatedAt()
  32629. return nil
  32630. case usagestatisticmonth.FieldUpdatedAt:
  32631. m.ResetUpdatedAt()
  32632. return nil
  32633. case usagestatisticmonth.FieldStatus:
  32634. m.ResetStatus()
  32635. return nil
  32636. case usagestatisticmonth.FieldDeletedAt:
  32637. m.ResetDeletedAt()
  32638. return nil
  32639. case usagestatisticmonth.FieldAddtime:
  32640. m.ResetAddtime()
  32641. return nil
  32642. case usagestatisticmonth.FieldType:
  32643. m.ResetType()
  32644. return nil
  32645. case usagestatisticmonth.FieldBotID:
  32646. m.ResetBotID()
  32647. return nil
  32648. case usagestatisticmonth.FieldOrganizationID:
  32649. m.ResetOrganizationID()
  32650. return nil
  32651. case usagestatisticmonth.FieldAiResponse:
  32652. m.ResetAiResponse()
  32653. return nil
  32654. case usagestatisticmonth.FieldSopRun:
  32655. m.ResetSopRun()
  32656. return nil
  32657. case usagestatisticmonth.FieldTotalFriend:
  32658. m.ResetTotalFriend()
  32659. return nil
  32660. case usagestatisticmonth.FieldTotalGroup:
  32661. m.ResetTotalGroup()
  32662. return nil
  32663. case usagestatisticmonth.FieldAccountBalance:
  32664. m.ResetAccountBalance()
  32665. return nil
  32666. case usagestatisticmonth.FieldConsumeToken:
  32667. m.ResetConsumeToken()
  32668. return nil
  32669. case usagestatisticmonth.FieldActiveUser:
  32670. m.ResetActiveUser()
  32671. return nil
  32672. case usagestatisticmonth.FieldNewUser:
  32673. m.ResetNewUser()
  32674. return nil
  32675. case usagestatisticmonth.FieldLabelDist:
  32676. m.ResetLabelDist()
  32677. return nil
  32678. }
  32679. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32680. }
  32681. // AddedEdges returns all edge names that were set/added in this mutation.
  32682. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32683. edges := make([]string, 0, 0)
  32684. return edges
  32685. }
  32686. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32687. // name in this mutation.
  32688. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32689. return nil
  32690. }
  32691. // RemovedEdges returns all edge names that were removed in this mutation.
  32692. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32693. edges := make([]string, 0, 0)
  32694. return edges
  32695. }
  32696. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32697. // the given name in this mutation.
  32698. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32699. return nil
  32700. }
  32701. // ClearedEdges returns all edge names that were cleared in this mutation.
  32702. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32703. edges := make([]string, 0, 0)
  32704. return edges
  32705. }
  32706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32707. // was cleared in this mutation.
  32708. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32709. return false
  32710. }
  32711. // ClearEdge clears the value of the edge with the given name. It returns an error
  32712. // if that edge is not defined in the schema.
  32713. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32714. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32715. }
  32716. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32717. // It returns an error if the edge is not defined in the schema.
  32718. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32719. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32720. }
  32721. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32722. type UsageTotalMutation struct {
  32723. config
  32724. op Op
  32725. typ string
  32726. id *uint64
  32727. created_at *time.Time
  32728. updated_at *time.Time
  32729. status *uint8
  32730. addstatus *int8
  32731. _type *int
  32732. add_type *int
  32733. bot_id *string
  32734. total_tokens *uint64
  32735. addtotal_tokens *int64
  32736. start_index *uint64
  32737. addstart_index *int64
  32738. end_index *uint64
  32739. addend_index *int64
  32740. organization_id *uint64
  32741. addorganization_id *int64
  32742. clearedFields map[string]struct{}
  32743. done bool
  32744. oldValue func(context.Context) (*UsageTotal, error)
  32745. predicates []predicate.UsageTotal
  32746. }
  32747. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32748. // usagetotalOption allows management of the mutation configuration using functional options.
  32749. type usagetotalOption func(*UsageTotalMutation)
  32750. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32751. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32752. m := &UsageTotalMutation{
  32753. config: c,
  32754. op: op,
  32755. typ: TypeUsageTotal,
  32756. clearedFields: make(map[string]struct{}),
  32757. }
  32758. for _, opt := range opts {
  32759. opt(m)
  32760. }
  32761. return m
  32762. }
  32763. // withUsageTotalID sets the ID field of the mutation.
  32764. func withUsageTotalID(id uint64) usagetotalOption {
  32765. return func(m *UsageTotalMutation) {
  32766. var (
  32767. err error
  32768. once sync.Once
  32769. value *UsageTotal
  32770. )
  32771. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32772. once.Do(func() {
  32773. if m.done {
  32774. err = errors.New("querying old values post mutation is not allowed")
  32775. } else {
  32776. value, err = m.Client().UsageTotal.Get(ctx, id)
  32777. }
  32778. })
  32779. return value, err
  32780. }
  32781. m.id = &id
  32782. }
  32783. }
  32784. // withUsageTotal sets the old UsageTotal of the mutation.
  32785. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32786. return func(m *UsageTotalMutation) {
  32787. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32788. return node, nil
  32789. }
  32790. m.id = &node.ID
  32791. }
  32792. }
  32793. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32794. // executed in a transaction (ent.Tx), a transactional client is returned.
  32795. func (m UsageTotalMutation) Client() *Client {
  32796. client := &Client{config: m.config}
  32797. client.init()
  32798. return client
  32799. }
  32800. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32801. // it returns an error otherwise.
  32802. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32803. if _, ok := m.driver.(*txDriver); !ok {
  32804. return nil, errors.New("ent: mutation is not running in a transaction")
  32805. }
  32806. tx := &Tx{config: m.config}
  32807. tx.init()
  32808. return tx, nil
  32809. }
  32810. // SetID sets the value of the id field. Note that this
  32811. // operation is only accepted on creation of UsageTotal entities.
  32812. func (m *UsageTotalMutation) SetID(id uint64) {
  32813. m.id = &id
  32814. }
  32815. // ID returns the ID value in the mutation. Note that the ID is only available
  32816. // if it was provided to the builder or after it was returned from the database.
  32817. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32818. if m.id == nil {
  32819. return
  32820. }
  32821. return *m.id, true
  32822. }
  32823. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32824. // That means, if the mutation is applied within a transaction with an isolation level such
  32825. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32826. // or updated by the mutation.
  32827. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32828. switch {
  32829. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32830. id, exists := m.ID()
  32831. if exists {
  32832. return []uint64{id}, nil
  32833. }
  32834. fallthrough
  32835. case m.op.Is(OpUpdate | OpDelete):
  32836. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32837. default:
  32838. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32839. }
  32840. }
  32841. // SetCreatedAt sets the "created_at" field.
  32842. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32843. m.created_at = &t
  32844. }
  32845. // CreatedAt returns the value of the "created_at" field in the mutation.
  32846. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32847. v := m.created_at
  32848. if v == nil {
  32849. return
  32850. }
  32851. return *v, true
  32852. }
  32853. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32854. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32856. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32857. if !m.op.Is(OpUpdateOne) {
  32858. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32859. }
  32860. if m.id == nil || m.oldValue == nil {
  32861. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32862. }
  32863. oldValue, err := m.oldValue(ctx)
  32864. if err != nil {
  32865. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32866. }
  32867. return oldValue.CreatedAt, nil
  32868. }
  32869. // ResetCreatedAt resets all changes to the "created_at" field.
  32870. func (m *UsageTotalMutation) ResetCreatedAt() {
  32871. m.created_at = nil
  32872. }
  32873. // SetUpdatedAt sets the "updated_at" field.
  32874. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32875. m.updated_at = &t
  32876. }
  32877. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32878. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32879. v := m.updated_at
  32880. if v == nil {
  32881. return
  32882. }
  32883. return *v, true
  32884. }
  32885. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32886. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32888. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32889. if !m.op.Is(OpUpdateOne) {
  32890. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32891. }
  32892. if m.id == nil || m.oldValue == nil {
  32893. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32894. }
  32895. oldValue, err := m.oldValue(ctx)
  32896. if err != nil {
  32897. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32898. }
  32899. return oldValue.UpdatedAt, nil
  32900. }
  32901. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32902. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32903. m.updated_at = nil
  32904. }
  32905. // SetStatus sets the "status" field.
  32906. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32907. m.status = &u
  32908. m.addstatus = nil
  32909. }
  32910. // Status returns the value of the "status" field in the mutation.
  32911. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32912. v := m.status
  32913. if v == nil {
  32914. return
  32915. }
  32916. return *v, true
  32917. }
  32918. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32919. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32921. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32922. if !m.op.Is(OpUpdateOne) {
  32923. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32924. }
  32925. if m.id == nil || m.oldValue == nil {
  32926. return v, errors.New("OldStatus requires an ID field in the mutation")
  32927. }
  32928. oldValue, err := m.oldValue(ctx)
  32929. if err != nil {
  32930. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32931. }
  32932. return oldValue.Status, nil
  32933. }
  32934. // AddStatus adds u to the "status" field.
  32935. func (m *UsageTotalMutation) AddStatus(u int8) {
  32936. if m.addstatus != nil {
  32937. *m.addstatus += u
  32938. } else {
  32939. m.addstatus = &u
  32940. }
  32941. }
  32942. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32943. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32944. v := m.addstatus
  32945. if v == nil {
  32946. return
  32947. }
  32948. return *v, true
  32949. }
  32950. // ClearStatus clears the value of the "status" field.
  32951. func (m *UsageTotalMutation) ClearStatus() {
  32952. m.status = nil
  32953. m.addstatus = nil
  32954. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32955. }
  32956. // StatusCleared returns if the "status" field was cleared in this mutation.
  32957. func (m *UsageTotalMutation) StatusCleared() bool {
  32958. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32959. return ok
  32960. }
  32961. // ResetStatus resets all changes to the "status" field.
  32962. func (m *UsageTotalMutation) ResetStatus() {
  32963. m.status = nil
  32964. m.addstatus = nil
  32965. delete(m.clearedFields, usagetotal.FieldStatus)
  32966. }
  32967. // SetType sets the "type" field.
  32968. func (m *UsageTotalMutation) SetType(i int) {
  32969. m._type = &i
  32970. m.add_type = nil
  32971. }
  32972. // GetType returns the value of the "type" field in the mutation.
  32973. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32974. v := m._type
  32975. if v == nil {
  32976. return
  32977. }
  32978. return *v, true
  32979. }
  32980. // OldType returns the old "type" field's value of the UsageTotal entity.
  32981. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32983. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32984. if !m.op.Is(OpUpdateOne) {
  32985. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32986. }
  32987. if m.id == nil || m.oldValue == nil {
  32988. return v, errors.New("OldType requires an ID field in the mutation")
  32989. }
  32990. oldValue, err := m.oldValue(ctx)
  32991. if err != nil {
  32992. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32993. }
  32994. return oldValue.Type, nil
  32995. }
  32996. // AddType adds i to the "type" field.
  32997. func (m *UsageTotalMutation) AddType(i int) {
  32998. if m.add_type != nil {
  32999. *m.add_type += i
  33000. } else {
  33001. m.add_type = &i
  33002. }
  33003. }
  33004. // AddedType returns the value that was added to the "type" field in this mutation.
  33005. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33006. v := m.add_type
  33007. if v == nil {
  33008. return
  33009. }
  33010. return *v, true
  33011. }
  33012. // ClearType clears the value of the "type" field.
  33013. func (m *UsageTotalMutation) ClearType() {
  33014. m._type = nil
  33015. m.add_type = nil
  33016. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33017. }
  33018. // TypeCleared returns if the "type" field was cleared in this mutation.
  33019. func (m *UsageTotalMutation) TypeCleared() bool {
  33020. _, ok := m.clearedFields[usagetotal.FieldType]
  33021. return ok
  33022. }
  33023. // ResetType resets all changes to the "type" field.
  33024. func (m *UsageTotalMutation) ResetType() {
  33025. m._type = nil
  33026. m.add_type = nil
  33027. delete(m.clearedFields, usagetotal.FieldType)
  33028. }
  33029. // SetBotID sets the "bot_id" field.
  33030. func (m *UsageTotalMutation) SetBotID(s string) {
  33031. m.bot_id = &s
  33032. }
  33033. // BotID returns the value of the "bot_id" field in the mutation.
  33034. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33035. v := m.bot_id
  33036. if v == nil {
  33037. return
  33038. }
  33039. return *v, true
  33040. }
  33041. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33042. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33044. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33045. if !m.op.Is(OpUpdateOne) {
  33046. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33047. }
  33048. if m.id == nil || m.oldValue == nil {
  33049. return v, errors.New("OldBotID requires an ID field in the mutation")
  33050. }
  33051. oldValue, err := m.oldValue(ctx)
  33052. if err != nil {
  33053. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33054. }
  33055. return oldValue.BotID, nil
  33056. }
  33057. // ResetBotID resets all changes to the "bot_id" field.
  33058. func (m *UsageTotalMutation) ResetBotID() {
  33059. m.bot_id = nil
  33060. }
  33061. // SetTotalTokens sets the "total_tokens" field.
  33062. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33063. m.total_tokens = &u
  33064. m.addtotal_tokens = nil
  33065. }
  33066. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33067. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33068. v := m.total_tokens
  33069. if v == nil {
  33070. return
  33071. }
  33072. return *v, true
  33073. }
  33074. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33075. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33077. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33078. if !m.op.Is(OpUpdateOne) {
  33079. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33080. }
  33081. if m.id == nil || m.oldValue == nil {
  33082. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33083. }
  33084. oldValue, err := m.oldValue(ctx)
  33085. if err != nil {
  33086. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33087. }
  33088. return oldValue.TotalTokens, nil
  33089. }
  33090. // AddTotalTokens adds u to the "total_tokens" field.
  33091. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33092. if m.addtotal_tokens != nil {
  33093. *m.addtotal_tokens += u
  33094. } else {
  33095. m.addtotal_tokens = &u
  33096. }
  33097. }
  33098. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33099. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33100. v := m.addtotal_tokens
  33101. if v == nil {
  33102. return
  33103. }
  33104. return *v, true
  33105. }
  33106. // ClearTotalTokens clears the value of the "total_tokens" field.
  33107. func (m *UsageTotalMutation) ClearTotalTokens() {
  33108. m.total_tokens = nil
  33109. m.addtotal_tokens = nil
  33110. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33111. }
  33112. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33113. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33114. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33115. return ok
  33116. }
  33117. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33118. func (m *UsageTotalMutation) ResetTotalTokens() {
  33119. m.total_tokens = nil
  33120. m.addtotal_tokens = nil
  33121. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33122. }
  33123. // SetStartIndex sets the "start_index" field.
  33124. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33125. m.start_index = &u
  33126. m.addstart_index = nil
  33127. }
  33128. // StartIndex returns the value of the "start_index" field in the mutation.
  33129. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33130. v := m.start_index
  33131. if v == nil {
  33132. return
  33133. }
  33134. return *v, true
  33135. }
  33136. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33137. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33139. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33140. if !m.op.Is(OpUpdateOne) {
  33141. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33142. }
  33143. if m.id == nil || m.oldValue == nil {
  33144. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33145. }
  33146. oldValue, err := m.oldValue(ctx)
  33147. if err != nil {
  33148. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33149. }
  33150. return oldValue.StartIndex, nil
  33151. }
  33152. // AddStartIndex adds u to the "start_index" field.
  33153. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33154. if m.addstart_index != nil {
  33155. *m.addstart_index += u
  33156. } else {
  33157. m.addstart_index = &u
  33158. }
  33159. }
  33160. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33161. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33162. v := m.addstart_index
  33163. if v == nil {
  33164. return
  33165. }
  33166. return *v, true
  33167. }
  33168. // ClearStartIndex clears the value of the "start_index" field.
  33169. func (m *UsageTotalMutation) ClearStartIndex() {
  33170. m.start_index = nil
  33171. m.addstart_index = nil
  33172. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33173. }
  33174. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33175. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33176. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33177. return ok
  33178. }
  33179. // ResetStartIndex resets all changes to the "start_index" field.
  33180. func (m *UsageTotalMutation) ResetStartIndex() {
  33181. m.start_index = nil
  33182. m.addstart_index = nil
  33183. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33184. }
  33185. // SetEndIndex sets the "end_index" field.
  33186. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33187. m.end_index = &u
  33188. m.addend_index = nil
  33189. }
  33190. // EndIndex returns the value of the "end_index" field in the mutation.
  33191. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33192. v := m.end_index
  33193. if v == nil {
  33194. return
  33195. }
  33196. return *v, true
  33197. }
  33198. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33199. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33201. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33202. if !m.op.Is(OpUpdateOne) {
  33203. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33204. }
  33205. if m.id == nil || m.oldValue == nil {
  33206. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33207. }
  33208. oldValue, err := m.oldValue(ctx)
  33209. if err != nil {
  33210. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33211. }
  33212. return oldValue.EndIndex, nil
  33213. }
  33214. // AddEndIndex adds u to the "end_index" field.
  33215. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33216. if m.addend_index != nil {
  33217. *m.addend_index += u
  33218. } else {
  33219. m.addend_index = &u
  33220. }
  33221. }
  33222. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33223. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33224. v := m.addend_index
  33225. if v == nil {
  33226. return
  33227. }
  33228. return *v, true
  33229. }
  33230. // ClearEndIndex clears the value of the "end_index" field.
  33231. func (m *UsageTotalMutation) ClearEndIndex() {
  33232. m.end_index = nil
  33233. m.addend_index = nil
  33234. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33235. }
  33236. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33237. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33238. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33239. return ok
  33240. }
  33241. // ResetEndIndex resets all changes to the "end_index" field.
  33242. func (m *UsageTotalMutation) ResetEndIndex() {
  33243. m.end_index = nil
  33244. m.addend_index = nil
  33245. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33246. }
  33247. // SetOrganizationID sets the "organization_id" field.
  33248. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33249. m.organization_id = &u
  33250. m.addorganization_id = nil
  33251. }
  33252. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33253. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33254. v := m.organization_id
  33255. if v == nil {
  33256. return
  33257. }
  33258. return *v, true
  33259. }
  33260. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33261. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33263. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33264. if !m.op.Is(OpUpdateOne) {
  33265. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33266. }
  33267. if m.id == nil || m.oldValue == nil {
  33268. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33269. }
  33270. oldValue, err := m.oldValue(ctx)
  33271. if err != nil {
  33272. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33273. }
  33274. return oldValue.OrganizationID, nil
  33275. }
  33276. // AddOrganizationID adds u to the "organization_id" field.
  33277. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33278. if m.addorganization_id != nil {
  33279. *m.addorganization_id += u
  33280. } else {
  33281. m.addorganization_id = &u
  33282. }
  33283. }
  33284. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33285. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33286. v := m.addorganization_id
  33287. if v == nil {
  33288. return
  33289. }
  33290. return *v, true
  33291. }
  33292. // ClearOrganizationID clears the value of the "organization_id" field.
  33293. func (m *UsageTotalMutation) ClearOrganizationID() {
  33294. m.organization_id = nil
  33295. m.addorganization_id = nil
  33296. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33297. }
  33298. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33299. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33300. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33301. return ok
  33302. }
  33303. // ResetOrganizationID resets all changes to the "organization_id" field.
  33304. func (m *UsageTotalMutation) ResetOrganizationID() {
  33305. m.organization_id = nil
  33306. m.addorganization_id = nil
  33307. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33308. }
  33309. // Where appends a list predicates to the UsageTotalMutation builder.
  33310. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33311. m.predicates = append(m.predicates, ps...)
  33312. }
  33313. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33314. // users can use type-assertion to append predicates that do not depend on any generated package.
  33315. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33316. p := make([]predicate.UsageTotal, len(ps))
  33317. for i := range ps {
  33318. p[i] = ps[i]
  33319. }
  33320. m.Where(p...)
  33321. }
  33322. // Op returns the operation name.
  33323. func (m *UsageTotalMutation) Op() Op {
  33324. return m.op
  33325. }
  33326. // SetOp allows setting the mutation operation.
  33327. func (m *UsageTotalMutation) SetOp(op Op) {
  33328. m.op = op
  33329. }
  33330. // Type returns the node type of this mutation (UsageTotal).
  33331. func (m *UsageTotalMutation) Type() string {
  33332. return m.typ
  33333. }
  33334. // Fields returns all fields that were changed during this mutation. Note that in
  33335. // order to get all numeric fields that were incremented/decremented, call
  33336. // AddedFields().
  33337. func (m *UsageTotalMutation) Fields() []string {
  33338. fields := make([]string, 0, 9)
  33339. if m.created_at != nil {
  33340. fields = append(fields, usagetotal.FieldCreatedAt)
  33341. }
  33342. if m.updated_at != nil {
  33343. fields = append(fields, usagetotal.FieldUpdatedAt)
  33344. }
  33345. if m.status != nil {
  33346. fields = append(fields, usagetotal.FieldStatus)
  33347. }
  33348. if m._type != nil {
  33349. fields = append(fields, usagetotal.FieldType)
  33350. }
  33351. if m.bot_id != nil {
  33352. fields = append(fields, usagetotal.FieldBotID)
  33353. }
  33354. if m.total_tokens != nil {
  33355. fields = append(fields, usagetotal.FieldTotalTokens)
  33356. }
  33357. if m.start_index != nil {
  33358. fields = append(fields, usagetotal.FieldStartIndex)
  33359. }
  33360. if m.end_index != nil {
  33361. fields = append(fields, usagetotal.FieldEndIndex)
  33362. }
  33363. if m.organization_id != nil {
  33364. fields = append(fields, usagetotal.FieldOrganizationID)
  33365. }
  33366. return fields
  33367. }
  33368. // Field returns the value of a field with the given name. The second boolean
  33369. // return value indicates that this field was not set, or was not defined in the
  33370. // schema.
  33371. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33372. switch name {
  33373. case usagetotal.FieldCreatedAt:
  33374. return m.CreatedAt()
  33375. case usagetotal.FieldUpdatedAt:
  33376. return m.UpdatedAt()
  33377. case usagetotal.FieldStatus:
  33378. return m.Status()
  33379. case usagetotal.FieldType:
  33380. return m.GetType()
  33381. case usagetotal.FieldBotID:
  33382. return m.BotID()
  33383. case usagetotal.FieldTotalTokens:
  33384. return m.TotalTokens()
  33385. case usagetotal.FieldStartIndex:
  33386. return m.StartIndex()
  33387. case usagetotal.FieldEndIndex:
  33388. return m.EndIndex()
  33389. case usagetotal.FieldOrganizationID:
  33390. return m.OrganizationID()
  33391. }
  33392. return nil, false
  33393. }
  33394. // OldField returns the old value of the field from the database. An error is
  33395. // returned if the mutation operation is not UpdateOne, or the query to the
  33396. // database failed.
  33397. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33398. switch name {
  33399. case usagetotal.FieldCreatedAt:
  33400. return m.OldCreatedAt(ctx)
  33401. case usagetotal.FieldUpdatedAt:
  33402. return m.OldUpdatedAt(ctx)
  33403. case usagetotal.FieldStatus:
  33404. return m.OldStatus(ctx)
  33405. case usagetotal.FieldType:
  33406. return m.OldType(ctx)
  33407. case usagetotal.FieldBotID:
  33408. return m.OldBotID(ctx)
  33409. case usagetotal.FieldTotalTokens:
  33410. return m.OldTotalTokens(ctx)
  33411. case usagetotal.FieldStartIndex:
  33412. return m.OldStartIndex(ctx)
  33413. case usagetotal.FieldEndIndex:
  33414. return m.OldEndIndex(ctx)
  33415. case usagetotal.FieldOrganizationID:
  33416. return m.OldOrganizationID(ctx)
  33417. }
  33418. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33419. }
  33420. // SetField sets the value of a field with the given name. It returns an error if
  33421. // the field is not defined in the schema, or if the type mismatched the field
  33422. // type.
  33423. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33424. switch name {
  33425. case usagetotal.FieldCreatedAt:
  33426. v, ok := value.(time.Time)
  33427. if !ok {
  33428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33429. }
  33430. m.SetCreatedAt(v)
  33431. return nil
  33432. case usagetotal.FieldUpdatedAt:
  33433. v, ok := value.(time.Time)
  33434. if !ok {
  33435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33436. }
  33437. m.SetUpdatedAt(v)
  33438. return nil
  33439. case usagetotal.FieldStatus:
  33440. v, ok := value.(uint8)
  33441. if !ok {
  33442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33443. }
  33444. m.SetStatus(v)
  33445. return nil
  33446. case usagetotal.FieldType:
  33447. v, ok := value.(int)
  33448. if !ok {
  33449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33450. }
  33451. m.SetType(v)
  33452. return nil
  33453. case usagetotal.FieldBotID:
  33454. v, ok := value.(string)
  33455. if !ok {
  33456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33457. }
  33458. m.SetBotID(v)
  33459. return nil
  33460. case usagetotal.FieldTotalTokens:
  33461. v, ok := value.(uint64)
  33462. if !ok {
  33463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33464. }
  33465. m.SetTotalTokens(v)
  33466. return nil
  33467. case usagetotal.FieldStartIndex:
  33468. v, ok := value.(uint64)
  33469. if !ok {
  33470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33471. }
  33472. m.SetStartIndex(v)
  33473. return nil
  33474. case usagetotal.FieldEndIndex:
  33475. v, ok := value.(uint64)
  33476. if !ok {
  33477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33478. }
  33479. m.SetEndIndex(v)
  33480. return nil
  33481. case usagetotal.FieldOrganizationID:
  33482. v, ok := value.(uint64)
  33483. if !ok {
  33484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33485. }
  33486. m.SetOrganizationID(v)
  33487. return nil
  33488. }
  33489. return fmt.Errorf("unknown UsageTotal field %s", name)
  33490. }
  33491. // AddedFields returns all numeric fields that were incremented/decremented during
  33492. // this mutation.
  33493. func (m *UsageTotalMutation) AddedFields() []string {
  33494. var fields []string
  33495. if m.addstatus != nil {
  33496. fields = append(fields, usagetotal.FieldStatus)
  33497. }
  33498. if m.add_type != nil {
  33499. fields = append(fields, usagetotal.FieldType)
  33500. }
  33501. if m.addtotal_tokens != nil {
  33502. fields = append(fields, usagetotal.FieldTotalTokens)
  33503. }
  33504. if m.addstart_index != nil {
  33505. fields = append(fields, usagetotal.FieldStartIndex)
  33506. }
  33507. if m.addend_index != nil {
  33508. fields = append(fields, usagetotal.FieldEndIndex)
  33509. }
  33510. if m.addorganization_id != nil {
  33511. fields = append(fields, usagetotal.FieldOrganizationID)
  33512. }
  33513. return fields
  33514. }
  33515. // AddedField returns the numeric value that was incremented/decremented on a field
  33516. // with the given name. The second boolean return value indicates that this field
  33517. // was not set, or was not defined in the schema.
  33518. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33519. switch name {
  33520. case usagetotal.FieldStatus:
  33521. return m.AddedStatus()
  33522. case usagetotal.FieldType:
  33523. return m.AddedType()
  33524. case usagetotal.FieldTotalTokens:
  33525. return m.AddedTotalTokens()
  33526. case usagetotal.FieldStartIndex:
  33527. return m.AddedStartIndex()
  33528. case usagetotal.FieldEndIndex:
  33529. return m.AddedEndIndex()
  33530. case usagetotal.FieldOrganizationID:
  33531. return m.AddedOrganizationID()
  33532. }
  33533. return nil, false
  33534. }
  33535. // AddField adds the value to the field with the given name. It returns an error if
  33536. // the field is not defined in the schema, or if the type mismatched the field
  33537. // type.
  33538. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33539. switch name {
  33540. case usagetotal.FieldStatus:
  33541. v, ok := value.(int8)
  33542. if !ok {
  33543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33544. }
  33545. m.AddStatus(v)
  33546. return nil
  33547. case usagetotal.FieldType:
  33548. v, ok := value.(int)
  33549. if !ok {
  33550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33551. }
  33552. m.AddType(v)
  33553. return nil
  33554. case usagetotal.FieldTotalTokens:
  33555. v, ok := value.(int64)
  33556. if !ok {
  33557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33558. }
  33559. m.AddTotalTokens(v)
  33560. return nil
  33561. case usagetotal.FieldStartIndex:
  33562. v, ok := value.(int64)
  33563. if !ok {
  33564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33565. }
  33566. m.AddStartIndex(v)
  33567. return nil
  33568. case usagetotal.FieldEndIndex:
  33569. v, ok := value.(int64)
  33570. if !ok {
  33571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33572. }
  33573. m.AddEndIndex(v)
  33574. return nil
  33575. case usagetotal.FieldOrganizationID:
  33576. v, ok := value.(int64)
  33577. if !ok {
  33578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33579. }
  33580. m.AddOrganizationID(v)
  33581. return nil
  33582. }
  33583. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33584. }
  33585. // ClearedFields returns all nullable fields that were cleared during this
  33586. // mutation.
  33587. func (m *UsageTotalMutation) ClearedFields() []string {
  33588. var fields []string
  33589. if m.FieldCleared(usagetotal.FieldStatus) {
  33590. fields = append(fields, usagetotal.FieldStatus)
  33591. }
  33592. if m.FieldCleared(usagetotal.FieldType) {
  33593. fields = append(fields, usagetotal.FieldType)
  33594. }
  33595. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33596. fields = append(fields, usagetotal.FieldTotalTokens)
  33597. }
  33598. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33599. fields = append(fields, usagetotal.FieldStartIndex)
  33600. }
  33601. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33602. fields = append(fields, usagetotal.FieldEndIndex)
  33603. }
  33604. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33605. fields = append(fields, usagetotal.FieldOrganizationID)
  33606. }
  33607. return fields
  33608. }
  33609. // FieldCleared returns a boolean indicating if a field with the given name was
  33610. // cleared in this mutation.
  33611. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33612. _, ok := m.clearedFields[name]
  33613. return ok
  33614. }
  33615. // ClearField clears the value of the field with the given name. It returns an
  33616. // error if the field is not defined in the schema.
  33617. func (m *UsageTotalMutation) ClearField(name string) error {
  33618. switch name {
  33619. case usagetotal.FieldStatus:
  33620. m.ClearStatus()
  33621. return nil
  33622. case usagetotal.FieldType:
  33623. m.ClearType()
  33624. return nil
  33625. case usagetotal.FieldTotalTokens:
  33626. m.ClearTotalTokens()
  33627. return nil
  33628. case usagetotal.FieldStartIndex:
  33629. m.ClearStartIndex()
  33630. return nil
  33631. case usagetotal.FieldEndIndex:
  33632. m.ClearEndIndex()
  33633. return nil
  33634. case usagetotal.FieldOrganizationID:
  33635. m.ClearOrganizationID()
  33636. return nil
  33637. }
  33638. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33639. }
  33640. // ResetField resets all changes in the mutation for the field with the given name.
  33641. // It returns an error if the field is not defined in the schema.
  33642. func (m *UsageTotalMutation) ResetField(name string) error {
  33643. switch name {
  33644. case usagetotal.FieldCreatedAt:
  33645. m.ResetCreatedAt()
  33646. return nil
  33647. case usagetotal.FieldUpdatedAt:
  33648. m.ResetUpdatedAt()
  33649. return nil
  33650. case usagetotal.FieldStatus:
  33651. m.ResetStatus()
  33652. return nil
  33653. case usagetotal.FieldType:
  33654. m.ResetType()
  33655. return nil
  33656. case usagetotal.FieldBotID:
  33657. m.ResetBotID()
  33658. return nil
  33659. case usagetotal.FieldTotalTokens:
  33660. m.ResetTotalTokens()
  33661. return nil
  33662. case usagetotal.FieldStartIndex:
  33663. m.ResetStartIndex()
  33664. return nil
  33665. case usagetotal.FieldEndIndex:
  33666. m.ResetEndIndex()
  33667. return nil
  33668. case usagetotal.FieldOrganizationID:
  33669. m.ResetOrganizationID()
  33670. return nil
  33671. }
  33672. return fmt.Errorf("unknown UsageTotal field %s", name)
  33673. }
  33674. // AddedEdges returns all edge names that were set/added in this mutation.
  33675. func (m *UsageTotalMutation) AddedEdges() []string {
  33676. edges := make([]string, 0, 0)
  33677. return edges
  33678. }
  33679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33680. // name in this mutation.
  33681. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33682. return nil
  33683. }
  33684. // RemovedEdges returns all edge names that were removed in this mutation.
  33685. func (m *UsageTotalMutation) RemovedEdges() []string {
  33686. edges := make([]string, 0, 0)
  33687. return edges
  33688. }
  33689. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33690. // the given name in this mutation.
  33691. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33692. return nil
  33693. }
  33694. // ClearedEdges returns all edge names that were cleared in this mutation.
  33695. func (m *UsageTotalMutation) ClearedEdges() []string {
  33696. edges := make([]string, 0, 0)
  33697. return edges
  33698. }
  33699. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33700. // was cleared in this mutation.
  33701. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33702. return false
  33703. }
  33704. // ClearEdge clears the value of the edge with the given name. It returns an error
  33705. // if that edge is not defined in the schema.
  33706. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33707. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33708. }
  33709. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33710. // It returns an error if the edge is not defined in the schema.
  33711. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33712. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33713. }
  33714. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33715. type WhatsappMutation struct {
  33716. config
  33717. op Op
  33718. typ string
  33719. id *uint64
  33720. created_at *time.Time
  33721. updated_at *time.Time
  33722. status *uint8
  33723. addstatus *int8
  33724. deleted_at *time.Time
  33725. ak *string
  33726. sk *string
  33727. callback *string
  33728. account *string
  33729. nickname *string
  33730. phone *string
  33731. organization_id *uint64
  33732. addorganization_id *int64
  33733. api_base *string
  33734. api_key *string
  33735. allow_list *[]string
  33736. appendallow_list []string
  33737. group_allow_list *[]string
  33738. appendgroup_allow_list []string
  33739. block_list *[]string
  33740. appendblock_list []string
  33741. group_block_list *[]string
  33742. appendgroup_block_list []string
  33743. clearedFields map[string]struct{}
  33744. agent *uint64
  33745. clearedagent bool
  33746. done bool
  33747. oldValue func(context.Context) (*Whatsapp, error)
  33748. predicates []predicate.Whatsapp
  33749. }
  33750. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33751. // whatsappOption allows management of the mutation configuration using functional options.
  33752. type whatsappOption func(*WhatsappMutation)
  33753. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33754. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33755. m := &WhatsappMutation{
  33756. config: c,
  33757. op: op,
  33758. typ: TypeWhatsapp,
  33759. clearedFields: make(map[string]struct{}),
  33760. }
  33761. for _, opt := range opts {
  33762. opt(m)
  33763. }
  33764. return m
  33765. }
  33766. // withWhatsappID sets the ID field of the mutation.
  33767. func withWhatsappID(id uint64) whatsappOption {
  33768. return func(m *WhatsappMutation) {
  33769. var (
  33770. err error
  33771. once sync.Once
  33772. value *Whatsapp
  33773. )
  33774. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33775. once.Do(func() {
  33776. if m.done {
  33777. err = errors.New("querying old values post mutation is not allowed")
  33778. } else {
  33779. value, err = m.Client().Whatsapp.Get(ctx, id)
  33780. }
  33781. })
  33782. return value, err
  33783. }
  33784. m.id = &id
  33785. }
  33786. }
  33787. // withWhatsapp sets the old Whatsapp of the mutation.
  33788. func withWhatsapp(node *Whatsapp) whatsappOption {
  33789. return func(m *WhatsappMutation) {
  33790. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33791. return node, nil
  33792. }
  33793. m.id = &node.ID
  33794. }
  33795. }
  33796. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33797. // executed in a transaction (ent.Tx), a transactional client is returned.
  33798. func (m WhatsappMutation) Client() *Client {
  33799. client := &Client{config: m.config}
  33800. client.init()
  33801. return client
  33802. }
  33803. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33804. // it returns an error otherwise.
  33805. func (m WhatsappMutation) Tx() (*Tx, error) {
  33806. if _, ok := m.driver.(*txDriver); !ok {
  33807. return nil, errors.New("ent: mutation is not running in a transaction")
  33808. }
  33809. tx := &Tx{config: m.config}
  33810. tx.init()
  33811. return tx, nil
  33812. }
  33813. // SetID sets the value of the id field. Note that this
  33814. // operation is only accepted on creation of Whatsapp entities.
  33815. func (m *WhatsappMutation) SetID(id uint64) {
  33816. m.id = &id
  33817. }
  33818. // ID returns the ID value in the mutation. Note that the ID is only available
  33819. // if it was provided to the builder or after it was returned from the database.
  33820. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33821. if m.id == nil {
  33822. return
  33823. }
  33824. return *m.id, true
  33825. }
  33826. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33827. // That means, if the mutation is applied within a transaction with an isolation level such
  33828. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33829. // or updated by the mutation.
  33830. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33831. switch {
  33832. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33833. id, exists := m.ID()
  33834. if exists {
  33835. return []uint64{id}, nil
  33836. }
  33837. fallthrough
  33838. case m.op.Is(OpUpdate | OpDelete):
  33839. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33840. default:
  33841. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33842. }
  33843. }
  33844. // SetCreatedAt sets the "created_at" field.
  33845. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33846. m.created_at = &t
  33847. }
  33848. // CreatedAt returns the value of the "created_at" field in the mutation.
  33849. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33850. v := m.created_at
  33851. if v == nil {
  33852. return
  33853. }
  33854. return *v, true
  33855. }
  33856. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33857. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33859. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33860. if !m.op.Is(OpUpdateOne) {
  33861. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33862. }
  33863. if m.id == nil || m.oldValue == nil {
  33864. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33865. }
  33866. oldValue, err := m.oldValue(ctx)
  33867. if err != nil {
  33868. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33869. }
  33870. return oldValue.CreatedAt, nil
  33871. }
  33872. // ResetCreatedAt resets all changes to the "created_at" field.
  33873. func (m *WhatsappMutation) ResetCreatedAt() {
  33874. m.created_at = nil
  33875. }
  33876. // SetUpdatedAt sets the "updated_at" field.
  33877. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33878. m.updated_at = &t
  33879. }
  33880. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33881. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33882. v := m.updated_at
  33883. if v == nil {
  33884. return
  33885. }
  33886. return *v, true
  33887. }
  33888. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33889. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33891. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33892. if !m.op.Is(OpUpdateOne) {
  33893. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33894. }
  33895. if m.id == nil || m.oldValue == nil {
  33896. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33897. }
  33898. oldValue, err := m.oldValue(ctx)
  33899. if err != nil {
  33900. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33901. }
  33902. return oldValue.UpdatedAt, nil
  33903. }
  33904. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33905. func (m *WhatsappMutation) ResetUpdatedAt() {
  33906. m.updated_at = nil
  33907. }
  33908. // SetStatus sets the "status" field.
  33909. func (m *WhatsappMutation) SetStatus(u uint8) {
  33910. m.status = &u
  33911. m.addstatus = nil
  33912. }
  33913. // Status returns the value of the "status" field in the mutation.
  33914. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33915. v := m.status
  33916. if v == nil {
  33917. return
  33918. }
  33919. return *v, true
  33920. }
  33921. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33922. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33924. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33925. if !m.op.Is(OpUpdateOne) {
  33926. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33927. }
  33928. if m.id == nil || m.oldValue == nil {
  33929. return v, errors.New("OldStatus requires an ID field in the mutation")
  33930. }
  33931. oldValue, err := m.oldValue(ctx)
  33932. if err != nil {
  33933. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33934. }
  33935. return oldValue.Status, nil
  33936. }
  33937. // AddStatus adds u to the "status" field.
  33938. func (m *WhatsappMutation) AddStatus(u int8) {
  33939. if m.addstatus != nil {
  33940. *m.addstatus += u
  33941. } else {
  33942. m.addstatus = &u
  33943. }
  33944. }
  33945. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33946. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33947. v := m.addstatus
  33948. if v == nil {
  33949. return
  33950. }
  33951. return *v, true
  33952. }
  33953. // ClearStatus clears the value of the "status" field.
  33954. func (m *WhatsappMutation) ClearStatus() {
  33955. m.status = nil
  33956. m.addstatus = nil
  33957. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33958. }
  33959. // StatusCleared returns if the "status" field was cleared in this mutation.
  33960. func (m *WhatsappMutation) StatusCleared() bool {
  33961. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33962. return ok
  33963. }
  33964. // ResetStatus resets all changes to the "status" field.
  33965. func (m *WhatsappMutation) ResetStatus() {
  33966. m.status = nil
  33967. m.addstatus = nil
  33968. delete(m.clearedFields, whatsapp.FieldStatus)
  33969. }
  33970. // SetDeletedAt sets the "deleted_at" field.
  33971. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33972. m.deleted_at = &t
  33973. }
  33974. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33975. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33976. v := m.deleted_at
  33977. if v == nil {
  33978. return
  33979. }
  33980. return *v, true
  33981. }
  33982. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  33983. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33985. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33986. if !m.op.Is(OpUpdateOne) {
  33987. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33988. }
  33989. if m.id == nil || m.oldValue == nil {
  33990. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33991. }
  33992. oldValue, err := m.oldValue(ctx)
  33993. if err != nil {
  33994. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33995. }
  33996. return oldValue.DeletedAt, nil
  33997. }
  33998. // ClearDeletedAt clears the value of the "deleted_at" field.
  33999. func (m *WhatsappMutation) ClearDeletedAt() {
  34000. m.deleted_at = nil
  34001. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34002. }
  34003. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34004. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34005. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34006. return ok
  34007. }
  34008. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34009. func (m *WhatsappMutation) ResetDeletedAt() {
  34010. m.deleted_at = nil
  34011. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34012. }
  34013. // SetAk sets the "ak" field.
  34014. func (m *WhatsappMutation) SetAk(s string) {
  34015. m.ak = &s
  34016. }
  34017. // Ak returns the value of the "ak" field in the mutation.
  34018. func (m *WhatsappMutation) Ak() (r string, exists bool) {
  34019. v := m.ak
  34020. if v == nil {
  34021. return
  34022. }
  34023. return *v, true
  34024. }
  34025. // OldAk returns the old "ak" field's value of the Whatsapp entity.
  34026. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34028. func (m *WhatsappMutation) OldAk(ctx context.Context) (v string, err error) {
  34029. if !m.op.Is(OpUpdateOne) {
  34030. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  34031. }
  34032. if m.id == nil || m.oldValue == nil {
  34033. return v, errors.New("OldAk requires an ID field in the mutation")
  34034. }
  34035. oldValue, err := m.oldValue(ctx)
  34036. if err != nil {
  34037. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  34038. }
  34039. return oldValue.Ak, nil
  34040. }
  34041. // ClearAk clears the value of the "ak" field.
  34042. func (m *WhatsappMutation) ClearAk() {
  34043. m.ak = nil
  34044. m.clearedFields[whatsapp.FieldAk] = struct{}{}
  34045. }
  34046. // AkCleared returns if the "ak" field was cleared in this mutation.
  34047. func (m *WhatsappMutation) AkCleared() bool {
  34048. _, ok := m.clearedFields[whatsapp.FieldAk]
  34049. return ok
  34050. }
  34051. // ResetAk resets all changes to the "ak" field.
  34052. func (m *WhatsappMutation) ResetAk() {
  34053. m.ak = nil
  34054. delete(m.clearedFields, whatsapp.FieldAk)
  34055. }
  34056. // SetSk sets the "sk" field.
  34057. func (m *WhatsappMutation) SetSk(s string) {
  34058. m.sk = &s
  34059. }
  34060. // Sk returns the value of the "sk" field in the mutation.
  34061. func (m *WhatsappMutation) Sk() (r string, exists bool) {
  34062. v := m.sk
  34063. if v == nil {
  34064. return
  34065. }
  34066. return *v, true
  34067. }
  34068. // OldSk returns the old "sk" field's value of the Whatsapp entity.
  34069. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34071. func (m *WhatsappMutation) OldSk(ctx context.Context) (v string, err error) {
  34072. if !m.op.Is(OpUpdateOne) {
  34073. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  34074. }
  34075. if m.id == nil || m.oldValue == nil {
  34076. return v, errors.New("OldSk requires an ID field in the mutation")
  34077. }
  34078. oldValue, err := m.oldValue(ctx)
  34079. if err != nil {
  34080. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  34081. }
  34082. return oldValue.Sk, nil
  34083. }
  34084. // ResetSk resets all changes to the "sk" field.
  34085. func (m *WhatsappMutation) ResetSk() {
  34086. m.sk = nil
  34087. }
  34088. // SetCallback sets the "callback" field.
  34089. func (m *WhatsappMutation) SetCallback(s string) {
  34090. m.callback = &s
  34091. }
  34092. // Callback returns the value of the "callback" field in the mutation.
  34093. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34094. v := m.callback
  34095. if v == nil {
  34096. return
  34097. }
  34098. return *v, true
  34099. }
  34100. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34101. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34103. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34104. if !m.op.Is(OpUpdateOne) {
  34105. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34106. }
  34107. if m.id == nil || m.oldValue == nil {
  34108. return v, errors.New("OldCallback requires an ID field in the mutation")
  34109. }
  34110. oldValue, err := m.oldValue(ctx)
  34111. if err != nil {
  34112. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34113. }
  34114. return oldValue.Callback, nil
  34115. }
  34116. // ResetCallback resets all changes to the "callback" field.
  34117. func (m *WhatsappMutation) ResetCallback() {
  34118. m.callback = nil
  34119. }
  34120. // SetAccount sets the "account" field.
  34121. func (m *WhatsappMutation) SetAccount(s string) {
  34122. m.account = &s
  34123. }
  34124. // Account returns the value of the "account" field in the mutation.
  34125. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34126. v := m.account
  34127. if v == nil {
  34128. return
  34129. }
  34130. return *v, true
  34131. }
  34132. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34133. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34135. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34136. if !m.op.Is(OpUpdateOne) {
  34137. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34138. }
  34139. if m.id == nil || m.oldValue == nil {
  34140. return v, errors.New("OldAccount requires an ID field in the mutation")
  34141. }
  34142. oldValue, err := m.oldValue(ctx)
  34143. if err != nil {
  34144. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34145. }
  34146. return oldValue.Account, nil
  34147. }
  34148. // ResetAccount resets all changes to the "account" field.
  34149. func (m *WhatsappMutation) ResetAccount() {
  34150. m.account = nil
  34151. }
  34152. // SetNickname sets the "nickname" field.
  34153. func (m *WhatsappMutation) SetNickname(s string) {
  34154. m.nickname = &s
  34155. }
  34156. // Nickname returns the value of the "nickname" field in the mutation.
  34157. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34158. v := m.nickname
  34159. if v == nil {
  34160. return
  34161. }
  34162. return *v, true
  34163. }
  34164. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34165. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34167. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34168. if !m.op.Is(OpUpdateOne) {
  34169. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34170. }
  34171. if m.id == nil || m.oldValue == nil {
  34172. return v, errors.New("OldNickname requires an ID field in the mutation")
  34173. }
  34174. oldValue, err := m.oldValue(ctx)
  34175. if err != nil {
  34176. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34177. }
  34178. return oldValue.Nickname, nil
  34179. }
  34180. // ResetNickname resets all changes to the "nickname" field.
  34181. func (m *WhatsappMutation) ResetNickname() {
  34182. m.nickname = nil
  34183. }
  34184. // SetPhone sets the "phone" field.
  34185. func (m *WhatsappMutation) SetPhone(s string) {
  34186. m.phone = &s
  34187. }
  34188. // Phone returns the value of the "phone" field in the mutation.
  34189. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34190. v := m.phone
  34191. if v == nil {
  34192. return
  34193. }
  34194. return *v, true
  34195. }
  34196. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34197. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34199. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34200. if !m.op.Is(OpUpdateOne) {
  34201. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34202. }
  34203. if m.id == nil || m.oldValue == nil {
  34204. return v, errors.New("OldPhone requires an ID field in the mutation")
  34205. }
  34206. oldValue, err := m.oldValue(ctx)
  34207. if err != nil {
  34208. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34209. }
  34210. return oldValue.Phone, nil
  34211. }
  34212. // ResetPhone resets all changes to the "phone" field.
  34213. func (m *WhatsappMutation) ResetPhone() {
  34214. m.phone = nil
  34215. }
  34216. // SetOrganizationID sets the "organization_id" field.
  34217. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34218. m.organization_id = &u
  34219. m.addorganization_id = nil
  34220. }
  34221. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34222. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34223. v := m.organization_id
  34224. if v == nil {
  34225. return
  34226. }
  34227. return *v, true
  34228. }
  34229. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34230. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34232. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34233. if !m.op.Is(OpUpdateOne) {
  34234. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34235. }
  34236. if m.id == nil || m.oldValue == nil {
  34237. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34238. }
  34239. oldValue, err := m.oldValue(ctx)
  34240. if err != nil {
  34241. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34242. }
  34243. return oldValue.OrganizationID, nil
  34244. }
  34245. // AddOrganizationID adds u to the "organization_id" field.
  34246. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34247. if m.addorganization_id != nil {
  34248. *m.addorganization_id += u
  34249. } else {
  34250. m.addorganization_id = &u
  34251. }
  34252. }
  34253. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34254. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34255. v := m.addorganization_id
  34256. if v == nil {
  34257. return
  34258. }
  34259. return *v, true
  34260. }
  34261. // ClearOrganizationID clears the value of the "organization_id" field.
  34262. func (m *WhatsappMutation) ClearOrganizationID() {
  34263. m.organization_id = nil
  34264. m.addorganization_id = nil
  34265. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34266. }
  34267. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34268. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34269. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34270. return ok
  34271. }
  34272. // ResetOrganizationID resets all changes to the "organization_id" field.
  34273. func (m *WhatsappMutation) ResetOrganizationID() {
  34274. m.organization_id = nil
  34275. m.addorganization_id = nil
  34276. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34277. }
  34278. // SetAgentID sets the "agent_id" field.
  34279. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34280. m.agent = &u
  34281. }
  34282. // AgentID returns the value of the "agent_id" field in the mutation.
  34283. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34284. v := m.agent
  34285. if v == nil {
  34286. return
  34287. }
  34288. return *v, true
  34289. }
  34290. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34291. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34293. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34294. if !m.op.Is(OpUpdateOne) {
  34295. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34296. }
  34297. if m.id == nil || m.oldValue == nil {
  34298. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34299. }
  34300. oldValue, err := m.oldValue(ctx)
  34301. if err != nil {
  34302. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34303. }
  34304. return oldValue.AgentID, nil
  34305. }
  34306. // ResetAgentID resets all changes to the "agent_id" field.
  34307. func (m *WhatsappMutation) ResetAgentID() {
  34308. m.agent = nil
  34309. }
  34310. // SetAPIBase sets the "api_base" field.
  34311. func (m *WhatsappMutation) SetAPIBase(s string) {
  34312. m.api_base = &s
  34313. }
  34314. // APIBase returns the value of the "api_base" field in the mutation.
  34315. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34316. v := m.api_base
  34317. if v == nil {
  34318. return
  34319. }
  34320. return *v, true
  34321. }
  34322. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34323. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34325. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34326. if !m.op.Is(OpUpdateOne) {
  34327. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34328. }
  34329. if m.id == nil || m.oldValue == nil {
  34330. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34331. }
  34332. oldValue, err := m.oldValue(ctx)
  34333. if err != nil {
  34334. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34335. }
  34336. return oldValue.APIBase, nil
  34337. }
  34338. // ClearAPIBase clears the value of the "api_base" field.
  34339. func (m *WhatsappMutation) ClearAPIBase() {
  34340. m.api_base = nil
  34341. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34342. }
  34343. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34344. func (m *WhatsappMutation) APIBaseCleared() bool {
  34345. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34346. return ok
  34347. }
  34348. // ResetAPIBase resets all changes to the "api_base" field.
  34349. func (m *WhatsappMutation) ResetAPIBase() {
  34350. m.api_base = nil
  34351. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34352. }
  34353. // SetAPIKey sets the "api_key" field.
  34354. func (m *WhatsappMutation) SetAPIKey(s string) {
  34355. m.api_key = &s
  34356. }
  34357. // APIKey returns the value of the "api_key" field in the mutation.
  34358. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34359. v := m.api_key
  34360. if v == nil {
  34361. return
  34362. }
  34363. return *v, true
  34364. }
  34365. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34366. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34368. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34369. if !m.op.Is(OpUpdateOne) {
  34370. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34371. }
  34372. if m.id == nil || m.oldValue == nil {
  34373. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34374. }
  34375. oldValue, err := m.oldValue(ctx)
  34376. if err != nil {
  34377. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34378. }
  34379. return oldValue.APIKey, nil
  34380. }
  34381. // ClearAPIKey clears the value of the "api_key" field.
  34382. func (m *WhatsappMutation) ClearAPIKey() {
  34383. m.api_key = nil
  34384. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34385. }
  34386. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34387. func (m *WhatsappMutation) APIKeyCleared() bool {
  34388. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34389. return ok
  34390. }
  34391. // ResetAPIKey resets all changes to the "api_key" field.
  34392. func (m *WhatsappMutation) ResetAPIKey() {
  34393. m.api_key = nil
  34394. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34395. }
  34396. // SetAllowList sets the "allow_list" field.
  34397. func (m *WhatsappMutation) SetAllowList(s []string) {
  34398. m.allow_list = &s
  34399. m.appendallow_list = nil
  34400. }
  34401. // AllowList returns the value of the "allow_list" field in the mutation.
  34402. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34403. v := m.allow_list
  34404. if v == nil {
  34405. return
  34406. }
  34407. return *v, true
  34408. }
  34409. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34410. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34412. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34413. if !m.op.Is(OpUpdateOne) {
  34414. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34415. }
  34416. if m.id == nil || m.oldValue == nil {
  34417. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34418. }
  34419. oldValue, err := m.oldValue(ctx)
  34420. if err != nil {
  34421. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34422. }
  34423. return oldValue.AllowList, nil
  34424. }
  34425. // AppendAllowList adds s to the "allow_list" field.
  34426. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34427. m.appendallow_list = append(m.appendallow_list, s...)
  34428. }
  34429. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34430. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34431. if len(m.appendallow_list) == 0 {
  34432. return nil, false
  34433. }
  34434. return m.appendallow_list, true
  34435. }
  34436. // ClearAllowList clears the value of the "allow_list" field.
  34437. func (m *WhatsappMutation) ClearAllowList() {
  34438. m.allow_list = nil
  34439. m.appendallow_list = nil
  34440. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34441. }
  34442. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34443. func (m *WhatsappMutation) AllowListCleared() bool {
  34444. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34445. return ok
  34446. }
  34447. // ResetAllowList resets all changes to the "allow_list" field.
  34448. func (m *WhatsappMutation) ResetAllowList() {
  34449. m.allow_list = nil
  34450. m.appendallow_list = nil
  34451. delete(m.clearedFields, whatsapp.FieldAllowList)
  34452. }
  34453. // SetGroupAllowList sets the "group_allow_list" field.
  34454. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34455. m.group_allow_list = &s
  34456. m.appendgroup_allow_list = nil
  34457. }
  34458. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34459. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34460. v := m.group_allow_list
  34461. if v == nil {
  34462. return
  34463. }
  34464. return *v, true
  34465. }
  34466. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34467. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34469. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34470. if !m.op.Is(OpUpdateOne) {
  34471. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34472. }
  34473. if m.id == nil || m.oldValue == nil {
  34474. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34475. }
  34476. oldValue, err := m.oldValue(ctx)
  34477. if err != nil {
  34478. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34479. }
  34480. return oldValue.GroupAllowList, nil
  34481. }
  34482. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34483. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34484. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34485. }
  34486. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34487. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34488. if len(m.appendgroup_allow_list) == 0 {
  34489. return nil, false
  34490. }
  34491. return m.appendgroup_allow_list, true
  34492. }
  34493. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34494. func (m *WhatsappMutation) ClearGroupAllowList() {
  34495. m.group_allow_list = nil
  34496. m.appendgroup_allow_list = nil
  34497. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34498. }
  34499. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34500. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34501. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34502. return ok
  34503. }
  34504. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34505. func (m *WhatsappMutation) ResetGroupAllowList() {
  34506. m.group_allow_list = nil
  34507. m.appendgroup_allow_list = nil
  34508. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34509. }
  34510. // SetBlockList sets the "block_list" field.
  34511. func (m *WhatsappMutation) SetBlockList(s []string) {
  34512. m.block_list = &s
  34513. m.appendblock_list = nil
  34514. }
  34515. // BlockList returns the value of the "block_list" field in the mutation.
  34516. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34517. v := m.block_list
  34518. if v == nil {
  34519. return
  34520. }
  34521. return *v, true
  34522. }
  34523. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34524. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34526. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34527. if !m.op.Is(OpUpdateOne) {
  34528. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34529. }
  34530. if m.id == nil || m.oldValue == nil {
  34531. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34532. }
  34533. oldValue, err := m.oldValue(ctx)
  34534. if err != nil {
  34535. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34536. }
  34537. return oldValue.BlockList, nil
  34538. }
  34539. // AppendBlockList adds s to the "block_list" field.
  34540. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34541. m.appendblock_list = append(m.appendblock_list, s...)
  34542. }
  34543. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34544. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34545. if len(m.appendblock_list) == 0 {
  34546. return nil, false
  34547. }
  34548. return m.appendblock_list, true
  34549. }
  34550. // ClearBlockList clears the value of the "block_list" field.
  34551. func (m *WhatsappMutation) ClearBlockList() {
  34552. m.block_list = nil
  34553. m.appendblock_list = nil
  34554. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34555. }
  34556. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34557. func (m *WhatsappMutation) BlockListCleared() bool {
  34558. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34559. return ok
  34560. }
  34561. // ResetBlockList resets all changes to the "block_list" field.
  34562. func (m *WhatsappMutation) ResetBlockList() {
  34563. m.block_list = nil
  34564. m.appendblock_list = nil
  34565. delete(m.clearedFields, whatsapp.FieldBlockList)
  34566. }
  34567. // SetGroupBlockList sets the "group_block_list" field.
  34568. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34569. m.group_block_list = &s
  34570. m.appendgroup_block_list = nil
  34571. }
  34572. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34573. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34574. v := m.group_block_list
  34575. if v == nil {
  34576. return
  34577. }
  34578. return *v, true
  34579. }
  34580. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34581. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34583. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34584. if !m.op.Is(OpUpdateOne) {
  34585. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34586. }
  34587. if m.id == nil || m.oldValue == nil {
  34588. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34589. }
  34590. oldValue, err := m.oldValue(ctx)
  34591. if err != nil {
  34592. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34593. }
  34594. return oldValue.GroupBlockList, nil
  34595. }
  34596. // AppendGroupBlockList adds s to the "group_block_list" field.
  34597. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34598. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34599. }
  34600. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34601. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34602. if len(m.appendgroup_block_list) == 0 {
  34603. return nil, false
  34604. }
  34605. return m.appendgroup_block_list, true
  34606. }
  34607. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34608. func (m *WhatsappMutation) ClearGroupBlockList() {
  34609. m.group_block_list = nil
  34610. m.appendgroup_block_list = nil
  34611. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34612. }
  34613. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34614. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34615. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34616. return ok
  34617. }
  34618. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34619. func (m *WhatsappMutation) ResetGroupBlockList() {
  34620. m.group_block_list = nil
  34621. m.appendgroup_block_list = nil
  34622. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34623. }
  34624. // ClearAgent clears the "agent" edge to the Agent entity.
  34625. func (m *WhatsappMutation) ClearAgent() {
  34626. m.clearedagent = true
  34627. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34628. }
  34629. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34630. func (m *WhatsappMutation) AgentCleared() bool {
  34631. return m.clearedagent
  34632. }
  34633. // AgentIDs returns the "agent" edge IDs in the mutation.
  34634. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34635. // AgentID instead. It exists only for internal usage by the builders.
  34636. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34637. if id := m.agent; id != nil {
  34638. ids = append(ids, *id)
  34639. }
  34640. return
  34641. }
  34642. // ResetAgent resets all changes to the "agent" edge.
  34643. func (m *WhatsappMutation) ResetAgent() {
  34644. m.agent = nil
  34645. m.clearedagent = false
  34646. }
  34647. // Where appends a list predicates to the WhatsappMutation builder.
  34648. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34649. m.predicates = append(m.predicates, ps...)
  34650. }
  34651. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34652. // users can use type-assertion to append predicates that do not depend on any generated package.
  34653. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34654. p := make([]predicate.Whatsapp, len(ps))
  34655. for i := range ps {
  34656. p[i] = ps[i]
  34657. }
  34658. m.Where(p...)
  34659. }
  34660. // Op returns the operation name.
  34661. func (m *WhatsappMutation) Op() Op {
  34662. return m.op
  34663. }
  34664. // SetOp allows setting the mutation operation.
  34665. func (m *WhatsappMutation) SetOp(op Op) {
  34666. m.op = op
  34667. }
  34668. // Type returns the node type of this mutation (Whatsapp).
  34669. func (m *WhatsappMutation) Type() string {
  34670. return m.typ
  34671. }
  34672. // Fields returns all fields that were changed during this mutation. Note that in
  34673. // order to get all numeric fields that were incremented/decremented, call
  34674. // AddedFields().
  34675. func (m *WhatsappMutation) Fields() []string {
  34676. fields := make([]string, 0, 18)
  34677. if m.created_at != nil {
  34678. fields = append(fields, whatsapp.FieldCreatedAt)
  34679. }
  34680. if m.updated_at != nil {
  34681. fields = append(fields, whatsapp.FieldUpdatedAt)
  34682. }
  34683. if m.status != nil {
  34684. fields = append(fields, whatsapp.FieldStatus)
  34685. }
  34686. if m.deleted_at != nil {
  34687. fields = append(fields, whatsapp.FieldDeletedAt)
  34688. }
  34689. if m.ak != nil {
  34690. fields = append(fields, whatsapp.FieldAk)
  34691. }
  34692. if m.sk != nil {
  34693. fields = append(fields, whatsapp.FieldSk)
  34694. }
  34695. if m.callback != nil {
  34696. fields = append(fields, whatsapp.FieldCallback)
  34697. }
  34698. if m.account != nil {
  34699. fields = append(fields, whatsapp.FieldAccount)
  34700. }
  34701. if m.nickname != nil {
  34702. fields = append(fields, whatsapp.FieldNickname)
  34703. }
  34704. if m.phone != nil {
  34705. fields = append(fields, whatsapp.FieldPhone)
  34706. }
  34707. if m.organization_id != nil {
  34708. fields = append(fields, whatsapp.FieldOrganizationID)
  34709. }
  34710. if m.agent != nil {
  34711. fields = append(fields, whatsapp.FieldAgentID)
  34712. }
  34713. if m.api_base != nil {
  34714. fields = append(fields, whatsapp.FieldAPIBase)
  34715. }
  34716. if m.api_key != nil {
  34717. fields = append(fields, whatsapp.FieldAPIKey)
  34718. }
  34719. if m.allow_list != nil {
  34720. fields = append(fields, whatsapp.FieldAllowList)
  34721. }
  34722. if m.group_allow_list != nil {
  34723. fields = append(fields, whatsapp.FieldGroupAllowList)
  34724. }
  34725. if m.block_list != nil {
  34726. fields = append(fields, whatsapp.FieldBlockList)
  34727. }
  34728. if m.group_block_list != nil {
  34729. fields = append(fields, whatsapp.FieldGroupBlockList)
  34730. }
  34731. return fields
  34732. }
  34733. // Field returns the value of a field with the given name. The second boolean
  34734. // return value indicates that this field was not set, or was not defined in the
  34735. // schema.
  34736. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34737. switch name {
  34738. case whatsapp.FieldCreatedAt:
  34739. return m.CreatedAt()
  34740. case whatsapp.FieldUpdatedAt:
  34741. return m.UpdatedAt()
  34742. case whatsapp.FieldStatus:
  34743. return m.Status()
  34744. case whatsapp.FieldDeletedAt:
  34745. return m.DeletedAt()
  34746. case whatsapp.FieldAk:
  34747. return m.Ak()
  34748. case whatsapp.FieldSk:
  34749. return m.Sk()
  34750. case whatsapp.FieldCallback:
  34751. return m.Callback()
  34752. case whatsapp.FieldAccount:
  34753. return m.Account()
  34754. case whatsapp.FieldNickname:
  34755. return m.Nickname()
  34756. case whatsapp.FieldPhone:
  34757. return m.Phone()
  34758. case whatsapp.FieldOrganizationID:
  34759. return m.OrganizationID()
  34760. case whatsapp.FieldAgentID:
  34761. return m.AgentID()
  34762. case whatsapp.FieldAPIBase:
  34763. return m.APIBase()
  34764. case whatsapp.FieldAPIKey:
  34765. return m.APIKey()
  34766. case whatsapp.FieldAllowList:
  34767. return m.AllowList()
  34768. case whatsapp.FieldGroupAllowList:
  34769. return m.GroupAllowList()
  34770. case whatsapp.FieldBlockList:
  34771. return m.BlockList()
  34772. case whatsapp.FieldGroupBlockList:
  34773. return m.GroupBlockList()
  34774. }
  34775. return nil, false
  34776. }
  34777. // OldField returns the old value of the field from the database. An error is
  34778. // returned if the mutation operation is not UpdateOne, or the query to the
  34779. // database failed.
  34780. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34781. switch name {
  34782. case whatsapp.FieldCreatedAt:
  34783. return m.OldCreatedAt(ctx)
  34784. case whatsapp.FieldUpdatedAt:
  34785. return m.OldUpdatedAt(ctx)
  34786. case whatsapp.FieldStatus:
  34787. return m.OldStatus(ctx)
  34788. case whatsapp.FieldDeletedAt:
  34789. return m.OldDeletedAt(ctx)
  34790. case whatsapp.FieldAk:
  34791. return m.OldAk(ctx)
  34792. case whatsapp.FieldSk:
  34793. return m.OldSk(ctx)
  34794. case whatsapp.FieldCallback:
  34795. return m.OldCallback(ctx)
  34796. case whatsapp.FieldAccount:
  34797. return m.OldAccount(ctx)
  34798. case whatsapp.FieldNickname:
  34799. return m.OldNickname(ctx)
  34800. case whatsapp.FieldPhone:
  34801. return m.OldPhone(ctx)
  34802. case whatsapp.FieldOrganizationID:
  34803. return m.OldOrganizationID(ctx)
  34804. case whatsapp.FieldAgentID:
  34805. return m.OldAgentID(ctx)
  34806. case whatsapp.FieldAPIBase:
  34807. return m.OldAPIBase(ctx)
  34808. case whatsapp.FieldAPIKey:
  34809. return m.OldAPIKey(ctx)
  34810. case whatsapp.FieldAllowList:
  34811. return m.OldAllowList(ctx)
  34812. case whatsapp.FieldGroupAllowList:
  34813. return m.OldGroupAllowList(ctx)
  34814. case whatsapp.FieldBlockList:
  34815. return m.OldBlockList(ctx)
  34816. case whatsapp.FieldGroupBlockList:
  34817. return m.OldGroupBlockList(ctx)
  34818. }
  34819. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34820. }
  34821. // SetField sets the value of a field with the given name. It returns an error if
  34822. // the field is not defined in the schema, or if the type mismatched the field
  34823. // type.
  34824. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34825. switch name {
  34826. case whatsapp.FieldCreatedAt:
  34827. v, ok := value.(time.Time)
  34828. if !ok {
  34829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34830. }
  34831. m.SetCreatedAt(v)
  34832. return nil
  34833. case whatsapp.FieldUpdatedAt:
  34834. v, ok := value.(time.Time)
  34835. if !ok {
  34836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34837. }
  34838. m.SetUpdatedAt(v)
  34839. return nil
  34840. case whatsapp.FieldStatus:
  34841. v, ok := value.(uint8)
  34842. if !ok {
  34843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34844. }
  34845. m.SetStatus(v)
  34846. return nil
  34847. case whatsapp.FieldDeletedAt:
  34848. v, ok := value.(time.Time)
  34849. if !ok {
  34850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34851. }
  34852. m.SetDeletedAt(v)
  34853. return nil
  34854. case whatsapp.FieldAk:
  34855. v, ok := value.(string)
  34856. if !ok {
  34857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34858. }
  34859. m.SetAk(v)
  34860. return nil
  34861. case whatsapp.FieldSk:
  34862. v, ok := value.(string)
  34863. if !ok {
  34864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34865. }
  34866. m.SetSk(v)
  34867. return nil
  34868. case whatsapp.FieldCallback:
  34869. v, ok := value.(string)
  34870. if !ok {
  34871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34872. }
  34873. m.SetCallback(v)
  34874. return nil
  34875. case whatsapp.FieldAccount:
  34876. v, ok := value.(string)
  34877. if !ok {
  34878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34879. }
  34880. m.SetAccount(v)
  34881. return nil
  34882. case whatsapp.FieldNickname:
  34883. v, ok := value.(string)
  34884. if !ok {
  34885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34886. }
  34887. m.SetNickname(v)
  34888. return nil
  34889. case whatsapp.FieldPhone:
  34890. v, ok := value.(string)
  34891. if !ok {
  34892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34893. }
  34894. m.SetPhone(v)
  34895. return nil
  34896. case whatsapp.FieldOrganizationID:
  34897. v, ok := value.(uint64)
  34898. if !ok {
  34899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34900. }
  34901. m.SetOrganizationID(v)
  34902. return nil
  34903. case whatsapp.FieldAgentID:
  34904. v, ok := value.(uint64)
  34905. if !ok {
  34906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34907. }
  34908. m.SetAgentID(v)
  34909. return nil
  34910. case whatsapp.FieldAPIBase:
  34911. v, ok := value.(string)
  34912. if !ok {
  34913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34914. }
  34915. m.SetAPIBase(v)
  34916. return nil
  34917. case whatsapp.FieldAPIKey:
  34918. v, ok := value.(string)
  34919. if !ok {
  34920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34921. }
  34922. m.SetAPIKey(v)
  34923. return nil
  34924. case whatsapp.FieldAllowList:
  34925. v, ok := value.([]string)
  34926. if !ok {
  34927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34928. }
  34929. m.SetAllowList(v)
  34930. return nil
  34931. case whatsapp.FieldGroupAllowList:
  34932. v, ok := value.([]string)
  34933. if !ok {
  34934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34935. }
  34936. m.SetGroupAllowList(v)
  34937. return nil
  34938. case whatsapp.FieldBlockList:
  34939. v, ok := value.([]string)
  34940. if !ok {
  34941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34942. }
  34943. m.SetBlockList(v)
  34944. return nil
  34945. case whatsapp.FieldGroupBlockList:
  34946. v, ok := value.([]string)
  34947. if !ok {
  34948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34949. }
  34950. m.SetGroupBlockList(v)
  34951. return nil
  34952. }
  34953. return fmt.Errorf("unknown Whatsapp field %s", name)
  34954. }
  34955. // AddedFields returns all numeric fields that were incremented/decremented during
  34956. // this mutation.
  34957. func (m *WhatsappMutation) AddedFields() []string {
  34958. var fields []string
  34959. if m.addstatus != nil {
  34960. fields = append(fields, whatsapp.FieldStatus)
  34961. }
  34962. if m.addorganization_id != nil {
  34963. fields = append(fields, whatsapp.FieldOrganizationID)
  34964. }
  34965. return fields
  34966. }
  34967. // AddedField returns the numeric value that was incremented/decremented on a field
  34968. // with the given name. The second boolean return value indicates that this field
  34969. // was not set, or was not defined in the schema.
  34970. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  34971. switch name {
  34972. case whatsapp.FieldStatus:
  34973. return m.AddedStatus()
  34974. case whatsapp.FieldOrganizationID:
  34975. return m.AddedOrganizationID()
  34976. }
  34977. return nil, false
  34978. }
  34979. // AddField adds the value to the field with the given name. It returns an error if
  34980. // the field is not defined in the schema, or if the type mismatched the field
  34981. // type.
  34982. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  34983. switch name {
  34984. case whatsapp.FieldStatus:
  34985. v, ok := value.(int8)
  34986. if !ok {
  34987. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34988. }
  34989. m.AddStatus(v)
  34990. return nil
  34991. case whatsapp.FieldOrganizationID:
  34992. v, ok := value.(int64)
  34993. if !ok {
  34994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34995. }
  34996. m.AddOrganizationID(v)
  34997. return nil
  34998. }
  34999. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35000. }
  35001. // ClearedFields returns all nullable fields that were cleared during this
  35002. // mutation.
  35003. func (m *WhatsappMutation) ClearedFields() []string {
  35004. var fields []string
  35005. if m.FieldCleared(whatsapp.FieldStatus) {
  35006. fields = append(fields, whatsapp.FieldStatus)
  35007. }
  35008. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35009. fields = append(fields, whatsapp.FieldDeletedAt)
  35010. }
  35011. if m.FieldCleared(whatsapp.FieldAk) {
  35012. fields = append(fields, whatsapp.FieldAk)
  35013. }
  35014. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35015. fields = append(fields, whatsapp.FieldOrganizationID)
  35016. }
  35017. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35018. fields = append(fields, whatsapp.FieldAPIBase)
  35019. }
  35020. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35021. fields = append(fields, whatsapp.FieldAPIKey)
  35022. }
  35023. if m.FieldCleared(whatsapp.FieldAllowList) {
  35024. fields = append(fields, whatsapp.FieldAllowList)
  35025. }
  35026. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35027. fields = append(fields, whatsapp.FieldGroupAllowList)
  35028. }
  35029. if m.FieldCleared(whatsapp.FieldBlockList) {
  35030. fields = append(fields, whatsapp.FieldBlockList)
  35031. }
  35032. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35033. fields = append(fields, whatsapp.FieldGroupBlockList)
  35034. }
  35035. return fields
  35036. }
  35037. // FieldCleared returns a boolean indicating if a field with the given name was
  35038. // cleared in this mutation.
  35039. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35040. _, ok := m.clearedFields[name]
  35041. return ok
  35042. }
  35043. // ClearField clears the value of the field with the given name. It returns an
  35044. // error if the field is not defined in the schema.
  35045. func (m *WhatsappMutation) ClearField(name string) error {
  35046. switch name {
  35047. case whatsapp.FieldStatus:
  35048. m.ClearStatus()
  35049. return nil
  35050. case whatsapp.FieldDeletedAt:
  35051. m.ClearDeletedAt()
  35052. return nil
  35053. case whatsapp.FieldAk:
  35054. m.ClearAk()
  35055. return nil
  35056. case whatsapp.FieldOrganizationID:
  35057. m.ClearOrganizationID()
  35058. return nil
  35059. case whatsapp.FieldAPIBase:
  35060. m.ClearAPIBase()
  35061. return nil
  35062. case whatsapp.FieldAPIKey:
  35063. m.ClearAPIKey()
  35064. return nil
  35065. case whatsapp.FieldAllowList:
  35066. m.ClearAllowList()
  35067. return nil
  35068. case whatsapp.FieldGroupAllowList:
  35069. m.ClearGroupAllowList()
  35070. return nil
  35071. case whatsapp.FieldBlockList:
  35072. m.ClearBlockList()
  35073. return nil
  35074. case whatsapp.FieldGroupBlockList:
  35075. m.ClearGroupBlockList()
  35076. return nil
  35077. }
  35078. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35079. }
  35080. // ResetField resets all changes in the mutation for the field with the given name.
  35081. // It returns an error if the field is not defined in the schema.
  35082. func (m *WhatsappMutation) ResetField(name string) error {
  35083. switch name {
  35084. case whatsapp.FieldCreatedAt:
  35085. m.ResetCreatedAt()
  35086. return nil
  35087. case whatsapp.FieldUpdatedAt:
  35088. m.ResetUpdatedAt()
  35089. return nil
  35090. case whatsapp.FieldStatus:
  35091. m.ResetStatus()
  35092. return nil
  35093. case whatsapp.FieldDeletedAt:
  35094. m.ResetDeletedAt()
  35095. return nil
  35096. case whatsapp.FieldAk:
  35097. m.ResetAk()
  35098. return nil
  35099. case whatsapp.FieldSk:
  35100. m.ResetSk()
  35101. return nil
  35102. case whatsapp.FieldCallback:
  35103. m.ResetCallback()
  35104. return nil
  35105. case whatsapp.FieldAccount:
  35106. m.ResetAccount()
  35107. return nil
  35108. case whatsapp.FieldNickname:
  35109. m.ResetNickname()
  35110. return nil
  35111. case whatsapp.FieldPhone:
  35112. m.ResetPhone()
  35113. return nil
  35114. case whatsapp.FieldOrganizationID:
  35115. m.ResetOrganizationID()
  35116. return nil
  35117. case whatsapp.FieldAgentID:
  35118. m.ResetAgentID()
  35119. return nil
  35120. case whatsapp.FieldAPIBase:
  35121. m.ResetAPIBase()
  35122. return nil
  35123. case whatsapp.FieldAPIKey:
  35124. m.ResetAPIKey()
  35125. return nil
  35126. case whatsapp.FieldAllowList:
  35127. m.ResetAllowList()
  35128. return nil
  35129. case whatsapp.FieldGroupAllowList:
  35130. m.ResetGroupAllowList()
  35131. return nil
  35132. case whatsapp.FieldBlockList:
  35133. m.ResetBlockList()
  35134. return nil
  35135. case whatsapp.FieldGroupBlockList:
  35136. m.ResetGroupBlockList()
  35137. return nil
  35138. }
  35139. return fmt.Errorf("unknown Whatsapp field %s", name)
  35140. }
  35141. // AddedEdges returns all edge names that were set/added in this mutation.
  35142. func (m *WhatsappMutation) AddedEdges() []string {
  35143. edges := make([]string, 0, 1)
  35144. if m.agent != nil {
  35145. edges = append(edges, whatsapp.EdgeAgent)
  35146. }
  35147. return edges
  35148. }
  35149. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35150. // name in this mutation.
  35151. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35152. switch name {
  35153. case whatsapp.EdgeAgent:
  35154. if id := m.agent; id != nil {
  35155. return []ent.Value{*id}
  35156. }
  35157. }
  35158. return nil
  35159. }
  35160. // RemovedEdges returns all edge names that were removed in this mutation.
  35161. func (m *WhatsappMutation) RemovedEdges() []string {
  35162. edges := make([]string, 0, 1)
  35163. return edges
  35164. }
  35165. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35166. // the given name in this mutation.
  35167. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35168. return nil
  35169. }
  35170. // ClearedEdges returns all edge names that were cleared in this mutation.
  35171. func (m *WhatsappMutation) ClearedEdges() []string {
  35172. edges := make([]string, 0, 1)
  35173. if m.clearedagent {
  35174. edges = append(edges, whatsapp.EdgeAgent)
  35175. }
  35176. return edges
  35177. }
  35178. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35179. // was cleared in this mutation.
  35180. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35181. switch name {
  35182. case whatsapp.EdgeAgent:
  35183. return m.clearedagent
  35184. }
  35185. return false
  35186. }
  35187. // ClearEdge clears the value of the edge with the given name. It returns an error
  35188. // if that edge is not defined in the schema.
  35189. func (m *WhatsappMutation) ClearEdge(name string) error {
  35190. switch name {
  35191. case whatsapp.EdgeAgent:
  35192. m.ClearAgent()
  35193. return nil
  35194. }
  35195. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35196. }
  35197. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35198. // It returns an error if the edge is not defined in the schema.
  35199. func (m *WhatsappMutation) ResetEdge(name string) error {
  35200. switch name {
  35201. case whatsapp.EdgeAgent:
  35202. m.ResetAgent()
  35203. return nil
  35204. }
  35205. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35206. }
  35207. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  35208. type WorkExperienceMutation struct {
  35209. config
  35210. op Op
  35211. typ string
  35212. id *uint64
  35213. created_at *time.Time
  35214. updated_at *time.Time
  35215. deleted_at *time.Time
  35216. start_date *time.Time
  35217. end_date *time.Time
  35218. company *string
  35219. experience *string
  35220. organization_id *uint64
  35221. addorganization_id *int64
  35222. clearedFields map[string]struct{}
  35223. employee *uint64
  35224. clearedemployee bool
  35225. done bool
  35226. oldValue func(context.Context) (*WorkExperience, error)
  35227. predicates []predicate.WorkExperience
  35228. }
  35229. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  35230. // workexperienceOption allows management of the mutation configuration using functional options.
  35231. type workexperienceOption func(*WorkExperienceMutation)
  35232. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  35233. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  35234. m := &WorkExperienceMutation{
  35235. config: c,
  35236. op: op,
  35237. typ: TypeWorkExperience,
  35238. clearedFields: make(map[string]struct{}),
  35239. }
  35240. for _, opt := range opts {
  35241. opt(m)
  35242. }
  35243. return m
  35244. }
  35245. // withWorkExperienceID sets the ID field of the mutation.
  35246. func withWorkExperienceID(id uint64) workexperienceOption {
  35247. return func(m *WorkExperienceMutation) {
  35248. var (
  35249. err error
  35250. once sync.Once
  35251. value *WorkExperience
  35252. )
  35253. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  35254. once.Do(func() {
  35255. if m.done {
  35256. err = errors.New("querying old values post mutation is not allowed")
  35257. } else {
  35258. value, err = m.Client().WorkExperience.Get(ctx, id)
  35259. }
  35260. })
  35261. return value, err
  35262. }
  35263. m.id = &id
  35264. }
  35265. }
  35266. // withWorkExperience sets the old WorkExperience of the mutation.
  35267. func withWorkExperience(node *WorkExperience) workexperienceOption {
  35268. return func(m *WorkExperienceMutation) {
  35269. m.oldValue = func(context.Context) (*WorkExperience, error) {
  35270. return node, nil
  35271. }
  35272. m.id = &node.ID
  35273. }
  35274. }
  35275. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35276. // executed in a transaction (ent.Tx), a transactional client is returned.
  35277. func (m WorkExperienceMutation) Client() *Client {
  35278. client := &Client{config: m.config}
  35279. client.init()
  35280. return client
  35281. }
  35282. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35283. // it returns an error otherwise.
  35284. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  35285. if _, ok := m.driver.(*txDriver); !ok {
  35286. return nil, errors.New("ent: mutation is not running in a transaction")
  35287. }
  35288. tx := &Tx{config: m.config}
  35289. tx.init()
  35290. return tx, nil
  35291. }
  35292. // SetID sets the value of the id field. Note that this
  35293. // operation is only accepted on creation of WorkExperience entities.
  35294. func (m *WorkExperienceMutation) SetID(id uint64) {
  35295. m.id = &id
  35296. }
  35297. // ID returns the ID value in the mutation. Note that the ID is only available
  35298. // if it was provided to the builder or after it was returned from the database.
  35299. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  35300. if m.id == nil {
  35301. return
  35302. }
  35303. return *m.id, true
  35304. }
  35305. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35306. // That means, if the mutation is applied within a transaction with an isolation level such
  35307. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35308. // or updated by the mutation.
  35309. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  35310. switch {
  35311. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35312. id, exists := m.ID()
  35313. if exists {
  35314. return []uint64{id}, nil
  35315. }
  35316. fallthrough
  35317. case m.op.Is(OpUpdate | OpDelete):
  35318. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  35319. default:
  35320. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35321. }
  35322. }
  35323. // SetCreatedAt sets the "created_at" field.
  35324. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  35325. m.created_at = &t
  35326. }
  35327. // CreatedAt returns the value of the "created_at" field in the mutation.
  35328. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  35329. v := m.created_at
  35330. if v == nil {
  35331. return
  35332. }
  35333. return *v, true
  35334. }
  35335. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  35336. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35338. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35339. if !m.op.Is(OpUpdateOne) {
  35340. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35341. }
  35342. if m.id == nil || m.oldValue == nil {
  35343. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35344. }
  35345. oldValue, err := m.oldValue(ctx)
  35346. if err != nil {
  35347. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35348. }
  35349. return oldValue.CreatedAt, nil
  35350. }
  35351. // ResetCreatedAt resets all changes to the "created_at" field.
  35352. func (m *WorkExperienceMutation) ResetCreatedAt() {
  35353. m.created_at = nil
  35354. }
  35355. // SetUpdatedAt sets the "updated_at" field.
  35356. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  35357. m.updated_at = &t
  35358. }
  35359. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35360. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  35361. v := m.updated_at
  35362. if v == nil {
  35363. return
  35364. }
  35365. return *v, true
  35366. }
  35367. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  35368. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35370. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35371. if !m.op.Is(OpUpdateOne) {
  35372. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35373. }
  35374. if m.id == nil || m.oldValue == nil {
  35375. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35376. }
  35377. oldValue, err := m.oldValue(ctx)
  35378. if err != nil {
  35379. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35380. }
  35381. return oldValue.UpdatedAt, nil
  35382. }
  35383. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35384. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  35385. m.updated_at = nil
  35386. }
  35387. // SetDeletedAt sets the "deleted_at" field.
  35388. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  35389. m.deleted_at = &t
  35390. }
  35391. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35392. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  35393. v := m.deleted_at
  35394. if v == nil {
  35395. return
  35396. }
  35397. return *v, true
  35398. }
  35399. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  35400. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35402. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35403. if !m.op.Is(OpUpdateOne) {
  35404. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35405. }
  35406. if m.id == nil || m.oldValue == nil {
  35407. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35408. }
  35409. oldValue, err := m.oldValue(ctx)
  35410. if err != nil {
  35411. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35412. }
  35413. return oldValue.DeletedAt, nil
  35414. }
  35415. // ClearDeletedAt clears the value of the "deleted_at" field.
  35416. func (m *WorkExperienceMutation) ClearDeletedAt() {
  35417. m.deleted_at = nil
  35418. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  35419. }
  35420. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35421. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  35422. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  35423. return ok
  35424. }
  35425. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35426. func (m *WorkExperienceMutation) ResetDeletedAt() {
  35427. m.deleted_at = nil
  35428. delete(m.clearedFields, workexperience.FieldDeletedAt)
  35429. }
  35430. // SetEmployeeID sets the "employee_id" field.
  35431. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  35432. m.employee = &u
  35433. }
  35434. // EmployeeID returns the value of the "employee_id" field in the mutation.
  35435. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  35436. v := m.employee
  35437. if v == nil {
  35438. return
  35439. }
  35440. return *v, true
  35441. }
  35442. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  35443. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35445. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  35446. if !m.op.Is(OpUpdateOne) {
  35447. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  35448. }
  35449. if m.id == nil || m.oldValue == nil {
  35450. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  35451. }
  35452. oldValue, err := m.oldValue(ctx)
  35453. if err != nil {
  35454. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  35455. }
  35456. return oldValue.EmployeeID, nil
  35457. }
  35458. // ResetEmployeeID resets all changes to the "employee_id" field.
  35459. func (m *WorkExperienceMutation) ResetEmployeeID() {
  35460. m.employee = nil
  35461. }
  35462. // SetStartDate sets the "start_date" field.
  35463. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  35464. m.start_date = &t
  35465. }
  35466. // StartDate returns the value of the "start_date" field in the mutation.
  35467. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  35468. v := m.start_date
  35469. if v == nil {
  35470. return
  35471. }
  35472. return *v, true
  35473. }
  35474. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  35475. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35476. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35477. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  35478. if !m.op.Is(OpUpdateOne) {
  35479. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  35480. }
  35481. if m.id == nil || m.oldValue == nil {
  35482. return v, errors.New("OldStartDate requires an ID field in the mutation")
  35483. }
  35484. oldValue, err := m.oldValue(ctx)
  35485. if err != nil {
  35486. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  35487. }
  35488. return oldValue.StartDate, nil
  35489. }
  35490. // ResetStartDate resets all changes to the "start_date" field.
  35491. func (m *WorkExperienceMutation) ResetStartDate() {
  35492. m.start_date = nil
  35493. }
  35494. // SetEndDate sets the "end_date" field.
  35495. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  35496. m.end_date = &t
  35497. }
  35498. // EndDate returns the value of the "end_date" field in the mutation.
  35499. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  35500. v := m.end_date
  35501. if v == nil {
  35502. return
  35503. }
  35504. return *v, true
  35505. }
  35506. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  35507. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35509. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  35510. if !m.op.Is(OpUpdateOne) {
  35511. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  35512. }
  35513. if m.id == nil || m.oldValue == nil {
  35514. return v, errors.New("OldEndDate requires an ID field in the mutation")
  35515. }
  35516. oldValue, err := m.oldValue(ctx)
  35517. if err != nil {
  35518. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  35519. }
  35520. return oldValue.EndDate, nil
  35521. }
  35522. // ResetEndDate resets all changes to the "end_date" field.
  35523. func (m *WorkExperienceMutation) ResetEndDate() {
  35524. m.end_date = nil
  35525. }
  35526. // SetCompany sets the "company" field.
  35527. func (m *WorkExperienceMutation) SetCompany(s string) {
  35528. m.company = &s
  35529. }
  35530. // Company returns the value of the "company" field in the mutation.
  35531. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  35532. v := m.company
  35533. if v == nil {
  35534. return
  35535. }
  35536. return *v, true
  35537. }
  35538. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  35539. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35541. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  35542. if !m.op.Is(OpUpdateOne) {
  35543. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35544. }
  35545. if m.id == nil || m.oldValue == nil {
  35546. return v, errors.New("OldCompany requires an ID field in the mutation")
  35547. }
  35548. oldValue, err := m.oldValue(ctx)
  35549. if err != nil {
  35550. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35551. }
  35552. return oldValue.Company, nil
  35553. }
  35554. // ResetCompany resets all changes to the "company" field.
  35555. func (m *WorkExperienceMutation) ResetCompany() {
  35556. m.company = nil
  35557. }
  35558. // SetExperience sets the "experience" field.
  35559. func (m *WorkExperienceMutation) SetExperience(s string) {
  35560. m.experience = &s
  35561. }
  35562. // Experience returns the value of the "experience" field in the mutation.
  35563. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  35564. v := m.experience
  35565. if v == nil {
  35566. return
  35567. }
  35568. return *v, true
  35569. }
  35570. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  35571. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35573. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  35574. if !m.op.Is(OpUpdateOne) {
  35575. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  35576. }
  35577. if m.id == nil || m.oldValue == nil {
  35578. return v, errors.New("OldExperience requires an ID field in the mutation")
  35579. }
  35580. oldValue, err := m.oldValue(ctx)
  35581. if err != nil {
  35582. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  35583. }
  35584. return oldValue.Experience, nil
  35585. }
  35586. // ResetExperience resets all changes to the "experience" field.
  35587. func (m *WorkExperienceMutation) ResetExperience() {
  35588. m.experience = nil
  35589. }
  35590. // SetOrganizationID sets the "organization_id" field.
  35591. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  35592. m.organization_id = &u
  35593. m.addorganization_id = nil
  35594. }
  35595. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35596. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  35597. v := m.organization_id
  35598. if v == nil {
  35599. return
  35600. }
  35601. return *v, true
  35602. }
  35603. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  35604. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35605. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35606. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35607. if !m.op.Is(OpUpdateOne) {
  35608. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35609. }
  35610. if m.id == nil || m.oldValue == nil {
  35611. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35612. }
  35613. oldValue, err := m.oldValue(ctx)
  35614. if err != nil {
  35615. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35616. }
  35617. return oldValue.OrganizationID, nil
  35618. }
  35619. // AddOrganizationID adds u to the "organization_id" field.
  35620. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  35621. if m.addorganization_id != nil {
  35622. *m.addorganization_id += u
  35623. } else {
  35624. m.addorganization_id = &u
  35625. }
  35626. }
  35627. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35628. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  35629. v := m.addorganization_id
  35630. if v == nil {
  35631. return
  35632. }
  35633. return *v, true
  35634. }
  35635. // ResetOrganizationID resets all changes to the "organization_id" field.
  35636. func (m *WorkExperienceMutation) ResetOrganizationID() {
  35637. m.organization_id = nil
  35638. m.addorganization_id = nil
  35639. }
  35640. // ClearEmployee clears the "employee" edge to the Employee entity.
  35641. func (m *WorkExperienceMutation) ClearEmployee() {
  35642. m.clearedemployee = true
  35643. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  35644. }
  35645. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  35646. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  35647. return m.clearedemployee
  35648. }
  35649. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  35650. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35651. // EmployeeID instead. It exists only for internal usage by the builders.
  35652. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  35653. if id := m.employee; id != nil {
  35654. ids = append(ids, *id)
  35655. }
  35656. return
  35657. }
  35658. // ResetEmployee resets all changes to the "employee" edge.
  35659. func (m *WorkExperienceMutation) ResetEmployee() {
  35660. m.employee = nil
  35661. m.clearedemployee = false
  35662. }
  35663. // Where appends a list predicates to the WorkExperienceMutation builder.
  35664. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  35665. m.predicates = append(m.predicates, ps...)
  35666. }
  35667. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  35668. // users can use type-assertion to append predicates that do not depend on any generated package.
  35669. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  35670. p := make([]predicate.WorkExperience, len(ps))
  35671. for i := range ps {
  35672. p[i] = ps[i]
  35673. }
  35674. m.Where(p...)
  35675. }
  35676. // Op returns the operation name.
  35677. func (m *WorkExperienceMutation) Op() Op {
  35678. return m.op
  35679. }
  35680. // SetOp allows setting the mutation operation.
  35681. func (m *WorkExperienceMutation) SetOp(op Op) {
  35682. m.op = op
  35683. }
  35684. // Type returns the node type of this mutation (WorkExperience).
  35685. func (m *WorkExperienceMutation) Type() string {
  35686. return m.typ
  35687. }
  35688. // Fields returns all fields that were changed during this mutation. Note that in
  35689. // order to get all numeric fields that were incremented/decremented, call
  35690. // AddedFields().
  35691. func (m *WorkExperienceMutation) Fields() []string {
  35692. fields := make([]string, 0, 9)
  35693. if m.created_at != nil {
  35694. fields = append(fields, workexperience.FieldCreatedAt)
  35695. }
  35696. if m.updated_at != nil {
  35697. fields = append(fields, workexperience.FieldUpdatedAt)
  35698. }
  35699. if m.deleted_at != nil {
  35700. fields = append(fields, workexperience.FieldDeletedAt)
  35701. }
  35702. if m.employee != nil {
  35703. fields = append(fields, workexperience.FieldEmployeeID)
  35704. }
  35705. if m.start_date != nil {
  35706. fields = append(fields, workexperience.FieldStartDate)
  35707. }
  35708. if m.end_date != nil {
  35709. fields = append(fields, workexperience.FieldEndDate)
  35710. }
  35711. if m.company != nil {
  35712. fields = append(fields, workexperience.FieldCompany)
  35713. }
  35714. if m.experience != nil {
  35715. fields = append(fields, workexperience.FieldExperience)
  35716. }
  35717. if m.organization_id != nil {
  35718. fields = append(fields, workexperience.FieldOrganizationID)
  35719. }
  35720. return fields
  35721. }
  35722. // Field returns the value of a field with the given name. The second boolean
  35723. // return value indicates that this field was not set, or was not defined in the
  35724. // schema.
  35725. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  35726. switch name {
  35727. case workexperience.FieldCreatedAt:
  35728. return m.CreatedAt()
  35729. case workexperience.FieldUpdatedAt:
  35730. return m.UpdatedAt()
  35731. case workexperience.FieldDeletedAt:
  35732. return m.DeletedAt()
  35733. case workexperience.FieldEmployeeID:
  35734. return m.EmployeeID()
  35735. case workexperience.FieldStartDate:
  35736. return m.StartDate()
  35737. case workexperience.FieldEndDate:
  35738. return m.EndDate()
  35739. case workexperience.FieldCompany:
  35740. return m.Company()
  35741. case workexperience.FieldExperience:
  35742. return m.Experience()
  35743. case workexperience.FieldOrganizationID:
  35744. return m.OrganizationID()
  35745. }
  35746. return nil, false
  35747. }
  35748. // OldField returns the old value of the field from the database. An error is
  35749. // returned if the mutation operation is not UpdateOne, or the query to the
  35750. // database failed.
  35751. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35752. switch name {
  35753. case workexperience.FieldCreatedAt:
  35754. return m.OldCreatedAt(ctx)
  35755. case workexperience.FieldUpdatedAt:
  35756. return m.OldUpdatedAt(ctx)
  35757. case workexperience.FieldDeletedAt:
  35758. return m.OldDeletedAt(ctx)
  35759. case workexperience.FieldEmployeeID:
  35760. return m.OldEmployeeID(ctx)
  35761. case workexperience.FieldStartDate:
  35762. return m.OldStartDate(ctx)
  35763. case workexperience.FieldEndDate:
  35764. return m.OldEndDate(ctx)
  35765. case workexperience.FieldCompany:
  35766. return m.OldCompany(ctx)
  35767. case workexperience.FieldExperience:
  35768. return m.OldExperience(ctx)
  35769. case workexperience.FieldOrganizationID:
  35770. return m.OldOrganizationID(ctx)
  35771. }
  35772. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  35773. }
  35774. // SetField sets the value of a field with the given name. It returns an error if
  35775. // the field is not defined in the schema, or if the type mismatched the field
  35776. // type.
  35777. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  35778. switch name {
  35779. case workexperience.FieldCreatedAt:
  35780. v, ok := value.(time.Time)
  35781. if !ok {
  35782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35783. }
  35784. m.SetCreatedAt(v)
  35785. return nil
  35786. case workexperience.FieldUpdatedAt:
  35787. v, ok := value.(time.Time)
  35788. if !ok {
  35789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35790. }
  35791. m.SetUpdatedAt(v)
  35792. return nil
  35793. case workexperience.FieldDeletedAt:
  35794. v, ok := value.(time.Time)
  35795. if !ok {
  35796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35797. }
  35798. m.SetDeletedAt(v)
  35799. return nil
  35800. case workexperience.FieldEmployeeID:
  35801. v, ok := value.(uint64)
  35802. if !ok {
  35803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35804. }
  35805. m.SetEmployeeID(v)
  35806. return nil
  35807. case workexperience.FieldStartDate:
  35808. v, ok := value.(time.Time)
  35809. if !ok {
  35810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35811. }
  35812. m.SetStartDate(v)
  35813. return nil
  35814. case workexperience.FieldEndDate:
  35815. v, ok := value.(time.Time)
  35816. if !ok {
  35817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35818. }
  35819. m.SetEndDate(v)
  35820. return nil
  35821. case workexperience.FieldCompany:
  35822. v, ok := value.(string)
  35823. if !ok {
  35824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35825. }
  35826. m.SetCompany(v)
  35827. return nil
  35828. case workexperience.FieldExperience:
  35829. v, ok := value.(string)
  35830. if !ok {
  35831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35832. }
  35833. m.SetExperience(v)
  35834. return nil
  35835. case workexperience.FieldOrganizationID:
  35836. v, ok := value.(uint64)
  35837. if !ok {
  35838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35839. }
  35840. m.SetOrganizationID(v)
  35841. return nil
  35842. }
  35843. return fmt.Errorf("unknown WorkExperience field %s", name)
  35844. }
  35845. // AddedFields returns all numeric fields that were incremented/decremented during
  35846. // this mutation.
  35847. func (m *WorkExperienceMutation) AddedFields() []string {
  35848. var fields []string
  35849. if m.addorganization_id != nil {
  35850. fields = append(fields, workexperience.FieldOrganizationID)
  35851. }
  35852. return fields
  35853. }
  35854. // AddedField returns the numeric value that was incremented/decremented on a field
  35855. // with the given name. The second boolean return value indicates that this field
  35856. // was not set, or was not defined in the schema.
  35857. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  35858. switch name {
  35859. case workexperience.FieldOrganizationID:
  35860. return m.AddedOrganizationID()
  35861. }
  35862. return nil, false
  35863. }
  35864. // AddField adds the value to the field with the given name. It returns an error if
  35865. // the field is not defined in the schema, or if the type mismatched the field
  35866. // type.
  35867. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  35868. switch name {
  35869. case workexperience.FieldOrganizationID:
  35870. v, ok := value.(int64)
  35871. if !ok {
  35872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35873. }
  35874. m.AddOrganizationID(v)
  35875. return nil
  35876. }
  35877. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  35878. }
  35879. // ClearedFields returns all nullable fields that were cleared during this
  35880. // mutation.
  35881. func (m *WorkExperienceMutation) ClearedFields() []string {
  35882. var fields []string
  35883. if m.FieldCleared(workexperience.FieldDeletedAt) {
  35884. fields = append(fields, workexperience.FieldDeletedAt)
  35885. }
  35886. return fields
  35887. }
  35888. // FieldCleared returns a boolean indicating if a field with the given name was
  35889. // cleared in this mutation.
  35890. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  35891. _, ok := m.clearedFields[name]
  35892. return ok
  35893. }
  35894. // ClearField clears the value of the field with the given name. It returns an
  35895. // error if the field is not defined in the schema.
  35896. func (m *WorkExperienceMutation) ClearField(name string) error {
  35897. switch name {
  35898. case workexperience.FieldDeletedAt:
  35899. m.ClearDeletedAt()
  35900. return nil
  35901. }
  35902. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  35903. }
  35904. // ResetField resets all changes in the mutation for the field with the given name.
  35905. // It returns an error if the field is not defined in the schema.
  35906. func (m *WorkExperienceMutation) ResetField(name string) error {
  35907. switch name {
  35908. case workexperience.FieldCreatedAt:
  35909. m.ResetCreatedAt()
  35910. return nil
  35911. case workexperience.FieldUpdatedAt:
  35912. m.ResetUpdatedAt()
  35913. return nil
  35914. case workexperience.FieldDeletedAt:
  35915. m.ResetDeletedAt()
  35916. return nil
  35917. case workexperience.FieldEmployeeID:
  35918. m.ResetEmployeeID()
  35919. return nil
  35920. case workexperience.FieldStartDate:
  35921. m.ResetStartDate()
  35922. return nil
  35923. case workexperience.FieldEndDate:
  35924. m.ResetEndDate()
  35925. return nil
  35926. case workexperience.FieldCompany:
  35927. m.ResetCompany()
  35928. return nil
  35929. case workexperience.FieldExperience:
  35930. m.ResetExperience()
  35931. return nil
  35932. case workexperience.FieldOrganizationID:
  35933. m.ResetOrganizationID()
  35934. return nil
  35935. }
  35936. return fmt.Errorf("unknown WorkExperience field %s", name)
  35937. }
  35938. // AddedEdges returns all edge names that were set/added in this mutation.
  35939. func (m *WorkExperienceMutation) AddedEdges() []string {
  35940. edges := make([]string, 0, 1)
  35941. if m.employee != nil {
  35942. edges = append(edges, workexperience.EdgeEmployee)
  35943. }
  35944. return edges
  35945. }
  35946. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35947. // name in this mutation.
  35948. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  35949. switch name {
  35950. case workexperience.EdgeEmployee:
  35951. if id := m.employee; id != nil {
  35952. return []ent.Value{*id}
  35953. }
  35954. }
  35955. return nil
  35956. }
  35957. // RemovedEdges returns all edge names that were removed in this mutation.
  35958. func (m *WorkExperienceMutation) RemovedEdges() []string {
  35959. edges := make([]string, 0, 1)
  35960. return edges
  35961. }
  35962. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35963. // the given name in this mutation.
  35964. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  35965. return nil
  35966. }
  35967. // ClearedEdges returns all edge names that were cleared in this mutation.
  35968. func (m *WorkExperienceMutation) ClearedEdges() []string {
  35969. edges := make([]string, 0, 1)
  35970. if m.clearedemployee {
  35971. edges = append(edges, workexperience.EdgeEmployee)
  35972. }
  35973. return edges
  35974. }
  35975. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35976. // was cleared in this mutation.
  35977. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  35978. switch name {
  35979. case workexperience.EdgeEmployee:
  35980. return m.clearedemployee
  35981. }
  35982. return false
  35983. }
  35984. // ClearEdge clears the value of the edge with the given name. It returns an error
  35985. // if that edge is not defined in the schema.
  35986. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  35987. switch name {
  35988. case workexperience.EdgeEmployee:
  35989. m.ClearEmployee()
  35990. return nil
  35991. }
  35992. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  35993. }
  35994. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35995. // It returns an error if the edge is not defined in the schema.
  35996. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  35997. switch name {
  35998. case workexperience.EdgeEmployee:
  35999. m.ResetEmployee()
  36000. return nil
  36001. }
  36002. return fmt.Errorf("unknown WorkExperience edge %s", name)
  36003. }
  36004. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  36005. type WpChatroomMutation struct {
  36006. config
  36007. op Op
  36008. typ string
  36009. id *uint64
  36010. created_at *time.Time
  36011. updated_at *time.Time
  36012. status *uint8
  36013. addstatus *int8
  36014. wx_wxid *string
  36015. chatroom_id *string
  36016. nickname *string
  36017. owner *string
  36018. avatar *string
  36019. member_list *[]string
  36020. appendmember_list []string
  36021. clearedFields map[string]struct{}
  36022. done bool
  36023. oldValue func(context.Context) (*WpChatroom, error)
  36024. predicates []predicate.WpChatroom
  36025. }
  36026. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  36027. // wpchatroomOption allows management of the mutation configuration using functional options.
  36028. type wpchatroomOption func(*WpChatroomMutation)
  36029. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  36030. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  36031. m := &WpChatroomMutation{
  36032. config: c,
  36033. op: op,
  36034. typ: TypeWpChatroom,
  36035. clearedFields: make(map[string]struct{}),
  36036. }
  36037. for _, opt := range opts {
  36038. opt(m)
  36039. }
  36040. return m
  36041. }
  36042. // withWpChatroomID sets the ID field of the mutation.
  36043. func withWpChatroomID(id uint64) wpchatroomOption {
  36044. return func(m *WpChatroomMutation) {
  36045. var (
  36046. err error
  36047. once sync.Once
  36048. value *WpChatroom
  36049. )
  36050. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  36051. once.Do(func() {
  36052. if m.done {
  36053. err = errors.New("querying old values post mutation is not allowed")
  36054. } else {
  36055. value, err = m.Client().WpChatroom.Get(ctx, id)
  36056. }
  36057. })
  36058. return value, err
  36059. }
  36060. m.id = &id
  36061. }
  36062. }
  36063. // withWpChatroom sets the old WpChatroom of the mutation.
  36064. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  36065. return func(m *WpChatroomMutation) {
  36066. m.oldValue = func(context.Context) (*WpChatroom, error) {
  36067. return node, nil
  36068. }
  36069. m.id = &node.ID
  36070. }
  36071. }
  36072. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36073. // executed in a transaction (ent.Tx), a transactional client is returned.
  36074. func (m WpChatroomMutation) Client() *Client {
  36075. client := &Client{config: m.config}
  36076. client.init()
  36077. return client
  36078. }
  36079. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36080. // it returns an error otherwise.
  36081. func (m WpChatroomMutation) Tx() (*Tx, error) {
  36082. if _, ok := m.driver.(*txDriver); !ok {
  36083. return nil, errors.New("ent: mutation is not running in a transaction")
  36084. }
  36085. tx := &Tx{config: m.config}
  36086. tx.init()
  36087. return tx, nil
  36088. }
  36089. // SetID sets the value of the id field. Note that this
  36090. // operation is only accepted on creation of WpChatroom entities.
  36091. func (m *WpChatroomMutation) SetID(id uint64) {
  36092. m.id = &id
  36093. }
  36094. // ID returns the ID value in the mutation. Note that the ID is only available
  36095. // if it was provided to the builder or after it was returned from the database.
  36096. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  36097. if m.id == nil {
  36098. return
  36099. }
  36100. return *m.id, true
  36101. }
  36102. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36103. // That means, if the mutation is applied within a transaction with an isolation level such
  36104. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36105. // or updated by the mutation.
  36106. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  36107. switch {
  36108. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36109. id, exists := m.ID()
  36110. if exists {
  36111. return []uint64{id}, nil
  36112. }
  36113. fallthrough
  36114. case m.op.Is(OpUpdate | OpDelete):
  36115. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  36116. default:
  36117. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36118. }
  36119. }
  36120. // SetCreatedAt sets the "created_at" field.
  36121. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  36122. m.created_at = &t
  36123. }
  36124. // CreatedAt returns the value of the "created_at" field in the mutation.
  36125. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  36126. v := m.created_at
  36127. if v == nil {
  36128. return
  36129. }
  36130. return *v, true
  36131. }
  36132. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  36133. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36135. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36136. if !m.op.Is(OpUpdateOne) {
  36137. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36138. }
  36139. if m.id == nil || m.oldValue == nil {
  36140. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36141. }
  36142. oldValue, err := m.oldValue(ctx)
  36143. if err != nil {
  36144. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36145. }
  36146. return oldValue.CreatedAt, nil
  36147. }
  36148. // ResetCreatedAt resets all changes to the "created_at" field.
  36149. func (m *WpChatroomMutation) ResetCreatedAt() {
  36150. m.created_at = nil
  36151. }
  36152. // SetUpdatedAt sets the "updated_at" field.
  36153. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  36154. m.updated_at = &t
  36155. }
  36156. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36157. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  36158. v := m.updated_at
  36159. if v == nil {
  36160. return
  36161. }
  36162. return *v, true
  36163. }
  36164. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  36165. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36167. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36168. if !m.op.Is(OpUpdateOne) {
  36169. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36170. }
  36171. if m.id == nil || m.oldValue == nil {
  36172. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36173. }
  36174. oldValue, err := m.oldValue(ctx)
  36175. if err != nil {
  36176. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36177. }
  36178. return oldValue.UpdatedAt, nil
  36179. }
  36180. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36181. func (m *WpChatroomMutation) ResetUpdatedAt() {
  36182. m.updated_at = nil
  36183. }
  36184. // SetStatus sets the "status" field.
  36185. func (m *WpChatroomMutation) SetStatus(u uint8) {
  36186. m.status = &u
  36187. m.addstatus = nil
  36188. }
  36189. // Status returns the value of the "status" field in the mutation.
  36190. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  36191. v := m.status
  36192. if v == nil {
  36193. return
  36194. }
  36195. return *v, true
  36196. }
  36197. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  36198. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36199. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36200. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36201. if !m.op.Is(OpUpdateOne) {
  36202. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36203. }
  36204. if m.id == nil || m.oldValue == nil {
  36205. return v, errors.New("OldStatus requires an ID field in the mutation")
  36206. }
  36207. oldValue, err := m.oldValue(ctx)
  36208. if err != nil {
  36209. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36210. }
  36211. return oldValue.Status, nil
  36212. }
  36213. // AddStatus adds u to the "status" field.
  36214. func (m *WpChatroomMutation) AddStatus(u int8) {
  36215. if m.addstatus != nil {
  36216. *m.addstatus += u
  36217. } else {
  36218. m.addstatus = &u
  36219. }
  36220. }
  36221. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36222. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  36223. v := m.addstatus
  36224. if v == nil {
  36225. return
  36226. }
  36227. return *v, true
  36228. }
  36229. // ClearStatus clears the value of the "status" field.
  36230. func (m *WpChatroomMutation) ClearStatus() {
  36231. m.status = nil
  36232. m.addstatus = nil
  36233. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  36234. }
  36235. // StatusCleared returns if the "status" field was cleared in this mutation.
  36236. func (m *WpChatroomMutation) StatusCleared() bool {
  36237. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  36238. return ok
  36239. }
  36240. // ResetStatus resets all changes to the "status" field.
  36241. func (m *WpChatroomMutation) ResetStatus() {
  36242. m.status = nil
  36243. m.addstatus = nil
  36244. delete(m.clearedFields, wpchatroom.FieldStatus)
  36245. }
  36246. // SetWxWxid sets the "wx_wxid" field.
  36247. func (m *WpChatroomMutation) SetWxWxid(s string) {
  36248. m.wx_wxid = &s
  36249. }
  36250. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36251. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  36252. v := m.wx_wxid
  36253. if v == nil {
  36254. return
  36255. }
  36256. return *v, true
  36257. }
  36258. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  36259. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36261. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36262. if !m.op.Is(OpUpdateOne) {
  36263. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36264. }
  36265. if m.id == nil || m.oldValue == nil {
  36266. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36267. }
  36268. oldValue, err := m.oldValue(ctx)
  36269. if err != nil {
  36270. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36271. }
  36272. return oldValue.WxWxid, nil
  36273. }
  36274. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36275. func (m *WpChatroomMutation) ResetWxWxid() {
  36276. m.wx_wxid = nil
  36277. }
  36278. // SetChatroomID sets the "chatroom_id" field.
  36279. func (m *WpChatroomMutation) SetChatroomID(s string) {
  36280. m.chatroom_id = &s
  36281. }
  36282. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  36283. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  36284. v := m.chatroom_id
  36285. if v == nil {
  36286. return
  36287. }
  36288. return *v, true
  36289. }
  36290. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  36291. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36293. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  36294. if !m.op.Is(OpUpdateOne) {
  36295. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  36296. }
  36297. if m.id == nil || m.oldValue == nil {
  36298. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  36299. }
  36300. oldValue, err := m.oldValue(ctx)
  36301. if err != nil {
  36302. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  36303. }
  36304. return oldValue.ChatroomID, nil
  36305. }
  36306. // ResetChatroomID resets all changes to the "chatroom_id" field.
  36307. func (m *WpChatroomMutation) ResetChatroomID() {
  36308. m.chatroom_id = nil
  36309. }
  36310. // SetNickname sets the "nickname" field.
  36311. func (m *WpChatroomMutation) SetNickname(s string) {
  36312. m.nickname = &s
  36313. }
  36314. // Nickname returns the value of the "nickname" field in the mutation.
  36315. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  36316. v := m.nickname
  36317. if v == nil {
  36318. return
  36319. }
  36320. return *v, true
  36321. }
  36322. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  36323. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36324. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36325. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  36326. if !m.op.Is(OpUpdateOne) {
  36327. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36328. }
  36329. if m.id == nil || m.oldValue == nil {
  36330. return v, errors.New("OldNickname requires an ID field in the mutation")
  36331. }
  36332. oldValue, err := m.oldValue(ctx)
  36333. if err != nil {
  36334. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36335. }
  36336. return oldValue.Nickname, nil
  36337. }
  36338. // ResetNickname resets all changes to the "nickname" field.
  36339. func (m *WpChatroomMutation) ResetNickname() {
  36340. m.nickname = nil
  36341. }
  36342. // SetOwner sets the "owner" field.
  36343. func (m *WpChatroomMutation) SetOwner(s string) {
  36344. m.owner = &s
  36345. }
  36346. // Owner returns the value of the "owner" field in the mutation.
  36347. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  36348. v := m.owner
  36349. if v == nil {
  36350. return
  36351. }
  36352. return *v, true
  36353. }
  36354. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  36355. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36357. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  36358. if !m.op.Is(OpUpdateOne) {
  36359. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  36360. }
  36361. if m.id == nil || m.oldValue == nil {
  36362. return v, errors.New("OldOwner requires an ID field in the mutation")
  36363. }
  36364. oldValue, err := m.oldValue(ctx)
  36365. if err != nil {
  36366. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  36367. }
  36368. return oldValue.Owner, nil
  36369. }
  36370. // ResetOwner resets all changes to the "owner" field.
  36371. func (m *WpChatroomMutation) ResetOwner() {
  36372. m.owner = nil
  36373. }
  36374. // SetAvatar sets the "avatar" field.
  36375. func (m *WpChatroomMutation) SetAvatar(s string) {
  36376. m.avatar = &s
  36377. }
  36378. // Avatar returns the value of the "avatar" field in the mutation.
  36379. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  36380. v := m.avatar
  36381. if v == nil {
  36382. return
  36383. }
  36384. return *v, true
  36385. }
  36386. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  36387. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36389. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36390. if !m.op.Is(OpUpdateOne) {
  36391. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36392. }
  36393. if m.id == nil || m.oldValue == nil {
  36394. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36395. }
  36396. oldValue, err := m.oldValue(ctx)
  36397. if err != nil {
  36398. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36399. }
  36400. return oldValue.Avatar, nil
  36401. }
  36402. // ResetAvatar resets all changes to the "avatar" field.
  36403. func (m *WpChatroomMutation) ResetAvatar() {
  36404. m.avatar = nil
  36405. }
  36406. // SetMemberList sets the "member_list" field.
  36407. func (m *WpChatroomMutation) SetMemberList(s []string) {
  36408. m.member_list = &s
  36409. m.appendmember_list = nil
  36410. }
  36411. // MemberList returns the value of the "member_list" field in the mutation.
  36412. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  36413. v := m.member_list
  36414. if v == nil {
  36415. return
  36416. }
  36417. return *v, true
  36418. }
  36419. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  36420. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36422. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  36423. if !m.op.Is(OpUpdateOne) {
  36424. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  36425. }
  36426. if m.id == nil || m.oldValue == nil {
  36427. return v, errors.New("OldMemberList requires an ID field in the mutation")
  36428. }
  36429. oldValue, err := m.oldValue(ctx)
  36430. if err != nil {
  36431. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  36432. }
  36433. return oldValue.MemberList, nil
  36434. }
  36435. // AppendMemberList adds s to the "member_list" field.
  36436. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  36437. m.appendmember_list = append(m.appendmember_list, s...)
  36438. }
  36439. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  36440. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  36441. if len(m.appendmember_list) == 0 {
  36442. return nil, false
  36443. }
  36444. return m.appendmember_list, true
  36445. }
  36446. // ResetMemberList resets all changes to the "member_list" field.
  36447. func (m *WpChatroomMutation) ResetMemberList() {
  36448. m.member_list = nil
  36449. m.appendmember_list = nil
  36450. }
  36451. // Where appends a list predicates to the WpChatroomMutation builder.
  36452. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  36453. m.predicates = append(m.predicates, ps...)
  36454. }
  36455. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  36456. // users can use type-assertion to append predicates that do not depend on any generated package.
  36457. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  36458. p := make([]predicate.WpChatroom, len(ps))
  36459. for i := range ps {
  36460. p[i] = ps[i]
  36461. }
  36462. m.Where(p...)
  36463. }
  36464. // Op returns the operation name.
  36465. func (m *WpChatroomMutation) Op() Op {
  36466. return m.op
  36467. }
  36468. // SetOp allows setting the mutation operation.
  36469. func (m *WpChatroomMutation) SetOp(op Op) {
  36470. m.op = op
  36471. }
  36472. // Type returns the node type of this mutation (WpChatroom).
  36473. func (m *WpChatroomMutation) Type() string {
  36474. return m.typ
  36475. }
  36476. // Fields returns all fields that were changed during this mutation. Note that in
  36477. // order to get all numeric fields that were incremented/decremented, call
  36478. // AddedFields().
  36479. func (m *WpChatroomMutation) Fields() []string {
  36480. fields := make([]string, 0, 9)
  36481. if m.created_at != nil {
  36482. fields = append(fields, wpchatroom.FieldCreatedAt)
  36483. }
  36484. if m.updated_at != nil {
  36485. fields = append(fields, wpchatroom.FieldUpdatedAt)
  36486. }
  36487. if m.status != nil {
  36488. fields = append(fields, wpchatroom.FieldStatus)
  36489. }
  36490. if m.wx_wxid != nil {
  36491. fields = append(fields, wpchatroom.FieldWxWxid)
  36492. }
  36493. if m.chatroom_id != nil {
  36494. fields = append(fields, wpchatroom.FieldChatroomID)
  36495. }
  36496. if m.nickname != nil {
  36497. fields = append(fields, wpchatroom.FieldNickname)
  36498. }
  36499. if m.owner != nil {
  36500. fields = append(fields, wpchatroom.FieldOwner)
  36501. }
  36502. if m.avatar != nil {
  36503. fields = append(fields, wpchatroom.FieldAvatar)
  36504. }
  36505. if m.member_list != nil {
  36506. fields = append(fields, wpchatroom.FieldMemberList)
  36507. }
  36508. return fields
  36509. }
  36510. // Field returns the value of a field with the given name. The second boolean
  36511. // return value indicates that this field was not set, or was not defined in the
  36512. // schema.
  36513. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  36514. switch name {
  36515. case wpchatroom.FieldCreatedAt:
  36516. return m.CreatedAt()
  36517. case wpchatroom.FieldUpdatedAt:
  36518. return m.UpdatedAt()
  36519. case wpchatroom.FieldStatus:
  36520. return m.Status()
  36521. case wpchatroom.FieldWxWxid:
  36522. return m.WxWxid()
  36523. case wpchatroom.FieldChatroomID:
  36524. return m.ChatroomID()
  36525. case wpchatroom.FieldNickname:
  36526. return m.Nickname()
  36527. case wpchatroom.FieldOwner:
  36528. return m.Owner()
  36529. case wpchatroom.FieldAvatar:
  36530. return m.Avatar()
  36531. case wpchatroom.FieldMemberList:
  36532. return m.MemberList()
  36533. }
  36534. return nil, false
  36535. }
  36536. // OldField returns the old value of the field from the database. An error is
  36537. // returned if the mutation operation is not UpdateOne, or the query to the
  36538. // database failed.
  36539. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36540. switch name {
  36541. case wpchatroom.FieldCreatedAt:
  36542. return m.OldCreatedAt(ctx)
  36543. case wpchatroom.FieldUpdatedAt:
  36544. return m.OldUpdatedAt(ctx)
  36545. case wpchatroom.FieldStatus:
  36546. return m.OldStatus(ctx)
  36547. case wpchatroom.FieldWxWxid:
  36548. return m.OldWxWxid(ctx)
  36549. case wpchatroom.FieldChatroomID:
  36550. return m.OldChatroomID(ctx)
  36551. case wpchatroom.FieldNickname:
  36552. return m.OldNickname(ctx)
  36553. case wpchatroom.FieldOwner:
  36554. return m.OldOwner(ctx)
  36555. case wpchatroom.FieldAvatar:
  36556. return m.OldAvatar(ctx)
  36557. case wpchatroom.FieldMemberList:
  36558. return m.OldMemberList(ctx)
  36559. }
  36560. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  36561. }
  36562. // SetField sets the value of a field with the given name. It returns an error if
  36563. // the field is not defined in the schema, or if the type mismatched the field
  36564. // type.
  36565. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  36566. switch name {
  36567. case wpchatroom.FieldCreatedAt:
  36568. v, ok := value.(time.Time)
  36569. if !ok {
  36570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36571. }
  36572. m.SetCreatedAt(v)
  36573. return nil
  36574. case wpchatroom.FieldUpdatedAt:
  36575. v, ok := value.(time.Time)
  36576. if !ok {
  36577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36578. }
  36579. m.SetUpdatedAt(v)
  36580. return nil
  36581. case wpchatroom.FieldStatus:
  36582. v, ok := value.(uint8)
  36583. if !ok {
  36584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36585. }
  36586. m.SetStatus(v)
  36587. return nil
  36588. case wpchatroom.FieldWxWxid:
  36589. v, ok := value.(string)
  36590. if !ok {
  36591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36592. }
  36593. m.SetWxWxid(v)
  36594. return nil
  36595. case wpchatroom.FieldChatroomID:
  36596. v, ok := value.(string)
  36597. if !ok {
  36598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36599. }
  36600. m.SetChatroomID(v)
  36601. return nil
  36602. case wpchatroom.FieldNickname:
  36603. v, ok := value.(string)
  36604. if !ok {
  36605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36606. }
  36607. m.SetNickname(v)
  36608. return nil
  36609. case wpchatroom.FieldOwner:
  36610. v, ok := value.(string)
  36611. if !ok {
  36612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36613. }
  36614. m.SetOwner(v)
  36615. return nil
  36616. case wpchatroom.FieldAvatar:
  36617. v, ok := value.(string)
  36618. if !ok {
  36619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36620. }
  36621. m.SetAvatar(v)
  36622. return nil
  36623. case wpchatroom.FieldMemberList:
  36624. v, ok := value.([]string)
  36625. if !ok {
  36626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36627. }
  36628. m.SetMemberList(v)
  36629. return nil
  36630. }
  36631. return fmt.Errorf("unknown WpChatroom field %s", name)
  36632. }
  36633. // AddedFields returns all numeric fields that were incremented/decremented during
  36634. // this mutation.
  36635. func (m *WpChatroomMutation) AddedFields() []string {
  36636. var fields []string
  36637. if m.addstatus != nil {
  36638. fields = append(fields, wpchatroom.FieldStatus)
  36639. }
  36640. return fields
  36641. }
  36642. // AddedField returns the numeric value that was incremented/decremented on a field
  36643. // with the given name. The second boolean return value indicates that this field
  36644. // was not set, or was not defined in the schema.
  36645. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  36646. switch name {
  36647. case wpchatroom.FieldStatus:
  36648. return m.AddedStatus()
  36649. }
  36650. return nil, false
  36651. }
  36652. // AddField adds the value to the field with the given name. It returns an error if
  36653. // the field is not defined in the schema, or if the type mismatched the field
  36654. // type.
  36655. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  36656. switch name {
  36657. case wpchatroom.FieldStatus:
  36658. v, ok := value.(int8)
  36659. if !ok {
  36660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36661. }
  36662. m.AddStatus(v)
  36663. return nil
  36664. }
  36665. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  36666. }
  36667. // ClearedFields returns all nullable fields that were cleared during this
  36668. // mutation.
  36669. func (m *WpChatroomMutation) ClearedFields() []string {
  36670. var fields []string
  36671. if m.FieldCleared(wpchatroom.FieldStatus) {
  36672. fields = append(fields, wpchatroom.FieldStatus)
  36673. }
  36674. return fields
  36675. }
  36676. // FieldCleared returns a boolean indicating if a field with the given name was
  36677. // cleared in this mutation.
  36678. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  36679. _, ok := m.clearedFields[name]
  36680. return ok
  36681. }
  36682. // ClearField clears the value of the field with the given name. It returns an
  36683. // error if the field is not defined in the schema.
  36684. func (m *WpChatroomMutation) ClearField(name string) error {
  36685. switch name {
  36686. case wpchatroom.FieldStatus:
  36687. m.ClearStatus()
  36688. return nil
  36689. }
  36690. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  36691. }
  36692. // ResetField resets all changes in the mutation for the field with the given name.
  36693. // It returns an error if the field is not defined in the schema.
  36694. func (m *WpChatroomMutation) ResetField(name string) error {
  36695. switch name {
  36696. case wpchatroom.FieldCreatedAt:
  36697. m.ResetCreatedAt()
  36698. return nil
  36699. case wpchatroom.FieldUpdatedAt:
  36700. m.ResetUpdatedAt()
  36701. return nil
  36702. case wpchatroom.FieldStatus:
  36703. m.ResetStatus()
  36704. return nil
  36705. case wpchatroom.FieldWxWxid:
  36706. m.ResetWxWxid()
  36707. return nil
  36708. case wpchatroom.FieldChatroomID:
  36709. m.ResetChatroomID()
  36710. return nil
  36711. case wpchatroom.FieldNickname:
  36712. m.ResetNickname()
  36713. return nil
  36714. case wpchatroom.FieldOwner:
  36715. m.ResetOwner()
  36716. return nil
  36717. case wpchatroom.FieldAvatar:
  36718. m.ResetAvatar()
  36719. return nil
  36720. case wpchatroom.FieldMemberList:
  36721. m.ResetMemberList()
  36722. return nil
  36723. }
  36724. return fmt.Errorf("unknown WpChatroom field %s", name)
  36725. }
  36726. // AddedEdges returns all edge names that were set/added in this mutation.
  36727. func (m *WpChatroomMutation) AddedEdges() []string {
  36728. edges := make([]string, 0, 0)
  36729. return edges
  36730. }
  36731. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36732. // name in this mutation.
  36733. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  36734. return nil
  36735. }
  36736. // RemovedEdges returns all edge names that were removed in this mutation.
  36737. func (m *WpChatroomMutation) RemovedEdges() []string {
  36738. edges := make([]string, 0, 0)
  36739. return edges
  36740. }
  36741. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36742. // the given name in this mutation.
  36743. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  36744. return nil
  36745. }
  36746. // ClearedEdges returns all edge names that were cleared in this mutation.
  36747. func (m *WpChatroomMutation) ClearedEdges() []string {
  36748. edges := make([]string, 0, 0)
  36749. return edges
  36750. }
  36751. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36752. // was cleared in this mutation.
  36753. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  36754. return false
  36755. }
  36756. // ClearEdge clears the value of the edge with the given name. It returns an error
  36757. // if that edge is not defined in the schema.
  36758. func (m *WpChatroomMutation) ClearEdge(name string) error {
  36759. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  36760. }
  36761. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36762. // It returns an error if the edge is not defined in the schema.
  36763. func (m *WpChatroomMutation) ResetEdge(name string) error {
  36764. return fmt.Errorf("unknown WpChatroom edge %s", name)
  36765. }
  36766. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  36767. type WpChatroomMemberMutation struct {
  36768. config
  36769. op Op
  36770. typ string
  36771. id *uint64
  36772. created_at *time.Time
  36773. updated_at *time.Time
  36774. status *uint8
  36775. addstatus *int8
  36776. wx_wxid *string
  36777. wxid *string
  36778. nickname *string
  36779. avatar *string
  36780. clearedFields map[string]struct{}
  36781. done bool
  36782. oldValue func(context.Context) (*WpChatroomMember, error)
  36783. predicates []predicate.WpChatroomMember
  36784. }
  36785. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  36786. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  36787. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  36788. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  36789. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  36790. m := &WpChatroomMemberMutation{
  36791. config: c,
  36792. op: op,
  36793. typ: TypeWpChatroomMember,
  36794. clearedFields: make(map[string]struct{}),
  36795. }
  36796. for _, opt := range opts {
  36797. opt(m)
  36798. }
  36799. return m
  36800. }
  36801. // withWpChatroomMemberID sets the ID field of the mutation.
  36802. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  36803. return func(m *WpChatroomMemberMutation) {
  36804. var (
  36805. err error
  36806. once sync.Once
  36807. value *WpChatroomMember
  36808. )
  36809. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  36810. once.Do(func() {
  36811. if m.done {
  36812. err = errors.New("querying old values post mutation is not allowed")
  36813. } else {
  36814. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  36815. }
  36816. })
  36817. return value, err
  36818. }
  36819. m.id = &id
  36820. }
  36821. }
  36822. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  36823. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  36824. return func(m *WpChatroomMemberMutation) {
  36825. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  36826. return node, nil
  36827. }
  36828. m.id = &node.ID
  36829. }
  36830. }
  36831. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36832. // executed in a transaction (ent.Tx), a transactional client is returned.
  36833. func (m WpChatroomMemberMutation) Client() *Client {
  36834. client := &Client{config: m.config}
  36835. client.init()
  36836. return client
  36837. }
  36838. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36839. // it returns an error otherwise.
  36840. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  36841. if _, ok := m.driver.(*txDriver); !ok {
  36842. return nil, errors.New("ent: mutation is not running in a transaction")
  36843. }
  36844. tx := &Tx{config: m.config}
  36845. tx.init()
  36846. return tx, nil
  36847. }
  36848. // SetID sets the value of the id field. Note that this
  36849. // operation is only accepted on creation of WpChatroomMember entities.
  36850. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  36851. m.id = &id
  36852. }
  36853. // ID returns the ID value in the mutation. Note that the ID is only available
  36854. // if it was provided to the builder or after it was returned from the database.
  36855. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  36856. if m.id == nil {
  36857. return
  36858. }
  36859. return *m.id, true
  36860. }
  36861. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36862. // That means, if the mutation is applied within a transaction with an isolation level such
  36863. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36864. // or updated by the mutation.
  36865. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  36866. switch {
  36867. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36868. id, exists := m.ID()
  36869. if exists {
  36870. return []uint64{id}, nil
  36871. }
  36872. fallthrough
  36873. case m.op.Is(OpUpdate | OpDelete):
  36874. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  36875. default:
  36876. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36877. }
  36878. }
  36879. // SetCreatedAt sets the "created_at" field.
  36880. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  36881. m.created_at = &t
  36882. }
  36883. // CreatedAt returns the value of the "created_at" field in the mutation.
  36884. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  36885. v := m.created_at
  36886. if v == nil {
  36887. return
  36888. }
  36889. return *v, true
  36890. }
  36891. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  36892. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36894. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36895. if !m.op.Is(OpUpdateOne) {
  36896. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36897. }
  36898. if m.id == nil || m.oldValue == nil {
  36899. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36900. }
  36901. oldValue, err := m.oldValue(ctx)
  36902. if err != nil {
  36903. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36904. }
  36905. return oldValue.CreatedAt, nil
  36906. }
  36907. // ResetCreatedAt resets all changes to the "created_at" field.
  36908. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  36909. m.created_at = nil
  36910. }
  36911. // SetUpdatedAt sets the "updated_at" field.
  36912. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  36913. m.updated_at = &t
  36914. }
  36915. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36916. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  36917. v := m.updated_at
  36918. if v == nil {
  36919. return
  36920. }
  36921. return *v, true
  36922. }
  36923. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  36924. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36925. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36926. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36927. if !m.op.Is(OpUpdateOne) {
  36928. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36929. }
  36930. if m.id == nil || m.oldValue == nil {
  36931. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36932. }
  36933. oldValue, err := m.oldValue(ctx)
  36934. if err != nil {
  36935. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36936. }
  36937. return oldValue.UpdatedAt, nil
  36938. }
  36939. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36940. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  36941. m.updated_at = nil
  36942. }
  36943. // SetStatus sets the "status" field.
  36944. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  36945. m.status = &u
  36946. m.addstatus = nil
  36947. }
  36948. // Status returns the value of the "status" field in the mutation.
  36949. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  36950. v := m.status
  36951. if v == nil {
  36952. return
  36953. }
  36954. return *v, true
  36955. }
  36956. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  36957. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36959. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36960. if !m.op.Is(OpUpdateOne) {
  36961. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36962. }
  36963. if m.id == nil || m.oldValue == nil {
  36964. return v, errors.New("OldStatus requires an ID field in the mutation")
  36965. }
  36966. oldValue, err := m.oldValue(ctx)
  36967. if err != nil {
  36968. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36969. }
  36970. return oldValue.Status, nil
  36971. }
  36972. // AddStatus adds u to the "status" field.
  36973. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  36974. if m.addstatus != nil {
  36975. *m.addstatus += u
  36976. } else {
  36977. m.addstatus = &u
  36978. }
  36979. }
  36980. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36981. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  36982. v := m.addstatus
  36983. if v == nil {
  36984. return
  36985. }
  36986. return *v, true
  36987. }
  36988. // ClearStatus clears the value of the "status" field.
  36989. func (m *WpChatroomMemberMutation) ClearStatus() {
  36990. m.status = nil
  36991. m.addstatus = nil
  36992. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  36993. }
  36994. // StatusCleared returns if the "status" field was cleared in this mutation.
  36995. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  36996. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  36997. return ok
  36998. }
  36999. // ResetStatus resets all changes to the "status" field.
  37000. func (m *WpChatroomMemberMutation) ResetStatus() {
  37001. m.status = nil
  37002. m.addstatus = nil
  37003. delete(m.clearedFields, wpchatroommember.FieldStatus)
  37004. }
  37005. // SetWxWxid sets the "wx_wxid" field.
  37006. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  37007. m.wx_wxid = &s
  37008. }
  37009. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37010. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  37011. v := m.wx_wxid
  37012. if v == nil {
  37013. return
  37014. }
  37015. return *v, true
  37016. }
  37017. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  37018. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37019. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37020. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37021. if !m.op.Is(OpUpdateOne) {
  37022. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37023. }
  37024. if m.id == nil || m.oldValue == nil {
  37025. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37026. }
  37027. oldValue, err := m.oldValue(ctx)
  37028. if err != nil {
  37029. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37030. }
  37031. return oldValue.WxWxid, nil
  37032. }
  37033. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37034. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  37035. m.wx_wxid = nil
  37036. }
  37037. // SetWxid sets the "wxid" field.
  37038. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  37039. m.wxid = &s
  37040. }
  37041. // Wxid returns the value of the "wxid" field in the mutation.
  37042. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  37043. v := m.wxid
  37044. if v == nil {
  37045. return
  37046. }
  37047. return *v, true
  37048. }
  37049. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  37050. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37052. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  37053. if !m.op.Is(OpUpdateOne) {
  37054. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37055. }
  37056. if m.id == nil || m.oldValue == nil {
  37057. return v, errors.New("OldWxid requires an ID field in the mutation")
  37058. }
  37059. oldValue, err := m.oldValue(ctx)
  37060. if err != nil {
  37061. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37062. }
  37063. return oldValue.Wxid, nil
  37064. }
  37065. // ResetWxid resets all changes to the "wxid" field.
  37066. func (m *WpChatroomMemberMutation) ResetWxid() {
  37067. m.wxid = nil
  37068. }
  37069. // SetNickname sets the "nickname" field.
  37070. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  37071. m.nickname = &s
  37072. }
  37073. // Nickname returns the value of the "nickname" field in the mutation.
  37074. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  37075. v := m.nickname
  37076. if v == nil {
  37077. return
  37078. }
  37079. return *v, true
  37080. }
  37081. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  37082. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37084. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  37085. if !m.op.Is(OpUpdateOne) {
  37086. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37087. }
  37088. if m.id == nil || m.oldValue == nil {
  37089. return v, errors.New("OldNickname requires an ID field in the mutation")
  37090. }
  37091. oldValue, err := m.oldValue(ctx)
  37092. if err != nil {
  37093. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37094. }
  37095. return oldValue.Nickname, nil
  37096. }
  37097. // ResetNickname resets all changes to the "nickname" field.
  37098. func (m *WpChatroomMemberMutation) ResetNickname() {
  37099. m.nickname = nil
  37100. }
  37101. // SetAvatar sets the "avatar" field.
  37102. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  37103. m.avatar = &s
  37104. }
  37105. // Avatar returns the value of the "avatar" field in the mutation.
  37106. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  37107. v := m.avatar
  37108. if v == nil {
  37109. return
  37110. }
  37111. return *v, true
  37112. }
  37113. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  37114. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37116. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37117. if !m.op.Is(OpUpdateOne) {
  37118. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37119. }
  37120. if m.id == nil || m.oldValue == nil {
  37121. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37122. }
  37123. oldValue, err := m.oldValue(ctx)
  37124. if err != nil {
  37125. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37126. }
  37127. return oldValue.Avatar, nil
  37128. }
  37129. // ResetAvatar resets all changes to the "avatar" field.
  37130. func (m *WpChatroomMemberMutation) ResetAvatar() {
  37131. m.avatar = nil
  37132. }
  37133. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  37134. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  37135. m.predicates = append(m.predicates, ps...)
  37136. }
  37137. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  37138. // users can use type-assertion to append predicates that do not depend on any generated package.
  37139. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  37140. p := make([]predicate.WpChatroomMember, len(ps))
  37141. for i := range ps {
  37142. p[i] = ps[i]
  37143. }
  37144. m.Where(p...)
  37145. }
  37146. // Op returns the operation name.
  37147. func (m *WpChatroomMemberMutation) Op() Op {
  37148. return m.op
  37149. }
  37150. // SetOp allows setting the mutation operation.
  37151. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  37152. m.op = op
  37153. }
  37154. // Type returns the node type of this mutation (WpChatroomMember).
  37155. func (m *WpChatroomMemberMutation) Type() string {
  37156. return m.typ
  37157. }
  37158. // Fields returns all fields that were changed during this mutation. Note that in
  37159. // order to get all numeric fields that were incremented/decremented, call
  37160. // AddedFields().
  37161. func (m *WpChatroomMemberMutation) Fields() []string {
  37162. fields := make([]string, 0, 7)
  37163. if m.created_at != nil {
  37164. fields = append(fields, wpchatroommember.FieldCreatedAt)
  37165. }
  37166. if m.updated_at != nil {
  37167. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  37168. }
  37169. if m.status != nil {
  37170. fields = append(fields, wpchatroommember.FieldStatus)
  37171. }
  37172. if m.wx_wxid != nil {
  37173. fields = append(fields, wpchatroommember.FieldWxWxid)
  37174. }
  37175. if m.wxid != nil {
  37176. fields = append(fields, wpchatroommember.FieldWxid)
  37177. }
  37178. if m.nickname != nil {
  37179. fields = append(fields, wpchatroommember.FieldNickname)
  37180. }
  37181. if m.avatar != nil {
  37182. fields = append(fields, wpchatroommember.FieldAvatar)
  37183. }
  37184. return fields
  37185. }
  37186. // Field returns the value of a field with the given name. The second boolean
  37187. // return value indicates that this field was not set, or was not defined in the
  37188. // schema.
  37189. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  37190. switch name {
  37191. case wpchatroommember.FieldCreatedAt:
  37192. return m.CreatedAt()
  37193. case wpchatroommember.FieldUpdatedAt:
  37194. return m.UpdatedAt()
  37195. case wpchatroommember.FieldStatus:
  37196. return m.Status()
  37197. case wpchatroommember.FieldWxWxid:
  37198. return m.WxWxid()
  37199. case wpchatroommember.FieldWxid:
  37200. return m.Wxid()
  37201. case wpchatroommember.FieldNickname:
  37202. return m.Nickname()
  37203. case wpchatroommember.FieldAvatar:
  37204. return m.Avatar()
  37205. }
  37206. return nil, false
  37207. }
  37208. // OldField returns the old value of the field from the database. An error is
  37209. // returned if the mutation operation is not UpdateOne, or the query to the
  37210. // database failed.
  37211. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37212. switch name {
  37213. case wpchatroommember.FieldCreatedAt:
  37214. return m.OldCreatedAt(ctx)
  37215. case wpchatroommember.FieldUpdatedAt:
  37216. return m.OldUpdatedAt(ctx)
  37217. case wpchatroommember.FieldStatus:
  37218. return m.OldStatus(ctx)
  37219. case wpchatroommember.FieldWxWxid:
  37220. return m.OldWxWxid(ctx)
  37221. case wpchatroommember.FieldWxid:
  37222. return m.OldWxid(ctx)
  37223. case wpchatroommember.FieldNickname:
  37224. return m.OldNickname(ctx)
  37225. case wpchatroommember.FieldAvatar:
  37226. return m.OldAvatar(ctx)
  37227. }
  37228. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  37229. }
  37230. // SetField sets the value of a field with the given name. It returns an error if
  37231. // the field is not defined in the schema, or if the type mismatched the field
  37232. // type.
  37233. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  37234. switch name {
  37235. case wpchatroommember.FieldCreatedAt:
  37236. v, ok := value.(time.Time)
  37237. if !ok {
  37238. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37239. }
  37240. m.SetCreatedAt(v)
  37241. return nil
  37242. case wpchatroommember.FieldUpdatedAt:
  37243. v, ok := value.(time.Time)
  37244. if !ok {
  37245. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37246. }
  37247. m.SetUpdatedAt(v)
  37248. return nil
  37249. case wpchatroommember.FieldStatus:
  37250. v, ok := value.(uint8)
  37251. if !ok {
  37252. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37253. }
  37254. m.SetStatus(v)
  37255. return nil
  37256. case wpchatroommember.FieldWxWxid:
  37257. v, ok := value.(string)
  37258. if !ok {
  37259. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37260. }
  37261. m.SetWxWxid(v)
  37262. return nil
  37263. case wpchatroommember.FieldWxid:
  37264. v, ok := value.(string)
  37265. if !ok {
  37266. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37267. }
  37268. m.SetWxid(v)
  37269. return nil
  37270. case wpchatroommember.FieldNickname:
  37271. v, ok := value.(string)
  37272. if !ok {
  37273. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37274. }
  37275. m.SetNickname(v)
  37276. return nil
  37277. case wpchatroommember.FieldAvatar:
  37278. v, ok := value.(string)
  37279. if !ok {
  37280. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37281. }
  37282. m.SetAvatar(v)
  37283. return nil
  37284. }
  37285. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37286. }
  37287. // AddedFields returns all numeric fields that were incremented/decremented during
  37288. // this mutation.
  37289. func (m *WpChatroomMemberMutation) AddedFields() []string {
  37290. var fields []string
  37291. if m.addstatus != nil {
  37292. fields = append(fields, wpchatroommember.FieldStatus)
  37293. }
  37294. return fields
  37295. }
  37296. // AddedField returns the numeric value that was incremented/decremented on a field
  37297. // with the given name. The second boolean return value indicates that this field
  37298. // was not set, or was not defined in the schema.
  37299. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  37300. switch name {
  37301. case wpchatroommember.FieldStatus:
  37302. return m.AddedStatus()
  37303. }
  37304. return nil, false
  37305. }
  37306. // AddField adds the value to the field with the given name. It returns an error if
  37307. // the field is not defined in the schema, or if the type mismatched the field
  37308. // type.
  37309. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  37310. switch name {
  37311. case wpchatroommember.FieldStatus:
  37312. v, ok := value.(int8)
  37313. if !ok {
  37314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37315. }
  37316. m.AddStatus(v)
  37317. return nil
  37318. }
  37319. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  37320. }
  37321. // ClearedFields returns all nullable fields that were cleared during this
  37322. // mutation.
  37323. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  37324. var fields []string
  37325. if m.FieldCleared(wpchatroommember.FieldStatus) {
  37326. fields = append(fields, wpchatroommember.FieldStatus)
  37327. }
  37328. return fields
  37329. }
  37330. // FieldCleared returns a boolean indicating if a field with the given name was
  37331. // cleared in this mutation.
  37332. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  37333. _, ok := m.clearedFields[name]
  37334. return ok
  37335. }
  37336. // ClearField clears the value of the field with the given name. It returns an
  37337. // error if the field is not defined in the schema.
  37338. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  37339. switch name {
  37340. case wpchatroommember.FieldStatus:
  37341. m.ClearStatus()
  37342. return nil
  37343. }
  37344. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  37345. }
  37346. // ResetField resets all changes in the mutation for the field with the given name.
  37347. // It returns an error if the field is not defined in the schema.
  37348. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  37349. switch name {
  37350. case wpchatroommember.FieldCreatedAt:
  37351. m.ResetCreatedAt()
  37352. return nil
  37353. case wpchatroommember.FieldUpdatedAt:
  37354. m.ResetUpdatedAt()
  37355. return nil
  37356. case wpchatroommember.FieldStatus:
  37357. m.ResetStatus()
  37358. return nil
  37359. case wpchatroommember.FieldWxWxid:
  37360. m.ResetWxWxid()
  37361. return nil
  37362. case wpchatroommember.FieldWxid:
  37363. m.ResetWxid()
  37364. return nil
  37365. case wpchatroommember.FieldNickname:
  37366. m.ResetNickname()
  37367. return nil
  37368. case wpchatroommember.FieldAvatar:
  37369. m.ResetAvatar()
  37370. return nil
  37371. }
  37372. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37373. }
  37374. // AddedEdges returns all edge names that were set/added in this mutation.
  37375. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  37376. edges := make([]string, 0, 0)
  37377. return edges
  37378. }
  37379. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37380. // name in this mutation.
  37381. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  37382. return nil
  37383. }
  37384. // RemovedEdges returns all edge names that were removed in this mutation.
  37385. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  37386. edges := make([]string, 0, 0)
  37387. return edges
  37388. }
  37389. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37390. // the given name in this mutation.
  37391. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  37392. return nil
  37393. }
  37394. // ClearedEdges returns all edge names that were cleared in this mutation.
  37395. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  37396. edges := make([]string, 0, 0)
  37397. return edges
  37398. }
  37399. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37400. // was cleared in this mutation.
  37401. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  37402. return false
  37403. }
  37404. // ClearEdge clears the value of the edge with the given name. It returns an error
  37405. // if that edge is not defined in the schema.
  37406. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  37407. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  37408. }
  37409. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37410. // It returns an error if the edge is not defined in the schema.
  37411. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  37412. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  37413. }
  37414. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  37415. type WxMutation struct {
  37416. config
  37417. op Op
  37418. typ string
  37419. id *uint64
  37420. created_at *time.Time
  37421. updated_at *time.Time
  37422. status *uint8
  37423. addstatus *int8
  37424. deleted_at *time.Time
  37425. port *string
  37426. process_id *string
  37427. callback *string
  37428. wxid *string
  37429. account *string
  37430. nickname *string
  37431. tel *string
  37432. head_big *string
  37433. organization_id *uint64
  37434. addorganization_id *int64
  37435. api_base *string
  37436. api_key *string
  37437. allow_list *[]string
  37438. appendallow_list []string
  37439. group_allow_list *[]string
  37440. appendgroup_allow_list []string
  37441. block_list *[]string
  37442. appendblock_list []string
  37443. group_block_list *[]string
  37444. appendgroup_block_list []string
  37445. clearedFields map[string]struct{}
  37446. server *uint64
  37447. clearedserver bool
  37448. agent *uint64
  37449. clearedagent bool
  37450. done bool
  37451. oldValue func(context.Context) (*Wx, error)
  37452. predicates []predicate.Wx
  37453. }
  37454. var _ ent.Mutation = (*WxMutation)(nil)
  37455. // wxOption allows management of the mutation configuration using functional options.
  37456. type wxOption func(*WxMutation)
  37457. // newWxMutation creates new mutation for the Wx entity.
  37458. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  37459. m := &WxMutation{
  37460. config: c,
  37461. op: op,
  37462. typ: TypeWx,
  37463. clearedFields: make(map[string]struct{}),
  37464. }
  37465. for _, opt := range opts {
  37466. opt(m)
  37467. }
  37468. return m
  37469. }
  37470. // withWxID sets the ID field of the mutation.
  37471. func withWxID(id uint64) wxOption {
  37472. return func(m *WxMutation) {
  37473. var (
  37474. err error
  37475. once sync.Once
  37476. value *Wx
  37477. )
  37478. m.oldValue = func(ctx context.Context) (*Wx, error) {
  37479. once.Do(func() {
  37480. if m.done {
  37481. err = errors.New("querying old values post mutation is not allowed")
  37482. } else {
  37483. value, err = m.Client().Wx.Get(ctx, id)
  37484. }
  37485. })
  37486. return value, err
  37487. }
  37488. m.id = &id
  37489. }
  37490. }
  37491. // withWx sets the old Wx of the mutation.
  37492. func withWx(node *Wx) wxOption {
  37493. return func(m *WxMutation) {
  37494. m.oldValue = func(context.Context) (*Wx, error) {
  37495. return node, nil
  37496. }
  37497. m.id = &node.ID
  37498. }
  37499. }
  37500. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37501. // executed in a transaction (ent.Tx), a transactional client is returned.
  37502. func (m WxMutation) Client() *Client {
  37503. client := &Client{config: m.config}
  37504. client.init()
  37505. return client
  37506. }
  37507. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37508. // it returns an error otherwise.
  37509. func (m WxMutation) Tx() (*Tx, error) {
  37510. if _, ok := m.driver.(*txDriver); !ok {
  37511. return nil, errors.New("ent: mutation is not running in a transaction")
  37512. }
  37513. tx := &Tx{config: m.config}
  37514. tx.init()
  37515. return tx, nil
  37516. }
  37517. // SetID sets the value of the id field. Note that this
  37518. // operation is only accepted on creation of Wx entities.
  37519. func (m *WxMutation) SetID(id uint64) {
  37520. m.id = &id
  37521. }
  37522. // ID returns the ID value in the mutation. Note that the ID is only available
  37523. // if it was provided to the builder or after it was returned from the database.
  37524. func (m *WxMutation) ID() (id uint64, exists bool) {
  37525. if m.id == nil {
  37526. return
  37527. }
  37528. return *m.id, true
  37529. }
  37530. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37531. // That means, if the mutation is applied within a transaction with an isolation level such
  37532. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37533. // or updated by the mutation.
  37534. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  37535. switch {
  37536. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37537. id, exists := m.ID()
  37538. if exists {
  37539. return []uint64{id}, nil
  37540. }
  37541. fallthrough
  37542. case m.op.Is(OpUpdate | OpDelete):
  37543. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  37544. default:
  37545. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37546. }
  37547. }
  37548. // SetCreatedAt sets the "created_at" field.
  37549. func (m *WxMutation) SetCreatedAt(t time.Time) {
  37550. m.created_at = &t
  37551. }
  37552. // CreatedAt returns the value of the "created_at" field in the mutation.
  37553. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  37554. v := m.created_at
  37555. if v == nil {
  37556. return
  37557. }
  37558. return *v, true
  37559. }
  37560. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  37561. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37563. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37564. if !m.op.Is(OpUpdateOne) {
  37565. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37566. }
  37567. if m.id == nil || m.oldValue == nil {
  37568. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37569. }
  37570. oldValue, err := m.oldValue(ctx)
  37571. if err != nil {
  37572. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37573. }
  37574. return oldValue.CreatedAt, nil
  37575. }
  37576. // ResetCreatedAt resets all changes to the "created_at" field.
  37577. func (m *WxMutation) ResetCreatedAt() {
  37578. m.created_at = nil
  37579. }
  37580. // SetUpdatedAt sets the "updated_at" field.
  37581. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  37582. m.updated_at = &t
  37583. }
  37584. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37585. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  37586. v := m.updated_at
  37587. if v == nil {
  37588. return
  37589. }
  37590. return *v, true
  37591. }
  37592. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  37593. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37594. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37595. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37596. if !m.op.Is(OpUpdateOne) {
  37597. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37598. }
  37599. if m.id == nil || m.oldValue == nil {
  37600. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37601. }
  37602. oldValue, err := m.oldValue(ctx)
  37603. if err != nil {
  37604. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37605. }
  37606. return oldValue.UpdatedAt, nil
  37607. }
  37608. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37609. func (m *WxMutation) ResetUpdatedAt() {
  37610. m.updated_at = nil
  37611. }
  37612. // SetStatus sets the "status" field.
  37613. func (m *WxMutation) SetStatus(u uint8) {
  37614. m.status = &u
  37615. m.addstatus = nil
  37616. }
  37617. // Status returns the value of the "status" field in the mutation.
  37618. func (m *WxMutation) Status() (r uint8, exists bool) {
  37619. v := m.status
  37620. if v == nil {
  37621. return
  37622. }
  37623. return *v, true
  37624. }
  37625. // OldStatus returns the old "status" field's value of the Wx entity.
  37626. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37627. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37628. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37629. if !m.op.Is(OpUpdateOne) {
  37630. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37631. }
  37632. if m.id == nil || m.oldValue == nil {
  37633. return v, errors.New("OldStatus requires an ID field in the mutation")
  37634. }
  37635. oldValue, err := m.oldValue(ctx)
  37636. if err != nil {
  37637. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37638. }
  37639. return oldValue.Status, nil
  37640. }
  37641. // AddStatus adds u to the "status" field.
  37642. func (m *WxMutation) AddStatus(u int8) {
  37643. if m.addstatus != nil {
  37644. *m.addstatus += u
  37645. } else {
  37646. m.addstatus = &u
  37647. }
  37648. }
  37649. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37650. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  37651. v := m.addstatus
  37652. if v == nil {
  37653. return
  37654. }
  37655. return *v, true
  37656. }
  37657. // ClearStatus clears the value of the "status" field.
  37658. func (m *WxMutation) ClearStatus() {
  37659. m.status = nil
  37660. m.addstatus = nil
  37661. m.clearedFields[wx.FieldStatus] = struct{}{}
  37662. }
  37663. // StatusCleared returns if the "status" field was cleared in this mutation.
  37664. func (m *WxMutation) StatusCleared() bool {
  37665. _, ok := m.clearedFields[wx.FieldStatus]
  37666. return ok
  37667. }
  37668. // ResetStatus resets all changes to the "status" field.
  37669. func (m *WxMutation) ResetStatus() {
  37670. m.status = nil
  37671. m.addstatus = nil
  37672. delete(m.clearedFields, wx.FieldStatus)
  37673. }
  37674. // SetDeletedAt sets the "deleted_at" field.
  37675. func (m *WxMutation) SetDeletedAt(t time.Time) {
  37676. m.deleted_at = &t
  37677. }
  37678. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37679. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  37680. v := m.deleted_at
  37681. if v == nil {
  37682. return
  37683. }
  37684. return *v, true
  37685. }
  37686. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  37687. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37689. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37690. if !m.op.Is(OpUpdateOne) {
  37691. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37692. }
  37693. if m.id == nil || m.oldValue == nil {
  37694. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37695. }
  37696. oldValue, err := m.oldValue(ctx)
  37697. if err != nil {
  37698. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37699. }
  37700. return oldValue.DeletedAt, nil
  37701. }
  37702. // ClearDeletedAt clears the value of the "deleted_at" field.
  37703. func (m *WxMutation) ClearDeletedAt() {
  37704. m.deleted_at = nil
  37705. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  37706. }
  37707. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37708. func (m *WxMutation) DeletedAtCleared() bool {
  37709. _, ok := m.clearedFields[wx.FieldDeletedAt]
  37710. return ok
  37711. }
  37712. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37713. func (m *WxMutation) ResetDeletedAt() {
  37714. m.deleted_at = nil
  37715. delete(m.clearedFields, wx.FieldDeletedAt)
  37716. }
  37717. // SetServerID sets the "server_id" field.
  37718. func (m *WxMutation) SetServerID(u uint64) {
  37719. m.server = &u
  37720. }
  37721. // ServerID returns the value of the "server_id" field in the mutation.
  37722. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  37723. v := m.server
  37724. if v == nil {
  37725. return
  37726. }
  37727. return *v, true
  37728. }
  37729. // OldServerID returns the old "server_id" field's value of the Wx entity.
  37730. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37732. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  37733. if !m.op.Is(OpUpdateOne) {
  37734. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  37735. }
  37736. if m.id == nil || m.oldValue == nil {
  37737. return v, errors.New("OldServerID requires an ID field in the mutation")
  37738. }
  37739. oldValue, err := m.oldValue(ctx)
  37740. if err != nil {
  37741. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  37742. }
  37743. return oldValue.ServerID, nil
  37744. }
  37745. // ClearServerID clears the value of the "server_id" field.
  37746. func (m *WxMutation) ClearServerID() {
  37747. m.server = nil
  37748. m.clearedFields[wx.FieldServerID] = struct{}{}
  37749. }
  37750. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  37751. func (m *WxMutation) ServerIDCleared() bool {
  37752. _, ok := m.clearedFields[wx.FieldServerID]
  37753. return ok
  37754. }
  37755. // ResetServerID resets all changes to the "server_id" field.
  37756. func (m *WxMutation) ResetServerID() {
  37757. m.server = nil
  37758. delete(m.clearedFields, wx.FieldServerID)
  37759. }
  37760. // SetPort sets the "port" field.
  37761. func (m *WxMutation) SetPort(s string) {
  37762. m.port = &s
  37763. }
  37764. // Port returns the value of the "port" field in the mutation.
  37765. func (m *WxMutation) Port() (r string, exists bool) {
  37766. v := m.port
  37767. if v == nil {
  37768. return
  37769. }
  37770. return *v, true
  37771. }
  37772. // OldPort returns the old "port" field's value of the Wx entity.
  37773. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37775. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  37776. if !m.op.Is(OpUpdateOne) {
  37777. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  37778. }
  37779. if m.id == nil || m.oldValue == nil {
  37780. return v, errors.New("OldPort requires an ID field in the mutation")
  37781. }
  37782. oldValue, err := m.oldValue(ctx)
  37783. if err != nil {
  37784. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  37785. }
  37786. return oldValue.Port, nil
  37787. }
  37788. // ResetPort resets all changes to the "port" field.
  37789. func (m *WxMutation) ResetPort() {
  37790. m.port = nil
  37791. }
  37792. // SetProcessID sets the "process_id" field.
  37793. func (m *WxMutation) SetProcessID(s string) {
  37794. m.process_id = &s
  37795. }
  37796. // ProcessID returns the value of the "process_id" field in the mutation.
  37797. func (m *WxMutation) ProcessID() (r string, exists bool) {
  37798. v := m.process_id
  37799. if v == nil {
  37800. return
  37801. }
  37802. return *v, true
  37803. }
  37804. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  37805. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37806. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37807. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  37808. if !m.op.Is(OpUpdateOne) {
  37809. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  37810. }
  37811. if m.id == nil || m.oldValue == nil {
  37812. return v, errors.New("OldProcessID requires an ID field in the mutation")
  37813. }
  37814. oldValue, err := m.oldValue(ctx)
  37815. if err != nil {
  37816. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  37817. }
  37818. return oldValue.ProcessID, nil
  37819. }
  37820. // ResetProcessID resets all changes to the "process_id" field.
  37821. func (m *WxMutation) ResetProcessID() {
  37822. m.process_id = nil
  37823. }
  37824. // SetCallback sets the "callback" field.
  37825. func (m *WxMutation) SetCallback(s string) {
  37826. m.callback = &s
  37827. }
  37828. // Callback returns the value of the "callback" field in the mutation.
  37829. func (m *WxMutation) Callback() (r string, exists bool) {
  37830. v := m.callback
  37831. if v == nil {
  37832. return
  37833. }
  37834. return *v, true
  37835. }
  37836. // OldCallback returns the old "callback" field's value of the Wx entity.
  37837. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37838. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37839. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  37840. if !m.op.Is(OpUpdateOne) {
  37841. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37842. }
  37843. if m.id == nil || m.oldValue == nil {
  37844. return v, errors.New("OldCallback requires an ID field in the mutation")
  37845. }
  37846. oldValue, err := m.oldValue(ctx)
  37847. if err != nil {
  37848. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37849. }
  37850. return oldValue.Callback, nil
  37851. }
  37852. // ResetCallback resets all changes to the "callback" field.
  37853. func (m *WxMutation) ResetCallback() {
  37854. m.callback = nil
  37855. }
  37856. // SetWxid sets the "wxid" field.
  37857. func (m *WxMutation) SetWxid(s string) {
  37858. m.wxid = &s
  37859. }
  37860. // Wxid returns the value of the "wxid" field in the mutation.
  37861. func (m *WxMutation) Wxid() (r string, exists bool) {
  37862. v := m.wxid
  37863. if v == nil {
  37864. return
  37865. }
  37866. return *v, true
  37867. }
  37868. // OldWxid returns the old "wxid" field's value of the Wx entity.
  37869. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37871. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  37872. if !m.op.Is(OpUpdateOne) {
  37873. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37874. }
  37875. if m.id == nil || m.oldValue == nil {
  37876. return v, errors.New("OldWxid requires an ID field in the mutation")
  37877. }
  37878. oldValue, err := m.oldValue(ctx)
  37879. if err != nil {
  37880. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37881. }
  37882. return oldValue.Wxid, nil
  37883. }
  37884. // ResetWxid resets all changes to the "wxid" field.
  37885. func (m *WxMutation) ResetWxid() {
  37886. m.wxid = nil
  37887. }
  37888. // SetAccount sets the "account" field.
  37889. func (m *WxMutation) SetAccount(s string) {
  37890. m.account = &s
  37891. }
  37892. // Account returns the value of the "account" field in the mutation.
  37893. func (m *WxMutation) Account() (r string, exists bool) {
  37894. v := m.account
  37895. if v == nil {
  37896. return
  37897. }
  37898. return *v, true
  37899. }
  37900. // OldAccount returns the old "account" field's value of the Wx entity.
  37901. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37902. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37903. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  37904. if !m.op.Is(OpUpdateOne) {
  37905. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37906. }
  37907. if m.id == nil || m.oldValue == nil {
  37908. return v, errors.New("OldAccount requires an ID field in the mutation")
  37909. }
  37910. oldValue, err := m.oldValue(ctx)
  37911. if err != nil {
  37912. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37913. }
  37914. return oldValue.Account, nil
  37915. }
  37916. // ResetAccount resets all changes to the "account" field.
  37917. func (m *WxMutation) ResetAccount() {
  37918. m.account = nil
  37919. }
  37920. // SetNickname sets the "nickname" field.
  37921. func (m *WxMutation) SetNickname(s string) {
  37922. m.nickname = &s
  37923. }
  37924. // Nickname returns the value of the "nickname" field in the mutation.
  37925. func (m *WxMutation) Nickname() (r string, exists bool) {
  37926. v := m.nickname
  37927. if v == nil {
  37928. return
  37929. }
  37930. return *v, true
  37931. }
  37932. // OldNickname returns the old "nickname" field's value of the Wx entity.
  37933. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37935. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  37936. if !m.op.Is(OpUpdateOne) {
  37937. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37938. }
  37939. if m.id == nil || m.oldValue == nil {
  37940. return v, errors.New("OldNickname requires an ID field in the mutation")
  37941. }
  37942. oldValue, err := m.oldValue(ctx)
  37943. if err != nil {
  37944. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37945. }
  37946. return oldValue.Nickname, nil
  37947. }
  37948. // ResetNickname resets all changes to the "nickname" field.
  37949. func (m *WxMutation) ResetNickname() {
  37950. m.nickname = nil
  37951. }
  37952. // SetTel sets the "tel" field.
  37953. func (m *WxMutation) SetTel(s string) {
  37954. m.tel = &s
  37955. }
  37956. // Tel returns the value of the "tel" field in the mutation.
  37957. func (m *WxMutation) Tel() (r string, exists bool) {
  37958. v := m.tel
  37959. if v == nil {
  37960. return
  37961. }
  37962. return *v, true
  37963. }
  37964. // OldTel returns the old "tel" field's value of the Wx entity.
  37965. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37967. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  37968. if !m.op.Is(OpUpdateOne) {
  37969. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  37970. }
  37971. if m.id == nil || m.oldValue == nil {
  37972. return v, errors.New("OldTel requires an ID field in the mutation")
  37973. }
  37974. oldValue, err := m.oldValue(ctx)
  37975. if err != nil {
  37976. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  37977. }
  37978. return oldValue.Tel, nil
  37979. }
  37980. // ResetTel resets all changes to the "tel" field.
  37981. func (m *WxMutation) ResetTel() {
  37982. m.tel = nil
  37983. }
  37984. // SetHeadBig sets the "head_big" field.
  37985. func (m *WxMutation) SetHeadBig(s string) {
  37986. m.head_big = &s
  37987. }
  37988. // HeadBig returns the value of the "head_big" field in the mutation.
  37989. func (m *WxMutation) HeadBig() (r string, exists bool) {
  37990. v := m.head_big
  37991. if v == nil {
  37992. return
  37993. }
  37994. return *v, true
  37995. }
  37996. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  37997. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37999. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  38000. if !m.op.Is(OpUpdateOne) {
  38001. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  38002. }
  38003. if m.id == nil || m.oldValue == nil {
  38004. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  38005. }
  38006. oldValue, err := m.oldValue(ctx)
  38007. if err != nil {
  38008. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  38009. }
  38010. return oldValue.HeadBig, nil
  38011. }
  38012. // ResetHeadBig resets all changes to the "head_big" field.
  38013. func (m *WxMutation) ResetHeadBig() {
  38014. m.head_big = nil
  38015. }
  38016. // SetOrganizationID sets the "organization_id" field.
  38017. func (m *WxMutation) SetOrganizationID(u uint64) {
  38018. m.organization_id = &u
  38019. m.addorganization_id = nil
  38020. }
  38021. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38022. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  38023. v := m.organization_id
  38024. if v == nil {
  38025. return
  38026. }
  38027. return *v, true
  38028. }
  38029. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  38030. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38032. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38033. if !m.op.Is(OpUpdateOne) {
  38034. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38035. }
  38036. if m.id == nil || m.oldValue == nil {
  38037. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38038. }
  38039. oldValue, err := m.oldValue(ctx)
  38040. if err != nil {
  38041. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38042. }
  38043. return oldValue.OrganizationID, nil
  38044. }
  38045. // AddOrganizationID adds u to the "organization_id" field.
  38046. func (m *WxMutation) AddOrganizationID(u int64) {
  38047. if m.addorganization_id != nil {
  38048. *m.addorganization_id += u
  38049. } else {
  38050. m.addorganization_id = &u
  38051. }
  38052. }
  38053. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38054. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  38055. v := m.addorganization_id
  38056. if v == nil {
  38057. return
  38058. }
  38059. return *v, true
  38060. }
  38061. // ClearOrganizationID clears the value of the "organization_id" field.
  38062. func (m *WxMutation) ClearOrganizationID() {
  38063. m.organization_id = nil
  38064. m.addorganization_id = nil
  38065. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  38066. }
  38067. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38068. func (m *WxMutation) OrganizationIDCleared() bool {
  38069. _, ok := m.clearedFields[wx.FieldOrganizationID]
  38070. return ok
  38071. }
  38072. // ResetOrganizationID resets all changes to the "organization_id" field.
  38073. func (m *WxMutation) ResetOrganizationID() {
  38074. m.organization_id = nil
  38075. m.addorganization_id = nil
  38076. delete(m.clearedFields, wx.FieldOrganizationID)
  38077. }
  38078. // SetAgentID sets the "agent_id" field.
  38079. func (m *WxMutation) SetAgentID(u uint64) {
  38080. m.agent = &u
  38081. }
  38082. // AgentID returns the value of the "agent_id" field in the mutation.
  38083. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  38084. v := m.agent
  38085. if v == nil {
  38086. return
  38087. }
  38088. return *v, true
  38089. }
  38090. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  38091. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38093. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38094. if !m.op.Is(OpUpdateOne) {
  38095. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38096. }
  38097. if m.id == nil || m.oldValue == nil {
  38098. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38099. }
  38100. oldValue, err := m.oldValue(ctx)
  38101. if err != nil {
  38102. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38103. }
  38104. return oldValue.AgentID, nil
  38105. }
  38106. // ResetAgentID resets all changes to the "agent_id" field.
  38107. func (m *WxMutation) ResetAgentID() {
  38108. m.agent = nil
  38109. }
  38110. // SetAPIBase sets the "api_base" field.
  38111. func (m *WxMutation) SetAPIBase(s string) {
  38112. m.api_base = &s
  38113. }
  38114. // APIBase returns the value of the "api_base" field in the mutation.
  38115. func (m *WxMutation) APIBase() (r string, exists bool) {
  38116. v := m.api_base
  38117. if v == nil {
  38118. return
  38119. }
  38120. return *v, true
  38121. }
  38122. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  38123. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38125. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38126. if !m.op.Is(OpUpdateOne) {
  38127. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38128. }
  38129. if m.id == nil || m.oldValue == nil {
  38130. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38131. }
  38132. oldValue, err := m.oldValue(ctx)
  38133. if err != nil {
  38134. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38135. }
  38136. return oldValue.APIBase, nil
  38137. }
  38138. // ClearAPIBase clears the value of the "api_base" field.
  38139. func (m *WxMutation) ClearAPIBase() {
  38140. m.api_base = nil
  38141. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  38142. }
  38143. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38144. func (m *WxMutation) APIBaseCleared() bool {
  38145. _, ok := m.clearedFields[wx.FieldAPIBase]
  38146. return ok
  38147. }
  38148. // ResetAPIBase resets all changes to the "api_base" field.
  38149. func (m *WxMutation) ResetAPIBase() {
  38150. m.api_base = nil
  38151. delete(m.clearedFields, wx.FieldAPIBase)
  38152. }
  38153. // SetAPIKey sets the "api_key" field.
  38154. func (m *WxMutation) SetAPIKey(s string) {
  38155. m.api_key = &s
  38156. }
  38157. // APIKey returns the value of the "api_key" field in the mutation.
  38158. func (m *WxMutation) APIKey() (r string, exists bool) {
  38159. v := m.api_key
  38160. if v == nil {
  38161. return
  38162. }
  38163. return *v, true
  38164. }
  38165. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  38166. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38167. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38168. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38169. if !m.op.Is(OpUpdateOne) {
  38170. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38171. }
  38172. if m.id == nil || m.oldValue == nil {
  38173. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38174. }
  38175. oldValue, err := m.oldValue(ctx)
  38176. if err != nil {
  38177. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38178. }
  38179. return oldValue.APIKey, nil
  38180. }
  38181. // ClearAPIKey clears the value of the "api_key" field.
  38182. func (m *WxMutation) ClearAPIKey() {
  38183. m.api_key = nil
  38184. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  38185. }
  38186. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38187. func (m *WxMutation) APIKeyCleared() bool {
  38188. _, ok := m.clearedFields[wx.FieldAPIKey]
  38189. return ok
  38190. }
  38191. // ResetAPIKey resets all changes to the "api_key" field.
  38192. func (m *WxMutation) ResetAPIKey() {
  38193. m.api_key = nil
  38194. delete(m.clearedFields, wx.FieldAPIKey)
  38195. }
  38196. // SetAllowList sets the "allow_list" field.
  38197. func (m *WxMutation) SetAllowList(s []string) {
  38198. m.allow_list = &s
  38199. m.appendallow_list = nil
  38200. }
  38201. // AllowList returns the value of the "allow_list" field in the mutation.
  38202. func (m *WxMutation) AllowList() (r []string, exists bool) {
  38203. v := m.allow_list
  38204. if v == nil {
  38205. return
  38206. }
  38207. return *v, true
  38208. }
  38209. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  38210. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38212. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38213. if !m.op.Is(OpUpdateOne) {
  38214. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38215. }
  38216. if m.id == nil || m.oldValue == nil {
  38217. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38218. }
  38219. oldValue, err := m.oldValue(ctx)
  38220. if err != nil {
  38221. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38222. }
  38223. return oldValue.AllowList, nil
  38224. }
  38225. // AppendAllowList adds s to the "allow_list" field.
  38226. func (m *WxMutation) AppendAllowList(s []string) {
  38227. m.appendallow_list = append(m.appendallow_list, s...)
  38228. }
  38229. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38230. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  38231. if len(m.appendallow_list) == 0 {
  38232. return nil, false
  38233. }
  38234. return m.appendallow_list, true
  38235. }
  38236. // ResetAllowList resets all changes to the "allow_list" field.
  38237. func (m *WxMutation) ResetAllowList() {
  38238. m.allow_list = nil
  38239. m.appendallow_list = nil
  38240. }
  38241. // SetGroupAllowList sets the "group_allow_list" field.
  38242. func (m *WxMutation) SetGroupAllowList(s []string) {
  38243. m.group_allow_list = &s
  38244. m.appendgroup_allow_list = nil
  38245. }
  38246. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38247. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  38248. v := m.group_allow_list
  38249. if v == nil {
  38250. return
  38251. }
  38252. return *v, true
  38253. }
  38254. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  38255. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38256. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38257. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38258. if !m.op.Is(OpUpdateOne) {
  38259. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38260. }
  38261. if m.id == nil || m.oldValue == nil {
  38262. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38263. }
  38264. oldValue, err := m.oldValue(ctx)
  38265. if err != nil {
  38266. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38267. }
  38268. return oldValue.GroupAllowList, nil
  38269. }
  38270. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38271. func (m *WxMutation) AppendGroupAllowList(s []string) {
  38272. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38273. }
  38274. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38275. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  38276. if len(m.appendgroup_allow_list) == 0 {
  38277. return nil, false
  38278. }
  38279. return m.appendgroup_allow_list, true
  38280. }
  38281. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38282. func (m *WxMutation) ResetGroupAllowList() {
  38283. m.group_allow_list = nil
  38284. m.appendgroup_allow_list = nil
  38285. }
  38286. // SetBlockList sets the "block_list" field.
  38287. func (m *WxMutation) SetBlockList(s []string) {
  38288. m.block_list = &s
  38289. m.appendblock_list = nil
  38290. }
  38291. // BlockList returns the value of the "block_list" field in the mutation.
  38292. func (m *WxMutation) BlockList() (r []string, exists bool) {
  38293. v := m.block_list
  38294. if v == nil {
  38295. return
  38296. }
  38297. return *v, true
  38298. }
  38299. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  38300. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38302. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38303. if !m.op.Is(OpUpdateOne) {
  38304. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38305. }
  38306. if m.id == nil || m.oldValue == nil {
  38307. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38308. }
  38309. oldValue, err := m.oldValue(ctx)
  38310. if err != nil {
  38311. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38312. }
  38313. return oldValue.BlockList, nil
  38314. }
  38315. // AppendBlockList adds s to the "block_list" field.
  38316. func (m *WxMutation) AppendBlockList(s []string) {
  38317. m.appendblock_list = append(m.appendblock_list, s...)
  38318. }
  38319. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38320. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  38321. if len(m.appendblock_list) == 0 {
  38322. return nil, false
  38323. }
  38324. return m.appendblock_list, true
  38325. }
  38326. // ResetBlockList resets all changes to the "block_list" field.
  38327. func (m *WxMutation) ResetBlockList() {
  38328. m.block_list = nil
  38329. m.appendblock_list = nil
  38330. }
  38331. // SetGroupBlockList sets the "group_block_list" field.
  38332. func (m *WxMutation) SetGroupBlockList(s []string) {
  38333. m.group_block_list = &s
  38334. m.appendgroup_block_list = nil
  38335. }
  38336. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38337. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  38338. v := m.group_block_list
  38339. if v == nil {
  38340. return
  38341. }
  38342. return *v, true
  38343. }
  38344. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  38345. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38347. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38348. if !m.op.Is(OpUpdateOne) {
  38349. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38350. }
  38351. if m.id == nil || m.oldValue == nil {
  38352. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38353. }
  38354. oldValue, err := m.oldValue(ctx)
  38355. if err != nil {
  38356. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38357. }
  38358. return oldValue.GroupBlockList, nil
  38359. }
  38360. // AppendGroupBlockList adds s to the "group_block_list" field.
  38361. func (m *WxMutation) AppendGroupBlockList(s []string) {
  38362. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38363. }
  38364. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38365. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  38366. if len(m.appendgroup_block_list) == 0 {
  38367. return nil, false
  38368. }
  38369. return m.appendgroup_block_list, true
  38370. }
  38371. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38372. func (m *WxMutation) ResetGroupBlockList() {
  38373. m.group_block_list = nil
  38374. m.appendgroup_block_list = nil
  38375. }
  38376. // ClearServer clears the "server" edge to the Server entity.
  38377. func (m *WxMutation) ClearServer() {
  38378. m.clearedserver = true
  38379. m.clearedFields[wx.FieldServerID] = struct{}{}
  38380. }
  38381. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  38382. func (m *WxMutation) ServerCleared() bool {
  38383. return m.ServerIDCleared() || m.clearedserver
  38384. }
  38385. // ServerIDs returns the "server" edge IDs in the mutation.
  38386. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38387. // ServerID instead. It exists only for internal usage by the builders.
  38388. func (m *WxMutation) ServerIDs() (ids []uint64) {
  38389. if id := m.server; id != nil {
  38390. ids = append(ids, *id)
  38391. }
  38392. return
  38393. }
  38394. // ResetServer resets all changes to the "server" edge.
  38395. func (m *WxMutation) ResetServer() {
  38396. m.server = nil
  38397. m.clearedserver = false
  38398. }
  38399. // ClearAgent clears the "agent" edge to the Agent entity.
  38400. func (m *WxMutation) ClearAgent() {
  38401. m.clearedagent = true
  38402. m.clearedFields[wx.FieldAgentID] = struct{}{}
  38403. }
  38404. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38405. func (m *WxMutation) AgentCleared() bool {
  38406. return m.clearedagent
  38407. }
  38408. // AgentIDs returns the "agent" edge IDs in the mutation.
  38409. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38410. // AgentID instead. It exists only for internal usage by the builders.
  38411. func (m *WxMutation) AgentIDs() (ids []uint64) {
  38412. if id := m.agent; id != nil {
  38413. ids = append(ids, *id)
  38414. }
  38415. return
  38416. }
  38417. // ResetAgent resets all changes to the "agent" edge.
  38418. func (m *WxMutation) ResetAgent() {
  38419. m.agent = nil
  38420. m.clearedagent = false
  38421. }
  38422. // Where appends a list predicates to the WxMutation builder.
  38423. func (m *WxMutation) Where(ps ...predicate.Wx) {
  38424. m.predicates = append(m.predicates, ps...)
  38425. }
  38426. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  38427. // users can use type-assertion to append predicates that do not depend on any generated package.
  38428. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  38429. p := make([]predicate.Wx, len(ps))
  38430. for i := range ps {
  38431. p[i] = ps[i]
  38432. }
  38433. m.Where(p...)
  38434. }
  38435. // Op returns the operation name.
  38436. func (m *WxMutation) Op() Op {
  38437. return m.op
  38438. }
  38439. // SetOp allows setting the mutation operation.
  38440. func (m *WxMutation) SetOp(op Op) {
  38441. m.op = op
  38442. }
  38443. // Type returns the node type of this mutation (Wx).
  38444. func (m *WxMutation) Type() string {
  38445. return m.typ
  38446. }
  38447. // Fields returns all fields that were changed during this mutation. Note that in
  38448. // order to get all numeric fields that were incremented/decremented, call
  38449. // AddedFields().
  38450. func (m *WxMutation) Fields() []string {
  38451. fields := make([]string, 0, 21)
  38452. if m.created_at != nil {
  38453. fields = append(fields, wx.FieldCreatedAt)
  38454. }
  38455. if m.updated_at != nil {
  38456. fields = append(fields, wx.FieldUpdatedAt)
  38457. }
  38458. if m.status != nil {
  38459. fields = append(fields, wx.FieldStatus)
  38460. }
  38461. if m.deleted_at != nil {
  38462. fields = append(fields, wx.FieldDeletedAt)
  38463. }
  38464. if m.server != nil {
  38465. fields = append(fields, wx.FieldServerID)
  38466. }
  38467. if m.port != nil {
  38468. fields = append(fields, wx.FieldPort)
  38469. }
  38470. if m.process_id != nil {
  38471. fields = append(fields, wx.FieldProcessID)
  38472. }
  38473. if m.callback != nil {
  38474. fields = append(fields, wx.FieldCallback)
  38475. }
  38476. if m.wxid != nil {
  38477. fields = append(fields, wx.FieldWxid)
  38478. }
  38479. if m.account != nil {
  38480. fields = append(fields, wx.FieldAccount)
  38481. }
  38482. if m.nickname != nil {
  38483. fields = append(fields, wx.FieldNickname)
  38484. }
  38485. if m.tel != nil {
  38486. fields = append(fields, wx.FieldTel)
  38487. }
  38488. if m.head_big != nil {
  38489. fields = append(fields, wx.FieldHeadBig)
  38490. }
  38491. if m.organization_id != nil {
  38492. fields = append(fields, wx.FieldOrganizationID)
  38493. }
  38494. if m.agent != nil {
  38495. fields = append(fields, wx.FieldAgentID)
  38496. }
  38497. if m.api_base != nil {
  38498. fields = append(fields, wx.FieldAPIBase)
  38499. }
  38500. if m.api_key != nil {
  38501. fields = append(fields, wx.FieldAPIKey)
  38502. }
  38503. if m.allow_list != nil {
  38504. fields = append(fields, wx.FieldAllowList)
  38505. }
  38506. if m.group_allow_list != nil {
  38507. fields = append(fields, wx.FieldGroupAllowList)
  38508. }
  38509. if m.block_list != nil {
  38510. fields = append(fields, wx.FieldBlockList)
  38511. }
  38512. if m.group_block_list != nil {
  38513. fields = append(fields, wx.FieldGroupBlockList)
  38514. }
  38515. return fields
  38516. }
  38517. // Field returns the value of a field with the given name. The second boolean
  38518. // return value indicates that this field was not set, or was not defined in the
  38519. // schema.
  38520. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  38521. switch name {
  38522. case wx.FieldCreatedAt:
  38523. return m.CreatedAt()
  38524. case wx.FieldUpdatedAt:
  38525. return m.UpdatedAt()
  38526. case wx.FieldStatus:
  38527. return m.Status()
  38528. case wx.FieldDeletedAt:
  38529. return m.DeletedAt()
  38530. case wx.FieldServerID:
  38531. return m.ServerID()
  38532. case wx.FieldPort:
  38533. return m.Port()
  38534. case wx.FieldProcessID:
  38535. return m.ProcessID()
  38536. case wx.FieldCallback:
  38537. return m.Callback()
  38538. case wx.FieldWxid:
  38539. return m.Wxid()
  38540. case wx.FieldAccount:
  38541. return m.Account()
  38542. case wx.FieldNickname:
  38543. return m.Nickname()
  38544. case wx.FieldTel:
  38545. return m.Tel()
  38546. case wx.FieldHeadBig:
  38547. return m.HeadBig()
  38548. case wx.FieldOrganizationID:
  38549. return m.OrganizationID()
  38550. case wx.FieldAgentID:
  38551. return m.AgentID()
  38552. case wx.FieldAPIBase:
  38553. return m.APIBase()
  38554. case wx.FieldAPIKey:
  38555. return m.APIKey()
  38556. case wx.FieldAllowList:
  38557. return m.AllowList()
  38558. case wx.FieldGroupAllowList:
  38559. return m.GroupAllowList()
  38560. case wx.FieldBlockList:
  38561. return m.BlockList()
  38562. case wx.FieldGroupBlockList:
  38563. return m.GroupBlockList()
  38564. }
  38565. return nil, false
  38566. }
  38567. // OldField returns the old value of the field from the database. An error is
  38568. // returned if the mutation operation is not UpdateOne, or the query to the
  38569. // database failed.
  38570. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38571. switch name {
  38572. case wx.FieldCreatedAt:
  38573. return m.OldCreatedAt(ctx)
  38574. case wx.FieldUpdatedAt:
  38575. return m.OldUpdatedAt(ctx)
  38576. case wx.FieldStatus:
  38577. return m.OldStatus(ctx)
  38578. case wx.FieldDeletedAt:
  38579. return m.OldDeletedAt(ctx)
  38580. case wx.FieldServerID:
  38581. return m.OldServerID(ctx)
  38582. case wx.FieldPort:
  38583. return m.OldPort(ctx)
  38584. case wx.FieldProcessID:
  38585. return m.OldProcessID(ctx)
  38586. case wx.FieldCallback:
  38587. return m.OldCallback(ctx)
  38588. case wx.FieldWxid:
  38589. return m.OldWxid(ctx)
  38590. case wx.FieldAccount:
  38591. return m.OldAccount(ctx)
  38592. case wx.FieldNickname:
  38593. return m.OldNickname(ctx)
  38594. case wx.FieldTel:
  38595. return m.OldTel(ctx)
  38596. case wx.FieldHeadBig:
  38597. return m.OldHeadBig(ctx)
  38598. case wx.FieldOrganizationID:
  38599. return m.OldOrganizationID(ctx)
  38600. case wx.FieldAgentID:
  38601. return m.OldAgentID(ctx)
  38602. case wx.FieldAPIBase:
  38603. return m.OldAPIBase(ctx)
  38604. case wx.FieldAPIKey:
  38605. return m.OldAPIKey(ctx)
  38606. case wx.FieldAllowList:
  38607. return m.OldAllowList(ctx)
  38608. case wx.FieldGroupAllowList:
  38609. return m.OldGroupAllowList(ctx)
  38610. case wx.FieldBlockList:
  38611. return m.OldBlockList(ctx)
  38612. case wx.FieldGroupBlockList:
  38613. return m.OldGroupBlockList(ctx)
  38614. }
  38615. return nil, fmt.Errorf("unknown Wx field %s", name)
  38616. }
  38617. // SetField sets the value of a field with the given name. It returns an error if
  38618. // the field is not defined in the schema, or if the type mismatched the field
  38619. // type.
  38620. func (m *WxMutation) SetField(name string, value ent.Value) error {
  38621. switch name {
  38622. case wx.FieldCreatedAt:
  38623. v, ok := value.(time.Time)
  38624. if !ok {
  38625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38626. }
  38627. m.SetCreatedAt(v)
  38628. return nil
  38629. case wx.FieldUpdatedAt:
  38630. v, ok := value.(time.Time)
  38631. if !ok {
  38632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38633. }
  38634. m.SetUpdatedAt(v)
  38635. return nil
  38636. case wx.FieldStatus:
  38637. v, ok := value.(uint8)
  38638. if !ok {
  38639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38640. }
  38641. m.SetStatus(v)
  38642. return nil
  38643. case wx.FieldDeletedAt:
  38644. v, ok := value.(time.Time)
  38645. if !ok {
  38646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38647. }
  38648. m.SetDeletedAt(v)
  38649. return nil
  38650. case wx.FieldServerID:
  38651. v, ok := value.(uint64)
  38652. if !ok {
  38653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38654. }
  38655. m.SetServerID(v)
  38656. return nil
  38657. case wx.FieldPort:
  38658. v, ok := value.(string)
  38659. if !ok {
  38660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38661. }
  38662. m.SetPort(v)
  38663. return nil
  38664. case wx.FieldProcessID:
  38665. v, ok := value.(string)
  38666. if !ok {
  38667. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38668. }
  38669. m.SetProcessID(v)
  38670. return nil
  38671. case wx.FieldCallback:
  38672. v, ok := value.(string)
  38673. if !ok {
  38674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38675. }
  38676. m.SetCallback(v)
  38677. return nil
  38678. case wx.FieldWxid:
  38679. v, ok := value.(string)
  38680. if !ok {
  38681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38682. }
  38683. m.SetWxid(v)
  38684. return nil
  38685. case wx.FieldAccount:
  38686. v, ok := value.(string)
  38687. if !ok {
  38688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38689. }
  38690. m.SetAccount(v)
  38691. return nil
  38692. case wx.FieldNickname:
  38693. v, ok := value.(string)
  38694. if !ok {
  38695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38696. }
  38697. m.SetNickname(v)
  38698. return nil
  38699. case wx.FieldTel:
  38700. v, ok := value.(string)
  38701. if !ok {
  38702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38703. }
  38704. m.SetTel(v)
  38705. return nil
  38706. case wx.FieldHeadBig:
  38707. v, ok := value.(string)
  38708. if !ok {
  38709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38710. }
  38711. m.SetHeadBig(v)
  38712. return nil
  38713. case wx.FieldOrganizationID:
  38714. v, ok := value.(uint64)
  38715. if !ok {
  38716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38717. }
  38718. m.SetOrganizationID(v)
  38719. return nil
  38720. case wx.FieldAgentID:
  38721. v, ok := value.(uint64)
  38722. if !ok {
  38723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38724. }
  38725. m.SetAgentID(v)
  38726. return nil
  38727. case wx.FieldAPIBase:
  38728. v, ok := value.(string)
  38729. if !ok {
  38730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38731. }
  38732. m.SetAPIBase(v)
  38733. return nil
  38734. case wx.FieldAPIKey:
  38735. v, ok := value.(string)
  38736. if !ok {
  38737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38738. }
  38739. m.SetAPIKey(v)
  38740. return nil
  38741. case wx.FieldAllowList:
  38742. v, ok := value.([]string)
  38743. if !ok {
  38744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38745. }
  38746. m.SetAllowList(v)
  38747. return nil
  38748. case wx.FieldGroupAllowList:
  38749. v, ok := value.([]string)
  38750. if !ok {
  38751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38752. }
  38753. m.SetGroupAllowList(v)
  38754. return nil
  38755. case wx.FieldBlockList:
  38756. v, ok := value.([]string)
  38757. if !ok {
  38758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38759. }
  38760. m.SetBlockList(v)
  38761. return nil
  38762. case wx.FieldGroupBlockList:
  38763. v, ok := value.([]string)
  38764. if !ok {
  38765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38766. }
  38767. m.SetGroupBlockList(v)
  38768. return nil
  38769. }
  38770. return fmt.Errorf("unknown Wx field %s", name)
  38771. }
  38772. // AddedFields returns all numeric fields that were incremented/decremented during
  38773. // this mutation.
  38774. func (m *WxMutation) AddedFields() []string {
  38775. var fields []string
  38776. if m.addstatus != nil {
  38777. fields = append(fields, wx.FieldStatus)
  38778. }
  38779. if m.addorganization_id != nil {
  38780. fields = append(fields, wx.FieldOrganizationID)
  38781. }
  38782. return fields
  38783. }
  38784. // AddedField returns the numeric value that was incremented/decremented on a field
  38785. // with the given name. The second boolean return value indicates that this field
  38786. // was not set, or was not defined in the schema.
  38787. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  38788. switch name {
  38789. case wx.FieldStatus:
  38790. return m.AddedStatus()
  38791. case wx.FieldOrganizationID:
  38792. return m.AddedOrganizationID()
  38793. }
  38794. return nil, false
  38795. }
  38796. // AddField adds the value to the field with the given name. It returns an error if
  38797. // the field is not defined in the schema, or if the type mismatched the field
  38798. // type.
  38799. func (m *WxMutation) AddField(name string, value ent.Value) error {
  38800. switch name {
  38801. case wx.FieldStatus:
  38802. v, ok := value.(int8)
  38803. if !ok {
  38804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38805. }
  38806. m.AddStatus(v)
  38807. return nil
  38808. case wx.FieldOrganizationID:
  38809. v, ok := value.(int64)
  38810. if !ok {
  38811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38812. }
  38813. m.AddOrganizationID(v)
  38814. return nil
  38815. }
  38816. return fmt.Errorf("unknown Wx numeric field %s", name)
  38817. }
  38818. // ClearedFields returns all nullable fields that were cleared during this
  38819. // mutation.
  38820. func (m *WxMutation) ClearedFields() []string {
  38821. var fields []string
  38822. if m.FieldCleared(wx.FieldStatus) {
  38823. fields = append(fields, wx.FieldStatus)
  38824. }
  38825. if m.FieldCleared(wx.FieldDeletedAt) {
  38826. fields = append(fields, wx.FieldDeletedAt)
  38827. }
  38828. if m.FieldCleared(wx.FieldServerID) {
  38829. fields = append(fields, wx.FieldServerID)
  38830. }
  38831. if m.FieldCleared(wx.FieldOrganizationID) {
  38832. fields = append(fields, wx.FieldOrganizationID)
  38833. }
  38834. if m.FieldCleared(wx.FieldAPIBase) {
  38835. fields = append(fields, wx.FieldAPIBase)
  38836. }
  38837. if m.FieldCleared(wx.FieldAPIKey) {
  38838. fields = append(fields, wx.FieldAPIKey)
  38839. }
  38840. return fields
  38841. }
  38842. // FieldCleared returns a boolean indicating if a field with the given name was
  38843. // cleared in this mutation.
  38844. func (m *WxMutation) FieldCleared(name string) bool {
  38845. _, ok := m.clearedFields[name]
  38846. return ok
  38847. }
  38848. // ClearField clears the value of the field with the given name. It returns an
  38849. // error if the field is not defined in the schema.
  38850. func (m *WxMutation) ClearField(name string) error {
  38851. switch name {
  38852. case wx.FieldStatus:
  38853. m.ClearStatus()
  38854. return nil
  38855. case wx.FieldDeletedAt:
  38856. m.ClearDeletedAt()
  38857. return nil
  38858. case wx.FieldServerID:
  38859. m.ClearServerID()
  38860. return nil
  38861. case wx.FieldOrganizationID:
  38862. m.ClearOrganizationID()
  38863. return nil
  38864. case wx.FieldAPIBase:
  38865. m.ClearAPIBase()
  38866. return nil
  38867. case wx.FieldAPIKey:
  38868. m.ClearAPIKey()
  38869. return nil
  38870. }
  38871. return fmt.Errorf("unknown Wx nullable field %s", name)
  38872. }
  38873. // ResetField resets all changes in the mutation for the field with the given name.
  38874. // It returns an error if the field is not defined in the schema.
  38875. func (m *WxMutation) ResetField(name string) error {
  38876. switch name {
  38877. case wx.FieldCreatedAt:
  38878. m.ResetCreatedAt()
  38879. return nil
  38880. case wx.FieldUpdatedAt:
  38881. m.ResetUpdatedAt()
  38882. return nil
  38883. case wx.FieldStatus:
  38884. m.ResetStatus()
  38885. return nil
  38886. case wx.FieldDeletedAt:
  38887. m.ResetDeletedAt()
  38888. return nil
  38889. case wx.FieldServerID:
  38890. m.ResetServerID()
  38891. return nil
  38892. case wx.FieldPort:
  38893. m.ResetPort()
  38894. return nil
  38895. case wx.FieldProcessID:
  38896. m.ResetProcessID()
  38897. return nil
  38898. case wx.FieldCallback:
  38899. m.ResetCallback()
  38900. return nil
  38901. case wx.FieldWxid:
  38902. m.ResetWxid()
  38903. return nil
  38904. case wx.FieldAccount:
  38905. m.ResetAccount()
  38906. return nil
  38907. case wx.FieldNickname:
  38908. m.ResetNickname()
  38909. return nil
  38910. case wx.FieldTel:
  38911. m.ResetTel()
  38912. return nil
  38913. case wx.FieldHeadBig:
  38914. m.ResetHeadBig()
  38915. return nil
  38916. case wx.FieldOrganizationID:
  38917. m.ResetOrganizationID()
  38918. return nil
  38919. case wx.FieldAgentID:
  38920. m.ResetAgentID()
  38921. return nil
  38922. case wx.FieldAPIBase:
  38923. m.ResetAPIBase()
  38924. return nil
  38925. case wx.FieldAPIKey:
  38926. m.ResetAPIKey()
  38927. return nil
  38928. case wx.FieldAllowList:
  38929. m.ResetAllowList()
  38930. return nil
  38931. case wx.FieldGroupAllowList:
  38932. m.ResetGroupAllowList()
  38933. return nil
  38934. case wx.FieldBlockList:
  38935. m.ResetBlockList()
  38936. return nil
  38937. case wx.FieldGroupBlockList:
  38938. m.ResetGroupBlockList()
  38939. return nil
  38940. }
  38941. return fmt.Errorf("unknown Wx field %s", name)
  38942. }
  38943. // AddedEdges returns all edge names that were set/added in this mutation.
  38944. func (m *WxMutation) AddedEdges() []string {
  38945. edges := make([]string, 0, 2)
  38946. if m.server != nil {
  38947. edges = append(edges, wx.EdgeServer)
  38948. }
  38949. if m.agent != nil {
  38950. edges = append(edges, wx.EdgeAgent)
  38951. }
  38952. return edges
  38953. }
  38954. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38955. // name in this mutation.
  38956. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  38957. switch name {
  38958. case wx.EdgeServer:
  38959. if id := m.server; id != nil {
  38960. return []ent.Value{*id}
  38961. }
  38962. case wx.EdgeAgent:
  38963. if id := m.agent; id != nil {
  38964. return []ent.Value{*id}
  38965. }
  38966. }
  38967. return nil
  38968. }
  38969. // RemovedEdges returns all edge names that were removed in this mutation.
  38970. func (m *WxMutation) RemovedEdges() []string {
  38971. edges := make([]string, 0, 2)
  38972. return edges
  38973. }
  38974. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38975. // the given name in this mutation.
  38976. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  38977. return nil
  38978. }
  38979. // ClearedEdges returns all edge names that were cleared in this mutation.
  38980. func (m *WxMutation) ClearedEdges() []string {
  38981. edges := make([]string, 0, 2)
  38982. if m.clearedserver {
  38983. edges = append(edges, wx.EdgeServer)
  38984. }
  38985. if m.clearedagent {
  38986. edges = append(edges, wx.EdgeAgent)
  38987. }
  38988. return edges
  38989. }
  38990. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38991. // was cleared in this mutation.
  38992. func (m *WxMutation) EdgeCleared(name string) bool {
  38993. switch name {
  38994. case wx.EdgeServer:
  38995. return m.clearedserver
  38996. case wx.EdgeAgent:
  38997. return m.clearedagent
  38998. }
  38999. return false
  39000. }
  39001. // ClearEdge clears the value of the edge with the given name. It returns an error
  39002. // if that edge is not defined in the schema.
  39003. func (m *WxMutation) ClearEdge(name string) error {
  39004. switch name {
  39005. case wx.EdgeServer:
  39006. m.ClearServer()
  39007. return nil
  39008. case wx.EdgeAgent:
  39009. m.ClearAgent()
  39010. return nil
  39011. }
  39012. return fmt.Errorf("unknown Wx unique edge %s", name)
  39013. }
  39014. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39015. // It returns an error if the edge is not defined in the schema.
  39016. func (m *WxMutation) ResetEdge(name string) error {
  39017. switch name {
  39018. case wx.EdgeServer:
  39019. m.ResetServer()
  39020. return nil
  39021. case wx.EdgeAgent:
  39022. m.ResetAgent()
  39023. return nil
  39024. }
  39025. return fmt.Errorf("unknown Wx edge %s", name)
  39026. }
  39027. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  39028. type WxCardMutation struct {
  39029. config
  39030. op Op
  39031. typ string
  39032. id *uint64
  39033. created_at *time.Time
  39034. updated_at *time.Time
  39035. deleted_at *time.Time
  39036. user_id *uint64
  39037. adduser_id *int64
  39038. wx_user_id *uint64
  39039. addwx_user_id *int64
  39040. avatar *string
  39041. logo *string
  39042. name *string
  39043. company *string
  39044. address *string
  39045. phone *string
  39046. official_account *string
  39047. wechat_account *string
  39048. email *string
  39049. api_base *string
  39050. api_key *string
  39051. ai_info *string
  39052. intro *string
  39053. clearedFields map[string]struct{}
  39054. done bool
  39055. oldValue func(context.Context) (*WxCard, error)
  39056. predicates []predicate.WxCard
  39057. }
  39058. var _ ent.Mutation = (*WxCardMutation)(nil)
  39059. // wxcardOption allows management of the mutation configuration using functional options.
  39060. type wxcardOption func(*WxCardMutation)
  39061. // newWxCardMutation creates new mutation for the WxCard entity.
  39062. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  39063. m := &WxCardMutation{
  39064. config: c,
  39065. op: op,
  39066. typ: TypeWxCard,
  39067. clearedFields: make(map[string]struct{}),
  39068. }
  39069. for _, opt := range opts {
  39070. opt(m)
  39071. }
  39072. return m
  39073. }
  39074. // withWxCardID sets the ID field of the mutation.
  39075. func withWxCardID(id uint64) wxcardOption {
  39076. return func(m *WxCardMutation) {
  39077. var (
  39078. err error
  39079. once sync.Once
  39080. value *WxCard
  39081. )
  39082. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  39083. once.Do(func() {
  39084. if m.done {
  39085. err = errors.New("querying old values post mutation is not allowed")
  39086. } else {
  39087. value, err = m.Client().WxCard.Get(ctx, id)
  39088. }
  39089. })
  39090. return value, err
  39091. }
  39092. m.id = &id
  39093. }
  39094. }
  39095. // withWxCard sets the old WxCard of the mutation.
  39096. func withWxCard(node *WxCard) wxcardOption {
  39097. return func(m *WxCardMutation) {
  39098. m.oldValue = func(context.Context) (*WxCard, error) {
  39099. return node, nil
  39100. }
  39101. m.id = &node.ID
  39102. }
  39103. }
  39104. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39105. // executed in a transaction (ent.Tx), a transactional client is returned.
  39106. func (m WxCardMutation) Client() *Client {
  39107. client := &Client{config: m.config}
  39108. client.init()
  39109. return client
  39110. }
  39111. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39112. // it returns an error otherwise.
  39113. func (m WxCardMutation) Tx() (*Tx, error) {
  39114. if _, ok := m.driver.(*txDriver); !ok {
  39115. return nil, errors.New("ent: mutation is not running in a transaction")
  39116. }
  39117. tx := &Tx{config: m.config}
  39118. tx.init()
  39119. return tx, nil
  39120. }
  39121. // SetID sets the value of the id field. Note that this
  39122. // operation is only accepted on creation of WxCard entities.
  39123. func (m *WxCardMutation) SetID(id uint64) {
  39124. m.id = &id
  39125. }
  39126. // ID returns the ID value in the mutation. Note that the ID is only available
  39127. // if it was provided to the builder or after it was returned from the database.
  39128. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  39129. if m.id == nil {
  39130. return
  39131. }
  39132. return *m.id, true
  39133. }
  39134. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39135. // That means, if the mutation is applied within a transaction with an isolation level such
  39136. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39137. // or updated by the mutation.
  39138. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  39139. switch {
  39140. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39141. id, exists := m.ID()
  39142. if exists {
  39143. return []uint64{id}, nil
  39144. }
  39145. fallthrough
  39146. case m.op.Is(OpUpdate | OpDelete):
  39147. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  39148. default:
  39149. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39150. }
  39151. }
  39152. // SetCreatedAt sets the "created_at" field.
  39153. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  39154. m.created_at = &t
  39155. }
  39156. // CreatedAt returns the value of the "created_at" field in the mutation.
  39157. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  39158. v := m.created_at
  39159. if v == nil {
  39160. return
  39161. }
  39162. return *v, true
  39163. }
  39164. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  39165. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39167. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39168. if !m.op.Is(OpUpdateOne) {
  39169. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39170. }
  39171. if m.id == nil || m.oldValue == nil {
  39172. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39173. }
  39174. oldValue, err := m.oldValue(ctx)
  39175. if err != nil {
  39176. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39177. }
  39178. return oldValue.CreatedAt, nil
  39179. }
  39180. // ResetCreatedAt resets all changes to the "created_at" field.
  39181. func (m *WxCardMutation) ResetCreatedAt() {
  39182. m.created_at = nil
  39183. }
  39184. // SetUpdatedAt sets the "updated_at" field.
  39185. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  39186. m.updated_at = &t
  39187. }
  39188. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39189. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  39190. v := m.updated_at
  39191. if v == nil {
  39192. return
  39193. }
  39194. return *v, true
  39195. }
  39196. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  39197. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39199. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39200. if !m.op.Is(OpUpdateOne) {
  39201. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39202. }
  39203. if m.id == nil || m.oldValue == nil {
  39204. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39205. }
  39206. oldValue, err := m.oldValue(ctx)
  39207. if err != nil {
  39208. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39209. }
  39210. return oldValue.UpdatedAt, nil
  39211. }
  39212. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39213. func (m *WxCardMutation) ResetUpdatedAt() {
  39214. m.updated_at = nil
  39215. }
  39216. // SetDeletedAt sets the "deleted_at" field.
  39217. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  39218. m.deleted_at = &t
  39219. }
  39220. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39221. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  39222. v := m.deleted_at
  39223. if v == nil {
  39224. return
  39225. }
  39226. return *v, true
  39227. }
  39228. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  39229. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39231. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39232. if !m.op.Is(OpUpdateOne) {
  39233. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39234. }
  39235. if m.id == nil || m.oldValue == nil {
  39236. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39237. }
  39238. oldValue, err := m.oldValue(ctx)
  39239. if err != nil {
  39240. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39241. }
  39242. return oldValue.DeletedAt, nil
  39243. }
  39244. // ClearDeletedAt clears the value of the "deleted_at" field.
  39245. func (m *WxCardMutation) ClearDeletedAt() {
  39246. m.deleted_at = nil
  39247. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  39248. }
  39249. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39250. func (m *WxCardMutation) DeletedAtCleared() bool {
  39251. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  39252. return ok
  39253. }
  39254. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39255. func (m *WxCardMutation) ResetDeletedAt() {
  39256. m.deleted_at = nil
  39257. delete(m.clearedFields, wxcard.FieldDeletedAt)
  39258. }
  39259. // SetUserID sets the "user_id" field.
  39260. func (m *WxCardMutation) SetUserID(u uint64) {
  39261. m.user_id = &u
  39262. m.adduser_id = nil
  39263. }
  39264. // UserID returns the value of the "user_id" field in the mutation.
  39265. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  39266. v := m.user_id
  39267. if v == nil {
  39268. return
  39269. }
  39270. return *v, true
  39271. }
  39272. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  39273. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39275. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39276. if !m.op.Is(OpUpdateOne) {
  39277. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39278. }
  39279. if m.id == nil || m.oldValue == nil {
  39280. return v, errors.New("OldUserID requires an ID field in the mutation")
  39281. }
  39282. oldValue, err := m.oldValue(ctx)
  39283. if err != nil {
  39284. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39285. }
  39286. return oldValue.UserID, nil
  39287. }
  39288. // AddUserID adds u to the "user_id" field.
  39289. func (m *WxCardMutation) AddUserID(u int64) {
  39290. if m.adduser_id != nil {
  39291. *m.adduser_id += u
  39292. } else {
  39293. m.adduser_id = &u
  39294. }
  39295. }
  39296. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39297. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  39298. v := m.adduser_id
  39299. if v == nil {
  39300. return
  39301. }
  39302. return *v, true
  39303. }
  39304. // ClearUserID clears the value of the "user_id" field.
  39305. func (m *WxCardMutation) ClearUserID() {
  39306. m.user_id = nil
  39307. m.adduser_id = nil
  39308. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  39309. }
  39310. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39311. func (m *WxCardMutation) UserIDCleared() bool {
  39312. _, ok := m.clearedFields[wxcard.FieldUserID]
  39313. return ok
  39314. }
  39315. // ResetUserID resets all changes to the "user_id" field.
  39316. func (m *WxCardMutation) ResetUserID() {
  39317. m.user_id = nil
  39318. m.adduser_id = nil
  39319. delete(m.clearedFields, wxcard.FieldUserID)
  39320. }
  39321. // SetWxUserID sets the "wx_user_id" field.
  39322. func (m *WxCardMutation) SetWxUserID(u uint64) {
  39323. m.wx_user_id = &u
  39324. m.addwx_user_id = nil
  39325. }
  39326. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  39327. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  39328. v := m.wx_user_id
  39329. if v == nil {
  39330. return
  39331. }
  39332. return *v, true
  39333. }
  39334. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  39335. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39337. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  39338. if !m.op.Is(OpUpdateOne) {
  39339. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  39340. }
  39341. if m.id == nil || m.oldValue == nil {
  39342. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  39343. }
  39344. oldValue, err := m.oldValue(ctx)
  39345. if err != nil {
  39346. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  39347. }
  39348. return oldValue.WxUserID, nil
  39349. }
  39350. // AddWxUserID adds u to the "wx_user_id" field.
  39351. func (m *WxCardMutation) AddWxUserID(u int64) {
  39352. if m.addwx_user_id != nil {
  39353. *m.addwx_user_id += u
  39354. } else {
  39355. m.addwx_user_id = &u
  39356. }
  39357. }
  39358. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  39359. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  39360. v := m.addwx_user_id
  39361. if v == nil {
  39362. return
  39363. }
  39364. return *v, true
  39365. }
  39366. // ClearWxUserID clears the value of the "wx_user_id" field.
  39367. func (m *WxCardMutation) ClearWxUserID() {
  39368. m.wx_user_id = nil
  39369. m.addwx_user_id = nil
  39370. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  39371. }
  39372. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  39373. func (m *WxCardMutation) WxUserIDCleared() bool {
  39374. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  39375. return ok
  39376. }
  39377. // ResetWxUserID resets all changes to the "wx_user_id" field.
  39378. func (m *WxCardMutation) ResetWxUserID() {
  39379. m.wx_user_id = nil
  39380. m.addwx_user_id = nil
  39381. delete(m.clearedFields, wxcard.FieldWxUserID)
  39382. }
  39383. // SetAvatar sets the "avatar" field.
  39384. func (m *WxCardMutation) SetAvatar(s string) {
  39385. m.avatar = &s
  39386. }
  39387. // Avatar returns the value of the "avatar" field in the mutation.
  39388. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  39389. v := m.avatar
  39390. if v == nil {
  39391. return
  39392. }
  39393. return *v, true
  39394. }
  39395. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  39396. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39398. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39399. if !m.op.Is(OpUpdateOne) {
  39400. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39401. }
  39402. if m.id == nil || m.oldValue == nil {
  39403. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39404. }
  39405. oldValue, err := m.oldValue(ctx)
  39406. if err != nil {
  39407. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39408. }
  39409. return oldValue.Avatar, nil
  39410. }
  39411. // ResetAvatar resets all changes to the "avatar" field.
  39412. func (m *WxCardMutation) ResetAvatar() {
  39413. m.avatar = nil
  39414. }
  39415. // SetLogo sets the "logo" field.
  39416. func (m *WxCardMutation) SetLogo(s string) {
  39417. m.logo = &s
  39418. }
  39419. // Logo returns the value of the "logo" field in the mutation.
  39420. func (m *WxCardMutation) Logo() (r string, exists bool) {
  39421. v := m.logo
  39422. if v == nil {
  39423. return
  39424. }
  39425. return *v, true
  39426. }
  39427. // OldLogo returns the old "logo" field's value of the WxCard entity.
  39428. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39429. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39430. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  39431. if !m.op.Is(OpUpdateOne) {
  39432. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  39433. }
  39434. if m.id == nil || m.oldValue == nil {
  39435. return v, errors.New("OldLogo requires an ID field in the mutation")
  39436. }
  39437. oldValue, err := m.oldValue(ctx)
  39438. if err != nil {
  39439. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  39440. }
  39441. return oldValue.Logo, nil
  39442. }
  39443. // ResetLogo resets all changes to the "logo" field.
  39444. func (m *WxCardMutation) ResetLogo() {
  39445. m.logo = nil
  39446. }
  39447. // SetName sets the "name" field.
  39448. func (m *WxCardMutation) SetName(s string) {
  39449. m.name = &s
  39450. }
  39451. // Name returns the value of the "name" field in the mutation.
  39452. func (m *WxCardMutation) Name() (r string, exists bool) {
  39453. v := m.name
  39454. if v == nil {
  39455. return
  39456. }
  39457. return *v, true
  39458. }
  39459. // OldName returns the old "name" field's value of the WxCard entity.
  39460. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39461. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39462. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  39463. if !m.op.Is(OpUpdateOne) {
  39464. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39465. }
  39466. if m.id == nil || m.oldValue == nil {
  39467. return v, errors.New("OldName requires an ID field in the mutation")
  39468. }
  39469. oldValue, err := m.oldValue(ctx)
  39470. if err != nil {
  39471. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39472. }
  39473. return oldValue.Name, nil
  39474. }
  39475. // ResetName resets all changes to the "name" field.
  39476. func (m *WxCardMutation) ResetName() {
  39477. m.name = nil
  39478. }
  39479. // SetCompany sets the "company" field.
  39480. func (m *WxCardMutation) SetCompany(s string) {
  39481. m.company = &s
  39482. }
  39483. // Company returns the value of the "company" field in the mutation.
  39484. func (m *WxCardMutation) Company() (r string, exists bool) {
  39485. v := m.company
  39486. if v == nil {
  39487. return
  39488. }
  39489. return *v, true
  39490. }
  39491. // OldCompany returns the old "company" field's value of the WxCard entity.
  39492. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39493. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39494. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  39495. if !m.op.Is(OpUpdateOne) {
  39496. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39497. }
  39498. if m.id == nil || m.oldValue == nil {
  39499. return v, errors.New("OldCompany requires an ID field in the mutation")
  39500. }
  39501. oldValue, err := m.oldValue(ctx)
  39502. if err != nil {
  39503. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39504. }
  39505. return oldValue.Company, nil
  39506. }
  39507. // ResetCompany resets all changes to the "company" field.
  39508. func (m *WxCardMutation) ResetCompany() {
  39509. m.company = nil
  39510. }
  39511. // SetAddress sets the "address" field.
  39512. func (m *WxCardMutation) SetAddress(s string) {
  39513. m.address = &s
  39514. }
  39515. // Address returns the value of the "address" field in the mutation.
  39516. func (m *WxCardMutation) Address() (r string, exists bool) {
  39517. v := m.address
  39518. if v == nil {
  39519. return
  39520. }
  39521. return *v, true
  39522. }
  39523. // OldAddress returns the old "address" field's value of the WxCard entity.
  39524. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39526. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  39527. if !m.op.Is(OpUpdateOne) {
  39528. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  39529. }
  39530. if m.id == nil || m.oldValue == nil {
  39531. return v, errors.New("OldAddress requires an ID field in the mutation")
  39532. }
  39533. oldValue, err := m.oldValue(ctx)
  39534. if err != nil {
  39535. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  39536. }
  39537. return oldValue.Address, nil
  39538. }
  39539. // ResetAddress resets all changes to the "address" field.
  39540. func (m *WxCardMutation) ResetAddress() {
  39541. m.address = nil
  39542. }
  39543. // SetPhone sets the "phone" field.
  39544. func (m *WxCardMutation) SetPhone(s string) {
  39545. m.phone = &s
  39546. }
  39547. // Phone returns the value of the "phone" field in the mutation.
  39548. func (m *WxCardMutation) Phone() (r string, exists bool) {
  39549. v := m.phone
  39550. if v == nil {
  39551. return
  39552. }
  39553. return *v, true
  39554. }
  39555. // OldPhone returns the old "phone" field's value of the WxCard entity.
  39556. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39558. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  39559. if !m.op.Is(OpUpdateOne) {
  39560. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39561. }
  39562. if m.id == nil || m.oldValue == nil {
  39563. return v, errors.New("OldPhone requires an ID field in the mutation")
  39564. }
  39565. oldValue, err := m.oldValue(ctx)
  39566. if err != nil {
  39567. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39568. }
  39569. return oldValue.Phone, nil
  39570. }
  39571. // ResetPhone resets all changes to the "phone" field.
  39572. func (m *WxCardMutation) ResetPhone() {
  39573. m.phone = nil
  39574. }
  39575. // SetOfficialAccount sets the "official_account" field.
  39576. func (m *WxCardMutation) SetOfficialAccount(s string) {
  39577. m.official_account = &s
  39578. }
  39579. // OfficialAccount returns the value of the "official_account" field in the mutation.
  39580. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  39581. v := m.official_account
  39582. if v == nil {
  39583. return
  39584. }
  39585. return *v, true
  39586. }
  39587. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  39588. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39590. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  39591. if !m.op.Is(OpUpdateOne) {
  39592. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  39593. }
  39594. if m.id == nil || m.oldValue == nil {
  39595. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  39596. }
  39597. oldValue, err := m.oldValue(ctx)
  39598. if err != nil {
  39599. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  39600. }
  39601. return oldValue.OfficialAccount, nil
  39602. }
  39603. // ResetOfficialAccount resets all changes to the "official_account" field.
  39604. func (m *WxCardMutation) ResetOfficialAccount() {
  39605. m.official_account = nil
  39606. }
  39607. // SetWechatAccount sets the "wechat_account" field.
  39608. func (m *WxCardMutation) SetWechatAccount(s string) {
  39609. m.wechat_account = &s
  39610. }
  39611. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  39612. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  39613. v := m.wechat_account
  39614. if v == nil {
  39615. return
  39616. }
  39617. return *v, true
  39618. }
  39619. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  39620. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39622. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  39623. if !m.op.Is(OpUpdateOne) {
  39624. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  39625. }
  39626. if m.id == nil || m.oldValue == nil {
  39627. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  39628. }
  39629. oldValue, err := m.oldValue(ctx)
  39630. if err != nil {
  39631. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  39632. }
  39633. return oldValue.WechatAccount, nil
  39634. }
  39635. // ResetWechatAccount resets all changes to the "wechat_account" field.
  39636. func (m *WxCardMutation) ResetWechatAccount() {
  39637. m.wechat_account = nil
  39638. }
  39639. // SetEmail sets the "email" field.
  39640. func (m *WxCardMutation) SetEmail(s string) {
  39641. m.email = &s
  39642. }
  39643. // Email returns the value of the "email" field in the mutation.
  39644. func (m *WxCardMutation) Email() (r string, exists bool) {
  39645. v := m.email
  39646. if v == nil {
  39647. return
  39648. }
  39649. return *v, true
  39650. }
  39651. // OldEmail returns the old "email" field's value of the WxCard entity.
  39652. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39653. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39654. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  39655. if !m.op.Is(OpUpdateOne) {
  39656. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  39657. }
  39658. if m.id == nil || m.oldValue == nil {
  39659. return v, errors.New("OldEmail requires an ID field in the mutation")
  39660. }
  39661. oldValue, err := m.oldValue(ctx)
  39662. if err != nil {
  39663. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  39664. }
  39665. return oldValue.Email, nil
  39666. }
  39667. // ClearEmail clears the value of the "email" field.
  39668. func (m *WxCardMutation) ClearEmail() {
  39669. m.email = nil
  39670. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  39671. }
  39672. // EmailCleared returns if the "email" field was cleared in this mutation.
  39673. func (m *WxCardMutation) EmailCleared() bool {
  39674. _, ok := m.clearedFields[wxcard.FieldEmail]
  39675. return ok
  39676. }
  39677. // ResetEmail resets all changes to the "email" field.
  39678. func (m *WxCardMutation) ResetEmail() {
  39679. m.email = nil
  39680. delete(m.clearedFields, wxcard.FieldEmail)
  39681. }
  39682. // SetAPIBase sets the "api_base" field.
  39683. func (m *WxCardMutation) SetAPIBase(s string) {
  39684. m.api_base = &s
  39685. }
  39686. // APIBase returns the value of the "api_base" field in the mutation.
  39687. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  39688. v := m.api_base
  39689. if v == nil {
  39690. return
  39691. }
  39692. return *v, true
  39693. }
  39694. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  39695. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39697. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39698. if !m.op.Is(OpUpdateOne) {
  39699. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39700. }
  39701. if m.id == nil || m.oldValue == nil {
  39702. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39703. }
  39704. oldValue, err := m.oldValue(ctx)
  39705. if err != nil {
  39706. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39707. }
  39708. return oldValue.APIBase, nil
  39709. }
  39710. // ClearAPIBase clears the value of the "api_base" field.
  39711. func (m *WxCardMutation) ClearAPIBase() {
  39712. m.api_base = nil
  39713. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  39714. }
  39715. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39716. func (m *WxCardMutation) APIBaseCleared() bool {
  39717. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  39718. return ok
  39719. }
  39720. // ResetAPIBase resets all changes to the "api_base" field.
  39721. func (m *WxCardMutation) ResetAPIBase() {
  39722. m.api_base = nil
  39723. delete(m.clearedFields, wxcard.FieldAPIBase)
  39724. }
  39725. // SetAPIKey sets the "api_key" field.
  39726. func (m *WxCardMutation) SetAPIKey(s string) {
  39727. m.api_key = &s
  39728. }
  39729. // APIKey returns the value of the "api_key" field in the mutation.
  39730. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  39731. v := m.api_key
  39732. if v == nil {
  39733. return
  39734. }
  39735. return *v, true
  39736. }
  39737. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  39738. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39740. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39741. if !m.op.Is(OpUpdateOne) {
  39742. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39743. }
  39744. if m.id == nil || m.oldValue == nil {
  39745. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39746. }
  39747. oldValue, err := m.oldValue(ctx)
  39748. if err != nil {
  39749. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39750. }
  39751. return oldValue.APIKey, nil
  39752. }
  39753. // ClearAPIKey clears the value of the "api_key" field.
  39754. func (m *WxCardMutation) ClearAPIKey() {
  39755. m.api_key = nil
  39756. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  39757. }
  39758. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39759. func (m *WxCardMutation) APIKeyCleared() bool {
  39760. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  39761. return ok
  39762. }
  39763. // ResetAPIKey resets all changes to the "api_key" field.
  39764. func (m *WxCardMutation) ResetAPIKey() {
  39765. m.api_key = nil
  39766. delete(m.clearedFields, wxcard.FieldAPIKey)
  39767. }
  39768. // SetAiInfo sets the "ai_info" field.
  39769. func (m *WxCardMutation) SetAiInfo(s string) {
  39770. m.ai_info = &s
  39771. }
  39772. // AiInfo returns the value of the "ai_info" field in the mutation.
  39773. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  39774. v := m.ai_info
  39775. if v == nil {
  39776. return
  39777. }
  39778. return *v, true
  39779. }
  39780. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  39781. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39783. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  39784. if !m.op.Is(OpUpdateOne) {
  39785. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  39786. }
  39787. if m.id == nil || m.oldValue == nil {
  39788. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  39789. }
  39790. oldValue, err := m.oldValue(ctx)
  39791. if err != nil {
  39792. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  39793. }
  39794. return oldValue.AiInfo, nil
  39795. }
  39796. // ClearAiInfo clears the value of the "ai_info" field.
  39797. func (m *WxCardMutation) ClearAiInfo() {
  39798. m.ai_info = nil
  39799. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  39800. }
  39801. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  39802. func (m *WxCardMutation) AiInfoCleared() bool {
  39803. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  39804. return ok
  39805. }
  39806. // ResetAiInfo resets all changes to the "ai_info" field.
  39807. func (m *WxCardMutation) ResetAiInfo() {
  39808. m.ai_info = nil
  39809. delete(m.clearedFields, wxcard.FieldAiInfo)
  39810. }
  39811. // SetIntro sets the "intro" field.
  39812. func (m *WxCardMutation) SetIntro(s string) {
  39813. m.intro = &s
  39814. }
  39815. // Intro returns the value of the "intro" field in the mutation.
  39816. func (m *WxCardMutation) Intro() (r string, exists bool) {
  39817. v := m.intro
  39818. if v == nil {
  39819. return
  39820. }
  39821. return *v, true
  39822. }
  39823. // OldIntro returns the old "intro" field's value of the WxCard entity.
  39824. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39826. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  39827. if !m.op.Is(OpUpdateOne) {
  39828. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  39829. }
  39830. if m.id == nil || m.oldValue == nil {
  39831. return v, errors.New("OldIntro requires an ID field in the mutation")
  39832. }
  39833. oldValue, err := m.oldValue(ctx)
  39834. if err != nil {
  39835. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  39836. }
  39837. return oldValue.Intro, nil
  39838. }
  39839. // ClearIntro clears the value of the "intro" field.
  39840. func (m *WxCardMutation) ClearIntro() {
  39841. m.intro = nil
  39842. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  39843. }
  39844. // IntroCleared returns if the "intro" field was cleared in this mutation.
  39845. func (m *WxCardMutation) IntroCleared() bool {
  39846. _, ok := m.clearedFields[wxcard.FieldIntro]
  39847. return ok
  39848. }
  39849. // ResetIntro resets all changes to the "intro" field.
  39850. func (m *WxCardMutation) ResetIntro() {
  39851. m.intro = nil
  39852. delete(m.clearedFields, wxcard.FieldIntro)
  39853. }
  39854. // Where appends a list predicates to the WxCardMutation builder.
  39855. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  39856. m.predicates = append(m.predicates, ps...)
  39857. }
  39858. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  39859. // users can use type-assertion to append predicates that do not depend on any generated package.
  39860. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  39861. p := make([]predicate.WxCard, len(ps))
  39862. for i := range ps {
  39863. p[i] = ps[i]
  39864. }
  39865. m.Where(p...)
  39866. }
  39867. // Op returns the operation name.
  39868. func (m *WxCardMutation) Op() Op {
  39869. return m.op
  39870. }
  39871. // SetOp allows setting the mutation operation.
  39872. func (m *WxCardMutation) SetOp(op Op) {
  39873. m.op = op
  39874. }
  39875. // Type returns the node type of this mutation (WxCard).
  39876. func (m *WxCardMutation) Type() string {
  39877. return m.typ
  39878. }
  39879. // Fields returns all fields that were changed during this mutation. Note that in
  39880. // order to get all numeric fields that were incremented/decremented, call
  39881. // AddedFields().
  39882. func (m *WxCardMutation) Fields() []string {
  39883. fields := make([]string, 0, 18)
  39884. if m.created_at != nil {
  39885. fields = append(fields, wxcard.FieldCreatedAt)
  39886. }
  39887. if m.updated_at != nil {
  39888. fields = append(fields, wxcard.FieldUpdatedAt)
  39889. }
  39890. if m.deleted_at != nil {
  39891. fields = append(fields, wxcard.FieldDeletedAt)
  39892. }
  39893. if m.user_id != nil {
  39894. fields = append(fields, wxcard.FieldUserID)
  39895. }
  39896. if m.wx_user_id != nil {
  39897. fields = append(fields, wxcard.FieldWxUserID)
  39898. }
  39899. if m.avatar != nil {
  39900. fields = append(fields, wxcard.FieldAvatar)
  39901. }
  39902. if m.logo != nil {
  39903. fields = append(fields, wxcard.FieldLogo)
  39904. }
  39905. if m.name != nil {
  39906. fields = append(fields, wxcard.FieldName)
  39907. }
  39908. if m.company != nil {
  39909. fields = append(fields, wxcard.FieldCompany)
  39910. }
  39911. if m.address != nil {
  39912. fields = append(fields, wxcard.FieldAddress)
  39913. }
  39914. if m.phone != nil {
  39915. fields = append(fields, wxcard.FieldPhone)
  39916. }
  39917. if m.official_account != nil {
  39918. fields = append(fields, wxcard.FieldOfficialAccount)
  39919. }
  39920. if m.wechat_account != nil {
  39921. fields = append(fields, wxcard.FieldWechatAccount)
  39922. }
  39923. if m.email != nil {
  39924. fields = append(fields, wxcard.FieldEmail)
  39925. }
  39926. if m.api_base != nil {
  39927. fields = append(fields, wxcard.FieldAPIBase)
  39928. }
  39929. if m.api_key != nil {
  39930. fields = append(fields, wxcard.FieldAPIKey)
  39931. }
  39932. if m.ai_info != nil {
  39933. fields = append(fields, wxcard.FieldAiInfo)
  39934. }
  39935. if m.intro != nil {
  39936. fields = append(fields, wxcard.FieldIntro)
  39937. }
  39938. return fields
  39939. }
  39940. // Field returns the value of a field with the given name. The second boolean
  39941. // return value indicates that this field was not set, or was not defined in the
  39942. // schema.
  39943. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  39944. switch name {
  39945. case wxcard.FieldCreatedAt:
  39946. return m.CreatedAt()
  39947. case wxcard.FieldUpdatedAt:
  39948. return m.UpdatedAt()
  39949. case wxcard.FieldDeletedAt:
  39950. return m.DeletedAt()
  39951. case wxcard.FieldUserID:
  39952. return m.UserID()
  39953. case wxcard.FieldWxUserID:
  39954. return m.WxUserID()
  39955. case wxcard.FieldAvatar:
  39956. return m.Avatar()
  39957. case wxcard.FieldLogo:
  39958. return m.Logo()
  39959. case wxcard.FieldName:
  39960. return m.Name()
  39961. case wxcard.FieldCompany:
  39962. return m.Company()
  39963. case wxcard.FieldAddress:
  39964. return m.Address()
  39965. case wxcard.FieldPhone:
  39966. return m.Phone()
  39967. case wxcard.FieldOfficialAccount:
  39968. return m.OfficialAccount()
  39969. case wxcard.FieldWechatAccount:
  39970. return m.WechatAccount()
  39971. case wxcard.FieldEmail:
  39972. return m.Email()
  39973. case wxcard.FieldAPIBase:
  39974. return m.APIBase()
  39975. case wxcard.FieldAPIKey:
  39976. return m.APIKey()
  39977. case wxcard.FieldAiInfo:
  39978. return m.AiInfo()
  39979. case wxcard.FieldIntro:
  39980. return m.Intro()
  39981. }
  39982. return nil, false
  39983. }
  39984. // OldField returns the old value of the field from the database. An error is
  39985. // returned if the mutation operation is not UpdateOne, or the query to the
  39986. // database failed.
  39987. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39988. switch name {
  39989. case wxcard.FieldCreatedAt:
  39990. return m.OldCreatedAt(ctx)
  39991. case wxcard.FieldUpdatedAt:
  39992. return m.OldUpdatedAt(ctx)
  39993. case wxcard.FieldDeletedAt:
  39994. return m.OldDeletedAt(ctx)
  39995. case wxcard.FieldUserID:
  39996. return m.OldUserID(ctx)
  39997. case wxcard.FieldWxUserID:
  39998. return m.OldWxUserID(ctx)
  39999. case wxcard.FieldAvatar:
  40000. return m.OldAvatar(ctx)
  40001. case wxcard.FieldLogo:
  40002. return m.OldLogo(ctx)
  40003. case wxcard.FieldName:
  40004. return m.OldName(ctx)
  40005. case wxcard.FieldCompany:
  40006. return m.OldCompany(ctx)
  40007. case wxcard.FieldAddress:
  40008. return m.OldAddress(ctx)
  40009. case wxcard.FieldPhone:
  40010. return m.OldPhone(ctx)
  40011. case wxcard.FieldOfficialAccount:
  40012. return m.OldOfficialAccount(ctx)
  40013. case wxcard.FieldWechatAccount:
  40014. return m.OldWechatAccount(ctx)
  40015. case wxcard.FieldEmail:
  40016. return m.OldEmail(ctx)
  40017. case wxcard.FieldAPIBase:
  40018. return m.OldAPIBase(ctx)
  40019. case wxcard.FieldAPIKey:
  40020. return m.OldAPIKey(ctx)
  40021. case wxcard.FieldAiInfo:
  40022. return m.OldAiInfo(ctx)
  40023. case wxcard.FieldIntro:
  40024. return m.OldIntro(ctx)
  40025. }
  40026. return nil, fmt.Errorf("unknown WxCard field %s", name)
  40027. }
  40028. // SetField sets the value of a field with the given name. It returns an error if
  40029. // the field is not defined in the schema, or if the type mismatched the field
  40030. // type.
  40031. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  40032. switch name {
  40033. case wxcard.FieldCreatedAt:
  40034. v, ok := value.(time.Time)
  40035. if !ok {
  40036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40037. }
  40038. m.SetCreatedAt(v)
  40039. return nil
  40040. case wxcard.FieldUpdatedAt:
  40041. v, ok := value.(time.Time)
  40042. if !ok {
  40043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40044. }
  40045. m.SetUpdatedAt(v)
  40046. return nil
  40047. case wxcard.FieldDeletedAt:
  40048. v, ok := value.(time.Time)
  40049. if !ok {
  40050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40051. }
  40052. m.SetDeletedAt(v)
  40053. return nil
  40054. case wxcard.FieldUserID:
  40055. v, ok := value.(uint64)
  40056. if !ok {
  40057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40058. }
  40059. m.SetUserID(v)
  40060. return nil
  40061. case wxcard.FieldWxUserID:
  40062. v, ok := value.(uint64)
  40063. if !ok {
  40064. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40065. }
  40066. m.SetWxUserID(v)
  40067. return nil
  40068. case wxcard.FieldAvatar:
  40069. v, ok := value.(string)
  40070. if !ok {
  40071. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40072. }
  40073. m.SetAvatar(v)
  40074. return nil
  40075. case wxcard.FieldLogo:
  40076. v, ok := value.(string)
  40077. if !ok {
  40078. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40079. }
  40080. m.SetLogo(v)
  40081. return nil
  40082. case wxcard.FieldName:
  40083. v, ok := value.(string)
  40084. if !ok {
  40085. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40086. }
  40087. m.SetName(v)
  40088. return nil
  40089. case wxcard.FieldCompany:
  40090. v, ok := value.(string)
  40091. if !ok {
  40092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40093. }
  40094. m.SetCompany(v)
  40095. return nil
  40096. case wxcard.FieldAddress:
  40097. v, ok := value.(string)
  40098. if !ok {
  40099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40100. }
  40101. m.SetAddress(v)
  40102. return nil
  40103. case wxcard.FieldPhone:
  40104. v, ok := value.(string)
  40105. if !ok {
  40106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40107. }
  40108. m.SetPhone(v)
  40109. return nil
  40110. case wxcard.FieldOfficialAccount:
  40111. v, ok := value.(string)
  40112. if !ok {
  40113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40114. }
  40115. m.SetOfficialAccount(v)
  40116. return nil
  40117. case wxcard.FieldWechatAccount:
  40118. v, ok := value.(string)
  40119. if !ok {
  40120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40121. }
  40122. m.SetWechatAccount(v)
  40123. return nil
  40124. case wxcard.FieldEmail:
  40125. v, ok := value.(string)
  40126. if !ok {
  40127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40128. }
  40129. m.SetEmail(v)
  40130. return nil
  40131. case wxcard.FieldAPIBase:
  40132. v, ok := value.(string)
  40133. if !ok {
  40134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40135. }
  40136. m.SetAPIBase(v)
  40137. return nil
  40138. case wxcard.FieldAPIKey:
  40139. v, ok := value.(string)
  40140. if !ok {
  40141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40142. }
  40143. m.SetAPIKey(v)
  40144. return nil
  40145. case wxcard.FieldAiInfo:
  40146. v, ok := value.(string)
  40147. if !ok {
  40148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40149. }
  40150. m.SetAiInfo(v)
  40151. return nil
  40152. case wxcard.FieldIntro:
  40153. v, ok := value.(string)
  40154. if !ok {
  40155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40156. }
  40157. m.SetIntro(v)
  40158. return nil
  40159. }
  40160. return fmt.Errorf("unknown WxCard field %s", name)
  40161. }
  40162. // AddedFields returns all numeric fields that were incremented/decremented during
  40163. // this mutation.
  40164. func (m *WxCardMutation) AddedFields() []string {
  40165. var fields []string
  40166. if m.adduser_id != nil {
  40167. fields = append(fields, wxcard.FieldUserID)
  40168. }
  40169. if m.addwx_user_id != nil {
  40170. fields = append(fields, wxcard.FieldWxUserID)
  40171. }
  40172. return fields
  40173. }
  40174. // AddedField returns the numeric value that was incremented/decremented on a field
  40175. // with the given name. The second boolean return value indicates that this field
  40176. // was not set, or was not defined in the schema.
  40177. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  40178. switch name {
  40179. case wxcard.FieldUserID:
  40180. return m.AddedUserID()
  40181. case wxcard.FieldWxUserID:
  40182. return m.AddedWxUserID()
  40183. }
  40184. return nil, false
  40185. }
  40186. // AddField adds the value to the field with the given name. It returns an error if
  40187. // the field is not defined in the schema, or if the type mismatched the field
  40188. // type.
  40189. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  40190. switch name {
  40191. case wxcard.FieldUserID:
  40192. v, ok := value.(int64)
  40193. if !ok {
  40194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40195. }
  40196. m.AddUserID(v)
  40197. return nil
  40198. case wxcard.FieldWxUserID:
  40199. v, ok := value.(int64)
  40200. if !ok {
  40201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40202. }
  40203. m.AddWxUserID(v)
  40204. return nil
  40205. }
  40206. return fmt.Errorf("unknown WxCard numeric field %s", name)
  40207. }
  40208. // ClearedFields returns all nullable fields that were cleared during this
  40209. // mutation.
  40210. func (m *WxCardMutation) ClearedFields() []string {
  40211. var fields []string
  40212. if m.FieldCleared(wxcard.FieldDeletedAt) {
  40213. fields = append(fields, wxcard.FieldDeletedAt)
  40214. }
  40215. if m.FieldCleared(wxcard.FieldUserID) {
  40216. fields = append(fields, wxcard.FieldUserID)
  40217. }
  40218. if m.FieldCleared(wxcard.FieldWxUserID) {
  40219. fields = append(fields, wxcard.FieldWxUserID)
  40220. }
  40221. if m.FieldCleared(wxcard.FieldEmail) {
  40222. fields = append(fields, wxcard.FieldEmail)
  40223. }
  40224. if m.FieldCleared(wxcard.FieldAPIBase) {
  40225. fields = append(fields, wxcard.FieldAPIBase)
  40226. }
  40227. if m.FieldCleared(wxcard.FieldAPIKey) {
  40228. fields = append(fields, wxcard.FieldAPIKey)
  40229. }
  40230. if m.FieldCleared(wxcard.FieldAiInfo) {
  40231. fields = append(fields, wxcard.FieldAiInfo)
  40232. }
  40233. if m.FieldCleared(wxcard.FieldIntro) {
  40234. fields = append(fields, wxcard.FieldIntro)
  40235. }
  40236. return fields
  40237. }
  40238. // FieldCleared returns a boolean indicating if a field with the given name was
  40239. // cleared in this mutation.
  40240. func (m *WxCardMutation) FieldCleared(name string) bool {
  40241. _, ok := m.clearedFields[name]
  40242. return ok
  40243. }
  40244. // ClearField clears the value of the field with the given name. It returns an
  40245. // error if the field is not defined in the schema.
  40246. func (m *WxCardMutation) ClearField(name string) error {
  40247. switch name {
  40248. case wxcard.FieldDeletedAt:
  40249. m.ClearDeletedAt()
  40250. return nil
  40251. case wxcard.FieldUserID:
  40252. m.ClearUserID()
  40253. return nil
  40254. case wxcard.FieldWxUserID:
  40255. m.ClearWxUserID()
  40256. return nil
  40257. case wxcard.FieldEmail:
  40258. m.ClearEmail()
  40259. return nil
  40260. case wxcard.FieldAPIBase:
  40261. m.ClearAPIBase()
  40262. return nil
  40263. case wxcard.FieldAPIKey:
  40264. m.ClearAPIKey()
  40265. return nil
  40266. case wxcard.FieldAiInfo:
  40267. m.ClearAiInfo()
  40268. return nil
  40269. case wxcard.FieldIntro:
  40270. m.ClearIntro()
  40271. return nil
  40272. }
  40273. return fmt.Errorf("unknown WxCard nullable field %s", name)
  40274. }
  40275. // ResetField resets all changes in the mutation for the field with the given name.
  40276. // It returns an error if the field is not defined in the schema.
  40277. func (m *WxCardMutation) ResetField(name string) error {
  40278. switch name {
  40279. case wxcard.FieldCreatedAt:
  40280. m.ResetCreatedAt()
  40281. return nil
  40282. case wxcard.FieldUpdatedAt:
  40283. m.ResetUpdatedAt()
  40284. return nil
  40285. case wxcard.FieldDeletedAt:
  40286. m.ResetDeletedAt()
  40287. return nil
  40288. case wxcard.FieldUserID:
  40289. m.ResetUserID()
  40290. return nil
  40291. case wxcard.FieldWxUserID:
  40292. m.ResetWxUserID()
  40293. return nil
  40294. case wxcard.FieldAvatar:
  40295. m.ResetAvatar()
  40296. return nil
  40297. case wxcard.FieldLogo:
  40298. m.ResetLogo()
  40299. return nil
  40300. case wxcard.FieldName:
  40301. m.ResetName()
  40302. return nil
  40303. case wxcard.FieldCompany:
  40304. m.ResetCompany()
  40305. return nil
  40306. case wxcard.FieldAddress:
  40307. m.ResetAddress()
  40308. return nil
  40309. case wxcard.FieldPhone:
  40310. m.ResetPhone()
  40311. return nil
  40312. case wxcard.FieldOfficialAccount:
  40313. m.ResetOfficialAccount()
  40314. return nil
  40315. case wxcard.FieldWechatAccount:
  40316. m.ResetWechatAccount()
  40317. return nil
  40318. case wxcard.FieldEmail:
  40319. m.ResetEmail()
  40320. return nil
  40321. case wxcard.FieldAPIBase:
  40322. m.ResetAPIBase()
  40323. return nil
  40324. case wxcard.FieldAPIKey:
  40325. m.ResetAPIKey()
  40326. return nil
  40327. case wxcard.FieldAiInfo:
  40328. m.ResetAiInfo()
  40329. return nil
  40330. case wxcard.FieldIntro:
  40331. m.ResetIntro()
  40332. return nil
  40333. }
  40334. return fmt.Errorf("unknown WxCard field %s", name)
  40335. }
  40336. // AddedEdges returns all edge names that were set/added in this mutation.
  40337. func (m *WxCardMutation) AddedEdges() []string {
  40338. edges := make([]string, 0, 0)
  40339. return edges
  40340. }
  40341. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40342. // name in this mutation.
  40343. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  40344. return nil
  40345. }
  40346. // RemovedEdges returns all edge names that were removed in this mutation.
  40347. func (m *WxCardMutation) RemovedEdges() []string {
  40348. edges := make([]string, 0, 0)
  40349. return edges
  40350. }
  40351. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40352. // the given name in this mutation.
  40353. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  40354. return nil
  40355. }
  40356. // ClearedEdges returns all edge names that were cleared in this mutation.
  40357. func (m *WxCardMutation) ClearedEdges() []string {
  40358. edges := make([]string, 0, 0)
  40359. return edges
  40360. }
  40361. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40362. // was cleared in this mutation.
  40363. func (m *WxCardMutation) EdgeCleared(name string) bool {
  40364. return false
  40365. }
  40366. // ClearEdge clears the value of the edge with the given name. It returns an error
  40367. // if that edge is not defined in the schema.
  40368. func (m *WxCardMutation) ClearEdge(name string) error {
  40369. return fmt.Errorf("unknown WxCard unique edge %s", name)
  40370. }
  40371. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40372. // It returns an error if the edge is not defined in the schema.
  40373. func (m *WxCardMutation) ResetEdge(name string) error {
  40374. return fmt.Errorf("unknown WxCard edge %s", name)
  40375. }
  40376. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  40377. type WxCardUserMutation struct {
  40378. config
  40379. op Op
  40380. typ string
  40381. id *uint64
  40382. created_at *time.Time
  40383. updated_at *time.Time
  40384. deleted_at *time.Time
  40385. wxid *string
  40386. account *string
  40387. avatar *string
  40388. nickname *string
  40389. remark *string
  40390. phone *string
  40391. open_id *string
  40392. union_id *string
  40393. session_key *string
  40394. is_vip *int
  40395. addis_vip *int
  40396. clearedFields map[string]struct{}
  40397. done bool
  40398. oldValue func(context.Context) (*WxCardUser, error)
  40399. predicates []predicate.WxCardUser
  40400. }
  40401. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  40402. // wxcarduserOption allows management of the mutation configuration using functional options.
  40403. type wxcarduserOption func(*WxCardUserMutation)
  40404. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  40405. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  40406. m := &WxCardUserMutation{
  40407. config: c,
  40408. op: op,
  40409. typ: TypeWxCardUser,
  40410. clearedFields: make(map[string]struct{}),
  40411. }
  40412. for _, opt := range opts {
  40413. opt(m)
  40414. }
  40415. return m
  40416. }
  40417. // withWxCardUserID sets the ID field of the mutation.
  40418. func withWxCardUserID(id uint64) wxcarduserOption {
  40419. return func(m *WxCardUserMutation) {
  40420. var (
  40421. err error
  40422. once sync.Once
  40423. value *WxCardUser
  40424. )
  40425. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  40426. once.Do(func() {
  40427. if m.done {
  40428. err = errors.New("querying old values post mutation is not allowed")
  40429. } else {
  40430. value, err = m.Client().WxCardUser.Get(ctx, id)
  40431. }
  40432. })
  40433. return value, err
  40434. }
  40435. m.id = &id
  40436. }
  40437. }
  40438. // withWxCardUser sets the old WxCardUser of the mutation.
  40439. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  40440. return func(m *WxCardUserMutation) {
  40441. m.oldValue = func(context.Context) (*WxCardUser, error) {
  40442. return node, nil
  40443. }
  40444. m.id = &node.ID
  40445. }
  40446. }
  40447. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40448. // executed in a transaction (ent.Tx), a transactional client is returned.
  40449. func (m WxCardUserMutation) Client() *Client {
  40450. client := &Client{config: m.config}
  40451. client.init()
  40452. return client
  40453. }
  40454. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40455. // it returns an error otherwise.
  40456. func (m WxCardUserMutation) Tx() (*Tx, error) {
  40457. if _, ok := m.driver.(*txDriver); !ok {
  40458. return nil, errors.New("ent: mutation is not running in a transaction")
  40459. }
  40460. tx := &Tx{config: m.config}
  40461. tx.init()
  40462. return tx, nil
  40463. }
  40464. // SetID sets the value of the id field. Note that this
  40465. // operation is only accepted on creation of WxCardUser entities.
  40466. func (m *WxCardUserMutation) SetID(id uint64) {
  40467. m.id = &id
  40468. }
  40469. // ID returns the ID value in the mutation. Note that the ID is only available
  40470. // if it was provided to the builder or after it was returned from the database.
  40471. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  40472. if m.id == nil {
  40473. return
  40474. }
  40475. return *m.id, true
  40476. }
  40477. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40478. // That means, if the mutation is applied within a transaction with an isolation level such
  40479. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40480. // or updated by the mutation.
  40481. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  40482. switch {
  40483. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40484. id, exists := m.ID()
  40485. if exists {
  40486. return []uint64{id}, nil
  40487. }
  40488. fallthrough
  40489. case m.op.Is(OpUpdate | OpDelete):
  40490. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  40491. default:
  40492. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40493. }
  40494. }
  40495. // SetCreatedAt sets the "created_at" field.
  40496. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  40497. m.created_at = &t
  40498. }
  40499. // CreatedAt returns the value of the "created_at" field in the mutation.
  40500. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  40501. v := m.created_at
  40502. if v == nil {
  40503. return
  40504. }
  40505. return *v, true
  40506. }
  40507. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  40508. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40509. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40510. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40511. if !m.op.Is(OpUpdateOne) {
  40512. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40513. }
  40514. if m.id == nil || m.oldValue == nil {
  40515. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40516. }
  40517. oldValue, err := m.oldValue(ctx)
  40518. if err != nil {
  40519. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40520. }
  40521. return oldValue.CreatedAt, nil
  40522. }
  40523. // ResetCreatedAt resets all changes to the "created_at" field.
  40524. func (m *WxCardUserMutation) ResetCreatedAt() {
  40525. m.created_at = nil
  40526. }
  40527. // SetUpdatedAt sets the "updated_at" field.
  40528. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  40529. m.updated_at = &t
  40530. }
  40531. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40532. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  40533. v := m.updated_at
  40534. if v == nil {
  40535. return
  40536. }
  40537. return *v, true
  40538. }
  40539. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  40540. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40542. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40543. if !m.op.Is(OpUpdateOne) {
  40544. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40545. }
  40546. if m.id == nil || m.oldValue == nil {
  40547. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40548. }
  40549. oldValue, err := m.oldValue(ctx)
  40550. if err != nil {
  40551. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40552. }
  40553. return oldValue.UpdatedAt, nil
  40554. }
  40555. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40556. func (m *WxCardUserMutation) ResetUpdatedAt() {
  40557. m.updated_at = nil
  40558. }
  40559. // SetDeletedAt sets the "deleted_at" field.
  40560. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  40561. m.deleted_at = &t
  40562. }
  40563. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40564. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  40565. v := m.deleted_at
  40566. if v == nil {
  40567. return
  40568. }
  40569. return *v, true
  40570. }
  40571. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  40572. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40573. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40574. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40575. if !m.op.Is(OpUpdateOne) {
  40576. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40577. }
  40578. if m.id == nil || m.oldValue == nil {
  40579. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40580. }
  40581. oldValue, err := m.oldValue(ctx)
  40582. if err != nil {
  40583. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40584. }
  40585. return oldValue.DeletedAt, nil
  40586. }
  40587. // ClearDeletedAt clears the value of the "deleted_at" field.
  40588. func (m *WxCardUserMutation) ClearDeletedAt() {
  40589. m.deleted_at = nil
  40590. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  40591. }
  40592. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40593. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  40594. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  40595. return ok
  40596. }
  40597. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40598. func (m *WxCardUserMutation) ResetDeletedAt() {
  40599. m.deleted_at = nil
  40600. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  40601. }
  40602. // SetWxid sets the "wxid" field.
  40603. func (m *WxCardUserMutation) SetWxid(s string) {
  40604. m.wxid = &s
  40605. }
  40606. // Wxid returns the value of the "wxid" field in the mutation.
  40607. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  40608. v := m.wxid
  40609. if v == nil {
  40610. return
  40611. }
  40612. return *v, true
  40613. }
  40614. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  40615. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40616. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40617. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  40618. if !m.op.Is(OpUpdateOne) {
  40619. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40620. }
  40621. if m.id == nil || m.oldValue == nil {
  40622. return v, errors.New("OldWxid requires an ID field in the mutation")
  40623. }
  40624. oldValue, err := m.oldValue(ctx)
  40625. if err != nil {
  40626. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40627. }
  40628. return oldValue.Wxid, nil
  40629. }
  40630. // ResetWxid resets all changes to the "wxid" field.
  40631. func (m *WxCardUserMutation) ResetWxid() {
  40632. m.wxid = nil
  40633. }
  40634. // SetAccount sets the "account" field.
  40635. func (m *WxCardUserMutation) SetAccount(s string) {
  40636. m.account = &s
  40637. }
  40638. // Account returns the value of the "account" field in the mutation.
  40639. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  40640. v := m.account
  40641. if v == nil {
  40642. return
  40643. }
  40644. return *v, true
  40645. }
  40646. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  40647. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40649. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  40650. if !m.op.Is(OpUpdateOne) {
  40651. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40652. }
  40653. if m.id == nil || m.oldValue == nil {
  40654. return v, errors.New("OldAccount requires an ID field in the mutation")
  40655. }
  40656. oldValue, err := m.oldValue(ctx)
  40657. if err != nil {
  40658. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40659. }
  40660. return oldValue.Account, nil
  40661. }
  40662. // ResetAccount resets all changes to the "account" field.
  40663. func (m *WxCardUserMutation) ResetAccount() {
  40664. m.account = nil
  40665. }
  40666. // SetAvatar sets the "avatar" field.
  40667. func (m *WxCardUserMutation) SetAvatar(s string) {
  40668. m.avatar = &s
  40669. }
  40670. // Avatar returns the value of the "avatar" field in the mutation.
  40671. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  40672. v := m.avatar
  40673. if v == nil {
  40674. return
  40675. }
  40676. return *v, true
  40677. }
  40678. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  40679. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40681. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40682. if !m.op.Is(OpUpdateOne) {
  40683. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40684. }
  40685. if m.id == nil || m.oldValue == nil {
  40686. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40687. }
  40688. oldValue, err := m.oldValue(ctx)
  40689. if err != nil {
  40690. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40691. }
  40692. return oldValue.Avatar, nil
  40693. }
  40694. // ResetAvatar resets all changes to the "avatar" field.
  40695. func (m *WxCardUserMutation) ResetAvatar() {
  40696. m.avatar = nil
  40697. }
  40698. // SetNickname sets the "nickname" field.
  40699. func (m *WxCardUserMutation) SetNickname(s string) {
  40700. m.nickname = &s
  40701. }
  40702. // Nickname returns the value of the "nickname" field in the mutation.
  40703. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  40704. v := m.nickname
  40705. if v == nil {
  40706. return
  40707. }
  40708. return *v, true
  40709. }
  40710. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  40711. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40713. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  40714. if !m.op.Is(OpUpdateOne) {
  40715. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40716. }
  40717. if m.id == nil || m.oldValue == nil {
  40718. return v, errors.New("OldNickname requires an ID field in the mutation")
  40719. }
  40720. oldValue, err := m.oldValue(ctx)
  40721. if err != nil {
  40722. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40723. }
  40724. return oldValue.Nickname, nil
  40725. }
  40726. // ResetNickname resets all changes to the "nickname" field.
  40727. func (m *WxCardUserMutation) ResetNickname() {
  40728. m.nickname = nil
  40729. }
  40730. // SetRemark sets the "remark" field.
  40731. func (m *WxCardUserMutation) SetRemark(s string) {
  40732. m.remark = &s
  40733. }
  40734. // Remark returns the value of the "remark" field in the mutation.
  40735. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  40736. v := m.remark
  40737. if v == nil {
  40738. return
  40739. }
  40740. return *v, true
  40741. }
  40742. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  40743. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40744. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40745. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  40746. if !m.op.Is(OpUpdateOne) {
  40747. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  40748. }
  40749. if m.id == nil || m.oldValue == nil {
  40750. return v, errors.New("OldRemark requires an ID field in the mutation")
  40751. }
  40752. oldValue, err := m.oldValue(ctx)
  40753. if err != nil {
  40754. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  40755. }
  40756. return oldValue.Remark, nil
  40757. }
  40758. // ResetRemark resets all changes to the "remark" field.
  40759. func (m *WxCardUserMutation) ResetRemark() {
  40760. m.remark = nil
  40761. }
  40762. // SetPhone sets the "phone" field.
  40763. func (m *WxCardUserMutation) SetPhone(s string) {
  40764. m.phone = &s
  40765. }
  40766. // Phone returns the value of the "phone" field in the mutation.
  40767. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  40768. v := m.phone
  40769. if v == nil {
  40770. return
  40771. }
  40772. return *v, true
  40773. }
  40774. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  40775. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40776. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40777. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  40778. if !m.op.Is(OpUpdateOne) {
  40779. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40780. }
  40781. if m.id == nil || m.oldValue == nil {
  40782. return v, errors.New("OldPhone requires an ID field in the mutation")
  40783. }
  40784. oldValue, err := m.oldValue(ctx)
  40785. if err != nil {
  40786. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40787. }
  40788. return oldValue.Phone, nil
  40789. }
  40790. // ResetPhone resets all changes to the "phone" field.
  40791. func (m *WxCardUserMutation) ResetPhone() {
  40792. m.phone = nil
  40793. }
  40794. // SetOpenID sets the "open_id" field.
  40795. func (m *WxCardUserMutation) SetOpenID(s string) {
  40796. m.open_id = &s
  40797. }
  40798. // OpenID returns the value of the "open_id" field in the mutation.
  40799. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  40800. v := m.open_id
  40801. if v == nil {
  40802. return
  40803. }
  40804. return *v, true
  40805. }
  40806. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  40807. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40809. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  40810. if !m.op.Is(OpUpdateOne) {
  40811. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  40812. }
  40813. if m.id == nil || m.oldValue == nil {
  40814. return v, errors.New("OldOpenID requires an ID field in the mutation")
  40815. }
  40816. oldValue, err := m.oldValue(ctx)
  40817. if err != nil {
  40818. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  40819. }
  40820. return oldValue.OpenID, nil
  40821. }
  40822. // ResetOpenID resets all changes to the "open_id" field.
  40823. func (m *WxCardUserMutation) ResetOpenID() {
  40824. m.open_id = nil
  40825. }
  40826. // SetUnionID sets the "union_id" field.
  40827. func (m *WxCardUserMutation) SetUnionID(s string) {
  40828. m.union_id = &s
  40829. }
  40830. // UnionID returns the value of the "union_id" field in the mutation.
  40831. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  40832. v := m.union_id
  40833. if v == nil {
  40834. return
  40835. }
  40836. return *v, true
  40837. }
  40838. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  40839. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40841. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  40842. if !m.op.Is(OpUpdateOne) {
  40843. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  40844. }
  40845. if m.id == nil || m.oldValue == nil {
  40846. return v, errors.New("OldUnionID requires an ID field in the mutation")
  40847. }
  40848. oldValue, err := m.oldValue(ctx)
  40849. if err != nil {
  40850. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  40851. }
  40852. return oldValue.UnionID, nil
  40853. }
  40854. // ResetUnionID resets all changes to the "union_id" field.
  40855. func (m *WxCardUserMutation) ResetUnionID() {
  40856. m.union_id = nil
  40857. }
  40858. // SetSessionKey sets the "session_key" field.
  40859. func (m *WxCardUserMutation) SetSessionKey(s string) {
  40860. m.session_key = &s
  40861. }
  40862. // SessionKey returns the value of the "session_key" field in the mutation.
  40863. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  40864. v := m.session_key
  40865. if v == nil {
  40866. return
  40867. }
  40868. return *v, true
  40869. }
  40870. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  40871. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40873. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  40874. if !m.op.Is(OpUpdateOne) {
  40875. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  40876. }
  40877. if m.id == nil || m.oldValue == nil {
  40878. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  40879. }
  40880. oldValue, err := m.oldValue(ctx)
  40881. if err != nil {
  40882. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  40883. }
  40884. return oldValue.SessionKey, nil
  40885. }
  40886. // ResetSessionKey resets all changes to the "session_key" field.
  40887. func (m *WxCardUserMutation) ResetSessionKey() {
  40888. m.session_key = nil
  40889. }
  40890. // SetIsVip sets the "is_vip" field.
  40891. func (m *WxCardUserMutation) SetIsVip(i int) {
  40892. m.is_vip = &i
  40893. m.addis_vip = nil
  40894. }
  40895. // IsVip returns the value of the "is_vip" field in the mutation.
  40896. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  40897. v := m.is_vip
  40898. if v == nil {
  40899. return
  40900. }
  40901. return *v, true
  40902. }
  40903. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  40904. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40906. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  40907. if !m.op.Is(OpUpdateOne) {
  40908. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  40909. }
  40910. if m.id == nil || m.oldValue == nil {
  40911. return v, errors.New("OldIsVip requires an ID field in the mutation")
  40912. }
  40913. oldValue, err := m.oldValue(ctx)
  40914. if err != nil {
  40915. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  40916. }
  40917. return oldValue.IsVip, nil
  40918. }
  40919. // AddIsVip adds i to the "is_vip" field.
  40920. func (m *WxCardUserMutation) AddIsVip(i int) {
  40921. if m.addis_vip != nil {
  40922. *m.addis_vip += i
  40923. } else {
  40924. m.addis_vip = &i
  40925. }
  40926. }
  40927. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  40928. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  40929. v := m.addis_vip
  40930. if v == nil {
  40931. return
  40932. }
  40933. return *v, true
  40934. }
  40935. // ResetIsVip resets all changes to the "is_vip" field.
  40936. func (m *WxCardUserMutation) ResetIsVip() {
  40937. m.is_vip = nil
  40938. m.addis_vip = nil
  40939. }
  40940. // Where appends a list predicates to the WxCardUserMutation builder.
  40941. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  40942. m.predicates = append(m.predicates, ps...)
  40943. }
  40944. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  40945. // users can use type-assertion to append predicates that do not depend on any generated package.
  40946. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  40947. p := make([]predicate.WxCardUser, len(ps))
  40948. for i := range ps {
  40949. p[i] = ps[i]
  40950. }
  40951. m.Where(p...)
  40952. }
  40953. // Op returns the operation name.
  40954. func (m *WxCardUserMutation) Op() Op {
  40955. return m.op
  40956. }
  40957. // SetOp allows setting the mutation operation.
  40958. func (m *WxCardUserMutation) SetOp(op Op) {
  40959. m.op = op
  40960. }
  40961. // Type returns the node type of this mutation (WxCardUser).
  40962. func (m *WxCardUserMutation) Type() string {
  40963. return m.typ
  40964. }
  40965. // Fields returns all fields that were changed during this mutation. Note that in
  40966. // order to get all numeric fields that were incremented/decremented, call
  40967. // AddedFields().
  40968. func (m *WxCardUserMutation) Fields() []string {
  40969. fields := make([]string, 0, 13)
  40970. if m.created_at != nil {
  40971. fields = append(fields, wxcarduser.FieldCreatedAt)
  40972. }
  40973. if m.updated_at != nil {
  40974. fields = append(fields, wxcarduser.FieldUpdatedAt)
  40975. }
  40976. if m.deleted_at != nil {
  40977. fields = append(fields, wxcarduser.FieldDeletedAt)
  40978. }
  40979. if m.wxid != nil {
  40980. fields = append(fields, wxcarduser.FieldWxid)
  40981. }
  40982. if m.account != nil {
  40983. fields = append(fields, wxcarduser.FieldAccount)
  40984. }
  40985. if m.avatar != nil {
  40986. fields = append(fields, wxcarduser.FieldAvatar)
  40987. }
  40988. if m.nickname != nil {
  40989. fields = append(fields, wxcarduser.FieldNickname)
  40990. }
  40991. if m.remark != nil {
  40992. fields = append(fields, wxcarduser.FieldRemark)
  40993. }
  40994. if m.phone != nil {
  40995. fields = append(fields, wxcarduser.FieldPhone)
  40996. }
  40997. if m.open_id != nil {
  40998. fields = append(fields, wxcarduser.FieldOpenID)
  40999. }
  41000. if m.union_id != nil {
  41001. fields = append(fields, wxcarduser.FieldUnionID)
  41002. }
  41003. if m.session_key != nil {
  41004. fields = append(fields, wxcarduser.FieldSessionKey)
  41005. }
  41006. if m.is_vip != nil {
  41007. fields = append(fields, wxcarduser.FieldIsVip)
  41008. }
  41009. return fields
  41010. }
  41011. // Field returns the value of a field with the given name. The second boolean
  41012. // return value indicates that this field was not set, or was not defined in the
  41013. // schema.
  41014. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  41015. switch name {
  41016. case wxcarduser.FieldCreatedAt:
  41017. return m.CreatedAt()
  41018. case wxcarduser.FieldUpdatedAt:
  41019. return m.UpdatedAt()
  41020. case wxcarduser.FieldDeletedAt:
  41021. return m.DeletedAt()
  41022. case wxcarduser.FieldWxid:
  41023. return m.Wxid()
  41024. case wxcarduser.FieldAccount:
  41025. return m.Account()
  41026. case wxcarduser.FieldAvatar:
  41027. return m.Avatar()
  41028. case wxcarduser.FieldNickname:
  41029. return m.Nickname()
  41030. case wxcarduser.FieldRemark:
  41031. return m.Remark()
  41032. case wxcarduser.FieldPhone:
  41033. return m.Phone()
  41034. case wxcarduser.FieldOpenID:
  41035. return m.OpenID()
  41036. case wxcarduser.FieldUnionID:
  41037. return m.UnionID()
  41038. case wxcarduser.FieldSessionKey:
  41039. return m.SessionKey()
  41040. case wxcarduser.FieldIsVip:
  41041. return m.IsVip()
  41042. }
  41043. return nil, false
  41044. }
  41045. // OldField returns the old value of the field from the database. An error is
  41046. // returned if the mutation operation is not UpdateOne, or the query to the
  41047. // database failed.
  41048. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41049. switch name {
  41050. case wxcarduser.FieldCreatedAt:
  41051. return m.OldCreatedAt(ctx)
  41052. case wxcarduser.FieldUpdatedAt:
  41053. return m.OldUpdatedAt(ctx)
  41054. case wxcarduser.FieldDeletedAt:
  41055. return m.OldDeletedAt(ctx)
  41056. case wxcarduser.FieldWxid:
  41057. return m.OldWxid(ctx)
  41058. case wxcarduser.FieldAccount:
  41059. return m.OldAccount(ctx)
  41060. case wxcarduser.FieldAvatar:
  41061. return m.OldAvatar(ctx)
  41062. case wxcarduser.FieldNickname:
  41063. return m.OldNickname(ctx)
  41064. case wxcarduser.FieldRemark:
  41065. return m.OldRemark(ctx)
  41066. case wxcarduser.FieldPhone:
  41067. return m.OldPhone(ctx)
  41068. case wxcarduser.FieldOpenID:
  41069. return m.OldOpenID(ctx)
  41070. case wxcarduser.FieldUnionID:
  41071. return m.OldUnionID(ctx)
  41072. case wxcarduser.FieldSessionKey:
  41073. return m.OldSessionKey(ctx)
  41074. case wxcarduser.FieldIsVip:
  41075. return m.OldIsVip(ctx)
  41076. }
  41077. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  41078. }
  41079. // SetField sets the value of a field with the given name. It returns an error if
  41080. // the field is not defined in the schema, or if the type mismatched the field
  41081. // type.
  41082. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  41083. switch name {
  41084. case wxcarduser.FieldCreatedAt:
  41085. v, ok := value.(time.Time)
  41086. if !ok {
  41087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41088. }
  41089. m.SetCreatedAt(v)
  41090. return nil
  41091. case wxcarduser.FieldUpdatedAt:
  41092. v, ok := value.(time.Time)
  41093. if !ok {
  41094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41095. }
  41096. m.SetUpdatedAt(v)
  41097. return nil
  41098. case wxcarduser.FieldDeletedAt:
  41099. v, ok := value.(time.Time)
  41100. if !ok {
  41101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41102. }
  41103. m.SetDeletedAt(v)
  41104. return nil
  41105. case wxcarduser.FieldWxid:
  41106. v, ok := value.(string)
  41107. if !ok {
  41108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41109. }
  41110. m.SetWxid(v)
  41111. return nil
  41112. case wxcarduser.FieldAccount:
  41113. v, ok := value.(string)
  41114. if !ok {
  41115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41116. }
  41117. m.SetAccount(v)
  41118. return nil
  41119. case wxcarduser.FieldAvatar:
  41120. v, ok := value.(string)
  41121. if !ok {
  41122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41123. }
  41124. m.SetAvatar(v)
  41125. return nil
  41126. case wxcarduser.FieldNickname:
  41127. v, ok := value.(string)
  41128. if !ok {
  41129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41130. }
  41131. m.SetNickname(v)
  41132. return nil
  41133. case wxcarduser.FieldRemark:
  41134. v, ok := value.(string)
  41135. if !ok {
  41136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41137. }
  41138. m.SetRemark(v)
  41139. return nil
  41140. case wxcarduser.FieldPhone:
  41141. v, ok := value.(string)
  41142. if !ok {
  41143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41144. }
  41145. m.SetPhone(v)
  41146. return nil
  41147. case wxcarduser.FieldOpenID:
  41148. v, ok := value.(string)
  41149. if !ok {
  41150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41151. }
  41152. m.SetOpenID(v)
  41153. return nil
  41154. case wxcarduser.FieldUnionID:
  41155. v, ok := value.(string)
  41156. if !ok {
  41157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41158. }
  41159. m.SetUnionID(v)
  41160. return nil
  41161. case wxcarduser.FieldSessionKey:
  41162. v, ok := value.(string)
  41163. if !ok {
  41164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41165. }
  41166. m.SetSessionKey(v)
  41167. return nil
  41168. case wxcarduser.FieldIsVip:
  41169. v, ok := value.(int)
  41170. if !ok {
  41171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41172. }
  41173. m.SetIsVip(v)
  41174. return nil
  41175. }
  41176. return fmt.Errorf("unknown WxCardUser field %s", name)
  41177. }
  41178. // AddedFields returns all numeric fields that were incremented/decremented during
  41179. // this mutation.
  41180. func (m *WxCardUserMutation) AddedFields() []string {
  41181. var fields []string
  41182. if m.addis_vip != nil {
  41183. fields = append(fields, wxcarduser.FieldIsVip)
  41184. }
  41185. return fields
  41186. }
  41187. // AddedField returns the numeric value that was incremented/decremented on a field
  41188. // with the given name. The second boolean return value indicates that this field
  41189. // was not set, or was not defined in the schema.
  41190. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  41191. switch name {
  41192. case wxcarduser.FieldIsVip:
  41193. return m.AddedIsVip()
  41194. }
  41195. return nil, false
  41196. }
  41197. // AddField adds the value to the field with the given name. It returns an error if
  41198. // the field is not defined in the schema, or if the type mismatched the field
  41199. // type.
  41200. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  41201. switch name {
  41202. case wxcarduser.FieldIsVip:
  41203. v, ok := value.(int)
  41204. if !ok {
  41205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41206. }
  41207. m.AddIsVip(v)
  41208. return nil
  41209. }
  41210. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  41211. }
  41212. // ClearedFields returns all nullable fields that were cleared during this
  41213. // mutation.
  41214. func (m *WxCardUserMutation) ClearedFields() []string {
  41215. var fields []string
  41216. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  41217. fields = append(fields, wxcarduser.FieldDeletedAt)
  41218. }
  41219. return fields
  41220. }
  41221. // FieldCleared returns a boolean indicating if a field with the given name was
  41222. // cleared in this mutation.
  41223. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  41224. _, ok := m.clearedFields[name]
  41225. return ok
  41226. }
  41227. // ClearField clears the value of the field with the given name. It returns an
  41228. // error if the field is not defined in the schema.
  41229. func (m *WxCardUserMutation) ClearField(name string) error {
  41230. switch name {
  41231. case wxcarduser.FieldDeletedAt:
  41232. m.ClearDeletedAt()
  41233. return nil
  41234. }
  41235. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  41236. }
  41237. // ResetField resets all changes in the mutation for the field with the given name.
  41238. // It returns an error if the field is not defined in the schema.
  41239. func (m *WxCardUserMutation) ResetField(name string) error {
  41240. switch name {
  41241. case wxcarduser.FieldCreatedAt:
  41242. m.ResetCreatedAt()
  41243. return nil
  41244. case wxcarduser.FieldUpdatedAt:
  41245. m.ResetUpdatedAt()
  41246. return nil
  41247. case wxcarduser.FieldDeletedAt:
  41248. m.ResetDeletedAt()
  41249. return nil
  41250. case wxcarduser.FieldWxid:
  41251. m.ResetWxid()
  41252. return nil
  41253. case wxcarduser.FieldAccount:
  41254. m.ResetAccount()
  41255. return nil
  41256. case wxcarduser.FieldAvatar:
  41257. m.ResetAvatar()
  41258. return nil
  41259. case wxcarduser.FieldNickname:
  41260. m.ResetNickname()
  41261. return nil
  41262. case wxcarduser.FieldRemark:
  41263. m.ResetRemark()
  41264. return nil
  41265. case wxcarduser.FieldPhone:
  41266. m.ResetPhone()
  41267. return nil
  41268. case wxcarduser.FieldOpenID:
  41269. m.ResetOpenID()
  41270. return nil
  41271. case wxcarduser.FieldUnionID:
  41272. m.ResetUnionID()
  41273. return nil
  41274. case wxcarduser.FieldSessionKey:
  41275. m.ResetSessionKey()
  41276. return nil
  41277. case wxcarduser.FieldIsVip:
  41278. m.ResetIsVip()
  41279. return nil
  41280. }
  41281. return fmt.Errorf("unknown WxCardUser field %s", name)
  41282. }
  41283. // AddedEdges returns all edge names that were set/added in this mutation.
  41284. func (m *WxCardUserMutation) AddedEdges() []string {
  41285. edges := make([]string, 0, 0)
  41286. return edges
  41287. }
  41288. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41289. // name in this mutation.
  41290. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  41291. return nil
  41292. }
  41293. // RemovedEdges returns all edge names that were removed in this mutation.
  41294. func (m *WxCardUserMutation) RemovedEdges() []string {
  41295. edges := make([]string, 0, 0)
  41296. return edges
  41297. }
  41298. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41299. // the given name in this mutation.
  41300. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  41301. return nil
  41302. }
  41303. // ClearedEdges returns all edge names that were cleared in this mutation.
  41304. func (m *WxCardUserMutation) ClearedEdges() []string {
  41305. edges := make([]string, 0, 0)
  41306. return edges
  41307. }
  41308. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41309. // was cleared in this mutation.
  41310. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  41311. return false
  41312. }
  41313. // ClearEdge clears the value of the edge with the given name. It returns an error
  41314. // if that edge is not defined in the schema.
  41315. func (m *WxCardUserMutation) ClearEdge(name string) error {
  41316. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  41317. }
  41318. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41319. // It returns an error if the edge is not defined in the schema.
  41320. func (m *WxCardUserMutation) ResetEdge(name string) error {
  41321. return fmt.Errorf("unknown WxCardUser edge %s", name)
  41322. }
  41323. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  41324. type WxCardVisitMutation struct {
  41325. config
  41326. op Op
  41327. typ string
  41328. id *uint64
  41329. created_at *time.Time
  41330. updated_at *time.Time
  41331. deleted_at *time.Time
  41332. user_id *uint64
  41333. adduser_id *int64
  41334. bot_id *uint64
  41335. addbot_id *int64
  41336. bot_type *uint8
  41337. addbot_type *int8
  41338. clearedFields map[string]struct{}
  41339. done bool
  41340. oldValue func(context.Context) (*WxCardVisit, error)
  41341. predicates []predicate.WxCardVisit
  41342. }
  41343. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  41344. // wxcardvisitOption allows management of the mutation configuration using functional options.
  41345. type wxcardvisitOption func(*WxCardVisitMutation)
  41346. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  41347. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  41348. m := &WxCardVisitMutation{
  41349. config: c,
  41350. op: op,
  41351. typ: TypeWxCardVisit,
  41352. clearedFields: make(map[string]struct{}),
  41353. }
  41354. for _, opt := range opts {
  41355. opt(m)
  41356. }
  41357. return m
  41358. }
  41359. // withWxCardVisitID sets the ID field of the mutation.
  41360. func withWxCardVisitID(id uint64) wxcardvisitOption {
  41361. return func(m *WxCardVisitMutation) {
  41362. var (
  41363. err error
  41364. once sync.Once
  41365. value *WxCardVisit
  41366. )
  41367. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  41368. once.Do(func() {
  41369. if m.done {
  41370. err = errors.New("querying old values post mutation is not allowed")
  41371. } else {
  41372. value, err = m.Client().WxCardVisit.Get(ctx, id)
  41373. }
  41374. })
  41375. return value, err
  41376. }
  41377. m.id = &id
  41378. }
  41379. }
  41380. // withWxCardVisit sets the old WxCardVisit of the mutation.
  41381. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  41382. return func(m *WxCardVisitMutation) {
  41383. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  41384. return node, nil
  41385. }
  41386. m.id = &node.ID
  41387. }
  41388. }
  41389. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41390. // executed in a transaction (ent.Tx), a transactional client is returned.
  41391. func (m WxCardVisitMutation) Client() *Client {
  41392. client := &Client{config: m.config}
  41393. client.init()
  41394. return client
  41395. }
  41396. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41397. // it returns an error otherwise.
  41398. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  41399. if _, ok := m.driver.(*txDriver); !ok {
  41400. return nil, errors.New("ent: mutation is not running in a transaction")
  41401. }
  41402. tx := &Tx{config: m.config}
  41403. tx.init()
  41404. return tx, nil
  41405. }
  41406. // SetID sets the value of the id field. Note that this
  41407. // operation is only accepted on creation of WxCardVisit entities.
  41408. func (m *WxCardVisitMutation) SetID(id uint64) {
  41409. m.id = &id
  41410. }
  41411. // ID returns the ID value in the mutation. Note that the ID is only available
  41412. // if it was provided to the builder or after it was returned from the database.
  41413. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  41414. if m.id == nil {
  41415. return
  41416. }
  41417. return *m.id, true
  41418. }
  41419. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41420. // That means, if the mutation is applied within a transaction with an isolation level such
  41421. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41422. // or updated by the mutation.
  41423. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  41424. switch {
  41425. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41426. id, exists := m.ID()
  41427. if exists {
  41428. return []uint64{id}, nil
  41429. }
  41430. fallthrough
  41431. case m.op.Is(OpUpdate | OpDelete):
  41432. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  41433. default:
  41434. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41435. }
  41436. }
  41437. // SetCreatedAt sets the "created_at" field.
  41438. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  41439. m.created_at = &t
  41440. }
  41441. // CreatedAt returns the value of the "created_at" field in the mutation.
  41442. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  41443. v := m.created_at
  41444. if v == nil {
  41445. return
  41446. }
  41447. return *v, true
  41448. }
  41449. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  41450. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41452. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41453. if !m.op.Is(OpUpdateOne) {
  41454. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41455. }
  41456. if m.id == nil || m.oldValue == nil {
  41457. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41458. }
  41459. oldValue, err := m.oldValue(ctx)
  41460. if err != nil {
  41461. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41462. }
  41463. return oldValue.CreatedAt, nil
  41464. }
  41465. // ResetCreatedAt resets all changes to the "created_at" field.
  41466. func (m *WxCardVisitMutation) ResetCreatedAt() {
  41467. m.created_at = nil
  41468. }
  41469. // SetUpdatedAt sets the "updated_at" field.
  41470. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  41471. m.updated_at = &t
  41472. }
  41473. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41474. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  41475. v := m.updated_at
  41476. if v == nil {
  41477. return
  41478. }
  41479. return *v, true
  41480. }
  41481. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  41482. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41484. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41485. if !m.op.Is(OpUpdateOne) {
  41486. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41487. }
  41488. if m.id == nil || m.oldValue == nil {
  41489. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41490. }
  41491. oldValue, err := m.oldValue(ctx)
  41492. if err != nil {
  41493. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41494. }
  41495. return oldValue.UpdatedAt, nil
  41496. }
  41497. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41498. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  41499. m.updated_at = nil
  41500. }
  41501. // SetDeletedAt sets the "deleted_at" field.
  41502. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  41503. m.deleted_at = &t
  41504. }
  41505. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41506. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  41507. v := m.deleted_at
  41508. if v == nil {
  41509. return
  41510. }
  41511. return *v, true
  41512. }
  41513. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  41514. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41516. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41517. if !m.op.Is(OpUpdateOne) {
  41518. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41519. }
  41520. if m.id == nil || m.oldValue == nil {
  41521. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41522. }
  41523. oldValue, err := m.oldValue(ctx)
  41524. if err != nil {
  41525. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41526. }
  41527. return oldValue.DeletedAt, nil
  41528. }
  41529. // ClearDeletedAt clears the value of the "deleted_at" field.
  41530. func (m *WxCardVisitMutation) ClearDeletedAt() {
  41531. m.deleted_at = nil
  41532. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  41533. }
  41534. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41535. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  41536. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  41537. return ok
  41538. }
  41539. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41540. func (m *WxCardVisitMutation) ResetDeletedAt() {
  41541. m.deleted_at = nil
  41542. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  41543. }
  41544. // SetUserID sets the "user_id" field.
  41545. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  41546. m.user_id = &u
  41547. m.adduser_id = nil
  41548. }
  41549. // UserID returns the value of the "user_id" field in the mutation.
  41550. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  41551. v := m.user_id
  41552. if v == nil {
  41553. return
  41554. }
  41555. return *v, true
  41556. }
  41557. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  41558. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41560. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41561. if !m.op.Is(OpUpdateOne) {
  41562. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41563. }
  41564. if m.id == nil || m.oldValue == nil {
  41565. return v, errors.New("OldUserID requires an ID field in the mutation")
  41566. }
  41567. oldValue, err := m.oldValue(ctx)
  41568. if err != nil {
  41569. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41570. }
  41571. return oldValue.UserID, nil
  41572. }
  41573. // AddUserID adds u to the "user_id" field.
  41574. func (m *WxCardVisitMutation) AddUserID(u int64) {
  41575. if m.adduser_id != nil {
  41576. *m.adduser_id += u
  41577. } else {
  41578. m.adduser_id = &u
  41579. }
  41580. }
  41581. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41582. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  41583. v := m.adduser_id
  41584. if v == nil {
  41585. return
  41586. }
  41587. return *v, true
  41588. }
  41589. // ClearUserID clears the value of the "user_id" field.
  41590. func (m *WxCardVisitMutation) ClearUserID() {
  41591. m.user_id = nil
  41592. m.adduser_id = nil
  41593. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  41594. }
  41595. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41596. func (m *WxCardVisitMutation) UserIDCleared() bool {
  41597. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  41598. return ok
  41599. }
  41600. // ResetUserID resets all changes to the "user_id" field.
  41601. func (m *WxCardVisitMutation) ResetUserID() {
  41602. m.user_id = nil
  41603. m.adduser_id = nil
  41604. delete(m.clearedFields, wxcardvisit.FieldUserID)
  41605. }
  41606. // SetBotID sets the "bot_id" field.
  41607. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  41608. m.bot_id = &u
  41609. m.addbot_id = nil
  41610. }
  41611. // BotID returns the value of the "bot_id" field in the mutation.
  41612. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  41613. v := m.bot_id
  41614. if v == nil {
  41615. return
  41616. }
  41617. return *v, true
  41618. }
  41619. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  41620. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41621. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41622. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  41623. if !m.op.Is(OpUpdateOne) {
  41624. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41625. }
  41626. if m.id == nil || m.oldValue == nil {
  41627. return v, errors.New("OldBotID requires an ID field in the mutation")
  41628. }
  41629. oldValue, err := m.oldValue(ctx)
  41630. if err != nil {
  41631. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41632. }
  41633. return oldValue.BotID, nil
  41634. }
  41635. // AddBotID adds u to the "bot_id" field.
  41636. func (m *WxCardVisitMutation) AddBotID(u int64) {
  41637. if m.addbot_id != nil {
  41638. *m.addbot_id += u
  41639. } else {
  41640. m.addbot_id = &u
  41641. }
  41642. }
  41643. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  41644. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  41645. v := m.addbot_id
  41646. if v == nil {
  41647. return
  41648. }
  41649. return *v, true
  41650. }
  41651. // ResetBotID resets all changes to the "bot_id" field.
  41652. func (m *WxCardVisitMutation) ResetBotID() {
  41653. m.bot_id = nil
  41654. m.addbot_id = nil
  41655. }
  41656. // SetBotType sets the "bot_type" field.
  41657. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  41658. m.bot_type = &u
  41659. m.addbot_type = nil
  41660. }
  41661. // BotType returns the value of the "bot_type" field in the mutation.
  41662. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  41663. v := m.bot_type
  41664. if v == nil {
  41665. return
  41666. }
  41667. return *v, true
  41668. }
  41669. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  41670. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41672. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  41673. if !m.op.Is(OpUpdateOne) {
  41674. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  41675. }
  41676. if m.id == nil || m.oldValue == nil {
  41677. return v, errors.New("OldBotType requires an ID field in the mutation")
  41678. }
  41679. oldValue, err := m.oldValue(ctx)
  41680. if err != nil {
  41681. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  41682. }
  41683. return oldValue.BotType, nil
  41684. }
  41685. // AddBotType adds u to the "bot_type" field.
  41686. func (m *WxCardVisitMutation) AddBotType(u int8) {
  41687. if m.addbot_type != nil {
  41688. *m.addbot_type += u
  41689. } else {
  41690. m.addbot_type = &u
  41691. }
  41692. }
  41693. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  41694. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  41695. v := m.addbot_type
  41696. if v == nil {
  41697. return
  41698. }
  41699. return *v, true
  41700. }
  41701. // ResetBotType resets all changes to the "bot_type" field.
  41702. func (m *WxCardVisitMutation) ResetBotType() {
  41703. m.bot_type = nil
  41704. m.addbot_type = nil
  41705. }
  41706. // Where appends a list predicates to the WxCardVisitMutation builder.
  41707. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  41708. m.predicates = append(m.predicates, ps...)
  41709. }
  41710. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  41711. // users can use type-assertion to append predicates that do not depend on any generated package.
  41712. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  41713. p := make([]predicate.WxCardVisit, len(ps))
  41714. for i := range ps {
  41715. p[i] = ps[i]
  41716. }
  41717. m.Where(p...)
  41718. }
  41719. // Op returns the operation name.
  41720. func (m *WxCardVisitMutation) Op() Op {
  41721. return m.op
  41722. }
  41723. // SetOp allows setting the mutation operation.
  41724. func (m *WxCardVisitMutation) SetOp(op Op) {
  41725. m.op = op
  41726. }
  41727. // Type returns the node type of this mutation (WxCardVisit).
  41728. func (m *WxCardVisitMutation) Type() string {
  41729. return m.typ
  41730. }
  41731. // Fields returns all fields that were changed during this mutation. Note that in
  41732. // order to get all numeric fields that were incremented/decremented, call
  41733. // AddedFields().
  41734. func (m *WxCardVisitMutation) Fields() []string {
  41735. fields := make([]string, 0, 6)
  41736. if m.created_at != nil {
  41737. fields = append(fields, wxcardvisit.FieldCreatedAt)
  41738. }
  41739. if m.updated_at != nil {
  41740. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  41741. }
  41742. if m.deleted_at != nil {
  41743. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41744. }
  41745. if m.user_id != nil {
  41746. fields = append(fields, wxcardvisit.FieldUserID)
  41747. }
  41748. if m.bot_id != nil {
  41749. fields = append(fields, wxcardvisit.FieldBotID)
  41750. }
  41751. if m.bot_type != nil {
  41752. fields = append(fields, wxcardvisit.FieldBotType)
  41753. }
  41754. return fields
  41755. }
  41756. // Field returns the value of a field with the given name. The second boolean
  41757. // return value indicates that this field was not set, or was not defined in the
  41758. // schema.
  41759. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  41760. switch name {
  41761. case wxcardvisit.FieldCreatedAt:
  41762. return m.CreatedAt()
  41763. case wxcardvisit.FieldUpdatedAt:
  41764. return m.UpdatedAt()
  41765. case wxcardvisit.FieldDeletedAt:
  41766. return m.DeletedAt()
  41767. case wxcardvisit.FieldUserID:
  41768. return m.UserID()
  41769. case wxcardvisit.FieldBotID:
  41770. return m.BotID()
  41771. case wxcardvisit.FieldBotType:
  41772. return m.BotType()
  41773. }
  41774. return nil, false
  41775. }
  41776. // OldField returns the old value of the field from the database. An error is
  41777. // returned if the mutation operation is not UpdateOne, or the query to the
  41778. // database failed.
  41779. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41780. switch name {
  41781. case wxcardvisit.FieldCreatedAt:
  41782. return m.OldCreatedAt(ctx)
  41783. case wxcardvisit.FieldUpdatedAt:
  41784. return m.OldUpdatedAt(ctx)
  41785. case wxcardvisit.FieldDeletedAt:
  41786. return m.OldDeletedAt(ctx)
  41787. case wxcardvisit.FieldUserID:
  41788. return m.OldUserID(ctx)
  41789. case wxcardvisit.FieldBotID:
  41790. return m.OldBotID(ctx)
  41791. case wxcardvisit.FieldBotType:
  41792. return m.OldBotType(ctx)
  41793. }
  41794. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  41795. }
  41796. // SetField sets the value of a field with the given name. It returns an error if
  41797. // the field is not defined in the schema, or if the type mismatched the field
  41798. // type.
  41799. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  41800. switch name {
  41801. case wxcardvisit.FieldCreatedAt:
  41802. v, ok := value.(time.Time)
  41803. if !ok {
  41804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41805. }
  41806. m.SetCreatedAt(v)
  41807. return nil
  41808. case wxcardvisit.FieldUpdatedAt:
  41809. v, ok := value.(time.Time)
  41810. if !ok {
  41811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41812. }
  41813. m.SetUpdatedAt(v)
  41814. return nil
  41815. case wxcardvisit.FieldDeletedAt:
  41816. v, ok := value.(time.Time)
  41817. if !ok {
  41818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41819. }
  41820. m.SetDeletedAt(v)
  41821. return nil
  41822. case wxcardvisit.FieldUserID:
  41823. v, ok := value.(uint64)
  41824. if !ok {
  41825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41826. }
  41827. m.SetUserID(v)
  41828. return nil
  41829. case wxcardvisit.FieldBotID:
  41830. v, ok := value.(uint64)
  41831. if !ok {
  41832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41833. }
  41834. m.SetBotID(v)
  41835. return nil
  41836. case wxcardvisit.FieldBotType:
  41837. v, ok := value.(uint8)
  41838. if !ok {
  41839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41840. }
  41841. m.SetBotType(v)
  41842. return nil
  41843. }
  41844. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41845. }
  41846. // AddedFields returns all numeric fields that were incremented/decremented during
  41847. // this mutation.
  41848. func (m *WxCardVisitMutation) AddedFields() []string {
  41849. var fields []string
  41850. if m.adduser_id != nil {
  41851. fields = append(fields, wxcardvisit.FieldUserID)
  41852. }
  41853. if m.addbot_id != nil {
  41854. fields = append(fields, wxcardvisit.FieldBotID)
  41855. }
  41856. if m.addbot_type != nil {
  41857. fields = append(fields, wxcardvisit.FieldBotType)
  41858. }
  41859. return fields
  41860. }
  41861. // AddedField returns the numeric value that was incremented/decremented on a field
  41862. // with the given name. The second boolean return value indicates that this field
  41863. // was not set, or was not defined in the schema.
  41864. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  41865. switch name {
  41866. case wxcardvisit.FieldUserID:
  41867. return m.AddedUserID()
  41868. case wxcardvisit.FieldBotID:
  41869. return m.AddedBotID()
  41870. case wxcardvisit.FieldBotType:
  41871. return m.AddedBotType()
  41872. }
  41873. return nil, false
  41874. }
  41875. // AddField adds the value to the field with the given name. It returns an error if
  41876. // the field is not defined in the schema, or if the type mismatched the field
  41877. // type.
  41878. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  41879. switch name {
  41880. case wxcardvisit.FieldUserID:
  41881. v, ok := value.(int64)
  41882. if !ok {
  41883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41884. }
  41885. m.AddUserID(v)
  41886. return nil
  41887. case wxcardvisit.FieldBotID:
  41888. v, ok := value.(int64)
  41889. if !ok {
  41890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41891. }
  41892. m.AddBotID(v)
  41893. return nil
  41894. case wxcardvisit.FieldBotType:
  41895. v, ok := value.(int8)
  41896. if !ok {
  41897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41898. }
  41899. m.AddBotType(v)
  41900. return nil
  41901. }
  41902. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  41903. }
  41904. // ClearedFields returns all nullable fields that were cleared during this
  41905. // mutation.
  41906. func (m *WxCardVisitMutation) ClearedFields() []string {
  41907. var fields []string
  41908. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  41909. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41910. }
  41911. if m.FieldCleared(wxcardvisit.FieldUserID) {
  41912. fields = append(fields, wxcardvisit.FieldUserID)
  41913. }
  41914. return fields
  41915. }
  41916. // FieldCleared returns a boolean indicating if a field with the given name was
  41917. // cleared in this mutation.
  41918. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  41919. _, ok := m.clearedFields[name]
  41920. return ok
  41921. }
  41922. // ClearField clears the value of the field with the given name. It returns an
  41923. // error if the field is not defined in the schema.
  41924. func (m *WxCardVisitMutation) ClearField(name string) error {
  41925. switch name {
  41926. case wxcardvisit.FieldDeletedAt:
  41927. m.ClearDeletedAt()
  41928. return nil
  41929. case wxcardvisit.FieldUserID:
  41930. m.ClearUserID()
  41931. return nil
  41932. }
  41933. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  41934. }
  41935. // ResetField resets all changes in the mutation for the field with the given name.
  41936. // It returns an error if the field is not defined in the schema.
  41937. func (m *WxCardVisitMutation) ResetField(name string) error {
  41938. switch name {
  41939. case wxcardvisit.FieldCreatedAt:
  41940. m.ResetCreatedAt()
  41941. return nil
  41942. case wxcardvisit.FieldUpdatedAt:
  41943. m.ResetUpdatedAt()
  41944. return nil
  41945. case wxcardvisit.FieldDeletedAt:
  41946. m.ResetDeletedAt()
  41947. return nil
  41948. case wxcardvisit.FieldUserID:
  41949. m.ResetUserID()
  41950. return nil
  41951. case wxcardvisit.FieldBotID:
  41952. m.ResetBotID()
  41953. return nil
  41954. case wxcardvisit.FieldBotType:
  41955. m.ResetBotType()
  41956. return nil
  41957. }
  41958. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41959. }
  41960. // AddedEdges returns all edge names that were set/added in this mutation.
  41961. func (m *WxCardVisitMutation) AddedEdges() []string {
  41962. edges := make([]string, 0, 0)
  41963. return edges
  41964. }
  41965. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41966. // name in this mutation.
  41967. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  41968. return nil
  41969. }
  41970. // RemovedEdges returns all edge names that were removed in this mutation.
  41971. func (m *WxCardVisitMutation) RemovedEdges() []string {
  41972. edges := make([]string, 0, 0)
  41973. return edges
  41974. }
  41975. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41976. // the given name in this mutation.
  41977. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  41978. return nil
  41979. }
  41980. // ClearedEdges returns all edge names that were cleared in this mutation.
  41981. func (m *WxCardVisitMutation) ClearedEdges() []string {
  41982. edges := make([]string, 0, 0)
  41983. return edges
  41984. }
  41985. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41986. // was cleared in this mutation.
  41987. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  41988. return false
  41989. }
  41990. // ClearEdge clears the value of the edge with the given name. It returns an error
  41991. // if that edge is not defined in the schema.
  41992. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  41993. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  41994. }
  41995. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41996. // It returns an error if the edge is not defined in the schema.
  41997. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  41998. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  41999. }