mutation.go 1.3 MB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362636363646365636663676368636963706371637263736374637563766377637863796380638163826383638463856386638763886389639063916392639363946395639663976398639964006401640264036404640564066407640864096410641164126413641464156416641764186419642064216422642364246425642664276428642964306431643264336434643564366437643864396440644164426443644464456446644764486449645064516452645364546455645664576458645964606461646264636464646564666467646864696470647164726473647464756476647764786479648064816482648364846485648664876488648964906491649264936494649564966497649864996500650165026503650465056506650765086509651065116512651365146515651665176518651965206521652265236524652565266527652865296530653165326533653465356536653765386539654065416542654365446545654665476548654965506551655265536554655565566557655865596560656165626563656465656566656765686569657065716572657365746575657665776578657965806581658265836584658565866587658865896590659165926593659465956596659765986599660066016602660366046605660666076608660966106611661266136614661566166617661866196620662166226623662466256626662766286629663066316632663366346635663666376638663966406641664266436644664566466647664866496650665166526653665466556656665766586659666066616662666366646665666666676668666966706671667266736674667566766677667866796680668166826683668466856686668766886689669066916692669366946695669666976698669967006701670267036704670567066707670867096710671167126713671467156716671767186719672067216722672367246725672667276728672967306731673267336734673567366737673867396740674167426743674467456746674767486749675067516752675367546755675667576758675967606761676267636764676567666767676867696770677167726773677467756776677767786779678067816782678367846785678667876788678967906791679267936794679567966797679867996800680168026803680468056806680768086809681068116812681368146815681668176818681968206821682268236824682568266827682868296830683168326833683468356836683768386839684068416842684368446845684668476848684968506851685268536854685568566857685868596860686168626863686468656866686768686869687068716872687368746875687668776878687968806881688268836884688568866887688868896890689168926893689468956896689768986899690069016902690369046905690669076908690969106911691269136914691569166917691869196920692169226923692469256926692769286929693069316932693369346935693669376938693969406941694269436944694569466947694869496950695169526953695469556956695769586959696069616962696369646965696669676968696969706971697269736974697569766977697869796980698169826983698469856986698769886989699069916992699369946995699669976998699970007001700270037004700570067007700870097010701170127013701470157016701770187019702070217022702370247025702670277028702970307031703270337034703570367037703870397040704170427043704470457046704770487049705070517052705370547055705670577058705970607061706270637064706570667067706870697070707170727073707470757076707770787079708070817082708370847085708670877088708970907091709270937094709570967097709870997100710171027103710471057106710771087109711071117112711371147115711671177118711971207121712271237124712571267127712871297130713171327133713471357136713771387139714071417142714371447145714671477148714971507151715271537154715571567157715871597160716171627163716471657166716771687169717071717172717371747175717671777178717971807181718271837184718571867187718871897190719171927193719471957196719771987199720072017202720372047205720672077208720972107211721272137214721572167217721872197220722172227223722472257226722772287229723072317232723372347235723672377238723972407241724272437244724572467247724872497250725172527253725472557256725772587259726072617262726372647265726672677268726972707271727272737274727572767277727872797280728172827283728472857286728772887289729072917292729372947295729672977298729973007301730273037304730573067307730873097310731173127313731473157316731773187319732073217322732373247325732673277328732973307331733273337334733573367337733873397340734173427343734473457346734773487349735073517352735373547355735673577358735973607361736273637364736573667367736873697370737173727373737473757376737773787379738073817382738373847385738673877388738973907391739273937394739573967397739873997400740174027403740474057406740774087409741074117412741374147415741674177418741974207421742274237424742574267427742874297430743174327433743474357436743774387439744074417442744374447445744674477448744974507451745274537454745574567457745874597460746174627463746474657466746774687469747074717472747374747475747674777478747974807481748274837484748574867487748874897490749174927493749474957496749774987499750075017502750375047505750675077508750975107511751275137514751575167517751875197520752175227523752475257526752775287529753075317532753375347535753675377538753975407541754275437544754575467547754875497550755175527553755475557556755775587559756075617562756375647565756675677568756975707571757275737574757575767577757875797580758175827583758475857586758775887589759075917592759375947595759675977598759976007601760276037604760576067607760876097610761176127613761476157616761776187619762076217622762376247625762676277628762976307631763276337634763576367637763876397640764176427643764476457646764776487649765076517652765376547655765676577658765976607661766276637664766576667667766876697670767176727673767476757676767776787679768076817682768376847685768676877688768976907691769276937694769576967697769876997700770177027703770477057706770777087709771077117712771377147715771677177718771977207721772277237724772577267727772877297730773177327733773477357736773777387739774077417742774377447745774677477748774977507751775277537754775577567757775877597760776177627763776477657766776777687769777077717772777377747775777677777778777977807781778277837784778577867787778877897790779177927793779477957796779777987799780078017802780378047805780678077808780978107811781278137814781578167817781878197820782178227823782478257826782778287829783078317832783378347835783678377838783978407841784278437844784578467847784878497850785178527853785478557856785778587859786078617862786378647865786678677868786978707871787278737874787578767877787878797880788178827883788478857886788778887889789078917892789378947895789678977898789979007901790279037904790579067907790879097910791179127913791479157916791779187919792079217922792379247925792679277928792979307931793279337934793579367937793879397940794179427943794479457946794779487949795079517952795379547955795679577958795979607961796279637964796579667967796879697970797179727973797479757976797779787979798079817982798379847985798679877988798979907991799279937994799579967997799879998000800180028003800480058006800780088009801080118012801380148015801680178018801980208021802280238024802580268027802880298030803180328033803480358036803780388039804080418042804380448045804680478048804980508051805280538054805580568057805880598060806180628063806480658066806780688069807080718072807380748075807680778078807980808081808280838084808580868087808880898090809180928093809480958096809780988099810081018102810381048105810681078108810981108111811281138114811581168117811881198120812181228123812481258126812781288129813081318132813381348135813681378138813981408141814281438144814581468147814881498150815181528153815481558156815781588159816081618162816381648165816681678168816981708171817281738174817581768177817881798180818181828183818481858186818781888189819081918192819381948195819681978198819982008201820282038204820582068207820882098210821182128213821482158216821782188219822082218222822382248225822682278228822982308231823282338234823582368237823882398240824182428243824482458246824782488249825082518252825382548255825682578258825982608261826282638264826582668267826882698270827182728273827482758276827782788279828082818282828382848285828682878288828982908291829282938294829582968297829882998300830183028303830483058306830783088309831083118312831383148315831683178318831983208321832283238324832583268327832883298330833183328333833483358336833783388339834083418342834383448345834683478348834983508351835283538354835583568357835883598360836183628363836483658366836783688369837083718372837383748375837683778378837983808381838283838384838583868387838883898390839183928393839483958396839783988399840084018402840384048405840684078408840984108411841284138414841584168417841884198420842184228423842484258426842784288429843084318432843384348435843684378438843984408441844284438444844584468447844884498450845184528453845484558456845784588459846084618462846384648465846684678468846984708471847284738474847584768477847884798480848184828483848484858486848784888489849084918492849384948495849684978498849985008501850285038504850585068507850885098510851185128513851485158516851785188519852085218522852385248525852685278528852985308531853285338534853585368537853885398540854185428543854485458546854785488549855085518552855385548555855685578558855985608561856285638564856585668567856885698570857185728573857485758576857785788579858085818582858385848585858685878588858985908591859285938594859585968597859885998600860186028603860486058606860786088609861086118612861386148615861686178618861986208621862286238624862586268627862886298630863186328633863486358636863786388639864086418642864386448645864686478648864986508651865286538654865586568657865886598660866186628663866486658666866786688669867086718672867386748675867686778678867986808681868286838684868586868687868886898690869186928693869486958696869786988699870087018702870387048705870687078708870987108711871287138714871587168717871887198720872187228723872487258726872787288729873087318732873387348735873687378738873987408741874287438744874587468747874887498750875187528753875487558756875787588759876087618762876387648765876687678768876987708771877287738774877587768777877887798780878187828783878487858786878787888789879087918792879387948795879687978798879988008801880288038804880588068807880888098810881188128813881488158816881788188819882088218822882388248825882688278828882988308831883288338834883588368837883888398840884188428843884488458846884788488849885088518852885388548855885688578858885988608861886288638864886588668867886888698870887188728873887488758876887788788879888088818882888388848885888688878888888988908891889288938894889588968897889888998900890189028903890489058906890789088909891089118912891389148915891689178918891989208921892289238924892589268927892889298930893189328933893489358936893789388939894089418942894389448945894689478948894989508951895289538954895589568957895889598960896189628963896489658966896789688969897089718972897389748975897689778978897989808981898289838984898589868987898889898990899189928993899489958996899789988999900090019002900390049005900690079008900990109011901290139014901590169017901890199020902190229023902490259026902790289029903090319032903390349035903690379038903990409041904290439044904590469047904890499050905190529053905490559056905790589059906090619062906390649065906690679068906990709071907290739074907590769077907890799080908190829083908490859086908790889089909090919092909390949095909690979098909991009101910291039104910591069107910891099110911191129113911491159116911791189119912091219122912391249125912691279128912991309131913291339134913591369137913891399140914191429143914491459146914791489149915091519152915391549155915691579158915991609161916291639164916591669167916891699170917191729173917491759176917791789179918091819182918391849185918691879188918991909191919291939194919591969197919891999200920192029203920492059206920792089209921092119212921392149215921692179218921992209221922292239224922592269227922892299230923192329233923492359236923792389239924092419242924392449245924692479248924992509251925292539254925592569257925892599260926192629263926492659266926792689269927092719272927392749275927692779278927992809281928292839284928592869287928892899290929192929293929492959296929792989299930093019302930393049305930693079308930993109311931293139314931593169317931893199320932193229323932493259326932793289329933093319332933393349335933693379338933993409341934293439344934593469347934893499350935193529353935493559356935793589359936093619362936393649365936693679368936993709371937293739374937593769377937893799380938193829383938493859386938793889389939093919392939393949395939693979398939994009401940294039404940594069407940894099410941194129413941494159416941794189419942094219422942394249425942694279428942994309431943294339434943594369437943894399440944194429443944494459446944794489449945094519452945394549455945694579458945994609461946294639464946594669467946894699470947194729473947494759476947794789479948094819482948394849485948694879488948994909491949294939494949594969497949894999500950195029503950495059506950795089509951095119512951395149515951695179518951995209521952295239524952595269527952895299530953195329533953495359536953795389539954095419542954395449545954695479548954995509551955295539554955595569557955895599560956195629563956495659566956795689569957095719572957395749575957695779578957995809581958295839584958595869587958895899590959195929593959495959596959795989599960096019602960396049605960696079608960996109611961296139614961596169617961896199620962196229623962496259626962796289629963096319632963396349635963696379638963996409641964296439644964596469647964896499650965196529653965496559656965796589659966096619662966396649665966696679668966996709671967296739674967596769677967896799680968196829683968496859686968796889689969096919692969396949695969696979698969997009701970297039704970597069707970897099710971197129713971497159716971797189719972097219722972397249725972697279728972997309731973297339734973597369737973897399740974197429743974497459746974797489749975097519752975397549755975697579758975997609761976297639764976597669767976897699770977197729773977497759776977797789779978097819782978397849785978697879788978997909791979297939794979597969797979897999800980198029803980498059806980798089809981098119812981398149815981698179818981998209821982298239824982598269827982898299830983198329833983498359836983798389839984098419842984398449845984698479848984998509851985298539854985598569857985898599860986198629863986498659866986798689869987098719872987398749875987698779878987998809881988298839884988598869887988898899890989198929893989498959896989798989899990099019902990399049905990699079908990999109911991299139914991599169917991899199920992199229923992499259926992799289929993099319932993399349935993699379938993999409941994299439944994599469947994899499950995199529953995499559956995799589959996099619962996399649965996699679968996999709971997299739974997599769977997899799980998199829983998499859986998799889989999099919992999399949995999699979998999910000100011000210003100041000510006100071000810009100101001110012100131001410015100161001710018100191002010021100221002310024100251002610027100281002910030100311003210033100341003510036100371003810039100401004110042100431004410045100461004710048100491005010051100521005310054100551005610057100581005910060100611006210063100641006510066100671006810069100701007110072100731007410075100761007710078100791008010081100821008310084100851008610087100881008910090100911009210093100941009510096100971009810099101001010110102101031010410105101061010710108101091011010111101121011310114101151011610117101181011910120101211012210123101241012510126101271012810129101301013110132101331013410135101361013710138101391014010141101421014310144101451014610147101481014910150101511015210153101541015510156101571015810159101601016110162101631016410165101661016710168101691017010171101721017310174101751017610177101781017910180101811018210183101841018510186101871018810189101901019110192101931019410195101961019710198101991020010201102021020310204102051020610207102081020910210102111021210213102141021510216102171021810219102201022110222102231022410225102261022710228102291023010231102321023310234102351023610237102381023910240102411024210243102441024510246102471024810249102501025110252102531025410255102561025710258102591026010261102621026310264102651026610267102681026910270102711027210273102741027510276102771027810279102801028110282102831028410285102861028710288102891029010291102921029310294102951029610297102981029910300103011030210303103041030510306103071030810309103101031110312103131031410315103161031710318103191032010321103221032310324103251032610327103281032910330103311033210333103341033510336103371033810339103401034110342103431034410345103461034710348103491035010351103521035310354103551035610357103581035910360103611036210363103641036510366103671036810369103701037110372103731037410375103761037710378103791038010381103821038310384103851038610387103881038910390103911039210393103941039510396103971039810399104001040110402104031040410405104061040710408104091041010411104121041310414104151041610417104181041910420104211042210423104241042510426104271042810429104301043110432104331043410435104361043710438104391044010441104421044310444104451044610447104481044910450104511045210453104541045510456104571045810459104601046110462104631046410465104661046710468104691047010471104721047310474104751047610477104781047910480104811048210483104841048510486104871048810489104901049110492104931049410495104961049710498104991050010501105021050310504105051050610507105081050910510105111051210513105141051510516105171051810519105201052110522105231052410525105261052710528105291053010531105321053310534105351053610537105381053910540105411054210543105441054510546105471054810549105501055110552105531055410555105561055710558105591056010561105621056310564105651056610567105681056910570105711057210573105741057510576105771057810579105801058110582105831058410585105861058710588105891059010591105921059310594105951059610597105981059910600106011060210603106041060510606106071060810609106101061110612106131061410615106161061710618106191062010621106221062310624106251062610627106281062910630106311063210633106341063510636106371063810639106401064110642106431064410645106461064710648106491065010651106521065310654106551065610657106581065910660106611066210663106641066510666106671066810669106701067110672106731067410675106761067710678106791068010681106821068310684106851068610687106881068910690106911069210693106941069510696106971069810699107001070110702107031070410705107061070710708107091071010711107121071310714107151071610717107181071910720107211072210723107241072510726107271072810729107301073110732107331073410735107361073710738107391074010741107421074310744107451074610747107481074910750107511075210753107541075510756107571075810759107601076110762107631076410765107661076710768107691077010771107721077310774107751077610777107781077910780107811078210783107841078510786107871078810789107901079110792107931079410795107961079710798107991080010801108021080310804108051080610807108081080910810108111081210813108141081510816108171081810819108201082110822108231082410825108261082710828108291083010831108321083310834108351083610837108381083910840108411084210843108441084510846108471084810849108501085110852108531085410855108561085710858108591086010861108621086310864108651086610867108681086910870108711087210873108741087510876108771087810879108801088110882108831088410885108861088710888108891089010891108921089310894108951089610897108981089910900109011090210903109041090510906109071090810909109101091110912109131091410915109161091710918109191092010921109221092310924109251092610927109281092910930109311093210933109341093510936109371093810939109401094110942109431094410945109461094710948109491095010951109521095310954109551095610957109581095910960109611096210963109641096510966109671096810969109701097110972109731097410975109761097710978109791098010981109821098310984109851098610987109881098910990109911099210993109941099510996109971099810999110001100111002110031100411005110061100711008110091101011011110121101311014110151101611017110181101911020110211102211023110241102511026110271102811029110301103111032110331103411035110361103711038110391104011041110421104311044110451104611047110481104911050110511105211053110541105511056110571105811059110601106111062110631106411065110661106711068110691107011071110721107311074110751107611077110781107911080110811108211083110841108511086110871108811089110901109111092110931109411095110961109711098110991110011101111021110311104111051110611107111081110911110111111111211113111141111511116111171111811119111201112111122111231112411125111261112711128111291113011131111321113311134111351113611137111381113911140111411114211143111441114511146111471114811149111501115111152111531115411155111561115711158111591116011161111621116311164111651116611167111681116911170111711117211173111741117511176111771117811179111801118111182111831118411185111861118711188111891119011191111921119311194111951119611197111981119911200112011120211203112041120511206112071120811209112101121111212112131121411215112161121711218112191122011221112221122311224112251122611227112281122911230112311123211233112341123511236112371123811239112401124111242112431124411245112461124711248112491125011251112521125311254112551125611257112581125911260112611126211263112641126511266112671126811269112701127111272112731127411275112761127711278112791128011281112821128311284112851128611287112881128911290112911129211293112941129511296112971129811299113001130111302113031130411305113061130711308113091131011311113121131311314113151131611317113181131911320113211132211323113241132511326113271132811329113301133111332113331133411335113361133711338113391134011341113421134311344113451134611347113481134911350113511135211353113541135511356113571135811359113601136111362113631136411365113661136711368113691137011371113721137311374113751137611377113781137911380113811138211383113841138511386113871138811389113901139111392113931139411395113961139711398113991140011401114021140311404114051140611407114081140911410114111141211413114141141511416114171141811419114201142111422114231142411425114261142711428114291143011431114321143311434114351143611437114381143911440114411144211443114441144511446114471144811449114501145111452114531145411455114561145711458114591146011461114621146311464114651146611467114681146911470114711147211473114741147511476114771147811479114801148111482114831148411485114861148711488114891149011491114921149311494114951149611497114981149911500115011150211503115041150511506115071150811509115101151111512115131151411515115161151711518115191152011521115221152311524115251152611527115281152911530115311153211533115341153511536115371153811539115401154111542115431154411545115461154711548115491155011551115521155311554115551155611557115581155911560115611156211563115641156511566115671156811569115701157111572115731157411575115761157711578115791158011581115821158311584115851158611587115881158911590115911159211593115941159511596115971159811599116001160111602116031160411605116061160711608116091161011611116121161311614116151161611617116181161911620116211162211623116241162511626116271162811629116301163111632116331163411635116361163711638116391164011641116421164311644116451164611647116481164911650116511165211653116541165511656116571165811659116601166111662116631166411665116661166711668116691167011671116721167311674116751167611677116781167911680116811168211683116841168511686116871168811689116901169111692116931169411695116961169711698116991170011701117021170311704117051170611707117081170911710117111171211713117141171511716117171171811719117201172111722117231172411725117261172711728117291173011731117321173311734117351173611737117381173911740117411174211743117441174511746117471174811749117501175111752117531175411755117561175711758117591176011761117621176311764117651176611767117681176911770117711177211773117741177511776117771177811779117801178111782117831178411785117861178711788117891179011791117921179311794117951179611797117981179911800118011180211803118041180511806118071180811809118101181111812118131181411815118161181711818118191182011821118221182311824118251182611827118281182911830118311183211833118341183511836118371183811839118401184111842118431184411845118461184711848118491185011851118521185311854118551185611857118581185911860118611186211863118641186511866118671186811869118701187111872118731187411875118761187711878118791188011881118821188311884118851188611887118881188911890118911189211893118941189511896118971189811899119001190111902119031190411905119061190711908119091191011911119121191311914119151191611917119181191911920119211192211923119241192511926119271192811929119301193111932119331193411935119361193711938119391194011941119421194311944119451194611947119481194911950119511195211953119541195511956119571195811959119601196111962119631196411965119661196711968119691197011971119721197311974119751197611977119781197911980119811198211983119841198511986119871198811989119901199111992119931199411995119961199711998119991200012001120021200312004120051200612007120081200912010120111201212013120141201512016120171201812019120201202112022120231202412025120261202712028120291203012031120321203312034120351203612037120381203912040120411204212043120441204512046120471204812049120501205112052120531205412055120561205712058120591206012061120621206312064120651206612067120681206912070120711207212073120741207512076120771207812079120801208112082120831208412085120861208712088120891209012091120921209312094120951209612097120981209912100121011210212103121041210512106121071210812109121101211112112121131211412115121161211712118121191212012121121221212312124121251212612127121281212912130121311213212133121341213512136121371213812139121401214112142121431214412145121461214712148121491215012151121521215312154121551215612157121581215912160121611216212163121641216512166121671216812169121701217112172121731217412175121761217712178121791218012181121821218312184121851218612187121881218912190121911219212193121941219512196121971219812199122001220112202122031220412205122061220712208122091221012211122121221312214122151221612217122181221912220122211222212223122241222512226122271222812229122301223112232122331223412235122361223712238122391224012241122421224312244122451224612247122481224912250122511225212253122541225512256122571225812259122601226112262122631226412265122661226712268122691227012271122721227312274122751227612277122781227912280122811228212283122841228512286122871228812289122901229112292122931229412295122961229712298122991230012301123021230312304123051230612307123081230912310123111231212313123141231512316123171231812319123201232112322123231232412325123261232712328123291233012331123321233312334123351233612337123381233912340123411234212343123441234512346123471234812349123501235112352123531235412355123561235712358123591236012361123621236312364123651236612367123681236912370123711237212373123741237512376123771237812379123801238112382123831238412385123861238712388123891239012391123921239312394123951239612397123981239912400124011240212403124041240512406124071240812409124101241112412124131241412415124161241712418124191242012421124221242312424124251242612427124281242912430124311243212433124341243512436124371243812439124401244112442124431244412445124461244712448124491245012451124521245312454124551245612457124581245912460124611246212463124641246512466124671246812469124701247112472124731247412475124761247712478124791248012481124821248312484124851248612487124881248912490124911249212493124941249512496124971249812499125001250112502125031250412505125061250712508125091251012511125121251312514125151251612517125181251912520125211252212523125241252512526125271252812529125301253112532125331253412535125361253712538125391254012541125421254312544125451254612547125481254912550125511255212553125541255512556125571255812559125601256112562125631256412565125661256712568125691257012571125721257312574125751257612577125781257912580125811258212583125841258512586125871258812589125901259112592125931259412595125961259712598125991260012601126021260312604126051260612607126081260912610126111261212613126141261512616126171261812619126201262112622126231262412625126261262712628126291263012631126321263312634126351263612637126381263912640126411264212643126441264512646126471264812649126501265112652126531265412655126561265712658126591266012661126621266312664126651266612667126681266912670126711267212673126741267512676126771267812679126801268112682126831268412685126861268712688126891269012691126921269312694126951269612697126981269912700127011270212703127041270512706127071270812709127101271112712127131271412715127161271712718127191272012721127221272312724127251272612727127281272912730127311273212733127341273512736127371273812739127401274112742127431274412745127461274712748127491275012751127521275312754127551275612757127581275912760127611276212763127641276512766127671276812769127701277112772127731277412775127761277712778127791278012781127821278312784127851278612787127881278912790127911279212793127941279512796127971279812799128001280112802128031280412805128061280712808128091281012811128121281312814128151281612817128181281912820128211282212823128241282512826128271282812829128301283112832128331283412835128361283712838128391284012841128421284312844128451284612847128481284912850128511285212853128541285512856128571285812859128601286112862128631286412865128661286712868128691287012871128721287312874128751287612877128781287912880128811288212883128841288512886128871288812889128901289112892128931289412895128961289712898128991290012901129021290312904129051290612907129081290912910129111291212913129141291512916129171291812919129201292112922129231292412925129261292712928129291293012931129321293312934129351293612937129381293912940129411294212943129441294512946129471294812949129501295112952129531295412955129561295712958129591296012961129621296312964129651296612967129681296912970129711297212973129741297512976129771297812979129801298112982129831298412985129861298712988129891299012991129921299312994129951299612997129981299913000130011300213003130041300513006130071300813009130101301113012130131301413015130161301713018130191302013021130221302313024130251302613027130281302913030130311303213033130341303513036130371303813039130401304113042130431304413045130461304713048130491305013051130521305313054130551305613057130581305913060130611306213063130641306513066130671306813069130701307113072130731307413075130761307713078130791308013081130821308313084130851308613087130881308913090130911309213093130941309513096130971309813099131001310113102131031310413105131061310713108131091311013111131121311313114131151311613117131181311913120131211312213123131241312513126131271312813129131301313113132131331313413135131361313713138131391314013141131421314313144131451314613147131481314913150131511315213153131541315513156131571315813159131601316113162131631316413165131661316713168131691317013171131721317313174131751317613177131781317913180131811318213183131841318513186131871318813189131901319113192131931319413195131961319713198131991320013201132021320313204132051320613207132081320913210132111321213213132141321513216132171321813219132201322113222132231322413225132261322713228132291323013231132321323313234132351323613237132381323913240132411324213243132441324513246132471324813249132501325113252132531325413255132561325713258132591326013261132621326313264132651326613267132681326913270132711327213273132741327513276132771327813279132801328113282132831328413285132861328713288132891329013291132921329313294132951329613297132981329913300133011330213303133041330513306133071330813309133101331113312133131331413315133161331713318133191332013321133221332313324133251332613327133281332913330133311333213333133341333513336133371333813339133401334113342133431334413345133461334713348133491335013351133521335313354133551335613357133581335913360133611336213363133641336513366133671336813369133701337113372133731337413375133761337713378133791338013381133821338313384133851338613387133881338913390133911339213393133941339513396133971339813399134001340113402134031340413405134061340713408134091341013411134121341313414134151341613417134181341913420134211342213423134241342513426134271342813429134301343113432134331343413435134361343713438134391344013441134421344313444134451344613447134481344913450134511345213453134541345513456134571345813459134601346113462134631346413465134661346713468134691347013471134721347313474134751347613477134781347913480134811348213483134841348513486134871348813489134901349113492134931349413495134961349713498134991350013501135021350313504135051350613507135081350913510135111351213513135141351513516135171351813519135201352113522135231352413525135261352713528135291353013531135321353313534135351353613537135381353913540135411354213543135441354513546135471354813549135501355113552135531355413555135561355713558135591356013561135621356313564135651356613567135681356913570135711357213573135741357513576135771357813579135801358113582135831358413585135861358713588135891359013591135921359313594135951359613597135981359913600136011360213603136041360513606136071360813609136101361113612136131361413615136161361713618136191362013621136221362313624136251362613627136281362913630136311363213633136341363513636136371363813639136401364113642136431364413645136461364713648136491365013651136521365313654136551365613657136581365913660136611366213663136641366513666136671366813669136701367113672136731367413675136761367713678136791368013681136821368313684136851368613687136881368913690136911369213693136941369513696136971369813699137001370113702137031370413705137061370713708137091371013711137121371313714137151371613717137181371913720137211372213723137241372513726137271372813729137301373113732137331373413735137361373713738137391374013741137421374313744137451374613747137481374913750137511375213753137541375513756137571375813759137601376113762137631376413765137661376713768137691377013771137721377313774137751377613777137781377913780137811378213783137841378513786137871378813789137901379113792137931379413795137961379713798137991380013801138021380313804138051380613807138081380913810138111381213813138141381513816138171381813819138201382113822138231382413825138261382713828138291383013831138321383313834138351383613837138381383913840138411384213843138441384513846138471384813849138501385113852138531385413855138561385713858138591386013861138621386313864138651386613867138681386913870138711387213873138741387513876138771387813879138801388113882138831388413885138861388713888138891389013891138921389313894138951389613897138981389913900139011390213903139041390513906139071390813909139101391113912139131391413915139161391713918139191392013921139221392313924139251392613927139281392913930139311393213933139341393513936139371393813939139401394113942139431394413945139461394713948139491395013951139521395313954139551395613957139581395913960139611396213963139641396513966139671396813969139701397113972139731397413975139761397713978139791398013981139821398313984139851398613987139881398913990139911399213993139941399513996139971399813999140001400114002140031400414005140061400714008140091401014011140121401314014140151401614017140181401914020140211402214023140241402514026140271402814029140301403114032140331403414035140361403714038140391404014041140421404314044140451404614047140481404914050140511405214053140541405514056140571405814059140601406114062140631406414065140661406714068140691407014071140721407314074140751407614077140781407914080140811408214083140841408514086140871408814089140901409114092140931409414095140961409714098140991410014101141021410314104141051410614107141081410914110141111411214113141141411514116141171411814119141201412114122141231412414125141261412714128141291413014131141321413314134141351413614137141381413914140141411414214143141441414514146141471414814149141501415114152141531415414155141561415714158141591416014161141621416314164141651416614167141681416914170141711417214173141741417514176141771417814179141801418114182141831418414185141861418714188141891419014191141921419314194141951419614197141981419914200142011420214203142041420514206142071420814209142101421114212142131421414215142161421714218142191422014221142221422314224142251422614227142281422914230142311423214233142341423514236142371423814239142401424114242142431424414245142461424714248142491425014251142521425314254142551425614257142581425914260142611426214263142641426514266142671426814269142701427114272142731427414275142761427714278142791428014281142821428314284142851428614287142881428914290142911429214293142941429514296142971429814299143001430114302143031430414305143061430714308143091431014311143121431314314143151431614317143181431914320143211432214323143241432514326143271432814329143301433114332143331433414335143361433714338143391434014341143421434314344143451434614347143481434914350143511435214353143541435514356143571435814359143601436114362143631436414365143661436714368143691437014371143721437314374143751437614377143781437914380143811438214383143841438514386143871438814389143901439114392143931439414395143961439714398143991440014401144021440314404144051440614407144081440914410144111441214413144141441514416144171441814419144201442114422144231442414425144261442714428144291443014431144321443314434144351443614437144381443914440144411444214443144441444514446144471444814449144501445114452144531445414455144561445714458144591446014461144621446314464144651446614467144681446914470144711447214473144741447514476144771447814479144801448114482144831448414485144861448714488144891449014491144921449314494144951449614497144981449914500145011450214503145041450514506145071450814509145101451114512145131451414515145161451714518145191452014521145221452314524145251452614527145281452914530145311453214533145341453514536145371453814539145401454114542145431454414545145461454714548145491455014551145521455314554145551455614557145581455914560145611456214563145641456514566145671456814569145701457114572145731457414575145761457714578145791458014581145821458314584145851458614587145881458914590145911459214593145941459514596145971459814599146001460114602146031460414605146061460714608146091461014611146121461314614146151461614617146181461914620146211462214623146241462514626146271462814629146301463114632146331463414635146361463714638146391464014641146421464314644146451464614647146481464914650146511465214653146541465514656146571465814659146601466114662146631466414665146661466714668146691467014671146721467314674146751467614677146781467914680146811468214683146841468514686146871468814689146901469114692146931469414695146961469714698146991470014701147021470314704147051470614707147081470914710147111471214713147141471514716147171471814719147201472114722147231472414725147261472714728147291473014731147321473314734147351473614737147381473914740147411474214743147441474514746147471474814749147501475114752147531475414755147561475714758147591476014761147621476314764147651476614767147681476914770147711477214773147741477514776147771477814779147801478114782147831478414785147861478714788147891479014791147921479314794147951479614797147981479914800148011480214803148041480514806148071480814809148101481114812148131481414815148161481714818148191482014821148221482314824148251482614827148281482914830148311483214833148341483514836148371483814839148401484114842148431484414845148461484714848148491485014851148521485314854148551485614857148581485914860148611486214863148641486514866148671486814869148701487114872148731487414875148761487714878148791488014881148821488314884148851488614887148881488914890148911489214893148941489514896148971489814899149001490114902149031490414905149061490714908149091491014911149121491314914149151491614917149181491914920149211492214923149241492514926149271492814929149301493114932149331493414935149361493714938149391494014941149421494314944149451494614947149481494914950149511495214953149541495514956149571495814959149601496114962149631496414965149661496714968149691497014971149721497314974149751497614977149781497914980149811498214983149841498514986149871498814989149901499114992149931499414995149961499714998149991500015001150021500315004150051500615007150081500915010150111501215013150141501515016150171501815019150201502115022150231502415025150261502715028150291503015031150321503315034150351503615037150381503915040150411504215043150441504515046150471504815049150501505115052150531505415055150561505715058150591506015061150621506315064150651506615067150681506915070150711507215073150741507515076150771507815079150801508115082150831508415085150861508715088150891509015091150921509315094150951509615097150981509915100151011510215103151041510515106151071510815109151101511115112151131511415115151161511715118151191512015121151221512315124151251512615127151281512915130151311513215133151341513515136151371513815139151401514115142151431514415145151461514715148151491515015151151521515315154151551515615157151581515915160151611516215163151641516515166151671516815169151701517115172151731517415175151761517715178151791518015181151821518315184151851518615187151881518915190151911519215193151941519515196151971519815199152001520115202152031520415205152061520715208152091521015211152121521315214152151521615217152181521915220152211522215223152241522515226152271522815229152301523115232152331523415235152361523715238152391524015241152421524315244152451524615247152481524915250152511525215253152541525515256152571525815259152601526115262152631526415265152661526715268152691527015271152721527315274152751527615277152781527915280152811528215283152841528515286152871528815289152901529115292152931529415295152961529715298152991530015301153021530315304153051530615307153081530915310153111531215313153141531515316153171531815319153201532115322153231532415325153261532715328153291533015331153321533315334153351533615337153381533915340153411534215343153441534515346153471534815349153501535115352153531535415355153561535715358153591536015361153621536315364153651536615367153681536915370153711537215373153741537515376153771537815379153801538115382153831538415385153861538715388153891539015391153921539315394153951539615397153981539915400154011540215403154041540515406154071540815409154101541115412154131541415415154161541715418154191542015421154221542315424154251542615427154281542915430154311543215433154341543515436154371543815439154401544115442154431544415445154461544715448154491545015451154521545315454154551545615457154581545915460154611546215463154641546515466154671546815469154701547115472154731547415475154761547715478154791548015481154821548315484154851548615487154881548915490154911549215493154941549515496154971549815499155001550115502155031550415505155061550715508155091551015511155121551315514155151551615517155181551915520155211552215523155241552515526155271552815529155301553115532155331553415535155361553715538155391554015541155421554315544155451554615547155481554915550155511555215553155541555515556155571555815559155601556115562155631556415565155661556715568155691557015571155721557315574155751557615577155781557915580155811558215583155841558515586155871558815589155901559115592155931559415595155961559715598155991560015601156021560315604156051560615607156081560915610156111561215613156141561515616156171561815619156201562115622156231562415625156261562715628156291563015631156321563315634156351563615637156381563915640156411564215643156441564515646156471564815649156501565115652156531565415655156561565715658156591566015661156621566315664156651566615667156681566915670156711567215673156741567515676156771567815679156801568115682156831568415685156861568715688156891569015691156921569315694156951569615697156981569915700157011570215703157041570515706157071570815709157101571115712157131571415715157161571715718157191572015721157221572315724157251572615727157281572915730157311573215733157341573515736157371573815739157401574115742157431574415745157461574715748157491575015751157521575315754157551575615757157581575915760157611576215763157641576515766157671576815769157701577115772157731577415775157761577715778157791578015781157821578315784157851578615787157881578915790157911579215793157941579515796157971579815799158001580115802158031580415805158061580715808158091581015811158121581315814158151581615817158181581915820158211582215823158241582515826158271582815829158301583115832158331583415835158361583715838158391584015841158421584315844158451584615847158481584915850158511585215853158541585515856158571585815859158601586115862158631586415865158661586715868158691587015871158721587315874158751587615877158781587915880158811588215883158841588515886158871588815889158901589115892158931589415895158961589715898158991590015901159021590315904159051590615907159081590915910159111591215913159141591515916159171591815919159201592115922159231592415925159261592715928159291593015931159321593315934159351593615937159381593915940159411594215943159441594515946159471594815949159501595115952159531595415955159561595715958159591596015961159621596315964159651596615967159681596915970159711597215973159741597515976159771597815979159801598115982159831598415985159861598715988159891599015991159921599315994159951599615997159981599916000160011600216003160041600516006160071600816009160101601116012160131601416015160161601716018160191602016021160221602316024160251602616027160281602916030160311603216033160341603516036160371603816039160401604116042160431604416045160461604716048160491605016051160521605316054160551605616057160581605916060160611606216063160641606516066160671606816069160701607116072160731607416075160761607716078160791608016081160821608316084160851608616087160881608916090160911609216093160941609516096160971609816099161001610116102161031610416105161061610716108161091611016111161121611316114161151611616117161181611916120161211612216123161241612516126161271612816129161301613116132161331613416135161361613716138161391614016141161421614316144161451614616147161481614916150161511615216153161541615516156161571615816159161601616116162161631616416165161661616716168161691617016171161721617316174161751617616177161781617916180161811618216183161841618516186161871618816189161901619116192161931619416195161961619716198161991620016201162021620316204162051620616207162081620916210162111621216213162141621516216162171621816219162201622116222162231622416225162261622716228162291623016231162321623316234162351623616237162381623916240162411624216243162441624516246162471624816249162501625116252162531625416255162561625716258162591626016261162621626316264162651626616267162681626916270162711627216273162741627516276162771627816279162801628116282162831628416285162861628716288162891629016291162921629316294162951629616297162981629916300163011630216303163041630516306163071630816309163101631116312163131631416315163161631716318163191632016321163221632316324163251632616327163281632916330163311633216333163341633516336163371633816339163401634116342163431634416345163461634716348163491635016351163521635316354163551635616357163581635916360163611636216363163641636516366163671636816369163701637116372163731637416375163761637716378163791638016381163821638316384163851638616387163881638916390163911639216393163941639516396163971639816399164001640116402164031640416405164061640716408164091641016411164121641316414164151641616417164181641916420164211642216423164241642516426164271642816429164301643116432164331643416435164361643716438164391644016441164421644316444164451644616447164481644916450164511645216453164541645516456164571645816459164601646116462164631646416465164661646716468164691647016471164721647316474164751647616477164781647916480164811648216483164841648516486164871648816489164901649116492164931649416495164961649716498164991650016501165021650316504165051650616507165081650916510165111651216513165141651516516165171651816519165201652116522165231652416525165261652716528165291653016531165321653316534165351653616537165381653916540165411654216543165441654516546165471654816549165501655116552165531655416555165561655716558165591656016561165621656316564165651656616567165681656916570165711657216573165741657516576165771657816579165801658116582165831658416585165861658716588165891659016591165921659316594165951659616597165981659916600166011660216603166041660516606166071660816609166101661116612166131661416615166161661716618166191662016621166221662316624166251662616627166281662916630166311663216633166341663516636166371663816639166401664116642166431664416645166461664716648166491665016651166521665316654166551665616657166581665916660166611666216663166641666516666166671666816669166701667116672166731667416675166761667716678166791668016681166821668316684166851668616687166881668916690166911669216693166941669516696166971669816699167001670116702167031670416705167061670716708167091671016711167121671316714167151671616717167181671916720167211672216723167241672516726167271672816729167301673116732167331673416735167361673716738167391674016741167421674316744167451674616747167481674916750167511675216753167541675516756167571675816759167601676116762167631676416765167661676716768167691677016771167721677316774167751677616777167781677916780167811678216783167841678516786167871678816789167901679116792167931679416795167961679716798167991680016801168021680316804168051680616807168081680916810168111681216813168141681516816168171681816819168201682116822168231682416825168261682716828168291683016831168321683316834168351683616837168381683916840168411684216843168441684516846168471684816849168501685116852168531685416855168561685716858168591686016861168621686316864168651686616867168681686916870168711687216873168741687516876168771687816879168801688116882168831688416885168861688716888168891689016891168921689316894168951689616897168981689916900169011690216903169041690516906169071690816909169101691116912169131691416915169161691716918169191692016921169221692316924169251692616927169281692916930169311693216933169341693516936169371693816939169401694116942169431694416945169461694716948169491695016951169521695316954169551695616957169581695916960169611696216963169641696516966169671696816969169701697116972169731697416975169761697716978169791698016981169821698316984169851698616987169881698916990169911699216993169941699516996169971699816999170001700117002170031700417005170061700717008170091701017011170121701317014170151701617017170181701917020170211702217023170241702517026170271702817029170301703117032170331703417035170361703717038170391704017041170421704317044170451704617047170481704917050170511705217053170541705517056170571705817059170601706117062170631706417065170661706717068170691707017071170721707317074170751707617077170781707917080170811708217083170841708517086170871708817089170901709117092170931709417095170961709717098170991710017101171021710317104171051710617107171081710917110171111711217113171141711517116171171711817119171201712117122171231712417125171261712717128171291713017131171321713317134171351713617137171381713917140171411714217143171441714517146171471714817149171501715117152171531715417155171561715717158171591716017161171621716317164171651716617167171681716917170171711717217173171741717517176171771717817179171801718117182171831718417185171861718717188171891719017191171921719317194171951719617197171981719917200172011720217203172041720517206172071720817209172101721117212172131721417215172161721717218172191722017221172221722317224172251722617227172281722917230172311723217233172341723517236172371723817239172401724117242172431724417245172461724717248172491725017251172521725317254172551725617257172581725917260172611726217263172641726517266172671726817269172701727117272172731727417275172761727717278172791728017281172821728317284172851728617287172881728917290172911729217293172941729517296172971729817299173001730117302173031730417305173061730717308173091731017311173121731317314173151731617317173181731917320173211732217323173241732517326173271732817329173301733117332173331733417335173361733717338173391734017341173421734317344173451734617347173481734917350173511735217353173541735517356173571735817359173601736117362173631736417365173661736717368173691737017371173721737317374173751737617377173781737917380173811738217383173841738517386173871738817389173901739117392173931739417395173961739717398173991740017401174021740317404174051740617407174081740917410174111741217413174141741517416174171741817419174201742117422174231742417425174261742717428174291743017431174321743317434174351743617437174381743917440174411744217443174441744517446174471744817449174501745117452174531745417455174561745717458174591746017461174621746317464174651746617467174681746917470174711747217473174741747517476174771747817479174801748117482174831748417485174861748717488174891749017491174921749317494174951749617497174981749917500175011750217503175041750517506175071750817509175101751117512175131751417515175161751717518175191752017521175221752317524175251752617527175281752917530175311753217533175341753517536175371753817539175401754117542175431754417545175461754717548175491755017551175521755317554175551755617557175581755917560175611756217563175641756517566175671756817569175701757117572175731757417575175761757717578175791758017581175821758317584175851758617587175881758917590175911759217593175941759517596175971759817599176001760117602176031760417605176061760717608176091761017611176121761317614176151761617617176181761917620176211762217623176241762517626176271762817629176301763117632176331763417635176361763717638176391764017641176421764317644176451764617647176481764917650176511765217653176541765517656176571765817659176601766117662176631766417665176661766717668176691767017671176721767317674176751767617677176781767917680176811768217683176841768517686176871768817689176901769117692176931769417695176961769717698176991770017701177021770317704177051770617707177081770917710177111771217713177141771517716177171771817719177201772117722177231772417725177261772717728177291773017731177321773317734177351773617737177381773917740177411774217743177441774517746177471774817749177501775117752177531775417755177561775717758177591776017761177621776317764177651776617767177681776917770177711777217773177741777517776177771777817779177801778117782177831778417785177861778717788177891779017791177921779317794177951779617797177981779917800178011780217803178041780517806178071780817809178101781117812178131781417815178161781717818178191782017821178221782317824178251782617827178281782917830178311783217833178341783517836178371783817839178401784117842178431784417845178461784717848178491785017851178521785317854178551785617857178581785917860178611786217863178641786517866178671786817869178701787117872178731787417875178761787717878178791788017881178821788317884178851788617887178881788917890178911789217893178941789517896178971789817899179001790117902179031790417905179061790717908179091791017911179121791317914179151791617917179181791917920179211792217923179241792517926179271792817929179301793117932179331793417935179361793717938179391794017941179421794317944179451794617947179481794917950179511795217953179541795517956179571795817959179601796117962179631796417965179661796717968179691797017971179721797317974179751797617977179781797917980179811798217983179841798517986179871798817989179901799117992179931799417995179961799717998179991800018001180021800318004180051800618007180081800918010180111801218013180141801518016180171801818019180201802118022180231802418025180261802718028180291803018031180321803318034180351803618037180381803918040180411804218043180441804518046180471804818049180501805118052180531805418055180561805718058180591806018061180621806318064180651806618067180681806918070180711807218073180741807518076180771807818079180801808118082180831808418085180861808718088180891809018091180921809318094180951809618097180981809918100181011810218103181041810518106181071810818109181101811118112181131811418115181161811718118181191812018121181221812318124181251812618127181281812918130181311813218133181341813518136181371813818139181401814118142181431814418145181461814718148181491815018151181521815318154181551815618157181581815918160181611816218163181641816518166181671816818169181701817118172181731817418175181761817718178181791818018181181821818318184181851818618187181881818918190181911819218193181941819518196181971819818199182001820118202182031820418205182061820718208182091821018211182121821318214182151821618217182181821918220182211822218223182241822518226182271822818229182301823118232182331823418235182361823718238182391824018241182421824318244182451824618247182481824918250182511825218253182541825518256182571825818259182601826118262182631826418265182661826718268182691827018271182721827318274182751827618277182781827918280182811828218283182841828518286182871828818289182901829118292182931829418295182961829718298182991830018301183021830318304183051830618307183081830918310183111831218313183141831518316183171831818319183201832118322183231832418325183261832718328183291833018331183321833318334183351833618337183381833918340183411834218343183441834518346183471834818349183501835118352183531835418355183561835718358183591836018361183621836318364183651836618367183681836918370183711837218373183741837518376183771837818379183801838118382183831838418385183861838718388183891839018391183921839318394183951839618397183981839918400184011840218403184041840518406184071840818409184101841118412184131841418415184161841718418184191842018421184221842318424184251842618427184281842918430184311843218433184341843518436184371843818439184401844118442184431844418445184461844718448184491845018451184521845318454184551845618457184581845918460184611846218463184641846518466184671846818469184701847118472184731847418475184761847718478184791848018481184821848318484184851848618487184881848918490184911849218493184941849518496184971849818499185001850118502185031850418505185061850718508185091851018511185121851318514185151851618517185181851918520185211852218523185241852518526185271852818529185301853118532185331853418535185361853718538185391854018541185421854318544185451854618547185481854918550185511855218553185541855518556185571855818559185601856118562185631856418565185661856718568185691857018571185721857318574185751857618577185781857918580185811858218583185841858518586185871858818589185901859118592185931859418595185961859718598185991860018601186021860318604186051860618607186081860918610186111861218613186141861518616186171861818619186201862118622186231862418625186261862718628186291863018631186321863318634186351863618637186381863918640186411864218643186441864518646186471864818649186501865118652186531865418655186561865718658186591866018661186621866318664186651866618667186681866918670186711867218673186741867518676186771867818679186801868118682186831868418685186861868718688186891869018691186921869318694186951869618697186981869918700187011870218703187041870518706187071870818709187101871118712187131871418715187161871718718187191872018721187221872318724187251872618727187281872918730187311873218733187341873518736187371873818739187401874118742187431874418745187461874718748187491875018751187521875318754187551875618757187581875918760187611876218763187641876518766187671876818769187701877118772187731877418775187761877718778187791878018781187821878318784187851878618787187881878918790187911879218793187941879518796187971879818799188001880118802188031880418805188061880718808188091881018811188121881318814188151881618817188181881918820188211882218823188241882518826188271882818829188301883118832188331883418835188361883718838188391884018841188421884318844188451884618847188481884918850188511885218853188541885518856188571885818859188601886118862188631886418865188661886718868188691887018871188721887318874188751887618877188781887918880188811888218883188841888518886188871888818889188901889118892188931889418895188961889718898188991890018901189021890318904189051890618907189081890918910189111891218913189141891518916189171891818919189201892118922189231892418925189261892718928189291893018931189321893318934189351893618937189381893918940189411894218943189441894518946189471894818949189501895118952189531895418955189561895718958189591896018961189621896318964189651896618967189681896918970189711897218973189741897518976189771897818979189801898118982189831898418985189861898718988189891899018991189921899318994189951899618997189981899919000190011900219003190041900519006190071900819009190101901119012190131901419015190161901719018190191902019021190221902319024190251902619027190281902919030190311903219033190341903519036190371903819039190401904119042190431904419045190461904719048190491905019051190521905319054190551905619057190581905919060190611906219063190641906519066190671906819069190701907119072190731907419075190761907719078190791908019081190821908319084190851908619087190881908919090190911909219093190941909519096190971909819099191001910119102191031910419105191061910719108191091911019111191121911319114191151911619117191181911919120191211912219123191241912519126191271912819129191301913119132191331913419135191361913719138191391914019141191421914319144191451914619147191481914919150191511915219153191541915519156191571915819159191601916119162191631916419165191661916719168191691917019171191721917319174191751917619177191781917919180191811918219183191841918519186191871918819189191901919119192191931919419195191961919719198191991920019201192021920319204192051920619207192081920919210192111921219213192141921519216192171921819219192201922119222192231922419225192261922719228192291923019231192321923319234192351923619237192381923919240192411924219243192441924519246192471924819249192501925119252192531925419255192561925719258192591926019261192621926319264192651926619267192681926919270192711927219273192741927519276192771927819279192801928119282192831928419285192861928719288192891929019291192921929319294192951929619297192981929919300193011930219303193041930519306193071930819309193101931119312193131931419315193161931719318193191932019321193221932319324193251932619327193281932919330193311933219333193341933519336193371933819339193401934119342193431934419345193461934719348193491935019351193521935319354193551935619357193581935919360193611936219363193641936519366193671936819369193701937119372193731937419375193761937719378193791938019381193821938319384193851938619387193881938919390193911939219393193941939519396193971939819399194001940119402194031940419405194061940719408194091941019411194121941319414194151941619417194181941919420194211942219423194241942519426194271942819429194301943119432194331943419435194361943719438194391944019441194421944319444194451944619447194481944919450194511945219453194541945519456194571945819459194601946119462194631946419465194661946719468194691947019471194721947319474194751947619477194781947919480194811948219483194841948519486194871948819489194901949119492194931949419495194961949719498194991950019501195021950319504195051950619507195081950919510195111951219513195141951519516195171951819519195201952119522195231952419525195261952719528195291953019531195321953319534195351953619537195381953919540195411954219543195441954519546195471954819549195501955119552195531955419555195561955719558195591956019561195621956319564195651956619567195681956919570195711957219573195741957519576195771957819579195801958119582195831958419585195861958719588195891959019591195921959319594195951959619597195981959919600196011960219603196041960519606196071960819609196101961119612196131961419615196161961719618196191962019621196221962319624196251962619627196281962919630196311963219633196341963519636196371963819639196401964119642196431964419645196461964719648196491965019651196521965319654196551965619657196581965919660196611966219663196641966519666196671966819669196701967119672196731967419675196761967719678196791968019681196821968319684196851968619687196881968919690196911969219693196941969519696196971969819699197001970119702197031970419705197061970719708197091971019711197121971319714197151971619717197181971919720197211972219723197241972519726197271972819729197301973119732197331973419735197361973719738197391974019741197421974319744197451974619747197481974919750197511975219753197541975519756197571975819759197601976119762197631976419765197661976719768197691977019771197721977319774197751977619777197781977919780197811978219783197841978519786197871978819789197901979119792197931979419795197961979719798197991980019801198021980319804198051980619807198081980919810198111981219813198141981519816198171981819819198201982119822198231982419825198261982719828198291983019831198321983319834198351983619837198381983919840198411984219843198441984519846198471984819849198501985119852198531985419855198561985719858198591986019861198621986319864198651986619867198681986919870198711987219873198741987519876198771987819879198801988119882198831988419885198861988719888198891989019891198921989319894198951989619897198981989919900199011990219903199041990519906199071990819909199101991119912199131991419915199161991719918199191992019921199221992319924199251992619927199281992919930199311993219933199341993519936199371993819939199401994119942199431994419945199461994719948199491995019951199521995319954199551995619957199581995919960199611996219963199641996519966199671996819969199701997119972199731997419975199761997719978199791998019981199821998319984199851998619987199881998919990199911999219993199941999519996199971999819999200002000120002200032000420005200062000720008200092001020011200122001320014200152001620017200182001920020200212002220023200242002520026200272002820029200302003120032200332003420035200362003720038200392004020041200422004320044200452004620047200482004920050200512005220053200542005520056200572005820059200602006120062200632006420065200662006720068200692007020071200722007320074200752007620077200782007920080200812008220083200842008520086200872008820089200902009120092200932009420095200962009720098200992010020101201022010320104201052010620107201082010920110201112011220113201142011520116201172011820119201202012120122201232012420125201262012720128201292013020131201322013320134201352013620137201382013920140201412014220143201442014520146201472014820149201502015120152201532015420155201562015720158201592016020161201622016320164201652016620167201682016920170201712017220173201742017520176201772017820179201802018120182201832018420185201862018720188201892019020191201922019320194201952019620197201982019920200202012020220203202042020520206202072020820209202102021120212202132021420215202162021720218202192022020221202222022320224202252022620227202282022920230202312023220233202342023520236202372023820239202402024120242202432024420245202462024720248202492025020251202522025320254202552025620257202582025920260202612026220263202642026520266202672026820269202702027120272202732027420275202762027720278202792028020281202822028320284202852028620287202882028920290202912029220293202942029520296202972029820299203002030120302203032030420305203062030720308203092031020311203122031320314203152031620317203182031920320203212032220323203242032520326203272032820329203302033120332203332033420335203362033720338203392034020341203422034320344203452034620347203482034920350203512035220353203542035520356203572035820359203602036120362203632036420365203662036720368203692037020371203722037320374203752037620377203782037920380203812038220383203842038520386203872038820389203902039120392203932039420395203962039720398203992040020401204022040320404204052040620407204082040920410204112041220413204142041520416204172041820419204202042120422204232042420425204262042720428204292043020431204322043320434204352043620437204382043920440204412044220443204442044520446204472044820449204502045120452204532045420455204562045720458204592046020461204622046320464204652046620467204682046920470204712047220473204742047520476204772047820479204802048120482204832048420485204862048720488204892049020491204922049320494204952049620497204982049920500205012050220503205042050520506205072050820509205102051120512205132051420515205162051720518205192052020521205222052320524205252052620527205282052920530205312053220533205342053520536205372053820539205402054120542205432054420545205462054720548205492055020551205522055320554205552055620557205582055920560205612056220563205642056520566205672056820569205702057120572205732057420575205762057720578205792058020581205822058320584205852058620587205882058920590205912059220593205942059520596205972059820599206002060120602206032060420605206062060720608206092061020611206122061320614206152061620617206182061920620206212062220623206242062520626206272062820629206302063120632206332063420635206362063720638206392064020641206422064320644206452064620647206482064920650206512065220653206542065520656206572065820659206602066120662206632066420665206662066720668206692067020671206722067320674206752067620677206782067920680206812068220683206842068520686206872068820689206902069120692206932069420695206962069720698206992070020701207022070320704207052070620707207082070920710207112071220713207142071520716207172071820719207202072120722207232072420725207262072720728207292073020731207322073320734207352073620737207382073920740207412074220743207442074520746207472074820749207502075120752207532075420755207562075720758207592076020761207622076320764207652076620767207682076920770207712077220773207742077520776207772077820779207802078120782207832078420785207862078720788207892079020791207922079320794207952079620797207982079920800208012080220803208042080520806208072080820809208102081120812208132081420815208162081720818208192082020821208222082320824208252082620827208282082920830208312083220833208342083520836208372083820839208402084120842208432084420845208462084720848208492085020851208522085320854208552085620857208582085920860208612086220863208642086520866208672086820869208702087120872208732087420875208762087720878208792088020881208822088320884208852088620887208882088920890208912089220893208942089520896208972089820899209002090120902209032090420905209062090720908209092091020911209122091320914209152091620917209182091920920209212092220923209242092520926209272092820929209302093120932209332093420935209362093720938209392094020941209422094320944209452094620947209482094920950209512095220953209542095520956209572095820959209602096120962209632096420965209662096720968209692097020971209722097320974209752097620977209782097920980209812098220983209842098520986209872098820989209902099120992209932099420995209962099720998209992100021001210022100321004210052100621007210082100921010210112101221013210142101521016210172101821019210202102121022210232102421025210262102721028210292103021031210322103321034210352103621037210382103921040210412104221043210442104521046210472104821049210502105121052210532105421055210562105721058210592106021061210622106321064210652106621067210682106921070210712107221073210742107521076210772107821079210802108121082210832108421085210862108721088210892109021091210922109321094210952109621097210982109921100211012110221103211042110521106211072110821109211102111121112211132111421115211162111721118211192112021121211222112321124211252112621127211282112921130211312113221133211342113521136211372113821139211402114121142211432114421145211462114721148211492115021151211522115321154211552115621157211582115921160211612116221163211642116521166211672116821169211702117121172211732117421175211762117721178211792118021181211822118321184211852118621187211882118921190211912119221193211942119521196211972119821199212002120121202212032120421205212062120721208212092121021211212122121321214212152121621217212182121921220212212122221223212242122521226212272122821229212302123121232212332123421235212362123721238212392124021241212422124321244212452124621247212482124921250212512125221253212542125521256212572125821259212602126121262212632126421265212662126721268212692127021271212722127321274212752127621277212782127921280212812128221283212842128521286212872128821289212902129121292212932129421295212962129721298212992130021301213022130321304213052130621307213082130921310213112131221313213142131521316213172131821319213202132121322213232132421325213262132721328213292133021331213322133321334213352133621337213382133921340213412134221343213442134521346213472134821349213502135121352213532135421355213562135721358213592136021361213622136321364213652136621367213682136921370213712137221373213742137521376213772137821379213802138121382213832138421385213862138721388213892139021391213922139321394213952139621397213982139921400214012140221403214042140521406214072140821409214102141121412214132141421415214162141721418214192142021421214222142321424214252142621427214282142921430214312143221433214342143521436214372143821439214402144121442214432144421445214462144721448214492145021451214522145321454214552145621457214582145921460214612146221463214642146521466214672146821469214702147121472214732147421475214762147721478214792148021481214822148321484214852148621487214882148921490214912149221493214942149521496214972149821499215002150121502215032150421505215062150721508215092151021511215122151321514215152151621517215182151921520215212152221523215242152521526215272152821529215302153121532215332153421535215362153721538215392154021541215422154321544215452154621547215482154921550215512155221553215542155521556215572155821559215602156121562215632156421565215662156721568215692157021571215722157321574215752157621577215782157921580215812158221583215842158521586215872158821589215902159121592215932159421595215962159721598215992160021601216022160321604216052160621607216082160921610216112161221613216142161521616216172161821619216202162121622216232162421625216262162721628216292163021631216322163321634216352163621637216382163921640216412164221643216442164521646216472164821649216502165121652216532165421655216562165721658216592166021661216622166321664216652166621667216682166921670216712167221673216742167521676216772167821679216802168121682216832168421685216862168721688216892169021691216922169321694216952169621697216982169921700217012170221703217042170521706217072170821709217102171121712217132171421715217162171721718217192172021721217222172321724217252172621727217282172921730217312173221733217342173521736217372173821739217402174121742217432174421745217462174721748217492175021751217522175321754217552175621757217582175921760217612176221763217642176521766217672176821769217702177121772217732177421775217762177721778217792178021781217822178321784217852178621787217882178921790217912179221793217942179521796217972179821799218002180121802218032180421805218062180721808218092181021811218122181321814218152181621817218182181921820218212182221823218242182521826218272182821829218302183121832218332183421835218362183721838218392184021841218422184321844218452184621847218482184921850218512185221853218542185521856218572185821859218602186121862218632186421865218662186721868218692187021871218722187321874218752187621877218782187921880218812188221883218842188521886218872188821889218902189121892218932189421895218962189721898218992190021901219022190321904219052190621907219082190921910219112191221913219142191521916219172191821919219202192121922219232192421925219262192721928219292193021931219322193321934219352193621937219382193921940219412194221943219442194521946219472194821949219502195121952219532195421955219562195721958219592196021961219622196321964219652196621967219682196921970219712197221973219742197521976219772197821979219802198121982219832198421985219862198721988219892199021991219922199321994219952199621997219982199922000220012200222003220042200522006220072200822009220102201122012220132201422015220162201722018220192202022021220222202322024220252202622027220282202922030220312203222033220342203522036220372203822039220402204122042220432204422045220462204722048220492205022051220522205322054220552205622057220582205922060220612206222063220642206522066220672206822069220702207122072220732207422075220762207722078220792208022081220822208322084220852208622087220882208922090220912209222093220942209522096220972209822099221002210122102221032210422105221062210722108221092211022111221122211322114221152211622117221182211922120221212212222123221242212522126221272212822129221302213122132221332213422135221362213722138221392214022141221422214322144221452214622147221482214922150221512215222153221542215522156221572215822159221602216122162221632216422165221662216722168221692217022171221722217322174221752217622177221782217922180221812218222183221842218522186221872218822189221902219122192221932219422195221962219722198221992220022201222022220322204222052220622207222082220922210222112221222213222142221522216222172221822219222202222122222222232222422225222262222722228222292223022231222322223322234222352223622237222382223922240222412224222243222442224522246222472224822249222502225122252222532225422255222562225722258222592226022261222622226322264222652226622267222682226922270222712227222273222742227522276222772227822279222802228122282222832228422285222862228722288222892229022291222922229322294222952229622297222982229922300223012230222303223042230522306223072230822309223102231122312223132231422315223162231722318223192232022321223222232322324223252232622327223282232922330223312233222333223342233522336223372233822339223402234122342223432234422345223462234722348223492235022351223522235322354223552235622357223582235922360223612236222363223642236522366223672236822369223702237122372223732237422375223762237722378223792238022381223822238322384223852238622387223882238922390223912239222393223942239522396223972239822399224002240122402224032240422405224062240722408224092241022411224122241322414224152241622417224182241922420224212242222423224242242522426224272242822429224302243122432224332243422435224362243722438224392244022441224422244322444224452244622447224482244922450224512245222453224542245522456224572245822459224602246122462224632246422465224662246722468224692247022471224722247322474224752247622477224782247922480224812248222483224842248522486224872248822489224902249122492224932249422495224962249722498224992250022501225022250322504225052250622507225082250922510225112251222513225142251522516225172251822519225202252122522225232252422525225262252722528225292253022531225322253322534225352253622537225382253922540225412254222543225442254522546225472254822549225502255122552225532255422555225562255722558225592256022561225622256322564225652256622567225682256922570225712257222573225742257522576225772257822579225802258122582225832258422585225862258722588225892259022591225922259322594225952259622597225982259922600226012260222603226042260522606226072260822609226102261122612226132261422615226162261722618226192262022621226222262322624226252262622627226282262922630226312263222633226342263522636226372263822639226402264122642226432264422645226462264722648226492265022651226522265322654226552265622657226582265922660226612266222663226642266522666226672266822669226702267122672226732267422675226762267722678226792268022681226822268322684226852268622687226882268922690226912269222693226942269522696226972269822699227002270122702227032270422705227062270722708227092271022711227122271322714227152271622717227182271922720227212272222723227242272522726227272272822729227302273122732227332273422735227362273722738227392274022741227422274322744227452274622747227482274922750227512275222753227542275522756227572275822759227602276122762227632276422765227662276722768227692277022771227722277322774227752277622777227782277922780227812278222783227842278522786227872278822789227902279122792227932279422795227962279722798227992280022801228022280322804228052280622807228082280922810228112281222813228142281522816228172281822819228202282122822228232282422825228262282722828228292283022831228322283322834228352283622837228382283922840228412284222843228442284522846228472284822849228502285122852228532285422855228562285722858228592286022861228622286322864228652286622867228682286922870228712287222873228742287522876228772287822879228802288122882228832288422885228862288722888228892289022891228922289322894228952289622897228982289922900229012290222903229042290522906229072290822909229102291122912229132291422915229162291722918229192292022921229222292322924229252292622927229282292922930229312293222933229342293522936229372293822939229402294122942229432294422945229462294722948229492295022951229522295322954229552295622957229582295922960229612296222963229642296522966229672296822969229702297122972229732297422975229762297722978229792298022981229822298322984229852298622987229882298922990229912299222993229942299522996229972299822999230002300123002230032300423005230062300723008230092301023011230122301323014230152301623017230182301923020230212302223023230242302523026230272302823029230302303123032230332303423035230362303723038230392304023041230422304323044230452304623047230482304923050230512305223053230542305523056230572305823059230602306123062230632306423065230662306723068230692307023071230722307323074230752307623077230782307923080230812308223083230842308523086230872308823089230902309123092230932309423095230962309723098230992310023101231022310323104231052310623107231082310923110231112311223113231142311523116231172311823119231202312123122231232312423125231262312723128231292313023131231322313323134231352313623137231382313923140231412314223143231442314523146231472314823149231502315123152231532315423155231562315723158231592316023161231622316323164231652316623167231682316923170231712317223173231742317523176231772317823179231802318123182231832318423185231862318723188231892319023191231922319323194231952319623197231982319923200232012320223203232042320523206232072320823209232102321123212232132321423215232162321723218232192322023221232222322323224232252322623227232282322923230232312323223233232342323523236232372323823239232402324123242232432324423245232462324723248232492325023251232522325323254232552325623257232582325923260232612326223263232642326523266232672326823269232702327123272232732327423275232762327723278232792328023281232822328323284232852328623287232882328923290232912329223293232942329523296232972329823299233002330123302233032330423305233062330723308233092331023311233122331323314233152331623317233182331923320233212332223323233242332523326233272332823329233302333123332233332333423335233362333723338233392334023341233422334323344233452334623347233482334923350233512335223353233542335523356233572335823359233602336123362233632336423365233662336723368233692337023371233722337323374233752337623377233782337923380233812338223383233842338523386233872338823389233902339123392233932339423395233962339723398233992340023401234022340323404234052340623407234082340923410234112341223413234142341523416234172341823419234202342123422234232342423425234262342723428234292343023431234322343323434234352343623437234382343923440234412344223443234442344523446234472344823449234502345123452234532345423455234562345723458234592346023461234622346323464234652346623467234682346923470234712347223473234742347523476234772347823479234802348123482234832348423485234862348723488234892349023491234922349323494234952349623497234982349923500235012350223503235042350523506235072350823509235102351123512235132351423515235162351723518235192352023521235222352323524235252352623527235282352923530235312353223533235342353523536235372353823539235402354123542235432354423545235462354723548235492355023551235522355323554235552355623557235582355923560235612356223563235642356523566235672356823569235702357123572235732357423575235762357723578235792358023581235822358323584235852358623587235882358923590235912359223593235942359523596235972359823599236002360123602236032360423605236062360723608236092361023611236122361323614236152361623617236182361923620236212362223623236242362523626236272362823629236302363123632236332363423635236362363723638236392364023641236422364323644236452364623647236482364923650236512365223653236542365523656236572365823659236602366123662236632366423665236662366723668236692367023671236722367323674236752367623677236782367923680236812368223683236842368523686236872368823689236902369123692236932369423695236962369723698236992370023701237022370323704237052370623707237082370923710237112371223713237142371523716237172371823719237202372123722237232372423725237262372723728237292373023731237322373323734237352373623737237382373923740237412374223743237442374523746237472374823749237502375123752237532375423755237562375723758237592376023761237622376323764237652376623767237682376923770237712377223773237742377523776237772377823779237802378123782237832378423785237862378723788237892379023791237922379323794237952379623797237982379923800238012380223803238042380523806238072380823809238102381123812238132381423815238162381723818238192382023821238222382323824238252382623827238282382923830238312383223833238342383523836238372383823839238402384123842238432384423845238462384723848238492385023851238522385323854238552385623857238582385923860238612386223863238642386523866238672386823869238702387123872238732387423875238762387723878238792388023881238822388323884238852388623887238882388923890238912389223893238942389523896238972389823899239002390123902239032390423905239062390723908239092391023911239122391323914239152391623917239182391923920239212392223923239242392523926239272392823929239302393123932239332393423935239362393723938239392394023941239422394323944239452394623947239482394923950239512395223953239542395523956239572395823959239602396123962239632396423965239662396723968239692397023971239722397323974239752397623977239782397923980239812398223983239842398523986239872398823989239902399123992239932399423995239962399723998239992400024001240022400324004240052400624007240082400924010240112401224013240142401524016240172401824019240202402124022240232402424025240262402724028240292403024031240322403324034240352403624037240382403924040240412404224043240442404524046240472404824049240502405124052240532405424055240562405724058240592406024061240622406324064240652406624067240682406924070240712407224073240742407524076240772407824079240802408124082240832408424085240862408724088240892409024091240922409324094240952409624097240982409924100241012410224103241042410524106241072410824109241102411124112241132411424115241162411724118241192412024121241222412324124241252412624127241282412924130241312413224133241342413524136241372413824139241402414124142241432414424145241462414724148241492415024151241522415324154241552415624157241582415924160241612416224163241642416524166241672416824169241702417124172241732417424175241762417724178241792418024181241822418324184241852418624187241882418924190241912419224193241942419524196241972419824199242002420124202242032420424205242062420724208242092421024211242122421324214242152421624217242182421924220242212422224223242242422524226242272422824229242302423124232242332423424235242362423724238242392424024241242422424324244242452424624247242482424924250242512425224253242542425524256242572425824259242602426124262242632426424265242662426724268242692427024271242722427324274242752427624277242782427924280242812428224283242842428524286242872428824289242902429124292242932429424295242962429724298242992430024301243022430324304243052430624307243082430924310243112431224313243142431524316243172431824319243202432124322243232432424325243262432724328243292433024331243322433324334243352433624337243382433924340243412434224343243442434524346243472434824349243502435124352243532435424355243562435724358243592436024361243622436324364243652436624367243682436924370243712437224373243742437524376243772437824379243802438124382243832438424385243862438724388243892439024391243922439324394243952439624397243982439924400244012440224403244042440524406244072440824409244102441124412244132441424415244162441724418244192442024421244222442324424244252442624427244282442924430244312443224433244342443524436244372443824439244402444124442244432444424445244462444724448244492445024451244522445324454244552445624457244582445924460244612446224463244642446524466244672446824469244702447124472244732447424475244762447724478244792448024481244822448324484244852448624487244882448924490244912449224493244942449524496244972449824499245002450124502245032450424505245062450724508245092451024511245122451324514245152451624517245182451924520245212452224523245242452524526245272452824529245302453124532245332453424535245362453724538245392454024541245422454324544245452454624547245482454924550245512455224553245542455524556245572455824559245602456124562245632456424565245662456724568245692457024571245722457324574245752457624577245782457924580245812458224583245842458524586245872458824589245902459124592245932459424595245962459724598245992460024601246022460324604246052460624607246082460924610246112461224613246142461524616246172461824619246202462124622246232462424625246262462724628246292463024631246322463324634246352463624637246382463924640246412464224643246442464524646246472464824649246502465124652246532465424655246562465724658246592466024661246622466324664246652466624667246682466924670246712467224673246742467524676246772467824679246802468124682246832468424685246862468724688246892469024691246922469324694246952469624697246982469924700247012470224703247042470524706247072470824709247102471124712247132471424715247162471724718247192472024721247222472324724247252472624727247282472924730247312473224733247342473524736247372473824739247402474124742247432474424745247462474724748247492475024751247522475324754247552475624757247582475924760247612476224763247642476524766247672476824769247702477124772247732477424775247762477724778247792478024781247822478324784247852478624787247882478924790247912479224793247942479524796247972479824799248002480124802248032480424805248062480724808248092481024811248122481324814248152481624817248182481924820248212482224823248242482524826248272482824829248302483124832248332483424835248362483724838248392484024841248422484324844248452484624847248482484924850248512485224853248542485524856248572485824859248602486124862248632486424865248662486724868248692487024871248722487324874248752487624877248782487924880248812488224883248842488524886248872488824889248902489124892248932489424895248962489724898248992490024901249022490324904249052490624907249082490924910249112491224913249142491524916249172491824919249202492124922249232492424925249262492724928249292493024931249322493324934249352493624937249382493924940249412494224943249442494524946249472494824949249502495124952249532495424955249562495724958249592496024961249622496324964249652496624967249682496924970249712497224973249742497524976249772497824979249802498124982249832498424985249862498724988249892499024991249922499324994249952499624997249982499925000250012500225003250042500525006250072500825009250102501125012250132501425015250162501725018250192502025021250222502325024250252502625027250282502925030250312503225033250342503525036250372503825039250402504125042250432504425045250462504725048250492505025051250522505325054250552505625057250582505925060250612506225063250642506525066250672506825069250702507125072250732507425075250762507725078250792508025081250822508325084250852508625087250882508925090250912509225093250942509525096250972509825099251002510125102251032510425105251062510725108251092511025111251122511325114251152511625117251182511925120251212512225123251242512525126251272512825129251302513125132251332513425135251362513725138251392514025141251422514325144251452514625147251482514925150251512515225153251542515525156251572515825159251602516125162251632516425165251662516725168251692517025171251722517325174251752517625177251782517925180251812518225183251842518525186251872518825189251902519125192251932519425195251962519725198251992520025201252022520325204252052520625207252082520925210252112521225213252142521525216252172521825219252202522125222252232522425225252262522725228252292523025231252322523325234252352523625237252382523925240252412524225243252442524525246252472524825249252502525125252252532525425255252562525725258252592526025261252622526325264252652526625267252682526925270252712527225273252742527525276252772527825279252802528125282252832528425285252862528725288252892529025291252922529325294252952529625297252982529925300253012530225303253042530525306253072530825309253102531125312253132531425315253162531725318253192532025321253222532325324253252532625327253282532925330253312533225333253342533525336253372533825339253402534125342253432534425345253462534725348253492535025351253522535325354253552535625357253582535925360253612536225363253642536525366253672536825369253702537125372253732537425375253762537725378253792538025381253822538325384253852538625387253882538925390253912539225393253942539525396253972539825399254002540125402254032540425405254062540725408254092541025411254122541325414254152541625417254182541925420254212542225423254242542525426254272542825429254302543125432254332543425435254362543725438254392544025441254422544325444254452544625447254482544925450254512545225453254542545525456254572545825459254602546125462254632546425465254662546725468254692547025471254722547325474254752547625477254782547925480254812548225483254842548525486254872548825489254902549125492254932549425495254962549725498254992550025501255022550325504255052550625507255082550925510255112551225513255142551525516255172551825519255202552125522255232552425525255262552725528255292553025531255322553325534255352553625537255382553925540255412554225543255442554525546255472554825549255502555125552255532555425555255562555725558255592556025561255622556325564255652556625567255682556925570255712557225573255742557525576255772557825579255802558125582255832558425585255862558725588255892559025591255922559325594255952559625597255982559925600256012560225603256042560525606256072560825609256102561125612256132561425615256162561725618256192562025621256222562325624256252562625627256282562925630256312563225633256342563525636256372563825639256402564125642256432564425645256462564725648256492565025651256522565325654256552565625657256582565925660256612566225663256642566525666256672566825669256702567125672256732567425675256762567725678256792568025681256822568325684256852568625687256882568925690256912569225693256942569525696256972569825699257002570125702257032570425705257062570725708257092571025711257122571325714257152571625717257182571925720257212572225723257242572525726257272572825729257302573125732257332573425735257362573725738257392574025741257422574325744257452574625747257482574925750257512575225753257542575525756257572575825759257602576125762257632576425765257662576725768257692577025771257722577325774257752577625777257782577925780257812578225783257842578525786257872578825789257902579125792257932579425795257962579725798257992580025801258022580325804258052580625807258082580925810258112581225813258142581525816258172581825819258202582125822258232582425825258262582725828258292583025831258322583325834258352583625837258382583925840258412584225843258442584525846258472584825849258502585125852258532585425855258562585725858258592586025861258622586325864258652586625867258682586925870258712587225873258742587525876258772587825879258802588125882258832588425885258862588725888258892589025891258922589325894258952589625897258982589925900259012590225903259042590525906259072590825909259102591125912259132591425915259162591725918259192592025921259222592325924259252592625927259282592925930259312593225933259342593525936259372593825939259402594125942259432594425945259462594725948259492595025951259522595325954259552595625957259582595925960259612596225963259642596525966259672596825969259702597125972259732597425975259762597725978259792598025981259822598325984259852598625987259882598925990259912599225993259942599525996259972599825999260002600126002260032600426005260062600726008260092601026011260122601326014260152601626017260182601926020260212602226023260242602526026260272602826029260302603126032260332603426035260362603726038260392604026041260422604326044260452604626047260482604926050260512605226053260542605526056260572605826059260602606126062260632606426065260662606726068260692607026071260722607326074260752607626077260782607926080260812608226083260842608526086260872608826089260902609126092260932609426095260962609726098260992610026101261022610326104261052610626107261082610926110261112611226113261142611526116261172611826119261202612126122261232612426125261262612726128261292613026131261322613326134261352613626137261382613926140261412614226143261442614526146261472614826149261502615126152261532615426155261562615726158261592616026161261622616326164261652616626167261682616926170261712617226173261742617526176261772617826179261802618126182261832618426185261862618726188261892619026191261922619326194261952619626197261982619926200262012620226203262042620526206262072620826209262102621126212262132621426215262162621726218262192622026221262222622326224262252622626227262282622926230262312623226233262342623526236262372623826239262402624126242262432624426245262462624726248262492625026251262522625326254262552625626257262582625926260262612626226263262642626526266262672626826269262702627126272262732627426275262762627726278262792628026281262822628326284262852628626287262882628926290262912629226293262942629526296262972629826299263002630126302263032630426305263062630726308263092631026311263122631326314263152631626317263182631926320263212632226323263242632526326263272632826329263302633126332263332633426335263362633726338263392634026341263422634326344263452634626347263482634926350263512635226353263542635526356263572635826359263602636126362263632636426365263662636726368263692637026371263722637326374263752637626377263782637926380263812638226383263842638526386263872638826389263902639126392263932639426395263962639726398263992640026401264022640326404264052640626407264082640926410264112641226413264142641526416264172641826419264202642126422264232642426425264262642726428264292643026431264322643326434264352643626437264382643926440264412644226443264442644526446264472644826449264502645126452264532645426455264562645726458264592646026461264622646326464264652646626467264682646926470264712647226473264742647526476264772647826479264802648126482264832648426485264862648726488264892649026491264922649326494264952649626497264982649926500265012650226503265042650526506265072650826509265102651126512265132651426515265162651726518265192652026521265222652326524265252652626527265282652926530265312653226533265342653526536265372653826539265402654126542265432654426545265462654726548265492655026551265522655326554265552655626557265582655926560265612656226563265642656526566265672656826569265702657126572265732657426575265762657726578265792658026581265822658326584265852658626587265882658926590265912659226593265942659526596265972659826599266002660126602266032660426605266062660726608266092661026611266122661326614266152661626617266182661926620266212662226623266242662526626266272662826629266302663126632266332663426635266362663726638266392664026641266422664326644266452664626647266482664926650266512665226653266542665526656266572665826659266602666126662266632666426665266662666726668266692667026671266722667326674266752667626677266782667926680266812668226683266842668526686266872668826689266902669126692266932669426695266962669726698266992670026701267022670326704267052670626707267082670926710267112671226713267142671526716267172671826719267202672126722267232672426725267262672726728267292673026731267322673326734267352673626737267382673926740267412674226743267442674526746267472674826749267502675126752267532675426755267562675726758267592676026761267622676326764267652676626767267682676926770267712677226773267742677526776267772677826779267802678126782267832678426785267862678726788267892679026791267922679326794267952679626797267982679926800268012680226803268042680526806268072680826809268102681126812268132681426815268162681726818268192682026821268222682326824268252682626827268282682926830268312683226833268342683526836268372683826839268402684126842268432684426845268462684726848268492685026851268522685326854268552685626857268582685926860268612686226863268642686526866268672686826869268702687126872268732687426875268762687726878268792688026881268822688326884268852688626887268882688926890268912689226893268942689526896268972689826899269002690126902269032690426905269062690726908269092691026911269122691326914269152691626917269182691926920269212692226923269242692526926269272692826929269302693126932269332693426935269362693726938269392694026941269422694326944269452694626947269482694926950269512695226953269542695526956269572695826959269602696126962269632696426965269662696726968269692697026971269722697326974269752697626977269782697926980269812698226983269842698526986269872698826989269902699126992269932699426995269962699726998269992700027001270022700327004270052700627007270082700927010270112701227013270142701527016270172701827019270202702127022270232702427025270262702727028270292703027031270322703327034270352703627037270382703927040270412704227043270442704527046270472704827049270502705127052270532705427055270562705727058270592706027061270622706327064270652706627067270682706927070270712707227073270742707527076270772707827079270802708127082270832708427085270862708727088270892709027091270922709327094270952709627097270982709927100271012710227103271042710527106271072710827109271102711127112271132711427115271162711727118271192712027121271222712327124271252712627127271282712927130271312713227133271342713527136271372713827139271402714127142271432714427145271462714727148271492715027151271522715327154271552715627157271582715927160271612716227163271642716527166271672716827169271702717127172271732717427175271762717727178271792718027181271822718327184271852718627187271882718927190271912719227193271942719527196271972719827199272002720127202272032720427205272062720727208272092721027211272122721327214272152721627217272182721927220272212722227223272242722527226272272722827229272302723127232272332723427235272362723727238272392724027241272422724327244272452724627247272482724927250272512725227253272542725527256272572725827259272602726127262272632726427265272662726727268272692727027271272722727327274272752727627277272782727927280272812728227283272842728527286272872728827289272902729127292272932729427295272962729727298272992730027301273022730327304273052730627307273082730927310273112731227313273142731527316273172731827319273202732127322273232732427325273262732727328273292733027331273322733327334273352733627337273382733927340273412734227343273442734527346273472734827349273502735127352273532735427355273562735727358273592736027361273622736327364273652736627367273682736927370273712737227373273742737527376273772737827379273802738127382273832738427385273862738727388273892739027391273922739327394273952739627397273982739927400274012740227403274042740527406274072740827409274102741127412274132741427415274162741727418274192742027421274222742327424274252742627427274282742927430274312743227433274342743527436274372743827439274402744127442274432744427445274462744727448274492745027451274522745327454274552745627457274582745927460274612746227463274642746527466274672746827469274702747127472274732747427475274762747727478274792748027481274822748327484274852748627487274882748927490274912749227493274942749527496274972749827499275002750127502275032750427505275062750727508275092751027511275122751327514275152751627517275182751927520275212752227523275242752527526275272752827529275302753127532275332753427535275362753727538275392754027541275422754327544275452754627547275482754927550275512755227553275542755527556275572755827559275602756127562275632756427565275662756727568275692757027571275722757327574275752757627577275782757927580275812758227583275842758527586275872758827589275902759127592275932759427595275962759727598275992760027601276022760327604276052760627607276082760927610276112761227613276142761527616276172761827619276202762127622276232762427625276262762727628276292763027631276322763327634276352763627637276382763927640276412764227643276442764527646276472764827649276502765127652276532765427655276562765727658276592766027661276622766327664276652766627667276682766927670276712767227673276742767527676276772767827679276802768127682276832768427685276862768727688276892769027691276922769327694276952769627697276982769927700277012770227703277042770527706277072770827709277102771127712277132771427715277162771727718277192772027721277222772327724277252772627727277282772927730277312773227733277342773527736277372773827739277402774127742277432774427745277462774727748277492775027751277522775327754277552775627757277582775927760277612776227763277642776527766277672776827769277702777127772277732777427775277762777727778277792778027781277822778327784277852778627787277882778927790277912779227793277942779527796277972779827799278002780127802278032780427805278062780727808278092781027811278122781327814278152781627817278182781927820278212782227823278242782527826278272782827829278302783127832278332783427835278362783727838278392784027841278422784327844278452784627847278482784927850278512785227853278542785527856278572785827859278602786127862278632786427865278662786727868278692787027871278722787327874278752787627877278782787927880278812788227883278842788527886278872788827889278902789127892278932789427895278962789727898278992790027901279022790327904279052790627907279082790927910279112791227913279142791527916279172791827919279202792127922279232792427925279262792727928279292793027931279322793327934279352793627937279382793927940279412794227943279442794527946279472794827949279502795127952279532795427955279562795727958279592796027961279622796327964279652796627967279682796927970279712797227973279742797527976279772797827979279802798127982279832798427985279862798727988279892799027991279922799327994279952799627997279982799928000280012800228003280042800528006280072800828009280102801128012280132801428015280162801728018280192802028021280222802328024280252802628027280282802928030280312803228033280342803528036280372803828039280402804128042280432804428045280462804728048280492805028051280522805328054280552805628057280582805928060280612806228063280642806528066280672806828069280702807128072280732807428075280762807728078280792808028081280822808328084280852808628087280882808928090280912809228093280942809528096280972809828099281002810128102281032810428105281062810728108281092811028111281122811328114281152811628117281182811928120281212812228123281242812528126281272812828129281302813128132281332813428135281362813728138281392814028141281422814328144281452814628147281482814928150281512815228153281542815528156281572815828159281602816128162281632816428165281662816728168281692817028171281722817328174281752817628177281782817928180281812818228183281842818528186281872818828189281902819128192281932819428195281962819728198281992820028201282022820328204282052820628207282082820928210282112821228213282142821528216282172821828219282202822128222282232822428225282262822728228282292823028231282322823328234282352823628237282382823928240282412824228243282442824528246282472824828249282502825128252282532825428255282562825728258282592826028261282622826328264282652826628267282682826928270282712827228273282742827528276282772827828279282802828128282282832828428285282862828728288282892829028291282922829328294282952829628297282982829928300283012830228303283042830528306283072830828309283102831128312283132831428315283162831728318283192832028321283222832328324283252832628327283282832928330283312833228333283342833528336283372833828339283402834128342283432834428345283462834728348283492835028351283522835328354283552835628357283582835928360283612836228363283642836528366283672836828369283702837128372283732837428375283762837728378283792838028381283822838328384283852838628387283882838928390283912839228393283942839528396283972839828399284002840128402284032840428405284062840728408284092841028411284122841328414284152841628417284182841928420284212842228423284242842528426284272842828429284302843128432284332843428435284362843728438284392844028441284422844328444284452844628447284482844928450284512845228453284542845528456284572845828459284602846128462284632846428465284662846728468284692847028471284722847328474284752847628477284782847928480284812848228483284842848528486284872848828489284902849128492284932849428495284962849728498284992850028501285022850328504285052850628507285082850928510285112851228513285142851528516285172851828519285202852128522285232852428525285262852728528285292853028531285322853328534285352853628537285382853928540285412854228543285442854528546285472854828549285502855128552285532855428555285562855728558285592856028561285622856328564285652856628567285682856928570285712857228573285742857528576285772857828579285802858128582285832858428585285862858728588285892859028591285922859328594285952859628597285982859928600286012860228603286042860528606286072860828609286102861128612286132861428615286162861728618286192862028621286222862328624286252862628627286282862928630286312863228633286342863528636286372863828639286402864128642286432864428645286462864728648286492865028651286522865328654286552865628657286582865928660286612866228663286642866528666286672866828669286702867128672286732867428675286762867728678286792868028681286822868328684286852868628687286882868928690286912869228693286942869528696286972869828699287002870128702287032870428705287062870728708287092871028711287122871328714287152871628717287182871928720287212872228723287242872528726287272872828729287302873128732287332873428735287362873728738287392874028741287422874328744287452874628747287482874928750287512875228753287542875528756287572875828759287602876128762287632876428765287662876728768287692877028771287722877328774287752877628777287782877928780287812878228783287842878528786287872878828789287902879128792287932879428795287962879728798287992880028801288022880328804288052880628807288082880928810288112881228813288142881528816288172881828819288202882128822288232882428825288262882728828288292883028831288322883328834288352883628837288382883928840288412884228843288442884528846288472884828849288502885128852288532885428855288562885728858288592886028861288622886328864288652886628867288682886928870288712887228873288742887528876288772887828879288802888128882288832888428885288862888728888288892889028891288922889328894288952889628897288982889928900289012890228903289042890528906289072890828909289102891128912289132891428915289162891728918289192892028921289222892328924289252892628927289282892928930289312893228933289342893528936289372893828939289402894128942289432894428945289462894728948289492895028951289522895328954289552895628957289582895928960289612896228963289642896528966289672896828969289702897128972289732897428975289762897728978289792898028981289822898328984289852898628987289882898928990289912899228993289942899528996289972899828999290002900129002290032900429005290062900729008290092901029011290122901329014290152901629017290182901929020290212902229023290242902529026290272902829029290302903129032290332903429035290362903729038290392904029041290422904329044290452904629047290482904929050290512905229053290542905529056290572905829059290602906129062290632906429065290662906729068290692907029071290722907329074290752907629077290782907929080290812908229083290842908529086290872908829089290902909129092290932909429095290962909729098290992910029101291022910329104291052910629107291082910929110291112911229113291142911529116291172911829119291202912129122291232912429125291262912729128291292913029131291322913329134291352913629137291382913929140291412914229143291442914529146291472914829149291502915129152291532915429155291562915729158291592916029161291622916329164291652916629167291682916929170291712917229173291742917529176291772917829179291802918129182291832918429185291862918729188291892919029191291922919329194291952919629197291982919929200292012920229203292042920529206292072920829209292102921129212292132921429215292162921729218292192922029221292222922329224292252922629227292282922929230292312923229233292342923529236292372923829239292402924129242292432924429245292462924729248292492925029251292522925329254292552925629257292582925929260292612926229263292642926529266292672926829269292702927129272292732927429275292762927729278292792928029281292822928329284292852928629287292882928929290292912929229293292942929529296292972929829299293002930129302293032930429305293062930729308293092931029311293122931329314293152931629317293182931929320293212932229323293242932529326293272932829329293302933129332293332933429335293362933729338293392934029341293422934329344293452934629347293482934929350293512935229353293542935529356293572935829359293602936129362293632936429365293662936729368293692937029371293722937329374293752937629377293782937929380293812938229383293842938529386293872938829389293902939129392293932939429395293962939729398293992940029401294022940329404294052940629407294082940929410294112941229413294142941529416294172941829419294202942129422294232942429425294262942729428294292943029431294322943329434294352943629437294382943929440294412944229443294442944529446294472944829449294502945129452294532945429455294562945729458294592946029461294622946329464294652946629467294682946929470294712947229473294742947529476294772947829479294802948129482294832948429485294862948729488294892949029491294922949329494294952949629497294982949929500295012950229503295042950529506295072950829509295102951129512295132951429515295162951729518295192952029521295222952329524295252952629527295282952929530295312953229533295342953529536295372953829539295402954129542295432954429545295462954729548295492955029551295522955329554295552955629557295582955929560295612956229563295642956529566295672956829569295702957129572295732957429575295762957729578295792958029581295822958329584295852958629587295882958929590295912959229593295942959529596295972959829599296002960129602296032960429605296062960729608296092961029611296122961329614296152961629617296182961929620296212962229623296242962529626296272962829629296302963129632296332963429635296362963729638296392964029641296422964329644296452964629647296482964929650296512965229653296542965529656296572965829659296602966129662296632966429665296662966729668296692967029671296722967329674296752967629677296782967929680296812968229683296842968529686296872968829689296902969129692296932969429695296962969729698296992970029701297022970329704297052970629707297082970929710297112971229713297142971529716297172971829719297202972129722297232972429725297262972729728297292973029731297322973329734297352973629737297382973929740297412974229743297442974529746297472974829749297502975129752297532975429755297562975729758297592976029761297622976329764297652976629767297682976929770297712977229773297742977529776297772977829779297802978129782297832978429785297862978729788297892979029791297922979329794297952979629797297982979929800298012980229803298042980529806298072980829809298102981129812298132981429815298162981729818298192982029821298222982329824298252982629827298282982929830298312983229833298342983529836298372983829839298402984129842298432984429845298462984729848298492985029851298522985329854298552985629857298582985929860298612986229863298642986529866298672986829869298702987129872298732987429875298762987729878298792988029881298822988329884298852988629887298882988929890298912989229893298942989529896298972989829899299002990129902299032990429905299062990729908299092991029911299122991329914299152991629917299182991929920299212992229923299242992529926299272992829929299302993129932299332993429935299362993729938299392994029941299422994329944299452994629947299482994929950299512995229953299542995529956299572995829959299602996129962299632996429965299662996729968299692997029971299722997329974299752997629977299782997929980299812998229983299842998529986299872998829989299902999129992299932999429995299962999729998299993000030001300023000330004300053000630007300083000930010300113001230013300143001530016300173001830019300203002130022300233002430025300263002730028300293003030031300323003330034300353003630037300383003930040300413004230043300443004530046300473004830049300503005130052300533005430055300563005730058300593006030061300623006330064300653006630067300683006930070300713007230073300743007530076300773007830079300803008130082300833008430085300863008730088300893009030091300923009330094300953009630097300983009930100301013010230103301043010530106301073010830109301103011130112301133011430115301163011730118301193012030121301223012330124301253012630127301283012930130301313013230133301343013530136301373013830139301403014130142301433014430145301463014730148301493015030151301523015330154301553015630157301583015930160301613016230163301643016530166301673016830169301703017130172301733017430175301763017730178301793018030181301823018330184301853018630187301883018930190301913019230193301943019530196301973019830199302003020130202302033020430205302063020730208302093021030211302123021330214302153021630217302183021930220302213022230223302243022530226302273022830229302303023130232302333023430235302363023730238302393024030241302423024330244302453024630247302483024930250302513025230253302543025530256302573025830259302603026130262302633026430265302663026730268302693027030271302723027330274302753027630277302783027930280302813028230283302843028530286302873028830289302903029130292302933029430295302963029730298302993030030301303023030330304303053030630307303083030930310303113031230313303143031530316303173031830319303203032130322303233032430325303263032730328303293033030331303323033330334303353033630337303383033930340303413034230343303443034530346303473034830349303503035130352303533035430355303563035730358303593036030361303623036330364303653036630367303683036930370303713037230373303743037530376303773037830379303803038130382303833038430385303863038730388303893039030391303923039330394303953039630397303983039930400304013040230403304043040530406304073040830409304103041130412304133041430415304163041730418304193042030421304223042330424304253042630427304283042930430304313043230433304343043530436304373043830439304403044130442304433044430445304463044730448304493045030451304523045330454304553045630457304583045930460304613046230463304643046530466304673046830469304703047130472304733047430475304763047730478304793048030481304823048330484304853048630487304883048930490304913049230493304943049530496304973049830499305003050130502305033050430505305063050730508305093051030511305123051330514305153051630517305183051930520305213052230523305243052530526305273052830529305303053130532305333053430535305363053730538305393054030541305423054330544305453054630547305483054930550305513055230553305543055530556305573055830559305603056130562305633056430565305663056730568305693057030571305723057330574305753057630577305783057930580305813058230583305843058530586305873058830589305903059130592305933059430595305963059730598305993060030601306023060330604306053060630607306083060930610306113061230613306143061530616306173061830619306203062130622306233062430625306263062730628306293063030631306323063330634306353063630637306383063930640306413064230643306443064530646306473064830649306503065130652306533065430655306563065730658306593066030661306623066330664306653066630667306683066930670306713067230673306743067530676306773067830679306803068130682306833068430685306863068730688306893069030691306923069330694306953069630697306983069930700307013070230703307043070530706307073070830709307103071130712307133071430715307163071730718307193072030721307223072330724307253072630727307283072930730307313073230733307343073530736307373073830739307403074130742307433074430745307463074730748307493075030751307523075330754307553075630757307583075930760307613076230763307643076530766307673076830769307703077130772307733077430775307763077730778307793078030781307823078330784307853078630787307883078930790307913079230793307943079530796307973079830799308003080130802308033080430805308063080730808308093081030811308123081330814308153081630817308183081930820308213082230823308243082530826308273082830829308303083130832308333083430835308363083730838308393084030841308423084330844308453084630847308483084930850308513085230853308543085530856308573085830859308603086130862308633086430865308663086730868308693087030871308723087330874308753087630877308783087930880308813088230883308843088530886308873088830889308903089130892308933089430895308963089730898308993090030901309023090330904309053090630907309083090930910309113091230913309143091530916309173091830919309203092130922309233092430925309263092730928309293093030931309323093330934309353093630937309383093930940309413094230943309443094530946309473094830949309503095130952309533095430955309563095730958309593096030961309623096330964309653096630967309683096930970309713097230973309743097530976309773097830979309803098130982309833098430985309863098730988309893099030991309923099330994309953099630997309983099931000310013100231003310043100531006310073100831009310103101131012310133101431015310163101731018310193102031021310223102331024310253102631027310283102931030310313103231033310343103531036310373103831039310403104131042310433104431045310463104731048310493105031051310523105331054310553105631057310583105931060310613106231063310643106531066310673106831069310703107131072310733107431075310763107731078310793108031081310823108331084310853108631087310883108931090310913109231093310943109531096310973109831099311003110131102311033110431105311063110731108311093111031111311123111331114311153111631117311183111931120311213112231123311243112531126311273112831129311303113131132311333113431135311363113731138311393114031141311423114331144311453114631147311483114931150311513115231153311543115531156311573115831159311603116131162311633116431165311663116731168311693117031171311723117331174311753117631177311783117931180311813118231183311843118531186311873118831189311903119131192311933119431195311963119731198311993120031201312023120331204312053120631207312083120931210312113121231213312143121531216312173121831219312203122131222312233122431225312263122731228312293123031231312323123331234312353123631237312383123931240312413124231243312443124531246312473124831249312503125131252312533125431255312563125731258312593126031261312623126331264312653126631267312683126931270312713127231273312743127531276312773127831279312803128131282312833128431285312863128731288312893129031291312923129331294312953129631297312983129931300313013130231303313043130531306313073130831309313103131131312313133131431315313163131731318313193132031321313223132331324313253132631327313283132931330313313133231333313343133531336313373133831339313403134131342313433134431345313463134731348313493135031351313523135331354313553135631357313583135931360313613136231363313643136531366313673136831369313703137131372313733137431375313763137731378313793138031381313823138331384313853138631387313883138931390313913139231393313943139531396313973139831399314003140131402314033140431405314063140731408314093141031411314123141331414314153141631417314183141931420314213142231423314243142531426314273142831429314303143131432314333143431435314363143731438314393144031441314423144331444314453144631447314483144931450314513145231453314543145531456314573145831459314603146131462314633146431465314663146731468314693147031471314723147331474314753147631477314783147931480314813148231483314843148531486314873148831489314903149131492314933149431495314963149731498314993150031501315023150331504315053150631507315083150931510315113151231513315143151531516315173151831519315203152131522315233152431525315263152731528315293153031531315323153331534315353153631537315383153931540315413154231543315443154531546315473154831549315503155131552315533155431555315563155731558315593156031561315623156331564315653156631567315683156931570315713157231573315743157531576315773157831579315803158131582315833158431585315863158731588315893159031591315923159331594315953159631597315983159931600316013160231603316043160531606316073160831609316103161131612316133161431615316163161731618316193162031621316223162331624316253162631627316283162931630316313163231633316343163531636316373163831639316403164131642316433164431645316463164731648316493165031651316523165331654316553165631657316583165931660316613166231663316643166531666316673166831669316703167131672316733167431675316763167731678316793168031681316823168331684316853168631687316883168931690316913169231693316943169531696316973169831699317003170131702317033170431705317063170731708317093171031711317123171331714317153171631717317183171931720317213172231723317243172531726317273172831729317303173131732317333173431735317363173731738317393174031741317423174331744317453174631747317483174931750317513175231753317543175531756317573175831759317603176131762317633176431765317663176731768317693177031771317723177331774317753177631777317783177931780317813178231783317843178531786317873178831789317903179131792317933179431795317963179731798317993180031801318023180331804318053180631807318083180931810318113181231813318143181531816318173181831819318203182131822318233182431825318263182731828318293183031831318323183331834318353183631837318383183931840318413184231843318443184531846318473184831849318503185131852318533185431855318563185731858318593186031861318623186331864318653186631867318683186931870318713187231873318743187531876318773187831879318803188131882318833188431885318863188731888318893189031891318923189331894318953189631897318983189931900319013190231903319043190531906319073190831909319103191131912319133191431915319163191731918319193192031921319223192331924319253192631927319283192931930319313193231933319343193531936319373193831939319403194131942319433194431945319463194731948319493195031951319523195331954319553195631957319583195931960319613196231963319643196531966319673196831969319703197131972319733197431975319763197731978319793198031981319823198331984319853198631987319883198931990319913199231993319943199531996319973199831999320003200132002320033200432005320063200732008320093201032011320123201332014320153201632017320183201932020320213202232023320243202532026320273202832029320303203132032320333203432035320363203732038320393204032041320423204332044320453204632047320483204932050320513205232053320543205532056320573205832059320603206132062320633206432065320663206732068320693207032071320723207332074320753207632077320783207932080320813208232083320843208532086320873208832089320903209132092320933209432095320963209732098320993210032101321023210332104321053210632107321083210932110321113211232113321143211532116321173211832119321203212132122321233212432125321263212732128321293213032131321323213332134321353213632137321383213932140321413214232143321443214532146321473214832149321503215132152321533215432155321563215732158321593216032161321623216332164321653216632167321683216932170321713217232173321743217532176321773217832179321803218132182321833218432185321863218732188321893219032191321923219332194321953219632197321983219932200322013220232203322043220532206322073220832209322103221132212322133221432215322163221732218322193222032221322223222332224322253222632227322283222932230322313223232233322343223532236322373223832239322403224132242322433224432245322463224732248322493225032251322523225332254322553225632257322583225932260322613226232263322643226532266322673226832269322703227132272322733227432275322763227732278322793228032281322823228332284322853228632287322883228932290322913229232293322943229532296322973229832299323003230132302323033230432305323063230732308323093231032311323123231332314323153231632317323183231932320323213232232323323243232532326323273232832329323303233132332323333233432335323363233732338323393234032341323423234332344323453234632347323483234932350323513235232353323543235532356323573235832359323603236132362323633236432365323663236732368323693237032371323723237332374323753237632377323783237932380323813238232383323843238532386323873238832389323903239132392323933239432395323963239732398323993240032401324023240332404324053240632407324083240932410324113241232413324143241532416324173241832419324203242132422324233242432425324263242732428324293243032431324323243332434324353243632437324383243932440324413244232443324443244532446324473244832449324503245132452324533245432455324563245732458324593246032461324623246332464324653246632467324683246932470324713247232473324743247532476324773247832479324803248132482324833248432485324863248732488324893249032491324923249332494324953249632497324983249932500325013250232503325043250532506325073250832509325103251132512325133251432515325163251732518325193252032521325223252332524325253252632527325283252932530325313253232533325343253532536325373253832539325403254132542325433254432545325463254732548325493255032551325523255332554325553255632557325583255932560325613256232563325643256532566325673256832569325703257132572325733257432575325763257732578325793258032581325823258332584325853258632587325883258932590325913259232593325943259532596325973259832599326003260132602326033260432605326063260732608326093261032611326123261332614326153261632617326183261932620326213262232623326243262532626326273262832629326303263132632326333263432635326363263732638326393264032641326423264332644326453264632647326483264932650326513265232653326543265532656326573265832659326603266132662326633266432665326663266732668326693267032671326723267332674326753267632677326783267932680326813268232683326843268532686326873268832689326903269132692326933269432695326963269732698326993270032701327023270332704327053270632707327083270932710327113271232713327143271532716327173271832719327203272132722327233272432725327263272732728327293273032731327323273332734327353273632737327383273932740327413274232743327443274532746327473274832749327503275132752327533275432755327563275732758327593276032761327623276332764327653276632767327683276932770327713277232773327743277532776327773277832779327803278132782327833278432785327863278732788327893279032791327923279332794327953279632797327983279932800328013280232803328043280532806328073280832809328103281132812328133281432815328163281732818328193282032821328223282332824328253282632827328283282932830328313283232833328343283532836328373283832839328403284132842328433284432845328463284732848328493285032851328523285332854328553285632857328583285932860328613286232863328643286532866328673286832869328703287132872328733287432875328763287732878328793288032881328823288332884328853288632887328883288932890328913289232893328943289532896328973289832899329003290132902329033290432905329063290732908329093291032911329123291332914329153291632917329183291932920329213292232923329243292532926329273292832929329303293132932329333293432935329363293732938329393294032941329423294332944329453294632947329483294932950329513295232953329543295532956329573295832959329603296132962329633296432965329663296732968329693297032971329723297332974329753297632977329783297932980329813298232983329843298532986329873298832989329903299132992329933299432995329963299732998329993300033001330023300333004330053300633007330083300933010330113301233013330143301533016330173301833019330203302133022330233302433025330263302733028330293303033031330323303333034330353303633037330383303933040330413304233043330443304533046330473304833049330503305133052330533305433055330563305733058330593306033061330623306333064330653306633067330683306933070330713307233073330743307533076330773307833079330803308133082330833308433085330863308733088330893309033091330923309333094330953309633097330983309933100331013310233103331043310533106331073310833109331103311133112331133311433115331163311733118331193312033121331223312333124331253312633127331283312933130331313313233133331343313533136331373313833139331403314133142331433314433145331463314733148331493315033151331523315333154331553315633157331583315933160331613316233163331643316533166331673316833169331703317133172331733317433175331763317733178331793318033181331823318333184331853318633187331883318933190331913319233193331943319533196331973319833199332003320133202332033320433205332063320733208332093321033211332123321333214332153321633217332183321933220332213322233223332243322533226332273322833229332303323133232332333323433235332363323733238332393324033241332423324333244332453324633247332483324933250332513325233253332543325533256332573325833259332603326133262332633326433265332663326733268332693327033271332723327333274332753327633277332783327933280332813328233283332843328533286332873328833289332903329133292332933329433295332963329733298332993330033301333023330333304333053330633307333083330933310333113331233313333143331533316333173331833319333203332133322333233332433325333263332733328333293333033331333323333333334333353333633337333383333933340333413334233343333443334533346333473334833349333503335133352333533335433355333563335733358333593336033361333623336333364333653336633367333683336933370333713337233373333743337533376333773337833379333803338133382333833338433385333863338733388333893339033391333923339333394333953339633397333983339933400334013340233403334043340533406334073340833409334103341133412334133341433415334163341733418334193342033421334223342333424334253342633427334283342933430334313343233433334343343533436334373343833439334403344133442334433344433445334463344733448334493345033451334523345333454334553345633457334583345933460334613346233463334643346533466334673346833469334703347133472334733347433475334763347733478334793348033481334823348333484334853348633487334883348933490334913349233493334943349533496334973349833499335003350133502335033350433505335063350733508335093351033511335123351333514335153351633517335183351933520335213352233523335243352533526335273352833529335303353133532335333353433535335363353733538335393354033541335423354333544335453354633547335483354933550335513355233553335543355533556335573355833559335603356133562335633356433565335663356733568335693357033571335723357333574335753357633577335783357933580335813358233583335843358533586335873358833589335903359133592335933359433595335963359733598335993360033601336023360333604336053360633607336083360933610336113361233613336143361533616336173361833619336203362133622336233362433625336263362733628336293363033631336323363333634336353363633637336383363933640336413364233643336443364533646336473364833649336503365133652336533365433655336563365733658336593366033661336623366333664336653366633667336683366933670336713367233673336743367533676336773367833679336803368133682336833368433685336863368733688336893369033691336923369333694336953369633697336983369933700337013370233703337043370533706337073370833709337103371133712337133371433715337163371733718337193372033721337223372333724337253372633727337283372933730337313373233733337343373533736337373373833739337403374133742337433374433745337463374733748337493375033751337523375333754337553375633757337583375933760337613376233763337643376533766337673376833769337703377133772337733377433775337763377733778337793378033781337823378333784337853378633787337883378933790337913379233793337943379533796337973379833799338003380133802338033380433805338063380733808338093381033811338123381333814338153381633817338183381933820338213382233823338243382533826338273382833829338303383133832338333383433835338363383733838338393384033841338423384333844338453384633847338483384933850338513385233853338543385533856338573385833859338603386133862338633386433865338663386733868338693387033871338723387333874338753387633877338783387933880338813388233883338843388533886338873388833889338903389133892338933389433895338963389733898338993390033901339023390333904339053390633907339083390933910339113391233913339143391533916339173391833919339203392133922339233392433925339263392733928339293393033931339323393333934339353393633937339383393933940339413394233943339443394533946339473394833949339503395133952339533395433955339563395733958339593396033961339623396333964339653396633967339683396933970339713397233973339743397533976339773397833979339803398133982339833398433985339863398733988339893399033991339923399333994339953399633997339983399934000340013400234003340043400534006340073400834009340103401134012340133401434015340163401734018340193402034021340223402334024340253402634027340283402934030340313403234033340343403534036340373403834039340403404134042340433404434045340463404734048340493405034051340523405334054340553405634057340583405934060340613406234063340643406534066340673406834069340703407134072340733407434075340763407734078340793408034081340823408334084340853408634087340883408934090340913409234093340943409534096340973409834099341003410134102341033410434105341063410734108341093411034111341123411334114341153411634117341183411934120341213412234123341243412534126341273412834129341303413134132341333413434135341363413734138341393414034141341423414334144341453414634147341483414934150341513415234153341543415534156341573415834159341603416134162341633416434165341663416734168341693417034171341723417334174341753417634177341783417934180341813418234183341843418534186341873418834189341903419134192341933419434195341963419734198341993420034201342023420334204342053420634207342083420934210342113421234213342143421534216342173421834219342203422134222342233422434225342263422734228342293423034231342323423334234342353423634237342383423934240342413424234243342443424534246342473424834249342503425134252342533425434255342563425734258342593426034261342623426334264342653426634267342683426934270342713427234273342743427534276342773427834279342803428134282342833428434285342863428734288342893429034291342923429334294342953429634297342983429934300343013430234303343043430534306343073430834309343103431134312343133431434315343163431734318343193432034321343223432334324343253432634327343283432934330343313433234333343343433534336343373433834339343403434134342343433434434345343463434734348343493435034351343523435334354343553435634357343583435934360343613436234363343643436534366343673436834369343703437134372343733437434375343763437734378343793438034381343823438334384343853438634387343883438934390343913439234393343943439534396343973439834399344003440134402344033440434405344063440734408344093441034411344123441334414344153441634417344183441934420344213442234423344243442534426344273442834429344303443134432344333443434435344363443734438344393444034441344423444334444344453444634447344483444934450344513445234453344543445534456344573445834459344603446134462344633446434465344663446734468344693447034471344723447334474344753447634477344783447934480344813448234483344843448534486344873448834489344903449134492344933449434495344963449734498344993450034501345023450334504345053450634507345083450934510345113451234513345143451534516345173451834519345203452134522345233452434525345263452734528345293453034531345323453334534345353453634537345383453934540345413454234543345443454534546345473454834549345503455134552345533455434555345563455734558345593456034561345623456334564345653456634567345683456934570345713457234573345743457534576345773457834579345803458134582345833458434585345863458734588345893459034591345923459334594345953459634597345983459934600346013460234603346043460534606346073460834609346103461134612346133461434615346163461734618346193462034621346223462334624346253462634627346283462934630346313463234633346343463534636346373463834639346403464134642346433464434645346463464734648346493465034651346523465334654346553465634657346583465934660346613466234663346643466534666346673466834669346703467134672346733467434675346763467734678346793468034681346823468334684346853468634687346883468934690346913469234693346943469534696346973469834699347003470134702347033470434705347063470734708347093471034711347123471334714347153471634717347183471934720347213472234723347243472534726347273472834729347303473134732347333473434735347363473734738347393474034741347423474334744347453474634747347483474934750347513475234753347543475534756347573475834759347603476134762347633476434765347663476734768347693477034771347723477334774347753477634777347783477934780347813478234783347843478534786347873478834789347903479134792347933479434795347963479734798347993480034801348023480334804348053480634807348083480934810348113481234813348143481534816348173481834819348203482134822348233482434825348263482734828348293483034831348323483334834348353483634837348383483934840348413484234843348443484534846348473484834849348503485134852348533485434855348563485734858348593486034861348623486334864348653486634867348683486934870348713487234873348743487534876348773487834879348803488134882348833488434885348863488734888348893489034891348923489334894348953489634897348983489934900349013490234903349043490534906349073490834909349103491134912349133491434915349163491734918349193492034921349223492334924349253492634927349283492934930349313493234933349343493534936349373493834939349403494134942349433494434945349463494734948349493495034951349523495334954349553495634957349583495934960349613496234963349643496534966349673496834969349703497134972349733497434975349763497734978349793498034981349823498334984349853498634987349883498934990349913499234993349943499534996349973499834999350003500135002350033500435005350063500735008350093501035011350123501335014350153501635017350183501935020350213502235023350243502535026350273502835029350303503135032350333503435035350363503735038350393504035041350423504335044350453504635047350483504935050350513505235053350543505535056350573505835059350603506135062350633506435065350663506735068350693507035071350723507335074350753507635077350783507935080350813508235083350843508535086350873508835089350903509135092350933509435095350963509735098350993510035101351023510335104351053510635107351083510935110351113511235113351143511535116351173511835119351203512135122351233512435125351263512735128351293513035131351323513335134351353513635137351383513935140351413514235143351443514535146351473514835149351503515135152351533515435155351563515735158351593516035161351623516335164351653516635167351683516935170351713517235173351743517535176351773517835179351803518135182351833518435185351863518735188351893519035191351923519335194351953519635197351983519935200352013520235203352043520535206352073520835209352103521135212352133521435215352163521735218352193522035221352223522335224352253522635227352283522935230352313523235233352343523535236352373523835239352403524135242352433524435245352463524735248352493525035251352523525335254352553525635257352583525935260352613526235263352643526535266352673526835269352703527135272352733527435275352763527735278352793528035281352823528335284352853528635287352883528935290352913529235293352943529535296352973529835299353003530135302353033530435305353063530735308353093531035311353123531335314353153531635317353183531935320353213532235323353243532535326353273532835329353303533135332353333533435335353363533735338353393534035341353423534335344353453534635347353483534935350353513535235353353543535535356353573535835359353603536135362353633536435365353663536735368353693537035371353723537335374353753537635377353783537935380353813538235383353843538535386353873538835389353903539135392353933539435395353963539735398353993540035401354023540335404354053540635407354083540935410354113541235413354143541535416354173541835419354203542135422354233542435425354263542735428354293543035431354323543335434354353543635437354383543935440354413544235443354443544535446354473544835449354503545135452354533545435455354563545735458354593546035461354623546335464354653546635467354683546935470354713547235473354743547535476354773547835479354803548135482354833548435485354863548735488354893549035491354923549335494354953549635497354983549935500355013550235503355043550535506355073550835509355103551135512355133551435515355163551735518355193552035521355223552335524355253552635527355283552935530355313553235533355343553535536355373553835539355403554135542355433554435545355463554735548355493555035551355523555335554355553555635557355583555935560355613556235563355643556535566355673556835569355703557135572355733557435575355763557735578355793558035581355823558335584355853558635587355883558935590355913559235593355943559535596355973559835599356003560135602356033560435605356063560735608356093561035611356123561335614356153561635617356183561935620356213562235623356243562535626356273562835629356303563135632356333563435635356363563735638356393564035641356423564335644356453564635647356483564935650356513565235653356543565535656356573565835659356603566135662356633566435665356663566735668356693567035671356723567335674356753567635677356783567935680356813568235683356843568535686356873568835689356903569135692356933569435695356963569735698356993570035701357023570335704357053570635707357083570935710357113571235713357143571535716357173571835719357203572135722357233572435725357263572735728357293573035731357323573335734357353573635737357383573935740357413574235743357443574535746357473574835749357503575135752357533575435755357563575735758357593576035761357623576335764357653576635767357683576935770357713577235773357743577535776357773577835779357803578135782357833578435785357863578735788357893579035791357923579335794357953579635797357983579935800358013580235803358043580535806358073580835809358103581135812358133581435815358163581735818358193582035821358223582335824358253582635827358283582935830358313583235833358343583535836358373583835839358403584135842358433584435845358463584735848358493585035851358523585335854358553585635857358583585935860358613586235863358643586535866358673586835869358703587135872358733587435875358763587735878358793588035881358823588335884358853588635887358883588935890358913589235893358943589535896358973589835899359003590135902359033590435905359063590735908359093591035911359123591335914359153591635917359183591935920359213592235923359243592535926359273592835929359303593135932359333593435935359363593735938359393594035941359423594335944359453594635947359483594935950359513595235953359543595535956359573595835959359603596135962359633596435965359663596735968359693597035971359723597335974359753597635977359783597935980359813598235983359843598535986359873598835989359903599135992359933599435995359963599735998359993600036001360023600336004360053600636007360083600936010360113601236013360143601536016360173601836019360203602136022360233602436025360263602736028360293603036031360323603336034360353603636037360383603936040360413604236043360443604536046360473604836049360503605136052360533605436055360563605736058360593606036061360623606336064360653606636067360683606936070360713607236073360743607536076360773607836079360803608136082360833608436085360863608736088360893609036091360923609336094360953609636097360983609936100361013610236103361043610536106361073610836109361103611136112361133611436115361163611736118361193612036121361223612336124361253612636127361283612936130361313613236133361343613536136361373613836139361403614136142361433614436145361463614736148361493615036151361523615336154361553615636157361583615936160361613616236163361643616536166361673616836169361703617136172361733617436175361763617736178361793618036181361823618336184361853618636187361883618936190361913619236193361943619536196361973619836199362003620136202362033620436205362063620736208362093621036211362123621336214362153621636217362183621936220362213622236223362243622536226362273622836229362303623136232362333623436235362363623736238362393624036241362423624336244362453624636247362483624936250362513625236253362543625536256362573625836259362603626136262362633626436265362663626736268362693627036271362723627336274362753627636277362783627936280362813628236283362843628536286362873628836289362903629136292362933629436295362963629736298362993630036301363023630336304363053630636307363083630936310363113631236313363143631536316363173631836319363203632136322363233632436325363263632736328363293633036331363323633336334363353633636337363383633936340363413634236343363443634536346363473634836349363503635136352363533635436355363563635736358363593636036361363623636336364363653636636367363683636936370363713637236373363743637536376363773637836379363803638136382363833638436385363863638736388363893639036391363923639336394363953639636397363983639936400364013640236403364043640536406364073640836409364103641136412364133641436415364163641736418364193642036421364223642336424364253642636427364283642936430364313643236433364343643536436364373643836439364403644136442364433644436445364463644736448364493645036451364523645336454364553645636457364583645936460364613646236463364643646536466364673646836469364703647136472364733647436475364763647736478364793648036481364823648336484364853648636487364883648936490364913649236493364943649536496364973649836499365003650136502365033650436505365063650736508365093651036511365123651336514365153651636517365183651936520365213652236523365243652536526365273652836529365303653136532365333653436535365363653736538365393654036541365423654336544365453654636547365483654936550365513655236553365543655536556365573655836559365603656136562365633656436565365663656736568365693657036571365723657336574365753657636577365783657936580365813658236583365843658536586365873658836589365903659136592365933659436595365963659736598365993660036601366023660336604366053660636607366083660936610366113661236613366143661536616366173661836619366203662136622366233662436625366263662736628366293663036631366323663336634366353663636637366383663936640366413664236643366443664536646366473664836649366503665136652366533665436655366563665736658366593666036661366623666336664366653666636667366683666936670366713667236673366743667536676366773667836679366803668136682366833668436685366863668736688366893669036691366923669336694366953669636697366983669936700367013670236703367043670536706367073670836709367103671136712367133671436715367163671736718367193672036721367223672336724367253672636727367283672936730367313673236733367343673536736367373673836739367403674136742367433674436745367463674736748367493675036751367523675336754367553675636757367583675936760367613676236763367643676536766367673676836769367703677136772367733677436775367763677736778367793678036781367823678336784367853678636787367883678936790367913679236793367943679536796367973679836799368003680136802368033680436805368063680736808368093681036811368123681336814368153681636817368183681936820368213682236823368243682536826368273682836829368303683136832368333683436835368363683736838368393684036841368423684336844368453684636847368483684936850368513685236853368543685536856368573685836859368603686136862368633686436865368663686736868368693687036871368723687336874368753687636877368783687936880368813688236883368843688536886368873688836889368903689136892368933689436895368963689736898368993690036901369023690336904369053690636907369083690936910369113691236913369143691536916369173691836919369203692136922369233692436925369263692736928369293693036931369323693336934369353693636937369383693936940369413694236943369443694536946369473694836949369503695136952369533695436955369563695736958369593696036961369623696336964369653696636967369683696936970369713697236973369743697536976369773697836979369803698136982369833698436985369863698736988369893699036991369923699336994369953699636997369983699937000370013700237003370043700537006370073700837009370103701137012370133701437015370163701737018370193702037021370223702337024370253702637027370283702937030370313703237033370343703537036370373703837039370403704137042370433704437045370463704737048370493705037051370523705337054370553705637057370583705937060370613706237063370643706537066370673706837069370703707137072370733707437075370763707737078370793708037081370823708337084370853708637087370883708937090370913709237093370943709537096370973709837099371003710137102371033710437105371063710737108371093711037111371123711337114371153711637117371183711937120371213712237123371243712537126371273712837129371303713137132371333713437135371363713737138371393714037141371423714337144371453714637147371483714937150371513715237153371543715537156371573715837159371603716137162371633716437165371663716737168371693717037171371723717337174371753717637177371783717937180371813718237183371843718537186371873718837189371903719137192371933719437195371963719737198371993720037201372023720337204372053720637207372083720937210372113721237213372143721537216372173721837219372203722137222372233722437225372263722737228372293723037231372323723337234372353723637237372383723937240372413724237243372443724537246372473724837249372503725137252372533725437255372563725737258372593726037261372623726337264372653726637267372683726937270372713727237273372743727537276372773727837279372803728137282372833728437285372863728737288372893729037291372923729337294372953729637297372983729937300373013730237303373043730537306373073730837309373103731137312373133731437315373163731737318373193732037321373223732337324373253732637327373283732937330373313733237333373343733537336373373733837339373403734137342373433734437345373463734737348373493735037351373523735337354373553735637357373583735937360373613736237363373643736537366373673736837369373703737137372373733737437375373763737737378373793738037381373823738337384373853738637387373883738937390373913739237393373943739537396373973739837399374003740137402374033740437405374063740737408374093741037411374123741337414374153741637417374183741937420374213742237423374243742537426374273742837429374303743137432374333743437435374363743737438374393744037441374423744337444374453744637447374483744937450374513745237453374543745537456374573745837459374603746137462374633746437465374663746737468374693747037471374723747337474374753747637477374783747937480374813748237483374843748537486374873748837489374903749137492374933749437495374963749737498374993750037501375023750337504375053750637507375083750937510375113751237513375143751537516375173751837519375203752137522375233752437525375263752737528375293753037531375323753337534375353753637537375383753937540375413754237543375443754537546375473754837549375503755137552375533755437555375563755737558375593756037561375623756337564375653756637567375683756937570375713757237573375743757537576375773757837579375803758137582375833758437585375863758737588375893759037591375923759337594375953759637597375983759937600376013760237603376043760537606376073760837609376103761137612376133761437615376163761737618376193762037621376223762337624376253762637627376283762937630376313763237633376343763537636376373763837639376403764137642376433764437645376463764737648376493765037651376523765337654376553765637657376583765937660376613766237663376643766537666376673766837669376703767137672376733767437675376763767737678376793768037681376823768337684376853768637687376883768937690376913769237693376943769537696376973769837699377003770137702377033770437705377063770737708377093771037711377123771337714377153771637717377183771937720377213772237723377243772537726377273772837729377303773137732377333773437735377363773737738377393774037741377423774337744377453774637747377483774937750377513775237753377543775537756377573775837759377603776137762377633776437765377663776737768377693777037771377723777337774377753777637777377783777937780377813778237783377843778537786377873778837789377903779137792377933779437795377963779737798377993780037801378023780337804378053780637807378083780937810378113781237813378143781537816378173781837819378203782137822378233782437825378263782737828378293783037831378323783337834378353783637837378383783937840378413784237843378443784537846378473784837849378503785137852378533785437855378563785737858378593786037861378623786337864378653786637867378683786937870378713787237873378743787537876378773787837879378803788137882378833788437885378863788737888378893789037891378923789337894378953789637897378983789937900379013790237903379043790537906379073790837909379103791137912379133791437915379163791737918379193792037921379223792337924379253792637927379283792937930379313793237933379343793537936379373793837939379403794137942379433794437945379463794737948379493795037951379523795337954379553795637957379583795937960379613796237963379643796537966379673796837969379703797137972379733797437975379763797737978379793798037981379823798337984379853798637987379883798937990379913799237993379943799537996379973799837999380003800138002380033800438005380063800738008380093801038011380123801338014380153801638017380183801938020380213802238023380243802538026380273802838029380303803138032380333803438035380363803738038380393804038041380423804338044380453804638047380483804938050380513805238053380543805538056380573805838059380603806138062380633806438065380663806738068380693807038071380723807338074380753807638077380783807938080380813808238083380843808538086380873808838089380903809138092380933809438095380963809738098380993810038101381023810338104381053810638107381083810938110381113811238113381143811538116381173811838119381203812138122381233812438125381263812738128381293813038131381323813338134381353813638137381383813938140381413814238143381443814538146381473814838149381503815138152381533815438155381563815738158381593816038161381623816338164381653816638167381683816938170381713817238173381743817538176381773817838179381803818138182381833818438185381863818738188381893819038191381923819338194381953819638197381983819938200382013820238203382043820538206382073820838209382103821138212382133821438215382163821738218382193822038221382223822338224382253822638227382283822938230382313823238233382343823538236382373823838239382403824138242382433824438245382463824738248382493825038251382523825338254382553825638257382583825938260382613826238263382643826538266382673826838269382703827138272382733827438275382763827738278382793828038281382823828338284382853828638287382883828938290382913829238293382943829538296382973829838299383003830138302383033830438305383063830738308383093831038311383123831338314383153831638317383183831938320383213832238323383243832538326383273832838329383303833138332383333833438335383363833738338383393834038341383423834338344383453834638347383483834938350383513835238353383543835538356383573835838359383603836138362383633836438365383663836738368383693837038371383723837338374383753837638377383783837938380383813838238383383843838538386383873838838389383903839138392383933839438395383963839738398383993840038401384023840338404384053840638407384083840938410384113841238413384143841538416384173841838419384203842138422384233842438425384263842738428384293843038431384323843338434384353843638437384383843938440384413844238443384443844538446384473844838449384503845138452384533845438455384563845738458384593846038461384623846338464384653846638467384683846938470384713847238473384743847538476384773847838479384803848138482384833848438485384863848738488384893849038491384923849338494384953849638497384983849938500385013850238503385043850538506385073850838509385103851138512385133851438515385163851738518385193852038521385223852338524385253852638527385283852938530385313853238533385343853538536385373853838539385403854138542385433854438545385463854738548385493855038551385523855338554385553855638557385583855938560385613856238563385643856538566385673856838569385703857138572385733857438575385763857738578385793858038581385823858338584385853858638587385883858938590385913859238593385943859538596385973859838599386003860138602386033860438605386063860738608386093861038611386123861338614386153861638617386183861938620386213862238623386243862538626386273862838629386303863138632386333863438635386363863738638386393864038641386423864338644386453864638647386483864938650386513865238653386543865538656386573865838659386603866138662386633866438665386663866738668386693867038671386723867338674386753867638677386783867938680386813868238683386843868538686386873868838689386903869138692386933869438695386963869738698386993870038701387023870338704387053870638707387083870938710387113871238713387143871538716387173871838719387203872138722387233872438725387263872738728387293873038731387323873338734387353873638737387383873938740387413874238743387443874538746387473874838749387503875138752387533875438755387563875738758387593876038761387623876338764387653876638767387683876938770387713877238773387743877538776387773877838779387803878138782387833878438785387863878738788387893879038791387923879338794387953879638797387983879938800388013880238803388043880538806388073880838809388103881138812388133881438815388163881738818388193882038821388223882338824388253882638827388283882938830388313883238833388343883538836388373883838839388403884138842388433884438845388463884738848388493885038851388523885338854388553885638857388583885938860388613886238863388643886538866388673886838869388703887138872388733887438875388763887738878388793888038881388823888338884388853888638887388883888938890388913889238893388943889538896388973889838899389003890138902389033890438905389063890738908389093891038911389123891338914389153891638917389183891938920389213892238923389243892538926389273892838929389303893138932389333893438935389363893738938389393894038941389423894338944389453894638947389483894938950389513895238953389543895538956389573895838959389603896138962389633896438965389663896738968389693897038971389723897338974389753897638977389783897938980389813898238983389843898538986389873898838989389903899138992389933899438995389963899738998389993900039001390023900339004390053900639007390083900939010390113901239013390143901539016390173901839019390203902139022390233902439025390263902739028390293903039031390323903339034390353903639037390383903939040390413904239043390443904539046390473904839049390503905139052390533905439055390563905739058390593906039061390623906339064390653906639067390683906939070390713907239073390743907539076390773907839079390803908139082390833908439085390863908739088390893909039091390923909339094390953909639097390983909939100391013910239103391043910539106391073910839109391103911139112391133911439115391163911739118391193912039121391223912339124391253912639127391283912939130391313913239133391343913539136391373913839139391403914139142391433914439145391463914739148391493915039151391523915339154391553915639157391583915939160391613916239163391643916539166391673916839169391703917139172391733917439175391763917739178391793918039181391823918339184391853918639187391883918939190391913919239193391943919539196391973919839199392003920139202392033920439205392063920739208392093921039211392123921339214392153921639217392183921939220392213922239223392243922539226392273922839229392303923139232392333923439235392363923739238392393924039241392423924339244392453924639247392483924939250392513925239253392543925539256392573925839259392603926139262392633926439265392663926739268392693927039271392723927339274392753927639277392783927939280392813928239283392843928539286392873928839289392903929139292392933929439295392963929739298392993930039301393023930339304393053930639307393083930939310393113931239313393143931539316393173931839319393203932139322393233932439325393263932739328393293933039331393323933339334393353933639337393383933939340393413934239343393443934539346393473934839349393503935139352393533935439355393563935739358393593936039361393623936339364393653936639367393683936939370393713937239373393743937539376393773937839379393803938139382393833938439385393863938739388393893939039391393923939339394393953939639397393983939939400394013940239403394043940539406394073940839409394103941139412394133941439415394163941739418394193942039421394223942339424394253942639427394283942939430394313943239433394343943539436394373943839439394403944139442394433944439445394463944739448394493945039451394523945339454394553945639457394583945939460394613946239463394643946539466394673946839469394703947139472394733947439475394763947739478394793948039481394823948339484394853948639487394883948939490394913949239493394943949539496394973949839499395003950139502395033950439505395063950739508395093951039511395123951339514395153951639517395183951939520395213952239523395243952539526395273952839529395303953139532395333953439535395363953739538395393954039541395423954339544395453954639547395483954939550395513955239553395543955539556395573955839559395603956139562395633956439565395663956739568395693957039571395723957339574395753957639577395783957939580395813958239583395843958539586395873958839589395903959139592395933959439595395963959739598395993960039601396023960339604396053960639607396083960939610396113961239613396143961539616396173961839619396203962139622396233962439625396263962739628396293963039631396323963339634396353963639637396383963939640396413964239643396443964539646396473964839649396503965139652396533965439655396563965739658396593966039661396623966339664396653966639667396683966939670396713967239673396743967539676396773967839679396803968139682396833968439685396863968739688396893969039691396923969339694396953969639697396983969939700397013970239703397043970539706397073970839709397103971139712397133971439715397163971739718397193972039721397223972339724397253972639727397283972939730397313973239733397343973539736397373973839739397403974139742397433974439745397463974739748397493975039751397523975339754397553975639757397583975939760397613976239763397643976539766397673976839769397703977139772397733977439775397763977739778397793978039781397823978339784397853978639787397883978939790397913979239793397943979539796397973979839799398003980139802398033980439805398063980739808398093981039811398123981339814398153981639817398183981939820398213982239823398243982539826398273982839829398303983139832398333983439835398363983739838398393984039841398423984339844398453984639847398483984939850398513985239853398543985539856398573985839859398603986139862398633986439865398663986739868398693987039871398723987339874398753987639877398783987939880398813988239883398843988539886398873988839889398903989139892398933989439895398963989739898398993990039901399023990339904399053990639907399083990939910399113991239913399143991539916399173991839919399203992139922399233992439925399263992739928399293993039931399323993339934399353993639937399383993939940399413994239943399443994539946399473994839949399503995139952399533995439955399563995739958399593996039961399623996339964399653996639967399683996939970399713997239973399743997539976399773997839979399803998139982399833998439985399863998739988399893999039991399923999339994399953999639997399983999940000400014000240003400044000540006400074000840009400104001140012400134001440015400164001740018400194002040021400224002340024400254002640027400284002940030400314003240033400344003540036400374003840039400404004140042400434004440045400464004740048400494005040051400524005340054400554005640057400584005940060400614006240063400644006540066400674006840069400704007140072400734007440075400764007740078400794008040081400824008340084400854008640087400884008940090400914009240093400944009540096400974009840099401004010140102401034010440105401064010740108401094011040111401124011340114401154011640117401184011940120401214012240123401244012540126401274012840129401304013140132401334013440135401364013740138401394014040141401424014340144401454014640147401484014940150401514015240153401544015540156401574015840159401604016140162401634016440165401664016740168401694017040171401724017340174401754017640177401784017940180401814018240183401844018540186401874018840189401904019140192401934019440195401964019740198401994020040201402024020340204402054020640207402084020940210402114021240213402144021540216402174021840219402204022140222402234022440225402264022740228402294023040231402324023340234402354023640237402384023940240402414024240243402444024540246402474024840249402504025140252402534025440255402564025740258402594026040261402624026340264402654026640267402684026940270402714027240273402744027540276402774027840279402804028140282402834028440285402864028740288402894029040291402924029340294402954029640297402984029940300403014030240303403044030540306403074030840309403104031140312403134031440315403164031740318403194032040321403224032340324403254032640327403284032940330403314033240333403344033540336403374033840339403404034140342403434034440345403464034740348403494035040351403524035340354403554035640357403584035940360403614036240363403644036540366403674036840369403704037140372403734037440375403764037740378403794038040381403824038340384403854038640387403884038940390403914039240393403944039540396403974039840399404004040140402404034040440405404064040740408404094041040411404124041340414404154041640417404184041940420404214042240423404244042540426404274042840429404304043140432404334043440435404364043740438404394044040441404424044340444404454044640447404484044940450404514045240453404544045540456404574045840459404604046140462404634046440465404664046740468404694047040471404724047340474404754047640477404784047940480404814048240483404844048540486404874048840489404904049140492404934049440495404964049740498404994050040501405024050340504405054050640507405084050940510405114051240513405144051540516405174051840519405204052140522405234052440525405264052740528405294053040531405324053340534405354053640537405384053940540405414054240543405444054540546405474054840549405504055140552405534055440555405564055740558405594056040561405624056340564405654056640567405684056940570405714057240573405744057540576405774057840579405804058140582405834058440585405864058740588405894059040591405924059340594405954059640597405984059940600406014060240603406044060540606406074060840609406104061140612406134061440615406164061740618406194062040621406224062340624406254062640627406284062940630406314063240633406344063540636406374063840639406404064140642406434064440645406464064740648406494065040651406524065340654406554065640657406584065940660406614066240663406644066540666406674066840669406704067140672406734067440675406764067740678406794068040681406824068340684406854068640687406884068940690406914069240693406944069540696406974069840699407004070140702407034070440705407064070740708407094071040711407124071340714407154071640717407184071940720407214072240723407244072540726407274072840729407304073140732407334073440735407364073740738407394074040741407424074340744407454074640747407484074940750407514075240753407544075540756407574075840759407604076140762407634076440765407664076740768407694077040771407724077340774407754077640777407784077940780407814078240783407844078540786407874078840789407904079140792407934079440795407964079740798407994080040801408024080340804408054080640807408084080940810408114081240813408144081540816408174081840819408204082140822408234082440825408264082740828408294083040831408324083340834408354083640837408384083940840408414084240843408444084540846408474084840849408504085140852408534085440855408564085740858408594086040861408624086340864408654086640867408684086940870408714087240873408744087540876408774087840879408804088140882408834088440885408864088740888408894089040891408924089340894408954089640897408984089940900409014090240903409044090540906409074090840909409104091140912409134091440915409164091740918409194092040921409224092340924409254092640927409284092940930409314093240933409344093540936409374093840939409404094140942409434094440945409464094740948409494095040951409524095340954409554095640957409584095940960409614096240963409644096540966409674096840969409704097140972409734097440975409764097740978409794098040981409824098340984409854098640987409884098940990409914099240993409944099540996409974099840999410004100141002410034100441005410064100741008410094101041011410124101341014410154101641017410184101941020410214102241023410244102541026410274102841029410304103141032410334103441035410364103741038410394104041041410424104341044410454104641047410484104941050410514105241053410544105541056410574105841059410604106141062410634106441065410664106741068410694107041071410724107341074410754107641077410784107941080410814108241083410844108541086410874108841089410904109141092410934109441095410964109741098410994110041101411024110341104411054110641107411084110941110411114111241113411144111541116411174111841119411204112141122411234112441125411264112741128411294113041131411324113341134411354113641137411384113941140411414114241143411444114541146411474114841149411504115141152411534115441155411564115741158411594116041161411624116341164411654116641167411684116941170411714117241173411744117541176411774117841179411804118141182411834118441185411864118741188411894119041191411924119341194411954119641197411984119941200412014120241203412044120541206412074120841209412104121141212412134121441215412164121741218412194122041221412224122341224412254122641227412284122941230412314123241233412344123541236412374123841239412404124141242412434124441245412464124741248412494125041251412524125341254412554125641257412584125941260412614126241263412644126541266412674126841269412704127141272412734127441275412764127741278412794128041281412824128341284412854128641287412884128941290412914129241293412944129541296412974129841299413004130141302413034130441305413064130741308413094131041311413124131341314413154131641317413184131941320413214132241323413244132541326413274132841329413304133141332413334133441335413364133741338413394134041341413424134341344413454134641347413484134941350413514135241353413544135541356413574135841359413604136141362413634136441365413664136741368413694137041371413724137341374413754137641377413784137941380413814138241383413844138541386413874138841389413904139141392413934139441395413964139741398413994140041401414024140341404414054140641407414084140941410414114141241413414144141541416414174141841419414204142141422414234142441425414264142741428414294143041431414324143341434414354143641437414384143941440414414144241443414444144541446414474144841449414504145141452414534145441455414564145741458414594146041461414624146341464414654146641467414684146941470414714147241473414744147541476414774147841479414804148141482414834148441485414864148741488414894149041491414924149341494414954149641497414984149941500415014150241503415044150541506415074150841509415104151141512415134151441515415164151741518415194152041521415224152341524415254152641527415284152941530415314153241533415344153541536415374153841539415404154141542415434154441545415464154741548415494155041551415524155341554415554155641557415584155941560415614156241563415644156541566415674156841569415704157141572415734157441575415764157741578415794158041581415824158341584415854158641587415884158941590415914159241593415944159541596415974159841599416004160141602416034160441605416064160741608416094161041611416124161341614416154161641617416184161941620416214162241623416244162541626416274162841629416304163141632416334163441635416364163741638416394164041641416424164341644416454164641647416484164941650416514165241653416544165541656416574165841659416604166141662416634166441665416664166741668416694167041671416724167341674416754167641677416784167941680416814168241683416844168541686416874168841689416904169141692416934169441695416964169741698416994170041701417024170341704417054170641707417084170941710417114171241713417144171541716417174171841719417204172141722417234172441725417264172741728417294173041731417324173341734417354173641737417384173941740417414174241743417444174541746417474174841749417504175141752417534175441755417564175741758417594176041761417624176341764417654176641767417684176941770417714177241773417744177541776417774177841779417804178141782417834178441785417864178741788417894179041791417924179341794417954179641797417984179941800418014180241803418044180541806418074180841809418104181141812418134181441815418164181741818418194182041821418224182341824418254182641827418284182941830418314183241833418344183541836418374183841839418404184141842418434184441845418464184741848418494185041851418524185341854418554185641857418584185941860418614186241863418644186541866418674186841869418704187141872418734187441875418764187741878418794188041881418824188341884418854188641887418884188941890418914189241893418944189541896418974189841899419004190141902419034190441905419064190741908419094191041911419124191341914419154191641917419184191941920419214192241923419244192541926419274192841929419304193141932419334193441935419364193741938419394194041941419424194341944419454194641947419484194941950419514195241953419544195541956419574195841959419604196141962419634196441965419664196741968419694197041971419724197341974419754197641977419784197941980419814198241983419844198541986419874198841989419904199141992419934199441995419964199741998419994200042001420024200342004420054200642007420084200942010420114201242013420144201542016420174201842019420204202142022420234202442025420264202742028420294203042031420324203342034420354203642037420384203942040420414204242043420444204542046420474204842049420504205142052420534205442055420564205742058420594206042061420624206342064420654206642067420684206942070420714207242073420744207542076420774207842079420804208142082420834208442085420864208742088420894209042091420924209342094420954209642097420984209942100421014210242103421044210542106421074210842109421104211142112421134211442115421164211742118421194212042121421224212342124421254212642127421284212942130421314213242133421344213542136421374213842139421404214142142421434214442145421464214742148421494215042151421524215342154421554215642157421584215942160421614216242163421644216542166421674216842169421704217142172421734217442175421764217742178421794218042181421824218342184421854218642187421884218942190421914219242193421944219542196421974219842199422004220142202422034220442205422064220742208422094221042211422124221342214422154221642217422184221942220422214222242223422244222542226422274222842229422304223142232422334223442235422364223742238422394224042241422424224342244422454224642247422484224942250422514225242253422544225542256422574225842259422604226142262422634226442265422664226742268422694227042271422724227342274422754227642277422784227942280422814228242283422844228542286422874228842289422904229142292422934229442295422964229742298422994230042301423024230342304423054230642307423084230942310423114231242313423144231542316423174231842319423204232142322423234232442325423264232742328423294233042331423324233342334423354233642337423384233942340423414234242343423444234542346423474234842349423504235142352423534235442355423564235742358423594236042361423624236342364423654236642367423684236942370423714237242373423744237542376423774237842379423804238142382423834238442385423864238742388423894239042391423924239342394423954239642397423984239942400424014240242403424044240542406424074240842409424104241142412424134241442415424164241742418424194242042421424224242342424424254242642427424284242942430424314243242433424344243542436424374243842439424404244142442424434244442445424464244742448424494245042451424524245342454424554245642457424584245942460424614246242463424644246542466424674246842469424704247142472424734247442475424764247742478424794248042481424824248342484424854248642487424884248942490424914249242493424944249542496424974249842499425004250142502425034250442505425064250742508425094251042511425124251342514425154251642517425184251942520425214252242523425244252542526425274252842529425304253142532425334253442535425364253742538425394254042541425424254342544425454254642547425484254942550425514255242553425544255542556425574255842559425604256142562425634256442565425664256742568425694257042571425724257342574425754257642577425784257942580425814258242583425844258542586425874258842589425904259142592425934259442595425964259742598425994260042601426024260342604426054260642607426084260942610426114261242613426144261542616426174261842619426204262142622426234262442625426264262742628426294263042631426324263342634426354263642637426384263942640426414264242643426444264542646426474264842649426504265142652426534265442655426564265742658426594266042661426624266342664426654266642667426684266942670426714267242673426744267542676426774267842679426804268142682426834268442685426864268742688426894269042691426924269342694426954269642697426984269942700427014270242703427044270542706427074270842709427104271142712427134271442715427164271742718427194272042721427224272342724427254272642727427284272942730427314273242733427344273542736427374273842739427404274142742427434274442745427464274742748427494275042751427524275342754427554275642757427584275942760427614276242763427644276542766427674276842769427704277142772427734277442775427764277742778427794278042781427824278342784427854278642787427884278942790427914279242793427944279542796427974279842799428004280142802428034280442805428064280742808428094281042811428124281342814428154281642817428184281942820428214282242823428244282542826428274282842829428304283142832428334283442835428364283742838428394284042841428424284342844428454284642847428484284942850428514285242853428544285542856428574285842859428604286142862428634286442865428664286742868428694287042871428724287342874428754287642877428784287942880428814288242883428844288542886428874288842889428904289142892428934289442895428964289742898428994290042901429024290342904429054290642907429084290942910429114291242913429144291542916429174291842919429204292142922429234292442925429264292742928429294293042931429324293342934429354293642937429384293942940429414294242943429444294542946429474294842949429504295142952429534295442955429564295742958429594296042961429624296342964429654296642967429684296942970429714297242973429744297542976429774297842979429804298142982429834298442985429864298742988429894299042991429924299342994429954299642997429984299943000430014300243003430044300543006430074300843009430104301143012430134301443015430164301743018430194302043021430224302343024430254302643027430284302943030430314303243033430344303543036430374303843039430404304143042430434304443045430464304743048430494305043051430524305343054430554305643057430584305943060430614306243063430644306543066430674306843069430704307143072430734307443075430764307743078430794308043081430824308343084430854308643087430884308943090430914309243093430944309543096430974309843099431004310143102431034310443105431064310743108431094311043111431124311343114431154311643117431184311943120431214312243123431244312543126431274312843129431304313143132431334313443135431364313743138431394314043141431424314343144431454314643147431484314943150431514315243153431544315543156431574315843159431604316143162431634316443165431664316743168431694317043171431724317343174431754317643177431784317943180431814318243183431844318543186431874318843189431904319143192431934319443195431964319743198431994320043201432024320343204432054320643207432084320943210432114321243213432144321543216432174321843219432204322143222432234322443225432264322743228432294323043231432324323343234432354323643237432384323943240432414324243243432444324543246432474324843249432504325143252432534325443255432564325743258432594326043261432624326343264432654326643267432684326943270432714327243273432744327543276432774327843279432804328143282432834328443285432864328743288432894329043291432924329343294432954329643297432984329943300433014330243303433044330543306433074330843309433104331143312433134331443315433164331743318433194332043321433224332343324433254332643327433284332943330433314333243333433344333543336433374333843339433404334143342433434334443345433464334743348433494335043351433524335343354433554335643357433584335943360433614336243363433644336543366433674336843369433704337143372433734337443375433764337743378433794338043381433824338343384433854338643387433884338943390433914339243393433944339543396433974339843399434004340143402434034340443405434064340743408434094341043411434124341343414434154341643417434184341943420434214342243423434244342543426434274342843429434304343143432434334343443435434364343743438434394344043441434424344343444434454344643447434484344943450434514345243453434544345543456434574345843459434604346143462434634346443465434664346743468434694347043471434724347343474434754347643477434784347943480434814348243483434844348543486434874348843489434904349143492434934349443495434964349743498434994350043501435024350343504435054350643507435084350943510435114351243513435144351543516435174351843519435204352143522435234352443525435264352743528435294353043531435324353343534435354353643537435384353943540435414354243543435444354543546435474354843549435504355143552435534355443555435564355743558435594356043561435624356343564435654356643567435684356943570435714357243573435744357543576435774357843579435804358143582435834358443585435864358743588435894359043591435924359343594435954359643597435984359943600436014360243603436044360543606436074360843609436104361143612436134361443615436164361743618436194362043621436224362343624436254362643627436284362943630436314363243633436344363543636436374363843639436404364143642436434364443645436464364743648436494365043651436524365343654436554365643657436584365943660436614366243663436644366543666436674366843669436704367143672436734367443675436764367743678436794368043681436824368343684436854368643687436884368943690436914369243693436944369543696436974369843699437004370143702437034370443705437064370743708437094371043711437124371343714437154371643717437184371943720437214372243723437244372543726437274372843729437304373143732437334373443735437364373743738437394374043741437424374343744437454374643747437484374943750437514375243753437544375543756437574375843759437604376143762437634376443765437664376743768437694377043771437724377343774437754377643777437784377943780437814378243783437844378543786437874378843789437904379143792437934379443795437964379743798437994380043801438024380343804438054380643807438084380943810438114381243813438144381543816438174381843819438204382143822438234382443825438264382743828438294383043831438324383343834438354383643837438384383943840438414384243843438444384543846438474384843849438504385143852438534385443855438564385743858438594386043861438624386343864438654386643867438684386943870438714387243873438744387543876438774387843879438804388143882438834388443885438864388743888438894389043891438924389343894438954389643897438984389943900439014390243903439044390543906439074390843909439104391143912439134391443915439164391743918439194392043921439224392343924439254392643927439284392943930439314393243933439344393543936439374393843939439404394143942439434394443945439464394743948439494395043951439524395343954439554395643957439584395943960439614396243963439644396543966439674396843969439704397143972439734397443975439764397743978439794398043981439824398343984439854398643987439884398943990439914399243993439944399543996439974399843999440004400144002440034400444005440064400744008440094401044011440124401344014440154401644017440184401944020440214402244023440244402544026440274402844029440304403144032440334403444035440364403744038440394404044041440424404344044440454404644047440484404944050440514405244053440544405544056440574405844059440604406144062440634406444065440664406744068440694407044071440724407344074440754407644077440784407944080440814408244083440844408544086440874408844089440904409144092440934409444095440964409744098440994410044101441024410344104441054410644107441084410944110441114411244113441144411544116441174411844119441204412144122441234412444125441264412744128441294413044131441324413344134441354413644137441384413944140441414414244143441444414544146441474414844149441504415144152441534415444155441564415744158441594416044161441624416344164441654416644167441684416944170441714417244173441744417544176441774417844179441804418144182441834418444185441864418744188441894419044191441924419344194441954419644197441984419944200442014420244203442044420544206442074420844209442104421144212442134421444215442164421744218442194422044221442224422344224442254422644227442284422944230442314423244233442344423544236442374423844239442404424144242442434424444245442464424744248442494425044251442524425344254442554425644257442584425944260442614426244263442644426544266442674426844269442704427144272442734427444275442764427744278442794428044281442824428344284442854428644287442884428944290442914429244293442944429544296442974429844299443004430144302443034430444305443064430744308443094431044311443124431344314443154431644317443184431944320443214432244323443244432544326443274432844329443304433144332443334433444335443364433744338443394434044341443424434344344443454434644347443484434944350443514435244353443544435544356443574435844359443604436144362443634436444365443664436744368443694437044371443724437344374443754437644377443784437944380443814438244383443844438544386443874438844389443904439144392443934439444395443964439744398443994440044401444024440344404444054440644407444084440944410444114441244413444144441544416444174441844419444204442144422444234442444425444264442744428444294443044431444324443344434444354443644437444384443944440444414444244443444444444544446444474444844449444504445144452444534445444455444564445744458444594446044461444624446344464444654446644467444684446944470444714447244473444744447544476444774447844479444804448144482444834448444485444864448744488444894449044491444924449344494444954449644497444984449944500445014450244503445044450544506445074450844509445104451144512445134451444515445164451744518445194452044521445224452344524445254452644527445284452944530445314453244533445344453544536445374453844539445404454144542445434454444545445464454744548445494455044551445524455344554445554455644557445584455944560445614456244563445644456544566445674456844569445704457144572445734457444575445764457744578445794458044581445824458344584445854458644587445884458944590445914459244593445944459544596445974459844599446004460144602446034460444605446064460744608446094461044611446124461344614446154461644617446184461944620446214462244623446244462544626446274462844629446304463144632446334463444635446364463744638446394464044641446424464344644446454464644647446484464944650446514465244653446544465544656446574465844659446604466144662446634466444665446664466744668446694467044671446724467344674446754467644677446784467944680446814468244683446844468544686446874468844689446904469144692446934469444695446964469744698446994470044701447024470344704447054470644707447084470944710447114471244713447144471544716447174471844719447204472144722447234472444725447264472744728447294473044731447324473344734447354473644737447384473944740447414474244743447444474544746447474474844749447504475144752447534475444755447564475744758447594476044761447624476344764447654476644767447684476944770447714477244773447744477544776447774477844779447804478144782447834478444785447864478744788447894479044791447924479344794447954479644797447984479944800448014480244803448044480544806448074480844809448104481144812448134481444815448164481744818448194482044821448224482344824448254482644827448284482944830448314483244833448344483544836448374483844839448404484144842448434484444845448464484744848448494485044851448524485344854448554485644857448584485944860448614486244863448644486544866448674486844869448704487144872448734487444875448764487744878448794488044881448824488344884448854488644887448884488944890448914489244893448944489544896448974489844899449004490144902449034490444905449064490744908449094491044911449124491344914449154491644917449184491944920449214492244923449244492544926449274492844929449304493144932449334493444935449364493744938449394494044941449424494344944449454494644947449484494944950449514495244953449544495544956449574495844959449604496144962449634496444965449664496744968449694497044971449724497344974449754497644977449784497944980449814498244983449844498544986449874498844989449904499144992449934499444995449964499744998449994500045001450024500345004450054500645007450084500945010450114501245013450144501545016450174501845019450204502145022450234502445025450264502745028450294503045031450324503345034450354503645037450384503945040450414504245043450444504545046450474504845049450504505145052450534505445055450564505745058450594506045061450624506345064450654506645067450684506945070450714507245073450744507545076450774507845079450804508145082450834508445085450864508745088450894509045091450924509345094450954509645097450984509945100451014510245103451044510545106451074510845109451104511145112451134511445115451164511745118451194512045121451224512345124451254512645127451284512945130451314513245133451344513545136451374513845139451404514145142451434514445145451464514745148451494515045151451524515345154451554515645157451584515945160451614516245163451644516545166451674516845169451704517145172451734517445175451764517745178451794518045181451824518345184451854518645187451884518945190451914519245193451944519545196451974519845199452004520145202452034520445205452064520745208452094521045211452124521345214452154521645217452184521945220452214522245223452244522545226452274522845229452304523145232452334523445235452364523745238452394524045241452424524345244452454524645247452484524945250452514525245253452544525545256452574525845259452604526145262452634526445265452664526745268452694527045271452724527345274452754527645277452784527945280452814528245283452844528545286452874528845289452904529145292452934529445295452964529745298452994530045301453024530345304453054530645307453084530945310453114531245313453144531545316453174531845319453204532145322453234532445325453264532745328453294533045331453324533345334453354533645337453384533945340453414534245343453444534545346453474534845349453504535145352453534535445355453564535745358453594536045361453624536345364453654536645367453684536945370453714537245373453744537545376453774537845379453804538145382453834538445385453864538745388453894539045391453924539345394453954539645397453984539945400454014540245403454044540545406454074540845409454104541145412454134541445415454164541745418454194542045421454224542345424454254542645427454284542945430454314543245433454344543545436454374543845439454404544145442454434544445445454464544745448454494545045451454524545345454454554545645457454584545945460454614546245463454644546545466454674546845469454704547145472454734547445475454764547745478454794548045481454824548345484454854548645487454884548945490454914549245493454944549545496454974549845499455004550145502455034550445505455064550745508455094551045511455124551345514455154551645517455184551945520455214552245523455244552545526455274552845529455304553145532455334553445535455364553745538455394554045541455424554345544455454554645547455484554945550455514555245553455544555545556455574555845559455604556145562455634556445565455664556745568455694557045571455724557345574455754557645577455784557945580455814558245583455844558545586455874558845589455904559145592455934559445595455964559745598455994560045601456024560345604456054560645607456084560945610456114561245613456144561545616456174561845619456204562145622456234562445625456264562745628456294563045631456324563345634456354563645637456384563945640456414564245643456444564545646456474564845649456504565145652456534565445655456564565745658456594566045661456624566345664456654566645667456684566945670456714567245673456744567545676456774567845679456804568145682456834568445685456864568745688456894569045691456924569345694456954569645697456984569945700457014570245703457044570545706457074570845709457104571145712457134571445715457164571745718457194572045721457224572345724457254572645727457284572945730457314573245733457344573545736457374573845739457404574145742457434574445745457464574745748457494575045751457524575345754457554575645757457584575945760457614576245763457644576545766457674576845769457704577145772457734577445775457764577745778457794578045781457824578345784457854578645787457884578945790457914579245793457944579545796457974579845799458004580145802458034580445805458064580745808458094581045811458124581345814458154581645817458184581945820458214582245823458244582545826458274582845829458304583145832458334583445835458364583745838458394584045841458424584345844458454584645847458484584945850458514585245853458544585545856458574585845859458604586145862458634586445865458664586745868458694587045871458724587345874
  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. done bool
  128. oldValue func(context.Context) (*Agent, error)
  129. predicates []predicate.Agent
  130. }
  131. var _ ent.Mutation = (*AgentMutation)(nil)
  132. // agentOption allows management of the mutation configuration using functional options.
  133. type agentOption func(*AgentMutation)
  134. // newAgentMutation creates new mutation for the Agent entity.
  135. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  136. m := &AgentMutation{
  137. config: c,
  138. op: op,
  139. typ: TypeAgent,
  140. clearedFields: make(map[string]struct{}),
  141. }
  142. for _, opt := range opts {
  143. opt(m)
  144. }
  145. return m
  146. }
  147. // withAgentID sets the ID field of the mutation.
  148. func withAgentID(id uint64) agentOption {
  149. return func(m *AgentMutation) {
  150. var (
  151. err error
  152. once sync.Once
  153. value *Agent
  154. )
  155. m.oldValue = func(ctx context.Context) (*Agent, error) {
  156. once.Do(func() {
  157. if m.done {
  158. err = errors.New("querying old values post mutation is not allowed")
  159. } else {
  160. value, err = m.Client().Agent.Get(ctx, id)
  161. }
  162. })
  163. return value, err
  164. }
  165. m.id = &id
  166. }
  167. }
  168. // withAgent sets the old Agent of the mutation.
  169. func withAgent(node *Agent) agentOption {
  170. return func(m *AgentMutation) {
  171. m.oldValue = func(context.Context) (*Agent, error) {
  172. return node, nil
  173. }
  174. m.id = &node.ID
  175. }
  176. }
  177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  178. // executed in a transaction (ent.Tx), a transactional client is returned.
  179. func (m AgentMutation) Client() *Client {
  180. client := &Client{config: m.config}
  181. client.init()
  182. return client
  183. }
  184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  185. // it returns an error otherwise.
  186. func (m AgentMutation) Tx() (*Tx, error) {
  187. if _, ok := m.driver.(*txDriver); !ok {
  188. return nil, errors.New("ent: mutation is not running in a transaction")
  189. }
  190. tx := &Tx{config: m.config}
  191. tx.init()
  192. return tx, nil
  193. }
  194. // SetID sets the value of the id field. Note that this
  195. // operation is only accepted on creation of Agent entities.
  196. func (m *AgentMutation) SetID(id uint64) {
  197. m.id = &id
  198. }
  199. // ID returns the ID value in the mutation. Note that the ID is only available
  200. // if it was provided to the builder or after it was returned from the database.
  201. func (m *AgentMutation) ID() (id uint64, exists bool) {
  202. if m.id == nil {
  203. return
  204. }
  205. return *m.id, true
  206. }
  207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  208. // That means, if the mutation is applied within a transaction with an isolation level such
  209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  210. // or updated by the mutation.
  211. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  212. switch {
  213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  214. id, exists := m.ID()
  215. if exists {
  216. return []uint64{id}, nil
  217. }
  218. fallthrough
  219. case m.op.Is(OpUpdate | OpDelete):
  220. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  221. default:
  222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  223. }
  224. }
  225. // SetCreatedAt sets the "created_at" field.
  226. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  227. m.created_at = &t
  228. }
  229. // CreatedAt returns the value of the "created_at" field in the mutation.
  230. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  231. v := m.created_at
  232. if v == nil {
  233. return
  234. }
  235. return *v, true
  236. }
  237. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  238. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  240. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  241. if !m.op.Is(OpUpdateOne) {
  242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  243. }
  244. if m.id == nil || m.oldValue == nil {
  245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  246. }
  247. oldValue, err := m.oldValue(ctx)
  248. if err != nil {
  249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  250. }
  251. return oldValue.CreatedAt, nil
  252. }
  253. // ResetCreatedAt resets all changes to the "created_at" field.
  254. func (m *AgentMutation) ResetCreatedAt() {
  255. m.created_at = nil
  256. }
  257. // SetUpdatedAt sets the "updated_at" field.
  258. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  259. m.updated_at = &t
  260. }
  261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  262. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  263. v := m.updated_at
  264. if v == nil {
  265. return
  266. }
  267. return *v, true
  268. }
  269. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  270. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  272. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  273. if !m.op.Is(OpUpdateOne) {
  274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  275. }
  276. if m.id == nil || m.oldValue == nil {
  277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  278. }
  279. oldValue, err := m.oldValue(ctx)
  280. if err != nil {
  281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  282. }
  283. return oldValue.UpdatedAt, nil
  284. }
  285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  286. func (m *AgentMutation) ResetUpdatedAt() {
  287. m.updated_at = nil
  288. }
  289. // SetDeletedAt sets the "deleted_at" field.
  290. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  291. m.deleted_at = &t
  292. }
  293. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  294. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  295. v := m.deleted_at
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  314. }
  315. return oldValue.DeletedAt, nil
  316. }
  317. // ClearDeletedAt clears the value of the "deleted_at" field.
  318. func (m *AgentMutation) ClearDeletedAt() {
  319. m.deleted_at = nil
  320. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  321. }
  322. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  323. func (m *AgentMutation) DeletedAtCleared() bool {
  324. _, ok := m.clearedFields[agent.FieldDeletedAt]
  325. return ok
  326. }
  327. // ResetDeletedAt resets all changes to the "deleted_at" field.
  328. func (m *AgentMutation) ResetDeletedAt() {
  329. m.deleted_at = nil
  330. delete(m.clearedFields, agent.FieldDeletedAt)
  331. }
  332. // SetName sets the "name" field.
  333. func (m *AgentMutation) SetName(s string) {
  334. m.name = &s
  335. }
  336. // Name returns the value of the "name" field in the mutation.
  337. func (m *AgentMutation) Name() (r string, exists bool) {
  338. v := m.name
  339. if v == nil {
  340. return
  341. }
  342. return *v, true
  343. }
  344. // OldName returns the old "name" field's value of the Agent entity.
  345. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  347. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  348. if !m.op.Is(OpUpdateOne) {
  349. return v, errors.New("OldName is only allowed on UpdateOne operations")
  350. }
  351. if m.id == nil || m.oldValue == nil {
  352. return v, errors.New("OldName requires an ID field in the mutation")
  353. }
  354. oldValue, err := m.oldValue(ctx)
  355. if err != nil {
  356. return v, fmt.Errorf("querying old value for OldName: %w", err)
  357. }
  358. return oldValue.Name, nil
  359. }
  360. // ResetName resets all changes to the "name" field.
  361. func (m *AgentMutation) ResetName() {
  362. m.name = nil
  363. }
  364. // SetRole sets the "role" field.
  365. func (m *AgentMutation) SetRole(s string) {
  366. m.role = &s
  367. }
  368. // Role returns the value of the "role" field in the mutation.
  369. func (m *AgentMutation) Role() (r string, exists bool) {
  370. v := m.role
  371. if v == nil {
  372. return
  373. }
  374. return *v, true
  375. }
  376. // OldRole returns the old "role" field's value of the Agent entity.
  377. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  379. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  380. if !m.op.Is(OpUpdateOne) {
  381. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  382. }
  383. if m.id == nil || m.oldValue == nil {
  384. return v, errors.New("OldRole requires an ID field in the mutation")
  385. }
  386. oldValue, err := m.oldValue(ctx)
  387. if err != nil {
  388. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  389. }
  390. return oldValue.Role, nil
  391. }
  392. // ResetRole resets all changes to the "role" field.
  393. func (m *AgentMutation) ResetRole() {
  394. m.role = nil
  395. }
  396. // SetStatus sets the "status" field.
  397. func (m *AgentMutation) SetStatus(i int) {
  398. m.status = &i
  399. m.addstatus = nil
  400. }
  401. // Status returns the value of the "status" field in the mutation.
  402. func (m *AgentMutation) Status() (r int, exists bool) {
  403. v := m.status
  404. if v == nil {
  405. return
  406. }
  407. return *v, true
  408. }
  409. // OldStatus returns the old "status" field's value of the Agent entity.
  410. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  412. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  413. if !m.op.Is(OpUpdateOne) {
  414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  415. }
  416. if m.id == nil || m.oldValue == nil {
  417. return v, errors.New("OldStatus requires an ID field in the mutation")
  418. }
  419. oldValue, err := m.oldValue(ctx)
  420. if err != nil {
  421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  422. }
  423. return oldValue.Status, nil
  424. }
  425. // AddStatus adds i to the "status" field.
  426. func (m *AgentMutation) AddStatus(i int) {
  427. if m.addstatus != nil {
  428. *m.addstatus += i
  429. } else {
  430. m.addstatus = &i
  431. }
  432. }
  433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  434. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  435. v := m.addstatus
  436. if v == nil {
  437. return
  438. }
  439. return *v, true
  440. }
  441. // ClearStatus clears the value of the "status" field.
  442. func (m *AgentMutation) ClearStatus() {
  443. m.status = nil
  444. m.addstatus = nil
  445. m.clearedFields[agent.FieldStatus] = struct{}{}
  446. }
  447. // StatusCleared returns if the "status" field was cleared in this mutation.
  448. func (m *AgentMutation) StatusCleared() bool {
  449. _, ok := m.clearedFields[agent.FieldStatus]
  450. return ok
  451. }
  452. // ResetStatus resets all changes to the "status" field.
  453. func (m *AgentMutation) ResetStatus() {
  454. m.status = nil
  455. m.addstatus = nil
  456. delete(m.clearedFields, agent.FieldStatus)
  457. }
  458. // SetBackground sets the "background" field.
  459. func (m *AgentMutation) SetBackground(s string) {
  460. m.background = &s
  461. }
  462. // Background returns the value of the "background" field in the mutation.
  463. func (m *AgentMutation) Background() (r string, exists bool) {
  464. v := m.background
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldBackground returns the old "background" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldBackground requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  483. }
  484. return oldValue.Background, nil
  485. }
  486. // ClearBackground clears the value of the "background" field.
  487. func (m *AgentMutation) ClearBackground() {
  488. m.background = nil
  489. m.clearedFields[agent.FieldBackground] = struct{}{}
  490. }
  491. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  492. func (m *AgentMutation) BackgroundCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldBackground]
  494. return ok
  495. }
  496. // ResetBackground resets all changes to the "background" field.
  497. func (m *AgentMutation) ResetBackground() {
  498. m.background = nil
  499. delete(m.clearedFields, agent.FieldBackground)
  500. }
  501. // SetExamples sets the "examples" field.
  502. func (m *AgentMutation) SetExamples(s string) {
  503. m.examples = &s
  504. }
  505. // Examples returns the value of the "examples" field in the mutation.
  506. func (m *AgentMutation) Examples() (r string, exists bool) {
  507. v := m.examples
  508. if v == nil {
  509. return
  510. }
  511. return *v, true
  512. }
  513. // OldExamples returns the old "examples" field's value of the Agent entity.
  514. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  516. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  517. if !m.op.Is(OpUpdateOne) {
  518. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  519. }
  520. if m.id == nil || m.oldValue == nil {
  521. return v, errors.New("OldExamples requires an ID field in the mutation")
  522. }
  523. oldValue, err := m.oldValue(ctx)
  524. if err != nil {
  525. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  526. }
  527. return oldValue.Examples, nil
  528. }
  529. // ClearExamples clears the value of the "examples" field.
  530. func (m *AgentMutation) ClearExamples() {
  531. m.examples = nil
  532. m.clearedFields[agent.FieldExamples] = struct{}{}
  533. }
  534. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  535. func (m *AgentMutation) ExamplesCleared() bool {
  536. _, ok := m.clearedFields[agent.FieldExamples]
  537. return ok
  538. }
  539. // ResetExamples resets all changes to the "examples" field.
  540. func (m *AgentMutation) ResetExamples() {
  541. m.examples = nil
  542. delete(m.clearedFields, agent.FieldExamples)
  543. }
  544. // SetOrganizationID sets the "organization_id" field.
  545. func (m *AgentMutation) SetOrganizationID(u uint64) {
  546. m.organization_id = &u
  547. m.addorganization_id = nil
  548. }
  549. // OrganizationID returns the value of the "organization_id" field in the mutation.
  550. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  551. v := m.organization_id
  552. if v == nil {
  553. return
  554. }
  555. return *v, true
  556. }
  557. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  558. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  560. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  561. if !m.op.Is(OpUpdateOne) {
  562. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  563. }
  564. if m.id == nil || m.oldValue == nil {
  565. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  566. }
  567. oldValue, err := m.oldValue(ctx)
  568. if err != nil {
  569. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  570. }
  571. return oldValue.OrganizationID, nil
  572. }
  573. // AddOrganizationID adds u to the "organization_id" field.
  574. func (m *AgentMutation) AddOrganizationID(u int64) {
  575. if m.addorganization_id != nil {
  576. *m.addorganization_id += u
  577. } else {
  578. m.addorganization_id = &u
  579. }
  580. }
  581. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  582. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  583. v := m.addorganization_id
  584. if v == nil {
  585. return
  586. }
  587. return *v, true
  588. }
  589. // ResetOrganizationID resets all changes to the "organization_id" field.
  590. func (m *AgentMutation) ResetOrganizationID() {
  591. m.organization_id = nil
  592. m.addorganization_id = nil
  593. }
  594. // SetDatasetID sets the "dataset_id" field.
  595. func (m *AgentMutation) SetDatasetID(s string) {
  596. m.dataset_id = &s
  597. }
  598. // DatasetID returns the value of the "dataset_id" field in the mutation.
  599. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  600. v := m.dataset_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  607. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  609. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  610. if !m.op.Is(OpUpdateOne) {
  611. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  612. }
  613. if m.id == nil || m.oldValue == nil {
  614. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  615. }
  616. oldValue, err := m.oldValue(ctx)
  617. if err != nil {
  618. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  619. }
  620. return oldValue.DatasetID, nil
  621. }
  622. // ResetDatasetID resets all changes to the "dataset_id" field.
  623. func (m *AgentMutation) ResetDatasetID() {
  624. m.dataset_id = nil
  625. }
  626. // SetCollectionID sets the "collection_id" field.
  627. func (m *AgentMutation) SetCollectionID(s string) {
  628. m.collection_id = &s
  629. }
  630. // CollectionID returns the value of the "collection_id" field in the mutation.
  631. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  632. v := m.collection_id
  633. if v == nil {
  634. return
  635. }
  636. return *v, true
  637. }
  638. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  639. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  641. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  642. if !m.op.Is(OpUpdateOne) {
  643. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  644. }
  645. if m.id == nil || m.oldValue == nil {
  646. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  647. }
  648. oldValue, err := m.oldValue(ctx)
  649. if err != nil {
  650. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  651. }
  652. return oldValue.CollectionID, nil
  653. }
  654. // ResetCollectionID resets all changes to the "collection_id" field.
  655. func (m *AgentMutation) ResetCollectionID() {
  656. m.collection_id = nil
  657. }
  658. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  659. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  660. if m.wx_agent == nil {
  661. m.wx_agent = make(map[uint64]struct{})
  662. }
  663. for i := range ids {
  664. m.wx_agent[ids[i]] = struct{}{}
  665. }
  666. }
  667. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  668. func (m *AgentMutation) ClearWxAgent() {
  669. m.clearedwx_agent = true
  670. }
  671. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  672. func (m *AgentMutation) WxAgentCleared() bool {
  673. return m.clearedwx_agent
  674. }
  675. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  676. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  677. if m.removedwx_agent == nil {
  678. m.removedwx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. delete(m.wx_agent, ids[i])
  682. m.removedwx_agent[ids[i]] = struct{}{}
  683. }
  684. }
  685. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  686. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  687. for id := range m.removedwx_agent {
  688. ids = append(ids, id)
  689. }
  690. return
  691. }
  692. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  693. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  694. for id := range m.wx_agent {
  695. ids = append(ids, id)
  696. }
  697. return
  698. }
  699. // ResetWxAgent resets all changes to the "wx_agent" edge.
  700. func (m *AgentMutation) ResetWxAgent() {
  701. m.wx_agent = nil
  702. m.clearedwx_agent = false
  703. m.removedwx_agent = nil
  704. }
  705. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  706. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  707. if m.token_agent == nil {
  708. m.token_agent = make(map[uint64]struct{})
  709. }
  710. for i := range ids {
  711. m.token_agent[ids[i]] = struct{}{}
  712. }
  713. }
  714. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  715. func (m *AgentMutation) ClearTokenAgent() {
  716. m.clearedtoken_agent = true
  717. }
  718. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  719. func (m *AgentMutation) TokenAgentCleared() bool {
  720. return m.clearedtoken_agent
  721. }
  722. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  723. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  724. if m.removedtoken_agent == nil {
  725. m.removedtoken_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. delete(m.token_agent, ids[i])
  729. m.removedtoken_agent[ids[i]] = struct{}{}
  730. }
  731. }
  732. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  733. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  734. for id := range m.removedtoken_agent {
  735. ids = append(ids, id)
  736. }
  737. return
  738. }
  739. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  740. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  741. for id := range m.token_agent {
  742. ids = append(ids, id)
  743. }
  744. return
  745. }
  746. // ResetTokenAgent resets all changes to the "token_agent" edge.
  747. func (m *AgentMutation) ResetTokenAgent() {
  748. m.token_agent = nil
  749. m.clearedtoken_agent = false
  750. m.removedtoken_agent = nil
  751. }
  752. // Where appends a list predicates to the AgentMutation builder.
  753. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  754. m.predicates = append(m.predicates, ps...)
  755. }
  756. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  757. // users can use type-assertion to append predicates that do not depend on any generated package.
  758. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  759. p := make([]predicate.Agent, len(ps))
  760. for i := range ps {
  761. p[i] = ps[i]
  762. }
  763. m.Where(p...)
  764. }
  765. // Op returns the operation name.
  766. func (m *AgentMutation) Op() Op {
  767. return m.op
  768. }
  769. // SetOp allows setting the mutation operation.
  770. func (m *AgentMutation) SetOp(op Op) {
  771. m.op = op
  772. }
  773. // Type returns the node type of this mutation (Agent).
  774. func (m *AgentMutation) Type() string {
  775. return m.typ
  776. }
  777. // Fields returns all fields that were changed during this mutation. Note that in
  778. // order to get all numeric fields that were incremented/decremented, call
  779. // AddedFields().
  780. func (m *AgentMutation) Fields() []string {
  781. fields := make([]string, 0, 11)
  782. if m.created_at != nil {
  783. fields = append(fields, agent.FieldCreatedAt)
  784. }
  785. if m.updated_at != nil {
  786. fields = append(fields, agent.FieldUpdatedAt)
  787. }
  788. if m.deleted_at != nil {
  789. fields = append(fields, agent.FieldDeletedAt)
  790. }
  791. if m.name != nil {
  792. fields = append(fields, agent.FieldName)
  793. }
  794. if m.role != nil {
  795. fields = append(fields, agent.FieldRole)
  796. }
  797. if m.status != nil {
  798. fields = append(fields, agent.FieldStatus)
  799. }
  800. if m.background != nil {
  801. fields = append(fields, agent.FieldBackground)
  802. }
  803. if m.examples != nil {
  804. fields = append(fields, agent.FieldExamples)
  805. }
  806. if m.organization_id != nil {
  807. fields = append(fields, agent.FieldOrganizationID)
  808. }
  809. if m.dataset_id != nil {
  810. fields = append(fields, agent.FieldDatasetID)
  811. }
  812. if m.collection_id != nil {
  813. fields = append(fields, agent.FieldCollectionID)
  814. }
  815. return fields
  816. }
  817. // Field returns the value of a field with the given name. The second boolean
  818. // return value indicates that this field was not set, or was not defined in the
  819. // schema.
  820. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  821. switch name {
  822. case agent.FieldCreatedAt:
  823. return m.CreatedAt()
  824. case agent.FieldUpdatedAt:
  825. return m.UpdatedAt()
  826. case agent.FieldDeletedAt:
  827. return m.DeletedAt()
  828. case agent.FieldName:
  829. return m.Name()
  830. case agent.FieldRole:
  831. return m.Role()
  832. case agent.FieldStatus:
  833. return m.Status()
  834. case agent.FieldBackground:
  835. return m.Background()
  836. case agent.FieldExamples:
  837. return m.Examples()
  838. case agent.FieldOrganizationID:
  839. return m.OrganizationID()
  840. case agent.FieldDatasetID:
  841. return m.DatasetID()
  842. case agent.FieldCollectionID:
  843. return m.CollectionID()
  844. }
  845. return nil, false
  846. }
  847. // OldField returns the old value of the field from the database. An error is
  848. // returned if the mutation operation is not UpdateOne, or the query to the
  849. // database failed.
  850. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  851. switch name {
  852. case agent.FieldCreatedAt:
  853. return m.OldCreatedAt(ctx)
  854. case agent.FieldUpdatedAt:
  855. return m.OldUpdatedAt(ctx)
  856. case agent.FieldDeletedAt:
  857. return m.OldDeletedAt(ctx)
  858. case agent.FieldName:
  859. return m.OldName(ctx)
  860. case agent.FieldRole:
  861. return m.OldRole(ctx)
  862. case agent.FieldStatus:
  863. return m.OldStatus(ctx)
  864. case agent.FieldBackground:
  865. return m.OldBackground(ctx)
  866. case agent.FieldExamples:
  867. return m.OldExamples(ctx)
  868. case agent.FieldOrganizationID:
  869. return m.OldOrganizationID(ctx)
  870. case agent.FieldDatasetID:
  871. return m.OldDatasetID(ctx)
  872. case agent.FieldCollectionID:
  873. return m.OldCollectionID(ctx)
  874. }
  875. return nil, fmt.Errorf("unknown Agent field %s", name)
  876. }
  877. // SetField sets the value of a field with the given name. It returns an error if
  878. // the field is not defined in the schema, or if the type mismatched the field
  879. // type.
  880. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  881. switch name {
  882. case agent.FieldCreatedAt:
  883. v, ok := value.(time.Time)
  884. if !ok {
  885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  886. }
  887. m.SetCreatedAt(v)
  888. return nil
  889. case agent.FieldUpdatedAt:
  890. v, ok := value.(time.Time)
  891. if !ok {
  892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  893. }
  894. m.SetUpdatedAt(v)
  895. return nil
  896. case agent.FieldDeletedAt:
  897. v, ok := value.(time.Time)
  898. if !ok {
  899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  900. }
  901. m.SetDeletedAt(v)
  902. return nil
  903. case agent.FieldName:
  904. v, ok := value.(string)
  905. if !ok {
  906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  907. }
  908. m.SetName(v)
  909. return nil
  910. case agent.FieldRole:
  911. v, ok := value.(string)
  912. if !ok {
  913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  914. }
  915. m.SetRole(v)
  916. return nil
  917. case agent.FieldStatus:
  918. v, ok := value.(int)
  919. if !ok {
  920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  921. }
  922. m.SetStatus(v)
  923. return nil
  924. case agent.FieldBackground:
  925. v, ok := value.(string)
  926. if !ok {
  927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  928. }
  929. m.SetBackground(v)
  930. return nil
  931. case agent.FieldExamples:
  932. v, ok := value.(string)
  933. if !ok {
  934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  935. }
  936. m.SetExamples(v)
  937. return nil
  938. case agent.FieldOrganizationID:
  939. v, ok := value.(uint64)
  940. if !ok {
  941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  942. }
  943. m.SetOrganizationID(v)
  944. return nil
  945. case agent.FieldDatasetID:
  946. v, ok := value.(string)
  947. if !ok {
  948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  949. }
  950. m.SetDatasetID(v)
  951. return nil
  952. case agent.FieldCollectionID:
  953. v, ok := value.(string)
  954. if !ok {
  955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  956. }
  957. m.SetCollectionID(v)
  958. return nil
  959. }
  960. return fmt.Errorf("unknown Agent field %s", name)
  961. }
  962. // AddedFields returns all numeric fields that were incremented/decremented during
  963. // this mutation.
  964. func (m *AgentMutation) AddedFields() []string {
  965. var fields []string
  966. if m.addstatus != nil {
  967. fields = append(fields, agent.FieldStatus)
  968. }
  969. if m.addorganization_id != nil {
  970. fields = append(fields, agent.FieldOrganizationID)
  971. }
  972. return fields
  973. }
  974. // AddedField returns the numeric value that was incremented/decremented on a field
  975. // with the given name. The second boolean return value indicates that this field
  976. // was not set, or was not defined in the schema.
  977. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  978. switch name {
  979. case agent.FieldStatus:
  980. return m.AddedStatus()
  981. case agent.FieldOrganizationID:
  982. return m.AddedOrganizationID()
  983. }
  984. return nil, false
  985. }
  986. // AddField adds the value to the field with the given name. It returns an error if
  987. // the field is not defined in the schema, or if the type mismatched the field
  988. // type.
  989. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  990. switch name {
  991. case agent.FieldStatus:
  992. v, ok := value.(int)
  993. if !ok {
  994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  995. }
  996. m.AddStatus(v)
  997. return nil
  998. case agent.FieldOrganizationID:
  999. v, ok := value.(int64)
  1000. if !ok {
  1001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1002. }
  1003. m.AddOrganizationID(v)
  1004. return nil
  1005. }
  1006. return fmt.Errorf("unknown Agent numeric field %s", name)
  1007. }
  1008. // ClearedFields returns all nullable fields that were cleared during this
  1009. // mutation.
  1010. func (m *AgentMutation) ClearedFields() []string {
  1011. var fields []string
  1012. if m.FieldCleared(agent.FieldDeletedAt) {
  1013. fields = append(fields, agent.FieldDeletedAt)
  1014. }
  1015. if m.FieldCleared(agent.FieldStatus) {
  1016. fields = append(fields, agent.FieldStatus)
  1017. }
  1018. if m.FieldCleared(agent.FieldBackground) {
  1019. fields = append(fields, agent.FieldBackground)
  1020. }
  1021. if m.FieldCleared(agent.FieldExamples) {
  1022. fields = append(fields, agent.FieldExamples)
  1023. }
  1024. return fields
  1025. }
  1026. // FieldCleared returns a boolean indicating if a field with the given name was
  1027. // cleared in this mutation.
  1028. func (m *AgentMutation) FieldCleared(name string) bool {
  1029. _, ok := m.clearedFields[name]
  1030. return ok
  1031. }
  1032. // ClearField clears the value of the field with the given name. It returns an
  1033. // error if the field is not defined in the schema.
  1034. func (m *AgentMutation) ClearField(name string) error {
  1035. switch name {
  1036. case agent.FieldDeletedAt:
  1037. m.ClearDeletedAt()
  1038. return nil
  1039. case agent.FieldStatus:
  1040. m.ClearStatus()
  1041. return nil
  1042. case agent.FieldBackground:
  1043. m.ClearBackground()
  1044. return nil
  1045. case agent.FieldExamples:
  1046. m.ClearExamples()
  1047. return nil
  1048. }
  1049. return fmt.Errorf("unknown Agent nullable field %s", name)
  1050. }
  1051. // ResetField resets all changes in the mutation for the field with the given name.
  1052. // It returns an error if the field is not defined in the schema.
  1053. func (m *AgentMutation) ResetField(name string) error {
  1054. switch name {
  1055. case agent.FieldCreatedAt:
  1056. m.ResetCreatedAt()
  1057. return nil
  1058. case agent.FieldUpdatedAt:
  1059. m.ResetUpdatedAt()
  1060. return nil
  1061. case agent.FieldDeletedAt:
  1062. m.ResetDeletedAt()
  1063. return nil
  1064. case agent.FieldName:
  1065. m.ResetName()
  1066. return nil
  1067. case agent.FieldRole:
  1068. m.ResetRole()
  1069. return nil
  1070. case agent.FieldStatus:
  1071. m.ResetStatus()
  1072. return nil
  1073. case agent.FieldBackground:
  1074. m.ResetBackground()
  1075. return nil
  1076. case agent.FieldExamples:
  1077. m.ResetExamples()
  1078. return nil
  1079. case agent.FieldOrganizationID:
  1080. m.ResetOrganizationID()
  1081. return nil
  1082. case agent.FieldDatasetID:
  1083. m.ResetDatasetID()
  1084. return nil
  1085. case agent.FieldCollectionID:
  1086. m.ResetCollectionID()
  1087. return nil
  1088. }
  1089. return fmt.Errorf("unknown Agent field %s", name)
  1090. }
  1091. // AddedEdges returns all edge names that were set/added in this mutation.
  1092. func (m *AgentMutation) AddedEdges() []string {
  1093. edges := make([]string, 0, 2)
  1094. if m.wx_agent != nil {
  1095. edges = append(edges, agent.EdgeWxAgent)
  1096. }
  1097. if m.token_agent != nil {
  1098. edges = append(edges, agent.EdgeTokenAgent)
  1099. }
  1100. return edges
  1101. }
  1102. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1103. // name in this mutation.
  1104. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1105. switch name {
  1106. case agent.EdgeWxAgent:
  1107. ids := make([]ent.Value, 0, len(m.wx_agent))
  1108. for id := range m.wx_agent {
  1109. ids = append(ids, id)
  1110. }
  1111. return ids
  1112. case agent.EdgeTokenAgent:
  1113. ids := make([]ent.Value, 0, len(m.token_agent))
  1114. for id := range m.token_agent {
  1115. ids = append(ids, id)
  1116. }
  1117. return ids
  1118. }
  1119. return nil
  1120. }
  1121. // RemovedEdges returns all edge names that were removed in this mutation.
  1122. func (m *AgentMutation) RemovedEdges() []string {
  1123. edges := make([]string, 0, 2)
  1124. if m.removedwx_agent != nil {
  1125. edges = append(edges, agent.EdgeWxAgent)
  1126. }
  1127. if m.removedtoken_agent != nil {
  1128. edges = append(edges, agent.EdgeTokenAgent)
  1129. }
  1130. return edges
  1131. }
  1132. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1133. // the given name in this mutation.
  1134. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1135. switch name {
  1136. case agent.EdgeWxAgent:
  1137. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1138. for id := range m.removedwx_agent {
  1139. ids = append(ids, id)
  1140. }
  1141. return ids
  1142. case agent.EdgeTokenAgent:
  1143. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1144. for id := range m.removedtoken_agent {
  1145. ids = append(ids, id)
  1146. }
  1147. return ids
  1148. }
  1149. return nil
  1150. }
  1151. // ClearedEdges returns all edge names that were cleared in this mutation.
  1152. func (m *AgentMutation) ClearedEdges() []string {
  1153. edges := make([]string, 0, 2)
  1154. if m.clearedwx_agent {
  1155. edges = append(edges, agent.EdgeWxAgent)
  1156. }
  1157. if m.clearedtoken_agent {
  1158. edges = append(edges, agent.EdgeTokenAgent)
  1159. }
  1160. return edges
  1161. }
  1162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1163. // was cleared in this mutation.
  1164. func (m *AgentMutation) EdgeCleared(name string) bool {
  1165. switch name {
  1166. case agent.EdgeWxAgent:
  1167. return m.clearedwx_agent
  1168. case agent.EdgeTokenAgent:
  1169. return m.clearedtoken_agent
  1170. }
  1171. return false
  1172. }
  1173. // ClearEdge clears the value of the edge with the given name. It returns an error
  1174. // if that edge is not defined in the schema.
  1175. func (m *AgentMutation) ClearEdge(name string) error {
  1176. switch name {
  1177. }
  1178. return fmt.Errorf("unknown Agent unique edge %s", name)
  1179. }
  1180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1181. // It returns an error if the edge is not defined in the schema.
  1182. func (m *AgentMutation) ResetEdge(name string) error {
  1183. switch name {
  1184. case agent.EdgeWxAgent:
  1185. m.ResetWxAgent()
  1186. return nil
  1187. case agent.EdgeTokenAgent:
  1188. m.ResetTokenAgent()
  1189. return nil
  1190. }
  1191. return fmt.Errorf("unknown Agent edge %s", name)
  1192. }
  1193. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1194. type AgentBaseMutation struct {
  1195. config
  1196. op Op
  1197. typ string
  1198. id *string
  1199. q *string
  1200. a *string
  1201. chunk_index *uint64
  1202. addchunk_index *int64
  1203. indexes *[]string
  1204. appendindexes []string
  1205. dataset_id *string
  1206. collection_id *string
  1207. source_name *string
  1208. can_write *[]bool
  1209. appendcan_write []bool
  1210. is_owner *[]bool
  1211. appendis_owner []bool
  1212. clearedFields map[string]struct{}
  1213. wx_agent map[uint64]struct{}
  1214. removedwx_agent map[uint64]struct{}
  1215. clearedwx_agent bool
  1216. done bool
  1217. oldValue func(context.Context) (*AgentBase, error)
  1218. predicates []predicate.AgentBase
  1219. }
  1220. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1221. // agentbaseOption allows management of the mutation configuration using functional options.
  1222. type agentbaseOption func(*AgentBaseMutation)
  1223. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1224. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1225. m := &AgentBaseMutation{
  1226. config: c,
  1227. op: op,
  1228. typ: TypeAgentBase,
  1229. clearedFields: make(map[string]struct{}),
  1230. }
  1231. for _, opt := range opts {
  1232. opt(m)
  1233. }
  1234. return m
  1235. }
  1236. // withAgentBaseID sets the ID field of the mutation.
  1237. func withAgentBaseID(id string) agentbaseOption {
  1238. return func(m *AgentBaseMutation) {
  1239. var (
  1240. err error
  1241. once sync.Once
  1242. value *AgentBase
  1243. )
  1244. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1245. once.Do(func() {
  1246. if m.done {
  1247. err = errors.New("querying old values post mutation is not allowed")
  1248. } else {
  1249. value, err = m.Client().AgentBase.Get(ctx, id)
  1250. }
  1251. })
  1252. return value, err
  1253. }
  1254. m.id = &id
  1255. }
  1256. }
  1257. // withAgentBase sets the old AgentBase of the mutation.
  1258. func withAgentBase(node *AgentBase) agentbaseOption {
  1259. return func(m *AgentBaseMutation) {
  1260. m.oldValue = func(context.Context) (*AgentBase, error) {
  1261. return node, nil
  1262. }
  1263. m.id = &node.ID
  1264. }
  1265. }
  1266. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1267. // executed in a transaction (ent.Tx), a transactional client is returned.
  1268. func (m AgentBaseMutation) Client() *Client {
  1269. client := &Client{config: m.config}
  1270. client.init()
  1271. return client
  1272. }
  1273. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1274. // it returns an error otherwise.
  1275. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1276. if _, ok := m.driver.(*txDriver); !ok {
  1277. return nil, errors.New("ent: mutation is not running in a transaction")
  1278. }
  1279. tx := &Tx{config: m.config}
  1280. tx.init()
  1281. return tx, nil
  1282. }
  1283. // SetID sets the value of the id field. Note that this
  1284. // operation is only accepted on creation of AgentBase entities.
  1285. func (m *AgentBaseMutation) SetID(id string) {
  1286. m.id = &id
  1287. }
  1288. // ID returns the ID value in the mutation. Note that the ID is only available
  1289. // if it was provided to the builder or after it was returned from the database.
  1290. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1291. if m.id == nil {
  1292. return
  1293. }
  1294. return *m.id, true
  1295. }
  1296. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1297. // That means, if the mutation is applied within a transaction with an isolation level such
  1298. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1299. // or updated by the mutation.
  1300. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1301. switch {
  1302. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1303. id, exists := m.ID()
  1304. if exists {
  1305. return []string{id}, nil
  1306. }
  1307. fallthrough
  1308. case m.op.Is(OpUpdate | OpDelete):
  1309. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1310. default:
  1311. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1312. }
  1313. }
  1314. // SetQ sets the "q" field.
  1315. func (m *AgentBaseMutation) SetQ(s string) {
  1316. m.q = &s
  1317. }
  1318. // Q returns the value of the "q" field in the mutation.
  1319. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1320. v := m.q
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldQ returns the old "q" field's value of the AgentBase entity.
  1327. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1329. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldQ requires an ID field in the mutation")
  1335. }
  1336. oldValue, err := m.oldValue(ctx)
  1337. if err != nil {
  1338. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1339. }
  1340. return oldValue.Q, nil
  1341. }
  1342. // ClearQ clears the value of the "q" field.
  1343. func (m *AgentBaseMutation) ClearQ() {
  1344. m.q = nil
  1345. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1346. }
  1347. // QCleared returns if the "q" field was cleared in this mutation.
  1348. func (m *AgentBaseMutation) QCleared() bool {
  1349. _, ok := m.clearedFields[agentbase.FieldQ]
  1350. return ok
  1351. }
  1352. // ResetQ resets all changes to the "q" field.
  1353. func (m *AgentBaseMutation) ResetQ() {
  1354. m.q = nil
  1355. delete(m.clearedFields, agentbase.FieldQ)
  1356. }
  1357. // SetA sets the "a" field.
  1358. func (m *AgentBaseMutation) SetA(s string) {
  1359. m.a = &s
  1360. }
  1361. // A returns the value of the "a" field in the mutation.
  1362. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1363. v := m.a
  1364. if v == nil {
  1365. return
  1366. }
  1367. return *v, true
  1368. }
  1369. // OldA returns the old "a" field's value of the AgentBase entity.
  1370. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1372. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1373. if !m.op.Is(OpUpdateOne) {
  1374. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1375. }
  1376. if m.id == nil || m.oldValue == nil {
  1377. return v, errors.New("OldA requires an ID field in the mutation")
  1378. }
  1379. oldValue, err := m.oldValue(ctx)
  1380. if err != nil {
  1381. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1382. }
  1383. return oldValue.A, nil
  1384. }
  1385. // ClearA clears the value of the "a" field.
  1386. func (m *AgentBaseMutation) ClearA() {
  1387. m.a = nil
  1388. m.clearedFields[agentbase.FieldA] = struct{}{}
  1389. }
  1390. // ACleared returns if the "a" field was cleared in this mutation.
  1391. func (m *AgentBaseMutation) ACleared() bool {
  1392. _, ok := m.clearedFields[agentbase.FieldA]
  1393. return ok
  1394. }
  1395. // ResetA resets all changes to the "a" field.
  1396. func (m *AgentBaseMutation) ResetA() {
  1397. m.a = nil
  1398. delete(m.clearedFields, agentbase.FieldA)
  1399. }
  1400. // SetChunkIndex sets the "chunk_index" field.
  1401. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1402. m.chunk_index = &u
  1403. m.addchunk_index = nil
  1404. }
  1405. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1406. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1407. v := m.chunk_index
  1408. if v == nil {
  1409. return
  1410. }
  1411. return *v, true
  1412. }
  1413. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1414. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1416. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1417. if !m.op.Is(OpUpdateOne) {
  1418. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1419. }
  1420. if m.id == nil || m.oldValue == nil {
  1421. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1422. }
  1423. oldValue, err := m.oldValue(ctx)
  1424. if err != nil {
  1425. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1426. }
  1427. return oldValue.ChunkIndex, nil
  1428. }
  1429. // AddChunkIndex adds u to the "chunk_index" field.
  1430. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1431. if m.addchunk_index != nil {
  1432. *m.addchunk_index += u
  1433. } else {
  1434. m.addchunk_index = &u
  1435. }
  1436. }
  1437. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1438. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1439. v := m.addchunk_index
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1446. func (m *AgentBaseMutation) ResetChunkIndex() {
  1447. m.chunk_index = nil
  1448. m.addchunk_index = nil
  1449. }
  1450. // SetIndexes sets the "indexes" field.
  1451. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1452. m.indexes = &s
  1453. m.appendindexes = nil
  1454. }
  1455. // Indexes returns the value of the "indexes" field in the mutation.
  1456. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1457. v := m.indexes
  1458. if v == nil {
  1459. return
  1460. }
  1461. return *v, true
  1462. }
  1463. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1464. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1466. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1467. if !m.op.Is(OpUpdateOne) {
  1468. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1469. }
  1470. if m.id == nil || m.oldValue == nil {
  1471. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1472. }
  1473. oldValue, err := m.oldValue(ctx)
  1474. if err != nil {
  1475. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1476. }
  1477. return oldValue.Indexes, nil
  1478. }
  1479. // AppendIndexes adds s to the "indexes" field.
  1480. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1481. m.appendindexes = append(m.appendindexes, s...)
  1482. }
  1483. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1484. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1485. if len(m.appendindexes) == 0 {
  1486. return nil, false
  1487. }
  1488. return m.appendindexes, true
  1489. }
  1490. // ClearIndexes clears the value of the "indexes" field.
  1491. func (m *AgentBaseMutation) ClearIndexes() {
  1492. m.indexes = nil
  1493. m.appendindexes = nil
  1494. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1495. }
  1496. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1497. func (m *AgentBaseMutation) IndexesCleared() bool {
  1498. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1499. return ok
  1500. }
  1501. // ResetIndexes resets all changes to the "indexes" field.
  1502. func (m *AgentBaseMutation) ResetIndexes() {
  1503. m.indexes = nil
  1504. m.appendindexes = nil
  1505. delete(m.clearedFields, agentbase.FieldIndexes)
  1506. }
  1507. // SetDatasetID sets the "dataset_id" field.
  1508. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1509. m.dataset_id = &s
  1510. }
  1511. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1512. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1513. v := m.dataset_id
  1514. if v == nil {
  1515. return
  1516. }
  1517. return *v, true
  1518. }
  1519. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1520. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1522. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1523. if !m.op.Is(OpUpdateOne) {
  1524. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1525. }
  1526. if m.id == nil || m.oldValue == nil {
  1527. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1528. }
  1529. oldValue, err := m.oldValue(ctx)
  1530. if err != nil {
  1531. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1532. }
  1533. return oldValue.DatasetID, nil
  1534. }
  1535. // ClearDatasetID clears the value of the "dataset_id" field.
  1536. func (m *AgentBaseMutation) ClearDatasetID() {
  1537. m.dataset_id = nil
  1538. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1539. }
  1540. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1541. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1542. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1543. return ok
  1544. }
  1545. // ResetDatasetID resets all changes to the "dataset_id" field.
  1546. func (m *AgentBaseMutation) ResetDatasetID() {
  1547. m.dataset_id = nil
  1548. delete(m.clearedFields, agentbase.FieldDatasetID)
  1549. }
  1550. // SetCollectionID sets the "collection_id" field.
  1551. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1552. m.collection_id = &s
  1553. }
  1554. // CollectionID returns the value of the "collection_id" field in the mutation.
  1555. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1556. v := m.collection_id
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1575. }
  1576. return oldValue.CollectionID, nil
  1577. }
  1578. // ClearCollectionID clears the value of the "collection_id" field.
  1579. func (m *AgentBaseMutation) ClearCollectionID() {
  1580. m.collection_id = nil
  1581. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1582. }
  1583. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1586. return ok
  1587. }
  1588. // ResetCollectionID resets all changes to the "collection_id" field.
  1589. func (m *AgentBaseMutation) ResetCollectionID() {
  1590. m.collection_id = nil
  1591. delete(m.clearedFields, agentbase.FieldCollectionID)
  1592. }
  1593. // SetSourceName sets the "source_name" field.
  1594. func (m *AgentBaseMutation) SetSourceName(s string) {
  1595. m.source_name = &s
  1596. }
  1597. // SourceName returns the value of the "source_name" field in the mutation.
  1598. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1599. v := m.source_name
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1618. }
  1619. return oldValue.SourceName, nil
  1620. }
  1621. // ClearSourceName clears the value of the "source_name" field.
  1622. func (m *AgentBaseMutation) ClearSourceName() {
  1623. m.source_name = nil
  1624. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1625. }
  1626. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1629. return ok
  1630. }
  1631. // ResetSourceName resets all changes to the "source_name" field.
  1632. func (m *AgentBaseMutation) ResetSourceName() {
  1633. m.source_name = nil
  1634. delete(m.clearedFields, agentbase.FieldSourceName)
  1635. }
  1636. // SetCanWrite sets the "can_write" field.
  1637. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1638. m.can_write = &b
  1639. m.appendcan_write = nil
  1640. }
  1641. // CanWrite returns the value of the "can_write" field in the mutation.
  1642. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1643. v := m.can_write
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1662. }
  1663. return oldValue.CanWrite, nil
  1664. }
  1665. // AppendCanWrite adds b to the "can_write" field.
  1666. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1667. m.appendcan_write = append(m.appendcan_write, b...)
  1668. }
  1669. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1670. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1671. if len(m.appendcan_write) == 0 {
  1672. return nil, false
  1673. }
  1674. return m.appendcan_write, true
  1675. }
  1676. // ClearCanWrite clears the value of the "can_write" field.
  1677. func (m *AgentBaseMutation) ClearCanWrite() {
  1678. m.can_write = nil
  1679. m.appendcan_write = nil
  1680. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1681. }
  1682. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1683. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1684. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1685. return ok
  1686. }
  1687. // ResetCanWrite resets all changes to the "can_write" field.
  1688. func (m *AgentBaseMutation) ResetCanWrite() {
  1689. m.can_write = nil
  1690. m.appendcan_write = nil
  1691. delete(m.clearedFields, agentbase.FieldCanWrite)
  1692. }
  1693. // SetIsOwner sets the "is_owner" field.
  1694. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1695. m.is_owner = &b
  1696. m.appendis_owner = nil
  1697. }
  1698. // IsOwner returns the value of the "is_owner" field in the mutation.
  1699. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1700. v := m.is_owner
  1701. if v == nil {
  1702. return
  1703. }
  1704. return *v, true
  1705. }
  1706. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1707. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1709. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1710. if !m.op.Is(OpUpdateOne) {
  1711. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1712. }
  1713. if m.id == nil || m.oldValue == nil {
  1714. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1715. }
  1716. oldValue, err := m.oldValue(ctx)
  1717. if err != nil {
  1718. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1719. }
  1720. return oldValue.IsOwner, nil
  1721. }
  1722. // AppendIsOwner adds b to the "is_owner" field.
  1723. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1724. m.appendis_owner = append(m.appendis_owner, b...)
  1725. }
  1726. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1727. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1728. if len(m.appendis_owner) == 0 {
  1729. return nil, false
  1730. }
  1731. return m.appendis_owner, true
  1732. }
  1733. // ClearIsOwner clears the value of the "is_owner" field.
  1734. func (m *AgentBaseMutation) ClearIsOwner() {
  1735. m.is_owner = nil
  1736. m.appendis_owner = nil
  1737. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1738. }
  1739. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1740. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1741. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1742. return ok
  1743. }
  1744. // ResetIsOwner resets all changes to the "is_owner" field.
  1745. func (m *AgentBaseMutation) ResetIsOwner() {
  1746. m.is_owner = nil
  1747. m.appendis_owner = nil
  1748. delete(m.clearedFields, agentbase.FieldIsOwner)
  1749. }
  1750. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1751. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1752. if m.wx_agent == nil {
  1753. m.wx_agent = make(map[uint64]struct{})
  1754. }
  1755. for i := range ids {
  1756. m.wx_agent[ids[i]] = struct{}{}
  1757. }
  1758. }
  1759. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1760. func (m *AgentBaseMutation) ClearWxAgent() {
  1761. m.clearedwx_agent = true
  1762. }
  1763. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1764. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1765. return m.clearedwx_agent
  1766. }
  1767. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1768. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1769. if m.removedwx_agent == nil {
  1770. m.removedwx_agent = make(map[uint64]struct{})
  1771. }
  1772. for i := range ids {
  1773. delete(m.wx_agent, ids[i])
  1774. m.removedwx_agent[ids[i]] = struct{}{}
  1775. }
  1776. }
  1777. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1778. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1779. for id := range m.removedwx_agent {
  1780. ids = append(ids, id)
  1781. }
  1782. return
  1783. }
  1784. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1785. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1786. for id := range m.wx_agent {
  1787. ids = append(ids, id)
  1788. }
  1789. return
  1790. }
  1791. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1792. func (m *AgentBaseMutation) ResetWxAgent() {
  1793. m.wx_agent = nil
  1794. m.clearedwx_agent = false
  1795. m.removedwx_agent = nil
  1796. }
  1797. // Where appends a list predicates to the AgentBaseMutation builder.
  1798. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1799. m.predicates = append(m.predicates, ps...)
  1800. }
  1801. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1802. // users can use type-assertion to append predicates that do not depend on any generated package.
  1803. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1804. p := make([]predicate.AgentBase, len(ps))
  1805. for i := range ps {
  1806. p[i] = ps[i]
  1807. }
  1808. m.Where(p...)
  1809. }
  1810. // Op returns the operation name.
  1811. func (m *AgentBaseMutation) Op() Op {
  1812. return m.op
  1813. }
  1814. // SetOp allows setting the mutation operation.
  1815. func (m *AgentBaseMutation) SetOp(op Op) {
  1816. m.op = op
  1817. }
  1818. // Type returns the node type of this mutation (AgentBase).
  1819. func (m *AgentBaseMutation) Type() string {
  1820. return m.typ
  1821. }
  1822. // Fields returns all fields that were changed during this mutation. Note that in
  1823. // order to get all numeric fields that were incremented/decremented, call
  1824. // AddedFields().
  1825. func (m *AgentBaseMutation) Fields() []string {
  1826. fields := make([]string, 0, 9)
  1827. if m.q != nil {
  1828. fields = append(fields, agentbase.FieldQ)
  1829. }
  1830. if m.a != nil {
  1831. fields = append(fields, agentbase.FieldA)
  1832. }
  1833. if m.chunk_index != nil {
  1834. fields = append(fields, agentbase.FieldChunkIndex)
  1835. }
  1836. if m.indexes != nil {
  1837. fields = append(fields, agentbase.FieldIndexes)
  1838. }
  1839. if m.dataset_id != nil {
  1840. fields = append(fields, agentbase.FieldDatasetID)
  1841. }
  1842. if m.collection_id != nil {
  1843. fields = append(fields, agentbase.FieldCollectionID)
  1844. }
  1845. if m.source_name != nil {
  1846. fields = append(fields, agentbase.FieldSourceName)
  1847. }
  1848. if m.can_write != nil {
  1849. fields = append(fields, agentbase.FieldCanWrite)
  1850. }
  1851. if m.is_owner != nil {
  1852. fields = append(fields, agentbase.FieldIsOwner)
  1853. }
  1854. return fields
  1855. }
  1856. // Field returns the value of a field with the given name. The second boolean
  1857. // return value indicates that this field was not set, or was not defined in the
  1858. // schema.
  1859. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1860. switch name {
  1861. case agentbase.FieldQ:
  1862. return m.Q()
  1863. case agentbase.FieldA:
  1864. return m.A()
  1865. case agentbase.FieldChunkIndex:
  1866. return m.ChunkIndex()
  1867. case agentbase.FieldIndexes:
  1868. return m.Indexes()
  1869. case agentbase.FieldDatasetID:
  1870. return m.DatasetID()
  1871. case agentbase.FieldCollectionID:
  1872. return m.CollectionID()
  1873. case agentbase.FieldSourceName:
  1874. return m.SourceName()
  1875. case agentbase.FieldCanWrite:
  1876. return m.CanWrite()
  1877. case agentbase.FieldIsOwner:
  1878. return m.IsOwner()
  1879. }
  1880. return nil, false
  1881. }
  1882. // OldField returns the old value of the field from the database. An error is
  1883. // returned if the mutation operation is not UpdateOne, or the query to the
  1884. // database failed.
  1885. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1886. switch name {
  1887. case agentbase.FieldQ:
  1888. return m.OldQ(ctx)
  1889. case agentbase.FieldA:
  1890. return m.OldA(ctx)
  1891. case agentbase.FieldChunkIndex:
  1892. return m.OldChunkIndex(ctx)
  1893. case agentbase.FieldIndexes:
  1894. return m.OldIndexes(ctx)
  1895. case agentbase.FieldDatasetID:
  1896. return m.OldDatasetID(ctx)
  1897. case agentbase.FieldCollectionID:
  1898. return m.OldCollectionID(ctx)
  1899. case agentbase.FieldSourceName:
  1900. return m.OldSourceName(ctx)
  1901. case agentbase.FieldCanWrite:
  1902. return m.OldCanWrite(ctx)
  1903. case agentbase.FieldIsOwner:
  1904. return m.OldIsOwner(ctx)
  1905. }
  1906. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1907. }
  1908. // SetField sets the value of a field with the given name. It returns an error if
  1909. // the field is not defined in the schema, or if the type mismatched the field
  1910. // type.
  1911. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1912. switch name {
  1913. case agentbase.FieldQ:
  1914. v, ok := value.(string)
  1915. if !ok {
  1916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1917. }
  1918. m.SetQ(v)
  1919. return nil
  1920. case agentbase.FieldA:
  1921. v, ok := value.(string)
  1922. if !ok {
  1923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1924. }
  1925. m.SetA(v)
  1926. return nil
  1927. case agentbase.FieldChunkIndex:
  1928. v, ok := value.(uint64)
  1929. if !ok {
  1930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1931. }
  1932. m.SetChunkIndex(v)
  1933. return nil
  1934. case agentbase.FieldIndexes:
  1935. v, ok := value.([]string)
  1936. if !ok {
  1937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1938. }
  1939. m.SetIndexes(v)
  1940. return nil
  1941. case agentbase.FieldDatasetID:
  1942. v, ok := value.(string)
  1943. if !ok {
  1944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1945. }
  1946. m.SetDatasetID(v)
  1947. return nil
  1948. case agentbase.FieldCollectionID:
  1949. v, ok := value.(string)
  1950. if !ok {
  1951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1952. }
  1953. m.SetCollectionID(v)
  1954. return nil
  1955. case agentbase.FieldSourceName:
  1956. v, ok := value.(string)
  1957. if !ok {
  1958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1959. }
  1960. m.SetSourceName(v)
  1961. return nil
  1962. case agentbase.FieldCanWrite:
  1963. v, ok := value.([]bool)
  1964. if !ok {
  1965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1966. }
  1967. m.SetCanWrite(v)
  1968. return nil
  1969. case agentbase.FieldIsOwner:
  1970. v, ok := value.([]bool)
  1971. if !ok {
  1972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1973. }
  1974. m.SetIsOwner(v)
  1975. return nil
  1976. }
  1977. return fmt.Errorf("unknown AgentBase field %s", name)
  1978. }
  1979. // AddedFields returns all numeric fields that were incremented/decremented during
  1980. // this mutation.
  1981. func (m *AgentBaseMutation) AddedFields() []string {
  1982. var fields []string
  1983. if m.addchunk_index != nil {
  1984. fields = append(fields, agentbase.FieldChunkIndex)
  1985. }
  1986. return fields
  1987. }
  1988. // AddedField returns the numeric value that was incremented/decremented on a field
  1989. // with the given name. The second boolean return value indicates that this field
  1990. // was not set, or was not defined in the schema.
  1991. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1992. switch name {
  1993. case agentbase.FieldChunkIndex:
  1994. return m.AddedChunkIndex()
  1995. }
  1996. return nil, false
  1997. }
  1998. // AddField adds the value to the field with the given name. It returns an error if
  1999. // the field is not defined in the schema, or if the type mismatched the field
  2000. // type.
  2001. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2002. switch name {
  2003. case agentbase.FieldChunkIndex:
  2004. v, ok := value.(int64)
  2005. if !ok {
  2006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2007. }
  2008. m.AddChunkIndex(v)
  2009. return nil
  2010. }
  2011. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2012. }
  2013. // ClearedFields returns all nullable fields that were cleared during this
  2014. // mutation.
  2015. func (m *AgentBaseMutation) ClearedFields() []string {
  2016. var fields []string
  2017. if m.FieldCleared(agentbase.FieldQ) {
  2018. fields = append(fields, agentbase.FieldQ)
  2019. }
  2020. if m.FieldCleared(agentbase.FieldA) {
  2021. fields = append(fields, agentbase.FieldA)
  2022. }
  2023. if m.FieldCleared(agentbase.FieldIndexes) {
  2024. fields = append(fields, agentbase.FieldIndexes)
  2025. }
  2026. if m.FieldCleared(agentbase.FieldDatasetID) {
  2027. fields = append(fields, agentbase.FieldDatasetID)
  2028. }
  2029. if m.FieldCleared(agentbase.FieldCollectionID) {
  2030. fields = append(fields, agentbase.FieldCollectionID)
  2031. }
  2032. if m.FieldCleared(agentbase.FieldSourceName) {
  2033. fields = append(fields, agentbase.FieldSourceName)
  2034. }
  2035. if m.FieldCleared(agentbase.FieldCanWrite) {
  2036. fields = append(fields, agentbase.FieldCanWrite)
  2037. }
  2038. if m.FieldCleared(agentbase.FieldIsOwner) {
  2039. fields = append(fields, agentbase.FieldIsOwner)
  2040. }
  2041. return fields
  2042. }
  2043. // FieldCleared returns a boolean indicating if a field with the given name was
  2044. // cleared in this mutation.
  2045. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2046. _, ok := m.clearedFields[name]
  2047. return ok
  2048. }
  2049. // ClearField clears the value of the field with the given name. It returns an
  2050. // error if the field is not defined in the schema.
  2051. func (m *AgentBaseMutation) ClearField(name string) error {
  2052. switch name {
  2053. case agentbase.FieldQ:
  2054. m.ClearQ()
  2055. return nil
  2056. case agentbase.FieldA:
  2057. m.ClearA()
  2058. return nil
  2059. case agentbase.FieldIndexes:
  2060. m.ClearIndexes()
  2061. return nil
  2062. case agentbase.FieldDatasetID:
  2063. m.ClearDatasetID()
  2064. return nil
  2065. case agentbase.FieldCollectionID:
  2066. m.ClearCollectionID()
  2067. return nil
  2068. case agentbase.FieldSourceName:
  2069. m.ClearSourceName()
  2070. return nil
  2071. case agentbase.FieldCanWrite:
  2072. m.ClearCanWrite()
  2073. return nil
  2074. case agentbase.FieldIsOwner:
  2075. m.ClearIsOwner()
  2076. return nil
  2077. }
  2078. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2079. }
  2080. // ResetField resets all changes in the mutation for the field with the given name.
  2081. // It returns an error if the field is not defined in the schema.
  2082. func (m *AgentBaseMutation) ResetField(name string) error {
  2083. switch name {
  2084. case agentbase.FieldQ:
  2085. m.ResetQ()
  2086. return nil
  2087. case agentbase.FieldA:
  2088. m.ResetA()
  2089. return nil
  2090. case agentbase.FieldChunkIndex:
  2091. m.ResetChunkIndex()
  2092. return nil
  2093. case agentbase.FieldIndexes:
  2094. m.ResetIndexes()
  2095. return nil
  2096. case agentbase.FieldDatasetID:
  2097. m.ResetDatasetID()
  2098. return nil
  2099. case agentbase.FieldCollectionID:
  2100. m.ResetCollectionID()
  2101. return nil
  2102. case agentbase.FieldSourceName:
  2103. m.ResetSourceName()
  2104. return nil
  2105. case agentbase.FieldCanWrite:
  2106. m.ResetCanWrite()
  2107. return nil
  2108. case agentbase.FieldIsOwner:
  2109. m.ResetIsOwner()
  2110. return nil
  2111. }
  2112. return fmt.Errorf("unknown AgentBase field %s", name)
  2113. }
  2114. // AddedEdges returns all edge names that were set/added in this mutation.
  2115. func (m *AgentBaseMutation) AddedEdges() []string {
  2116. edges := make([]string, 0, 1)
  2117. if m.wx_agent != nil {
  2118. edges = append(edges, agentbase.EdgeWxAgent)
  2119. }
  2120. return edges
  2121. }
  2122. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2123. // name in this mutation.
  2124. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2125. switch name {
  2126. case agentbase.EdgeWxAgent:
  2127. ids := make([]ent.Value, 0, len(m.wx_agent))
  2128. for id := range m.wx_agent {
  2129. ids = append(ids, id)
  2130. }
  2131. return ids
  2132. }
  2133. return nil
  2134. }
  2135. // RemovedEdges returns all edge names that were removed in this mutation.
  2136. func (m *AgentBaseMutation) RemovedEdges() []string {
  2137. edges := make([]string, 0, 1)
  2138. if m.removedwx_agent != nil {
  2139. edges = append(edges, agentbase.EdgeWxAgent)
  2140. }
  2141. return edges
  2142. }
  2143. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2144. // the given name in this mutation.
  2145. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2146. switch name {
  2147. case agentbase.EdgeWxAgent:
  2148. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2149. for id := range m.removedwx_agent {
  2150. ids = append(ids, id)
  2151. }
  2152. return ids
  2153. }
  2154. return nil
  2155. }
  2156. // ClearedEdges returns all edge names that were cleared in this mutation.
  2157. func (m *AgentBaseMutation) ClearedEdges() []string {
  2158. edges := make([]string, 0, 1)
  2159. if m.clearedwx_agent {
  2160. edges = append(edges, agentbase.EdgeWxAgent)
  2161. }
  2162. return edges
  2163. }
  2164. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2165. // was cleared in this mutation.
  2166. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2167. switch name {
  2168. case agentbase.EdgeWxAgent:
  2169. return m.clearedwx_agent
  2170. }
  2171. return false
  2172. }
  2173. // ClearEdge clears the value of the edge with the given name. It returns an error
  2174. // if that edge is not defined in the schema.
  2175. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2176. switch name {
  2177. }
  2178. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2179. }
  2180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2181. // It returns an error if the edge is not defined in the schema.
  2182. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2183. switch name {
  2184. case agentbase.EdgeWxAgent:
  2185. m.ResetWxAgent()
  2186. return nil
  2187. }
  2188. return fmt.Errorf("unknown AgentBase edge %s", name)
  2189. }
  2190. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2191. type AliyunAvatarMutation struct {
  2192. config
  2193. op Op
  2194. typ string
  2195. id *uint64
  2196. created_at *time.Time
  2197. updated_at *time.Time
  2198. deleted_at *time.Time
  2199. user_id *uint64
  2200. adduser_id *int64
  2201. biz_id *string
  2202. access_key_id *string
  2203. access_key_secret *string
  2204. app_id *string
  2205. tenant_id *uint64
  2206. addtenant_id *int64
  2207. response *string
  2208. token *string
  2209. session_id *string
  2210. clearedFields map[string]struct{}
  2211. done bool
  2212. oldValue func(context.Context) (*AliyunAvatar, error)
  2213. predicates []predicate.AliyunAvatar
  2214. }
  2215. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2216. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2217. type aliyunavatarOption func(*AliyunAvatarMutation)
  2218. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2219. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2220. m := &AliyunAvatarMutation{
  2221. config: c,
  2222. op: op,
  2223. typ: TypeAliyunAvatar,
  2224. clearedFields: make(map[string]struct{}),
  2225. }
  2226. for _, opt := range opts {
  2227. opt(m)
  2228. }
  2229. return m
  2230. }
  2231. // withAliyunAvatarID sets the ID field of the mutation.
  2232. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2233. return func(m *AliyunAvatarMutation) {
  2234. var (
  2235. err error
  2236. once sync.Once
  2237. value *AliyunAvatar
  2238. )
  2239. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2240. once.Do(func() {
  2241. if m.done {
  2242. err = errors.New("querying old values post mutation is not allowed")
  2243. } else {
  2244. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2245. }
  2246. })
  2247. return value, err
  2248. }
  2249. m.id = &id
  2250. }
  2251. }
  2252. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2253. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2254. return func(m *AliyunAvatarMutation) {
  2255. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2256. return node, nil
  2257. }
  2258. m.id = &node.ID
  2259. }
  2260. }
  2261. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2262. // executed in a transaction (ent.Tx), a transactional client is returned.
  2263. func (m AliyunAvatarMutation) Client() *Client {
  2264. client := &Client{config: m.config}
  2265. client.init()
  2266. return client
  2267. }
  2268. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2269. // it returns an error otherwise.
  2270. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2271. if _, ok := m.driver.(*txDriver); !ok {
  2272. return nil, errors.New("ent: mutation is not running in a transaction")
  2273. }
  2274. tx := &Tx{config: m.config}
  2275. tx.init()
  2276. return tx, nil
  2277. }
  2278. // SetID sets the value of the id field. Note that this
  2279. // operation is only accepted on creation of AliyunAvatar entities.
  2280. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2281. m.id = &id
  2282. }
  2283. // ID returns the ID value in the mutation. Note that the ID is only available
  2284. // if it was provided to the builder or after it was returned from the database.
  2285. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2286. if m.id == nil {
  2287. return
  2288. }
  2289. return *m.id, true
  2290. }
  2291. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2292. // That means, if the mutation is applied within a transaction with an isolation level such
  2293. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2294. // or updated by the mutation.
  2295. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2296. switch {
  2297. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2298. id, exists := m.ID()
  2299. if exists {
  2300. return []uint64{id}, nil
  2301. }
  2302. fallthrough
  2303. case m.op.Is(OpUpdate | OpDelete):
  2304. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2305. default:
  2306. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2307. }
  2308. }
  2309. // SetCreatedAt sets the "created_at" field.
  2310. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2311. m.created_at = &t
  2312. }
  2313. // CreatedAt returns the value of the "created_at" field in the mutation.
  2314. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2315. v := m.created_at
  2316. if v == nil {
  2317. return
  2318. }
  2319. return *v, true
  2320. }
  2321. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2322. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2324. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2325. if !m.op.Is(OpUpdateOne) {
  2326. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2327. }
  2328. if m.id == nil || m.oldValue == nil {
  2329. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2330. }
  2331. oldValue, err := m.oldValue(ctx)
  2332. if err != nil {
  2333. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2334. }
  2335. return oldValue.CreatedAt, nil
  2336. }
  2337. // ResetCreatedAt resets all changes to the "created_at" field.
  2338. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2339. m.created_at = nil
  2340. }
  2341. // SetUpdatedAt sets the "updated_at" field.
  2342. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2343. m.updated_at = &t
  2344. }
  2345. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2346. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2347. v := m.updated_at
  2348. if v == nil {
  2349. return
  2350. }
  2351. return *v, true
  2352. }
  2353. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2354. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2356. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2357. if !m.op.Is(OpUpdateOne) {
  2358. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2359. }
  2360. if m.id == nil || m.oldValue == nil {
  2361. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2362. }
  2363. oldValue, err := m.oldValue(ctx)
  2364. if err != nil {
  2365. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2366. }
  2367. return oldValue.UpdatedAt, nil
  2368. }
  2369. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2370. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2371. m.updated_at = nil
  2372. }
  2373. // SetDeletedAt sets the "deleted_at" field.
  2374. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2375. m.deleted_at = &t
  2376. }
  2377. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2378. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2379. v := m.deleted_at
  2380. if v == nil {
  2381. return
  2382. }
  2383. return *v, true
  2384. }
  2385. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2386. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2388. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2389. if !m.op.Is(OpUpdateOne) {
  2390. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2391. }
  2392. if m.id == nil || m.oldValue == nil {
  2393. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2394. }
  2395. oldValue, err := m.oldValue(ctx)
  2396. if err != nil {
  2397. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2398. }
  2399. return oldValue.DeletedAt, nil
  2400. }
  2401. // ClearDeletedAt clears the value of the "deleted_at" field.
  2402. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2403. m.deleted_at = nil
  2404. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2405. }
  2406. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2407. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2408. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2409. return ok
  2410. }
  2411. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2412. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2413. m.deleted_at = nil
  2414. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2415. }
  2416. // SetUserID sets the "user_id" field.
  2417. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2418. m.user_id = &u
  2419. m.adduser_id = nil
  2420. }
  2421. // UserID returns the value of the "user_id" field in the mutation.
  2422. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2423. v := m.user_id
  2424. if v == nil {
  2425. return
  2426. }
  2427. return *v, true
  2428. }
  2429. // OldUserID returns the old "user_id" 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) OldUserID(ctx context.Context) (v uint64, err error) {
  2433. if !m.op.Is(OpUpdateOne) {
  2434. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2435. }
  2436. if m.id == nil || m.oldValue == nil {
  2437. return v, errors.New("OldUserID 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 OldUserID: %w", err)
  2442. }
  2443. return oldValue.UserID, nil
  2444. }
  2445. // AddUserID adds u to the "user_id" field.
  2446. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2447. if m.adduser_id != nil {
  2448. *m.adduser_id += u
  2449. } else {
  2450. m.adduser_id = &u
  2451. }
  2452. }
  2453. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2454. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2455. v := m.adduser_id
  2456. if v == nil {
  2457. return
  2458. }
  2459. return *v, true
  2460. }
  2461. // ResetUserID resets all changes to the "user_id" field.
  2462. func (m *AliyunAvatarMutation) ResetUserID() {
  2463. m.user_id = nil
  2464. m.adduser_id = nil
  2465. }
  2466. // SetBizID sets the "biz_id" field.
  2467. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2468. m.biz_id = &s
  2469. }
  2470. // BizID returns the value of the "biz_id" field in the mutation.
  2471. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2472. v := m.biz_id
  2473. if v == nil {
  2474. return
  2475. }
  2476. return *v, true
  2477. }
  2478. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2479. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2481. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2482. if !m.op.Is(OpUpdateOne) {
  2483. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2484. }
  2485. if m.id == nil || m.oldValue == nil {
  2486. return v, errors.New("OldBizID requires an ID field in the mutation")
  2487. }
  2488. oldValue, err := m.oldValue(ctx)
  2489. if err != nil {
  2490. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2491. }
  2492. return oldValue.BizID, nil
  2493. }
  2494. // ResetBizID resets all changes to the "biz_id" field.
  2495. func (m *AliyunAvatarMutation) ResetBizID() {
  2496. m.biz_id = nil
  2497. }
  2498. // SetAccessKeyID sets the "access_key_id" field.
  2499. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2500. m.access_key_id = &s
  2501. }
  2502. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2503. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2504. v := m.access_key_id
  2505. if v == nil {
  2506. return
  2507. }
  2508. return *v, true
  2509. }
  2510. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2511. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2513. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2514. if !m.op.Is(OpUpdateOne) {
  2515. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2516. }
  2517. if m.id == nil || m.oldValue == nil {
  2518. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2519. }
  2520. oldValue, err := m.oldValue(ctx)
  2521. if err != nil {
  2522. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2523. }
  2524. return oldValue.AccessKeyID, nil
  2525. }
  2526. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2527. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2528. m.access_key_id = nil
  2529. }
  2530. // SetAccessKeySecret sets the "access_key_secret" field.
  2531. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2532. m.access_key_secret = &s
  2533. }
  2534. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2535. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2536. v := m.access_key_secret
  2537. if v == nil {
  2538. return
  2539. }
  2540. return *v, true
  2541. }
  2542. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2543. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2545. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2546. if !m.op.Is(OpUpdateOne) {
  2547. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2548. }
  2549. if m.id == nil || m.oldValue == nil {
  2550. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2551. }
  2552. oldValue, err := m.oldValue(ctx)
  2553. if err != nil {
  2554. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2555. }
  2556. return oldValue.AccessKeySecret, nil
  2557. }
  2558. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2559. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2560. m.access_key_secret = nil
  2561. }
  2562. // SetAppID sets the "app_id" field.
  2563. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2564. m.app_id = &s
  2565. }
  2566. // AppID returns the value of the "app_id" field in the mutation.
  2567. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2568. v := m.app_id
  2569. if v == nil {
  2570. return
  2571. }
  2572. return *v, true
  2573. }
  2574. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2575. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2577. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2578. if !m.op.Is(OpUpdateOne) {
  2579. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2580. }
  2581. if m.id == nil || m.oldValue == nil {
  2582. return v, errors.New("OldAppID requires an ID field in the mutation")
  2583. }
  2584. oldValue, err := m.oldValue(ctx)
  2585. if err != nil {
  2586. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2587. }
  2588. return oldValue.AppID, nil
  2589. }
  2590. // ClearAppID clears the value of the "app_id" field.
  2591. func (m *AliyunAvatarMutation) ClearAppID() {
  2592. m.app_id = nil
  2593. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2594. }
  2595. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2596. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2597. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2598. return ok
  2599. }
  2600. // ResetAppID resets all changes to the "app_id" field.
  2601. func (m *AliyunAvatarMutation) ResetAppID() {
  2602. m.app_id = nil
  2603. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2604. }
  2605. // SetTenantID sets the "tenant_id" field.
  2606. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2607. m.tenant_id = &u
  2608. m.addtenant_id = nil
  2609. }
  2610. // TenantID returns the value of the "tenant_id" field in the mutation.
  2611. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2612. v := m.tenant_id
  2613. if v == nil {
  2614. return
  2615. }
  2616. return *v, true
  2617. }
  2618. // OldTenantID returns the old "tenant_id" 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) OldTenantID(ctx context.Context) (v uint64, err error) {
  2622. if !m.op.Is(OpUpdateOne) {
  2623. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2624. }
  2625. if m.id == nil || m.oldValue == nil {
  2626. return v, errors.New("OldTenantID 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 OldTenantID: %w", err)
  2631. }
  2632. return oldValue.TenantID, nil
  2633. }
  2634. // AddTenantID adds u to the "tenant_id" field.
  2635. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2636. if m.addtenant_id != nil {
  2637. *m.addtenant_id += u
  2638. } else {
  2639. m.addtenant_id = &u
  2640. }
  2641. }
  2642. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2643. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2644. v := m.addtenant_id
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // ResetTenantID resets all changes to the "tenant_id" field.
  2651. func (m *AliyunAvatarMutation) ResetTenantID() {
  2652. m.tenant_id = nil
  2653. m.addtenant_id = nil
  2654. }
  2655. // SetResponse sets the "response" field.
  2656. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2657. m.response = &s
  2658. }
  2659. // Response returns the value of the "response" field in the mutation.
  2660. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2661. v := m.response
  2662. if v == nil {
  2663. return
  2664. }
  2665. return *v, true
  2666. }
  2667. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2668. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2670. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2671. if !m.op.Is(OpUpdateOne) {
  2672. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2673. }
  2674. if m.id == nil || m.oldValue == nil {
  2675. return v, errors.New("OldResponse requires an ID field in the mutation")
  2676. }
  2677. oldValue, err := m.oldValue(ctx)
  2678. if err != nil {
  2679. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2680. }
  2681. return oldValue.Response, nil
  2682. }
  2683. // ResetResponse resets all changes to the "response" field.
  2684. func (m *AliyunAvatarMutation) ResetResponse() {
  2685. m.response = nil
  2686. }
  2687. // SetToken sets the "token" field.
  2688. func (m *AliyunAvatarMutation) SetToken(s string) {
  2689. m.token = &s
  2690. }
  2691. // Token returns the value of the "token" field in the mutation.
  2692. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2693. v := m.token
  2694. if v == nil {
  2695. return
  2696. }
  2697. return *v, true
  2698. }
  2699. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2700. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2702. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2703. if !m.op.Is(OpUpdateOne) {
  2704. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2705. }
  2706. if m.id == nil || m.oldValue == nil {
  2707. return v, errors.New("OldToken requires an ID field in the mutation")
  2708. }
  2709. oldValue, err := m.oldValue(ctx)
  2710. if err != nil {
  2711. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2712. }
  2713. return oldValue.Token, nil
  2714. }
  2715. // ResetToken resets all changes to the "token" field.
  2716. func (m *AliyunAvatarMutation) ResetToken() {
  2717. m.token = nil
  2718. }
  2719. // SetSessionID sets the "session_id" field.
  2720. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2721. m.session_id = &s
  2722. }
  2723. // SessionID returns the value of the "session_id" field in the mutation.
  2724. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2725. v := m.session_id
  2726. if v == nil {
  2727. return
  2728. }
  2729. return *v, true
  2730. }
  2731. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2732. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2734. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2735. if !m.op.Is(OpUpdateOne) {
  2736. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2737. }
  2738. if m.id == nil || m.oldValue == nil {
  2739. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2740. }
  2741. oldValue, err := m.oldValue(ctx)
  2742. if err != nil {
  2743. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2744. }
  2745. return oldValue.SessionID, nil
  2746. }
  2747. // ResetSessionID resets all changes to the "session_id" field.
  2748. func (m *AliyunAvatarMutation) ResetSessionID() {
  2749. m.session_id = nil
  2750. }
  2751. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2752. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2753. m.predicates = append(m.predicates, ps...)
  2754. }
  2755. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2756. // users can use type-assertion to append predicates that do not depend on any generated package.
  2757. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2758. p := make([]predicate.AliyunAvatar, len(ps))
  2759. for i := range ps {
  2760. p[i] = ps[i]
  2761. }
  2762. m.Where(p...)
  2763. }
  2764. // Op returns the operation name.
  2765. func (m *AliyunAvatarMutation) Op() Op {
  2766. return m.op
  2767. }
  2768. // SetOp allows setting the mutation operation.
  2769. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2770. m.op = op
  2771. }
  2772. // Type returns the node type of this mutation (AliyunAvatar).
  2773. func (m *AliyunAvatarMutation) Type() string {
  2774. return m.typ
  2775. }
  2776. // Fields returns all fields that were changed during this mutation. Note that in
  2777. // order to get all numeric fields that were incremented/decremented, call
  2778. // AddedFields().
  2779. func (m *AliyunAvatarMutation) Fields() []string {
  2780. fields := make([]string, 0, 12)
  2781. if m.created_at != nil {
  2782. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2783. }
  2784. if m.updated_at != nil {
  2785. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2786. }
  2787. if m.deleted_at != nil {
  2788. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2789. }
  2790. if m.user_id != nil {
  2791. fields = append(fields, aliyunavatar.FieldUserID)
  2792. }
  2793. if m.biz_id != nil {
  2794. fields = append(fields, aliyunavatar.FieldBizID)
  2795. }
  2796. if m.access_key_id != nil {
  2797. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2798. }
  2799. if m.access_key_secret != nil {
  2800. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2801. }
  2802. if m.app_id != nil {
  2803. fields = append(fields, aliyunavatar.FieldAppID)
  2804. }
  2805. if m.tenant_id != nil {
  2806. fields = append(fields, aliyunavatar.FieldTenantID)
  2807. }
  2808. if m.response != nil {
  2809. fields = append(fields, aliyunavatar.FieldResponse)
  2810. }
  2811. if m.token != nil {
  2812. fields = append(fields, aliyunavatar.FieldToken)
  2813. }
  2814. if m.session_id != nil {
  2815. fields = append(fields, aliyunavatar.FieldSessionID)
  2816. }
  2817. return fields
  2818. }
  2819. // Field returns the value of a field with the given name. The second boolean
  2820. // return value indicates that this field was not set, or was not defined in the
  2821. // schema.
  2822. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2823. switch name {
  2824. case aliyunavatar.FieldCreatedAt:
  2825. return m.CreatedAt()
  2826. case aliyunavatar.FieldUpdatedAt:
  2827. return m.UpdatedAt()
  2828. case aliyunavatar.FieldDeletedAt:
  2829. return m.DeletedAt()
  2830. case aliyunavatar.FieldUserID:
  2831. return m.UserID()
  2832. case aliyunavatar.FieldBizID:
  2833. return m.BizID()
  2834. case aliyunavatar.FieldAccessKeyID:
  2835. return m.AccessKeyID()
  2836. case aliyunavatar.FieldAccessKeySecret:
  2837. return m.AccessKeySecret()
  2838. case aliyunavatar.FieldAppID:
  2839. return m.AppID()
  2840. case aliyunavatar.FieldTenantID:
  2841. return m.TenantID()
  2842. case aliyunavatar.FieldResponse:
  2843. return m.Response()
  2844. case aliyunavatar.FieldToken:
  2845. return m.Token()
  2846. case aliyunavatar.FieldSessionID:
  2847. return m.SessionID()
  2848. }
  2849. return nil, false
  2850. }
  2851. // OldField returns the old value of the field from the database. An error is
  2852. // returned if the mutation operation is not UpdateOne, or the query to the
  2853. // database failed.
  2854. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2855. switch name {
  2856. case aliyunavatar.FieldCreatedAt:
  2857. return m.OldCreatedAt(ctx)
  2858. case aliyunavatar.FieldUpdatedAt:
  2859. return m.OldUpdatedAt(ctx)
  2860. case aliyunavatar.FieldDeletedAt:
  2861. return m.OldDeletedAt(ctx)
  2862. case aliyunavatar.FieldUserID:
  2863. return m.OldUserID(ctx)
  2864. case aliyunavatar.FieldBizID:
  2865. return m.OldBizID(ctx)
  2866. case aliyunavatar.FieldAccessKeyID:
  2867. return m.OldAccessKeyID(ctx)
  2868. case aliyunavatar.FieldAccessKeySecret:
  2869. return m.OldAccessKeySecret(ctx)
  2870. case aliyunavatar.FieldAppID:
  2871. return m.OldAppID(ctx)
  2872. case aliyunavatar.FieldTenantID:
  2873. return m.OldTenantID(ctx)
  2874. case aliyunavatar.FieldResponse:
  2875. return m.OldResponse(ctx)
  2876. case aliyunavatar.FieldToken:
  2877. return m.OldToken(ctx)
  2878. case aliyunavatar.FieldSessionID:
  2879. return m.OldSessionID(ctx)
  2880. }
  2881. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2882. }
  2883. // SetField sets the value of a field with the given name. It returns an error if
  2884. // the field is not defined in the schema, or if the type mismatched the field
  2885. // type.
  2886. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2887. switch name {
  2888. case aliyunavatar.FieldCreatedAt:
  2889. v, ok := value.(time.Time)
  2890. if !ok {
  2891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2892. }
  2893. m.SetCreatedAt(v)
  2894. return nil
  2895. case aliyunavatar.FieldUpdatedAt:
  2896. v, ok := value.(time.Time)
  2897. if !ok {
  2898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2899. }
  2900. m.SetUpdatedAt(v)
  2901. return nil
  2902. case aliyunavatar.FieldDeletedAt:
  2903. v, ok := value.(time.Time)
  2904. if !ok {
  2905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2906. }
  2907. m.SetDeletedAt(v)
  2908. return nil
  2909. case aliyunavatar.FieldUserID:
  2910. v, ok := value.(uint64)
  2911. if !ok {
  2912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2913. }
  2914. m.SetUserID(v)
  2915. return nil
  2916. case aliyunavatar.FieldBizID:
  2917. v, ok := value.(string)
  2918. if !ok {
  2919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2920. }
  2921. m.SetBizID(v)
  2922. return nil
  2923. case aliyunavatar.FieldAccessKeyID:
  2924. v, ok := value.(string)
  2925. if !ok {
  2926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2927. }
  2928. m.SetAccessKeyID(v)
  2929. return nil
  2930. case aliyunavatar.FieldAccessKeySecret:
  2931. v, ok := value.(string)
  2932. if !ok {
  2933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2934. }
  2935. m.SetAccessKeySecret(v)
  2936. return nil
  2937. case aliyunavatar.FieldAppID:
  2938. v, ok := value.(string)
  2939. if !ok {
  2940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2941. }
  2942. m.SetAppID(v)
  2943. return nil
  2944. case aliyunavatar.FieldTenantID:
  2945. v, ok := value.(uint64)
  2946. if !ok {
  2947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2948. }
  2949. m.SetTenantID(v)
  2950. return nil
  2951. case aliyunavatar.FieldResponse:
  2952. v, ok := value.(string)
  2953. if !ok {
  2954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2955. }
  2956. m.SetResponse(v)
  2957. return nil
  2958. case aliyunavatar.FieldToken:
  2959. v, ok := value.(string)
  2960. if !ok {
  2961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2962. }
  2963. m.SetToken(v)
  2964. return nil
  2965. case aliyunavatar.FieldSessionID:
  2966. v, ok := value.(string)
  2967. if !ok {
  2968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2969. }
  2970. m.SetSessionID(v)
  2971. return nil
  2972. }
  2973. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2974. }
  2975. // AddedFields returns all numeric fields that were incremented/decremented during
  2976. // this mutation.
  2977. func (m *AliyunAvatarMutation) AddedFields() []string {
  2978. var fields []string
  2979. if m.adduser_id != nil {
  2980. fields = append(fields, aliyunavatar.FieldUserID)
  2981. }
  2982. if m.addtenant_id != nil {
  2983. fields = append(fields, aliyunavatar.FieldTenantID)
  2984. }
  2985. return fields
  2986. }
  2987. // AddedField returns the numeric value that was incremented/decremented on a field
  2988. // with the given name. The second boolean return value indicates that this field
  2989. // was not set, or was not defined in the schema.
  2990. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2991. switch name {
  2992. case aliyunavatar.FieldUserID:
  2993. return m.AddedUserID()
  2994. case aliyunavatar.FieldTenantID:
  2995. return m.AddedTenantID()
  2996. }
  2997. return nil, false
  2998. }
  2999. // AddField adds the value to the field with the given name. It returns an error if
  3000. // the field is not defined in the schema, or if the type mismatched the field
  3001. // type.
  3002. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3003. switch name {
  3004. case aliyunavatar.FieldUserID:
  3005. v, ok := value.(int64)
  3006. if !ok {
  3007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3008. }
  3009. m.AddUserID(v)
  3010. return nil
  3011. case aliyunavatar.FieldTenantID:
  3012. v, ok := value.(int64)
  3013. if !ok {
  3014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3015. }
  3016. m.AddTenantID(v)
  3017. return nil
  3018. }
  3019. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3020. }
  3021. // ClearedFields returns all nullable fields that were cleared during this
  3022. // mutation.
  3023. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3024. var fields []string
  3025. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3026. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3027. }
  3028. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3029. fields = append(fields, aliyunavatar.FieldAppID)
  3030. }
  3031. return fields
  3032. }
  3033. // FieldCleared returns a boolean indicating if a field with the given name was
  3034. // cleared in this mutation.
  3035. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3036. _, ok := m.clearedFields[name]
  3037. return ok
  3038. }
  3039. // ClearField clears the value of the field with the given name. It returns an
  3040. // error if the field is not defined in the schema.
  3041. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3042. switch name {
  3043. case aliyunavatar.FieldDeletedAt:
  3044. m.ClearDeletedAt()
  3045. return nil
  3046. case aliyunavatar.FieldAppID:
  3047. m.ClearAppID()
  3048. return nil
  3049. }
  3050. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3051. }
  3052. // ResetField resets all changes in the mutation for the field with the given name.
  3053. // It returns an error if the field is not defined in the schema.
  3054. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3055. switch name {
  3056. case aliyunavatar.FieldCreatedAt:
  3057. m.ResetCreatedAt()
  3058. return nil
  3059. case aliyunavatar.FieldUpdatedAt:
  3060. m.ResetUpdatedAt()
  3061. return nil
  3062. case aliyunavatar.FieldDeletedAt:
  3063. m.ResetDeletedAt()
  3064. return nil
  3065. case aliyunavatar.FieldUserID:
  3066. m.ResetUserID()
  3067. return nil
  3068. case aliyunavatar.FieldBizID:
  3069. m.ResetBizID()
  3070. return nil
  3071. case aliyunavatar.FieldAccessKeyID:
  3072. m.ResetAccessKeyID()
  3073. return nil
  3074. case aliyunavatar.FieldAccessKeySecret:
  3075. m.ResetAccessKeySecret()
  3076. return nil
  3077. case aliyunavatar.FieldAppID:
  3078. m.ResetAppID()
  3079. return nil
  3080. case aliyunavatar.FieldTenantID:
  3081. m.ResetTenantID()
  3082. return nil
  3083. case aliyunavatar.FieldResponse:
  3084. m.ResetResponse()
  3085. return nil
  3086. case aliyunavatar.FieldToken:
  3087. m.ResetToken()
  3088. return nil
  3089. case aliyunavatar.FieldSessionID:
  3090. m.ResetSessionID()
  3091. return nil
  3092. }
  3093. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3094. }
  3095. // AddedEdges returns all edge names that were set/added in this mutation.
  3096. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3097. edges := make([]string, 0, 0)
  3098. return edges
  3099. }
  3100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3101. // name in this mutation.
  3102. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3103. return nil
  3104. }
  3105. // RemovedEdges returns all edge names that were removed in this mutation.
  3106. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3107. edges := make([]string, 0, 0)
  3108. return edges
  3109. }
  3110. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3111. // the given name in this mutation.
  3112. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3113. return nil
  3114. }
  3115. // ClearedEdges returns all edge names that were cleared in this mutation.
  3116. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3117. edges := make([]string, 0, 0)
  3118. return edges
  3119. }
  3120. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3121. // was cleared in this mutation.
  3122. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3123. return false
  3124. }
  3125. // ClearEdge clears the value of the edge with the given name. It returns an error
  3126. // if that edge is not defined in the schema.
  3127. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3128. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3129. }
  3130. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3131. // It returns an error if the edge is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3133. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3134. }
  3135. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3136. type AllocAgentMutation struct {
  3137. config
  3138. op Op
  3139. typ string
  3140. id *uint64
  3141. created_at *time.Time
  3142. updated_at *time.Time
  3143. deleted_at *time.Time
  3144. user_id *string
  3145. organization_id *uint64
  3146. addorganization_id *int64
  3147. agents *[]uint64
  3148. appendagents []uint64
  3149. status *int
  3150. addstatus *int
  3151. clearedFields map[string]struct{}
  3152. done bool
  3153. oldValue func(context.Context) (*AllocAgent, error)
  3154. predicates []predicate.AllocAgent
  3155. }
  3156. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3157. // allocagentOption allows management of the mutation configuration using functional options.
  3158. type allocagentOption func(*AllocAgentMutation)
  3159. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3160. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3161. m := &AllocAgentMutation{
  3162. config: c,
  3163. op: op,
  3164. typ: TypeAllocAgent,
  3165. clearedFields: make(map[string]struct{}),
  3166. }
  3167. for _, opt := range opts {
  3168. opt(m)
  3169. }
  3170. return m
  3171. }
  3172. // withAllocAgentID sets the ID field of the mutation.
  3173. func withAllocAgentID(id uint64) allocagentOption {
  3174. return func(m *AllocAgentMutation) {
  3175. var (
  3176. err error
  3177. once sync.Once
  3178. value *AllocAgent
  3179. )
  3180. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3181. once.Do(func() {
  3182. if m.done {
  3183. err = errors.New("querying old values post mutation is not allowed")
  3184. } else {
  3185. value, err = m.Client().AllocAgent.Get(ctx, id)
  3186. }
  3187. })
  3188. return value, err
  3189. }
  3190. m.id = &id
  3191. }
  3192. }
  3193. // withAllocAgent sets the old AllocAgent of the mutation.
  3194. func withAllocAgent(node *AllocAgent) allocagentOption {
  3195. return func(m *AllocAgentMutation) {
  3196. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3197. return node, nil
  3198. }
  3199. m.id = &node.ID
  3200. }
  3201. }
  3202. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3203. // executed in a transaction (ent.Tx), a transactional client is returned.
  3204. func (m AllocAgentMutation) Client() *Client {
  3205. client := &Client{config: m.config}
  3206. client.init()
  3207. return client
  3208. }
  3209. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3210. // it returns an error otherwise.
  3211. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3212. if _, ok := m.driver.(*txDriver); !ok {
  3213. return nil, errors.New("ent: mutation is not running in a transaction")
  3214. }
  3215. tx := &Tx{config: m.config}
  3216. tx.init()
  3217. return tx, nil
  3218. }
  3219. // SetID sets the value of the id field. Note that this
  3220. // operation is only accepted on creation of AllocAgent entities.
  3221. func (m *AllocAgentMutation) SetID(id uint64) {
  3222. m.id = &id
  3223. }
  3224. // ID returns the ID value in the mutation. Note that the ID is only available
  3225. // if it was provided to the builder or after it was returned from the database.
  3226. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3227. if m.id == nil {
  3228. return
  3229. }
  3230. return *m.id, true
  3231. }
  3232. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3233. // That means, if the mutation is applied within a transaction with an isolation level such
  3234. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3235. // or updated by the mutation.
  3236. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3237. switch {
  3238. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3239. id, exists := m.ID()
  3240. if exists {
  3241. return []uint64{id}, nil
  3242. }
  3243. fallthrough
  3244. case m.op.Is(OpUpdate | OpDelete):
  3245. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3246. default:
  3247. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3248. }
  3249. }
  3250. // SetCreatedAt sets the "created_at" field.
  3251. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3252. m.created_at = &t
  3253. }
  3254. // CreatedAt returns the value of the "created_at" field in the mutation.
  3255. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3256. v := m.created_at
  3257. if v == nil {
  3258. return
  3259. }
  3260. return *v, true
  3261. }
  3262. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3263. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3265. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3266. if !m.op.Is(OpUpdateOne) {
  3267. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3268. }
  3269. if m.id == nil || m.oldValue == nil {
  3270. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3271. }
  3272. oldValue, err := m.oldValue(ctx)
  3273. if err != nil {
  3274. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3275. }
  3276. return oldValue.CreatedAt, nil
  3277. }
  3278. // ResetCreatedAt resets all changes to the "created_at" field.
  3279. func (m *AllocAgentMutation) ResetCreatedAt() {
  3280. m.created_at = nil
  3281. }
  3282. // SetUpdatedAt sets the "updated_at" field.
  3283. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3284. m.updated_at = &t
  3285. }
  3286. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3287. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3288. v := m.updated_at
  3289. if v == nil {
  3290. return
  3291. }
  3292. return *v, true
  3293. }
  3294. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3295. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3297. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3298. if !m.op.Is(OpUpdateOne) {
  3299. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3300. }
  3301. if m.id == nil || m.oldValue == nil {
  3302. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3303. }
  3304. oldValue, err := m.oldValue(ctx)
  3305. if err != nil {
  3306. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3307. }
  3308. return oldValue.UpdatedAt, nil
  3309. }
  3310. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3311. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3312. m.updated_at = nil
  3313. }
  3314. // SetDeletedAt sets the "deleted_at" field.
  3315. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3316. m.deleted_at = &t
  3317. }
  3318. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3319. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3320. v := m.deleted_at
  3321. if v == nil {
  3322. return
  3323. }
  3324. return *v, true
  3325. }
  3326. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3327. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3329. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3330. if !m.op.Is(OpUpdateOne) {
  3331. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3332. }
  3333. if m.id == nil || m.oldValue == nil {
  3334. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3335. }
  3336. oldValue, err := m.oldValue(ctx)
  3337. if err != nil {
  3338. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3339. }
  3340. return oldValue.DeletedAt, nil
  3341. }
  3342. // ClearDeletedAt clears the value of the "deleted_at" field.
  3343. func (m *AllocAgentMutation) ClearDeletedAt() {
  3344. m.deleted_at = nil
  3345. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3346. }
  3347. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3348. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3349. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3350. return ok
  3351. }
  3352. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3353. func (m *AllocAgentMutation) ResetDeletedAt() {
  3354. m.deleted_at = nil
  3355. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3356. }
  3357. // SetUserID sets the "user_id" field.
  3358. func (m *AllocAgentMutation) SetUserID(s string) {
  3359. m.user_id = &s
  3360. }
  3361. // UserID returns the value of the "user_id" field in the mutation.
  3362. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3363. v := m.user_id
  3364. if v == nil {
  3365. return
  3366. }
  3367. return *v, true
  3368. }
  3369. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3370. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3372. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3373. if !m.op.Is(OpUpdateOne) {
  3374. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3375. }
  3376. if m.id == nil || m.oldValue == nil {
  3377. return v, errors.New("OldUserID requires an ID field in the mutation")
  3378. }
  3379. oldValue, err := m.oldValue(ctx)
  3380. if err != nil {
  3381. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3382. }
  3383. return oldValue.UserID, nil
  3384. }
  3385. // ClearUserID clears the value of the "user_id" field.
  3386. func (m *AllocAgentMutation) ClearUserID() {
  3387. m.user_id = nil
  3388. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3389. }
  3390. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3391. func (m *AllocAgentMutation) UserIDCleared() bool {
  3392. _, ok := m.clearedFields[allocagent.FieldUserID]
  3393. return ok
  3394. }
  3395. // ResetUserID resets all changes to the "user_id" field.
  3396. func (m *AllocAgentMutation) ResetUserID() {
  3397. m.user_id = nil
  3398. delete(m.clearedFields, allocagent.FieldUserID)
  3399. }
  3400. // SetOrganizationID sets the "organization_id" field.
  3401. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3402. m.organization_id = &u
  3403. m.addorganization_id = nil
  3404. }
  3405. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3406. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3407. v := m.organization_id
  3408. if v == nil {
  3409. return
  3410. }
  3411. return *v, true
  3412. }
  3413. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3414. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3416. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3417. if !m.op.Is(OpUpdateOne) {
  3418. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3419. }
  3420. if m.id == nil || m.oldValue == nil {
  3421. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3422. }
  3423. oldValue, err := m.oldValue(ctx)
  3424. if err != nil {
  3425. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3426. }
  3427. return oldValue.OrganizationID, nil
  3428. }
  3429. // AddOrganizationID adds u to the "organization_id" field.
  3430. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3431. if m.addorganization_id != nil {
  3432. *m.addorganization_id += u
  3433. } else {
  3434. m.addorganization_id = &u
  3435. }
  3436. }
  3437. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3438. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3439. v := m.addorganization_id
  3440. if v == nil {
  3441. return
  3442. }
  3443. return *v, true
  3444. }
  3445. // ClearOrganizationID clears the value of the "organization_id" field.
  3446. func (m *AllocAgentMutation) ClearOrganizationID() {
  3447. m.organization_id = nil
  3448. m.addorganization_id = nil
  3449. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3450. }
  3451. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3452. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3453. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3454. return ok
  3455. }
  3456. // ResetOrganizationID resets all changes to the "organization_id" field.
  3457. func (m *AllocAgentMutation) ResetOrganizationID() {
  3458. m.organization_id = nil
  3459. m.addorganization_id = nil
  3460. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3461. }
  3462. // SetAgents sets the "agents" field.
  3463. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3464. m.agents = &u
  3465. m.appendagents = nil
  3466. }
  3467. // Agents returns the value of the "agents" field in the mutation.
  3468. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3469. v := m.agents
  3470. if v == nil {
  3471. return
  3472. }
  3473. return *v, true
  3474. }
  3475. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3476. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3478. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3479. if !m.op.Is(OpUpdateOne) {
  3480. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3481. }
  3482. if m.id == nil || m.oldValue == nil {
  3483. return v, errors.New("OldAgents requires an ID field in the mutation")
  3484. }
  3485. oldValue, err := m.oldValue(ctx)
  3486. if err != nil {
  3487. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3488. }
  3489. return oldValue.Agents, nil
  3490. }
  3491. // AppendAgents adds u to the "agents" field.
  3492. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3493. m.appendagents = append(m.appendagents, u...)
  3494. }
  3495. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3496. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3497. if len(m.appendagents) == 0 {
  3498. return nil, false
  3499. }
  3500. return m.appendagents, true
  3501. }
  3502. // ResetAgents resets all changes to the "agents" field.
  3503. func (m *AllocAgentMutation) ResetAgents() {
  3504. m.agents = nil
  3505. m.appendagents = nil
  3506. }
  3507. // SetStatus sets the "status" field.
  3508. func (m *AllocAgentMutation) SetStatus(i int) {
  3509. m.status = &i
  3510. m.addstatus = nil
  3511. }
  3512. // Status returns the value of the "status" field in the mutation.
  3513. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3514. v := m.status
  3515. if v == nil {
  3516. return
  3517. }
  3518. return *v, true
  3519. }
  3520. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3521. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3523. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3524. if !m.op.Is(OpUpdateOne) {
  3525. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3526. }
  3527. if m.id == nil || m.oldValue == nil {
  3528. return v, errors.New("OldStatus requires an ID field in the mutation")
  3529. }
  3530. oldValue, err := m.oldValue(ctx)
  3531. if err != nil {
  3532. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3533. }
  3534. return oldValue.Status, nil
  3535. }
  3536. // AddStatus adds i to the "status" field.
  3537. func (m *AllocAgentMutation) AddStatus(i int) {
  3538. if m.addstatus != nil {
  3539. *m.addstatus += i
  3540. } else {
  3541. m.addstatus = &i
  3542. }
  3543. }
  3544. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3545. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3546. v := m.addstatus
  3547. if v == nil {
  3548. return
  3549. }
  3550. return *v, true
  3551. }
  3552. // ClearStatus clears the value of the "status" field.
  3553. func (m *AllocAgentMutation) ClearStatus() {
  3554. m.status = nil
  3555. m.addstatus = nil
  3556. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3557. }
  3558. // StatusCleared returns if the "status" field was cleared in this mutation.
  3559. func (m *AllocAgentMutation) StatusCleared() bool {
  3560. _, ok := m.clearedFields[allocagent.FieldStatus]
  3561. return ok
  3562. }
  3563. // ResetStatus resets all changes to the "status" field.
  3564. func (m *AllocAgentMutation) ResetStatus() {
  3565. m.status = nil
  3566. m.addstatus = nil
  3567. delete(m.clearedFields, allocagent.FieldStatus)
  3568. }
  3569. // Where appends a list predicates to the AllocAgentMutation builder.
  3570. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3571. m.predicates = append(m.predicates, ps...)
  3572. }
  3573. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3574. // users can use type-assertion to append predicates that do not depend on any generated package.
  3575. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3576. p := make([]predicate.AllocAgent, len(ps))
  3577. for i := range ps {
  3578. p[i] = ps[i]
  3579. }
  3580. m.Where(p...)
  3581. }
  3582. // Op returns the operation name.
  3583. func (m *AllocAgentMutation) Op() Op {
  3584. return m.op
  3585. }
  3586. // SetOp allows setting the mutation operation.
  3587. func (m *AllocAgentMutation) SetOp(op Op) {
  3588. m.op = op
  3589. }
  3590. // Type returns the node type of this mutation (AllocAgent).
  3591. func (m *AllocAgentMutation) Type() string {
  3592. return m.typ
  3593. }
  3594. // Fields returns all fields that were changed during this mutation. Note that in
  3595. // order to get all numeric fields that were incremented/decremented, call
  3596. // AddedFields().
  3597. func (m *AllocAgentMutation) Fields() []string {
  3598. fields := make([]string, 0, 7)
  3599. if m.created_at != nil {
  3600. fields = append(fields, allocagent.FieldCreatedAt)
  3601. }
  3602. if m.updated_at != nil {
  3603. fields = append(fields, allocagent.FieldUpdatedAt)
  3604. }
  3605. if m.deleted_at != nil {
  3606. fields = append(fields, allocagent.FieldDeletedAt)
  3607. }
  3608. if m.user_id != nil {
  3609. fields = append(fields, allocagent.FieldUserID)
  3610. }
  3611. if m.organization_id != nil {
  3612. fields = append(fields, allocagent.FieldOrganizationID)
  3613. }
  3614. if m.agents != nil {
  3615. fields = append(fields, allocagent.FieldAgents)
  3616. }
  3617. if m.status != nil {
  3618. fields = append(fields, allocagent.FieldStatus)
  3619. }
  3620. return fields
  3621. }
  3622. // Field returns the value of a field with the given name. The second boolean
  3623. // return value indicates that this field was not set, or was not defined in the
  3624. // schema.
  3625. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3626. switch name {
  3627. case allocagent.FieldCreatedAt:
  3628. return m.CreatedAt()
  3629. case allocagent.FieldUpdatedAt:
  3630. return m.UpdatedAt()
  3631. case allocagent.FieldDeletedAt:
  3632. return m.DeletedAt()
  3633. case allocagent.FieldUserID:
  3634. return m.UserID()
  3635. case allocagent.FieldOrganizationID:
  3636. return m.OrganizationID()
  3637. case allocagent.FieldAgents:
  3638. return m.Agents()
  3639. case allocagent.FieldStatus:
  3640. return m.Status()
  3641. }
  3642. return nil, false
  3643. }
  3644. // OldField returns the old value of the field from the database. An error is
  3645. // returned if the mutation operation is not UpdateOne, or the query to the
  3646. // database failed.
  3647. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3648. switch name {
  3649. case allocagent.FieldCreatedAt:
  3650. return m.OldCreatedAt(ctx)
  3651. case allocagent.FieldUpdatedAt:
  3652. return m.OldUpdatedAt(ctx)
  3653. case allocagent.FieldDeletedAt:
  3654. return m.OldDeletedAt(ctx)
  3655. case allocagent.FieldUserID:
  3656. return m.OldUserID(ctx)
  3657. case allocagent.FieldOrganizationID:
  3658. return m.OldOrganizationID(ctx)
  3659. case allocagent.FieldAgents:
  3660. return m.OldAgents(ctx)
  3661. case allocagent.FieldStatus:
  3662. return m.OldStatus(ctx)
  3663. }
  3664. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3665. }
  3666. // SetField sets the value of a field with the given name. It returns an error if
  3667. // the field is not defined in the schema, or if the type mismatched the field
  3668. // type.
  3669. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3670. switch name {
  3671. case allocagent.FieldCreatedAt:
  3672. v, ok := value.(time.Time)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetCreatedAt(v)
  3677. return nil
  3678. case allocagent.FieldUpdatedAt:
  3679. v, ok := value.(time.Time)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetUpdatedAt(v)
  3684. return nil
  3685. case allocagent.FieldDeletedAt:
  3686. v, ok := value.(time.Time)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetDeletedAt(v)
  3691. return nil
  3692. case allocagent.FieldUserID:
  3693. v, ok := value.(string)
  3694. if !ok {
  3695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3696. }
  3697. m.SetUserID(v)
  3698. return nil
  3699. case allocagent.FieldOrganizationID:
  3700. v, ok := value.(uint64)
  3701. if !ok {
  3702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3703. }
  3704. m.SetOrganizationID(v)
  3705. return nil
  3706. case allocagent.FieldAgents:
  3707. v, ok := value.([]uint64)
  3708. if !ok {
  3709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3710. }
  3711. m.SetAgents(v)
  3712. return nil
  3713. case allocagent.FieldStatus:
  3714. v, ok := value.(int)
  3715. if !ok {
  3716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3717. }
  3718. m.SetStatus(v)
  3719. return nil
  3720. }
  3721. return fmt.Errorf("unknown AllocAgent field %s", name)
  3722. }
  3723. // AddedFields returns all numeric fields that were incremented/decremented during
  3724. // this mutation.
  3725. func (m *AllocAgentMutation) AddedFields() []string {
  3726. var fields []string
  3727. if m.addorganization_id != nil {
  3728. fields = append(fields, allocagent.FieldOrganizationID)
  3729. }
  3730. if m.addstatus != nil {
  3731. fields = append(fields, allocagent.FieldStatus)
  3732. }
  3733. return fields
  3734. }
  3735. // AddedField returns the numeric value that was incremented/decremented on a field
  3736. // with the given name. The second boolean return value indicates that this field
  3737. // was not set, or was not defined in the schema.
  3738. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3739. switch name {
  3740. case allocagent.FieldOrganizationID:
  3741. return m.AddedOrganizationID()
  3742. case allocagent.FieldStatus:
  3743. return m.AddedStatus()
  3744. }
  3745. return nil, false
  3746. }
  3747. // AddField adds the value to the field with the given name. It returns an error if
  3748. // the field is not defined in the schema, or if the type mismatched the field
  3749. // type.
  3750. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3751. switch name {
  3752. case allocagent.FieldOrganizationID:
  3753. v, ok := value.(int64)
  3754. if !ok {
  3755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3756. }
  3757. m.AddOrganizationID(v)
  3758. return nil
  3759. case allocagent.FieldStatus:
  3760. v, ok := value.(int)
  3761. if !ok {
  3762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3763. }
  3764. m.AddStatus(v)
  3765. return nil
  3766. }
  3767. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3768. }
  3769. // ClearedFields returns all nullable fields that were cleared during this
  3770. // mutation.
  3771. func (m *AllocAgentMutation) ClearedFields() []string {
  3772. var fields []string
  3773. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3774. fields = append(fields, allocagent.FieldDeletedAt)
  3775. }
  3776. if m.FieldCleared(allocagent.FieldUserID) {
  3777. fields = append(fields, allocagent.FieldUserID)
  3778. }
  3779. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3780. fields = append(fields, allocagent.FieldOrganizationID)
  3781. }
  3782. if m.FieldCleared(allocagent.FieldStatus) {
  3783. fields = append(fields, allocagent.FieldStatus)
  3784. }
  3785. return fields
  3786. }
  3787. // FieldCleared returns a boolean indicating if a field with the given name was
  3788. // cleared in this mutation.
  3789. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3790. _, ok := m.clearedFields[name]
  3791. return ok
  3792. }
  3793. // ClearField clears the value of the field with the given name. It returns an
  3794. // error if the field is not defined in the schema.
  3795. func (m *AllocAgentMutation) ClearField(name string) error {
  3796. switch name {
  3797. case allocagent.FieldDeletedAt:
  3798. m.ClearDeletedAt()
  3799. return nil
  3800. case allocagent.FieldUserID:
  3801. m.ClearUserID()
  3802. return nil
  3803. case allocagent.FieldOrganizationID:
  3804. m.ClearOrganizationID()
  3805. return nil
  3806. case allocagent.FieldStatus:
  3807. m.ClearStatus()
  3808. return nil
  3809. }
  3810. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3811. }
  3812. // ResetField resets all changes in the mutation for the field with the given name.
  3813. // It returns an error if the field is not defined in the schema.
  3814. func (m *AllocAgentMutation) ResetField(name string) error {
  3815. switch name {
  3816. case allocagent.FieldCreatedAt:
  3817. m.ResetCreatedAt()
  3818. return nil
  3819. case allocagent.FieldUpdatedAt:
  3820. m.ResetUpdatedAt()
  3821. return nil
  3822. case allocagent.FieldDeletedAt:
  3823. m.ResetDeletedAt()
  3824. return nil
  3825. case allocagent.FieldUserID:
  3826. m.ResetUserID()
  3827. return nil
  3828. case allocagent.FieldOrganizationID:
  3829. m.ResetOrganizationID()
  3830. return nil
  3831. case allocagent.FieldAgents:
  3832. m.ResetAgents()
  3833. return nil
  3834. case allocagent.FieldStatus:
  3835. m.ResetStatus()
  3836. return nil
  3837. }
  3838. return fmt.Errorf("unknown AllocAgent field %s", name)
  3839. }
  3840. // AddedEdges returns all edge names that were set/added in this mutation.
  3841. func (m *AllocAgentMutation) AddedEdges() []string {
  3842. edges := make([]string, 0, 0)
  3843. return edges
  3844. }
  3845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3846. // name in this mutation.
  3847. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3848. return nil
  3849. }
  3850. // RemovedEdges returns all edge names that were removed in this mutation.
  3851. func (m *AllocAgentMutation) RemovedEdges() []string {
  3852. edges := make([]string, 0, 0)
  3853. return edges
  3854. }
  3855. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3856. // the given name in this mutation.
  3857. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3858. return nil
  3859. }
  3860. // ClearedEdges returns all edge names that were cleared in this mutation.
  3861. func (m *AllocAgentMutation) ClearedEdges() []string {
  3862. edges := make([]string, 0, 0)
  3863. return edges
  3864. }
  3865. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3866. // was cleared in this mutation.
  3867. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3868. return false
  3869. }
  3870. // ClearEdge clears the value of the edge with the given name. It returns an error
  3871. // if that edge is not defined in the schema.
  3872. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3873. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3874. }
  3875. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3876. // It returns an error if the edge is not defined in the schema.
  3877. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3878. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3879. }
  3880. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3881. type BatchMsgMutation struct {
  3882. config
  3883. op Op
  3884. typ string
  3885. id *uint64
  3886. created_at *time.Time
  3887. updated_at *time.Time
  3888. deleted_at *time.Time
  3889. status *uint8
  3890. addstatus *int8
  3891. batch_no *string
  3892. task_name *string
  3893. fromwxid *string
  3894. msg *string
  3895. tag *string
  3896. tagids *string
  3897. total *int32
  3898. addtotal *int32
  3899. success *int32
  3900. addsuccess *int32
  3901. fail *int32
  3902. addfail *int32
  3903. start_time *time.Time
  3904. stop_time *time.Time
  3905. send_time *time.Time
  3906. _type *int32
  3907. add_type *int32
  3908. organization_id *uint64
  3909. addorganization_id *int64
  3910. clearedFields map[string]struct{}
  3911. done bool
  3912. oldValue func(context.Context) (*BatchMsg, error)
  3913. predicates []predicate.BatchMsg
  3914. }
  3915. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3916. // batchmsgOption allows management of the mutation configuration using functional options.
  3917. type batchmsgOption func(*BatchMsgMutation)
  3918. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3919. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3920. m := &BatchMsgMutation{
  3921. config: c,
  3922. op: op,
  3923. typ: TypeBatchMsg,
  3924. clearedFields: make(map[string]struct{}),
  3925. }
  3926. for _, opt := range opts {
  3927. opt(m)
  3928. }
  3929. return m
  3930. }
  3931. // withBatchMsgID sets the ID field of the mutation.
  3932. func withBatchMsgID(id uint64) batchmsgOption {
  3933. return func(m *BatchMsgMutation) {
  3934. var (
  3935. err error
  3936. once sync.Once
  3937. value *BatchMsg
  3938. )
  3939. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3940. once.Do(func() {
  3941. if m.done {
  3942. err = errors.New("querying old values post mutation is not allowed")
  3943. } else {
  3944. value, err = m.Client().BatchMsg.Get(ctx, id)
  3945. }
  3946. })
  3947. return value, err
  3948. }
  3949. m.id = &id
  3950. }
  3951. }
  3952. // withBatchMsg sets the old BatchMsg of the mutation.
  3953. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3954. return func(m *BatchMsgMutation) {
  3955. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3956. return node, nil
  3957. }
  3958. m.id = &node.ID
  3959. }
  3960. }
  3961. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3962. // executed in a transaction (ent.Tx), a transactional client is returned.
  3963. func (m BatchMsgMutation) Client() *Client {
  3964. client := &Client{config: m.config}
  3965. client.init()
  3966. return client
  3967. }
  3968. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3969. // it returns an error otherwise.
  3970. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3971. if _, ok := m.driver.(*txDriver); !ok {
  3972. return nil, errors.New("ent: mutation is not running in a transaction")
  3973. }
  3974. tx := &Tx{config: m.config}
  3975. tx.init()
  3976. return tx, nil
  3977. }
  3978. // SetID sets the value of the id field. Note that this
  3979. // operation is only accepted on creation of BatchMsg entities.
  3980. func (m *BatchMsgMutation) SetID(id uint64) {
  3981. m.id = &id
  3982. }
  3983. // ID returns the ID value in the mutation. Note that the ID is only available
  3984. // if it was provided to the builder or after it was returned from the database.
  3985. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3986. if m.id == nil {
  3987. return
  3988. }
  3989. return *m.id, true
  3990. }
  3991. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3992. // That means, if the mutation is applied within a transaction with an isolation level such
  3993. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3994. // or updated by the mutation.
  3995. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3996. switch {
  3997. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3998. id, exists := m.ID()
  3999. if exists {
  4000. return []uint64{id}, nil
  4001. }
  4002. fallthrough
  4003. case m.op.Is(OpUpdate | OpDelete):
  4004. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4005. default:
  4006. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4007. }
  4008. }
  4009. // SetCreatedAt sets the "created_at" field.
  4010. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4011. m.created_at = &t
  4012. }
  4013. // CreatedAt returns the value of the "created_at" field in the mutation.
  4014. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4015. v := m.created_at
  4016. if v == nil {
  4017. return
  4018. }
  4019. return *v, true
  4020. }
  4021. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4022. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4024. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4025. if !m.op.Is(OpUpdateOne) {
  4026. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4027. }
  4028. if m.id == nil || m.oldValue == nil {
  4029. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4030. }
  4031. oldValue, err := m.oldValue(ctx)
  4032. if err != nil {
  4033. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4034. }
  4035. return oldValue.CreatedAt, nil
  4036. }
  4037. // ResetCreatedAt resets all changes to the "created_at" field.
  4038. func (m *BatchMsgMutation) ResetCreatedAt() {
  4039. m.created_at = nil
  4040. }
  4041. // SetUpdatedAt sets the "updated_at" field.
  4042. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4043. m.updated_at = &t
  4044. }
  4045. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4046. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4047. v := m.updated_at
  4048. if v == nil {
  4049. return
  4050. }
  4051. return *v, true
  4052. }
  4053. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4054. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4056. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4057. if !m.op.Is(OpUpdateOne) {
  4058. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4059. }
  4060. if m.id == nil || m.oldValue == nil {
  4061. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4062. }
  4063. oldValue, err := m.oldValue(ctx)
  4064. if err != nil {
  4065. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4066. }
  4067. return oldValue.UpdatedAt, nil
  4068. }
  4069. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4070. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4071. m.updated_at = nil
  4072. }
  4073. // SetDeletedAt sets the "deleted_at" field.
  4074. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4075. m.deleted_at = &t
  4076. }
  4077. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4078. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4079. v := m.deleted_at
  4080. if v == nil {
  4081. return
  4082. }
  4083. return *v, true
  4084. }
  4085. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4086. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4088. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4089. if !m.op.Is(OpUpdateOne) {
  4090. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4091. }
  4092. if m.id == nil || m.oldValue == nil {
  4093. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4094. }
  4095. oldValue, err := m.oldValue(ctx)
  4096. if err != nil {
  4097. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4098. }
  4099. return oldValue.DeletedAt, nil
  4100. }
  4101. // ClearDeletedAt clears the value of the "deleted_at" field.
  4102. func (m *BatchMsgMutation) ClearDeletedAt() {
  4103. m.deleted_at = nil
  4104. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4105. }
  4106. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4107. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4108. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4109. return ok
  4110. }
  4111. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4112. func (m *BatchMsgMutation) ResetDeletedAt() {
  4113. m.deleted_at = nil
  4114. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4115. }
  4116. // SetStatus sets the "status" field.
  4117. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4118. m.status = &u
  4119. m.addstatus = nil
  4120. }
  4121. // Status returns the value of the "status" field in the mutation.
  4122. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4123. v := m.status
  4124. if v == nil {
  4125. return
  4126. }
  4127. return *v, true
  4128. }
  4129. // OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
  4133. if !m.op.Is(OpUpdateOne) {
  4134. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4135. }
  4136. if m.id == nil || m.oldValue == nil {
  4137. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  4142. }
  4143. return oldValue.Status, nil
  4144. }
  4145. // AddStatus adds u to the "status" field.
  4146. func (m *BatchMsgMutation) AddStatus(u int8) {
  4147. if m.addstatus != nil {
  4148. *m.addstatus += u
  4149. } else {
  4150. m.addstatus = &u
  4151. }
  4152. }
  4153. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4154. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4155. v := m.addstatus
  4156. if v == nil {
  4157. return
  4158. }
  4159. return *v, true
  4160. }
  4161. // ClearStatus clears the value of the "status" field.
  4162. func (m *BatchMsgMutation) ClearStatus() {
  4163. m.status = nil
  4164. m.addstatus = nil
  4165. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4166. }
  4167. // StatusCleared returns if the "status" field was cleared in this mutation.
  4168. func (m *BatchMsgMutation) StatusCleared() bool {
  4169. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4170. return ok
  4171. }
  4172. // ResetStatus resets all changes to the "status" field.
  4173. func (m *BatchMsgMutation) ResetStatus() {
  4174. m.status = nil
  4175. m.addstatus = nil
  4176. delete(m.clearedFields, batchmsg.FieldStatus)
  4177. }
  4178. // SetBatchNo sets the "batch_no" field.
  4179. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4180. m.batch_no = &s
  4181. }
  4182. // BatchNo returns the value of the "batch_no" field in the mutation.
  4183. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4184. v := m.batch_no
  4185. if v == nil {
  4186. return
  4187. }
  4188. return *v, true
  4189. }
  4190. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4191. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4193. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4194. if !m.op.Is(OpUpdateOne) {
  4195. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4196. }
  4197. if m.id == nil || m.oldValue == nil {
  4198. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4199. }
  4200. oldValue, err := m.oldValue(ctx)
  4201. if err != nil {
  4202. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4203. }
  4204. return oldValue.BatchNo, nil
  4205. }
  4206. // ClearBatchNo clears the value of the "batch_no" field.
  4207. func (m *BatchMsgMutation) ClearBatchNo() {
  4208. m.batch_no = nil
  4209. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4210. }
  4211. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4212. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4213. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4214. return ok
  4215. }
  4216. // ResetBatchNo resets all changes to the "batch_no" field.
  4217. func (m *BatchMsgMutation) ResetBatchNo() {
  4218. m.batch_no = nil
  4219. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4220. }
  4221. // SetTaskName sets the "task_name" field.
  4222. func (m *BatchMsgMutation) SetTaskName(s string) {
  4223. m.task_name = &s
  4224. }
  4225. // TaskName returns the value of the "task_name" field in the mutation.
  4226. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4227. v := m.task_name
  4228. if v == nil {
  4229. return
  4230. }
  4231. return *v, true
  4232. }
  4233. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4234. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4236. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4237. if !m.op.Is(OpUpdateOne) {
  4238. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4239. }
  4240. if m.id == nil || m.oldValue == nil {
  4241. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4242. }
  4243. oldValue, err := m.oldValue(ctx)
  4244. if err != nil {
  4245. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4246. }
  4247. return oldValue.TaskName, nil
  4248. }
  4249. // ClearTaskName clears the value of the "task_name" field.
  4250. func (m *BatchMsgMutation) ClearTaskName() {
  4251. m.task_name = nil
  4252. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4253. }
  4254. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4255. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4256. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4257. return ok
  4258. }
  4259. // ResetTaskName resets all changes to the "task_name" field.
  4260. func (m *BatchMsgMutation) ResetTaskName() {
  4261. m.task_name = nil
  4262. delete(m.clearedFields, batchmsg.FieldTaskName)
  4263. }
  4264. // SetFromwxid sets the "fromwxid" field.
  4265. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4266. m.fromwxid = &s
  4267. }
  4268. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4269. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4270. v := m.fromwxid
  4271. if v == nil {
  4272. return
  4273. }
  4274. return *v, true
  4275. }
  4276. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4277. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4279. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4280. if !m.op.Is(OpUpdateOne) {
  4281. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4282. }
  4283. if m.id == nil || m.oldValue == nil {
  4284. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4285. }
  4286. oldValue, err := m.oldValue(ctx)
  4287. if err != nil {
  4288. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4289. }
  4290. return oldValue.Fromwxid, nil
  4291. }
  4292. // ClearFromwxid clears the value of the "fromwxid" field.
  4293. func (m *BatchMsgMutation) ClearFromwxid() {
  4294. m.fromwxid = nil
  4295. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4296. }
  4297. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4298. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4299. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4300. return ok
  4301. }
  4302. // ResetFromwxid resets all changes to the "fromwxid" field.
  4303. func (m *BatchMsgMutation) ResetFromwxid() {
  4304. m.fromwxid = nil
  4305. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4306. }
  4307. // SetMsg sets the "msg" field.
  4308. func (m *BatchMsgMutation) SetMsg(s string) {
  4309. m.msg = &s
  4310. }
  4311. // Msg returns the value of the "msg" field in the mutation.
  4312. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4313. v := m.msg
  4314. if v == nil {
  4315. return
  4316. }
  4317. return *v, true
  4318. }
  4319. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4320. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4322. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4323. if !m.op.Is(OpUpdateOne) {
  4324. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4325. }
  4326. if m.id == nil || m.oldValue == nil {
  4327. return v, errors.New("OldMsg requires an ID field in the mutation")
  4328. }
  4329. oldValue, err := m.oldValue(ctx)
  4330. if err != nil {
  4331. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4332. }
  4333. return oldValue.Msg, nil
  4334. }
  4335. // ClearMsg clears the value of the "msg" field.
  4336. func (m *BatchMsgMutation) ClearMsg() {
  4337. m.msg = nil
  4338. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4339. }
  4340. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4341. func (m *BatchMsgMutation) MsgCleared() bool {
  4342. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4343. return ok
  4344. }
  4345. // ResetMsg resets all changes to the "msg" field.
  4346. func (m *BatchMsgMutation) ResetMsg() {
  4347. m.msg = nil
  4348. delete(m.clearedFields, batchmsg.FieldMsg)
  4349. }
  4350. // SetTag sets the "tag" field.
  4351. func (m *BatchMsgMutation) SetTag(s string) {
  4352. m.tag = &s
  4353. }
  4354. // Tag returns the value of the "tag" field in the mutation.
  4355. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4356. v := m.tag
  4357. if v == nil {
  4358. return
  4359. }
  4360. return *v, true
  4361. }
  4362. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4363. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4365. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4366. if !m.op.Is(OpUpdateOne) {
  4367. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4368. }
  4369. if m.id == nil || m.oldValue == nil {
  4370. return v, errors.New("OldTag requires an ID field in the mutation")
  4371. }
  4372. oldValue, err := m.oldValue(ctx)
  4373. if err != nil {
  4374. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4375. }
  4376. return oldValue.Tag, nil
  4377. }
  4378. // ClearTag clears the value of the "tag" field.
  4379. func (m *BatchMsgMutation) ClearTag() {
  4380. m.tag = nil
  4381. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4382. }
  4383. // TagCleared returns if the "tag" field was cleared in this mutation.
  4384. func (m *BatchMsgMutation) TagCleared() bool {
  4385. _, ok := m.clearedFields[batchmsg.FieldTag]
  4386. return ok
  4387. }
  4388. // ResetTag resets all changes to the "tag" field.
  4389. func (m *BatchMsgMutation) ResetTag() {
  4390. m.tag = nil
  4391. delete(m.clearedFields, batchmsg.FieldTag)
  4392. }
  4393. // SetTagids sets the "tagids" field.
  4394. func (m *BatchMsgMutation) SetTagids(s string) {
  4395. m.tagids = &s
  4396. }
  4397. // Tagids returns the value of the "tagids" field in the mutation.
  4398. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4399. v := m.tagids
  4400. if v == nil {
  4401. return
  4402. }
  4403. return *v, true
  4404. }
  4405. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4406. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4408. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4409. if !m.op.Is(OpUpdateOne) {
  4410. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4411. }
  4412. if m.id == nil || m.oldValue == nil {
  4413. return v, errors.New("OldTagids requires an ID field in the mutation")
  4414. }
  4415. oldValue, err := m.oldValue(ctx)
  4416. if err != nil {
  4417. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4418. }
  4419. return oldValue.Tagids, nil
  4420. }
  4421. // ClearTagids clears the value of the "tagids" field.
  4422. func (m *BatchMsgMutation) ClearTagids() {
  4423. m.tagids = nil
  4424. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4425. }
  4426. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4427. func (m *BatchMsgMutation) TagidsCleared() bool {
  4428. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4429. return ok
  4430. }
  4431. // ResetTagids resets all changes to the "tagids" field.
  4432. func (m *BatchMsgMutation) ResetTagids() {
  4433. m.tagids = nil
  4434. delete(m.clearedFields, batchmsg.FieldTagids)
  4435. }
  4436. // SetTotal sets the "total" field.
  4437. func (m *BatchMsgMutation) SetTotal(i int32) {
  4438. m.total = &i
  4439. m.addtotal = nil
  4440. }
  4441. // Total returns the value of the "total" field in the mutation.
  4442. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4443. v := m.total
  4444. if v == nil {
  4445. return
  4446. }
  4447. return *v, true
  4448. }
  4449. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4450. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4452. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4453. if !m.op.Is(OpUpdateOne) {
  4454. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4455. }
  4456. if m.id == nil || m.oldValue == nil {
  4457. return v, errors.New("OldTotal requires an ID field in the mutation")
  4458. }
  4459. oldValue, err := m.oldValue(ctx)
  4460. if err != nil {
  4461. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4462. }
  4463. return oldValue.Total, nil
  4464. }
  4465. // AddTotal adds i to the "total" field.
  4466. func (m *BatchMsgMutation) AddTotal(i int32) {
  4467. if m.addtotal != nil {
  4468. *m.addtotal += i
  4469. } else {
  4470. m.addtotal = &i
  4471. }
  4472. }
  4473. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4474. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4475. v := m.addtotal
  4476. if v == nil {
  4477. return
  4478. }
  4479. return *v, true
  4480. }
  4481. // ClearTotal clears the value of the "total" field.
  4482. func (m *BatchMsgMutation) ClearTotal() {
  4483. m.total = nil
  4484. m.addtotal = nil
  4485. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4486. }
  4487. // TotalCleared returns if the "total" field was cleared in this mutation.
  4488. func (m *BatchMsgMutation) TotalCleared() bool {
  4489. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4490. return ok
  4491. }
  4492. // ResetTotal resets all changes to the "total" field.
  4493. func (m *BatchMsgMutation) ResetTotal() {
  4494. m.total = nil
  4495. m.addtotal = nil
  4496. delete(m.clearedFields, batchmsg.FieldTotal)
  4497. }
  4498. // SetSuccess sets the "success" field.
  4499. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4500. m.success = &i
  4501. m.addsuccess = nil
  4502. }
  4503. // Success returns the value of the "success" field in the mutation.
  4504. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4505. v := m.success
  4506. if v == nil {
  4507. return
  4508. }
  4509. return *v, true
  4510. }
  4511. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4512. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4514. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4515. if !m.op.Is(OpUpdateOne) {
  4516. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4517. }
  4518. if m.id == nil || m.oldValue == nil {
  4519. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4520. }
  4521. oldValue, err := m.oldValue(ctx)
  4522. if err != nil {
  4523. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4524. }
  4525. return oldValue.Success, nil
  4526. }
  4527. // AddSuccess adds i to the "success" field.
  4528. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4529. if m.addsuccess != nil {
  4530. *m.addsuccess += i
  4531. } else {
  4532. m.addsuccess = &i
  4533. }
  4534. }
  4535. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4536. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4537. v := m.addsuccess
  4538. if v == nil {
  4539. return
  4540. }
  4541. return *v, true
  4542. }
  4543. // ClearSuccess clears the value of the "success" field.
  4544. func (m *BatchMsgMutation) ClearSuccess() {
  4545. m.success = nil
  4546. m.addsuccess = nil
  4547. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4548. }
  4549. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4550. func (m *BatchMsgMutation) SuccessCleared() bool {
  4551. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4552. return ok
  4553. }
  4554. // ResetSuccess resets all changes to the "success" field.
  4555. func (m *BatchMsgMutation) ResetSuccess() {
  4556. m.success = nil
  4557. m.addsuccess = nil
  4558. delete(m.clearedFields, batchmsg.FieldSuccess)
  4559. }
  4560. // SetFail sets the "fail" field.
  4561. func (m *BatchMsgMutation) SetFail(i int32) {
  4562. m.fail = &i
  4563. m.addfail = nil
  4564. }
  4565. // Fail returns the value of the "fail" field in the mutation.
  4566. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4567. v := m.fail
  4568. if v == nil {
  4569. return
  4570. }
  4571. return *v, true
  4572. }
  4573. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4574. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4576. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4577. if !m.op.Is(OpUpdateOne) {
  4578. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4579. }
  4580. if m.id == nil || m.oldValue == nil {
  4581. return v, errors.New("OldFail requires an ID field in the mutation")
  4582. }
  4583. oldValue, err := m.oldValue(ctx)
  4584. if err != nil {
  4585. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4586. }
  4587. return oldValue.Fail, nil
  4588. }
  4589. // AddFail adds i to the "fail" field.
  4590. func (m *BatchMsgMutation) AddFail(i int32) {
  4591. if m.addfail != nil {
  4592. *m.addfail += i
  4593. } else {
  4594. m.addfail = &i
  4595. }
  4596. }
  4597. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4598. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4599. v := m.addfail
  4600. if v == nil {
  4601. return
  4602. }
  4603. return *v, true
  4604. }
  4605. // ClearFail clears the value of the "fail" field.
  4606. func (m *BatchMsgMutation) ClearFail() {
  4607. m.fail = nil
  4608. m.addfail = nil
  4609. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4610. }
  4611. // FailCleared returns if the "fail" field was cleared in this mutation.
  4612. func (m *BatchMsgMutation) FailCleared() bool {
  4613. _, ok := m.clearedFields[batchmsg.FieldFail]
  4614. return ok
  4615. }
  4616. // ResetFail resets all changes to the "fail" field.
  4617. func (m *BatchMsgMutation) ResetFail() {
  4618. m.fail = nil
  4619. m.addfail = nil
  4620. delete(m.clearedFields, batchmsg.FieldFail)
  4621. }
  4622. // SetStartTime sets the "start_time" field.
  4623. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4624. m.start_time = &t
  4625. }
  4626. // StartTime returns the value of the "start_time" field in the mutation.
  4627. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4628. v := m.start_time
  4629. if v == nil {
  4630. return
  4631. }
  4632. return *v, true
  4633. }
  4634. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4635. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4637. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4638. if !m.op.Is(OpUpdateOne) {
  4639. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4640. }
  4641. if m.id == nil || m.oldValue == nil {
  4642. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4643. }
  4644. oldValue, err := m.oldValue(ctx)
  4645. if err != nil {
  4646. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4647. }
  4648. return oldValue.StartTime, nil
  4649. }
  4650. // ClearStartTime clears the value of the "start_time" field.
  4651. func (m *BatchMsgMutation) ClearStartTime() {
  4652. m.start_time = nil
  4653. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4654. }
  4655. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4656. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4657. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4658. return ok
  4659. }
  4660. // ResetStartTime resets all changes to the "start_time" field.
  4661. func (m *BatchMsgMutation) ResetStartTime() {
  4662. m.start_time = nil
  4663. delete(m.clearedFields, batchmsg.FieldStartTime)
  4664. }
  4665. // SetStopTime sets the "stop_time" field.
  4666. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4667. m.stop_time = &t
  4668. }
  4669. // StopTime returns the value of the "stop_time" field in the mutation.
  4670. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4671. v := m.stop_time
  4672. if v == nil {
  4673. return
  4674. }
  4675. return *v, true
  4676. }
  4677. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4678. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4680. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4681. if !m.op.Is(OpUpdateOne) {
  4682. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4683. }
  4684. if m.id == nil || m.oldValue == nil {
  4685. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4686. }
  4687. oldValue, err := m.oldValue(ctx)
  4688. if err != nil {
  4689. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4690. }
  4691. return oldValue.StopTime, nil
  4692. }
  4693. // ClearStopTime clears the value of the "stop_time" field.
  4694. func (m *BatchMsgMutation) ClearStopTime() {
  4695. m.stop_time = nil
  4696. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4697. }
  4698. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4699. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4700. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4701. return ok
  4702. }
  4703. // ResetStopTime resets all changes to the "stop_time" field.
  4704. func (m *BatchMsgMutation) ResetStopTime() {
  4705. m.stop_time = nil
  4706. delete(m.clearedFields, batchmsg.FieldStopTime)
  4707. }
  4708. // SetSendTime sets the "send_time" field.
  4709. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4710. m.send_time = &t
  4711. }
  4712. // SendTime returns the value of the "send_time" field in the mutation.
  4713. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4714. v := m.send_time
  4715. if v == nil {
  4716. return
  4717. }
  4718. return *v, true
  4719. }
  4720. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4721. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4723. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4724. if !m.op.Is(OpUpdateOne) {
  4725. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4726. }
  4727. if m.id == nil || m.oldValue == nil {
  4728. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4729. }
  4730. oldValue, err := m.oldValue(ctx)
  4731. if err != nil {
  4732. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4733. }
  4734. return oldValue.SendTime, nil
  4735. }
  4736. // ClearSendTime clears the value of the "send_time" field.
  4737. func (m *BatchMsgMutation) ClearSendTime() {
  4738. m.send_time = nil
  4739. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4740. }
  4741. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4742. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4743. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4744. return ok
  4745. }
  4746. // ResetSendTime resets all changes to the "send_time" field.
  4747. func (m *BatchMsgMutation) ResetSendTime() {
  4748. m.send_time = nil
  4749. delete(m.clearedFields, batchmsg.FieldSendTime)
  4750. }
  4751. // SetType sets the "type" field.
  4752. func (m *BatchMsgMutation) SetType(i int32) {
  4753. m._type = &i
  4754. m.add_type = nil
  4755. }
  4756. // GetType returns the value of the "type" field in the mutation.
  4757. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4758. v := m._type
  4759. if v == nil {
  4760. return
  4761. }
  4762. return *v, true
  4763. }
  4764. // OldType returns the old "type" field's value of the BatchMsg entity.
  4765. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4767. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4768. if !m.op.Is(OpUpdateOne) {
  4769. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4770. }
  4771. if m.id == nil || m.oldValue == nil {
  4772. return v, errors.New("OldType requires an ID field in the mutation")
  4773. }
  4774. oldValue, err := m.oldValue(ctx)
  4775. if err != nil {
  4776. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4777. }
  4778. return oldValue.Type, nil
  4779. }
  4780. // AddType adds i to the "type" field.
  4781. func (m *BatchMsgMutation) AddType(i int32) {
  4782. if m.add_type != nil {
  4783. *m.add_type += i
  4784. } else {
  4785. m.add_type = &i
  4786. }
  4787. }
  4788. // AddedType returns the value that was added to the "type" field in this mutation.
  4789. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4790. v := m.add_type
  4791. if v == nil {
  4792. return
  4793. }
  4794. return *v, true
  4795. }
  4796. // ClearType clears the value of the "type" field.
  4797. func (m *BatchMsgMutation) ClearType() {
  4798. m._type = nil
  4799. m.add_type = nil
  4800. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4801. }
  4802. // TypeCleared returns if the "type" field was cleared in this mutation.
  4803. func (m *BatchMsgMutation) TypeCleared() bool {
  4804. _, ok := m.clearedFields[batchmsg.FieldType]
  4805. return ok
  4806. }
  4807. // ResetType resets all changes to the "type" field.
  4808. func (m *BatchMsgMutation) ResetType() {
  4809. m._type = nil
  4810. m.add_type = nil
  4811. delete(m.clearedFields, batchmsg.FieldType)
  4812. }
  4813. // SetOrganizationID sets the "organization_id" field.
  4814. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4815. m.organization_id = &u
  4816. m.addorganization_id = nil
  4817. }
  4818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4819. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4820. v := m.organization_id
  4821. if v == nil {
  4822. return
  4823. }
  4824. return *v, true
  4825. }
  4826. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4827. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4829. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4830. if !m.op.Is(OpUpdateOne) {
  4831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4832. }
  4833. if m.id == nil || m.oldValue == nil {
  4834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4835. }
  4836. oldValue, err := m.oldValue(ctx)
  4837. if err != nil {
  4838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4839. }
  4840. return oldValue.OrganizationID, nil
  4841. }
  4842. // AddOrganizationID adds u to the "organization_id" field.
  4843. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4844. if m.addorganization_id != nil {
  4845. *m.addorganization_id += u
  4846. } else {
  4847. m.addorganization_id = &u
  4848. }
  4849. }
  4850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4851. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4852. v := m.addorganization_id
  4853. if v == nil {
  4854. return
  4855. }
  4856. return *v, true
  4857. }
  4858. // ResetOrganizationID resets all changes to the "organization_id" field.
  4859. func (m *BatchMsgMutation) ResetOrganizationID() {
  4860. m.organization_id = nil
  4861. m.addorganization_id = nil
  4862. }
  4863. // Where appends a list predicates to the BatchMsgMutation builder.
  4864. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4865. m.predicates = append(m.predicates, ps...)
  4866. }
  4867. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4868. // users can use type-assertion to append predicates that do not depend on any generated package.
  4869. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4870. p := make([]predicate.BatchMsg, len(ps))
  4871. for i := range ps {
  4872. p[i] = ps[i]
  4873. }
  4874. m.Where(p...)
  4875. }
  4876. // Op returns the operation name.
  4877. func (m *BatchMsgMutation) Op() Op {
  4878. return m.op
  4879. }
  4880. // SetOp allows setting the mutation operation.
  4881. func (m *BatchMsgMutation) SetOp(op Op) {
  4882. m.op = op
  4883. }
  4884. // Type returns the node type of this mutation (BatchMsg).
  4885. func (m *BatchMsgMutation) Type() string {
  4886. return m.typ
  4887. }
  4888. // Fields returns all fields that were changed during this mutation. Note that in
  4889. // order to get all numeric fields that were incremented/decremented, call
  4890. // AddedFields().
  4891. func (m *BatchMsgMutation) Fields() []string {
  4892. fields := make([]string, 0, 18)
  4893. if m.created_at != nil {
  4894. fields = append(fields, batchmsg.FieldCreatedAt)
  4895. }
  4896. if m.updated_at != nil {
  4897. fields = append(fields, batchmsg.FieldUpdatedAt)
  4898. }
  4899. if m.deleted_at != nil {
  4900. fields = append(fields, batchmsg.FieldDeletedAt)
  4901. }
  4902. if m.status != nil {
  4903. fields = append(fields, batchmsg.FieldStatus)
  4904. }
  4905. if m.batch_no != nil {
  4906. fields = append(fields, batchmsg.FieldBatchNo)
  4907. }
  4908. if m.task_name != nil {
  4909. fields = append(fields, batchmsg.FieldTaskName)
  4910. }
  4911. if m.fromwxid != nil {
  4912. fields = append(fields, batchmsg.FieldFromwxid)
  4913. }
  4914. if m.msg != nil {
  4915. fields = append(fields, batchmsg.FieldMsg)
  4916. }
  4917. if m.tag != nil {
  4918. fields = append(fields, batchmsg.FieldTag)
  4919. }
  4920. if m.tagids != nil {
  4921. fields = append(fields, batchmsg.FieldTagids)
  4922. }
  4923. if m.total != nil {
  4924. fields = append(fields, batchmsg.FieldTotal)
  4925. }
  4926. if m.success != nil {
  4927. fields = append(fields, batchmsg.FieldSuccess)
  4928. }
  4929. if m.fail != nil {
  4930. fields = append(fields, batchmsg.FieldFail)
  4931. }
  4932. if m.start_time != nil {
  4933. fields = append(fields, batchmsg.FieldStartTime)
  4934. }
  4935. if m.stop_time != nil {
  4936. fields = append(fields, batchmsg.FieldStopTime)
  4937. }
  4938. if m.send_time != nil {
  4939. fields = append(fields, batchmsg.FieldSendTime)
  4940. }
  4941. if m._type != nil {
  4942. fields = append(fields, batchmsg.FieldType)
  4943. }
  4944. if m.organization_id != nil {
  4945. fields = append(fields, batchmsg.FieldOrganizationID)
  4946. }
  4947. return fields
  4948. }
  4949. // Field returns the value of a field with the given name. The second boolean
  4950. // return value indicates that this field was not set, or was not defined in the
  4951. // schema.
  4952. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4953. switch name {
  4954. case batchmsg.FieldCreatedAt:
  4955. return m.CreatedAt()
  4956. case batchmsg.FieldUpdatedAt:
  4957. return m.UpdatedAt()
  4958. case batchmsg.FieldDeletedAt:
  4959. return m.DeletedAt()
  4960. case batchmsg.FieldStatus:
  4961. return m.Status()
  4962. case batchmsg.FieldBatchNo:
  4963. return m.BatchNo()
  4964. case batchmsg.FieldTaskName:
  4965. return m.TaskName()
  4966. case batchmsg.FieldFromwxid:
  4967. return m.Fromwxid()
  4968. case batchmsg.FieldMsg:
  4969. return m.Msg()
  4970. case batchmsg.FieldTag:
  4971. return m.Tag()
  4972. case batchmsg.FieldTagids:
  4973. return m.Tagids()
  4974. case batchmsg.FieldTotal:
  4975. return m.Total()
  4976. case batchmsg.FieldSuccess:
  4977. return m.Success()
  4978. case batchmsg.FieldFail:
  4979. return m.Fail()
  4980. case batchmsg.FieldStartTime:
  4981. return m.StartTime()
  4982. case batchmsg.FieldStopTime:
  4983. return m.StopTime()
  4984. case batchmsg.FieldSendTime:
  4985. return m.SendTime()
  4986. case batchmsg.FieldType:
  4987. return m.GetType()
  4988. case batchmsg.FieldOrganizationID:
  4989. return m.OrganizationID()
  4990. }
  4991. return nil, false
  4992. }
  4993. // OldField returns the old value of the field from the database. An error is
  4994. // returned if the mutation operation is not UpdateOne, or the query to the
  4995. // database failed.
  4996. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4997. switch name {
  4998. case batchmsg.FieldCreatedAt:
  4999. return m.OldCreatedAt(ctx)
  5000. case batchmsg.FieldUpdatedAt:
  5001. return m.OldUpdatedAt(ctx)
  5002. case batchmsg.FieldDeletedAt:
  5003. return m.OldDeletedAt(ctx)
  5004. case batchmsg.FieldStatus:
  5005. return m.OldStatus(ctx)
  5006. case batchmsg.FieldBatchNo:
  5007. return m.OldBatchNo(ctx)
  5008. case batchmsg.FieldTaskName:
  5009. return m.OldTaskName(ctx)
  5010. case batchmsg.FieldFromwxid:
  5011. return m.OldFromwxid(ctx)
  5012. case batchmsg.FieldMsg:
  5013. return m.OldMsg(ctx)
  5014. case batchmsg.FieldTag:
  5015. return m.OldTag(ctx)
  5016. case batchmsg.FieldTagids:
  5017. return m.OldTagids(ctx)
  5018. case batchmsg.FieldTotal:
  5019. return m.OldTotal(ctx)
  5020. case batchmsg.FieldSuccess:
  5021. return m.OldSuccess(ctx)
  5022. case batchmsg.FieldFail:
  5023. return m.OldFail(ctx)
  5024. case batchmsg.FieldStartTime:
  5025. return m.OldStartTime(ctx)
  5026. case batchmsg.FieldStopTime:
  5027. return m.OldStopTime(ctx)
  5028. case batchmsg.FieldSendTime:
  5029. return m.OldSendTime(ctx)
  5030. case batchmsg.FieldType:
  5031. return m.OldType(ctx)
  5032. case batchmsg.FieldOrganizationID:
  5033. return m.OldOrganizationID(ctx)
  5034. }
  5035. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5036. }
  5037. // SetField sets the value of a field with the given name. It returns an error if
  5038. // the field is not defined in the schema, or if the type mismatched the field
  5039. // type.
  5040. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5041. switch name {
  5042. case batchmsg.FieldCreatedAt:
  5043. v, ok := value.(time.Time)
  5044. if !ok {
  5045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5046. }
  5047. m.SetCreatedAt(v)
  5048. return nil
  5049. case batchmsg.FieldUpdatedAt:
  5050. v, ok := value.(time.Time)
  5051. if !ok {
  5052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5053. }
  5054. m.SetUpdatedAt(v)
  5055. return nil
  5056. case batchmsg.FieldDeletedAt:
  5057. v, ok := value.(time.Time)
  5058. if !ok {
  5059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5060. }
  5061. m.SetDeletedAt(v)
  5062. return nil
  5063. case batchmsg.FieldStatus:
  5064. v, ok := value.(uint8)
  5065. if !ok {
  5066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5067. }
  5068. m.SetStatus(v)
  5069. return nil
  5070. case batchmsg.FieldBatchNo:
  5071. v, ok := value.(string)
  5072. if !ok {
  5073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5074. }
  5075. m.SetBatchNo(v)
  5076. return nil
  5077. case batchmsg.FieldTaskName:
  5078. v, ok := value.(string)
  5079. if !ok {
  5080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5081. }
  5082. m.SetTaskName(v)
  5083. return nil
  5084. case batchmsg.FieldFromwxid:
  5085. v, ok := value.(string)
  5086. if !ok {
  5087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5088. }
  5089. m.SetFromwxid(v)
  5090. return nil
  5091. case batchmsg.FieldMsg:
  5092. v, ok := value.(string)
  5093. if !ok {
  5094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5095. }
  5096. m.SetMsg(v)
  5097. return nil
  5098. case batchmsg.FieldTag:
  5099. v, ok := value.(string)
  5100. if !ok {
  5101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5102. }
  5103. m.SetTag(v)
  5104. return nil
  5105. case batchmsg.FieldTagids:
  5106. v, ok := value.(string)
  5107. if !ok {
  5108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5109. }
  5110. m.SetTagids(v)
  5111. return nil
  5112. case batchmsg.FieldTotal:
  5113. v, ok := value.(int32)
  5114. if !ok {
  5115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5116. }
  5117. m.SetTotal(v)
  5118. return nil
  5119. case batchmsg.FieldSuccess:
  5120. v, ok := value.(int32)
  5121. if !ok {
  5122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5123. }
  5124. m.SetSuccess(v)
  5125. return nil
  5126. case batchmsg.FieldFail:
  5127. v, ok := value.(int32)
  5128. if !ok {
  5129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5130. }
  5131. m.SetFail(v)
  5132. return nil
  5133. case batchmsg.FieldStartTime:
  5134. v, ok := value.(time.Time)
  5135. if !ok {
  5136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5137. }
  5138. m.SetStartTime(v)
  5139. return nil
  5140. case batchmsg.FieldStopTime:
  5141. v, ok := value.(time.Time)
  5142. if !ok {
  5143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5144. }
  5145. m.SetStopTime(v)
  5146. return nil
  5147. case batchmsg.FieldSendTime:
  5148. v, ok := value.(time.Time)
  5149. if !ok {
  5150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5151. }
  5152. m.SetSendTime(v)
  5153. return nil
  5154. case batchmsg.FieldType:
  5155. v, ok := value.(int32)
  5156. if !ok {
  5157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5158. }
  5159. m.SetType(v)
  5160. return nil
  5161. case batchmsg.FieldOrganizationID:
  5162. v, ok := value.(uint64)
  5163. if !ok {
  5164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5165. }
  5166. m.SetOrganizationID(v)
  5167. return nil
  5168. }
  5169. return fmt.Errorf("unknown BatchMsg field %s", name)
  5170. }
  5171. // AddedFields returns all numeric fields that were incremented/decremented during
  5172. // this mutation.
  5173. func (m *BatchMsgMutation) AddedFields() []string {
  5174. var fields []string
  5175. if m.addstatus != nil {
  5176. fields = append(fields, batchmsg.FieldStatus)
  5177. }
  5178. if m.addtotal != nil {
  5179. fields = append(fields, batchmsg.FieldTotal)
  5180. }
  5181. if m.addsuccess != nil {
  5182. fields = append(fields, batchmsg.FieldSuccess)
  5183. }
  5184. if m.addfail != nil {
  5185. fields = append(fields, batchmsg.FieldFail)
  5186. }
  5187. if m.add_type != nil {
  5188. fields = append(fields, batchmsg.FieldType)
  5189. }
  5190. if m.addorganization_id != nil {
  5191. fields = append(fields, batchmsg.FieldOrganizationID)
  5192. }
  5193. return fields
  5194. }
  5195. // AddedField returns the numeric value that was incremented/decremented on a field
  5196. // with the given name. The second boolean return value indicates that this field
  5197. // was not set, or was not defined in the schema.
  5198. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5199. switch name {
  5200. case batchmsg.FieldStatus:
  5201. return m.AddedStatus()
  5202. case batchmsg.FieldTotal:
  5203. return m.AddedTotal()
  5204. case batchmsg.FieldSuccess:
  5205. return m.AddedSuccess()
  5206. case batchmsg.FieldFail:
  5207. return m.AddedFail()
  5208. case batchmsg.FieldType:
  5209. return m.AddedType()
  5210. case batchmsg.FieldOrganizationID:
  5211. return m.AddedOrganizationID()
  5212. }
  5213. return nil, false
  5214. }
  5215. // AddField adds the value to the field with the given name. It returns an error if
  5216. // the field is not defined in the schema, or if the type mismatched the field
  5217. // type.
  5218. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5219. switch name {
  5220. case batchmsg.FieldStatus:
  5221. v, ok := value.(int8)
  5222. if !ok {
  5223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5224. }
  5225. m.AddStatus(v)
  5226. return nil
  5227. case batchmsg.FieldTotal:
  5228. v, ok := value.(int32)
  5229. if !ok {
  5230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5231. }
  5232. m.AddTotal(v)
  5233. return nil
  5234. case batchmsg.FieldSuccess:
  5235. v, ok := value.(int32)
  5236. if !ok {
  5237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5238. }
  5239. m.AddSuccess(v)
  5240. return nil
  5241. case batchmsg.FieldFail:
  5242. v, ok := value.(int32)
  5243. if !ok {
  5244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5245. }
  5246. m.AddFail(v)
  5247. return nil
  5248. case batchmsg.FieldType:
  5249. v, ok := value.(int32)
  5250. if !ok {
  5251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5252. }
  5253. m.AddType(v)
  5254. return nil
  5255. case batchmsg.FieldOrganizationID:
  5256. v, ok := value.(int64)
  5257. if !ok {
  5258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5259. }
  5260. m.AddOrganizationID(v)
  5261. return nil
  5262. }
  5263. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5264. }
  5265. // ClearedFields returns all nullable fields that were cleared during this
  5266. // mutation.
  5267. func (m *BatchMsgMutation) ClearedFields() []string {
  5268. var fields []string
  5269. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5270. fields = append(fields, batchmsg.FieldDeletedAt)
  5271. }
  5272. if m.FieldCleared(batchmsg.FieldStatus) {
  5273. fields = append(fields, batchmsg.FieldStatus)
  5274. }
  5275. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5276. fields = append(fields, batchmsg.FieldBatchNo)
  5277. }
  5278. if m.FieldCleared(batchmsg.FieldTaskName) {
  5279. fields = append(fields, batchmsg.FieldTaskName)
  5280. }
  5281. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5282. fields = append(fields, batchmsg.FieldFromwxid)
  5283. }
  5284. if m.FieldCleared(batchmsg.FieldMsg) {
  5285. fields = append(fields, batchmsg.FieldMsg)
  5286. }
  5287. if m.FieldCleared(batchmsg.FieldTag) {
  5288. fields = append(fields, batchmsg.FieldTag)
  5289. }
  5290. if m.FieldCleared(batchmsg.FieldTagids) {
  5291. fields = append(fields, batchmsg.FieldTagids)
  5292. }
  5293. if m.FieldCleared(batchmsg.FieldTotal) {
  5294. fields = append(fields, batchmsg.FieldTotal)
  5295. }
  5296. if m.FieldCleared(batchmsg.FieldSuccess) {
  5297. fields = append(fields, batchmsg.FieldSuccess)
  5298. }
  5299. if m.FieldCleared(batchmsg.FieldFail) {
  5300. fields = append(fields, batchmsg.FieldFail)
  5301. }
  5302. if m.FieldCleared(batchmsg.FieldStartTime) {
  5303. fields = append(fields, batchmsg.FieldStartTime)
  5304. }
  5305. if m.FieldCleared(batchmsg.FieldStopTime) {
  5306. fields = append(fields, batchmsg.FieldStopTime)
  5307. }
  5308. if m.FieldCleared(batchmsg.FieldSendTime) {
  5309. fields = append(fields, batchmsg.FieldSendTime)
  5310. }
  5311. if m.FieldCleared(batchmsg.FieldType) {
  5312. fields = append(fields, batchmsg.FieldType)
  5313. }
  5314. return fields
  5315. }
  5316. // FieldCleared returns a boolean indicating if a field with the given name was
  5317. // cleared in this mutation.
  5318. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5319. _, ok := m.clearedFields[name]
  5320. return ok
  5321. }
  5322. // ClearField clears the value of the field with the given name. It returns an
  5323. // error if the field is not defined in the schema.
  5324. func (m *BatchMsgMutation) ClearField(name string) error {
  5325. switch name {
  5326. case batchmsg.FieldDeletedAt:
  5327. m.ClearDeletedAt()
  5328. return nil
  5329. case batchmsg.FieldStatus:
  5330. m.ClearStatus()
  5331. return nil
  5332. case batchmsg.FieldBatchNo:
  5333. m.ClearBatchNo()
  5334. return nil
  5335. case batchmsg.FieldTaskName:
  5336. m.ClearTaskName()
  5337. return nil
  5338. case batchmsg.FieldFromwxid:
  5339. m.ClearFromwxid()
  5340. return nil
  5341. case batchmsg.FieldMsg:
  5342. m.ClearMsg()
  5343. return nil
  5344. case batchmsg.FieldTag:
  5345. m.ClearTag()
  5346. return nil
  5347. case batchmsg.FieldTagids:
  5348. m.ClearTagids()
  5349. return nil
  5350. case batchmsg.FieldTotal:
  5351. m.ClearTotal()
  5352. return nil
  5353. case batchmsg.FieldSuccess:
  5354. m.ClearSuccess()
  5355. return nil
  5356. case batchmsg.FieldFail:
  5357. m.ClearFail()
  5358. return nil
  5359. case batchmsg.FieldStartTime:
  5360. m.ClearStartTime()
  5361. return nil
  5362. case batchmsg.FieldStopTime:
  5363. m.ClearStopTime()
  5364. return nil
  5365. case batchmsg.FieldSendTime:
  5366. m.ClearSendTime()
  5367. return nil
  5368. case batchmsg.FieldType:
  5369. m.ClearType()
  5370. return nil
  5371. }
  5372. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5373. }
  5374. // ResetField resets all changes in the mutation for the field with the given name.
  5375. // It returns an error if the field is not defined in the schema.
  5376. func (m *BatchMsgMutation) ResetField(name string) error {
  5377. switch name {
  5378. case batchmsg.FieldCreatedAt:
  5379. m.ResetCreatedAt()
  5380. return nil
  5381. case batchmsg.FieldUpdatedAt:
  5382. m.ResetUpdatedAt()
  5383. return nil
  5384. case batchmsg.FieldDeletedAt:
  5385. m.ResetDeletedAt()
  5386. return nil
  5387. case batchmsg.FieldStatus:
  5388. m.ResetStatus()
  5389. return nil
  5390. case batchmsg.FieldBatchNo:
  5391. m.ResetBatchNo()
  5392. return nil
  5393. case batchmsg.FieldTaskName:
  5394. m.ResetTaskName()
  5395. return nil
  5396. case batchmsg.FieldFromwxid:
  5397. m.ResetFromwxid()
  5398. return nil
  5399. case batchmsg.FieldMsg:
  5400. m.ResetMsg()
  5401. return nil
  5402. case batchmsg.FieldTag:
  5403. m.ResetTag()
  5404. return nil
  5405. case batchmsg.FieldTagids:
  5406. m.ResetTagids()
  5407. return nil
  5408. case batchmsg.FieldTotal:
  5409. m.ResetTotal()
  5410. return nil
  5411. case batchmsg.FieldSuccess:
  5412. m.ResetSuccess()
  5413. return nil
  5414. case batchmsg.FieldFail:
  5415. m.ResetFail()
  5416. return nil
  5417. case batchmsg.FieldStartTime:
  5418. m.ResetStartTime()
  5419. return nil
  5420. case batchmsg.FieldStopTime:
  5421. m.ResetStopTime()
  5422. return nil
  5423. case batchmsg.FieldSendTime:
  5424. m.ResetSendTime()
  5425. return nil
  5426. case batchmsg.FieldType:
  5427. m.ResetType()
  5428. return nil
  5429. case batchmsg.FieldOrganizationID:
  5430. m.ResetOrganizationID()
  5431. return nil
  5432. }
  5433. return fmt.Errorf("unknown BatchMsg field %s", name)
  5434. }
  5435. // AddedEdges returns all edge names that were set/added in this mutation.
  5436. func (m *BatchMsgMutation) AddedEdges() []string {
  5437. edges := make([]string, 0, 0)
  5438. return edges
  5439. }
  5440. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5441. // name in this mutation.
  5442. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5443. return nil
  5444. }
  5445. // RemovedEdges returns all edge names that were removed in this mutation.
  5446. func (m *BatchMsgMutation) RemovedEdges() []string {
  5447. edges := make([]string, 0, 0)
  5448. return edges
  5449. }
  5450. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5451. // the given name in this mutation.
  5452. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5453. return nil
  5454. }
  5455. // ClearedEdges returns all edge names that were cleared in this mutation.
  5456. func (m *BatchMsgMutation) ClearedEdges() []string {
  5457. edges := make([]string, 0, 0)
  5458. return edges
  5459. }
  5460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5461. // was cleared in this mutation.
  5462. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5463. return false
  5464. }
  5465. // ClearEdge clears the value of the edge with the given name. It returns an error
  5466. // if that edge is not defined in the schema.
  5467. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5468. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5469. }
  5470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5471. // It returns an error if the edge is not defined in the schema.
  5472. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5473. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5474. }
  5475. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5476. type CategoryMutation struct {
  5477. config
  5478. op Op
  5479. typ string
  5480. id *uint64
  5481. created_at *time.Time
  5482. updated_at *time.Time
  5483. deleted_at *time.Time
  5484. name *string
  5485. organization_id *uint64
  5486. addorganization_id *int64
  5487. clearedFields map[string]struct{}
  5488. done bool
  5489. oldValue func(context.Context) (*Category, error)
  5490. predicates []predicate.Category
  5491. }
  5492. var _ ent.Mutation = (*CategoryMutation)(nil)
  5493. // categoryOption allows management of the mutation configuration using functional options.
  5494. type categoryOption func(*CategoryMutation)
  5495. // newCategoryMutation creates new mutation for the Category entity.
  5496. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5497. m := &CategoryMutation{
  5498. config: c,
  5499. op: op,
  5500. typ: TypeCategory,
  5501. clearedFields: make(map[string]struct{}),
  5502. }
  5503. for _, opt := range opts {
  5504. opt(m)
  5505. }
  5506. return m
  5507. }
  5508. // withCategoryID sets the ID field of the mutation.
  5509. func withCategoryID(id uint64) categoryOption {
  5510. return func(m *CategoryMutation) {
  5511. var (
  5512. err error
  5513. once sync.Once
  5514. value *Category
  5515. )
  5516. m.oldValue = func(ctx context.Context) (*Category, error) {
  5517. once.Do(func() {
  5518. if m.done {
  5519. err = errors.New("querying old values post mutation is not allowed")
  5520. } else {
  5521. value, err = m.Client().Category.Get(ctx, id)
  5522. }
  5523. })
  5524. return value, err
  5525. }
  5526. m.id = &id
  5527. }
  5528. }
  5529. // withCategory sets the old Category of the mutation.
  5530. func withCategory(node *Category) categoryOption {
  5531. return func(m *CategoryMutation) {
  5532. m.oldValue = func(context.Context) (*Category, error) {
  5533. return node, nil
  5534. }
  5535. m.id = &node.ID
  5536. }
  5537. }
  5538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5539. // executed in a transaction (ent.Tx), a transactional client is returned.
  5540. func (m CategoryMutation) Client() *Client {
  5541. client := &Client{config: m.config}
  5542. client.init()
  5543. return client
  5544. }
  5545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5546. // it returns an error otherwise.
  5547. func (m CategoryMutation) Tx() (*Tx, error) {
  5548. if _, ok := m.driver.(*txDriver); !ok {
  5549. return nil, errors.New("ent: mutation is not running in a transaction")
  5550. }
  5551. tx := &Tx{config: m.config}
  5552. tx.init()
  5553. return tx, nil
  5554. }
  5555. // SetID sets the value of the id field. Note that this
  5556. // operation is only accepted on creation of Category entities.
  5557. func (m *CategoryMutation) SetID(id uint64) {
  5558. m.id = &id
  5559. }
  5560. // ID returns the ID value in the mutation. Note that the ID is only available
  5561. // if it was provided to the builder or after it was returned from the database.
  5562. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5563. if m.id == nil {
  5564. return
  5565. }
  5566. return *m.id, true
  5567. }
  5568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5569. // That means, if the mutation is applied within a transaction with an isolation level such
  5570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5571. // or updated by the mutation.
  5572. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5573. switch {
  5574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5575. id, exists := m.ID()
  5576. if exists {
  5577. return []uint64{id}, nil
  5578. }
  5579. fallthrough
  5580. case m.op.Is(OpUpdate | OpDelete):
  5581. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5582. default:
  5583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5584. }
  5585. }
  5586. // SetCreatedAt sets the "created_at" field.
  5587. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5588. m.created_at = &t
  5589. }
  5590. // CreatedAt returns the value of the "created_at" field in the mutation.
  5591. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5592. v := m.created_at
  5593. if v == nil {
  5594. return
  5595. }
  5596. return *v, true
  5597. }
  5598. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5599. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5601. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5602. if !m.op.Is(OpUpdateOne) {
  5603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5604. }
  5605. if m.id == nil || m.oldValue == nil {
  5606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5607. }
  5608. oldValue, err := m.oldValue(ctx)
  5609. if err != nil {
  5610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5611. }
  5612. return oldValue.CreatedAt, nil
  5613. }
  5614. // ResetCreatedAt resets all changes to the "created_at" field.
  5615. func (m *CategoryMutation) ResetCreatedAt() {
  5616. m.created_at = nil
  5617. }
  5618. // SetUpdatedAt sets the "updated_at" field.
  5619. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5620. m.updated_at = &t
  5621. }
  5622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5623. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5624. v := m.updated_at
  5625. if v == nil {
  5626. return
  5627. }
  5628. return *v, true
  5629. }
  5630. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5631. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5633. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5634. if !m.op.Is(OpUpdateOne) {
  5635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5636. }
  5637. if m.id == nil || m.oldValue == nil {
  5638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5639. }
  5640. oldValue, err := m.oldValue(ctx)
  5641. if err != nil {
  5642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5643. }
  5644. return oldValue.UpdatedAt, nil
  5645. }
  5646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5647. func (m *CategoryMutation) ResetUpdatedAt() {
  5648. m.updated_at = nil
  5649. }
  5650. // SetDeletedAt sets the "deleted_at" field.
  5651. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5652. m.deleted_at = &t
  5653. }
  5654. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5655. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5656. v := m.deleted_at
  5657. if v == nil {
  5658. return
  5659. }
  5660. return *v, true
  5661. }
  5662. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5663. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5665. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5666. if !m.op.Is(OpUpdateOne) {
  5667. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5668. }
  5669. if m.id == nil || m.oldValue == nil {
  5670. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5671. }
  5672. oldValue, err := m.oldValue(ctx)
  5673. if err != nil {
  5674. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5675. }
  5676. return oldValue.DeletedAt, nil
  5677. }
  5678. // ClearDeletedAt clears the value of the "deleted_at" field.
  5679. func (m *CategoryMutation) ClearDeletedAt() {
  5680. m.deleted_at = nil
  5681. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5682. }
  5683. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5684. func (m *CategoryMutation) DeletedAtCleared() bool {
  5685. _, ok := m.clearedFields[category.FieldDeletedAt]
  5686. return ok
  5687. }
  5688. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5689. func (m *CategoryMutation) ResetDeletedAt() {
  5690. m.deleted_at = nil
  5691. delete(m.clearedFields, category.FieldDeletedAt)
  5692. }
  5693. // SetName sets the "name" field.
  5694. func (m *CategoryMutation) SetName(s string) {
  5695. m.name = &s
  5696. }
  5697. // Name returns the value of the "name" field in the mutation.
  5698. func (m *CategoryMutation) Name() (r string, exists bool) {
  5699. v := m.name
  5700. if v == nil {
  5701. return
  5702. }
  5703. return *v, true
  5704. }
  5705. // OldName returns the old "name" field's value of the Category entity.
  5706. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5708. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5709. if !m.op.Is(OpUpdateOne) {
  5710. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5711. }
  5712. if m.id == nil || m.oldValue == nil {
  5713. return v, errors.New("OldName requires an ID field in the mutation")
  5714. }
  5715. oldValue, err := m.oldValue(ctx)
  5716. if err != nil {
  5717. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5718. }
  5719. return oldValue.Name, nil
  5720. }
  5721. // ResetName resets all changes to the "name" field.
  5722. func (m *CategoryMutation) ResetName() {
  5723. m.name = nil
  5724. }
  5725. // SetOrganizationID sets the "organization_id" field.
  5726. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5727. m.organization_id = &u
  5728. m.addorganization_id = nil
  5729. }
  5730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5731. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5732. v := m.organization_id
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  5751. }
  5752. return oldValue.OrganizationID, nil
  5753. }
  5754. // AddOrganizationID adds u to the "organization_id" field.
  5755. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5756. if m.addorganization_id != nil {
  5757. *m.addorganization_id += u
  5758. } else {
  5759. m.addorganization_id = &u
  5760. }
  5761. }
  5762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5763. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5764. v := m.addorganization_id
  5765. if v == nil {
  5766. return
  5767. }
  5768. return *v, true
  5769. }
  5770. // ResetOrganizationID resets all changes to the "organization_id" field.
  5771. func (m *CategoryMutation) ResetOrganizationID() {
  5772. m.organization_id = nil
  5773. m.addorganization_id = nil
  5774. }
  5775. // Where appends a list predicates to the CategoryMutation builder.
  5776. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5777. m.predicates = append(m.predicates, ps...)
  5778. }
  5779. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5780. // users can use type-assertion to append predicates that do not depend on any generated package.
  5781. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5782. p := make([]predicate.Category, len(ps))
  5783. for i := range ps {
  5784. p[i] = ps[i]
  5785. }
  5786. m.Where(p...)
  5787. }
  5788. // Op returns the operation name.
  5789. func (m *CategoryMutation) Op() Op {
  5790. return m.op
  5791. }
  5792. // SetOp allows setting the mutation operation.
  5793. func (m *CategoryMutation) SetOp(op Op) {
  5794. m.op = op
  5795. }
  5796. // Type returns the node type of this mutation (Category).
  5797. func (m *CategoryMutation) Type() string {
  5798. return m.typ
  5799. }
  5800. // Fields returns all fields that were changed during this mutation. Note that in
  5801. // order to get all numeric fields that were incremented/decremented, call
  5802. // AddedFields().
  5803. func (m *CategoryMutation) Fields() []string {
  5804. fields := make([]string, 0, 5)
  5805. if m.created_at != nil {
  5806. fields = append(fields, category.FieldCreatedAt)
  5807. }
  5808. if m.updated_at != nil {
  5809. fields = append(fields, category.FieldUpdatedAt)
  5810. }
  5811. if m.deleted_at != nil {
  5812. fields = append(fields, category.FieldDeletedAt)
  5813. }
  5814. if m.name != nil {
  5815. fields = append(fields, category.FieldName)
  5816. }
  5817. if m.organization_id != nil {
  5818. fields = append(fields, category.FieldOrganizationID)
  5819. }
  5820. return fields
  5821. }
  5822. // Field returns the value of a field with the given name. The second boolean
  5823. // return value indicates that this field was not set, or was not defined in the
  5824. // schema.
  5825. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5826. switch name {
  5827. case category.FieldCreatedAt:
  5828. return m.CreatedAt()
  5829. case category.FieldUpdatedAt:
  5830. return m.UpdatedAt()
  5831. case category.FieldDeletedAt:
  5832. return m.DeletedAt()
  5833. case category.FieldName:
  5834. return m.Name()
  5835. case category.FieldOrganizationID:
  5836. return m.OrganizationID()
  5837. }
  5838. return nil, false
  5839. }
  5840. // OldField returns the old value of the field from the database. An error is
  5841. // returned if the mutation operation is not UpdateOne, or the query to the
  5842. // database failed.
  5843. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5844. switch name {
  5845. case category.FieldCreatedAt:
  5846. return m.OldCreatedAt(ctx)
  5847. case category.FieldUpdatedAt:
  5848. return m.OldUpdatedAt(ctx)
  5849. case category.FieldDeletedAt:
  5850. return m.OldDeletedAt(ctx)
  5851. case category.FieldName:
  5852. return m.OldName(ctx)
  5853. case category.FieldOrganizationID:
  5854. return m.OldOrganizationID(ctx)
  5855. }
  5856. return nil, fmt.Errorf("unknown Category field %s", name)
  5857. }
  5858. // SetField sets the value of a field with the given name. It returns an error if
  5859. // the field is not defined in the schema, or if the type mismatched the field
  5860. // type.
  5861. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5862. switch name {
  5863. case category.FieldCreatedAt:
  5864. v, ok := value.(time.Time)
  5865. if !ok {
  5866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5867. }
  5868. m.SetCreatedAt(v)
  5869. return nil
  5870. case category.FieldUpdatedAt:
  5871. v, ok := value.(time.Time)
  5872. if !ok {
  5873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5874. }
  5875. m.SetUpdatedAt(v)
  5876. return nil
  5877. case category.FieldDeletedAt:
  5878. v, ok := value.(time.Time)
  5879. if !ok {
  5880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5881. }
  5882. m.SetDeletedAt(v)
  5883. return nil
  5884. case category.FieldName:
  5885. v, ok := value.(string)
  5886. if !ok {
  5887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5888. }
  5889. m.SetName(v)
  5890. return nil
  5891. case category.FieldOrganizationID:
  5892. v, ok := value.(uint64)
  5893. if !ok {
  5894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5895. }
  5896. m.SetOrganizationID(v)
  5897. return nil
  5898. }
  5899. return fmt.Errorf("unknown Category field %s", name)
  5900. }
  5901. // AddedFields returns all numeric fields that were incremented/decremented during
  5902. // this mutation.
  5903. func (m *CategoryMutation) AddedFields() []string {
  5904. var fields []string
  5905. if m.addorganization_id != nil {
  5906. fields = append(fields, category.FieldOrganizationID)
  5907. }
  5908. return fields
  5909. }
  5910. // AddedField returns the numeric value that was incremented/decremented on a field
  5911. // with the given name. The second boolean return value indicates that this field
  5912. // was not set, or was not defined in the schema.
  5913. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5914. switch name {
  5915. case category.FieldOrganizationID:
  5916. return m.AddedOrganizationID()
  5917. }
  5918. return nil, false
  5919. }
  5920. // AddField adds the value to the field with the given name. It returns an error if
  5921. // the field is not defined in the schema, or if the type mismatched the field
  5922. // type.
  5923. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5924. switch name {
  5925. case category.FieldOrganizationID:
  5926. v, ok := value.(int64)
  5927. if !ok {
  5928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5929. }
  5930. m.AddOrganizationID(v)
  5931. return nil
  5932. }
  5933. return fmt.Errorf("unknown Category numeric field %s", name)
  5934. }
  5935. // ClearedFields returns all nullable fields that were cleared during this
  5936. // mutation.
  5937. func (m *CategoryMutation) ClearedFields() []string {
  5938. var fields []string
  5939. if m.FieldCleared(category.FieldDeletedAt) {
  5940. fields = append(fields, category.FieldDeletedAt)
  5941. }
  5942. return fields
  5943. }
  5944. // FieldCleared returns a boolean indicating if a field with the given name was
  5945. // cleared in this mutation.
  5946. func (m *CategoryMutation) FieldCleared(name string) bool {
  5947. _, ok := m.clearedFields[name]
  5948. return ok
  5949. }
  5950. // ClearField clears the value of the field with the given name. It returns an
  5951. // error if the field is not defined in the schema.
  5952. func (m *CategoryMutation) ClearField(name string) error {
  5953. switch name {
  5954. case category.FieldDeletedAt:
  5955. m.ClearDeletedAt()
  5956. return nil
  5957. }
  5958. return fmt.Errorf("unknown Category nullable field %s", name)
  5959. }
  5960. // ResetField resets all changes in the mutation for the field with the given name.
  5961. // It returns an error if the field is not defined in the schema.
  5962. func (m *CategoryMutation) ResetField(name string) error {
  5963. switch name {
  5964. case category.FieldCreatedAt:
  5965. m.ResetCreatedAt()
  5966. return nil
  5967. case category.FieldUpdatedAt:
  5968. m.ResetUpdatedAt()
  5969. return nil
  5970. case category.FieldDeletedAt:
  5971. m.ResetDeletedAt()
  5972. return nil
  5973. case category.FieldName:
  5974. m.ResetName()
  5975. return nil
  5976. case category.FieldOrganizationID:
  5977. m.ResetOrganizationID()
  5978. return nil
  5979. }
  5980. return fmt.Errorf("unknown Category field %s", name)
  5981. }
  5982. // AddedEdges returns all edge names that were set/added in this mutation.
  5983. func (m *CategoryMutation) AddedEdges() []string {
  5984. edges := make([]string, 0, 0)
  5985. return edges
  5986. }
  5987. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5988. // name in this mutation.
  5989. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5990. return nil
  5991. }
  5992. // RemovedEdges returns all edge names that were removed in this mutation.
  5993. func (m *CategoryMutation) RemovedEdges() []string {
  5994. edges := make([]string, 0, 0)
  5995. return edges
  5996. }
  5997. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5998. // the given name in this mutation.
  5999. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6000. return nil
  6001. }
  6002. // ClearedEdges returns all edge names that were cleared in this mutation.
  6003. func (m *CategoryMutation) ClearedEdges() []string {
  6004. edges := make([]string, 0, 0)
  6005. return edges
  6006. }
  6007. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6008. // was cleared in this mutation.
  6009. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6010. return false
  6011. }
  6012. // ClearEdge clears the value of the edge with the given name. It returns an error
  6013. // if that edge is not defined in the schema.
  6014. func (m *CategoryMutation) ClearEdge(name string) error {
  6015. return fmt.Errorf("unknown Category unique edge %s", name)
  6016. }
  6017. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6018. // It returns an error if the edge is not defined in the schema.
  6019. func (m *CategoryMutation) ResetEdge(name string) error {
  6020. return fmt.Errorf("unknown Category edge %s", name)
  6021. }
  6022. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6023. type ChatRecordsMutation struct {
  6024. config
  6025. op Op
  6026. typ string
  6027. id *uint64
  6028. created_at *time.Time
  6029. updated_at *time.Time
  6030. deleted_at *time.Time
  6031. content *string
  6032. content_type *uint8
  6033. addcontent_type *int8
  6034. session_id *uint64
  6035. addsession_id *int64
  6036. user_id *uint64
  6037. adduser_id *int64
  6038. bot_id *uint64
  6039. addbot_id *int64
  6040. bot_type *uint8
  6041. addbot_type *int8
  6042. clearedFields map[string]struct{}
  6043. done bool
  6044. oldValue func(context.Context) (*ChatRecords, error)
  6045. predicates []predicate.ChatRecords
  6046. }
  6047. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6048. // chatrecordsOption allows management of the mutation configuration using functional options.
  6049. type chatrecordsOption func(*ChatRecordsMutation)
  6050. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6051. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6052. m := &ChatRecordsMutation{
  6053. config: c,
  6054. op: op,
  6055. typ: TypeChatRecords,
  6056. clearedFields: make(map[string]struct{}),
  6057. }
  6058. for _, opt := range opts {
  6059. opt(m)
  6060. }
  6061. return m
  6062. }
  6063. // withChatRecordsID sets the ID field of the mutation.
  6064. func withChatRecordsID(id uint64) chatrecordsOption {
  6065. return func(m *ChatRecordsMutation) {
  6066. var (
  6067. err error
  6068. once sync.Once
  6069. value *ChatRecords
  6070. )
  6071. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6072. once.Do(func() {
  6073. if m.done {
  6074. err = errors.New("querying old values post mutation is not allowed")
  6075. } else {
  6076. value, err = m.Client().ChatRecords.Get(ctx, id)
  6077. }
  6078. })
  6079. return value, err
  6080. }
  6081. m.id = &id
  6082. }
  6083. }
  6084. // withChatRecords sets the old ChatRecords of the mutation.
  6085. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6086. return func(m *ChatRecordsMutation) {
  6087. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6088. return node, nil
  6089. }
  6090. m.id = &node.ID
  6091. }
  6092. }
  6093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6094. // executed in a transaction (ent.Tx), a transactional client is returned.
  6095. func (m ChatRecordsMutation) Client() *Client {
  6096. client := &Client{config: m.config}
  6097. client.init()
  6098. return client
  6099. }
  6100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6101. // it returns an error otherwise.
  6102. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6103. if _, ok := m.driver.(*txDriver); !ok {
  6104. return nil, errors.New("ent: mutation is not running in a transaction")
  6105. }
  6106. tx := &Tx{config: m.config}
  6107. tx.init()
  6108. return tx, nil
  6109. }
  6110. // SetID sets the value of the id field. Note that this
  6111. // operation is only accepted on creation of ChatRecords entities.
  6112. func (m *ChatRecordsMutation) SetID(id uint64) {
  6113. m.id = &id
  6114. }
  6115. // ID returns the ID value in the mutation. Note that the ID is only available
  6116. // if it was provided to the builder or after it was returned from the database.
  6117. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6118. if m.id == nil {
  6119. return
  6120. }
  6121. return *m.id, true
  6122. }
  6123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6124. // That means, if the mutation is applied within a transaction with an isolation level such
  6125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6126. // or updated by the mutation.
  6127. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6128. switch {
  6129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6130. id, exists := m.ID()
  6131. if exists {
  6132. return []uint64{id}, nil
  6133. }
  6134. fallthrough
  6135. case m.op.Is(OpUpdate | OpDelete):
  6136. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6137. default:
  6138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6139. }
  6140. }
  6141. // SetCreatedAt sets the "created_at" field.
  6142. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6143. m.created_at = &t
  6144. }
  6145. // CreatedAt returns the value of the "created_at" field in the mutation.
  6146. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6147. v := m.created_at
  6148. if v == nil {
  6149. return
  6150. }
  6151. return *v, true
  6152. }
  6153. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6154. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6156. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6157. if !m.op.Is(OpUpdateOne) {
  6158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6159. }
  6160. if m.id == nil || m.oldValue == nil {
  6161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6162. }
  6163. oldValue, err := m.oldValue(ctx)
  6164. if err != nil {
  6165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6166. }
  6167. return oldValue.CreatedAt, nil
  6168. }
  6169. // ResetCreatedAt resets all changes to the "created_at" field.
  6170. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6171. m.created_at = nil
  6172. }
  6173. // SetUpdatedAt sets the "updated_at" field.
  6174. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6175. m.updated_at = &t
  6176. }
  6177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6178. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6179. v := m.updated_at
  6180. if v == nil {
  6181. return
  6182. }
  6183. return *v, true
  6184. }
  6185. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6186. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6188. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6189. if !m.op.Is(OpUpdateOne) {
  6190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6191. }
  6192. if m.id == nil || m.oldValue == nil {
  6193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6194. }
  6195. oldValue, err := m.oldValue(ctx)
  6196. if err != nil {
  6197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6198. }
  6199. return oldValue.UpdatedAt, nil
  6200. }
  6201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6202. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6203. m.updated_at = nil
  6204. }
  6205. // SetDeletedAt sets the "deleted_at" field.
  6206. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6207. m.deleted_at = &t
  6208. }
  6209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6210. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6211. v := m.deleted_at
  6212. if v == nil {
  6213. return
  6214. }
  6215. return *v, true
  6216. }
  6217. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6218. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6220. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6221. if !m.op.Is(OpUpdateOne) {
  6222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6223. }
  6224. if m.id == nil || m.oldValue == nil {
  6225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6226. }
  6227. oldValue, err := m.oldValue(ctx)
  6228. if err != nil {
  6229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6230. }
  6231. return oldValue.DeletedAt, nil
  6232. }
  6233. // ClearDeletedAt clears the value of the "deleted_at" field.
  6234. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6235. m.deleted_at = nil
  6236. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6237. }
  6238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6239. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6240. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6241. return ok
  6242. }
  6243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6244. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6245. m.deleted_at = nil
  6246. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6247. }
  6248. // SetContent sets the "content" field.
  6249. func (m *ChatRecordsMutation) SetContent(s string) {
  6250. m.content = &s
  6251. }
  6252. // Content returns the value of the "content" field in the mutation.
  6253. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6254. v := m.content
  6255. if v == nil {
  6256. return
  6257. }
  6258. return *v, true
  6259. }
  6260. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6261. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6263. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6264. if !m.op.Is(OpUpdateOne) {
  6265. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6266. }
  6267. if m.id == nil || m.oldValue == nil {
  6268. return v, errors.New("OldContent requires an ID field in the mutation")
  6269. }
  6270. oldValue, err := m.oldValue(ctx)
  6271. if err != nil {
  6272. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6273. }
  6274. return oldValue.Content, nil
  6275. }
  6276. // ResetContent resets all changes to the "content" field.
  6277. func (m *ChatRecordsMutation) ResetContent() {
  6278. m.content = nil
  6279. }
  6280. // SetContentType sets the "content_type" field.
  6281. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6282. m.content_type = &u
  6283. m.addcontent_type = nil
  6284. }
  6285. // ContentType returns the value of the "content_type" field in the mutation.
  6286. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6287. v := m.content_type
  6288. if v == nil {
  6289. return
  6290. }
  6291. return *v, true
  6292. }
  6293. // OldContentType returns the old "content_type" 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) OldContentType(ctx context.Context) (v uint8, err error) {
  6297. if !m.op.Is(OpUpdateOne) {
  6298. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6299. }
  6300. if m.id == nil || m.oldValue == nil {
  6301. return v, errors.New("OldContentType 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 OldContentType: %w", err)
  6306. }
  6307. return oldValue.ContentType, nil
  6308. }
  6309. // AddContentType adds u to the "content_type" field.
  6310. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6311. if m.addcontent_type != nil {
  6312. *m.addcontent_type += u
  6313. } else {
  6314. m.addcontent_type = &u
  6315. }
  6316. }
  6317. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6318. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6319. v := m.addcontent_type
  6320. if v == nil {
  6321. return
  6322. }
  6323. return *v, true
  6324. }
  6325. // ResetContentType resets all changes to the "content_type" field.
  6326. func (m *ChatRecordsMutation) ResetContentType() {
  6327. m.content_type = nil
  6328. m.addcontent_type = nil
  6329. }
  6330. // SetSessionID sets the "session_id" field.
  6331. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6332. m.session_id = &u
  6333. m.addsession_id = nil
  6334. }
  6335. // SessionID returns the value of the "session_id" field in the mutation.
  6336. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6337. v := m.session_id
  6338. if v == nil {
  6339. return
  6340. }
  6341. return *v, true
  6342. }
  6343. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6344. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6346. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6347. if !m.op.Is(OpUpdateOne) {
  6348. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6349. }
  6350. if m.id == nil || m.oldValue == nil {
  6351. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6352. }
  6353. oldValue, err := m.oldValue(ctx)
  6354. if err != nil {
  6355. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6356. }
  6357. return oldValue.SessionID, nil
  6358. }
  6359. // AddSessionID adds u to the "session_id" field.
  6360. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6361. if m.addsession_id != nil {
  6362. *m.addsession_id += u
  6363. } else {
  6364. m.addsession_id = &u
  6365. }
  6366. }
  6367. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6368. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6369. v := m.addsession_id
  6370. if v == nil {
  6371. return
  6372. }
  6373. return *v, true
  6374. }
  6375. // ResetSessionID resets all changes to the "session_id" field.
  6376. func (m *ChatRecordsMutation) ResetSessionID() {
  6377. m.session_id = nil
  6378. m.addsession_id = nil
  6379. }
  6380. // SetUserID sets the "user_id" field.
  6381. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6382. m.user_id = &u
  6383. m.adduser_id = nil
  6384. }
  6385. // UserID returns the value of the "user_id" field in the mutation.
  6386. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6387. v := m.user_id
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6394. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldUserID requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6406. }
  6407. return oldValue.UserID, nil
  6408. }
  6409. // AddUserID adds u to the "user_id" field.
  6410. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6411. if m.adduser_id != nil {
  6412. *m.adduser_id += u
  6413. } else {
  6414. m.adduser_id = &u
  6415. }
  6416. }
  6417. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6418. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6419. v := m.adduser_id
  6420. if v == nil {
  6421. return
  6422. }
  6423. return *v, true
  6424. }
  6425. // ResetUserID resets all changes to the "user_id" field.
  6426. func (m *ChatRecordsMutation) ResetUserID() {
  6427. m.user_id = nil
  6428. m.adduser_id = nil
  6429. }
  6430. // SetBotID sets the "bot_id" field.
  6431. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6432. m.bot_id = &u
  6433. m.addbot_id = nil
  6434. }
  6435. // BotID returns the value of the "bot_id" field in the mutation.
  6436. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6437. v := m.bot_id
  6438. if v == nil {
  6439. return
  6440. }
  6441. return *v, true
  6442. }
  6443. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6444. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6446. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6447. if !m.op.Is(OpUpdateOne) {
  6448. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6449. }
  6450. if m.id == nil || m.oldValue == nil {
  6451. return v, errors.New("OldBotID requires an ID field in the mutation")
  6452. }
  6453. oldValue, err := m.oldValue(ctx)
  6454. if err != nil {
  6455. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6456. }
  6457. return oldValue.BotID, nil
  6458. }
  6459. // AddBotID adds u to the "bot_id" field.
  6460. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6461. if m.addbot_id != nil {
  6462. *m.addbot_id += u
  6463. } else {
  6464. m.addbot_id = &u
  6465. }
  6466. }
  6467. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6468. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6469. v := m.addbot_id
  6470. if v == nil {
  6471. return
  6472. }
  6473. return *v, true
  6474. }
  6475. // ResetBotID resets all changes to the "bot_id" field.
  6476. func (m *ChatRecordsMutation) ResetBotID() {
  6477. m.bot_id = nil
  6478. m.addbot_id = nil
  6479. }
  6480. // SetBotType sets the "bot_type" field.
  6481. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6482. m.bot_type = &u
  6483. m.addbot_type = nil
  6484. }
  6485. // BotType returns the value of the "bot_type" field in the mutation.
  6486. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6487. v := m.bot_type
  6488. if v == nil {
  6489. return
  6490. }
  6491. return *v, true
  6492. }
  6493. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6494. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6496. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6497. if !m.op.Is(OpUpdateOne) {
  6498. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6499. }
  6500. if m.id == nil || m.oldValue == nil {
  6501. return v, errors.New("OldBotType requires an ID field in the mutation")
  6502. }
  6503. oldValue, err := m.oldValue(ctx)
  6504. if err != nil {
  6505. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6506. }
  6507. return oldValue.BotType, nil
  6508. }
  6509. // AddBotType adds u to the "bot_type" field.
  6510. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6511. if m.addbot_type != nil {
  6512. *m.addbot_type += u
  6513. } else {
  6514. m.addbot_type = &u
  6515. }
  6516. }
  6517. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6518. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6519. v := m.addbot_type
  6520. if v == nil {
  6521. return
  6522. }
  6523. return *v, true
  6524. }
  6525. // ResetBotType resets all changes to the "bot_type" field.
  6526. func (m *ChatRecordsMutation) ResetBotType() {
  6527. m.bot_type = nil
  6528. m.addbot_type = nil
  6529. }
  6530. // Where appends a list predicates to the ChatRecordsMutation builder.
  6531. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6532. m.predicates = append(m.predicates, ps...)
  6533. }
  6534. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6535. // users can use type-assertion to append predicates that do not depend on any generated package.
  6536. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6537. p := make([]predicate.ChatRecords, len(ps))
  6538. for i := range ps {
  6539. p[i] = ps[i]
  6540. }
  6541. m.Where(p...)
  6542. }
  6543. // Op returns the operation name.
  6544. func (m *ChatRecordsMutation) Op() Op {
  6545. return m.op
  6546. }
  6547. // SetOp allows setting the mutation operation.
  6548. func (m *ChatRecordsMutation) SetOp(op Op) {
  6549. m.op = op
  6550. }
  6551. // Type returns the node type of this mutation (ChatRecords).
  6552. func (m *ChatRecordsMutation) Type() string {
  6553. return m.typ
  6554. }
  6555. // Fields returns all fields that were changed during this mutation. Note that in
  6556. // order to get all numeric fields that were incremented/decremented, call
  6557. // AddedFields().
  6558. func (m *ChatRecordsMutation) Fields() []string {
  6559. fields := make([]string, 0, 9)
  6560. if m.created_at != nil {
  6561. fields = append(fields, chatrecords.FieldCreatedAt)
  6562. }
  6563. if m.updated_at != nil {
  6564. fields = append(fields, chatrecords.FieldUpdatedAt)
  6565. }
  6566. if m.deleted_at != nil {
  6567. fields = append(fields, chatrecords.FieldDeletedAt)
  6568. }
  6569. if m.content != nil {
  6570. fields = append(fields, chatrecords.FieldContent)
  6571. }
  6572. if m.content_type != nil {
  6573. fields = append(fields, chatrecords.FieldContentType)
  6574. }
  6575. if m.session_id != nil {
  6576. fields = append(fields, chatrecords.FieldSessionID)
  6577. }
  6578. if m.user_id != nil {
  6579. fields = append(fields, chatrecords.FieldUserID)
  6580. }
  6581. if m.bot_id != nil {
  6582. fields = append(fields, chatrecords.FieldBotID)
  6583. }
  6584. if m.bot_type != nil {
  6585. fields = append(fields, chatrecords.FieldBotType)
  6586. }
  6587. return fields
  6588. }
  6589. // Field returns the value of a field with the given name. The second boolean
  6590. // return value indicates that this field was not set, or was not defined in the
  6591. // schema.
  6592. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6593. switch name {
  6594. case chatrecords.FieldCreatedAt:
  6595. return m.CreatedAt()
  6596. case chatrecords.FieldUpdatedAt:
  6597. return m.UpdatedAt()
  6598. case chatrecords.FieldDeletedAt:
  6599. return m.DeletedAt()
  6600. case chatrecords.FieldContent:
  6601. return m.Content()
  6602. case chatrecords.FieldContentType:
  6603. return m.ContentType()
  6604. case chatrecords.FieldSessionID:
  6605. return m.SessionID()
  6606. case chatrecords.FieldUserID:
  6607. return m.UserID()
  6608. case chatrecords.FieldBotID:
  6609. return m.BotID()
  6610. case chatrecords.FieldBotType:
  6611. return m.BotType()
  6612. }
  6613. return nil, false
  6614. }
  6615. // OldField returns the old value of the field from the database. An error is
  6616. // returned if the mutation operation is not UpdateOne, or the query to the
  6617. // database failed.
  6618. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6619. switch name {
  6620. case chatrecords.FieldCreatedAt:
  6621. return m.OldCreatedAt(ctx)
  6622. case chatrecords.FieldUpdatedAt:
  6623. return m.OldUpdatedAt(ctx)
  6624. case chatrecords.FieldDeletedAt:
  6625. return m.OldDeletedAt(ctx)
  6626. case chatrecords.FieldContent:
  6627. return m.OldContent(ctx)
  6628. case chatrecords.FieldContentType:
  6629. return m.OldContentType(ctx)
  6630. case chatrecords.FieldSessionID:
  6631. return m.OldSessionID(ctx)
  6632. case chatrecords.FieldUserID:
  6633. return m.OldUserID(ctx)
  6634. case chatrecords.FieldBotID:
  6635. return m.OldBotID(ctx)
  6636. case chatrecords.FieldBotType:
  6637. return m.OldBotType(ctx)
  6638. }
  6639. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6640. }
  6641. // SetField sets the value of a field with the given name. It returns an error if
  6642. // the field is not defined in the schema, or if the type mismatched the field
  6643. // type.
  6644. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6645. switch name {
  6646. case chatrecords.FieldCreatedAt:
  6647. v, ok := value.(time.Time)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetCreatedAt(v)
  6652. return nil
  6653. case chatrecords.FieldUpdatedAt:
  6654. v, ok := value.(time.Time)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetUpdatedAt(v)
  6659. return nil
  6660. case chatrecords.FieldDeletedAt:
  6661. v, ok := value.(time.Time)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetDeletedAt(v)
  6666. return nil
  6667. case chatrecords.FieldContent:
  6668. v, ok := value.(string)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetContent(v)
  6673. return nil
  6674. case chatrecords.FieldContentType:
  6675. v, ok := value.(uint8)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetContentType(v)
  6680. return nil
  6681. case chatrecords.FieldSessionID:
  6682. v, ok := value.(uint64)
  6683. if !ok {
  6684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6685. }
  6686. m.SetSessionID(v)
  6687. return nil
  6688. case chatrecords.FieldUserID:
  6689. v, ok := value.(uint64)
  6690. if !ok {
  6691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6692. }
  6693. m.SetUserID(v)
  6694. return nil
  6695. case chatrecords.FieldBotID:
  6696. v, ok := value.(uint64)
  6697. if !ok {
  6698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6699. }
  6700. m.SetBotID(v)
  6701. return nil
  6702. case chatrecords.FieldBotType:
  6703. v, ok := value.(uint8)
  6704. if !ok {
  6705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6706. }
  6707. m.SetBotType(v)
  6708. return nil
  6709. }
  6710. return fmt.Errorf("unknown ChatRecords field %s", name)
  6711. }
  6712. // AddedFields returns all numeric fields that were incremented/decremented during
  6713. // this mutation.
  6714. func (m *ChatRecordsMutation) AddedFields() []string {
  6715. var fields []string
  6716. if m.addcontent_type != nil {
  6717. fields = append(fields, chatrecords.FieldContentType)
  6718. }
  6719. if m.addsession_id != nil {
  6720. fields = append(fields, chatrecords.FieldSessionID)
  6721. }
  6722. if m.adduser_id != nil {
  6723. fields = append(fields, chatrecords.FieldUserID)
  6724. }
  6725. if m.addbot_id != nil {
  6726. fields = append(fields, chatrecords.FieldBotID)
  6727. }
  6728. if m.addbot_type != nil {
  6729. fields = append(fields, chatrecords.FieldBotType)
  6730. }
  6731. return fields
  6732. }
  6733. // AddedField returns the numeric value that was incremented/decremented on a field
  6734. // with the given name. The second boolean return value indicates that this field
  6735. // was not set, or was not defined in the schema.
  6736. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6737. switch name {
  6738. case chatrecords.FieldContentType:
  6739. return m.AddedContentType()
  6740. case chatrecords.FieldSessionID:
  6741. return m.AddedSessionID()
  6742. case chatrecords.FieldUserID:
  6743. return m.AddedUserID()
  6744. case chatrecords.FieldBotID:
  6745. return m.AddedBotID()
  6746. case chatrecords.FieldBotType:
  6747. return m.AddedBotType()
  6748. }
  6749. return nil, false
  6750. }
  6751. // AddField adds the value to the field with the given name. It returns an error if
  6752. // the field is not defined in the schema, or if the type mismatched the field
  6753. // type.
  6754. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6755. switch name {
  6756. case chatrecords.FieldContentType:
  6757. v, ok := value.(int8)
  6758. if !ok {
  6759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6760. }
  6761. m.AddContentType(v)
  6762. return nil
  6763. case chatrecords.FieldSessionID:
  6764. v, ok := value.(int64)
  6765. if !ok {
  6766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6767. }
  6768. m.AddSessionID(v)
  6769. return nil
  6770. case chatrecords.FieldUserID:
  6771. v, ok := value.(int64)
  6772. if !ok {
  6773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6774. }
  6775. m.AddUserID(v)
  6776. return nil
  6777. case chatrecords.FieldBotID:
  6778. v, ok := value.(int64)
  6779. if !ok {
  6780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6781. }
  6782. m.AddBotID(v)
  6783. return nil
  6784. case chatrecords.FieldBotType:
  6785. v, ok := value.(int8)
  6786. if !ok {
  6787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6788. }
  6789. m.AddBotType(v)
  6790. return nil
  6791. }
  6792. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6793. }
  6794. // ClearedFields returns all nullable fields that were cleared during this
  6795. // mutation.
  6796. func (m *ChatRecordsMutation) ClearedFields() []string {
  6797. var fields []string
  6798. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6799. fields = append(fields, chatrecords.FieldDeletedAt)
  6800. }
  6801. return fields
  6802. }
  6803. // FieldCleared returns a boolean indicating if a field with the given name was
  6804. // cleared in this mutation.
  6805. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6806. _, ok := m.clearedFields[name]
  6807. return ok
  6808. }
  6809. // ClearField clears the value of the field with the given name. It returns an
  6810. // error if the field is not defined in the schema.
  6811. func (m *ChatRecordsMutation) ClearField(name string) error {
  6812. switch name {
  6813. case chatrecords.FieldDeletedAt:
  6814. m.ClearDeletedAt()
  6815. return nil
  6816. }
  6817. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6818. }
  6819. // ResetField resets all changes in the mutation for the field with the given name.
  6820. // It returns an error if the field is not defined in the schema.
  6821. func (m *ChatRecordsMutation) ResetField(name string) error {
  6822. switch name {
  6823. case chatrecords.FieldCreatedAt:
  6824. m.ResetCreatedAt()
  6825. return nil
  6826. case chatrecords.FieldUpdatedAt:
  6827. m.ResetUpdatedAt()
  6828. return nil
  6829. case chatrecords.FieldDeletedAt:
  6830. m.ResetDeletedAt()
  6831. return nil
  6832. case chatrecords.FieldContent:
  6833. m.ResetContent()
  6834. return nil
  6835. case chatrecords.FieldContentType:
  6836. m.ResetContentType()
  6837. return nil
  6838. case chatrecords.FieldSessionID:
  6839. m.ResetSessionID()
  6840. return nil
  6841. case chatrecords.FieldUserID:
  6842. m.ResetUserID()
  6843. return nil
  6844. case chatrecords.FieldBotID:
  6845. m.ResetBotID()
  6846. return nil
  6847. case chatrecords.FieldBotType:
  6848. m.ResetBotType()
  6849. return nil
  6850. }
  6851. return fmt.Errorf("unknown ChatRecords field %s", name)
  6852. }
  6853. // AddedEdges returns all edge names that were set/added in this mutation.
  6854. func (m *ChatRecordsMutation) AddedEdges() []string {
  6855. edges := make([]string, 0, 0)
  6856. return edges
  6857. }
  6858. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6859. // name in this mutation.
  6860. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6861. return nil
  6862. }
  6863. // RemovedEdges returns all edge names that were removed in this mutation.
  6864. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6865. edges := make([]string, 0, 0)
  6866. return edges
  6867. }
  6868. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6869. // the given name in this mutation.
  6870. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6871. return nil
  6872. }
  6873. // ClearedEdges returns all edge names that were cleared in this mutation.
  6874. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6875. edges := make([]string, 0, 0)
  6876. return edges
  6877. }
  6878. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6879. // was cleared in this mutation.
  6880. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6881. return false
  6882. }
  6883. // ClearEdge clears the value of the edge with the given name. It returns an error
  6884. // if that edge is not defined in the schema.
  6885. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6886. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6887. }
  6888. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6889. // It returns an error if the edge is not defined in the schema.
  6890. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6891. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6892. }
  6893. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6894. type ChatSessionMutation struct {
  6895. config
  6896. op Op
  6897. typ string
  6898. id *uint64
  6899. created_at *time.Time
  6900. updated_at *time.Time
  6901. deleted_at *time.Time
  6902. name *string
  6903. user_id *uint64
  6904. adduser_id *int64
  6905. bot_id *uint64
  6906. addbot_id *int64
  6907. bot_type *uint8
  6908. addbot_type *int8
  6909. clearedFields map[string]struct{}
  6910. done bool
  6911. oldValue func(context.Context) (*ChatSession, error)
  6912. predicates []predicate.ChatSession
  6913. }
  6914. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6915. // chatsessionOption allows management of the mutation configuration using functional options.
  6916. type chatsessionOption func(*ChatSessionMutation)
  6917. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6918. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6919. m := &ChatSessionMutation{
  6920. config: c,
  6921. op: op,
  6922. typ: TypeChatSession,
  6923. clearedFields: make(map[string]struct{}),
  6924. }
  6925. for _, opt := range opts {
  6926. opt(m)
  6927. }
  6928. return m
  6929. }
  6930. // withChatSessionID sets the ID field of the mutation.
  6931. func withChatSessionID(id uint64) chatsessionOption {
  6932. return func(m *ChatSessionMutation) {
  6933. var (
  6934. err error
  6935. once sync.Once
  6936. value *ChatSession
  6937. )
  6938. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6939. once.Do(func() {
  6940. if m.done {
  6941. err = errors.New("querying old values post mutation is not allowed")
  6942. } else {
  6943. value, err = m.Client().ChatSession.Get(ctx, id)
  6944. }
  6945. })
  6946. return value, err
  6947. }
  6948. m.id = &id
  6949. }
  6950. }
  6951. // withChatSession sets the old ChatSession of the mutation.
  6952. func withChatSession(node *ChatSession) chatsessionOption {
  6953. return func(m *ChatSessionMutation) {
  6954. m.oldValue = func(context.Context) (*ChatSession, error) {
  6955. return node, nil
  6956. }
  6957. m.id = &node.ID
  6958. }
  6959. }
  6960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6961. // executed in a transaction (ent.Tx), a transactional client is returned.
  6962. func (m ChatSessionMutation) Client() *Client {
  6963. client := &Client{config: m.config}
  6964. client.init()
  6965. return client
  6966. }
  6967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6968. // it returns an error otherwise.
  6969. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6970. if _, ok := m.driver.(*txDriver); !ok {
  6971. return nil, errors.New("ent: mutation is not running in a transaction")
  6972. }
  6973. tx := &Tx{config: m.config}
  6974. tx.init()
  6975. return tx, nil
  6976. }
  6977. // SetID sets the value of the id field. Note that this
  6978. // operation is only accepted on creation of ChatSession entities.
  6979. func (m *ChatSessionMutation) SetID(id uint64) {
  6980. m.id = &id
  6981. }
  6982. // ID returns the ID value in the mutation. Note that the ID is only available
  6983. // if it was provided to the builder or after it was returned from the database.
  6984. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6985. if m.id == nil {
  6986. return
  6987. }
  6988. return *m.id, true
  6989. }
  6990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6991. // That means, if the mutation is applied within a transaction with an isolation level such
  6992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6993. // or updated by the mutation.
  6994. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6995. switch {
  6996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6997. id, exists := m.ID()
  6998. if exists {
  6999. return []uint64{id}, nil
  7000. }
  7001. fallthrough
  7002. case m.op.Is(OpUpdate | OpDelete):
  7003. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7004. default:
  7005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7006. }
  7007. }
  7008. // SetCreatedAt sets the "created_at" field.
  7009. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7010. m.created_at = &t
  7011. }
  7012. // CreatedAt returns the value of the "created_at" field in the mutation.
  7013. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7014. v := m.created_at
  7015. if v == nil {
  7016. return
  7017. }
  7018. return *v, true
  7019. }
  7020. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7021. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7023. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7024. if !m.op.Is(OpUpdateOne) {
  7025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7026. }
  7027. if m.id == nil || m.oldValue == nil {
  7028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7029. }
  7030. oldValue, err := m.oldValue(ctx)
  7031. if err != nil {
  7032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7033. }
  7034. return oldValue.CreatedAt, nil
  7035. }
  7036. // ResetCreatedAt resets all changes to the "created_at" field.
  7037. func (m *ChatSessionMutation) ResetCreatedAt() {
  7038. m.created_at = nil
  7039. }
  7040. // SetUpdatedAt sets the "updated_at" field.
  7041. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7042. m.updated_at = &t
  7043. }
  7044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7045. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7046. v := m.updated_at
  7047. if v == nil {
  7048. return
  7049. }
  7050. return *v, true
  7051. }
  7052. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7053. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7055. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7056. if !m.op.Is(OpUpdateOne) {
  7057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7058. }
  7059. if m.id == nil || m.oldValue == nil {
  7060. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7061. }
  7062. oldValue, err := m.oldValue(ctx)
  7063. if err != nil {
  7064. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7065. }
  7066. return oldValue.UpdatedAt, nil
  7067. }
  7068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7069. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7070. m.updated_at = nil
  7071. }
  7072. // SetDeletedAt sets the "deleted_at" field.
  7073. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7074. m.deleted_at = &t
  7075. }
  7076. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7077. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7078. v := m.deleted_at
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7085. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7097. }
  7098. return oldValue.DeletedAt, nil
  7099. }
  7100. // ClearDeletedAt clears the value of the "deleted_at" field.
  7101. func (m *ChatSessionMutation) ClearDeletedAt() {
  7102. m.deleted_at = nil
  7103. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7104. }
  7105. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7106. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7107. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7108. return ok
  7109. }
  7110. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7111. func (m *ChatSessionMutation) ResetDeletedAt() {
  7112. m.deleted_at = nil
  7113. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7114. }
  7115. // SetName sets the "name" field.
  7116. func (m *ChatSessionMutation) SetName(s string) {
  7117. m.name = &s
  7118. }
  7119. // Name returns the value of the "name" field in the mutation.
  7120. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7121. v := m.name
  7122. if v == nil {
  7123. return
  7124. }
  7125. return *v, true
  7126. }
  7127. // OldName returns the old "name" field's value of the ChatSession entity.
  7128. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7131. if !m.op.Is(OpUpdateOne) {
  7132. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7133. }
  7134. if m.id == nil || m.oldValue == nil {
  7135. return v, errors.New("OldName requires an ID field in the mutation")
  7136. }
  7137. oldValue, err := m.oldValue(ctx)
  7138. if err != nil {
  7139. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7140. }
  7141. return oldValue.Name, nil
  7142. }
  7143. // ResetName resets all changes to the "name" field.
  7144. func (m *ChatSessionMutation) ResetName() {
  7145. m.name = nil
  7146. }
  7147. // SetUserID sets the "user_id" field.
  7148. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7149. m.user_id = &u
  7150. m.adduser_id = nil
  7151. }
  7152. // UserID returns the value of the "user_id" field in the mutation.
  7153. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7154. v := m.user_id
  7155. if v == nil {
  7156. return
  7157. }
  7158. return *v, true
  7159. }
  7160. // OldUserID returns the old "user_id" 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) OldUserID(ctx context.Context) (v uint64, err error) {
  7164. if !m.op.Is(OpUpdateOne) {
  7165. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7166. }
  7167. if m.id == nil || m.oldValue == nil {
  7168. return v, errors.New("OldUserID 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 OldUserID: %w", err)
  7173. }
  7174. return oldValue.UserID, nil
  7175. }
  7176. // AddUserID adds u to the "user_id" field.
  7177. func (m *ChatSessionMutation) AddUserID(u int64) {
  7178. if m.adduser_id != nil {
  7179. *m.adduser_id += u
  7180. } else {
  7181. m.adduser_id = &u
  7182. }
  7183. }
  7184. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7185. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7186. v := m.adduser_id
  7187. if v == nil {
  7188. return
  7189. }
  7190. return *v, true
  7191. }
  7192. // ResetUserID resets all changes to the "user_id" field.
  7193. func (m *ChatSessionMutation) ResetUserID() {
  7194. m.user_id = nil
  7195. m.adduser_id = nil
  7196. }
  7197. // SetBotID sets the "bot_id" field.
  7198. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7199. m.bot_id = &u
  7200. m.addbot_id = nil
  7201. }
  7202. // BotID returns the value of the "bot_id" field in the mutation.
  7203. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7204. v := m.bot_id
  7205. if v == nil {
  7206. return
  7207. }
  7208. return *v, true
  7209. }
  7210. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7211. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7213. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7214. if !m.op.Is(OpUpdateOne) {
  7215. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7216. }
  7217. if m.id == nil || m.oldValue == nil {
  7218. return v, errors.New("OldBotID requires an ID field in the mutation")
  7219. }
  7220. oldValue, err := m.oldValue(ctx)
  7221. if err != nil {
  7222. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7223. }
  7224. return oldValue.BotID, nil
  7225. }
  7226. // AddBotID adds u to the "bot_id" field.
  7227. func (m *ChatSessionMutation) AddBotID(u int64) {
  7228. if m.addbot_id != nil {
  7229. *m.addbot_id += u
  7230. } else {
  7231. m.addbot_id = &u
  7232. }
  7233. }
  7234. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7235. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7236. v := m.addbot_id
  7237. if v == nil {
  7238. return
  7239. }
  7240. return *v, true
  7241. }
  7242. // ResetBotID resets all changes to the "bot_id" field.
  7243. func (m *ChatSessionMutation) ResetBotID() {
  7244. m.bot_id = nil
  7245. m.addbot_id = nil
  7246. }
  7247. // SetBotType sets the "bot_type" field.
  7248. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7249. m.bot_type = &u
  7250. m.addbot_type = nil
  7251. }
  7252. // BotType returns the value of the "bot_type" field in the mutation.
  7253. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7254. v := m.bot_type
  7255. if v == nil {
  7256. return
  7257. }
  7258. return *v, true
  7259. }
  7260. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7261. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7263. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7264. if !m.op.Is(OpUpdateOne) {
  7265. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7266. }
  7267. if m.id == nil || m.oldValue == nil {
  7268. return v, errors.New("OldBotType requires an ID field in the mutation")
  7269. }
  7270. oldValue, err := m.oldValue(ctx)
  7271. if err != nil {
  7272. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7273. }
  7274. return oldValue.BotType, nil
  7275. }
  7276. // AddBotType adds u to the "bot_type" field.
  7277. func (m *ChatSessionMutation) AddBotType(u int8) {
  7278. if m.addbot_type != nil {
  7279. *m.addbot_type += u
  7280. } else {
  7281. m.addbot_type = &u
  7282. }
  7283. }
  7284. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7285. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7286. v := m.addbot_type
  7287. if v == nil {
  7288. return
  7289. }
  7290. return *v, true
  7291. }
  7292. // ResetBotType resets all changes to the "bot_type" field.
  7293. func (m *ChatSessionMutation) ResetBotType() {
  7294. m.bot_type = nil
  7295. m.addbot_type = nil
  7296. }
  7297. // Where appends a list predicates to the ChatSessionMutation builder.
  7298. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7299. m.predicates = append(m.predicates, ps...)
  7300. }
  7301. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7302. // users can use type-assertion to append predicates that do not depend on any generated package.
  7303. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7304. p := make([]predicate.ChatSession, len(ps))
  7305. for i := range ps {
  7306. p[i] = ps[i]
  7307. }
  7308. m.Where(p...)
  7309. }
  7310. // Op returns the operation name.
  7311. func (m *ChatSessionMutation) Op() Op {
  7312. return m.op
  7313. }
  7314. // SetOp allows setting the mutation operation.
  7315. func (m *ChatSessionMutation) SetOp(op Op) {
  7316. m.op = op
  7317. }
  7318. // Type returns the node type of this mutation (ChatSession).
  7319. func (m *ChatSessionMutation) Type() string {
  7320. return m.typ
  7321. }
  7322. // Fields returns all fields that were changed during this mutation. Note that in
  7323. // order to get all numeric fields that were incremented/decremented, call
  7324. // AddedFields().
  7325. func (m *ChatSessionMutation) Fields() []string {
  7326. fields := make([]string, 0, 7)
  7327. if m.created_at != nil {
  7328. fields = append(fields, chatsession.FieldCreatedAt)
  7329. }
  7330. if m.updated_at != nil {
  7331. fields = append(fields, chatsession.FieldUpdatedAt)
  7332. }
  7333. if m.deleted_at != nil {
  7334. fields = append(fields, chatsession.FieldDeletedAt)
  7335. }
  7336. if m.name != nil {
  7337. fields = append(fields, chatsession.FieldName)
  7338. }
  7339. if m.user_id != nil {
  7340. fields = append(fields, chatsession.FieldUserID)
  7341. }
  7342. if m.bot_id != nil {
  7343. fields = append(fields, chatsession.FieldBotID)
  7344. }
  7345. if m.bot_type != nil {
  7346. fields = append(fields, chatsession.FieldBotType)
  7347. }
  7348. return fields
  7349. }
  7350. // Field returns the value of a field with the given name. The second boolean
  7351. // return value indicates that this field was not set, or was not defined in the
  7352. // schema.
  7353. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7354. switch name {
  7355. case chatsession.FieldCreatedAt:
  7356. return m.CreatedAt()
  7357. case chatsession.FieldUpdatedAt:
  7358. return m.UpdatedAt()
  7359. case chatsession.FieldDeletedAt:
  7360. return m.DeletedAt()
  7361. case chatsession.FieldName:
  7362. return m.Name()
  7363. case chatsession.FieldUserID:
  7364. return m.UserID()
  7365. case chatsession.FieldBotID:
  7366. return m.BotID()
  7367. case chatsession.FieldBotType:
  7368. return m.BotType()
  7369. }
  7370. return nil, false
  7371. }
  7372. // OldField returns the old value of the field from the database. An error is
  7373. // returned if the mutation operation is not UpdateOne, or the query to the
  7374. // database failed.
  7375. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7376. switch name {
  7377. case chatsession.FieldCreatedAt:
  7378. return m.OldCreatedAt(ctx)
  7379. case chatsession.FieldUpdatedAt:
  7380. return m.OldUpdatedAt(ctx)
  7381. case chatsession.FieldDeletedAt:
  7382. return m.OldDeletedAt(ctx)
  7383. case chatsession.FieldName:
  7384. return m.OldName(ctx)
  7385. case chatsession.FieldUserID:
  7386. return m.OldUserID(ctx)
  7387. case chatsession.FieldBotID:
  7388. return m.OldBotID(ctx)
  7389. case chatsession.FieldBotType:
  7390. return m.OldBotType(ctx)
  7391. }
  7392. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7393. }
  7394. // SetField sets the value of a field with the given name. It returns an error if
  7395. // the field is not defined in the schema, or if the type mismatched the field
  7396. // type.
  7397. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7398. switch name {
  7399. case chatsession.FieldCreatedAt:
  7400. v, ok := value.(time.Time)
  7401. if !ok {
  7402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7403. }
  7404. m.SetCreatedAt(v)
  7405. return nil
  7406. case chatsession.FieldUpdatedAt:
  7407. v, ok := value.(time.Time)
  7408. if !ok {
  7409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7410. }
  7411. m.SetUpdatedAt(v)
  7412. return nil
  7413. case chatsession.FieldDeletedAt:
  7414. v, ok := value.(time.Time)
  7415. if !ok {
  7416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7417. }
  7418. m.SetDeletedAt(v)
  7419. return nil
  7420. case chatsession.FieldName:
  7421. v, ok := value.(string)
  7422. if !ok {
  7423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7424. }
  7425. m.SetName(v)
  7426. return nil
  7427. case chatsession.FieldUserID:
  7428. v, ok := value.(uint64)
  7429. if !ok {
  7430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7431. }
  7432. m.SetUserID(v)
  7433. return nil
  7434. case chatsession.FieldBotID:
  7435. v, ok := value.(uint64)
  7436. if !ok {
  7437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7438. }
  7439. m.SetBotID(v)
  7440. return nil
  7441. case chatsession.FieldBotType:
  7442. v, ok := value.(uint8)
  7443. if !ok {
  7444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7445. }
  7446. m.SetBotType(v)
  7447. return nil
  7448. }
  7449. return fmt.Errorf("unknown ChatSession field %s", name)
  7450. }
  7451. // AddedFields returns all numeric fields that were incremented/decremented during
  7452. // this mutation.
  7453. func (m *ChatSessionMutation) AddedFields() []string {
  7454. var fields []string
  7455. if m.adduser_id != nil {
  7456. fields = append(fields, chatsession.FieldUserID)
  7457. }
  7458. if m.addbot_id != nil {
  7459. fields = append(fields, chatsession.FieldBotID)
  7460. }
  7461. if m.addbot_type != nil {
  7462. fields = append(fields, chatsession.FieldBotType)
  7463. }
  7464. return fields
  7465. }
  7466. // AddedField returns the numeric value that was incremented/decremented on a field
  7467. // with the given name. The second boolean return value indicates that this field
  7468. // was not set, or was not defined in the schema.
  7469. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7470. switch name {
  7471. case chatsession.FieldUserID:
  7472. return m.AddedUserID()
  7473. case chatsession.FieldBotID:
  7474. return m.AddedBotID()
  7475. case chatsession.FieldBotType:
  7476. return m.AddedBotType()
  7477. }
  7478. return nil, false
  7479. }
  7480. // AddField adds the value to the field with the given name. It returns an error if
  7481. // the field is not defined in the schema, or if the type mismatched the field
  7482. // type.
  7483. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7484. switch name {
  7485. case chatsession.FieldUserID:
  7486. v, ok := value.(int64)
  7487. if !ok {
  7488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7489. }
  7490. m.AddUserID(v)
  7491. return nil
  7492. case chatsession.FieldBotID:
  7493. v, ok := value.(int64)
  7494. if !ok {
  7495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7496. }
  7497. m.AddBotID(v)
  7498. return nil
  7499. case chatsession.FieldBotType:
  7500. v, ok := value.(int8)
  7501. if !ok {
  7502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7503. }
  7504. m.AddBotType(v)
  7505. return nil
  7506. }
  7507. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7508. }
  7509. // ClearedFields returns all nullable fields that were cleared during this
  7510. // mutation.
  7511. func (m *ChatSessionMutation) ClearedFields() []string {
  7512. var fields []string
  7513. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7514. fields = append(fields, chatsession.FieldDeletedAt)
  7515. }
  7516. return fields
  7517. }
  7518. // FieldCleared returns a boolean indicating if a field with the given name was
  7519. // cleared in this mutation.
  7520. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7521. _, ok := m.clearedFields[name]
  7522. return ok
  7523. }
  7524. // ClearField clears the value of the field with the given name. It returns an
  7525. // error if the field is not defined in the schema.
  7526. func (m *ChatSessionMutation) ClearField(name string) error {
  7527. switch name {
  7528. case chatsession.FieldDeletedAt:
  7529. m.ClearDeletedAt()
  7530. return nil
  7531. }
  7532. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7533. }
  7534. // ResetField resets all changes in the mutation for the field with the given name.
  7535. // It returns an error if the field is not defined in the schema.
  7536. func (m *ChatSessionMutation) ResetField(name string) error {
  7537. switch name {
  7538. case chatsession.FieldCreatedAt:
  7539. m.ResetCreatedAt()
  7540. return nil
  7541. case chatsession.FieldUpdatedAt:
  7542. m.ResetUpdatedAt()
  7543. return nil
  7544. case chatsession.FieldDeletedAt:
  7545. m.ResetDeletedAt()
  7546. return nil
  7547. case chatsession.FieldName:
  7548. m.ResetName()
  7549. return nil
  7550. case chatsession.FieldUserID:
  7551. m.ResetUserID()
  7552. return nil
  7553. case chatsession.FieldBotID:
  7554. m.ResetBotID()
  7555. return nil
  7556. case chatsession.FieldBotType:
  7557. m.ResetBotType()
  7558. return nil
  7559. }
  7560. return fmt.Errorf("unknown ChatSession field %s", name)
  7561. }
  7562. // AddedEdges returns all edge names that were set/added in this mutation.
  7563. func (m *ChatSessionMutation) AddedEdges() []string {
  7564. edges := make([]string, 0, 0)
  7565. return edges
  7566. }
  7567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7568. // name in this mutation.
  7569. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7570. return nil
  7571. }
  7572. // RemovedEdges returns all edge names that were removed in this mutation.
  7573. func (m *ChatSessionMutation) RemovedEdges() []string {
  7574. edges := make([]string, 0, 0)
  7575. return edges
  7576. }
  7577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7578. // the given name in this mutation.
  7579. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7580. return nil
  7581. }
  7582. // ClearedEdges returns all edge names that were cleared in this mutation.
  7583. func (m *ChatSessionMutation) ClearedEdges() []string {
  7584. edges := make([]string, 0, 0)
  7585. return edges
  7586. }
  7587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7588. // was cleared in this mutation.
  7589. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7590. return false
  7591. }
  7592. // ClearEdge clears the value of the edge with the given name. It returns an error
  7593. // if that edge is not defined in the schema.
  7594. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7595. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7596. }
  7597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7598. // It returns an error if the edge is not defined in the schema.
  7599. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7600. return fmt.Errorf("unknown ChatSession edge %s", name)
  7601. }
  7602. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7603. type ContactMutation struct {
  7604. config
  7605. op Op
  7606. typ string
  7607. id *uint64
  7608. created_at *time.Time
  7609. updated_at *time.Time
  7610. status *uint8
  7611. addstatus *int8
  7612. deleted_at *time.Time
  7613. wx_wxid *string
  7614. _type *int
  7615. add_type *int
  7616. wxid *string
  7617. account *string
  7618. nickname *string
  7619. markname *string
  7620. headimg *string
  7621. sex *int
  7622. addsex *int
  7623. starrole *string
  7624. dontseeit *int
  7625. adddontseeit *int
  7626. dontseeme *int
  7627. adddontseeme *int
  7628. lag *string
  7629. gid *string
  7630. gname *string
  7631. v3 *string
  7632. organization_id *uint64
  7633. addorganization_id *int64
  7634. clearedFields map[string]struct{}
  7635. contact_relationships map[uint64]struct{}
  7636. removedcontact_relationships map[uint64]struct{}
  7637. clearedcontact_relationships bool
  7638. contact_messages map[uint64]struct{}
  7639. removedcontact_messages map[uint64]struct{}
  7640. clearedcontact_messages bool
  7641. done bool
  7642. oldValue func(context.Context) (*Contact, error)
  7643. predicates []predicate.Contact
  7644. }
  7645. var _ ent.Mutation = (*ContactMutation)(nil)
  7646. // contactOption allows management of the mutation configuration using functional options.
  7647. type contactOption func(*ContactMutation)
  7648. // newContactMutation creates new mutation for the Contact entity.
  7649. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7650. m := &ContactMutation{
  7651. config: c,
  7652. op: op,
  7653. typ: TypeContact,
  7654. clearedFields: make(map[string]struct{}),
  7655. }
  7656. for _, opt := range opts {
  7657. opt(m)
  7658. }
  7659. return m
  7660. }
  7661. // withContactID sets the ID field of the mutation.
  7662. func withContactID(id uint64) contactOption {
  7663. return func(m *ContactMutation) {
  7664. var (
  7665. err error
  7666. once sync.Once
  7667. value *Contact
  7668. )
  7669. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7670. once.Do(func() {
  7671. if m.done {
  7672. err = errors.New("querying old values post mutation is not allowed")
  7673. } else {
  7674. value, err = m.Client().Contact.Get(ctx, id)
  7675. }
  7676. })
  7677. return value, err
  7678. }
  7679. m.id = &id
  7680. }
  7681. }
  7682. // withContact sets the old Contact of the mutation.
  7683. func withContact(node *Contact) contactOption {
  7684. return func(m *ContactMutation) {
  7685. m.oldValue = func(context.Context) (*Contact, error) {
  7686. return node, nil
  7687. }
  7688. m.id = &node.ID
  7689. }
  7690. }
  7691. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7692. // executed in a transaction (ent.Tx), a transactional client is returned.
  7693. func (m ContactMutation) Client() *Client {
  7694. client := &Client{config: m.config}
  7695. client.init()
  7696. return client
  7697. }
  7698. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7699. // it returns an error otherwise.
  7700. func (m ContactMutation) Tx() (*Tx, error) {
  7701. if _, ok := m.driver.(*txDriver); !ok {
  7702. return nil, errors.New("ent: mutation is not running in a transaction")
  7703. }
  7704. tx := &Tx{config: m.config}
  7705. tx.init()
  7706. return tx, nil
  7707. }
  7708. // SetID sets the value of the id field. Note that this
  7709. // operation is only accepted on creation of Contact entities.
  7710. func (m *ContactMutation) SetID(id uint64) {
  7711. m.id = &id
  7712. }
  7713. // ID returns the ID value in the mutation. Note that the ID is only available
  7714. // if it was provided to the builder or after it was returned from the database.
  7715. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7716. if m.id == nil {
  7717. return
  7718. }
  7719. return *m.id, true
  7720. }
  7721. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7722. // That means, if the mutation is applied within a transaction with an isolation level such
  7723. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7724. // or updated by the mutation.
  7725. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7726. switch {
  7727. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7728. id, exists := m.ID()
  7729. if exists {
  7730. return []uint64{id}, nil
  7731. }
  7732. fallthrough
  7733. case m.op.Is(OpUpdate | OpDelete):
  7734. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7735. default:
  7736. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7737. }
  7738. }
  7739. // SetCreatedAt sets the "created_at" field.
  7740. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7741. m.created_at = &t
  7742. }
  7743. // CreatedAt returns the value of the "created_at" field in the mutation.
  7744. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7745. v := m.created_at
  7746. if v == nil {
  7747. return
  7748. }
  7749. return *v, true
  7750. }
  7751. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7752. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7754. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7755. if !m.op.Is(OpUpdateOne) {
  7756. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7757. }
  7758. if m.id == nil || m.oldValue == nil {
  7759. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7760. }
  7761. oldValue, err := m.oldValue(ctx)
  7762. if err != nil {
  7763. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7764. }
  7765. return oldValue.CreatedAt, nil
  7766. }
  7767. // ResetCreatedAt resets all changes to the "created_at" field.
  7768. func (m *ContactMutation) ResetCreatedAt() {
  7769. m.created_at = nil
  7770. }
  7771. // SetUpdatedAt sets the "updated_at" field.
  7772. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7773. m.updated_at = &t
  7774. }
  7775. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7776. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7777. v := m.updated_at
  7778. if v == nil {
  7779. return
  7780. }
  7781. return *v, true
  7782. }
  7783. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7786. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7787. if !m.op.Is(OpUpdateOne) {
  7788. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7789. }
  7790. if m.id == nil || m.oldValue == nil {
  7791. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7792. }
  7793. oldValue, err := m.oldValue(ctx)
  7794. if err != nil {
  7795. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7796. }
  7797. return oldValue.UpdatedAt, nil
  7798. }
  7799. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7800. func (m *ContactMutation) ResetUpdatedAt() {
  7801. m.updated_at = nil
  7802. }
  7803. // SetStatus sets the "status" field.
  7804. func (m *ContactMutation) SetStatus(u uint8) {
  7805. m.status = &u
  7806. m.addstatus = nil
  7807. }
  7808. // Status returns the value of the "status" field in the mutation.
  7809. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7810. v := m.status
  7811. if v == nil {
  7812. return
  7813. }
  7814. return *v, true
  7815. }
  7816. // OldStatus returns the old "status" field's value of the Contact entity.
  7817. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7819. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7820. if !m.op.Is(OpUpdateOne) {
  7821. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7822. }
  7823. if m.id == nil || m.oldValue == nil {
  7824. return v, errors.New("OldStatus requires an ID field in the mutation")
  7825. }
  7826. oldValue, err := m.oldValue(ctx)
  7827. if err != nil {
  7828. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7829. }
  7830. return oldValue.Status, nil
  7831. }
  7832. // AddStatus adds u to the "status" field.
  7833. func (m *ContactMutation) AddStatus(u int8) {
  7834. if m.addstatus != nil {
  7835. *m.addstatus += u
  7836. } else {
  7837. m.addstatus = &u
  7838. }
  7839. }
  7840. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7841. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7842. v := m.addstatus
  7843. if v == nil {
  7844. return
  7845. }
  7846. return *v, true
  7847. }
  7848. // ClearStatus clears the value of the "status" field.
  7849. func (m *ContactMutation) ClearStatus() {
  7850. m.status = nil
  7851. m.addstatus = nil
  7852. m.clearedFields[contact.FieldStatus] = struct{}{}
  7853. }
  7854. // StatusCleared returns if the "status" field was cleared in this mutation.
  7855. func (m *ContactMutation) StatusCleared() bool {
  7856. _, ok := m.clearedFields[contact.FieldStatus]
  7857. return ok
  7858. }
  7859. // ResetStatus resets all changes to the "status" field.
  7860. func (m *ContactMutation) ResetStatus() {
  7861. m.status = nil
  7862. m.addstatus = nil
  7863. delete(m.clearedFields, contact.FieldStatus)
  7864. }
  7865. // SetDeletedAt sets the "deleted_at" field.
  7866. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7867. m.deleted_at = &t
  7868. }
  7869. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7870. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7871. v := m.deleted_at
  7872. if v == nil {
  7873. return
  7874. }
  7875. return *v, true
  7876. }
  7877. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7878. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7880. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7881. if !m.op.Is(OpUpdateOne) {
  7882. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7883. }
  7884. if m.id == nil || m.oldValue == nil {
  7885. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7886. }
  7887. oldValue, err := m.oldValue(ctx)
  7888. if err != nil {
  7889. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7890. }
  7891. return oldValue.DeletedAt, nil
  7892. }
  7893. // ClearDeletedAt clears the value of the "deleted_at" field.
  7894. func (m *ContactMutation) ClearDeletedAt() {
  7895. m.deleted_at = nil
  7896. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7897. }
  7898. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7899. func (m *ContactMutation) DeletedAtCleared() bool {
  7900. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7901. return ok
  7902. }
  7903. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7904. func (m *ContactMutation) ResetDeletedAt() {
  7905. m.deleted_at = nil
  7906. delete(m.clearedFields, contact.FieldDeletedAt)
  7907. }
  7908. // SetWxWxid sets the "wx_wxid" field.
  7909. func (m *ContactMutation) SetWxWxid(s string) {
  7910. m.wx_wxid = &s
  7911. }
  7912. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7913. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7914. v := m.wx_wxid
  7915. if v == nil {
  7916. return
  7917. }
  7918. return *v, true
  7919. }
  7920. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7923. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7924. if !m.op.Is(OpUpdateOne) {
  7925. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7926. }
  7927. if m.id == nil || m.oldValue == nil {
  7928. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7929. }
  7930. oldValue, err := m.oldValue(ctx)
  7931. if err != nil {
  7932. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7933. }
  7934. return oldValue.WxWxid, nil
  7935. }
  7936. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7937. func (m *ContactMutation) ResetWxWxid() {
  7938. m.wx_wxid = nil
  7939. }
  7940. // SetType sets the "type" field.
  7941. func (m *ContactMutation) SetType(i int) {
  7942. m._type = &i
  7943. m.add_type = nil
  7944. }
  7945. // GetType returns the value of the "type" field in the mutation.
  7946. func (m *ContactMutation) GetType() (r int, exists bool) {
  7947. v := m._type
  7948. if v == nil {
  7949. return
  7950. }
  7951. return *v, true
  7952. }
  7953. // OldType returns the old "type" 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) OldType(ctx context.Context) (v int, err error) {
  7957. if !m.op.Is(OpUpdateOne) {
  7958. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7959. }
  7960. if m.id == nil || m.oldValue == nil {
  7961. return v, errors.New("OldType 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 OldType: %w", err)
  7966. }
  7967. return oldValue.Type, nil
  7968. }
  7969. // AddType adds i to the "type" field.
  7970. func (m *ContactMutation) AddType(i int) {
  7971. if m.add_type != nil {
  7972. *m.add_type += i
  7973. } else {
  7974. m.add_type = &i
  7975. }
  7976. }
  7977. // AddedType returns the value that was added to the "type" field in this mutation.
  7978. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7979. v := m.add_type
  7980. if v == nil {
  7981. return
  7982. }
  7983. return *v, true
  7984. }
  7985. // ClearType clears the value of the "type" field.
  7986. func (m *ContactMutation) ClearType() {
  7987. m._type = nil
  7988. m.add_type = nil
  7989. m.clearedFields[contact.FieldType] = struct{}{}
  7990. }
  7991. // TypeCleared returns if the "type" field was cleared in this mutation.
  7992. func (m *ContactMutation) TypeCleared() bool {
  7993. _, ok := m.clearedFields[contact.FieldType]
  7994. return ok
  7995. }
  7996. // ResetType resets all changes to the "type" field.
  7997. func (m *ContactMutation) ResetType() {
  7998. m._type = nil
  7999. m.add_type = nil
  8000. delete(m.clearedFields, contact.FieldType)
  8001. }
  8002. // SetWxid sets the "wxid" field.
  8003. func (m *ContactMutation) SetWxid(s string) {
  8004. m.wxid = &s
  8005. }
  8006. // Wxid returns the value of the "wxid" field in the mutation.
  8007. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8008. v := m.wxid
  8009. if v == nil {
  8010. return
  8011. }
  8012. return *v, true
  8013. }
  8014. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8015. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8017. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8018. if !m.op.Is(OpUpdateOne) {
  8019. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8020. }
  8021. if m.id == nil || m.oldValue == nil {
  8022. return v, errors.New("OldWxid requires an ID field in the mutation")
  8023. }
  8024. oldValue, err := m.oldValue(ctx)
  8025. if err != nil {
  8026. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8027. }
  8028. return oldValue.Wxid, nil
  8029. }
  8030. // ResetWxid resets all changes to the "wxid" field.
  8031. func (m *ContactMutation) ResetWxid() {
  8032. m.wxid = nil
  8033. }
  8034. // SetAccount sets the "account" field.
  8035. func (m *ContactMutation) SetAccount(s string) {
  8036. m.account = &s
  8037. }
  8038. // Account returns the value of the "account" field in the mutation.
  8039. func (m *ContactMutation) Account() (r string, exists bool) {
  8040. v := m.account
  8041. if v == nil {
  8042. return
  8043. }
  8044. return *v, true
  8045. }
  8046. // OldAccount returns the old "account" field's value of the Contact entity.
  8047. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8049. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8050. if !m.op.Is(OpUpdateOne) {
  8051. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8052. }
  8053. if m.id == nil || m.oldValue == nil {
  8054. return v, errors.New("OldAccount requires an ID field in the mutation")
  8055. }
  8056. oldValue, err := m.oldValue(ctx)
  8057. if err != nil {
  8058. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8059. }
  8060. return oldValue.Account, nil
  8061. }
  8062. // ResetAccount resets all changes to the "account" field.
  8063. func (m *ContactMutation) ResetAccount() {
  8064. m.account = nil
  8065. }
  8066. // SetNickname sets the "nickname" field.
  8067. func (m *ContactMutation) SetNickname(s string) {
  8068. m.nickname = &s
  8069. }
  8070. // Nickname returns the value of the "nickname" field in the mutation.
  8071. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8072. v := m.nickname
  8073. if v == nil {
  8074. return
  8075. }
  8076. return *v, true
  8077. }
  8078. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8079. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8081. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8082. if !m.op.Is(OpUpdateOne) {
  8083. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8084. }
  8085. if m.id == nil || m.oldValue == nil {
  8086. return v, errors.New("OldNickname requires an ID field in the mutation")
  8087. }
  8088. oldValue, err := m.oldValue(ctx)
  8089. if err != nil {
  8090. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8091. }
  8092. return oldValue.Nickname, nil
  8093. }
  8094. // ResetNickname resets all changes to the "nickname" field.
  8095. func (m *ContactMutation) ResetNickname() {
  8096. m.nickname = nil
  8097. }
  8098. // SetMarkname sets the "markname" field.
  8099. func (m *ContactMutation) SetMarkname(s string) {
  8100. m.markname = &s
  8101. }
  8102. // Markname returns the value of the "markname" field in the mutation.
  8103. func (m *ContactMutation) Markname() (r string, exists bool) {
  8104. v := m.markname
  8105. if v == nil {
  8106. return
  8107. }
  8108. return *v, true
  8109. }
  8110. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8111. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8113. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8114. if !m.op.Is(OpUpdateOne) {
  8115. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8116. }
  8117. if m.id == nil || m.oldValue == nil {
  8118. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8119. }
  8120. oldValue, err := m.oldValue(ctx)
  8121. if err != nil {
  8122. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8123. }
  8124. return oldValue.Markname, nil
  8125. }
  8126. // ResetMarkname resets all changes to the "markname" field.
  8127. func (m *ContactMutation) ResetMarkname() {
  8128. m.markname = nil
  8129. }
  8130. // SetHeadimg sets the "headimg" field.
  8131. func (m *ContactMutation) SetHeadimg(s string) {
  8132. m.headimg = &s
  8133. }
  8134. // Headimg returns the value of the "headimg" field in the mutation.
  8135. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8136. v := m.headimg
  8137. if v == nil {
  8138. return
  8139. }
  8140. return *v, true
  8141. }
  8142. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8143. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8145. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8146. if !m.op.Is(OpUpdateOne) {
  8147. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8148. }
  8149. if m.id == nil || m.oldValue == nil {
  8150. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8151. }
  8152. oldValue, err := m.oldValue(ctx)
  8153. if err != nil {
  8154. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8155. }
  8156. return oldValue.Headimg, nil
  8157. }
  8158. // ResetHeadimg resets all changes to the "headimg" field.
  8159. func (m *ContactMutation) ResetHeadimg() {
  8160. m.headimg = nil
  8161. }
  8162. // SetSex sets the "sex" field.
  8163. func (m *ContactMutation) SetSex(i int) {
  8164. m.sex = &i
  8165. m.addsex = nil
  8166. }
  8167. // Sex returns the value of the "sex" field in the mutation.
  8168. func (m *ContactMutation) Sex() (r int, exists bool) {
  8169. v := m.sex
  8170. if v == nil {
  8171. return
  8172. }
  8173. return *v, true
  8174. }
  8175. // OldSex returns the old "sex" field's value of the Contact entity.
  8176. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8178. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8179. if !m.op.Is(OpUpdateOne) {
  8180. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8181. }
  8182. if m.id == nil || m.oldValue == nil {
  8183. return v, errors.New("OldSex requires an ID field in the mutation")
  8184. }
  8185. oldValue, err := m.oldValue(ctx)
  8186. if err != nil {
  8187. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8188. }
  8189. return oldValue.Sex, nil
  8190. }
  8191. // AddSex adds i to the "sex" field.
  8192. func (m *ContactMutation) AddSex(i int) {
  8193. if m.addsex != nil {
  8194. *m.addsex += i
  8195. } else {
  8196. m.addsex = &i
  8197. }
  8198. }
  8199. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8200. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8201. v := m.addsex
  8202. if v == nil {
  8203. return
  8204. }
  8205. return *v, true
  8206. }
  8207. // ResetSex resets all changes to the "sex" field.
  8208. func (m *ContactMutation) ResetSex() {
  8209. m.sex = nil
  8210. m.addsex = nil
  8211. }
  8212. // SetStarrole sets the "starrole" field.
  8213. func (m *ContactMutation) SetStarrole(s string) {
  8214. m.starrole = &s
  8215. }
  8216. // Starrole returns the value of the "starrole" field in the mutation.
  8217. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8218. v := m.starrole
  8219. if v == nil {
  8220. return
  8221. }
  8222. return *v, true
  8223. }
  8224. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8225. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8227. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8228. if !m.op.Is(OpUpdateOne) {
  8229. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8230. }
  8231. if m.id == nil || m.oldValue == nil {
  8232. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8233. }
  8234. oldValue, err := m.oldValue(ctx)
  8235. if err != nil {
  8236. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8237. }
  8238. return oldValue.Starrole, nil
  8239. }
  8240. // ResetStarrole resets all changes to the "starrole" field.
  8241. func (m *ContactMutation) ResetStarrole() {
  8242. m.starrole = nil
  8243. }
  8244. // SetDontseeit sets the "dontseeit" field.
  8245. func (m *ContactMutation) SetDontseeit(i int) {
  8246. m.dontseeit = &i
  8247. m.adddontseeit = nil
  8248. }
  8249. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8250. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8251. v := m.dontseeit
  8252. if v == nil {
  8253. return
  8254. }
  8255. return *v, true
  8256. }
  8257. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8258. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8260. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8261. if !m.op.Is(OpUpdateOne) {
  8262. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8263. }
  8264. if m.id == nil || m.oldValue == nil {
  8265. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8266. }
  8267. oldValue, err := m.oldValue(ctx)
  8268. if err != nil {
  8269. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8270. }
  8271. return oldValue.Dontseeit, nil
  8272. }
  8273. // AddDontseeit adds i to the "dontseeit" field.
  8274. func (m *ContactMutation) AddDontseeit(i int) {
  8275. if m.adddontseeit != nil {
  8276. *m.adddontseeit += i
  8277. } else {
  8278. m.adddontseeit = &i
  8279. }
  8280. }
  8281. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8282. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8283. v := m.adddontseeit
  8284. if v == nil {
  8285. return
  8286. }
  8287. return *v, true
  8288. }
  8289. // ResetDontseeit resets all changes to the "dontseeit" field.
  8290. func (m *ContactMutation) ResetDontseeit() {
  8291. m.dontseeit = nil
  8292. m.adddontseeit = nil
  8293. }
  8294. // SetDontseeme sets the "dontseeme" field.
  8295. func (m *ContactMutation) SetDontseeme(i int) {
  8296. m.dontseeme = &i
  8297. m.adddontseeme = nil
  8298. }
  8299. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8300. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8301. v := m.dontseeme
  8302. if v == nil {
  8303. return
  8304. }
  8305. return *v, true
  8306. }
  8307. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8308. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8310. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8311. if !m.op.Is(OpUpdateOne) {
  8312. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8313. }
  8314. if m.id == nil || m.oldValue == nil {
  8315. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8316. }
  8317. oldValue, err := m.oldValue(ctx)
  8318. if err != nil {
  8319. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8320. }
  8321. return oldValue.Dontseeme, nil
  8322. }
  8323. // AddDontseeme adds i to the "dontseeme" field.
  8324. func (m *ContactMutation) AddDontseeme(i int) {
  8325. if m.adddontseeme != nil {
  8326. *m.adddontseeme += i
  8327. } else {
  8328. m.adddontseeme = &i
  8329. }
  8330. }
  8331. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8332. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8333. v := m.adddontseeme
  8334. if v == nil {
  8335. return
  8336. }
  8337. return *v, true
  8338. }
  8339. // ResetDontseeme resets all changes to the "dontseeme" field.
  8340. func (m *ContactMutation) ResetDontseeme() {
  8341. m.dontseeme = nil
  8342. m.adddontseeme = nil
  8343. }
  8344. // SetLag sets the "lag" field.
  8345. func (m *ContactMutation) SetLag(s string) {
  8346. m.lag = &s
  8347. }
  8348. // Lag returns the value of the "lag" field in the mutation.
  8349. func (m *ContactMutation) Lag() (r string, exists bool) {
  8350. v := m.lag
  8351. if v == nil {
  8352. return
  8353. }
  8354. return *v, true
  8355. }
  8356. // OldLag returns the old "lag" field's value of the Contact entity.
  8357. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8359. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8360. if !m.op.Is(OpUpdateOne) {
  8361. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8362. }
  8363. if m.id == nil || m.oldValue == nil {
  8364. return v, errors.New("OldLag requires an ID field in the mutation")
  8365. }
  8366. oldValue, err := m.oldValue(ctx)
  8367. if err != nil {
  8368. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8369. }
  8370. return oldValue.Lag, nil
  8371. }
  8372. // ResetLag resets all changes to the "lag" field.
  8373. func (m *ContactMutation) ResetLag() {
  8374. m.lag = nil
  8375. }
  8376. // SetGid sets the "gid" field.
  8377. func (m *ContactMutation) SetGid(s string) {
  8378. m.gid = &s
  8379. }
  8380. // Gid returns the value of the "gid" field in the mutation.
  8381. func (m *ContactMutation) Gid() (r string, exists bool) {
  8382. v := m.gid
  8383. if v == nil {
  8384. return
  8385. }
  8386. return *v, true
  8387. }
  8388. // OldGid returns the old "gid" field's value of the Contact entity.
  8389. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8391. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8392. if !m.op.Is(OpUpdateOne) {
  8393. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8394. }
  8395. if m.id == nil || m.oldValue == nil {
  8396. return v, errors.New("OldGid requires an ID field in the mutation")
  8397. }
  8398. oldValue, err := m.oldValue(ctx)
  8399. if err != nil {
  8400. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8401. }
  8402. return oldValue.Gid, nil
  8403. }
  8404. // ResetGid resets all changes to the "gid" field.
  8405. func (m *ContactMutation) ResetGid() {
  8406. m.gid = nil
  8407. }
  8408. // SetGname sets the "gname" field.
  8409. func (m *ContactMutation) SetGname(s string) {
  8410. m.gname = &s
  8411. }
  8412. // Gname returns the value of the "gname" field in the mutation.
  8413. func (m *ContactMutation) Gname() (r string, exists bool) {
  8414. v := m.gname
  8415. if v == nil {
  8416. return
  8417. }
  8418. return *v, true
  8419. }
  8420. // OldGname returns the old "gname" field's value of the Contact entity.
  8421. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8423. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8424. if !m.op.Is(OpUpdateOne) {
  8425. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8426. }
  8427. if m.id == nil || m.oldValue == nil {
  8428. return v, errors.New("OldGname requires an ID field in the mutation")
  8429. }
  8430. oldValue, err := m.oldValue(ctx)
  8431. if err != nil {
  8432. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8433. }
  8434. return oldValue.Gname, nil
  8435. }
  8436. // ResetGname resets all changes to the "gname" field.
  8437. func (m *ContactMutation) ResetGname() {
  8438. m.gname = nil
  8439. }
  8440. // SetV3 sets the "v3" field.
  8441. func (m *ContactMutation) SetV3(s string) {
  8442. m.v3 = &s
  8443. }
  8444. // V3 returns the value of the "v3" field in the mutation.
  8445. func (m *ContactMutation) V3() (r string, exists bool) {
  8446. v := m.v3
  8447. if v == nil {
  8448. return
  8449. }
  8450. return *v, true
  8451. }
  8452. // OldV3 returns the old "v3" field's value of the Contact entity.
  8453. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8455. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8456. if !m.op.Is(OpUpdateOne) {
  8457. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8458. }
  8459. if m.id == nil || m.oldValue == nil {
  8460. return v, errors.New("OldV3 requires an ID field in the mutation")
  8461. }
  8462. oldValue, err := m.oldValue(ctx)
  8463. if err != nil {
  8464. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8465. }
  8466. return oldValue.V3, nil
  8467. }
  8468. // ResetV3 resets all changes to the "v3" field.
  8469. func (m *ContactMutation) ResetV3() {
  8470. m.v3 = nil
  8471. }
  8472. // SetOrganizationID sets the "organization_id" field.
  8473. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8474. m.organization_id = &u
  8475. m.addorganization_id = nil
  8476. }
  8477. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8478. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8479. v := m.organization_id
  8480. if v == nil {
  8481. return
  8482. }
  8483. return *v, true
  8484. }
  8485. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8486. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8488. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8489. if !m.op.Is(OpUpdateOne) {
  8490. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8491. }
  8492. if m.id == nil || m.oldValue == nil {
  8493. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8494. }
  8495. oldValue, err := m.oldValue(ctx)
  8496. if err != nil {
  8497. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8498. }
  8499. return oldValue.OrganizationID, nil
  8500. }
  8501. // AddOrganizationID adds u to the "organization_id" field.
  8502. func (m *ContactMutation) AddOrganizationID(u int64) {
  8503. if m.addorganization_id != nil {
  8504. *m.addorganization_id += u
  8505. } else {
  8506. m.addorganization_id = &u
  8507. }
  8508. }
  8509. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8510. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8511. v := m.addorganization_id
  8512. if v == nil {
  8513. return
  8514. }
  8515. return *v, true
  8516. }
  8517. // ClearOrganizationID clears the value of the "organization_id" field.
  8518. func (m *ContactMutation) ClearOrganizationID() {
  8519. m.organization_id = nil
  8520. m.addorganization_id = nil
  8521. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8522. }
  8523. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8524. func (m *ContactMutation) OrganizationIDCleared() bool {
  8525. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8526. return ok
  8527. }
  8528. // ResetOrganizationID resets all changes to the "organization_id" field.
  8529. func (m *ContactMutation) ResetOrganizationID() {
  8530. m.organization_id = nil
  8531. m.addorganization_id = nil
  8532. delete(m.clearedFields, contact.FieldOrganizationID)
  8533. }
  8534. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8535. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8536. if m.contact_relationships == nil {
  8537. m.contact_relationships = make(map[uint64]struct{})
  8538. }
  8539. for i := range ids {
  8540. m.contact_relationships[ids[i]] = struct{}{}
  8541. }
  8542. }
  8543. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8544. func (m *ContactMutation) ClearContactRelationships() {
  8545. m.clearedcontact_relationships = true
  8546. }
  8547. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8548. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8549. return m.clearedcontact_relationships
  8550. }
  8551. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8552. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8553. if m.removedcontact_relationships == nil {
  8554. m.removedcontact_relationships = make(map[uint64]struct{})
  8555. }
  8556. for i := range ids {
  8557. delete(m.contact_relationships, ids[i])
  8558. m.removedcontact_relationships[ids[i]] = struct{}{}
  8559. }
  8560. }
  8561. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8562. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8563. for id := range m.removedcontact_relationships {
  8564. ids = append(ids, id)
  8565. }
  8566. return
  8567. }
  8568. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8569. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8570. for id := range m.contact_relationships {
  8571. ids = append(ids, id)
  8572. }
  8573. return
  8574. }
  8575. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8576. func (m *ContactMutation) ResetContactRelationships() {
  8577. m.contact_relationships = nil
  8578. m.clearedcontact_relationships = false
  8579. m.removedcontact_relationships = nil
  8580. }
  8581. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8582. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8583. if m.contact_messages == nil {
  8584. m.contact_messages = make(map[uint64]struct{})
  8585. }
  8586. for i := range ids {
  8587. m.contact_messages[ids[i]] = struct{}{}
  8588. }
  8589. }
  8590. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8591. func (m *ContactMutation) ClearContactMessages() {
  8592. m.clearedcontact_messages = true
  8593. }
  8594. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8595. func (m *ContactMutation) ContactMessagesCleared() bool {
  8596. return m.clearedcontact_messages
  8597. }
  8598. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8599. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8600. if m.removedcontact_messages == nil {
  8601. m.removedcontact_messages = make(map[uint64]struct{})
  8602. }
  8603. for i := range ids {
  8604. delete(m.contact_messages, ids[i])
  8605. m.removedcontact_messages[ids[i]] = struct{}{}
  8606. }
  8607. }
  8608. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8609. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8610. for id := range m.removedcontact_messages {
  8611. ids = append(ids, id)
  8612. }
  8613. return
  8614. }
  8615. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8616. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8617. for id := range m.contact_messages {
  8618. ids = append(ids, id)
  8619. }
  8620. return
  8621. }
  8622. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8623. func (m *ContactMutation) ResetContactMessages() {
  8624. m.contact_messages = nil
  8625. m.clearedcontact_messages = false
  8626. m.removedcontact_messages = nil
  8627. }
  8628. // Where appends a list predicates to the ContactMutation builder.
  8629. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8630. m.predicates = append(m.predicates, ps...)
  8631. }
  8632. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8633. // users can use type-assertion to append predicates that do not depend on any generated package.
  8634. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8635. p := make([]predicate.Contact, len(ps))
  8636. for i := range ps {
  8637. p[i] = ps[i]
  8638. }
  8639. m.Where(p...)
  8640. }
  8641. // Op returns the operation name.
  8642. func (m *ContactMutation) Op() Op {
  8643. return m.op
  8644. }
  8645. // SetOp allows setting the mutation operation.
  8646. func (m *ContactMutation) SetOp(op Op) {
  8647. m.op = op
  8648. }
  8649. // Type returns the node type of this mutation (Contact).
  8650. func (m *ContactMutation) Type() string {
  8651. return m.typ
  8652. }
  8653. // Fields returns all fields that were changed during this mutation. Note that in
  8654. // order to get all numeric fields that were incremented/decremented, call
  8655. // AddedFields().
  8656. func (m *ContactMutation) Fields() []string {
  8657. fields := make([]string, 0, 20)
  8658. if m.created_at != nil {
  8659. fields = append(fields, contact.FieldCreatedAt)
  8660. }
  8661. if m.updated_at != nil {
  8662. fields = append(fields, contact.FieldUpdatedAt)
  8663. }
  8664. if m.status != nil {
  8665. fields = append(fields, contact.FieldStatus)
  8666. }
  8667. if m.deleted_at != nil {
  8668. fields = append(fields, contact.FieldDeletedAt)
  8669. }
  8670. if m.wx_wxid != nil {
  8671. fields = append(fields, contact.FieldWxWxid)
  8672. }
  8673. if m._type != nil {
  8674. fields = append(fields, contact.FieldType)
  8675. }
  8676. if m.wxid != nil {
  8677. fields = append(fields, contact.FieldWxid)
  8678. }
  8679. if m.account != nil {
  8680. fields = append(fields, contact.FieldAccount)
  8681. }
  8682. if m.nickname != nil {
  8683. fields = append(fields, contact.FieldNickname)
  8684. }
  8685. if m.markname != nil {
  8686. fields = append(fields, contact.FieldMarkname)
  8687. }
  8688. if m.headimg != nil {
  8689. fields = append(fields, contact.FieldHeadimg)
  8690. }
  8691. if m.sex != nil {
  8692. fields = append(fields, contact.FieldSex)
  8693. }
  8694. if m.starrole != nil {
  8695. fields = append(fields, contact.FieldStarrole)
  8696. }
  8697. if m.dontseeit != nil {
  8698. fields = append(fields, contact.FieldDontseeit)
  8699. }
  8700. if m.dontseeme != nil {
  8701. fields = append(fields, contact.FieldDontseeme)
  8702. }
  8703. if m.lag != nil {
  8704. fields = append(fields, contact.FieldLag)
  8705. }
  8706. if m.gid != nil {
  8707. fields = append(fields, contact.FieldGid)
  8708. }
  8709. if m.gname != nil {
  8710. fields = append(fields, contact.FieldGname)
  8711. }
  8712. if m.v3 != nil {
  8713. fields = append(fields, contact.FieldV3)
  8714. }
  8715. if m.organization_id != nil {
  8716. fields = append(fields, contact.FieldOrganizationID)
  8717. }
  8718. return fields
  8719. }
  8720. // Field returns the value of a field with the given name. The second boolean
  8721. // return value indicates that this field was not set, or was not defined in the
  8722. // schema.
  8723. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8724. switch name {
  8725. case contact.FieldCreatedAt:
  8726. return m.CreatedAt()
  8727. case contact.FieldUpdatedAt:
  8728. return m.UpdatedAt()
  8729. case contact.FieldStatus:
  8730. return m.Status()
  8731. case contact.FieldDeletedAt:
  8732. return m.DeletedAt()
  8733. case contact.FieldWxWxid:
  8734. return m.WxWxid()
  8735. case contact.FieldType:
  8736. return m.GetType()
  8737. case contact.FieldWxid:
  8738. return m.Wxid()
  8739. case contact.FieldAccount:
  8740. return m.Account()
  8741. case contact.FieldNickname:
  8742. return m.Nickname()
  8743. case contact.FieldMarkname:
  8744. return m.Markname()
  8745. case contact.FieldHeadimg:
  8746. return m.Headimg()
  8747. case contact.FieldSex:
  8748. return m.Sex()
  8749. case contact.FieldStarrole:
  8750. return m.Starrole()
  8751. case contact.FieldDontseeit:
  8752. return m.Dontseeit()
  8753. case contact.FieldDontseeme:
  8754. return m.Dontseeme()
  8755. case contact.FieldLag:
  8756. return m.Lag()
  8757. case contact.FieldGid:
  8758. return m.Gid()
  8759. case contact.FieldGname:
  8760. return m.Gname()
  8761. case contact.FieldV3:
  8762. return m.V3()
  8763. case contact.FieldOrganizationID:
  8764. return m.OrganizationID()
  8765. }
  8766. return nil, false
  8767. }
  8768. // OldField returns the old value of the field from the database. An error is
  8769. // returned if the mutation operation is not UpdateOne, or the query to the
  8770. // database failed.
  8771. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8772. switch name {
  8773. case contact.FieldCreatedAt:
  8774. return m.OldCreatedAt(ctx)
  8775. case contact.FieldUpdatedAt:
  8776. return m.OldUpdatedAt(ctx)
  8777. case contact.FieldStatus:
  8778. return m.OldStatus(ctx)
  8779. case contact.FieldDeletedAt:
  8780. return m.OldDeletedAt(ctx)
  8781. case contact.FieldWxWxid:
  8782. return m.OldWxWxid(ctx)
  8783. case contact.FieldType:
  8784. return m.OldType(ctx)
  8785. case contact.FieldWxid:
  8786. return m.OldWxid(ctx)
  8787. case contact.FieldAccount:
  8788. return m.OldAccount(ctx)
  8789. case contact.FieldNickname:
  8790. return m.OldNickname(ctx)
  8791. case contact.FieldMarkname:
  8792. return m.OldMarkname(ctx)
  8793. case contact.FieldHeadimg:
  8794. return m.OldHeadimg(ctx)
  8795. case contact.FieldSex:
  8796. return m.OldSex(ctx)
  8797. case contact.FieldStarrole:
  8798. return m.OldStarrole(ctx)
  8799. case contact.FieldDontseeit:
  8800. return m.OldDontseeit(ctx)
  8801. case contact.FieldDontseeme:
  8802. return m.OldDontseeme(ctx)
  8803. case contact.FieldLag:
  8804. return m.OldLag(ctx)
  8805. case contact.FieldGid:
  8806. return m.OldGid(ctx)
  8807. case contact.FieldGname:
  8808. return m.OldGname(ctx)
  8809. case contact.FieldV3:
  8810. return m.OldV3(ctx)
  8811. case contact.FieldOrganizationID:
  8812. return m.OldOrganizationID(ctx)
  8813. }
  8814. return nil, fmt.Errorf("unknown Contact field %s", name)
  8815. }
  8816. // SetField sets the value of a field with the given name. It returns an error if
  8817. // the field is not defined in the schema, or if the type mismatched the field
  8818. // type.
  8819. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8820. switch name {
  8821. case contact.FieldCreatedAt:
  8822. v, ok := value.(time.Time)
  8823. if !ok {
  8824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8825. }
  8826. m.SetCreatedAt(v)
  8827. return nil
  8828. case contact.FieldUpdatedAt:
  8829. v, ok := value.(time.Time)
  8830. if !ok {
  8831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8832. }
  8833. m.SetUpdatedAt(v)
  8834. return nil
  8835. case contact.FieldStatus:
  8836. v, ok := value.(uint8)
  8837. if !ok {
  8838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8839. }
  8840. m.SetStatus(v)
  8841. return nil
  8842. case contact.FieldDeletedAt:
  8843. v, ok := value.(time.Time)
  8844. if !ok {
  8845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8846. }
  8847. m.SetDeletedAt(v)
  8848. return nil
  8849. case contact.FieldWxWxid:
  8850. v, ok := value.(string)
  8851. if !ok {
  8852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8853. }
  8854. m.SetWxWxid(v)
  8855. return nil
  8856. case contact.FieldType:
  8857. v, ok := value.(int)
  8858. if !ok {
  8859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8860. }
  8861. m.SetType(v)
  8862. return nil
  8863. case contact.FieldWxid:
  8864. v, ok := value.(string)
  8865. if !ok {
  8866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8867. }
  8868. m.SetWxid(v)
  8869. return nil
  8870. case contact.FieldAccount:
  8871. v, ok := value.(string)
  8872. if !ok {
  8873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8874. }
  8875. m.SetAccount(v)
  8876. return nil
  8877. case contact.FieldNickname:
  8878. v, ok := value.(string)
  8879. if !ok {
  8880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8881. }
  8882. m.SetNickname(v)
  8883. return nil
  8884. case contact.FieldMarkname:
  8885. v, ok := value.(string)
  8886. if !ok {
  8887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8888. }
  8889. m.SetMarkname(v)
  8890. return nil
  8891. case contact.FieldHeadimg:
  8892. v, ok := value.(string)
  8893. if !ok {
  8894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8895. }
  8896. m.SetHeadimg(v)
  8897. return nil
  8898. case contact.FieldSex:
  8899. v, ok := value.(int)
  8900. if !ok {
  8901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8902. }
  8903. m.SetSex(v)
  8904. return nil
  8905. case contact.FieldStarrole:
  8906. v, ok := value.(string)
  8907. if !ok {
  8908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8909. }
  8910. m.SetStarrole(v)
  8911. return nil
  8912. case contact.FieldDontseeit:
  8913. v, ok := value.(int)
  8914. if !ok {
  8915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8916. }
  8917. m.SetDontseeit(v)
  8918. return nil
  8919. case contact.FieldDontseeme:
  8920. v, ok := value.(int)
  8921. if !ok {
  8922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8923. }
  8924. m.SetDontseeme(v)
  8925. return nil
  8926. case contact.FieldLag:
  8927. v, ok := value.(string)
  8928. if !ok {
  8929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8930. }
  8931. m.SetLag(v)
  8932. return nil
  8933. case contact.FieldGid:
  8934. v, ok := value.(string)
  8935. if !ok {
  8936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8937. }
  8938. m.SetGid(v)
  8939. return nil
  8940. case contact.FieldGname:
  8941. v, ok := value.(string)
  8942. if !ok {
  8943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8944. }
  8945. m.SetGname(v)
  8946. return nil
  8947. case contact.FieldV3:
  8948. v, ok := value.(string)
  8949. if !ok {
  8950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8951. }
  8952. m.SetV3(v)
  8953. return nil
  8954. case contact.FieldOrganizationID:
  8955. v, ok := value.(uint64)
  8956. if !ok {
  8957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8958. }
  8959. m.SetOrganizationID(v)
  8960. return nil
  8961. }
  8962. return fmt.Errorf("unknown Contact field %s", name)
  8963. }
  8964. // AddedFields returns all numeric fields that were incremented/decremented during
  8965. // this mutation.
  8966. func (m *ContactMutation) AddedFields() []string {
  8967. var fields []string
  8968. if m.addstatus != nil {
  8969. fields = append(fields, contact.FieldStatus)
  8970. }
  8971. if m.add_type != nil {
  8972. fields = append(fields, contact.FieldType)
  8973. }
  8974. if m.addsex != nil {
  8975. fields = append(fields, contact.FieldSex)
  8976. }
  8977. if m.adddontseeit != nil {
  8978. fields = append(fields, contact.FieldDontseeit)
  8979. }
  8980. if m.adddontseeme != nil {
  8981. fields = append(fields, contact.FieldDontseeme)
  8982. }
  8983. if m.addorganization_id != nil {
  8984. fields = append(fields, contact.FieldOrganizationID)
  8985. }
  8986. return fields
  8987. }
  8988. // AddedField returns the numeric value that was incremented/decremented on a field
  8989. // with the given name. The second boolean return value indicates that this field
  8990. // was not set, or was not defined in the schema.
  8991. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8992. switch name {
  8993. case contact.FieldStatus:
  8994. return m.AddedStatus()
  8995. case contact.FieldType:
  8996. return m.AddedType()
  8997. case contact.FieldSex:
  8998. return m.AddedSex()
  8999. case contact.FieldDontseeit:
  9000. return m.AddedDontseeit()
  9001. case contact.FieldDontseeme:
  9002. return m.AddedDontseeme()
  9003. case contact.FieldOrganizationID:
  9004. return m.AddedOrganizationID()
  9005. }
  9006. return nil, false
  9007. }
  9008. // AddField adds the value to the field with the given name. It returns an error if
  9009. // the field is not defined in the schema, or if the type mismatched the field
  9010. // type.
  9011. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9012. switch name {
  9013. case contact.FieldStatus:
  9014. v, ok := value.(int8)
  9015. if !ok {
  9016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9017. }
  9018. m.AddStatus(v)
  9019. return nil
  9020. case contact.FieldType:
  9021. v, ok := value.(int)
  9022. if !ok {
  9023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9024. }
  9025. m.AddType(v)
  9026. return nil
  9027. case contact.FieldSex:
  9028. v, ok := value.(int)
  9029. if !ok {
  9030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9031. }
  9032. m.AddSex(v)
  9033. return nil
  9034. case contact.FieldDontseeit:
  9035. v, ok := value.(int)
  9036. if !ok {
  9037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9038. }
  9039. m.AddDontseeit(v)
  9040. return nil
  9041. case contact.FieldDontseeme:
  9042. v, ok := value.(int)
  9043. if !ok {
  9044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9045. }
  9046. m.AddDontseeme(v)
  9047. return nil
  9048. case contact.FieldOrganizationID:
  9049. v, ok := value.(int64)
  9050. if !ok {
  9051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9052. }
  9053. m.AddOrganizationID(v)
  9054. return nil
  9055. }
  9056. return fmt.Errorf("unknown Contact numeric field %s", name)
  9057. }
  9058. // ClearedFields returns all nullable fields that were cleared during this
  9059. // mutation.
  9060. func (m *ContactMutation) ClearedFields() []string {
  9061. var fields []string
  9062. if m.FieldCleared(contact.FieldStatus) {
  9063. fields = append(fields, contact.FieldStatus)
  9064. }
  9065. if m.FieldCleared(contact.FieldDeletedAt) {
  9066. fields = append(fields, contact.FieldDeletedAt)
  9067. }
  9068. if m.FieldCleared(contact.FieldType) {
  9069. fields = append(fields, contact.FieldType)
  9070. }
  9071. if m.FieldCleared(contact.FieldOrganizationID) {
  9072. fields = append(fields, contact.FieldOrganizationID)
  9073. }
  9074. return fields
  9075. }
  9076. // FieldCleared returns a boolean indicating if a field with the given name was
  9077. // cleared in this mutation.
  9078. func (m *ContactMutation) FieldCleared(name string) bool {
  9079. _, ok := m.clearedFields[name]
  9080. return ok
  9081. }
  9082. // ClearField clears the value of the field with the given name. It returns an
  9083. // error if the field is not defined in the schema.
  9084. func (m *ContactMutation) ClearField(name string) error {
  9085. switch name {
  9086. case contact.FieldStatus:
  9087. m.ClearStatus()
  9088. return nil
  9089. case contact.FieldDeletedAt:
  9090. m.ClearDeletedAt()
  9091. return nil
  9092. case contact.FieldType:
  9093. m.ClearType()
  9094. return nil
  9095. case contact.FieldOrganizationID:
  9096. m.ClearOrganizationID()
  9097. return nil
  9098. }
  9099. return fmt.Errorf("unknown Contact nullable field %s", name)
  9100. }
  9101. // ResetField resets all changes in the mutation for the field with the given name.
  9102. // It returns an error if the field is not defined in the schema.
  9103. func (m *ContactMutation) ResetField(name string) error {
  9104. switch name {
  9105. case contact.FieldCreatedAt:
  9106. m.ResetCreatedAt()
  9107. return nil
  9108. case contact.FieldUpdatedAt:
  9109. m.ResetUpdatedAt()
  9110. return nil
  9111. case contact.FieldStatus:
  9112. m.ResetStatus()
  9113. return nil
  9114. case contact.FieldDeletedAt:
  9115. m.ResetDeletedAt()
  9116. return nil
  9117. case contact.FieldWxWxid:
  9118. m.ResetWxWxid()
  9119. return nil
  9120. case contact.FieldType:
  9121. m.ResetType()
  9122. return nil
  9123. case contact.FieldWxid:
  9124. m.ResetWxid()
  9125. return nil
  9126. case contact.FieldAccount:
  9127. m.ResetAccount()
  9128. return nil
  9129. case contact.FieldNickname:
  9130. m.ResetNickname()
  9131. return nil
  9132. case contact.FieldMarkname:
  9133. m.ResetMarkname()
  9134. return nil
  9135. case contact.FieldHeadimg:
  9136. m.ResetHeadimg()
  9137. return nil
  9138. case contact.FieldSex:
  9139. m.ResetSex()
  9140. return nil
  9141. case contact.FieldStarrole:
  9142. m.ResetStarrole()
  9143. return nil
  9144. case contact.FieldDontseeit:
  9145. m.ResetDontseeit()
  9146. return nil
  9147. case contact.FieldDontseeme:
  9148. m.ResetDontseeme()
  9149. return nil
  9150. case contact.FieldLag:
  9151. m.ResetLag()
  9152. return nil
  9153. case contact.FieldGid:
  9154. m.ResetGid()
  9155. return nil
  9156. case contact.FieldGname:
  9157. m.ResetGname()
  9158. return nil
  9159. case contact.FieldV3:
  9160. m.ResetV3()
  9161. return nil
  9162. case contact.FieldOrganizationID:
  9163. m.ResetOrganizationID()
  9164. return nil
  9165. }
  9166. return fmt.Errorf("unknown Contact field %s", name)
  9167. }
  9168. // AddedEdges returns all edge names that were set/added in this mutation.
  9169. func (m *ContactMutation) AddedEdges() []string {
  9170. edges := make([]string, 0, 2)
  9171. if m.contact_relationships != nil {
  9172. edges = append(edges, contact.EdgeContactRelationships)
  9173. }
  9174. if m.contact_messages != nil {
  9175. edges = append(edges, contact.EdgeContactMessages)
  9176. }
  9177. return edges
  9178. }
  9179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9180. // name in this mutation.
  9181. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9182. switch name {
  9183. case contact.EdgeContactRelationships:
  9184. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9185. for id := range m.contact_relationships {
  9186. ids = append(ids, id)
  9187. }
  9188. return ids
  9189. case contact.EdgeContactMessages:
  9190. ids := make([]ent.Value, 0, len(m.contact_messages))
  9191. for id := range m.contact_messages {
  9192. ids = append(ids, id)
  9193. }
  9194. return ids
  9195. }
  9196. return nil
  9197. }
  9198. // RemovedEdges returns all edge names that were removed in this mutation.
  9199. func (m *ContactMutation) RemovedEdges() []string {
  9200. edges := make([]string, 0, 2)
  9201. if m.removedcontact_relationships != nil {
  9202. edges = append(edges, contact.EdgeContactRelationships)
  9203. }
  9204. if m.removedcontact_messages != nil {
  9205. edges = append(edges, contact.EdgeContactMessages)
  9206. }
  9207. return edges
  9208. }
  9209. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9210. // the given name in this mutation.
  9211. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9212. switch name {
  9213. case contact.EdgeContactRelationships:
  9214. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9215. for id := range m.removedcontact_relationships {
  9216. ids = append(ids, id)
  9217. }
  9218. return ids
  9219. case contact.EdgeContactMessages:
  9220. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9221. for id := range m.removedcontact_messages {
  9222. ids = append(ids, id)
  9223. }
  9224. return ids
  9225. }
  9226. return nil
  9227. }
  9228. // ClearedEdges returns all edge names that were cleared in this mutation.
  9229. func (m *ContactMutation) ClearedEdges() []string {
  9230. edges := make([]string, 0, 2)
  9231. if m.clearedcontact_relationships {
  9232. edges = append(edges, contact.EdgeContactRelationships)
  9233. }
  9234. if m.clearedcontact_messages {
  9235. edges = append(edges, contact.EdgeContactMessages)
  9236. }
  9237. return edges
  9238. }
  9239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9240. // was cleared in this mutation.
  9241. func (m *ContactMutation) EdgeCleared(name string) bool {
  9242. switch name {
  9243. case contact.EdgeContactRelationships:
  9244. return m.clearedcontact_relationships
  9245. case contact.EdgeContactMessages:
  9246. return m.clearedcontact_messages
  9247. }
  9248. return false
  9249. }
  9250. // ClearEdge clears the value of the edge with the given name. It returns an error
  9251. // if that edge is not defined in the schema.
  9252. func (m *ContactMutation) ClearEdge(name string) error {
  9253. switch name {
  9254. }
  9255. return fmt.Errorf("unknown Contact unique edge %s", name)
  9256. }
  9257. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9258. // It returns an error if the edge is not defined in the schema.
  9259. func (m *ContactMutation) ResetEdge(name string) error {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. m.ResetContactRelationships()
  9263. return nil
  9264. case contact.EdgeContactMessages:
  9265. m.ResetContactMessages()
  9266. return nil
  9267. }
  9268. return fmt.Errorf("unknown Contact edge %s", name)
  9269. }
  9270. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9271. type CreditBalanceMutation struct {
  9272. config
  9273. op Op
  9274. typ string
  9275. id *uint64
  9276. created_at *time.Time
  9277. updated_at *time.Time
  9278. deleted_at *time.Time
  9279. user_id *string
  9280. balance *float32
  9281. addbalance *float32
  9282. status *int
  9283. addstatus *int
  9284. organization_id *uint64
  9285. addorganization_id *int64
  9286. clearedFields map[string]struct{}
  9287. done bool
  9288. oldValue func(context.Context) (*CreditBalance, error)
  9289. predicates []predicate.CreditBalance
  9290. }
  9291. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9292. // creditbalanceOption allows management of the mutation configuration using functional options.
  9293. type creditbalanceOption func(*CreditBalanceMutation)
  9294. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9295. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9296. m := &CreditBalanceMutation{
  9297. config: c,
  9298. op: op,
  9299. typ: TypeCreditBalance,
  9300. clearedFields: make(map[string]struct{}),
  9301. }
  9302. for _, opt := range opts {
  9303. opt(m)
  9304. }
  9305. return m
  9306. }
  9307. // withCreditBalanceID sets the ID field of the mutation.
  9308. func withCreditBalanceID(id uint64) creditbalanceOption {
  9309. return func(m *CreditBalanceMutation) {
  9310. var (
  9311. err error
  9312. once sync.Once
  9313. value *CreditBalance
  9314. )
  9315. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9316. once.Do(func() {
  9317. if m.done {
  9318. err = errors.New("querying old values post mutation is not allowed")
  9319. } else {
  9320. value, err = m.Client().CreditBalance.Get(ctx, id)
  9321. }
  9322. })
  9323. return value, err
  9324. }
  9325. m.id = &id
  9326. }
  9327. }
  9328. // withCreditBalance sets the old CreditBalance of the mutation.
  9329. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9330. return func(m *CreditBalanceMutation) {
  9331. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9332. return node, nil
  9333. }
  9334. m.id = &node.ID
  9335. }
  9336. }
  9337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9338. // executed in a transaction (ent.Tx), a transactional client is returned.
  9339. func (m CreditBalanceMutation) Client() *Client {
  9340. client := &Client{config: m.config}
  9341. client.init()
  9342. return client
  9343. }
  9344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9345. // it returns an error otherwise.
  9346. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9347. if _, ok := m.driver.(*txDriver); !ok {
  9348. return nil, errors.New("ent: mutation is not running in a transaction")
  9349. }
  9350. tx := &Tx{config: m.config}
  9351. tx.init()
  9352. return tx, nil
  9353. }
  9354. // SetID sets the value of the id field. Note that this
  9355. // operation is only accepted on creation of CreditBalance entities.
  9356. func (m *CreditBalanceMutation) SetID(id uint64) {
  9357. m.id = &id
  9358. }
  9359. // ID returns the ID value in the mutation. Note that the ID is only available
  9360. // if it was provided to the builder or after it was returned from the database.
  9361. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9362. if m.id == nil {
  9363. return
  9364. }
  9365. return *m.id, true
  9366. }
  9367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9368. // That means, if the mutation is applied within a transaction with an isolation level such
  9369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9370. // or updated by the mutation.
  9371. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9372. switch {
  9373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9374. id, exists := m.ID()
  9375. if exists {
  9376. return []uint64{id}, nil
  9377. }
  9378. fallthrough
  9379. case m.op.Is(OpUpdate | OpDelete):
  9380. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9381. default:
  9382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9383. }
  9384. }
  9385. // SetCreatedAt sets the "created_at" field.
  9386. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9387. m.created_at = &t
  9388. }
  9389. // CreatedAt returns the value of the "created_at" field in the mutation.
  9390. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9391. v := m.created_at
  9392. if v == nil {
  9393. return
  9394. }
  9395. return *v, true
  9396. }
  9397. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9398. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9400. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9401. if !m.op.Is(OpUpdateOne) {
  9402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9403. }
  9404. if m.id == nil || m.oldValue == nil {
  9405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9406. }
  9407. oldValue, err := m.oldValue(ctx)
  9408. if err != nil {
  9409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9410. }
  9411. return oldValue.CreatedAt, nil
  9412. }
  9413. // ResetCreatedAt resets all changes to the "created_at" field.
  9414. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9415. m.created_at = nil
  9416. }
  9417. // SetUpdatedAt sets the "updated_at" field.
  9418. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9419. m.updated_at = &t
  9420. }
  9421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9422. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9423. v := m.updated_at
  9424. if v == nil {
  9425. return
  9426. }
  9427. return *v, true
  9428. }
  9429. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9430. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9432. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9433. if !m.op.Is(OpUpdateOne) {
  9434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9435. }
  9436. if m.id == nil || m.oldValue == nil {
  9437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9438. }
  9439. oldValue, err := m.oldValue(ctx)
  9440. if err != nil {
  9441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9442. }
  9443. return oldValue.UpdatedAt, nil
  9444. }
  9445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9446. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9447. m.updated_at = nil
  9448. }
  9449. // SetDeletedAt sets the "deleted_at" field.
  9450. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9451. m.deleted_at = &t
  9452. }
  9453. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9454. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9455. v := m.deleted_at
  9456. if v == nil {
  9457. return
  9458. }
  9459. return *v, true
  9460. }
  9461. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9462. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9464. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9465. if !m.op.Is(OpUpdateOne) {
  9466. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9467. }
  9468. if m.id == nil || m.oldValue == nil {
  9469. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9470. }
  9471. oldValue, err := m.oldValue(ctx)
  9472. if err != nil {
  9473. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9474. }
  9475. return oldValue.DeletedAt, nil
  9476. }
  9477. // ClearDeletedAt clears the value of the "deleted_at" field.
  9478. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9479. m.deleted_at = nil
  9480. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9481. }
  9482. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9483. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9484. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9485. return ok
  9486. }
  9487. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9488. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9489. m.deleted_at = nil
  9490. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9491. }
  9492. // SetUserID sets the "user_id" field.
  9493. func (m *CreditBalanceMutation) SetUserID(s string) {
  9494. m.user_id = &s
  9495. }
  9496. // UserID returns the value of the "user_id" field in the mutation.
  9497. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9498. v := m.user_id
  9499. if v == nil {
  9500. return
  9501. }
  9502. return *v, true
  9503. }
  9504. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9505. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9507. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9508. if !m.op.Is(OpUpdateOne) {
  9509. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9510. }
  9511. if m.id == nil || m.oldValue == nil {
  9512. return v, errors.New("OldUserID requires an ID field in the mutation")
  9513. }
  9514. oldValue, err := m.oldValue(ctx)
  9515. if err != nil {
  9516. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9517. }
  9518. return oldValue.UserID, nil
  9519. }
  9520. // ResetUserID resets all changes to the "user_id" field.
  9521. func (m *CreditBalanceMutation) ResetUserID() {
  9522. m.user_id = nil
  9523. }
  9524. // SetBalance sets the "balance" field.
  9525. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9526. m.balance = &f
  9527. m.addbalance = nil
  9528. }
  9529. // Balance returns the value of the "balance" field in the mutation.
  9530. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9531. v := m.balance
  9532. if v == nil {
  9533. return
  9534. }
  9535. return *v, true
  9536. }
  9537. // OldBalance returns the old "balance" 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) OldBalance(ctx context.Context) (v float32, err error) {
  9541. if !m.op.Is(OpUpdateOne) {
  9542. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9543. }
  9544. if m.id == nil || m.oldValue == nil {
  9545. return v, errors.New("OldBalance 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 OldBalance: %w", err)
  9550. }
  9551. return oldValue.Balance, nil
  9552. }
  9553. // AddBalance adds f to the "balance" field.
  9554. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9555. if m.addbalance != nil {
  9556. *m.addbalance += f
  9557. } else {
  9558. m.addbalance = &f
  9559. }
  9560. }
  9561. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9562. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9563. v := m.addbalance
  9564. if v == nil {
  9565. return
  9566. }
  9567. return *v, true
  9568. }
  9569. // ResetBalance resets all changes to the "balance" field.
  9570. func (m *CreditBalanceMutation) ResetBalance() {
  9571. m.balance = nil
  9572. m.addbalance = nil
  9573. }
  9574. // SetStatus sets the "status" field.
  9575. func (m *CreditBalanceMutation) SetStatus(i int) {
  9576. m.status = &i
  9577. m.addstatus = nil
  9578. }
  9579. // Status returns the value of the "status" field in the mutation.
  9580. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9581. v := m.status
  9582. if v == nil {
  9583. return
  9584. }
  9585. return *v, true
  9586. }
  9587. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9588. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9590. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9591. if !m.op.Is(OpUpdateOne) {
  9592. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9593. }
  9594. if m.id == nil || m.oldValue == nil {
  9595. return v, errors.New("OldStatus requires an ID field in the mutation")
  9596. }
  9597. oldValue, err := m.oldValue(ctx)
  9598. if err != nil {
  9599. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9600. }
  9601. return oldValue.Status, nil
  9602. }
  9603. // AddStatus adds i to the "status" field.
  9604. func (m *CreditBalanceMutation) AddStatus(i int) {
  9605. if m.addstatus != nil {
  9606. *m.addstatus += i
  9607. } else {
  9608. m.addstatus = &i
  9609. }
  9610. }
  9611. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9612. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9613. v := m.addstatus
  9614. if v == nil {
  9615. return
  9616. }
  9617. return *v, true
  9618. }
  9619. // ClearStatus clears the value of the "status" field.
  9620. func (m *CreditBalanceMutation) ClearStatus() {
  9621. m.status = nil
  9622. m.addstatus = nil
  9623. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9624. }
  9625. // StatusCleared returns if the "status" field was cleared in this mutation.
  9626. func (m *CreditBalanceMutation) StatusCleared() bool {
  9627. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9628. return ok
  9629. }
  9630. // ResetStatus resets all changes to the "status" field.
  9631. func (m *CreditBalanceMutation) ResetStatus() {
  9632. m.status = nil
  9633. m.addstatus = nil
  9634. delete(m.clearedFields, creditbalance.FieldStatus)
  9635. }
  9636. // SetOrganizationID sets the "organization_id" field.
  9637. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9638. m.organization_id = &u
  9639. m.addorganization_id = nil
  9640. }
  9641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9642. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9643. v := m.organization_id
  9644. if v == nil {
  9645. return
  9646. }
  9647. return *v, true
  9648. }
  9649. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9650. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9652. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9653. if !m.op.Is(OpUpdateOne) {
  9654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9655. }
  9656. if m.id == nil || m.oldValue == nil {
  9657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9658. }
  9659. oldValue, err := m.oldValue(ctx)
  9660. if err != nil {
  9661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9662. }
  9663. return oldValue.OrganizationID, nil
  9664. }
  9665. // AddOrganizationID adds u to the "organization_id" field.
  9666. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9667. if m.addorganization_id != nil {
  9668. *m.addorganization_id += u
  9669. } else {
  9670. m.addorganization_id = &u
  9671. }
  9672. }
  9673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9674. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9675. v := m.addorganization_id
  9676. if v == nil {
  9677. return
  9678. }
  9679. return *v, true
  9680. }
  9681. // ResetOrganizationID resets all changes to the "organization_id" field.
  9682. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9683. m.organization_id = nil
  9684. m.addorganization_id = nil
  9685. }
  9686. // Where appends a list predicates to the CreditBalanceMutation builder.
  9687. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9688. m.predicates = append(m.predicates, ps...)
  9689. }
  9690. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9691. // users can use type-assertion to append predicates that do not depend on any generated package.
  9692. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9693. p := make([]predicate.CreditBalance, len(ps))
  9694. for i := range ps {
  9695. p[i] = ps[i]
  9696. }
  9697. m.Where(p...)
  9698. }
  9699. // Op returns the operation name.
  9700. func (m *CreditBalanceMutation) Op() Op {
  9701. return m.op
  9702. }
  9703. // SetOp allows setting the mutation operation.
  9704. func (m *CreditBalanceMutation) SetOp(op Op) {
  9705. m.op = op
  9706. }
  9707. // Type returns the node type of this mutation (CreditBalance).
  9708. func (m *CreditBalanceMutation) Type() string {
  9709. return m.typ
  9710. }
  9711. // Fields returns all fields that were changed during this mutation. Note that in
  9712. // order to get all numeric fields that were incremented/decremented, call
  9713. // AddedFields().
  9714. func (m *CreditBalanceMutation) Fields() []string {
  9715. fields := make([]string, 0, 7)
  9716. if m.created_at != nil {
  9717. fields = append(fields, creditbalance.FieldCreatedAt)
  9718. }
  9719. if m.updated_at != nil {
  9720. fields = append(fields, creditbalance.FieldUpdatedAt)
  9721. }
  9722. if m.deleted_at != nil {
  9723. fields = append(fields, creditbalance.FieldDeletedAt)
  9724. }
  9725. if m.user_id != nil {
  9726. fields = append(fields, creditbalance.FieldUserID)
  9727. }
  9728. if m.balance != nil {
  9729. fields = append(fields, creditbalance.FieldBalance)
  9730. }
  9731. if m.status != nil {
  9732. fields = append(fields, creditbalance.FieldStatus)
  9733. }
  9734. if m.organization_id != nil {
  9735. fields = append(fields, creditbalance.FieldOrganizationID)
  9736. }
  9737. return fields
  9738. }
  9739. // Field returns the value of a field with the given name. The second boolean
  9740. // return value indicates that this field was not set, or was not defined in the
  9741. // schema.
  9742. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9743. switch name {
  9744. case creditbalance.FieldCreatedAt:
  9745. return m.CreatedAt()
  9746. case creditbalance.FieldUpdatedAt:
  9747. return m.UpdatedAt()
  9748. case creditbalance.FieldDeletedAt:
  9749. return m.DeletedAt()
  9750. case creditbalance.FieldUserID:
  9751. return m.UserID()
  9752. case creditbalance.FieldBalance:
  9753. return m.Balance()
  9754. case creditbalance.FieldStatus:
  9755. return m.Status()
  9756. case creditbalance.FieldOrganizationID:
  9757. return m.OrganizationID()
  9758. }
  9759. return nil, false
  9760. }
  9761. // OldField returns the old value of the field from the database. An error is
  9762. // returned if the mutation operation is not UpdateOne, or the query to the
  9763. // database failed.
  9764. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9765. switch name {
  9766. case creditbalance.FieldCreatedAt:
  9767. return m.OldCreatedAt(ctx)
  9768. case creditbalance.FieldUpdatedAt:
  9769. return m.OldUpdatedAt(ctx)
  9770. case creditbalance.FieldDeletedAt:
  9771. return m.OldDeletedAt(ctx)
  9772. case creditbalance.FieldUserID:
  9773. return m.OldUserID(ctx)
  9774. case creditbalance.FieldBalance:
  9775. return m.OldBalance(ctx)
  9776. case creditbalance.FieldStatus:
  9777. return m.OldStatus(ctx)
  9778. case creditbalance.FieldOrganizationID:
  9779. return m.OldOrganizationID(ctx)
  9780. }
  9781. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9782. }
  9783. // SetField sets the value of a field with the given name. It returns an error if
  9784. // the field is not defined in the schema, or if the type mismatched the field
  9785. // type.
  9786. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9787. switch name {
  9788. case creditbalance.FieldCreatedAt:
  9789. v, ok := value.(time.Time)
  9790. if !ok {
  9791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9792. }
  9793. m.SetCreatedAt(v)
  9794. return nil
  9795. case creditbalance.FieldUpdatedAt:
  9796. v, ok := value.(time.Time)
  9797. if !ok {
  9798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9799. }
  9800. m.SetUpdatedAt(v)
  9801. return nil
  9802. case creditbalance.FieldDeletedAt:
  9803. v, ok := value.(time.Time)
  9804. if !ok {
  9805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9806. }
  9807. m.SetDeletedAt(v)
  9808. return nil
  9809. case creditbalance.FieldUserID:
  9810. v, ok := value.(string)
  9811. if !ok {
  9812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9813. }
  9814. m.SetUserID(v)
  9815. return nil
  9816. case creditbalance.FieldBalance:
  9817. v, ok := value.(float32)
  9818. if !ok {
  9819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9820. }
  9821. m.SetBalance(v)
  9822. return nil
  9823. case creditbalance.FieldStatus:
  9824. v, ok := value.(int)
  9825. if !ok {
  9826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9827. }
  9828. m.SetStatus(v)
  9829. return nil
  9830. case creditbalance.FieldOrganizationID:
  9831. v, ok := value.(uint64)
  9832. if !ok {
  9833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9834. }
  9835. m.SetOrganizationID(v)
  9836. return nil
  9837. }
  9838. return fmt.Errorf("unknown CreditBalance field %s", name)
  9839. }
  9840. // AddedFields returns all numeric fields that were incremented/decremented during
  9841. // this mutation.
  9842. func (m *CreditBalanceMutation) AddedFields() []string {
  9843. var fields []string
  9844. if m.addbalance != nil {
  9845. fields = append(fields, creditbalance.FieldBalance)
  9846. }
  9847. if m.addstatus != nil {
  9848. fields = append(fields, creditbalance.FieldStatus)
  9849. }
  9850. if m.addorganization_id != nil {
  9851. fields = append(fields, creditbalance.FieldOrganizationID)
  9852. }
  9853. return fields
  9854. }
  9855. // AddedField returns the numeric value that was incremented/decremented on a field
  9856. // with the given name. The second boolean return value indicates that this field
  9857. // was not set, or was not defined in the schema.
  9858. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9859. switch name {
  9860. case creditbalance.FieldBalance:
  9861. return m.AddedBalance()
  9862. case creditbalance.FieldStatus:
  9863. return m.AddedStatus()
  9864. case creditbalance.FieldOrganizationID:
  9865. return m.AddedOrganizationID()
  9866. }
  9867. return nil, false
  9868. }
  9869. // AddField adds the value to the field with the given name. It returns an error if
  9870. // the field is not defined in the schema, or if the type mismatched the field
  9871. // type.
  9872. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9873. switch name {
  9874. case creditbalance.FieldBalance:
  9875. v, ok := value.(float32)
  9876. if !ok {
  9877. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9878. }
  9879. m.AddBalance(v)
  9880. return nil
  9881. case creditbalance.FieldStatus:
  9882. v, ok := value.(int)
  9883. if !ok {
  9884. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9885. }
  9886. m.AddStatus(v)
  9887. return nil
  9888. case creditbalance.FieldOrganizationID:
  9889. v, ok := value.(int64)
  9890. if !ok {
  9891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9892. }
  9893. m.AddOrganizationID(v)
  9894. return nil
  9895. }
  9896. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9897. }
  9898. // ClearedFields returns all nullable fields that were cleared during this
  9899. // mutation.
  9900. func (m *CreditBalanceMutation) ClearedFields() []string {
  9901. var fields []string
  9902. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9903. fields = append(fields, creditbalance.FieldDeletedAt)
  9904. }
  9905. if m.FieldCleared(creditbalance.FieldStatus) {
  9906. fields = append(fields, creditbalance.FieldStatus)
  9907. }
  9908. return fields
  9909. }
  9910. // FieldCleared returns a boolean indicating if a field with the given name was
  9911. // cleared in this mutation.
  9912. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  9913. _, ok := m.clearedFields[name]
  9914. return ok
  9915. }
  9916. // ClearField clears the value of the field with the given name. It returns an
  9917. // error if the field is not defined in the schema.
  9918. func (m *CreditBalanceMutation) ClearField(name string) error {
  9919. switch name {
  9920. case creditbalance.FieldDeletedAt:
  9921. m.ClearDeletedAt()
  9922. return nil
  9923. case creditbalance.FieldStatus:
  9924. m.ClearStatus()
  9925. return nil
  9926. }
  9927. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  9928. }
  9929. // ResetField resets all changes in the mutation for the field with the given name.
  9930. // It returns an error if the field is not defined in the schema.
  9931. func (m *CreditBalanceMutation) ResetField(name string) error {
  9932. switch name {
  9933. case creditbalance.FieldCreatedAt:
  9934. m.ResetCreatedAt()
  9935. return nil
  9936. case creditbalance.FieldUpdatedAt:
  9937. m.ResetUpdatedAt()
  9938. return nil
  9939. case creditbalance.FieldDeletedAt:
  9940. m.ResetDeletedAt()
  9941. return nil
  9942. case creditbalance.FieldUserID:
  9943. m.ResetUserID()
  9944. return nil
  9945. case creditbalance.FieldBalance:
  9946. m.ResetBalance()
  9947. return nil
  9948. case creditbalance.FieldStatus:
  9949. m.ResetStatus()
  9950. return nil
  9951. case creditbalance.FieldOrganizationID:
  9952. m.ResetOrganizationID()
  9953. return nil
  9954. }
  9955. return fmt.Errorf("unknown CreditBalance field %s", name)
  9956. }
  9957. // AddedEdges returns all edge names that were set/added in this mutation.
  9958. func (m *CreditBalanceMutation) AddedEdges() []string {
  9959. edges := make([]string, 0, 0)
  9960. return edges
  9961. }
  9962. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9963. // name in this mutation.
  9964. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  9965. return nil
  9966. }
  9967. // RemovedEdges returns all edge names that were removed in this mutation.
  9968. func (m *CreditBalanceMutation) RemovedEdges() []string {
  9969. edges := make([]string, 0, 0)
  9970. return edges
  9971. }
  9972. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9973. // the given name in this mutation.
  9974. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  9975. return nil
  9976. }
  9977. // ClearedEdges returns all edge names that were cleared in this mutation.
  9978. func (m *CreditBalanceMutation) ClearedEdges() []string {
  9979. edges := make([]string, 0, 0)
  9980. return edges
  9981. }
  9982. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9983. // was cleared in this mutation.
  9984. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  9985. return false
  9986. }
  9987. // ClearEdge clears the value of the edge with the given name. It returns an error
  9988. // if that edge is not defined in the schema.
  9989. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  9990. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  9991. }
  9992. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9993. // It returns an error if the edge is not defined in the schema.
  9994. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  9995. return fmt.Errorf("unknown CreditBalance edge %s", name)
  9996. }
  9997. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  9998. type CreditUsageMutation struct {
  9999. config
  10000. op Op
  10001. typ string
  10002. id *uint64
  10003. created_at *time.Time
  10004. updated_at *time.Time
  10005. deleted_at *time.Time
  10006. user_id *string
  10007. number *float32
  10008. addnumber *float32
  10009. status *int
  10010. addstatus *int
  10011. ntype *int
  10012. addntype *int
  10013. table *string
  10014. organization_id *uint64
  10015. addorganization_id *int64
  10016. nid *uint64
  10017. addnid *int64
  10018. reason *string
  10019. operator *string
  10020. clearedFields map[string]struct{}
  10021. done bool
  10022. oldValue func(context.Context) (*CreditUsage, error)
  10023. predicates []predicate.CreditUsage
  10024. }
  10025. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10026. // creditusageOption allows management of the mutation configuration using functional options.
  10027. type creditusageOption func(*CreditUsageMutation)
  10028. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10029. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10030. m := &CreditUsageMutation{
  10031. config: c,
  10032. op: op,
  10033. typ: TypeCreditUsage,
  10034. clearedFields: make(map[string]struct{}),
  10035. }
  10036. for _, opt := range opts {
  10037. opt(m)
  10038. }
  10039. return m
  10040. }
  10041. // withCreditUsageID sets the ID field of the mutation.
  10042. func withCreditUsageID(id uint64) creditusageOption {
  10043. return func(m *CreditUsageMutation) {
  10044. var (
  10045. err error
  10046. once sync.Once
  10047. value *CreditUsage
  10048. )
  10049. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10050. once.Do(func() {
  10051. if m.done {
  10052. err = errors.New("querying old values post mutation is not allowed")
  10053. } else {
  10054. value, err = m.Client().CreditUsage.Get(ctx, id)
  10055. }
  10056. })
  10057. return value, err
  10058. }
  10059. m.id = &id
  10060. }
  10061. }
  10062. // withCreditUsage sets the old CreditUsage of the mutation.
  10063. func withCreditUsage(node *CreditUsage) creditusageOption {
  10064. return func(m *CreditUsageMutation) {
  10065. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10066. return node, nil
  10067. }
  10068. m.id = &node.ID
  10069. }
  10070. }
  10071. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10072. // executed in a transaction (ent.Tx), a transactional client is returned.
  10073. func (m CreditUsageMutation) Client() *Client {
  10074. client := &Client{config: m.config}
  10075. client.init()
  10076. return client
  10077. }
  10078. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10079. // it returns an error otherwise.
  10080. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10081. if _, ok := m.driver.(*txDriver); !ok {
  10082. return nil, errors.New("ent: mutation is not running in a transaction")
  10083. }
  10084. tx := &Tx{config: m.config}
  10085. tx.init()
  10086. return tx, nil
  10087. }
  10088. // SetID sets the value of the id field. Note that this
  10089. // operation is only accepted on creation of CreditUsage entities.
  10090. func (m *CreditUsageMutation) SetID(id uint64) {
  10091. m.id = &id
  10092. }
  10093. // ID returns the ID value in the mutation. Note that the ID is only available
  10094. // if it was provided to the builder or after it was returned from the database.
  10095. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10096. if m.id == nil {
  10097. return
  10098. }
  10099. return *m.id, true
  10100. }
  10101. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10102. // That means, if the mutation is applied within a transaction with an isolation level such
  10103. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10104. // or updated by the mutation.
  10105. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10106. switch {
  10107. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10108. id, exists := m.ID()
  10109. if exists {
  10110. return []uint64{id}, nil
  10111. }
  10112. fallthrough
  10113. case m.op.Is(OpUpdate | OpDelete):
  10114. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10115. default:
  10116. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10117. }
  10118. }
  10119. // SetCreatedAt sets the "created_at" field.
  10120. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10121. m.created_at = &t
  10122. }
  10123. // CreatedAt returns the value of the "created_at" field in the mutation.
  10124. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10125. v := m.created_at
  10126. if v == nil {
  10127. return
  10128. }
  10129. return *v, true
  10130. }
  10131. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10132. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10133. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10134. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10135. if !m.op.Is(OpUpdateOne) {
  10136. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10137. }
  10138. if m.id == nil || m.oldValue == nil {
  10139. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10140. }
  10141. oldValue, err := m.oldValue(ctx)
  10142. if err != nil {
  10143. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10144. }
  10145. return oldValue.CreatedAt, nil
  10146. }
  10147. // ResetCreatedAt resets all changes to the "created_at" field.
  10148. func (m *CreditUsageMutation) ResetCreatedAt() {
  10149. m.created_at = nil
  10150. }
  10151. // SetUpdatedAt sets the "updated_at" field.
  10152. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10153. m.updated_at = &t
  10154. }
  10155. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10156. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10157. v := m.updated_at
  10158. if v == nil {
  10159. return
  10160. }
  10161. return *v, true
  10162. }
  10163. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10164. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10166. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10167. if !m.op.Is(OpUpdateOne) {
  10168. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10169. }
  10170. if m.id == nil || m.oldValue == nil {
  10171. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10172. }
  10173. oldValue, err := m.oldValue(ctx)
  10174. if err != nil {
  10175. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10176. }
  10177. return oldValue.UpdatedAt, nil
  10178. }
  10179. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10180. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10181. m.updated_at = nil
  10182. }
  10183. // SetDeletedAt sets the "deleted_at" field.
  10184. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10185. m.deleted_at = &t
  10186. }
  10187. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10188. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10189. v := m.deleted_at
  10190. if v == nil {
  10191. return
  10192. }
  10193. return *v, true
  10194. }
  10195. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10196. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10198. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10199. if !m.op.Is(OpUpdateOne) {
  10200. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10201. }
  10202. if m.id == nil || m.oldValue == nil {
  10203. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10204. }
  10205. oldValue, err := m.oldValue(ctx)
  10206. if err != nil {
  10207. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10208. }
  10209. return oldValue.DeletedAt, nil
  10210. }
  10211. // ClearDeletedAt clears the value of the "deleted_at" field.
  10212. func (m *CreditUsageMutation) ClearDeletedAt() {
  10213. m.deleted_at = nil
  10214. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10215. }
  10216. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10217. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10218. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10219. return ok
  10220. }
  10221. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10222. func (m *CreditUsageMutation) ResetDeletedAt() {
  10223. m.deleted_at = nil
  10224. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10225. }
  10226. // SetUserID sets the "user_id" field.
  10227. func (m *CreditUsageMutation) SetUserID(s string) {
  10228. m.user_id = &s
  10229. }
  10230. // UserID returns the value of the "user_id" field in the mutation.
  10231. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10232. v := m.user_id
  10233. if v == nil {
  10234. return
  10235. }
  10236. return *v, true
  10237. }
  10238. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10239. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10241. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10242. if !m.op.Is(OpUpdateOne) {
  10243. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10244. }
  10245. if m.id == nil || m.oldValue == nil {
  10246. return v, errors.New("OldUserID requires an ID field in the mutation")
  10247. }
  10248. oldValue, err := m.oldValue(ctx)
  10249. if err != nil {
  10250. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10251. }
  10252. return oldValue.UserID, nil
  10253. }
  10254. // ResetUserID resets all changes to the "user_id" field.
  10255. func (m *CreditUsageMutation) ResetUserID() {
  10256. m.user_id = nil
  10257. }
  10258. // SetNumber sets the "number" field.
  10259. func (m *CreditUsageMutation) SetNumber(f float32) {
  10260. m.number = &f
  10261. m.addnumber = nil
  10262. }
  10263. // Number returns the value of the "number" field in the mutation.
  10264. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10265. v := m.number
  10266. if v == nil {
  10267. return
  10268. }
  10269. return *v, true
  10270. }
  10271. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10272. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10274. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10275. if !m.op.Is(OpUpdateOne) {
  10276. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10277. }
  10278. if m.id == nil || m.oldValue == nil {
  10279. return v, errors.New("OldNumber requires an ID field in the mutation")
  10280. }
  10281. oldValue, err := m.oldValue(ctx)
  10282. if err != nil {
  10283. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10284. }
  10285. return oldValue.Number, nil
  10286. }
  10287. // AddNumber adds f to the "number" field.
  10288. func (m *CreditUsageMutation) AddNumber(f float32) {
  10289. if m.addnumber != nil {
  10290. *m.addnumber += f
  10291. } else {
  10292. m.addnumber = &f
  10293. }
  10294. }
  10295. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10296. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10297. v := m.addnumber
  10298. if v == nil {
  10299. return
  10300. }
  10301. return *v, true
  10302. }
  10303. // ResetNumber resets all changes to the "number" field.
  10304. func (m *CreditUsageMutation) ResetNumber() {
  10305. m.number = nil
  10306. m.addnumber = nil
  10307. }
  10308. // SetStatus sets the "status" field.
  10309. func (m *CreditUsageMutation) SetStatus(i int) {
  10310. m.status = &i
  10311. m.addstatus = nil
  10312. }
  10313. // Status returns the value of the "status" field in the mutation.
  10314. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10315. v := m.status
  10316. if v == nil {
  10317. return
  10318. }
  10319. return *v, true
  10320. }
  10321. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10322. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10324. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10325. if !m.op.Is(OpUpdateOne) {
  10326. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10327. }
  10328. if m.id == nil || m.oldValue == nil {
  10329. return v, errors.New("OldStatus requires an ID field in the mutation")
  10330. }
  10331. oldValue, err := m.oldValue(ctx)
  10332. if err != nil {
  10333. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10334. }
  10335. return oldValue.Status, nil
  10336. }
  10337. // AddStatus adds i to the "status" field.
  10338. func (m *CreditUsageMutation) AddStatus(i int) {
  10339. if m.addstatus != nil {
  10340. *m.addstatus += i
  10341. } else {
  10342. m.addstatus = &i
  10343. }
  10344. }
  10345. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10346. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10347. v := m.addstatus
  10348. if v == nil {
  10349. return
  10350. }
  10351. return *v, true
  10352. }
  10353. // ClearStatus clears the value of the "status" field.
  10354. func (m *CreditUsageMutation) ClearStatus() {
  10355. m.status = nil
  10356. m.addstatus = nil
  10357. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10358. }
  10359. // StatusCleared returns if the "status" field was cleared in this mutation.
  10360. func (m *CreditUsageMutation) StatusCleared() bool {
  10361. _, ok := m.clearedFields[creditusage.FieldStatus]
  10362. return ok
  10363. }
  10364. // ResetStatus resets all changes to the "status" field.
  10365. func (m *CreditUsageMutation) ResetStatus() {
  10366. m.status = nil
  10367. m.addstatus = nil
  10368. delete(m.clearedFields, creditusage.FieldStatus)
  10369. }
  10370. // SetNtype sets the "ntype" field.
  10371. func (m *CreditUsageMutation) SetNtype(i int) {
  10372. m.ntype = &i
  10373. m.addntype = nil
  10374. }
  10375. // Ntype returns the value of the "ntype" field in the mutation.
  10376. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10377. v := m.ntype
  10378. if v == nil {
  10379. return
  10380. }
  10381. return *v, true
  10382. }
  10383. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10384. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10386. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10387. if !m.op.Is(OpUpdateOne) {
  10388. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10389. }
  10390. if m.id == nil || m.oldValue == nil {
  10391. return v, errors.New("OldNtype requires an ID field in the mutation")
  10392. }
  10393. oldValue, err := m.oldValue(ctx)
  10394. if err != nil {
  10395. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10396. }
  10397. return oldValue.Ntype, nil
  10398. }
  10399. // AddNtype adds i to the "ntype" field.
  10400. func (m *CreditUsageMutation) AddNtype(i int) {
  10401. if m.addntype != nil {
  10402. *m.addntype += i
  10403. } else {
  10404. m.addntype = &i
  10405. }
  10406. }
  10407. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10408. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10409. v := m.addntype
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // ResetNtype resets all changes to the "ntype" field.
  10416. func (m *CreditUsageMutation) ResetNtype() {
  10417. m.ntype = nil
  10418. m.addntype = nil
  10419. }
  10420. // SetTable sets the "table" field.
  10421. func (m *CreditUsageMutation) SetTable(s string) {
  10422. m.table = &s
  10423. }
  10424. // Table returns the value of the "table" field in the mutation.
  10425. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10426. v := m.table
  10427. if v == nil {
  10428. return
  10429. }
  10430. return *v, true
  10431. }
  10432. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10433. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10435. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10436. if !m.op.Is(OpUpdateOne) {
  10437. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10438. }
  10439. if m.id == nil || m.oldValue == nil {
  10440. return v, errors.New("OldTable requires an ID field in the mutation")
  10441. }
  10442. oldValue, err := m.oldValue(ctx)
  10443. if err != nil {
  10444. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10445. }
  10446. return oldValue.Table, nil
  10447. }
  10448. // ResetTable resets all changes to the "table" field.
  10449. func (m *CreditUsageMutation) ResetTable() {
  10450. m.table = nil
  10451. }
  10452. // SetOrganizationID sets the "organization_id" field.
  10453. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10454. m.organization_id = &u
  10455. m.addorganization_id = nil
  10456. }
  10457. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10458. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10459. v := m.organization_id
  10460. if v == nil {
  10461. return
  10462. }
  10463. return *v, true
  10464. }
  10465. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10466. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10468. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10469. if !m.op.Is(OpUpdateOne) {
  10470. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10471. }
  10472. if m.id == nil || m.oldValue == nil {
  10473. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10474. }
  10475. oldValue, err := m.oldValue(ctx)
  10476. if err != nil {
  10477. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10478. }
  10479. return oldValue.OrganizationID, nil
  10480. }
  10481. // AddOrganizationID adds u to the "organization_id" field.
  10482. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10483. if m.addorganization_id != nil {
  10484. *m.addorganization_id += u
  10485. } else {
  10486. m.addorganization_id = &u
  10487. }
  10488. }
  10489. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10490. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10491. v := m.addorganization_id
  10492. if v == nil {
  10493. return
  10494. }
  10495. return *v, true
  10496. }
  10497. // ResetOrganizationID resets all changes to the "organization_id" field.
  10498. func (m *CreditUsageMutation) ResetOrganizationID() {
  10499. m.organization_id = nil
  10500. m.addorganization_id = nil
  10501. }
  10502. // SetNid sets the "nid" field.
  10503. func (m *CreditUsageMutation) SetNid(u uint64) {
  10504. m.nid = &u
  10505. m.addnid = nil
  10506. }
  10507. // Nid returns the value of the "nid" field in the mutation.
  10508. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10509. v := m.nid
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10516. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10518. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10519. if !m.op.Is(OpUpdateOne) {
  10520. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10521. }
  10522. if m.id == nil || m.oldValue == nil {
  10523. return v, errors.New("OldNid requires an ID field in the mutation")
  10524. }
  10525. oldValue, err := m.oldValue(ctx)
  10526. if err != nil {
  10527. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10528. }
  10529. return oldValue.Nid, nil
  10530. }
  10531. // AddNid adds u to the "nid" field.
  10532. func (m *CreditUsageMutation) AddNid(u int64) {
  10533. if m.addnid != nil {
  10534. *m.addnid += u
  10535. } else {
  10536. m.addnid = &u
  10537. }
  10538. }
  10539. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10540. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10541. v := m.addnid
  10542. if v == nil {
  10543. return
  10544. }
  10545. return *v, true
  10546. }
  10547. // ResetNid resets all changes to the "nid" field.
  10548. func (m *CreditUsageMutation) ResetNid() {
  10549. m.nid = nil
  10550. m.addnid = nil
  10551. }
  10552. // SetReason sets the "reason" field.
  10553. func (m *CreditUsageMutation) SetReason(s string) {
  10554. m.reason = &s
  10555. }
  10556. // Reason returns the value of the "reason" field in the mutation.
  10557. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10558. v := m.reason
  10559. if v == nil {
  10560. return
  10561. }
  10562. return *v, true
  10563. }
  10564. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10565. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10566. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10567. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10568. if !m.op.Is(OpUpdateOne) {
  10569. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10570. }
  10571. if m.id == nil || m.oldValue == nil {
  10572. return v, errors.New("OldReason requires an ID field in the mutation")
  10573. }
  10574. oldValue, err := m.oldValue(ctx)
  10575. if err != nil {
  10576. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10577. }
  10578. return oldValue.Reason, nil
  10579. }
  10580. // ResetReason resets all changes to the "reason" field.
  10581. func (m *CreditUsageMutation) ResetReason() {
  10582. m.reason = nil
  10583. }
  10584. // SetOperator sets the "operator" field.
  10585. func (m *CreditUsageMutation) SetOperator(s string) {
  10586. m.operator = &s
  10587. }
  10588. // Operator returns the value of the "operator" field in the mutation.
  10589. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10590. v := m.operator
  10591. if v == nil {
  10592. return
  10593. }
  10594. return *v, true
  10595. }
  10596. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10597. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10599. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10600. if !m.op.Is(OpUpdateOne) {
  10601. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10602. }
  10603. if m.id == nil || m.oldValue == nil {
  10604. return v, errors.New("OldOperator requires an ID field in the mutation")
  10605. }
  10606. oldValue, err := m.oldValue(ctx)
  10607. if err != nil {
  10608. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10609. }
  10610. return oldValue.Operator, nil
  10611. }
  10612. // ResetOperator resets all changes to the "operator" field.
  10613. func (m *CreditUsageMutation) ResetOperator() {
  10614. m.operator = nil
  10615. }
  10616. // Where appends a list predicates to the CreditUsageMutation builder.
  10617. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10618. m.predicates = append(m.predicates, ps...)
  10619. }
  10620. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10621. // users can use type-assertion to append predicates that do not depend on any generated package.
  10622. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10623. p := make([]predicate.CreditUsage, len(ps))
  10624. for i := range ps {
  10625. p[i] = ps[i]
  10626. }
  10627. m.Where(p...)
  10628. }
  10629. // Op returns the operation name.
  10630. func (m *CreditUsageMutation) Op() Op {
  10631. return m.op
  10632. }
  10633. // SetOp allows setting the mutation operation.
  10634. func (m *CreditUsageMutation) SetOp(op Op) {
  10635. m.op = op
  10636. }
  10637. // Type returns the node type of this mutation (CreditUsage).
  10638. func (m *CreditUsageMutation) Type() string {
  10639. return m.typ
  10640. }
  10641. // Fields returns all fields that were changed during this mutation. Note that in
  10642. // order to get all numeric fields that were incremented/decremented, call
  10643. // AddedFields().
  10644. func (m *CreditUsageMutation) Fields() []string {
  10645. fields := make([]string, 0, 12)
  10646. if m.created_at != nil {
  10647. fields = append(fields, creditusage.FieldCreatedAt)
  10648. }
  10649. if m.updated_at != nil {
  10650. fields = append(fields, creditusage.FieldUpdatedAt)
  10651. }
  10652. if m.deleted_at != nil {
  10653. fields = append(fields, creditusage.FieldDeletedAt)
  10654. }
  10655. if m.user_id != nil {
  10656. fields = append(fields, creditusage.FieldUserID)
  10657. }
  10658. if m.number != nil {
  10659. fields = append(fields, creditusage.FieldNumber)
  10660. }
  10661. if m.status != nil {
  10662. fields = append(fields, creditusage.FieldStatus)
  10663. }
  10664. if m.ntype != nil {
  10665. fields = append(fields, creditusage.FieldNtype)
  10666. }
  10667. if m.table != nil {
  10668. fields = append(fields, creditusage.FieldTable)
  10669. }
  10670. if m.organization_id != nil {
  10671. fields = append(fields, creditusage.FieldOrganizationID)
  10672. }
  10673. if m.nid != nil {
  10674. fields = append(fields, creditusage.FieldNid)
  10675. }
  10676. if m.reason != nil {
  10677. fields = append(fields, creditusage.FieldReason)
  10678. }
  10679. if m.operator != nil {
  10680. fields = append(fields, creditusage.FieldOperator)
  10681. }
  10682. return fields
  10683. }
  10684. // Field returns the value of a field with the given name. The second boolean
  10685. // return value indicates that this field was not set, or was not defined in the
  10686. // schema.
  10687. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10688. switch name {
  10689. case creditusage.FieldCreatedAt:
  10690. return m.CreatedAt()
  10691. case creditusage.FieldUpdatedAt:
  10692. return m.UpdatedAt()
  10693. case creditusage.FieldDeletedAt:
  10694. return m.DeletedAt()
  10695. case creditusage.FieldUserID:
  10696. return m.UserID()
  10697. case creditusage.FieldNumber:
  10698. return m.Number()
  10699. case creditusage.FieldStatus:
  10700. return m.Status()
  10701. case creditusage.FieldNtype:
  10702. return m.Ntype()
  10703. case creditusage.FieldTable:
  10704. return m.Table()
  10705. case creditusage.FieldOrganizationID:
  10706. return m.OrganizationID()
  10707. case creditusage.FieldNid:
  10708. return m.Nid()
  10709. case creditusage.FieldReason:
  10710. return m.Reason()
  10711. case creditusage.FieldOperator:
  10712. return m.Operator()
  10713. }
  10714. return nil, false
  10715. }
  10716. // OldField returns the old value of the field from the database. An error is
  10717. // returned if the mutation operation is not UpdateOne, or the query to the
  10718. // database failed.
  10719. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10720. switch name {
  10721. case creditusage.FieldCreatedAt:
  10722. return m.OldCreatedAt(ctx)
  10723. case creditusage.FieldUpdatedAt:
  10724. return m.OldUpdatedAt(ctx)
  10725. case creditusage.FieldDeletedAt:
  10726. return m.OldDeletedAt(ctx)
  10727. case creditusage.FieldUserID:
  10728. return m.OldUserID(ctx)
  10729. case creditusage.FieldNumber:
  10730. return m.OldNumber(ctx)
  10731. case creditusage.FieldStatus:
  10732. return m.OldStatus(ctx)
  10733. case creditusage.FieldNtype:
  10734. return m.OldNtype(ctx)
  10735. case creditusage.FieldTable:
  10736. return m.OldTable(ctx)
  10737. case creditusage.FieldOrganizationID:
  10738. return m.OldOrganizationID(ctx)
  10739. case creditusage.FieldNid:
  10740. return m.OldNid(ctx)
  10741. case creditusage.FieldReason:
  10742. return m.OldReason(ctx)
  10743. case creditusage.FieldOperator:
  10744. return m.OldOperator(ctx)
  10745. }
  10746. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10747. }
  10748. // SetField sets the value of a field with the given name. It returns an error if
  10749. // the field is not defined in the schema, or if the type mismatched the field
  10750. // type.
  10751. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10752. switch name {
  10753. case creditusage.FieldCreatedAt:
  10754. v, ok := value.(time.Time)
  10755. if !ok {
  10756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10757. }
  10758. m.SetCreatedAt(v)
  10759. return nil
  10760. case creditusage.FieldUpdatedAt:
  10761. v, ok := value.(time.Time)
  10762. if !ok {
  10763. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10764. }
  10765. m.SetUpdatedAt(v)
  10766. return nil
  10767. case creditusage.FieldDeletedAt:
  10768. v, ok := value.(time.Time)
  10769. if !ok {
  10770. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10771. }
  10772. m.SetDeletedAt(v)
  10773. return nil
  10774. case creditusage.FieldUserID:
  10775. v, ok := value.(string)
  10776. if !ok {
  10777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10778. }
  10779. m.SetUserID(v)
  10780. return nil
  10781. case creditusage.FieldNumber:
  10782. v, ok := value.(float32)
  10783. if !ok {
  10784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10785. }
  10786. m.SetNumber(v)
  10787. return nil
  10788. case creditusage.FieldStatus:
  10789. v, ok := value.(int)
  10790. if !ok {
  10791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10792. }
  10793. m.SetStatus(v)
  10794. return nil
  10795. case creditusage.FieldNtype:
  10796. v, ok := value.(int)
  10797. if !ok {
  10798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10799. }
  10800. m.SetNtype(v)
  10801. return nil
  10802. case creditusage.FieldTable:
  10803. v, ok := value.(string)
  10804. if !ok {
  10805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10806. }
  10807. m.SetTable(v)
  10808. return nil
  10809. case creditusage.FieldOrganizationID:
  10810. v, ok := value.(uint64)
  10811. if !ok {
  10812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10813. }
  10814. m.SetOrganizationID(v)
  10815. return nil
  10816. case creditusage.FieldNid:
  10817. v, ok := value.(uint64)
  10818. if !ok {
  10819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10820. }
  10821. m.SetNid(v)
  10822. return nil
  10823. case creditusage.FieldReason:
  10824. v, ok := value.(string)
  10825. if !ok {
  10826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10827. }
  10828. m.SetReason(v)
  10829. return nil
  10830. case creditusage.FieldOperator:
  10831. v, ok := value.(string)
  10832. if !ok {
  10833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10834. }
  10835. m.SetOperator(v)
  10836. return nil
  10837. }
  10838. return fmt.Errorf("unknown CreditUsage field %s", name)
  10839. }
  10840. // AddedFields returns all numeric fields that were incremented/decremented during
  10841. // this mutation.
  10842. func (m *CreditUsageMutation) AddedFields() []string {
  10843. var fields []string
  10844. if m.addnumber != nil {
  10845. fields = append(fields, creditusage.FieldNumber)
  10846. }
  10847. if m.addstatus != nil {
  10848. fields = append(fields, creditusage.FieldStatus)
  10849. }
  10850. if m.addntype != nil {
  10851. fields = append(fields, creditusage.FieldNtype)
  10852. }
  10853. if m.addorganization_id != nil {
  10854. fields = append(fields, creditusage.FieldOrganizationID)
  10855. }
  10856. if m.addnid != nil {
  10857. fields = append(fields, creditusage.FieldNid)
  10858. }
  10859. return fields
  10860. }
  10861. // AddedField returns the numeric value that was incremented/decremented on a field
  10862. // with the given name. The second boolean return value indicates that this field
  10863. // was not set, or was not defined in the schema.
  10864. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10865. switch name {
  10866. case creditusage.FieldNumber:
  10867. return m.AddedNumber()
  10868. case creditusage.FieldStatus:
  10869. return m.AddedStatus()
  10870. case creditusage.FieldNtype:
  10871. return m.AddedNtype()
  10872. case creditusage.FieldOrganizationID:
  10873. return m.AddedOrganizationID()
  10874. case creditusage.FieldNid:
  10875. return m.AddedNid()
  10876. }
  10877. return nil, false
  10878. }
  10879. // AddField adds the value to the field with the given name. It returns an error if
  10880. // the field is not defined in the schema, or if the type mismatched the field
  10881. // type.
  10882. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10883. switch name {
  10884. case creditusage.FieldNumber:
  10885. v, ok := value.(float32)
  10886. if !ok {
  10887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10888. }
  10889. m.AddNumber(v)
  10890. return nil
  10891. case creditusage.FieldStatus:
  10892. v, ok := value.(int)
  10893. if !ok {
  10894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10895. }
  10896. m.AddStatus(v)
  10897. return nil
  10898. case creditusage.FieldNtype:
  10899. v, ok := value.(int)
  10900. if !ok {
  10901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10902. }
  10903. m.AddNtype(v)
  10904. return nil
  10905. case creditusage.FieldOrganizationID:
  10906. v, ok := value.(int64)
  10907. if !ok {
  10908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10909. }
  10910. m.AddOrganizationID(v)
  10911. return nil
  10912. case creditusage.FieldNid:
  10913. v, ok := value.(int64)
  10914. if !ok {
  10915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10916. }
  10917. m.AddNid(v)
  10918. return nil
  10919. }
  10920. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  10921. }
  10922. // ClearedFields returns all nullable fields that were cleared during this
  10923. // mutation.
  10924. func (m *CreditUsageMutation) ClearedFields() []string {
  10925. var fields []string
  10926. if m.FieldCleared(creditusage.FieldDeletedAt) {
  10927. fields = append(fields, creditusage.FieldDeletedAt)
  10928. }
  10929. if m.FieldCleared(creditusage.FieldStatus) {
  10930. fields = append(fields, creditusage.FieldStatus)
  10931. }
  10932. return fields
  10933. }
  10934. // FieldCleared returns a boolean indicating if a field with the given name was
  10935. // cleared in this mutation.
  10936. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  10937. _, ok := m.clearedFields[name]
  10938. return ok
  10939. }
  10940. // ClearField clears the value of the field with the given name. It returns an
  10941. // error if the field is not defined in the schema.
  10942. func (m *CreditUsageMutation) ClearField(name string) error {
  10943. switch name {
  10944. case creditusage.FieldDeletedAt:
  10945. m.ClearDeletedAt()
  10946. return nil
  10947. case creditusage.FieldStatus:
  10948. m.ClearStatus()
  10949. return nil
  10950. }
  10951. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  10952. }
  10953. // ResetField resets all changes in the mutation for the field with the given name.
  10954. // It returns an error if the field is not defined in the schema.
  10955. func (m *CreditUsageMutation) ResetField(name string) error {
  10956. switch name {
  10957. case creditusage.FieldCreatedAt:
  10958. m.ResetCreatedAt()
  10959. return nil
  10960. case creditusage.FieldUpdatedAt:
  10961. m.ResetUpdatedAt()
  10962. return nil
  10963. case creditusage.FieldDeletedAt:
  10964. m.ResetDeletedAt()
  10965. return nil
  10966. case creditusage.FieldUserID:
  10967. m.ResetUserID()
  10968. return nil
  10969. case creditusage.FieldNumber:
  10970. m.ResetNumber()
  10971. return nil
  10972. case creditusage.FieldStatus:
  10973. m.ResetStatus()
  10974. return nil
  10975. case creditusage.FieldNtype:
  10976. m.ResetNtype()
  10977. return nil
  10978. case creditusage.FieldTable:
  10979. m.ResetTable()
  10980. return nil
  10981. case creditusage.FieldOrganizationID:
  10982. m.ResetOrganizationID()
  10983. return nil
  10984. case creditusage.FieldNid:
  10985. m.ResetNid()
  10986. return nil
  10987. case creditusage.FieldReason:
  10988. m.ResetReason()
  10989. return nil
  10990. case creditusage.FieldOperator:
  10991. m.ResetOperator()
  10992. return nil
  10993. }
  10994. return fmt.Errorf("unknown CreditUsage field %s", name)
  10995. }
  10996. // AddedEdges returns all edge names that were set/added in this mutation.
  10997. func (m *CreditUsageMutation) AddedEdges() []string {
  10998. edges := make([]string, 0, 0)
  10999. return edges
  11000. }
  11001. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11002. // name in this mutation.
  11003. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11004. return nil
  11005. }
  11006. // RemovedEdges returns all edge names that were removed in this mutation.
  11007. func (m *CreditUsageMutation) RemovedEdges() []string {
  11008. edges := make([]string, 0, 0)
  11009. return edges
  11010. }
  11011. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11012. // the given name in this mutation.
  11013. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11014. return nil
  11015. }
  11016. // ClearedEdges returns all edge names that were cleared in this mutation.
  11017. func (m *CreditUsageMutation) ClearedEdges() []string {
  11018. edges := make([]string, 0, 0)
  11019. return edges
  11020. }
  11021. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11022. // was cleared in this mutation.
  11023. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11024. return false
  11025. }
  11026. // ClearEdge clears the value of the edge with the given name. It returns an error
  11027. // if that edge is not defined in the schema.
  11028. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11029. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11030. }
  11031. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11032. // It returns an error if the edge is not defined in the schema.
  11033. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11034. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11035. }
  11036. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11037. type EmployeeMutation struct {
  11038. config
  11039. op Op
  11040. typ string
  11041. id *uint64
  11042. created_at *time.Time
  11043. updated_at *time.Time
  11044. deleted_at *time.Time
  11045. title *string
  11046. avatar *string
  11047. tags *string
  11048. hire_count *int
  11049. addhire_count *int
  11050. service_count *int
  11051. addservice_count *int
  11052. achievement_count *int
  11053. addachievement_count *int
  11054. intro *string
  11055. estimate *string
  11056. skill *string
  11057. ability_type *string
  11058. scene *string
  11059. switch_in *string
  11060. video_url *string
  11061. organization_id *uint64
  11062. addorganization_id *int64
  11063. category_id *uint64
  11064. addcategory_id *int64
  11065. api_base *string
  11066. api_key *string
  11067. ai_info *string
  11068. is_vip *int
  11069. addis_vip *int
  11070. chat_url *string
  11071. clearedFields map[string]struct{}
  11072. em_work_experiences map[uint64]struct{}
  11073. removedem_work_experiences map[uint64]struct{}
  11074. clearedem_work_experiences bool
  11075. em_tutorial map[uint64]struct{}
  11076. removedem_tutorial map[uint64]struct{}
  11077. clearedem_tutorial bool
  11078. done bool
  11079. oldValue func(context.Context) (*Employee, error)
  11080. predicates []predicate.Employee
  11081. }
  11082. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11083. // employeeOption allows management of the mutation configuration using functional options.
  11084. type employeeOption func(*EmployeeMutation)
  11085. // newEmployeeMutation creates new mutation for the Employee entity.
  11086. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11087. m := &EmployeeMutation{
  11088. config: c,
  11089. op: op,
  11090. typ: TypeEmployee,
  11091. clearedFields: make(map[string]struct{}),
  11092. }
  11093. for _, opt := range opts {
  11094. opt(m)
  11095. }
  11096. return m
  11097. }
  11098. // withEmployeeID sets the ID field of the mutation.
  11099. func withEmployeeID(id uint64) employeeOption {
  11100. return func(m *EmployeeMutation) {
  11101. var (
  11102. err error
  11103. once sync.Once
  11104. value *Employee
  11105. )
  11106. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11107. once.Do(func() {
  11108. if m.done {
  11109. err = errors.New("querying old values post mutation is not allowed")
  11110. } else {
  11111. value, err = m.Client().Employee.Get(ctx, id)
  11112. }
  11113. })
  11114. return value, err
  11115. }
  11116. m.id = &id
  11117. }
  11118. }
  11119. // withEmployee sets the old Employee of the mutation.
  11120. func withEmployee(node *Employee) employeeOption {
  11121. return func(m *EmployeeMutation) {
  11122. m.oldValue = func(context.Context) (*Employee, error) {
  11123. return node, nil
  11124. }
  11125. m.id = &node.ID
  11126. }
  11127. }
  11128. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11129. // executed in a transaction (ent.Tx), a transactional client is returned.
  11130. func (m EmployeeMutation) Client() *Client {
  11131. client := &Client{config: m.config}
  11132. client.init()
  11133. return client
  11134. }
  11135. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11136. // it returns an error otherwise.
  11137. func (m EmployeeMutation) Tx() (*Tx, error) {
  11138. if _, ok := m.driver.(*txDriver); !ok {
  11139. return nil, errors.New("ent: mutation is not running in a transaction")
  11140. }
  11141. tx := &Tx{config: m.config}
  11142. tx.init()
  11143. return tx, nil
  11144. }
  11145. // SetID sets the value of the id field. Note that this
  11146. // operation is only accepted on creation of Employee entities.
  11147. func (m *EmployeeMutation) SetID(id uint64) {
  11148. m.id = &id
  11149. }
  11150. // ID returns the ID value in the mutation. Note that the ID is only available
  11151. // if it was provided to the builder or after it was returned from the database.
  11152. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11153. if m.id == nil {
  11154. return
  11155. }
  11156. return *m.id, true
  11157. }
  11158. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11159. // That means, if the mutation is applied within a transaction with an isolation level such
  11160. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11161. // or updated by the mutation.
  11162. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11163. switch {
  11164. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11165. id, exists := m.ID()
  11166. if exists {
  11167. return []uint64{id}, nil
  11168. }
  11169. fallthrough
  11170. case m.op.Is(OpUpdate | OpDelete):
  11171. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11172. default:
  11173. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11174. }
  11175. }
  11176. // SetCreatedAt sets the "created_at" field.
  11177. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11178. m.created_at = &t
  11179. }
  11180. // CreatedAt returns the value of the "created_at" field in the mutation.
  11181. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11182. v := m.created_at
  11183. if v == nil {
  11184. return
  11185. }
  11186. return *v, true
  11187. }
  11188. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11189. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11190. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11191. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11192. if !m.op.Is(OpUpdateOne) {
  11193. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11194. }
  11195. if m.id == nil || m.oldValue == nil {
  11196. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11197. }
  11198. oldValue, err := m.oldValue(ctx)
  11199. if err != nil {
  11200. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11201. }
  11202. return oldValue.CreatedAt, nil
  11203. }
  11204. // ResetCreatedAt resets all changes to the "created_at" field.
  11205. func (m *EmployeeMutation) ResetCreatedAt() {
  11206. m.created_at = nil
  11207. }
  11208. // SetUpdatedAt sets the "updated_at" field.
  11209. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11210. m.updated_at = &t
  11211. }
  11212. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11213. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11214. v := m.updated_at
  11215. if v == nil {
  11216. return
  11217. }
  11218. return *v, true
  11219. }
  11220. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11221. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11223. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11224. if !m.op.Is(OpUpdateOne) {
  11225. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11226. }
  11227. if m.id == nil || m.oldValue == nil {
  11228. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11229. }
  11230. oldValue, err := m.oldValue(ctx)
  11231. if err != nil {
  11232. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11233. }
  11234. return oldValue.UpdatedAt, nil
  11235. }
  11236. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11237. func (m *EmployeeMutation) ResetUpdatedAt() {
  11238. m.updated_at = nil
  11239. }
  11240. // SetDeletedAt sets the "deleted_at" field.
  11241. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11242. m.deleted_at = &t
  11243. }
  11244. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11245. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11246. v := m.deleted_at
  11247. if v == nil {
  11248. return
  11249. }
  11250. return *v, true
  11251. }
  11252. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11253. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11255. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11256. if !m.op.Is(OpUpdateOne) {
  11257. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11258. }
  11259. if m.id == nil || m.oldValue == nil {
  11260. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11261. }
  11262. oldValue, err := m.oldValue(ctx)
  11263. if err != nil {
  11264. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11265. }
  11266. return oldValue.DeletedAt, nil
  11267. }
  11268. // ClearDeletedAt clears the value of the "deleted_at" field.
  11269. func (m *EmployeeMutation) ClearDeletedAt() {
  11270. m.deleted_at = nil
  11271. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11272. }
  11273. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11274. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11275. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11276. return ok
  11277. }
  11278. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11279. func (m *EmployeeMutation) ResetDeletedAt() {
  11280. m.deleted_at = nil
  11281. delete(m.clearedFields, employee.FieldDeletedAt)
  11282. }
  11283. // SetTitle sets the "title" field.
  11284. func (m *EmployeeMutation) SetTitle(s string) {
  11285. m.title = &s
  11286. }
  11287. // Title returns the value of the "title" field in the mutation.
  11288. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11289. v := m.title
  11290. if v == nil {
  11291. return
  11292. }
  11293. return *v, true
  11294. }
  11295. // OldTitle returns the old "title" field's value of the Employee entity.
  11296. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11297. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11298. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11299. if !m.op.Is(OpUpdateOne) {
  11300. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11301. }
  11302. if m.id == nil || m.oldValue == nil {
  11303. return v, errors.New("OldTitle requires an ID field in the mutation")
  11304. }
  11305. oldValue, err := m.oldValue(ctx)
  11306. if err != nil {
  11307. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11308. }
  11309. return oldValue.Title, nil
  11310. }
  11311. // ResetTitle resets all changes to the "title" field.
  11312. func (m *EmployeeMutation) ResetTitle() {
  11313. m.title = nil
  11314. }
  11315. // SetAvatar sets the "avatar" field.
  11316. func (m *EmployeeMutation) SetAvatar(s string) {
  11317. m.avatar = &s
  11318. }
  11319. // Avatar returns the value of the "avatar" field in the mutation.
  11320. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11321. v := m.avatar
  11322. if v == nil {
  11323. return
  11324. }
  11325. return *v, true
  11326. }
  11327. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11328. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11330. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11331. if !m.op.Is(OpUpdateOne) {
  11332. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11333. }
  11334. if m.id == nil || m.oldValue == nil {
  11335. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11336. }
  11337. oldValue, err := m.oldValue(ctx)
  11338. if err != nil {
  11339. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11340. }
  11341. return oldValue.Avatar, nil
  11342. }
  11343. // ResetAvatar resets all changes to the "avatar" field.
  11344. func (m *EmployeeMutation) ResetAvatar() {
  11345. m.avatar = nil
  11346. }
  11347. // SetTags sets the "tags" field.
  11348. func (m *EmployeeMutation) SetTags(s string) {
  11349. m.tags = &s
  11350. }
  11351. // Tags returns the value of the "tags" field in the mutation.
  11352. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11353. v := m.tags
  11354. if v == nil {
  11355. return
  11356. }
  11357. return *v, true
  11358. }
  11359. // OldTags returns the old "tags" field's value of the Employee entity.
  11360. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11361. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11362. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11363. if !m.op.Is(OpUpdateOne) {
  11364. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11365. }
  11366. if m.id == nil || m.oldValue == nil {
  11367. return v, errors.New("OldTags requires an ID field in the mutation")
  11368. }
  11369. oldValue, err := m.oldValue(ctx)
  11370. if err != nil {
  11371. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11372. }
  11373. return oldValue.Tags, nil
  11374. }
  11375. // ResetTags resets all changes to the "tags" field.
  11376. func (m *EmployeeMutation) ResetTags() {
  11377. m.tags = nil
  11378. }
  11379. // SetHireCount sets the "hire_count" field.
  11380. func (m *EmployeeMutation) SetHireCount(i int) {
  11381. m.hire_count = &i
  11382. m.addhire_count = nil
  11383. }
  11384. // HireCount returns the value of the "hire_count" field in the mutation.
  11385. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11386. v := m.hire_count
  11387. if v == nil {
  11388. return
  11389. }
  11390. return *v, true
  11391. }
  11392. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11393. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11395. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11396. if !m.op.Is(OpUpdateOne) {
  11397. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11398. }
  11399. if m.id == nil || m.oldValue == nil {
  11400. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11401. }
  11402. oldValue, err := m.oldValue(ctx)
  11403. if err != nil {
  11404. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11405. }
  11406. return oldValue.HireCount, nil
  11407. }
  11408. // AddHireCount adds i to the "hire_count" field.
  11409. func (m *EmployeeMutation) AddHireCount(i int) {
  11410. if m.addhire_count != nil {
  11411. *m.addhire_count += i
  11412. } else {
  11413. m.addhire_count = &i
  11414. }
  11415. }
  11416. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11417. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11418. v := m.addhire_count
  11419. if v == nil {
  11420. return
  11421. }
  11422. return *v, true
  11423. }
  11424. // ResetHireCount resets all changes to the "hire_count" field.
  11425. func (m *EmployeeMutation) ResetHireCount() {
  11426. m.hire_count = nil
  11427. m.addhire_count = nil
  11428. }
  11429. // SetServiceCount sets the "service_count" field.
  11430. func (m *EmployeeMutation) SetServiceCount(i int) {
  11431. m.service_count = &i
  11432. m.addservice_count = nil
  11433. }
  11434. // ServiceCount returns the value of the "service_count" field in the mutation.
  11435. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11436. v := m.service_count
  11437. if v == nil {
  11438. return
  11439. }
  11440. return *v, true
  11441. }
  11442. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11443. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11444. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11445. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11446. if !m.op.Is(OpUpdateOne) {
  11447. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11448. }
  11449. if m.id == nil || m.oldValue == nil {
  11450. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11451. }
  11452. oldValue, err := m.oldValue(ctx)
  11453. if err != nil {
  11454. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11455. }
  11456. return oldValue.ServiceCount, nil
  11457. }
  11458. // AddServiceCount adds i to the "service_count" field.
  11459. func (m *EmployeeMutation) AddServiceCount(i int) {
  11460. if m.addservice_count != nil {
  11461. *m.addservice_count += i
  11462. } else {
  11463. m.addservice_count = &i
  11464. }
  11465. }
  11466. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11467. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11468. v := m.addservice_count
  11469. if v == nil {
  11470. return
  11471. }
  11472. return *v, true
  11473. }
  11474. // ResetServiceCount resets all changes to the "service_count" field.
  11475. func (m *EmployeeMutation) ResetServiceCount() {
  11476. m.service_count = nil
  11477. m.addservice_count = nil
  11478. }
  11479. // SetAchievementCount sets the "achievement_count" field.
  11480. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11481. m.achievement_count = &i
  11482. m.addachievement_count = nil
  11483. }
  11484. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11485. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11486. v := m.achievement_count
  11487. if v == nil {
  11488. return
  11489. }
  11490. return *v, true
  11491. }
  11492. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11493. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11495. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11496. if !m.op.Is(OpUpdateOne) {
  11497. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11498. }
  11499. if m.id == nil || m.oldValue == nil {
  11500. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11501. }
  11502. oldValue, err := m.oldValue(ctx)
  11503. if err != nil {
  11504. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11505. }
  11506. return oldValue.AchievementCount, nil
  11507. }
  11508. // AddAchievementCount adds i to the "achievement_count" field.
  11509. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11510. if m.addachievement_count != nil {
  11511. *m.addachievement_count += i
  11512. } else {
  11513. m.addachievement_count = &i
  11514. }
  11515. }
  11516. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11517. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11518. v := m.addachievement_count
  11519. if v == nil {
  11520. return
  11521. }
  11522. return *v, true
  11523. }
  11524. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11525. func (m *EmployeeMutation) ResetAchievementCount() {
  11526. m.achievement_count = nil
  11527. m.addachievement_count = nil
  11528. }
  11529. // SetIntro sets the "intro" field.
  11530. func (m *EmployeeMutation) SetIntro(s string) {
  11531. m.intro = &s
  11532. }
  11533. // Intro returns the value of the "intro" field in the mutation.
  11534. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11535. v := m.intro
  11536. if v == nil {
  11537. return
  11538. }
  11539. return *v, true
  11540. }
  11541. // OldIntro returns the old "intro" field's value of the Employee entity.
  11542. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11544. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11545. if !m.op.Is(OpUpdateOne) {
  11546. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11547. }
  11548. if m.id == nil || m.oldValue == nil {
  11549. return v, errors.New("OldIntro requires an ID field in the mutation")
  11550. }
  11551. oldValue, err := m.oldValue(ctx)
  11552. if err != nil {
  11553. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11554. }
  11555. return oldValue.Intro, nil
  11556. }
  11557. // ResetIntro resets all changes to the "intro" field.
  11558. func (m *EmployeeMutation) ResetIntro() {
  11559. m.intro = nil
  11560. }
  11561. // SetEstimate sets the "estimate" field.
  11562. func (m *EmployeeMutation) SetEstimate(s string) {
  11563. m.estimate = &s
  11564. }
  11565. // Estimate returns the value of the "estimate" field in the mutation.
  11566. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11567. v := m.estimate
  11568. if v == nil {
  11569. return
  11570. }
  11571. return *v, true
  11572. }
  11573. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11574. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11576. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11577. if !m.op.Is(OpUpdateOne) {
  11578. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11579. }
  11580. if m.id == nil || m.oldValue == nil {
  11581. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11582. }
  11583. oldValue, err := m.oldValue(ctx)
  11584. if err != nil {
  11585. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11586. }
  11587. return oldValue.Estimate, nil
  11588. }
  11589. // ResetEstimate resets all changes to the "estimate" field.
  11590. func (m *EmployeeMutation) ResetEstimate() {
  11591. m.estimate = nil
  11592. }
  11593. // SetSkill sets the "skill" field.
  11594. func (m *EmployeeMutation) SetSkill(s string) {
  11595. m.skill = &s
  11596. }
  11597. // Skill returns the value of the "skill" field in the mutation.
  11598. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11599. v := m.skill
  11600. if v == nil {
  11601. return
  11602. }
  11603. return *v, true
  11604. }
  11605. // OldSkill returns the old "skill" field's value of the Employee entity.
  11606. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11608. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11609. if !m.op.Is(OpUpdateOne) {
  11610. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11611. }
  11612. if m.id == nil || m.oldValue == nil {
  11613. return v, errors.New("OldSkill requires an ID field in the mutation")
  11614. }
  11615. oldValue, err := m.oldValue(ctx)
  11616. if err != nil {
  11617. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11618. }
  11619. return oldValue.Skill, nil
  11620. }
  11621. // ResetSkill resets all changes to the "skill" field.
  11622. func (m *EmployeeMutation) ResetSkill() {
  11623. m.skill = nil
  11624. }
  11625. // SetAbilityType sets the "ability_type" field.
  11626. func (m *EmployeeMutation) SetAbilityType(s string) {
  11627. m.ability_type = &s
  11628. }
  11629. // AbilityType returns the value of the "ability_type" field in the mutation.
  11630. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11631. v := m.ability_type
  11632. if v == nil {
  11633. return
  11634. }
  11635. return *v, true
  11636. }
  11637. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11638. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11640. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11641. if !m.op.Is(OpUpdateOne) {
  11642. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11643. }
  11644. if m.id == nil || m.oldValue == nil {
  11645. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11646. }
  11647. oldValue, err := m.oldValue(ctx)
  11648. if err != nil {
  11649. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11650. }
  11651. return oldValue.AbilityType, nil
  11652. }
  11653. // ResetAbilityType resets all changes to the "ability_type" field.
  11654. func (m *EmployeeMutation) ResetAbilityType() {
  11655. m.ability_type = nil
  11656. }
  11657. // SetScene sets the "scene" field.
  11658. func (m *EmployeeMutation) SetScene(s string) {
  11659. m.scene = &s
  11660. }
  11661. // Scene returns the value of the "scene" field in the mutation.
  11662. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11663. v := m.scene
  11664. if v == nil {
  11665. return
  11666. }
  11667. return *v, true
  11668. }
  11669. // OldScene returns the old "scene" field's value of the Employee entity.
  11670. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11672. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11673. if !m.op.Is(OpUpdateOne) {
  11674. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11675. }
  11676. if m.id == nil || m.oldValue == nil {
  11677. return v, errors.New("OldScene requires an ID field in the mutation")
  11678. }
  11679. oldValue, err := m.oldValue(ctx)
  11680. if err != nil {
  11681. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11682. }
  11683. return oldValue.Scene, nil
  11684. }
  11685. // ResetScene resets all changes to the "scene" field.
  11686. func (m *EmployeeMutation) ResetScene() {
  11687. m.scene = nil
  11688. }
  11689. // SetSwitchIn sets the "switch_in" field.
  11690. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11691. m.switch_in = &s
  11692. }
  11693. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11694. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11695. v := m.switch_in
  11696. if v == nil {
  11697. return
  11698. }
  11699. return *v, true
  11700. }
  11701. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11702. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11703. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11704. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11705. if !m.op.Is(OpUpdateOne) {
  11706. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11707. }
  11708. if m.id == nil || m.oldValue == nil {
  11709. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11710. }
  11711. oldValue, err := m.oldValue(ctx)
  11712. if err != nil {
  11713. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11714. }
  11715. return oldValue.SwitchIn, nil
  11716. }
  11717. // ResetSwitchIn resets all changes to the "switch_in" field.
  11718. func (m *EmployeeMutation) ResetSwitchIn() {
  11719. m.switch_in = nil
  11720. }
  11721. // SetVideoURL sets the "video_url" field.
  11722. func (m *EmployeeMutation) SetVideoURL(s string) {
  11723. m.video_url = &s
  11724. }
  11725. // VideoURL returns the value of the "video_url" field in the mutation.
  11726. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11727. v := m.video_url
  11728. if v == nil {
  11729. return
  11730. }
  11731. return *v, true
  11732. }
  11733. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11734. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11735. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11736. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11737. if !m.op.Is(OpUpdateOne) {
  11738. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11739. }
  11740. if m.id == nil || m.oldValue == nil {
  11741. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11742. }
  11743. oldValue, err := m.oldValue(ctx)
  11744. if err != nil {
  11745. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11746. }
  11747. return oldValue.VideoURL, nil
  11748. }
  11749. // ResetVideoURL resets all changes to the "video_url" field.
  11750. func (m *EmployeeMutation) ResetVideoURL() {
  11751. m.video_url = nil
  11752. }
  11753. // SetOrganizationID sets the "organization_id" field.
  11754. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11755. m.organization_id = &u
  11756. m.addorganization_id = nil
  11757. }
  11758. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11759. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11760. v := m.organization_id
  11761. if v == nil {
  11762. return
  11763. }
  11764. return *v, true
  11765. }
  11766. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11767. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11769. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11770. if !m.op.Is(OpUpdateOne) {
  11771. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11772. }
  11773. if m.id == nil || m.oldValue == nil {
  11774. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11775. }
  11776. oldValue, err := m.oldValue(ctx)
  11777. if err != nil {
  11778. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11779. }
  11780. return oldValue.OrganizationID, nil
  11781. }
  11782. // AddOrganizationID adds u to the "organization_id" field.
  11783. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11784. if m.addorganization_id != nil {
  11785. *m.addorganization_id += u
  11786. } else {
  11787. m.addorganization_id = &u
  11788. }
  11789. }
  11790. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11791. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11792. v := m.addorganization_id
  11793. if v == nil {
  11794. return
  11795. }
  11796. return *v, true
  11797. }
  11798. // ResetOrganizationID resets all changes to the "organization_id" field.
  11799. func (m *EmployeeMutation) ResetOrganizationID() {
  11800. m.organization_id = nil
  11801. m.addorganization_id = nil
  11802. }
  11803. // SetCategoryID sets the "category_id" field.
  11804. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11805. m.category_id = &u
  11806. m.addcategory_id = nil
  11807. }
  11808. // CategoryID returns the value of the "category_id" field in the mutation.
  11809. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11810. v := m.category_id
  11811. if v == nil {
  11812. return
  11813. }
  11814. return *v, true
  11815. }
  11816. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11817. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11819. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11820. if !m.op.Is(OpUpdateOne) {
  11821. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11822. }
  11823. if m.id == nil || m.oldValue == nil {
  11824. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11825. }
  11826. oldValue, err := m.oldValue(ctx)
  11827. if err != nil {
  11828. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11829. }
  11830. return oldValue.CategoryID, nil
  11831. }
  11832. // AddCategoryID adds u to the "category_id" field.
  11833. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11834. if m.addcategory_id != nil {
  11835. *m.addcategory_id += u
  11836. } else {
  11837. m.addcategory_id = &u
  11838. }
  11839. }
  11840. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11841. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11842. v := m.addcategory_id
  11843. if v == nil {
  11844. return
  11845. }
  11846. return *v, true
  11847. }
  11848. // ResetCategoryID resets all changes to the "category_id" field.
  11849. func (m *EmployeeMutation) ResetCategoryID() {
  11850. m.category_id = nil
  11851. m.addcategory_id = nil
  11852. }
  11853. // SetAPIBase sets the "api_base" field.
  11854. func (m *EmployeeMutation) SetAPIBase(s string) {
  11855. m.api_base = &s
  11856. }
  11857. // APIBase returns the value of the "api_base" field in the mutation.
  11858. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11859. v := m.api_base
  11860. if v == nil {
  11861. return
  11862. }
  11863. return *v, true
  11864. }
  11865. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11866. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11868. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11869. if !m.op.Is(OpUpdateOne) {
  11870. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11871. }
  11872. if m.id == nil || m.oldValue == nil {
  11873. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11874. }
  11875. oldValue, err := m.oldValue(ctx)
  11876. if err != nil {
  11877. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11878. }
  11879. return oldValue.APIBase, nil
  11880. }
  11881. // ResetAPIBase resets all changes to the "api_base" field.
  11882. func (m *EmployeeMutation) ResetAPIBase() {
  11883. m.api_base = nil
  11884. }
  11885. // SetAPIKey sets the "api_key" field.
  11886. func (m *EmployeeMutation) SetAPIKey(s string) {
  11887. m.api_key = &s
  11888. }
  11889. // APIKey returns the value of the "api_key" field in the mutation.
  11890. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  11891. v := m.api_key
  11892. if v == nil {
  11893. return
  11894. }
  11895. return *v, true
  11896. }
  11897. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  11898. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11899. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11900. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  11901. if !m.op.Is(OpUpdateOne) {
  11902. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  11903. }
  11904. if m.id == nil || m.oldValue == nil {
  11905. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  11906. }
  11907. oldValue, err := m.oldValue(ctx)
  11908. if err != nil {
  11909. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  11910. }
  11911. return oldValue.APIKey, nil
  11912. }
  11913. // ResetAPIKey resets all changes to the "api_key" field.
  11914. func (m *EmployeeMutation) ResetAPIKey() {
  11915. m.api_key = nil
  11916. }
  11917. // SetAiInfo sets the "ai_info" field.
  11918. func (m *EmployeeMutation) SetAiInfo(s string) {
  11919. m.ai_info = &s
  11920. }
  11921. // AiInfo returns the value of the "ai_info" field in the mutation.
  11922. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  11923. v := m.ai_info
  11924. if v == nil {
  11925. return
  11926. }
  11927. return *v, true
  11928. }
  11929. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  11930. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11932. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  11933. if !m.op.Is(OpUpdateOne) {
  11934. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  11935. }
  11936. if m.id == nil || m.oldValue == nil {
  11937. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  11938. }
  11939. oldValue, err := m.oldValue(ctx)
  11940. if err != nil {
  11941. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  11942. }
  11943. return oldValue.AiInfo, nil
  11944. }
  11945. // ClearAiInfo clears the value of the "ai_info" field.
  11946. func (m *EmployeeMutation) ClearAiInfo() {
  11947. m.ai_info = nil
  11948. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  11949. }
  11950. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  11951. func (m *EmployeeMutation) AiInfoCleared() bool {
  11952. _, ok := m.clearedFields[employee.FieldAiInfo]
  11953. return ok
  11954. }
  11955. // ResetAiInfo resets all changes to the "ai_info" field.
  11956. func (m *EmployeeMutation) ResetAiInfo() {
  11957. m.ai_info = nil
  11958. delete(m.clearedFields, employee.FieldAiInfo)
  11959. }
  11960. // SetIsVip sets the "is_vip" field.
  11961. func (m *EmployeeMutation) SetIsVip(i int) {
  11962. m.is_vip = &i
  11963. m.addis_vip = nil
  11964. }
  11965. // IsVip returns the value of the "is_vip" field in the mutation.
  11966. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  11967. v := m.is_vip
  11968. if v == nil {
  11969. return
  11970. }
  11971. return *v, true
  11972. }
  11973. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  11974. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11975. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11976. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  11977. if !m.op.Is(OpUpdateOne) {
  11978. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  11979. }
  11980. if m.id == nil || m.oldValue == nil {
  11981. return v, errors.New("OldIsVip requires an ID field in the mutation")
  11982. }
  11983. oldValue, err := m.oldValue(ctx)
  11984. if err != nil {
  11985. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  11986. }
  11987. return oldValue.IsVip, nil
  11988. }
  11989. // AddIsVip adds i to the "is_vip" field.
  11990. func (m *EmployeeMutation) AddIsVip(i int) {
  11991. if m.addis_vip != nil {
  11992. *m.addis_vip += i
  11993. } else {
  11994. m.addis_vip = &i
  11995. }
  11996. }
  11997. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  11998. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  11999. v := m.addis_vip
  12000. if v == nil {
  12001. return
  12002. }
  12003. return *v, true
  12004. }
  12005. // ResetIsVip resets all changes to the "is_vip" field.
  12006. func (m *EmployeeMutation) ResetIsVip() {
  12007. m.is_vip = nil
  12008. m.addis_vip = nil
  12009. }
  12010. // SetChatURL sets the "chat_url" field.
  12011. func (m *EmployeeMutation) SetChatURL(s string) {
  12012. m.chat_url = &s
  12013. }
  12014. // ChatURL returns the value of the "chat_url" field in the mutation.
  12015. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12016. v := m.chat_url
  12017. if v == nil {
  12018. return
  12019. }
  12020. return *v, true
  12021. }
  12022. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12023. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12024. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12025. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12026. if !m.op.Is(OpUpdateOne) {
  12027. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12028. }
  12029. if m.id == nil || m.oldValue == nil {
  12030. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12031. }
  12032. oldValue, err := m.oldValue(ctx)
  12033. if err != nil {
  12034. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12035. }
  12036. return oldValue.ChatURL, nil
  12037. }
  12038. // ResetChatURL resets all changes to the "chat_url" field.
  12039. func (m *EmployeeMutation) ResetChatURL() {
  12040. m.chat_url = nil
  12041. }
  12042. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12043. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12044. if m.em_work_experiences == nil {
  12045. m.em_work_experiences = make(map[uint64]struct{})
  12046. }
  12047. for i := range ids {
  12048. m.em_work_experiences[ids[i]] = struct{}{}
  12049. }
  12050. }
  12051. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12052. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12053. m.clearedem_work_experiences = true
  12054. }
  12055. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12056. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12057. return m.clearedem_work_experiences
  12058. }
  12059. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12060. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12061. if m.removedem_work_experiences == nil {
  12062. m.removedem_work_experiences = make(map[uint64]struct{})
  12063. }
  12064. for i := range ids {
  12065. delete(m.em_work_experiences, ids[i])
  12066. m.removedem_work_experiences[ids[i]] = struct{}{}
  12067. }
  12068. }
  12069. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12070. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12071. for id := range m.removedem_work_experiences {
  12072. ids = append(ids, id)
  12073. }
  12074. return
  12075. }
  12076. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12077. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12078. for id := range m.em_work_experiences {
  12079. ids = append(ids, id)
  12080. }
  12081. return
  12082. }
  12083. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12084. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12085. m.em_work_experiences = nil
  12086. m.clearedem_work_experiences = false
  12087. m.removedem_work_experiences = nil
  12088. }
  12089. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12090. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12091. if m.em_tutorial == nil {
  12092. m.em_tutorial = make(map[uint64]struct{})
  12093. }
  12094. for i := range ids {
  12095. m.em_tutorial[ids[i]] = struct{}{}
  12096. }
  12097. }
  12098. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12099. func (m *EmployeeMutation) ClearEmTutorial() {
  12100. m.clearedem_tutorial = true
  12101. }
  12102. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12103. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12104. return m.clearedem_tutorial
  12105. }
  12106. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12107. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12108. if m.removedem_tutorial == nil {
  12109. m.removedem_tutorial = make(map[uint64]struct{})
  12110. }
  12111. for i := range ids {
  12112. delete(m.em_tutorial, ids[i])
  12113. m.removedem_tutorial[ids[i]] = struct{}{}
  12114. }
  12115. }
  12116. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12117. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12118. for id := range m.removedem_tutorial {
  12119. ids = append(ids, id)
  12120. }
  12121. return
  12122. }
  12123. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12124. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12125. for id := range m.em_tutorial {
  12126. ids = append(ids, id)
  12127. }
  12128. return
  12129. }
  12130. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12131. func (m *EmployeeMutation) ResetEmTutorial() {
  12132. m.em_tutorial = nil
  12133. m.clearedem_tutorial = false
  12134. m.removedem_tutorial = nil
  12135. }
  12136. // Where appends a list predicates to the EmployeeMutation builder.
  12137. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12138. m.predicates = append(m.predicates, ps...)
  12139. }
  12140. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12141. // users can use type-assertion to append predicates that do not depend on any generated package.
  12142. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12143. p := make([]predicate.Employee, len(ps))
  12144. for i := range ps {
  12145. p[i] = ps[i]
  12146. }
  12147. m.Where(p...)
  12148. }
  12149. // Op returns the operation name.
  12150. func (m *EmployeeMutation) Op() Op {
  12151. return m.op
  12152. }
  12153. // SetOp allows setting the mutation operation.
  12154. func (m *EmployeeMutation) SetOp(op Op) {
  12155. m.op = op
  12156. }
  12157. // Type returns the node type of this mutation (Employee).
  12158. func (m *EmployeeMutation) Type() string {
  12159. return m.typ
  12160. }
  12161. // Fields returns all fields that were changed during this mutation. Note that in
  12162. // order to get all numeric fields that were incremented/decremented, call
  12163. // AddedFields().
  12164. func (m *EmployeeMutation) Fields() []string {
  12165. fields := make([]string, 0, 23)
  12166. if m.created_at != nil {
  12167. fields = append(fields, employee.FieldCreatedAt)
  12168. }
  12169. if m.updated_at != nil {
  12170. fields = append(fields, employee.FieldUpdatedAt)
  12171. }
  12172. if m.deleted_at != nil {
  12173. fields = append(fields, employee.FieldDeletedAt)
  12174. }
  12175. if m.title != nil {
  12176. fields = append(fields, employee.FieldTitle)
  12177. }
  12178. if m.avatar != nil {
  12179. fields = append(fields, employee.FieldAvatar)
  12180. }
  12181. if m.tags != nil {
  12182. fields = append(fields, employee.FieldTags)
  12183. }
  12184. if m.hire_count != nil {
  12185. fields = append(fields, employee.FieldHireCount)
  12186. }
  12187. if m.service_count != nil {
  12188. fields = append(fields, employee.FieldServiceCount)
  12189. }
  12190. if m.achievement_count != nil {
  12191. fields = append(fields, employee.FieldAchievementCount)
  12192. }
  12193. if m.intro != nil {
  12194. fields = append(fields, employee.FieldIntro)
  12195. }
  12196. if m.estimate != nil {
  12197. fields = append(fields, employee.FieldEstimate)
  12198. }
  12199. if m.skill != nil {
  12200. fields = append(fields, employee.FieldSkill)
  12201. }
  12202. if m.ability_type != nil {
  12203. fields = append(fields, employee.FieldAbilityType)
  12204. }
  12205. if m.scene != nil {
  12206. fields = append(fields, employee.FieldScene)
  12207. }
  12208. if m.switch_in != nil {
  12209. fields = append(fields, employee.FieldSwitchIn)
  12210. }
  12211. if m.video_url != nil {
  12212. fields = append(fields, employee.FieldVideoURL)
  12213. }
  12214. if m.organization_id != nil {
  12215. fields = append(fields, employee.FieldOrganizationID)
  12216. }
  12217. if m.category_id != nil {
  12218. fields = append(fields, employee.FieldCategoryID)
  12219. }
  12220. if m.api_base != nil {
  12221. fields = append(fields, employee.FieldAPIBase)
  12222. }
  12223. if m.api_key != nil {
  12224. fields = append(fields, employee.FieldAPIKey)
  12225. }
  12226. if m.ai_info != nil {
  12227. fields = append(fields, employee.FieldAiInfo)
  12228. }
  12229. if m.is_vip != nil {
  12230. fields = append(fields, employee.FieldIsVip)
  12231. }
  12232. if m.chat_url != nil {
  12233. fields = append(fields, employee.FieldChatURL)
  12234. }
  12235. return fields
  12236. }
  12237. // Field returns the value of a field with the given name. The second boolean
  12238. // return value indicates that this field was not set, or was not defined in the
  12239. // schema.
  12240. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12241. switch name {
  12242. case employee.FieldCreatedAt:
  12243. return m.CreatedAt()
  12244. case employee.FieldUpdatedAt:
  12245. return m.UpdatedAt()
  12246. case employee.FieldDeletedAt:
  12247. return m.DeletedAt()
  12248. case employee.FieldTitle:
  12249. return m.Title()
  12250. case employee.FieldAvatar:
  12251. return m.Avatar()
  12252. case employee.FieldTags:
  12253. return m.Tags()
  12254. case employee.FieldHireCount:
  12255. return m.HireCount()
  12256. case employee.FieldServiceCount:
  12257. return m.ServiceCount()
  12258. case employee.FieldAchievementCount:
  12259. return m.AchievementCount()
  12260. case employee.FieldIntro:
  12261. return m.Intro()
  12262. case employee.FieldEstimate:
  12263. return m.Estimate()
  12264. case employee.FieldSkill:
  12265. return m.Skill()
  12266. case employee.FieldAbilityType:
  12267. return m.AbilityType()
  12268. case employee.FieldScene:
  12269. return m.Scene()
  12270. case employee.FieldSwitchIn:
  12271. return m.SwitchIn()
  12272. case employee.FieldVideoURL:
  12273. return m.VideoURL()
  12274. case employee.FieldOrganizationID:
  12275. return m.OrganizationID()
  12276. case employee.FieldCategoryID:
  12277. return m.CategoryID()
  12278. case employee.FieldAPIBase:
  12279. return m.APIBase()
  12280. case employee.FieldAPIKey:
  12281. return m.APIKey()
  12282. case employee.FieldAiInfo:
  12283. return m.AiInfo()
  12284. case employee.FieldIsVip:
  12285. return m.IsVip()
  12286. case employee.FieldChatURL:
  12287. return m.ChatURL()
  12288. }
  12289. return nil, false
  12290. }
  12291. // OldField returns the old value of the field from the database. An error is
  12292. // returned if the mutation operation is not UpdateOne, or the query to the
  12293. // database failed.
  12294. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12295. switch name {
  12296. case employee.FieldCreatedAt:
  12297. return m.OldCreatedAt(ctx)
  12298. case employee.FieldUpdatedAt:
  12299. return m.OldUpdatedAt(ctx)
  12300. case employee.FieldDeletedAt:
  12301. return m.OldDeletedAt(ctx)
  12302. case employee.FieldTitle:
  12303. return m.OldTitle(ctx)
  12304. case employee.FieldAvatar:
  12305. return m.OldAvatar(ctx)
  12306. case employee.FieldTags:
  12307. return m.OldTags(ctx)
  12308. case employee.FieldHireCount:
  12309. return m.OldHireCount(ctx)
  12310. case employee.FieldServiceCount:
  12311. return m.OldServiceCount(ctx)
  12312. case employee.FieldAchievementCount:
  12313. return m.OldAchievementCount(ctx)
  12314. case employee.FieldIntro:
  12315. return m.OldIntro(ctx)
  12316. case employee.FieldEstimate:
  12317. return m.OldEstimate(ctx)
  12318. case employee.FieldSkill:
  12319. return m.OldSkill(ctx)
  12320. case employee.FieldAbilityType:
  12321. return m.OldAbilityType(ctx)
  12322. case employee.FieldScene:
  12323. return m.OldScene(ctx)
  12324. case employee.FieldSwitchIn:
  12325. return m.OldSwitchIn(ctx)
  12326. case employee.FieldVideoURL:
  12327. return m.OldVideoURL(ctx)
  12328. case employee.FieldOrganizationID:
  12329. return m.OldOrganizationID(ctx)
  12330. case employee.FieldCategoryID:
  12331. return m.OldCategoryID(ctx)
  12332. case employee.FieldAPIBase:
  12333. return m.OldAPIBase(ctx)
  12334. case employee.FieldAPIKey:
  12335. return m.OldAPIKey(ctx)
  12336. case employee.FieldAiInfo:
  12337. return m.OldAiInfo(ctx)
  12338. case employee.FieldIsVip:
  12339. return m.OldIsVip(ctx)
  12340. case employee.FieldChatURL:
  12341. return m.OldChatURL(ctx)
  12342. }
  12343. return nil, fmt.Errorf("unknown Employee field %s", name)
  12344. }
  12345. // SetField sets the value of a field with the given name. It returns an error if
  12346. // the field is not defined in the schema, or if the type mismatched the field
  12347. // type.
  12348. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12349. switch name {
  12350. case employee.FieldCreatedAt:
  12351. v, ok := value.(time.Time)
  12352. if !ok {
  12353. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12354. }
  12355. m.SetCreatedAt(v)
  12356. return nil
  12357. case employee.FieldUpdatedAt:
  12358. v, ok := value.(time.Time)
  12359. if !ok {
  12360. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12361. }
  12362. m.SetUpdatedAt(v)
  12363. return nil
  12364. case employee.FieldDeletedAt:
  12365. v, ok := value.(time.Time)
  12366. if !ok {
  12367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12368. }
  12369. m.SetDeletedAt(v)
  12370. return nil
  12371. case employee.FieldTitle:
  12372. v, ok := value.(string)
  12373. if !ok {
  12374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12375. }
  12376. m.SetTitle(v)
  12377. return nil
  12378. case employee.FieldAvatar:
  12379. v, ok := value.(string)
  12380. if !ok {
  12381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12382. }
  12383. m.SetAvatar(v)
  12384. return nil
  12385. case employee.FieldTags:
  12386. v, ok := value.(string)
  12387. if !ok {
  12388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12389. }
  12390. m.SetTags(v)
  12391. return nil
  12392. case employee.FieldHireCount:
  12393. v, ok := value.(int)
  12394. if !ok {
  12395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12396. }
  12397. m.SetHireCount(v)
  12398. return nil
  12399. case employee.FieldServiceCount:
  12400. v, ok := value.(int)
  12401. if !ok {
  12402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12403. }
  12404. m.SetServiceCount(v)
  12405. return nil
  12406. case employee.FieldAchievementCount:
  12407. v, ok := value.(int)
  12408. if !ok {
  12409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12410. }
  12411. m.SetAchievementCount(v)
  12412. return nil
  12413. case employee.FieldIntro:
  12414. v, ok := value.(string)
  12415. if !ok {
  12416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12417. }
  12418. m.SetIntro(v)
  12419. return nil
  12420. case employee.FieldEstimate:
  12421. v, ok := value.(string)
  12422. if !ok {
  12423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12424. }
  12425. m.SetEstimate(v)
  12426. return nil
  12427. case employee.FieldSkill:
  12428. v, ok := value.(string)
  12429. if !ok {
  12430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12431. }
  12432. m.SetSkill(v)
  12433. return nil
  12434. case employee.FieldAbilityType:
  12435. v, ok := value.(string)
  12436. if !ok {
  12437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12438. }
  12439. m.SetAbilityType(v)
  12440. return nil
  12441. case employee.FieldScene:
  12442. v, ok := value.(string)
  12443. if !ok {
  12444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12445. }
  12446. m.SetScene(v)
  12447. return nil
  12448. case employee.FieldSwitchIn:
  12449. v, ok := value.(string)
  12450. if !ok {
  12451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12452. }
  12453. m.SetSwitchIn(v)
  12454. return nil
  12455. case employee.FieldVideoURL:
  12456. v, ok := value.(string)
  12457. if !ok {
  12458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12459. }
  12460. m.SetVideoURL(v)
  12461. return nil
  12462. case employee.FieldOrganizationID:
  12463. v, ok := value.(uint64)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetOrganizationID(v)
  12468. return nil
  12469. case employee.FieldCategoryID:
  12470. v, ok := value.(uint64)
  12471. if !ok {
  12472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12473. }
  12474. m.SetCategoryID(v)
  12475. return nil
  12476. case employee.FieldAPIBase:
  12477. v, ok := value.(string)
  12478. if !ok {
  12479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12480. }
  12481. m.SetAPIBase(v)
  12482. return nil
  12483. case employee.FieldAPIKey:
  12484. v, ok := value.(string)
  12485. if !ok {
  12486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12487. }
  12488. m.SetAPIKey(v)
  12489. return nil
  12490. case employee.FieldAiInfo:
  12491. v, ok := value.(string)
  12492. if !ok {
  12493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12494. }
  12495. m.SetAiInfo(v)
  12496. return nil
  12497. case employee.FieldIsVip:
  12498. v, ok := value.(int)
  12499. if !ok {
  12500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12501. }
  12502. m.SetIsVip(v)
  12503. return nil
  12504. case employee.FieldChatURL:
  12505. v, ok := value.(string)
  12506. if !ok {
  12507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12508. }
  12509. m.SetChatURL(v)
  12510. return nil
  12511. }
  12512. return fmt.Errorf("unknown Employee field %s", name)
  12513. }
  12514. // AddedFields returns all numeric fields that were incremented/decremented during
  12515. // this mutation.
  12516. func (m *EmployeeMutation) AddedFields() []string {
  12517. var fields []string
  12518. if m.addhire_count != nil {
  12519. fields = append(fields, employee.FieldHireCount)
  12520. }
  12521. if m.addservice_count != nil {
  12522. fields = append(fields, employee.FieldServiceCount)
  12523. }
  12524. if m.addachievement_count != nil {
  12525. fields = append(fields, employee.FieldAchievementCount)
  12526. }
  12527. if m.addorganization_id != nil {
  12528. fields = append(fields, employee.FieldOrganizationID)
  12529. }
  12530. if m.addcategory_id != nil {
  12531. fields = append(fields, employee.FieldCategoryID)
  12532. }
  12533. if m.addis_vip != nil {
  12534. fields = append(fields, employee.FieldIsVip)
  12535. }
  12536. return fields
  12537. }
  12538. // AddedField returns the numeric value that was incremented/decremented on a field
  12539. // with the given name. The second boolean return value indicates that this field
  12540. // was not set, or was not defined in the schema.
  12541. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12542. switch name {
  12543. case employee.FieldHireCount:
  12544. return m.AddedHireCount()
  12545. case employee.FieldServiceCount:
  12546. return m.AddedServiceCount()
  12547. case employee.FieldAchievementCount:
  12548. return m.AddedAchievementCount()
  12549. case employee.FieldOrganizationID:
  12550. return m.AddedOrganizationID()
  12551. case employee.FieldCategoryID:
  12552. return m.AddedCategoryID()
  12553. case employee.FieldIsVip:
  12554. return m.AddedIsVip()
  12555. }
  12556. return nil, false
  12557. }
  12558. // AddField adds the value to the field with the given name. It returns an error if
  12559. // the field is not defined in the schema, or if the type mismatched the field
  12560. // type.
  12561. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12562. switch name {
  12563. case employee.FieldHireCount:
  12564. v, ok := value.(int)
  12565. if !ok {
  12566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12567. }
  12568. m.AddHireCount(v)
  12569. return nil
  12570. case employee.FieldServiceCount:
  12571. v, ok := value.(int)
  12572. if !ok {
  12573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12574. }
  12575. m.AddServiceCount(v)
  12576. return nil
  12577. case employee.FieldAchievementCount:
  12578. v, ok := value.(int)
  12579. if !ok {
  12580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12581. }
  12582. m.AddAchievementCount(v)
  12583. return nil
  12584. case employee.FieldOrganizationID:
  12585. v, ok := value.(int64)
  12586. if !ok {
  12587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12588. }
  12589. m.AddOrganizationID(v)
  12590. return nil
  12591. case employee.FieldCategoryID:
  12592. v, ok := value.(int64)
  12593. if !ok {
  12594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12595. }
  12596. m.AddCategoryID(v)
  12597. return nil
  12598. case employee.FieldIsVip:
  12599. v, ok := value.(int)
  12600. if !ok {
  12601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12602. }
  12603. m.AddIsVip(v)
  12604. return nil
  12605. }
  12606. return fmt.Errorf("unknown Employee numeric field %s", name)
  12607. }
  12608. // ClearedFields returns all nullable fields that were cleared during this
  12609. // mutation.
  12610. func (m *EmployeeMutation) ClearedFields() []string {
  12611. var fields []string
  12612. if m.FieldCleared(employee.FieldDeletedAt) {
  12613. fields = append(fields, employee.FieldDeletedAt)
  12614. }
  12615. if m.FieldCleared(employee.FieldAiInfo) {
  12616. fields = append(fields, employee.FieldAiInfo)
  12617. }
  12618. return fields
  12619. }
  12620. // FieldCleared returns a boolean indicating if a field with the given name was
  12621. // cleared in this mutation.
  12622. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12623. _, ok := m.clearedFields[name]
  12624. return ok
  12625. }
  12626. // ClearField clears the value of the field with the given name. It returns an
  12627. // error if the field is not defined in the schema.
  12628. func (m *EmployeeMutation) ClearField(name string) error {
  12629. switch name {
  12630. case employee.FieldDeletedAt:
  12631. m.ClearDeletedAt()
  12632. return nil
  12633. case employee.FieldAiInfo:
  12634. m.ClearAiInfo()
  12635. return nil
  12636. }
  12637. return fmt.Errorf("unknown Employee nullable field %s", name)
  12638. }
  12639. // ResetField resets all changes in the mutation for the field with the given name.
  12640. // It returns an error if the field is not defined in the schema.
  12641. func (m *EmployeeMutation) ResetField(name string) error {
  12642. switch name {
  12643. case employee.FieldCreatedAt:
  12644. m.ResetCreatedAt()
  12645. return nil
  12646. case employee.FieldUpdatedAt:
  12647. m.ResetUpdatedAt()
  12648. return nil
  12649. case employee.FieldDeletedAt:
  12650. m.ResetDeletedAt()
  12651. return nil
  12652. case employee.FieldTitle:
  12653. m.ResetTitle()
  12654. return nil
  12655. case employee.FieldAvatar:
  12656. m.ResetAvatar()
  12657. return nil
  12658. case employee.FieldTags:
  12659. m.ResetTags()
  12660. return nil
  12661. case employee.FieldHireCount:
  12662. m.ResetHireCount()
  12663. return nil
  12664. case employee.FieldServiceCount:
  12665. m.ResetServiceCount()
  12666. return nil
  12667. case employee.FieldAchievementCount:
  12668. m.ResetAchievementCount()
  12669. return nil
  12670. case employee.FieldIntro:
  12671. m.ResetIntro()
  12672. return nil
  12673. case employee.FieldEstimate:
  12674. m.ResetEstimate()
  12675. return nil
  12676. case employee.FieldSkill:
  12677. m.ResetSkill()
  12678. return nil
  12679. case employee.FieldAbilityType:
  12680. m.ResetAbilityType()
  12681. return nil
  12682. case employee.FieldScene:
  12683. m.ResetScene()
  12684. return nil
  12685. case employee.FieldSwitchIn:
  12686. m.ResetSwitchIn()
  12687. return nil
  12688. case employee.FieldVideoURL:
  12689. m.ResetVideoURL()
  12690. return nil
  12691. case employee.FieldOrganizationID:
  12692. m.ResetOrganizationID()
  12693. return nil
  12694. case employee.FieldCategoryID:
  12695. m.ResetCategoryID()
  12696. return nil
  12697. case employee.FieldAPIBase:
  12698. m.ResetAPIBase()
  12699. return nil
  12700. case employee.FieldAPIKey:
  12701. m.ResetAPIKey()
  12702. return nil
  12703. case employee.FieldAiInfo:
  12704. m.ResetAiInfo()
  12705. return nil
  12706. case employee.FieldIsVip:
  12707. m.ResetIsVip()
  12708. return nil
  12709. case employee.FieldChatURL:
  12710. m.ResetChatURL()
  12711. return nil
  12712. }
  12713. return fmt.Errorf("unknown Employee field %s", name)
  12714. }
  12715. // AddedEdges returns all edge names that were set/added in this mutation.
  12716. func (m *EmployeeMutation) AddedEdges() []string {
  12717. edges := make([]string, 0, 2)
  12718. if m.em_work_experiences != nil {
  12719. edges = append(edges, employee.EdgeEmWorkExperiences)
  12720. }
  12721. if m.em_tutorial != nil {
  12722. edges = append(edges, employee.EdgeEmTutorial)
  12723. }
  12724. return edges
  12725. }
  12726. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12727. // name in this mutation.
  12728. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12729. switch name {
  12730. case employee.EdgeEmWorkExperiences:
  12731. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12732. for id := range m.em_work_experiences {
  12733. ids = append(ids, id)
  12734. }
  12735. return ids
  12736. case employee.EdgeEmTutorial:
  12737. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12738. for id := range m.em_tutorial {
  12739. ids = append(ids, id)
  12740. }
  12741. return ids
  12742. }
  12743. return nil
  12744. }
  12745. // RemovedEdges returns all edge names that were removed in this mutation.
  12746. func (m *EmployeeMutation) RemovedEdges() []string {
  12747. edges := make([]string, 0, 2)
  12748. if m.removedem_work_experiences != nil {
  12749. edges = append(edges, employee.EdgeEmWorkExperiences)
  12750. }
  12751. if m.removedem_tutorial != nil {
  12752. edges = append(edges, employee.EdgeEmTutorial)
  12753. }
  12754. return edges
  12755. }
  12756. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12757. // the given name in this mutation.
  12758. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12759. switch name {
  12760. case employee.EdgeEmWorkExperiences:
  12761. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12762. for id := range m.removedem_work_experiences {
  12763. ids = append(ids, id)
  12764. }
  12765. return ids
  12766. case employee.EdgeEmTutorial:
  12767. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12768. for id := range m.removedem_tutorial {
  12769. ids = append(ids, id)
  12770. }
  12771. return ids
  12772. }
  12773. return nil
  12774. }
  12775. // ClearedEdges returns all edge names that were cleared in this mutation.
  12776. func (m *EmployeeMutation) ClearedEdges() []string {
  12777. edges := make([]string, 0, 2)
  12778. if m.clearedem_work_experiences {
  12779. edges = append(edges, employee.EdgeEmWorkExperiences)
  12780. }
  12781. if m.clearedem_tutorial {
  12782. edges = append(edges, employee.EdgeEmTutorial)
  12783. }
  12784. return edges
  12785. }
  12786. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12787. // was cleared in this mutation.
  12788. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12789. switch name {
  12790. case employee.EdgeEmWorkExperiences:
  12791. return m.clearedem_work_experiences
  12792. case employee.EdgeEmTutorial:
  12793. return m.clearedem_tutorial
  12794. }
  12795. return false
  12796. }
  12797. // ClearEdge clears the value of the edge with the given name. It returns an error
  12798. // if that edge is not defined in the schema.
  12799. func (m *EmployeeMutation) ClearEdge(name string) error {
  12800. switch name {
  12801. }
  12802. return fmt.Errorf("unknown Employee unique edge %s", name)
  12803. }
  12804. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12805. // It returns an error if the edge is not defined in the schema.
  12806. func (m *EmployeeMutation) ResetEdge(name string) error {
  12807. switch name {
  12808. case employee.EdgeEmWorkExperiences:
  12809. m.ResetEmWorkExperiences()
  12810. return nil
  12811. case employee.EdgeEmTutorial:
  12812. m.ResetEmTutorial()
  12813. return nil
  12814. }
  12815. return fmt.Errorf("unknown Employee edge %s", name)
  12816. }
  12817. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12818. type EmployeeConfigMutation struct {
  12819. config
  12820. op Op
  12821. typ string
  12822. id *uint64
  12823. created_at *time.Time
  12824. updated_at *time.Time
  12825. deleted_at *time.Time
  12826. stype *string
  12827. title *string
  12828. photo *string
  12829. organization_id *uint64
  12830. addorganization_id *int64
  12831. clearedFields map[string]struct{}
  12832. done bool
  12833. oldValue func(context.Context) (*EmployeeConfig, error)
  12834. predicates []predicate.EmployeeConfig
  12835. }
  12836. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12837. // employeeconfigOption allows management of the mutation configuration using functional options.
  12838. type employeeconfigOption func(*EmployeeConfigMutation)
  12839. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12840. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12841. m := &EmployeeConfigMutation{
  12842. config: c,
  12843. op: op,
  12844. typ: TypeEmployeeConfig,
  12845. clearedFields: make(map[string]struct{}),
  12846. }
  12847. for _, opt := range opts {
  12848. opt(m)
  12849. }
  12850. return m
  12851. }
  12852. // withEmployeeConfigID sets the ID field of the mutation.
  12853. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12854. return func(m *EmployeeConfigMutation) {
  12855. var (
  12856. err error
  12857. once sync.Once
  12858. value *EmployeeConfig
  12859. )
  12860. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12861. once.Do(func() {
  12862. if m.done {
  12863. err = errors.New("querying old values post mutation is not allowed")
  12864. } else {
  12865. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12866. }
  12867. })
  12868. return value, err
  12869. }
  12870. m.id = &id
  12871. }
  12872. }
  12873. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12874. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12875. return func(m *EmployeeConfigMutation) {
  12876. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12877. return node, nil
  12878. }
  12879. m.id = &node.ID
  12880. }
  12881. }
  12882. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12883. // executed in a transaction (ent.Tx), a transactional client is returned.
  12884. func (m EmployeeConfigMutation) Client() *Client {
  12885. client := &Client{config: m.config}
  12886. client.init()
  12887. return client
  12888. }
  12889. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12890. // it returns an error otherwise.
  12891. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  12892. if _, ok := m.driver.(*txDriver); !ok {
  12893. return nil, errors.New("ent: mutation is not running in a transaction")
  12894. }
  12895. tx := &Tx{config: m.config}
  12896. tx.init()
  12897. return tx, nil
  12898. }
  12899. // SetID sets the value of the id field. Note that this
  12900. // operation is only accepted on creation of EmployeeConfig entities.
  12901. func (m *EmployeeConfigMutation) SetID(id uint64) {
  12902. m.id = &id
  12903. }
  12904. // ID returns the ID value in the mutation. Note that the ID is only available
  12905. // if it was provided to the builder or after it was returned from the database.
  12906. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  12907. if m.id == nil {
  12908. return
  12909. }
  12910. return *m.id, true
  12911. }
  12912. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12913. // That means, if the mutation is applied within a transaction with an isolation level such
  12914. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12915. // or updated by the mutation.
  12916. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  12917. switch {
  12918. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12919. id, exists := m.ID()
  12920. if exists {
  12921. return []uint64{id}, nil
  12922. }
  12923. fallthrough
  12924. case m.op.Is(OpUpdate | OpDelete):
  12925. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  12926. default:
  12927. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12928. }
  12929. }
  12930. // SetCreatedAt sets the "created_at" field.
  12931. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  12932. m.created_at = &t
  12933. }
  12934. // CreatedAt returns the value of the "created_at" field in the mutation.
  12935. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  12936. v := m.created_at
  12937. if v == nil {
  12938. return
  12939. }
  12940. return *v, true
  12941. }
  12942. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  12943. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12944. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12945. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12946. if !m.op.Is(OpUpdateOne) {
  12947. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12948. }
  12949. if m.id == nil || m.oldValue == nil {
  12950. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12951. }
  12952. oldValue, err := m.oldValue(ctx)
  12953. if err != nil {
  12954. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12955. }
  12956. return oldValue.CreatedAt, nil
  12957. }
  12958. // ResetCreatedAt resets all changes to the "created_at" field.
  12959. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  12960. m.created_at = nil
  12961. }
  12962. // SetUpdatedAt sets the "updated_at" field.
  12963. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  12964. m.updated_at = &t
  12965. }
  12966. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  12967. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  12968. v := m.updated_at
  12969. if v == nil {
  12970. return
  12971. }
  12972. return *v, true
  12973. }
  12974. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  12975. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12976. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12977. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  12978. if !m.op.Is(OpUpdateOne) {
  12979. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  12980. }
  12981. if m.id == nil || m.oldValue == nil {
  12982. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  12983. }
  12984. oldValue, err := m.oldValue(ctx)
  12985. if err != nil {
  12986. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  12987. }
  12988. return oldValue.UpdatedAt, nil
  12989. }
  12990. // ResetUpdatedAt resets all changes to the "updated_at" field.
  12991. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  12992. m.updated_at = nil
  12993. }
  12994. // SetDeletedAt sets the "deleted_at" field.
  12995. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  12996. m.deleted_at = &t
  12997. }
  12998. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  12999. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13000. v := m.deleted_at
  13001. if v == nil {
  13002. return
  13003. }
  13004. return *v, true
  13005. }
  13006. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13007. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13008. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13009. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13010. if !m.op.Is(OpUpdateOne) {
  13011. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13012. }
  13013. if m.id == nil || m.oldValue == nil {
  13014. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13015. }
  13016. oldValue, err := m.oldValue(ctx)
  13017. if err != nil {
  13018. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13019. }
  13020. return oldValue.DeletedAt, nil
  13021. }
  13022. // ClearDeletedAt clears the value of the "deleted_at" field.
  13023. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13024. m.deleted_at = nil
  13025. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13026. }
  13027. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13028. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13029. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13030. return ok
  13031. }
  13032. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13033. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13034. m.deleted_at = nil
  13035. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13036. }
  13037. // SetStype sets the "stype" field.
  13038. func (m *EmployeeConfigMutation) SetStype(s string) {
  13039. m.stype = &s
  13040. }
  13041. // Stype returns the value of the "stype" field in the mutation.
  13042. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13043. v := m.stype
  13044. if v == nil {
  13045. return
  13046. }
  13047. return *v, true
  13048. }
  13049. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13050. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13051. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13052. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13053. if !m.op.Is(OpUpdateOne) {
  13054. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13055. }
  13056. if m.id == nil || m.oldValue == nil {
  13057. return v, errors.New("OldStype requires an ID field in the mutation")
  13058. }
  13059. oldValue, err := m.oldValue(ctx)
  13060. if err != nil {
  13061. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13062. }
  13063. return oldValue.Stype, nil
  13064. }
  13065. // ResetStype resets all changes to the "stype" field.
  13066. func (m *EmployeeConfigMutation) ResetStype() {
  13067. m.stype = nil
  13068. }
  13069. // SetTitle sets the "title" field.
  13070. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13071. m.title = &s
  13072. }
  13073. // Title returns the value of the "title" field in the mutation.
  13074. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13075. v := m.title
  13076. if v == nil {
  13077. return
  13078. }
  13079. return *v, true
  13080. }
  13081. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13082. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13084. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13085. if !m.op.Is(OpUpdateOne) {
  13086. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13087. }
  13088. if m.id == nil || m.oldValue == nil {
  13089. return v, errors.New("OldTitle requires an ID field in the mutation")
  13090. }
  13091. oldValue, err := m.oldValue(ctx)
  13092. if err != nil {
  13093. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13094. }
  13095. return oldValue.Title, nil
  13096. }
  13097. // ResetTitle resets all changes to the "title" field.
  13098. func (m *EmployeeConfigMutation) ResetTitle() {
  13099. m.title = nil
  13100. }
  13101. // SetPhoto sets the "photo" field.
  13102. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13103. m.photo = &s
  13104. }
  13105. // Photo returns the value of the "photo" field in the mutation.
  13106. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13107. v := m.photo
  13108. if v == nil {
  13109. return
  13110. }
  13111. return *v, true
  13112. }
  13113. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13114. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13116. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13117. if !m.op.Is(OpUpdateOne) {
  13118. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13119. }
  13120. if m.id == nil || m.oldValue == nil {
  13121. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13122. }
  13123. oldValue, err := m.oldValue(ctx)
  13124. if err != nil {
  13125. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13126. }
  13127. return oldValue.Photo, nil
  13128. }
  13129. // ResetPhoto resets all changes to the "photo" field.
  13130. func (m *EmployeeConfigMutation) ResetPhoto() {
  13131. m.photo = nil
  13132. }
  13133. // SetOrganizationID sets the "organization_id" field.
  13134. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13135. m.organization_id = &u
  13136. m.addorganization_id = nil
  13137. }
  13138. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13139. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13140. v := m.organization_id
  13141. if v == nil {
  13142. return
  13143. }
  13144. return *v, true
  13145. }
  13146. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13147. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13149. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13150. if !m.op.Is(OpUpdateOne) {
  13151. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13152. }
  13153. if m.id == nil || m.oldValue == nil {
  13154. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13155. }
  13156. oldValue, err := m.oldValue(ctx)
  13157. if err != nil {
  13158. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13159. }
  13160. return oldValue.OrganizationID, nil
  13161. }
  13162. // AddOrganizationID adds u to the "organization_id" field.
  13163. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13164. if m.addorganization_id != nil {
  13165. *m.addorganization_id += u
  13166. } else {
  13167. m.addorganization_id = &u
  13168. }
  13169. }
  13170. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13171. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13172. v := m.addorganization_id
  13173. if v == nil {
  13174. return
  13175. }
  13176. return *v, true
  13177. }
  13178. // ClearOrganizationID clears the value of the "organization_id" field.
  13179. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13180. m.organization_id = nil
  13181. m.addorganization_id = nil
  13182. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13183. }
  13184. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13185. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13186. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13187. return ok
  13188. }
  13189. // ResetOrganizationID resets all changes to the "organization_id" field.
  13190. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13191. m.organization_id = nil
  13192. m.addorganization_id = nil
  13193. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13194. }
  13195. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13196. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13197. m.predicates = append(m.predicates, ps...)
  13198. }
  13199. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13200. // users can use type-assertion to append predicates that do not depend on any generated package.
  13201. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13202. p := make([]predicate.EmployeeConfig, len(ps))
  13203. for i := range ps {
  13204. p[i] = ps[i]
  13205. }
  13206. m.Where(p...)
  13207. }
  13208. // Op returns the operation name.
  13209. func (m *EmployeeConfigMutation) Op() Op {
  13210. return m.op
  13211. }
  13212. // SetOp allows setting the mutation operation.
  13213. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13214. m.op = op
  13215. }
  13216. // Type returns the node type of this mutation (EmployeeConfig).
  13217. func (m *EmployeeConfigMutation) Type() string {
  13218. return m.typ
  13219. }
  13220. // Fields returns all fields that were changed during this mutation. Note that in
  13221. // order to get all numeric fields that were incremented/decremented, call
  13222. // AddedFields().
  13223. func (m *EmployeeConfigMutation) Fields() []string {
  13224. fields := make([]string, 0, 7)
  13225. if m.created_at != nil {
  13226. fields = append(fields, employeeconfig.FieldCreatedAt)
  13227. }
  13228. if m.updated_at != nil {
  13229. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13230. }
  13231. if m.deleted_at != nil {
  13232. fields = append(fields, employeeconfig.FieldDeletedAt)
  13233. }
  13234. if m.stype != nil {
  13235. fields = append(fields, employeeconfig.FieldStype)
  13236. }
  13237. if m.title != nil {
  13238. fields = append(fields, employeeconfig.FieldTitle)
  13239. }
  13240. if m.photo != nil {
  13241. fields = append(fields, employeeconfig.FieldPhoto)
  13242. }
  13243. if m.organization_id != nil {
  13244. fields = append(fields, employeeconfig.FieldOrganizationID)
  13245. }
  13246. return fields
  13247. }
  13248. // Field returns the value of a field with the given name. The second boolean
  13249. // return value indicates that this field was not set, or was not defined in the
  13250. // schema.
  13251. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13252. switch name {
  13253. case employeeconfig.FieldCreatedAt:
  13254. return m.CreatedAt()
  13255. case employeeconfig.FieldUpdatedAt:
  13256. return m.UpdatedAt()
  13257. case employeeconfig.FieldDeletedAt:
  13258. return m.DeletedAt()
  13259. case employeeconfig.FieldStype:
  13260. return m.Stype()
  13261. case employeeconfig.FieldTitle:
  13262. return m.Title()
  13263. case employeeconfig.FieldPhoto:
  13264. return m.Photo()
  13265. case employeeconfig.FieldOrganizationID:
  13266. return m.OrganizationID()
  13267. }
  13268. return nil, false
  13269. }
  13270. // OldField returns the old value of the field from the database. An error is
  13271. // returned if the mutation operation is not UpdateOne, or the query to the
  13272. // database failed.
  13273. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13274. switch name {
  13275. case employeeconfig.FieldCreatedAt:
  13276. return m.OldCreatedAt(ctx)
  13277. case employeeconfig.FieldUpdatedAt:
  13278. return m.OldUpdatedAt(ctx)
  13279. case employeeconfig.FieldDeletedAt:
  13280. return m.OldDeletedAt(ctx)
  13281. case employeeconfig.FieldStype:
  13282. return m.OldStype(ctx)
  13283. case employeeconfig.FieldTitle:
  13284. return m.OldTitle(ctx)
  13285. case employeeconfig.FieldPhoto:
  13286. return m.OldPhoto(ctx)
  13287. case employeeconfig.FieldOrganizationID:
  13288. return m.OldOrganizationID(ctx)
  13289. }
  13290. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13291. }
  13292. // SetField sets the value of a field with the given name. It returns an error if
  13293. // the field is not defined in the schema, or if the type mismatched the field
  13294. // type.
  13295. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13296. switch name {
  13297. case employeeconfig.FieldCreatedAt:
  13298. v, ok := value.(time.Time)
  13299. if !ok {
  13300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13301. }
  13302. m.SetCreatedAt(v)
  13303. return nil
  13304. case employeeconfig.FieldUpdatedAt:
  13305. v, ok := value.(time.Time)
  13306. if !ok {
  13307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13308. }
  13309. m.SetUpdatedAt(v)
  13310. return nil
  13311. case employeeconfig.FieldDeletedAt:
  13312. v, ok := value.(time.Time)
  13313. if !ok {
  13314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13315. }
  13316. m.SetDeletedAt(v)
  13317. return nil
  13318. case employeeconfig.FieldStype:
  13319. v, ok := value.(string)
  13320. if !ok {
  13321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13322. }
  13323. m.SetStype(v)
  13324. return nil
  13325. case employeeconfig.FieldTitle:
  13326. v, ok := value.(string)
  13327. if !ok {
  13328. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13329. }
  13330. m.SetTitle(v)
  13331. return nil
  13332. case employeeconfig.FieldPhoto:
  13333. v, ok := value.(string)
  13334. if !ok {
  13335. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13336. }
  13337. m.SetPhoto(v)
  13338. return nil
  13339. case employeeconfig.FieldOrganizationID:
  13340. v, ok := value.(uint64)
  13341. if !ok {
  13342. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13343. }
  13344. m.SetOrganizationID(v)
  13345. return nil
  13346. }
  13347. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13348. }
  13349. // AddedFields returns all numeric fields that were incremented/decremented during
  13350. // this mutation.
  13351. func (m *EmployeeConfigMutation) AddedFields() []string {
  13352. var fields []string
  13353. if m.addorganization_id != nil {
  13354. fields = append(fields, employeeconfig.FieldOrganizationID)
  13355. }
  13356. return fields
  13357. }
  13358. // AddedField returns the numeric value that was incremented/decremented on a field
  13359. // with the given name. The second boolean return value indicates that this field
  13360. // was not set, or was not defined in the schema.
  13361. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13362. switch name {
  13363. case employeeconfig.FieldOrganizationID:
  13364. return m.AddedOrganizationID()
  13365. }
  13366. return nil, false
  13367. }
  13368. // AddField adds the value to the field with the given name. It returns an error if
  13369. // the field is not defined in the schema, or if the type mismatched the field
  13370. // type.
  13371. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13372. switch name {
  13373. case employeeconfig.FieldOrganizationID:
  13374. v, ok := value.(int64)
  13375. if !ok {
  13376. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13377. }
  13378. m.AddOrganizationID(v)
  13379. return nil
  13380. }
  13381. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13382. }
  13383. // ClearedFields returns all nullable fields that were cleared during this
  13384. // mutation.
  13385. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13386. var fields []string
  13387. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13388. fields = append(fields, employeeconfig.FieldDeletedAt)
  13389. }
  13390. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13391. fields = append(fields, employeeconfig.FieldOrganizationID)
  13392. }
  13393. return fields
  13394. }
  13395. // FieldCleared returns a boolean indicating if a field with the given name was
  13396. // cleared in this mutation.
  13397. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13398. _, ok := m.clearedFields[name]
  13399. return ok
  13400. }
  13401. // ClearField clears the value of the field with the given name. It returns an
  13402. // error if the field is not defined in the schema.
  13403. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13404. switch name {
  13405. case employeeconfig.FieldDeletedAt:
  13406. m.ClearDeletedAt()
  13407. return nil
  13408. case employeeconfig.FieldOrganizationID:
  13409. m.ClearOrganizationID()
  13410. return nil
  13411. }
  13412. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13413. }
  13414. // ResetField resets all changes in the mutation for the field with the given name.
  13415. // It returns an error if the field is not defined in the schema.
  13416. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13417. switch name {
  13418. case employeeconfig.FieldCreatedAt:
  13419. m.ResetCreatedAt()
  13420. return nil
  13421. case employeeconfig.FieldUpdatedAt:
  13422. m.ResetUpdatedAt()
  13423. return nil
  13424. case employeeconfig.FieldDeletedAt:
  13425. m.ResetDeletedAt()
  13426. return nil
  13427. case employeeconfig.FieldStype:
  13428. m.ResetStype()
  13429. return nil
  13430. case employeeconfig.FieldTitle:
  13431. m.ResetTitle()
  13432. return nil
  13433. case employeeconfig.FieldPhoto:
  13434. m.ResetPhoto()
  13435. return nil
  13436. case employeeconfig.FieldOrganizationID:
  13437. m.ResetOrganizationID()
  13438. return nil
  13439. }
  13440. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13441. }
  13442. // AddedEdges returns all edge names that were set/added in this mutation.
  13443. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13444. edges := make([]string, 0, 0)
  13445. return edges
  13446. }
  13447. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13448. // name in this mutation.
  13449. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13450. return nil
  13451. }
  13452. // RemovedEdges returns all edge names that were removed in this mutation.
  13453. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13454. edges := make([]string, 0, 0)
  13455. return edges
  13456. }
  13457. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13458. // the given name in this mutation.
  13459. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13460. return nil
  13461. }
  13462. // ClearedEdges returns all edge names that were cleared in this mutation.
  13463. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13464. edges := make([]string, 0, 0)
  13465. return edges
  13466. }
  13467. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13468. // was cleared in this mutation.
  13469. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13470. return false
  13471. }
  13472. // ClearEdge clears the value of the edge with the given name. It returns an error
  13473. // if that edge is not defined in the schema.
  13474. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13475. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13476. }
  13477. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13478. // It returns an error if the edge is not defined in the schema.
  13479. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13480. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13481. }
  13482. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13483. type LabelMutation struct {
  13484. config
  13485. op Op
  13486. typ string
  13487. id *uint64
  13488. created_at *time.Time
  13489. updated_at *time.Time
  13490. status *uint8
  13491. addstatus *int8
  13492. _type *int
  13493. add_type *int
  13494. name *string
  13495. from *int
  13496. addfrom *int
  13497. mode *int
  13498. addmode *int
  13499. conditions *string
  13500. organization_id *uint64
  13501. addorganization_id *int64
  13502. clearedFields map[string]struct{}
  13503. label_relationships map[uint64]struct{}
  13504. removedlabel_relationships map[uint64]struct{}
  13505. clearedlabel_relationships bool
  13506. done bool
  13507. oldValue func(context.Context) (*Label, error)
  13508. predicates []predicate.Label
  13509. }
  13510. var _ ent.Mutation = (*LabelMutation)(nil)
  13511. // labelOption allows management of the mutation configuration using functional options.
  13512. type labelOption func(*LabelMutation)
  13513. // newLabelMutation creates new mutation for the Label entity.
  13514. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13515. m := &LabelMutation{
  13516. config: c,
  13517. op: op,
  13518. typ: TypeLabel,
  13519. clearedFields: make(map[string]struct{}),
  13520. }
  13521. for _, opt := range opts {
  13522. opt(m)
  13523. }
  13524. return m
  13525. }
  13526. // withLabelID sets the ID field of the mutation.
  13527. func withLabelID(id uint64) labelOption {
  13528. return func(m *LabelMutation) {
  13529. var (
  13530. err error
  13531. once sync.Once
  13532. value *Label
  13533. )
  13534. m.oldValue = func(ctx context.Context) (*Label, error) {
  13535. once.Do(func() {
  13536. if m.done {
  13537. err = errors.New("querying old values post mutation is not allowed")
  13538. } else {
  13539. value, err = m.Client().Label.Get(ctx, id)
  13540. }
  13541. })
  13542. return value, err
  13543. }
  13544. m.id = &id
  13545. }
  13546. }
  13547. // withLabel sets the old Label of the mutation.
  13548. func withLabel(node *Label) labelOption {
  13549. return func(m *LabelMutation) {
  13550. m.oldValue = func(context.Context) (*Label, error) {
  13551. return node, nil
  13552. }
  13553. m.id = &node.ID
  13554. }
  13555. }
  13556. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13557. // executed in a transaction (ent.Tx), a transactional client is returned.
  13558. func (m LabelMutation) Client() *Client {
  13559. client := &Client{config: m.config}
  13560. client.init()
  13561. return client
  13562. }
  13563. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13564. // it returns an error otherwise.
  13565. func (m LabelMutation) Tx() (*Tx, error) {
  13566. if _, ok := m.driver.(*txDriver); !ok {
  13567. return nil, errors.New("ent: mutation is not running in a transaction")
  13568. }
  13569. tx := &Tx{config: m.config}
  13570. tx.init()
  13571. return tx, nil
  13572. }
  13573. // SetID sets the value of the id field. Note that this
  13574. // operation is only accepted on creation of Label entities.
  13575. func (m *LabelMutation) SetID(id uint64) {
  13576. m.id = &id
  13577. }
  13578. // ID returns the ID value in the mutation. Note that the ID is only available
  13579. // if it was provided to the builder or after it was returned from the database.
  13580. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13581. if m.id == nil {
  13582. return
  13583. }
  13584. return *m.id, true
  13585. }
  13586. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13587. // That means, if the mutation is applied within a transaction with an isolation level such
  13588. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13589. // or updated by the mutation.
  13590. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13591. switch {
  13592. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13593. id, exists := m.ID()
  13594. if exists {
  13595. return []uint64{id}, nil
  13596. }
  13597. fallthrough
  13598. case m.op.Is(OpUpdate | OpDelete):
  13599. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13600. default:
  13601. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13602. }
  13603. }
  13604. // SetCreatedAt sets the "created_at" field.
  13605. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13606. m.created_at = &t
  13607. }
  13608. // CreatedAt returns the value of the "created_at" field in the mutation.
  13609. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13610. v := m.created_at
  13611. if v == nil {
  13612. return
  13613. }
  13614. return *v, true
  13615. }
  13616. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13617. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13619. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13620. if !m.op.Is(OpUpdateOne) {
  13621. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13622. }
  13623. if m.id == nil || m.oldValue == nil {
  13624. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13625. }
  13626. oldValue, err := m.oldValue(ctx)
  13627. if err != nil {
  13628. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13629. }
  13630. return oldValue.CreatedAt, nil
  13631. }
  13632. // ResetCreatedAt resets all changes to the "created_at" field.
  13633. func (m *LabelMutation) ResetCreatedAt() {
  13634. m.created_at = nil
  13635. }
  13636. // SetUpdatedAt sets the "updated_at" field.
  13637. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13638. m.updated_at = &t
  13639. }
  13640. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13641. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13642. v := m.updated_at
  13643. if v == nil {
  13644. return
  13645. }
  13646. return *v, true
  13647. }
  13648. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13649. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13651. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13652. if !m.op.Is(OpUpdateOne) {
  13653. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13654. }
  13655. if m.id == nil || m.oldValue == nil {
  13656. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13657. }
  13658. oldValue, err := m.oldValue(ctx)
  13659. if err != nil {
  13660. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13661. }
  13662. return oldValue.UpdatedAt, nil
  13663. }
  13664. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13665. func (m *LabelMutation) ResetUpdatedAt() {
  13666. m.updated_at = nil
  13667. }
  13668. // SetStatus sets the "status" field.
  13669. func (m *LabelMutation) SetStatus(u uint8) {
  13670. m.status = &u
  13671. m.addstatus = nil
  13672. }
  13673. // Status returns the value of the "status" field in the mutation.
  13674. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13675. v := m.status
  13676. if v == nil {
  13677. return
  13678. }
  13679. return *v, true
  13680. }
  13681. // OldStatus returns the old "status" field's value of the Label entity.
  13682. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13684. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13685. if !m.op.Is(OpUpdateOne) {
  13686. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13687. }
  13688. if m.id == nil || m.oldValue == nil {
  13689. return v, errors.New("OldStatus requires an ID field in the mutation")
  13690. }
  13691. oldValue, err := m.oldValue(ctx)
  13692. if err != nil {
  13693. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13694. }
  13695. return oldValue.Status, nil
  13696. }
  13697. // AddStatus adds u to the "status" field.
  13698. func (m *LabelMutation) AddStatus(u int8) {
  13699. if m.addstatus != nil {
  13700. *m.addstatus += u
  13701. } else {
  13702. m.addstatus = &u
  13703. }
  13704. }
  13705. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13706. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13707. v := m.addstatus
  13708. if v == nil {
  13709. return
  13710. }
  13711. return *v, true
  13712. }
  13713. // ClearStatus clears the value of the "status" field.
  13714. func (m *LabelMutation) ClearStatus() {
  13715. m.status = nil
  13716. m.addstatus = nil
  13717. m.clearedFields[label.FieldStatus] = struct{}{}
  13718. }
  13719. // StatusCleared returns if the "status" field was cleared in this mutation.
  13720. func (m *LabelMutation) StatusCleared() bool {
  13721. _, ok := m.clearedFields[label.FieldStatus]
  13722. return ok
  13723. }
  13724. // ResetStatus resets all changes to the "status" field.
  13725. func (m *LabelMutation) ResetStatus() {
  13726. m.status = nil
  13727. m.addstatus = nil
  13728. delete(m.clearedFields, label.FieldStatus)
  13729. }
  13730. // SetType sets the "type" field.
  13731. func (m *LabelMutation) SetType(i int) {
  13732. m._type = &i
  13733. m.add_type = nil
  13734. }
  13735. // GetType returns the value of the "type" field in the mutation.
  13736. func (m *LabelMutation) GetType() (r int, exists bool) {
  13737. v := m._type
  13738. if v == nil {
  13739. return
  13740. }
  13741. return *v, true
  13742. }
  13743. // OldType returns the old "type" field's value of the Label entity.
  13744. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13746. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13747. if !m.op.Is(OpUpdateOne) {
  13748. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13749. }
  13750. if m.id == nil || m.oldValue == nil {
  13751. return v, errors.New("OldType requires an ID field in the mutation")
  13752. }
  13753. oldValue, err := m.oldValue(ctx)
  13754. if err != nil {
  13755. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13756. }
  13757. return oldValue.Type, nil
  13758. }
  13759. // AddType adds i to the "type" field.
  13760. func (m *LabelMutation) AddType(i int) {
  13761. if m.add_type != nil {
  13762. *m.add_type += i
  13763. } else {
  13764. m.add_type = &i
  13765. }
  13766. }
  13767. // AddedType returns the value that was added to the "type" field in this mutation.
  13768. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13769. v := m.add_type
  13770. if v == nil {
  13771. return
  13772. }
  13773. return *v, true
  13774. }
  13775. // ResetType resets all changes to the "type" field.
  13776. func (m *LabelMutation) ResetType() {
  13777. m._type = nil
  13778. m.add_type = nil
  13779. }
  13780. // SetName sets the "name" field.
  13781. func (m *LabelMutation) SetName(s string) {
  13782. m.name = &s
  13783. }
  13784. // Name returns the value of the "name" field in the mutation.
  13785. func (m *LabelMutation) Name() (r string, exists bool) {
  13786. v := m.name
  13787. if v == nil {
  13788. return
  13789. }
  13790. return *v, true
  13791. }
  13792. // OldName returns the old "name" field's value of the Label entity.
  13793. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13795. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13796. if !m.op.Is(OpUpdateOne) {
  13797. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13798. }
  13799. if m.id == nil || m.oldValue == nil {
  13800. return v, errors.New("OldName requires an ID field in the mutation")
  13801. }
  13802. oldValue, err := m.oldValue(ctx)
  13803. if err != nil {
  13804. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13805. }
  13806. return oldValue.Name, nil
  13807. }
  13808. // ResetName resets all changes to the "name" field.
  13809. func (m *LabelMutation) ResetName() {
  13810. m.name = nil
  13811. }
  13812. // SetFrom sets the "from" field.
  13813. func (m *LabelMutation) SetFrom(i int) {
  13814. m.from = &i
  13815. m.addfrom = nil
  13816. }
  13817. // From returns the value of the "from" field in the mutation.
  13818. func (m *LabelMutation) From() (r int, exists bool) {
  13819. v := m.from
  13820. if v == nil {
  13821. return
  13822. }
  13823. return *v, true
  13824. }
  13825. // OldFrom returns the old "from" field's value of the Label entity.
  13826. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13828. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13829. if !m.op.Is(OpUpdateOne) {
  13830. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13831. }
  13832. if m.id == nil || m.oldValue == nil {
  13833. return v, errors.New("OldFrom requires an ID field in the mutation")
  13834. }
  13835. oldValue, err := m.oldValue(ctx)
  13836. if err != nil {
  13837. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13838. }
  13839. return oldValue.From, nil
  13840. }
  13841. // AddFrom adds i to the "from" field.
  13842. func (m *LabelMutation) AddFrom(i int) {
  13843. if m.addfrom != nil {
  13844. *m.addfrom += i
  13845. } else {
  13846. m.addfrom = &i
  13847. }
  13848. }
  13849. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13850. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13851. v := m.addfrom
  13852. if v == nil {
  13853. return
  13854. }
  13855. return *v, true
  13856. }
  13857. // ResetFrom resets all changes to the "from" field.
  13858. func (m *LabelMutation) ResetFrom() {
  13859. m.from = nil
  13860. m.addfrom = nil
  13861. }
  13862. // SetMode sets the "mode" field.
  13863. func (m *LabelMutation) SetMode(i int) {
  13864. m.mode = &i
  13865. m.addmode = nil
  13866. }
  13867. // Mode returns the value of the "mode" field in the mutation.
  13868. func (m *LabelMutation) Mode() (r int, exists bool) {
  13869. v := m.mode
  13870. if v == nil {
  13871. return
  13872. }
  13873. return *v, true
  13874. }
  13875. // OldMode returns the old "mode" field's value of the Label entity.
  13876. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13877. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13878. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13879. if !m.op.Is(OpUpdateOne) {
  13880. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13881. }
  13882. if m.id == nil || m.oldValue == nil {
  13883. return v, errors.New("OldMode requires an ID field in the mutation")
  13884. }
  13885. oldValue, err := m.oldValue(ctx)
  13886. if err != nil {
  13887. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  13888. }
  13889. return oldValue.Mode, nil
  13890. }
  13891. // AddMode adds i to the "mode" field.
  13892. func (m *LabelMutation) AddMode(i int) {
  13893. if m.addmode != nil {
  13894. *m.addmode += i
  13895. } else {
  13896. m.addmode = &i
  13897. }
  13898. }
  13899. // AddedMode returns the value that was added to the "mode" field in this mutation.
  13900. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  13901. v := m.addmode
  13902. if v == nil {
  13903. return
  13904. }
  13905. return *v, true
  13906. }
  13907. // ResetMode resets all changes to the "mode" field.
  13908. func (m *LabelMutation) ResetMode() {
  13909. m.mode = nil
  13910. m.addmode = nil
  13911. }
  13912. // SetConditions sets the "conditions" field.
  13913. func (m *LabelMutation) SetConditions(s string) {
  13914. m.conditions = &s
  13915. }
  13916. // Conditions returns the value of the "conditions" field in the mutation.
  13917. func (m *LabelMutation) Conditions() (r string, exists bool) {
  13918. v := m.conditions
  13919. if v == nil {
  13920. return
  13921. }
  13922. return *v, true
  13923. }
  13924. // OldConditions returns the old "conditions" field's value of the Label entity.
  13925. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13927. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  13928. if !m.op.Is(OpUpdateOne) {
  13929. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13930. }
  13931. if m.id == nil || m.oldValue == nil {
  13932. return v, errors.New("OldConditions requires an ID field in the mutation")
  13933. }
  13934. oldValue, err := m.oldValue(ctx)
  13935. if err != nil {
  13936. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13937. }
  13938. return oldValue.Conditions, nil
  13939. }
  13940. // ClearConditions clears the value of the "conditions" field.
  13941. func (m *LabelMutation) ClearConditions() {
  13942. m.conditions = nil
  13943. m.clearedFields[label.FieldConditions] = struct{}{}
  13944. }
  13945. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13946. func (m *LabelMutation) ConditionsCleared() bool {
  13947. _, ok := m.clearedFields[label.FieldConditions]
  13948. return ok
  13949. }
  13950. // ResetConditions resets all changes to the "conditions" field.
  13951. func (m *LabelMutation) ResetConditions() {
  13952. m.conditions = nil
  13953. delete(m.clearedFields, label.FieldConditions)
  13954. }
  13955. // SetOrganizationID sets the "organization_id" field.
  13956. func (m *LabelMutation) SetOrganizationID(u uint64) {
  13957. m.organization_id = &u
  13958. m.addorganization_id = nil
  13959. }
  13960. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13961. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  13962. v := m.organization_id
  13963. if v == nil {
  13964. return
  13965. }
  13966. return *v, true
  13967. }
  13968. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  13969. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13970. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13971. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13972. if !m.op.Is(OpUpdateOne) {
  13973. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13974. }
  13975. if m.id == nil || m.oldValue == nil {
  13976. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13977. }
  13978. oldValue, err := m.oldValue(ctx)
  13979. if err != nil {
  13980. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13981. }
  13982. return oldValue.OrganizationID, nil
  13983. }
  13984. // AddOrganizationID adds u to the "organization_id" field.
  13985. func (m *LabelMutation) AddOrganizationID(u int64) {
  13986. if m.addorganization_id != nil {
  13987. *m.addorganization_id += u
  13988. } else {
  13989. m.addorganization_id = &u
  13990. }
  13991. }
  13992. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13993. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  13994. v := m.addorganization_id
  13995. if v == nil {
  13996. return
  13997. }
  13998. return *v, true
  13999. }
  14000. // ClearOrganizationID clears the value of the "organization_id" field.
  14001. func (m *LabelMutation) ClearOrganizationID() {
  14002. m.organization_id = nil
  14003. m.addorganization_id = nil
  14004. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14005. }
  14006. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14007. func (m *LabelMutation) OrganizationIDCleared() bool {
  14008. _, ok := m.clearedFields[label.FieldOrganizationID]
  14009. return ok
  14010. }
  14011. // ResetOrganizationID resets all changes to the "organization_id" field.
  14012. func (m *LabelMutation) ResetOrganizationID() {
  14013. m.organization_id = nil
  14014. m.addorganization_id = nil
  14015. delete(m.clearedFields, label.FieldOrganizationID)
  14016. }
  14017. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14018. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14019. if m.label_relationships == nil {
  14020. m.label_relationships = make(map[uint64]struct{})
  14021. }
  14022. for i := range ids {
  14023. m.label_relationships[ids[i]] = struct{}{}
  14024. }
  14025. }
  14026. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14027. func (m *LabelMutation) ClearLabelRelationships() {
  14028. m.clearedlabel_relationships = true
  14029. }
  14030. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14031. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14032. return m.clearedlabel_relationships
  14033. }
  14034. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14035. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14036. if m.removedlabel_relationships == nil {
  14037. m.removedlabel_relationships = make(map[uint64]struct{})
  14038. }
  14039. for i := range ids {
  14040. delete(m.label_relationships, ids[i])
  14041. m.removedlabel_relationships[ids[i]] = struct{}{}
  14042. }
  14043. }
  14044. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14045. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14046. for id := range m.removedlabel_relationships {
  14047. ids = append(ids, id)
  14048. }
  14049. return
  14050. }
  14051. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14052. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14053. for id := range m.label_relationships {
  14054. ids = append(ids, id)
  14055. }
  14056. return
  14057. }
  14058. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14059. func (m *LabelMutation) ResetLabelRelationships() {
  14060. m.label_relationships = nil
  14061. m.clearedlabel_relationships = false
  14062. m.removedlabel_relationships = nil
  14063. }
  14064. // Where appends a list predicates to the LabelMutation builder.
  14065. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14066. m.predicates = append(m.predicates, ps...)
  14067. }
  14068. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14069. // users can use type-assertion to append predicates that do not depend on any generated package.
  14070. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14071. p := make([]predicate.Label, len(ps))
  14072. for i := range ps {
  14073. p[i] = ps[i]
  14074. }
  14075. m.Where(p...)
  14076. }
  14077. // Op returns the operation name.
  14078. func (m *LabelMutation) Op() Op {
  14079. return m.op
  14080. }
  14081. // SetOp allows setting the mutation operation.
  14082. func (m *LabelMutation) SetOp(op Op) {
  14083. m.op = op
  14084. }
  14085. // Type returns the node type of this mutation (Label).
  14086. func (m *LabelMutation) Type() string {
  14087. return m.typ
  14088. }
  14089. // Fields returns all fields that were changed during this mutation. Note that in
  14090. // order to get all numeric fields that were incremented/decremented, call
  14091. // AddedFields().
  14092. func (m *LabelMutation) Fields() []string {
  14093. fields := make([]string, 0, 9)
  14094. if m.created_at != nil {
  14095. fields = append(fields, label.FieldCreatedAt)
  14096. }
  14097. if m.updated_at != nil {
  14098. fields = append(fields, label.FieldUpdatedAt)
  14099. }
  14100. if m.status != nil {
  14101. fields = append(fields, label.FieldStatus)
  14102. }
  14103. if m._type != nil {
  14104. fields = append(fields, label.FieldType)
  14105. }
  14106. if m.name != nil {
  14107. fields = append(fields, label.FieldName)
  14108. }
  14109. if m.from != nil {
  14110. fields = append(fields, label.FieldFrom)
  14111. }
  14112. if m.mode != nil {
  14113. fields = append(fields, label.FieldMode)
  14114. }
  14115. if m.conditions != nil {
  14116. fields = append(fields, label.FieldConditions)
  14117. }
  14118. if m.organization_id != nil {
  14119. fields = append(fields, label.FieldOrganizationID)
  14120. }
  14121. return fields
  14122. }
  14123. // Field returns the value of a field with the given name. The second boolean
  14124. // return value indicates that this field was not set, or was not defined in the
  14125. // schema.
  14126. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14127. switch name {
  14128. case label.FieldCreatedAt:
  14129. return m.CreatedAt()
  14130. case label.FieldUpdatedAt:
  14131. return m.UpdatedAt()
  14132. case label.FieldStatus:
  14133. return m.Status()
  14134. case label.FieldType:
  14135. return m.GetType()
  14136. case label.FieldName:
  14137. return m.Name()
  14138. case label.FieldFrom:
  14139. return m.From()
  14140. case label.FieldMode:
  14141. return m.Mode()
  14142. case label.FieldConditions:
  14143. return m.Conditions()
  14144. case label.FieldOrganizationID:
  14145. return m.OrganizationID()
  14146. }
  14147. return nil, false
  14148. }
  14149. // OldField returns the old value of the field from the database. An error is
  14150. // returned if the mutation operation is not UpdateOne, or the query to the
  14151. // database failed.
  14152. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14153. switch name {
  14154. case label.FieldCreatedAt:
  14155. return m.OldCreatedAt(ctx)
  14156. case label.FieldUpdatedAt:
  14157. return m.OldUpdatedAt(ctx)
  14158. case label.FieldStatus:
  14159. return m.OldStatus(ctx)
  14160. case label.FieldType:
  14161. return m.OldType(ctx)
  14162. case label.FieldName:
  14163. return m.OldName(ctx)
  14164. case label.FieldFrom:
  14165. return m.OldFrom(ctx)
  14166. case label.FieldMode:
  14167. return m.OldMode(ctx)
  14168. case label.FieldConditions:
  14169. return m.OldConditions(ctx)
  14170. case label.FieldOrganizationID:
  14171. return m.OldOrganizationID(ctx)
  14172. }
  14173. return nil, fmt.Errorf("unknown Label field %s", name)
  14174. }
  14175. // SetField sets the value of a field with the given name. It returns an error if
  14176. // the field is not defined in the schema, or if the type mismatched the field
  14177. // type.
  14178. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14179. switch name {
  14180. case label.FieldCreatedAt:
  14181. v, ok := value.(time.Time)
  14182. if !ok {
  14183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14184. }
  14185. m.SetCreatedAt(v)
  14186. return nil
  14187. case label.FieldUpdatedAt:
  14188. v, ok := value.(time.Time)
  14189. if !ok {
  14190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14191. }
  14192. m.SetUpdatedAt(v)
  14193. return nil
  14194. case label.FieldStatus:
  14195. v, ok := value.(uint8)
  14196. if !ok {
  14197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14198. }
  14199. m.SetStatus(v)
  14200. return nil
  14201. case label.FieldType:
  14202. v, ok := value.(int)
  14203. if !ok {
  14204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14205. }
  14206. m.SetType(v)
  14207. return nil
  14208. case label.FieldName:
  14209. v, ok := value.(string)
  14210. if !ok {
  14211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14212. }
  14213. m.SetName(v)
  14214. return nil
  14215. case label.FieldFrom:
  14216. v, ok := value.(int)
  14217. if !ok {
  14218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14219. }
  14220. m.SetFrom(v)
  14221. return nil
  14222. case label.FieldMode:
  14223. v, ok := value.(int)
  14224. if !ok {
  14225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14226. }
  14227. m.SetMode(v)
  14228. return nil
  14229. case label.FieldConditions:
  14230. v, ok := value.(string)
  14231. if !ok {
  14232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14233. }
  14234. m.SetConditions(v)
  14235. return nil
  14236. case label.FieldOrganizationID:
  14237. v, ok := value.(uint64)
  14238. if !ok {
  14239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14240. }
  14241. m.SetOrganizationID(v)
  14242. return nil
  14243. }
  14244. return fmt.Errorf("unknown Label field %s", name)
  14245. }
  14246. // AddedFields returns all numeric fields that were incremented/decremented during
  14247. // this mutation.
  14248. func (m *LabelMutation) AddedFields() []string {
  14249. var fields []string
  14250. if m.addstatus != nil {
  14251. fields = append(fields, label.FieldStatus)
  14252. }
  14253. if m.add_type != nil {
  14254. fields = append(fields, label.FieldType)
  14255. }
  14256. if m.addfrom != nil {
  14257. fields = append(fields, label.FieldFrom)
  14258. }
  14259. if m.addmode != nil {
  14260. fields = append(fields, label.FieldMode)
  14261. }
  14262. if m.addorganization_id != nil {
  14263. fields = append(fields, label.FieldOrganizationID)
  14264. }
  14265. return fields
  14266. }
  14267. // AddedField returns the numeric value that was incremented/decremented on a field
  14268. // with the given name. The second boolean return value indicates that this field
  14269. // was not set, or was not defined in the schema.
  14270. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14271. switch name {
  14272. case label.FieldStatus:
  14273. return m.AddedStatus()
  14274. case label.FieldType:
  14275. return m.AddedType()
  14276. case label.FieldFrom:
  14277. return m.AddedFrom()
  14278. case label.FieldMode:
  14279. return m.AddedMode()
  14280. case label.FieldOrganizationID:
  14281. return m.AddedOrganizationID()
  14282. }
  14283. return nil, false
  14284. }
  14285. // AddField adds the value to the field with the given name. It returns an error if
  14286. // the field is not defined in the schema, or if the type mismatched the field
  14287. // type.
  14288. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14289. switch name {
  14290. case label.FieldStatus:
  14291. v, ok := value.(int8)
  14292. if !ok {
  14293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14294. }
  14295. m.AddStatus(v)
  14296. return nil
  14297. case label.FieldType:
  14298. v, ok := value.(int)
  14299. if !ok {
  14300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14301. }
  14302. m.AddType(v)
  14303. return nil
  14304. case label.FieldFrom:
  14305. v, ok := value.(int)
  14306. if !ok {
  14307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14308. }
  14309. m.AddFrom(v)
  14310. return nil
  14311. case label.FieldMode:
  14312. v, ok := value.(int)
  14313. if !ok {
  14314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14315. }
  14316. m.AddMode(v)
  14317. return nil
  14318. case label.FieldOrganizationID:
  14319. v, ok := value.(int64)
  14320. if !ok {
  14321. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14322. }
  14323. m.AddOrganizationID(v)
  14324. return nil
  14325. }
  14326. return fmt.Errorf("unknown Label numeric field %s", name)
  14327. }
  14328. // ClearedFields returns all nullable fields that were cleared during this
  14329. // mutation.
  14330. func (m *LabelMutation) ClearedFields() []string {
  14331. var fields []string
  14332. if m.FieldCleared(label.FieldStatus) {
  14333. fields = append(fields, label.FieldStatus)
  14334. }
  14335. if m.FieldCleared(label.FieldConditions) {
  14336. fields = append(fields, label.FieldConditions)
  14337. }
  14338. if m.FieldCleared(label.FieldOrganizationID) {
  14339. fields = append(fields, label.FieldOrganizationID)
  14340. }
  14341. return fields
  14342. }
  14343. // FieldCleared returns a boolean indicating if a field with the given name was
  14344. // cleared in this mutation.
  14345. func (m *LabelMutation) FieldCleared(name string) bool {
  14346. _, ok := m.clearedFields[name]
  14347. return ok
  14348. }
  14349. // ClearField clears the value of the field with the given name. It returns an
  14350. // error if the field is not defined in the schema.
  14351. func (m *LabelMutation) ClearField(name string) error {
  14352. switch name {
  14353. case label.FieldStatus:
  14354. m.ClearStatus()
  14355. return nil
  14356. case label.FieldConditions:
  14357. m.ClearConditions()
  14358. return nil
  14359. case label.FieldOrganizationID:
  14360. m.ClearOrganizationID()
  14361. return nil
  14362. }
  14363. return fmt.Errorf("unknown Label nullable field %s", name)
  14364. }
  14365. // ResetField resets all changes in the mutation for the field with the given name.
  14366. // It returns an error if the field is not defined in the schema.
  14367. func (m *LabelMutation) ResetField(name string) error {
  14368. switch name {
  14369. case label.FieldCreatedAt:
  14370. m.ResetCreatedAt()
  14371. return nil
  14372. case label.FieldUpdatedAt:
  14373. m.ResetUpdatedAt()
  14374. return nil
  14375. case label.FieldStatus:
  14376. m.ResetStatus()
  14377. return nil
  14378. case label.FieldType:
  14379. m.ResetType()
  14380. return nil
  14381. case label.FieldName:
  14382. m.ResetName()
  14383. return nil
  14384. case label.FieldFrom:
  14385. m.ResetFrom()
  14386. return nil
  14387. case label.FieldMode:
  14388. m.ResetMode()
  14389. return nil
  14390. case label.FieldConditions:
  14391. m.ResetConditions()
  14392. return nil
  14393. case label.FieldOrganizationID:
  14394. m.ResetOrganizationID()
  14395. return nil
  14396. }
  14397. return fmt.Errorf("unknown Label field %s", name)
  14398. }
  14399. // AddedEdges returns all edge names that were set/added in this mutation.
  14400. func (m *LabelMutation) AddedEdges() []string {
  14401. edges := make([]string, 0, 1)
  14402. if m.label_relationships != nil {
  14403. edges = append(edges, label.EdgeLabelRelationships)
  14404. }
  14405. return edges
  14406. }
  14407. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14408. // name in this mutation.
  14409. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14410. switch name {
  14411. case label.EdgeLabelRelationships:
  14412. ids := make([]ent.Value, 0, len(m.label_relationships))
  14413. for id := range m.label_relationships {
  14414. ids = append(ids, id)
  14415. }
  14416. return ids
  14417. }
  14418. return nil
  14419. }
  14420. // RemovedEdges returns all edge names that were removed in this mutation.
  14421. func (m *LabelMutation) RemovedEdges() []string {
  14422. edges := make([]string, 0, 1)
  14423. if m.removedlabel_relationships != nil {
  14424. edges = append(edges, label.EdgeLabelRelationships)
  14425. }
  14426. return edges
  14427. }
  14428. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14429. // the given name in this mutation.
  14430. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14431. switch name {
  14432. case label.EdgeLabelRelationships:
  14433. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14434. for id := range m.removedlabel_relationships {
  14435. ids = append(ids, id)
  14436. }
  14437. return ids
  14438. }
  14439. return nil
  14440. }
  14441. // ClearedEdges returns all edge names that were cleared in this mutation.
  14442. func (m *LabelMutation) ClearedEdges() []string {
  14443. edges := make([]string, 0, 1)
  14444. if m.clearedlabel_relationships {
  14445. edges = append(edges, label.EdgeLabelRelationships)
  14446. }
  14447. return edges
  14448. }
  14449. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14450. // was cleared in this mutation.
  14451. func (m *LabelMutation) EdgeCleared(name string) bool {
  14452. switch name {
  14453. case label.EdgeLabelRelationships:
  14454. return m.clearedlabel_relationships
  14455. }
  14456. return false
  14457. }
  14458. // ClearEdge clears the value of the edge with the given name. It returns an error
  14459. // if that edge is not defined in the schema.
  14460. func (m *LabelMutation) ClearEdge(name string) error {
  14461. switch name {
  14462. }
  14463. return fmt.Errorf("unknown Label unique edge %s", name)
  14464. }
  14465. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14466. // It returns an error if the edge is not defined in the schema.
  14467. func (m *LabelMutation) ResetEdge(name string) error {
  14468. switch name {
  14469. case label.EdgeLabelRelationships:
  14470. m.ResetLabelRelationships()
  14471. return nil
  14472. }
  14473. return fmt.Errorf("unknown Label edge %s", name)
  14474. }
  14475. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14476. type LabelRelationshipMutation struct {
  14477. config
  14478. op Op
  14479. typ string
  14480. id *uint64
  14481. created_at *time.Time
  14482. updated_at *time.Time
  14483. status *uint8
  14484. addstatus *int8
  14485. organization_id *uint64
  14486. addorganization_id *int64
  14487. clearedFields map[string]struct{}
  14488. contacts *uint64
  14489. clearedcontacts bool
  14490. labels *uint64
  14491. clearedlabels bool
  14492. done bool
  14493. oldValue func(context.Context) (*LabelRelationship, error)
  14494. predicates []predicate.LabelRelationship
  14495. }
  14496. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14497. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14498. type labelrelationshipOption func(*LabelRelationshipMutation)
  14499. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14500. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14501. m := &LabelRelationshipMutation{
  14502. config: c,
  14503. op: op,
  14504. typ: TypeLabelRelationship,
  14505. clearedFields: make(map[string]struct{}),
  14506. }
  14507. for _, opt := range opts {
  14508. opt(m)
  14509. }
  14510. return m
  14511. }
  14512. // withLabelRelationshipID sets the ID field of the mutation.
  14513. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14514. return func(m *LabelRelationshipMutation) {
  14515. var (
  14516. err error
  14517. once sync.Once
  14518. value *LabelRelationship
  14519. )
  14520. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14521. once.Do(func() {
  14522. if m.done {
  14523. err = errors.New("querying old values post mutation is not allowed")
  14524. } else {
  14525. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14526. }
  14527. })
  14528. return value, err
  14529. }
  14530. m.id = &id
  14531. }
  14532. }
  14533. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14534. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14535. return func(m *LabelRelationshipMutation) {
  14536. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14537. return node, nil
  14538. }
  14539. m.id = &node.ID
  14540. }
  14541. }
  14542. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14543. // executed in a transaction (ent.Tx), a transactional client is returned.
  14544. func (m LabelRelationshipMutation) Client() *Client {
  14545. client := &Client{config: m.config}
  14546. client.init()
  14547. return client
  14548. }
  14549. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14550. // it returns an error otherwise.
  14551. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14552. if _, ok := m.driver.(*txDriver); !ok {
  14553. return nil, errors.New("ent: mutation is not running in a transaction")
  14554. }
  14555. tx := &Tx{config: m.config}
  14556. tx.init()
  14557. return tx, nil
  14558. }
  14559. // SetID sets the value of the id field. Note that this
  14560. // operation is only accepted on creation of LabelRelationship entities.
  14561. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14562. m.id = &id
  14563. }
  14564. // ID returns the ID value in the mutation. Note that the ID is only available
  14565. // if it was provided to the builder or after it was returned from the database.
  14566. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14567. if m.id == nil {
  14568. return
  14569. }
  14570. return *m.id, true
  14571. }
  14572. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14573. // That means, if the mutation is applied within a transaction with an isolation level such
  14574. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14575. // or updated by the mutation.
  14576. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14577. switch {
  14578. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14579. id, exists := m.ID()
  14580. if exists {
  14581. return []uint64{id}, nil
  14582. }
  14583. fallthrough
  14584. case m.op.Is(OpUpdate | OpDelete):
  14585. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14586. default:
  14587. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14588. }
  14589. }
  14590. // SetCreatedAt sets the "created_at" field.
  14591. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14592. m.created_at = &t
  14593. }
  14594. // CreatedAt returns the value of the "created_at" field in the mutation.
  14595. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14596. v := m.created_at
  14597. if v == nil {
  14598. return
  14599. }
  14600. return *v, true
  14601. }
  14602. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14603. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14605. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14606. if !m.op.Is(OpUpdateOne) {
  14607. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14608. }
  14609. if m.id == nil || m.oldValue == nil {
  14610. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14611. }
  14612. oldValue, err := m.oldValue(ctx)
  14613. if err != nil {
  14614. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14615. }
  14616. return oldValue.CreatedAt, nil
  14617. }
  14618. // ResetCreatedAt resets all changes to the "created_at" field.
  14619. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14620. m.created_at = nil
  14621. }
  14622. // SetUpdatedAt sets the "updated_at" field.
  14623. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14624. m.updated_at = &t
  14625. }
  14626. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14627. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14628. v := m.updated_at
  14629. if v == nil {
  14630. return
  14631. }
  14632. return *v, true
  14633. }
  14634. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14635. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14637. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14638. if !m.op.Is(OpUpdateOne) {
  14639. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14640. }
  14641. if m.id == nil || m.oldValue == nil {
  14642. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14643. }
  14644. oldValue, err := m.oldValue(ctx)
  14645. if err != nil {
  14646. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14647. }
  14648. return oldValue.UpdatedAt, nil
  14649. }
  14650. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14651. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14652. m.updated_at = nil
  14653. }
  14654. // SetStatus sets the "status" field.
  14655. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14656. m.status = &u
  14657. m.addstatus = nil
  14658. }
  14659. // Status returns the value of the "status" field in the mutation.
  14660. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14661. v := m.status
  14662. if v == nil {
  14663. return
  14664. }
  14665. return *v, true
  14666. }
  14667. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14668. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14670. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14671. if !m.op.Is(OpUpdateOne) {
  14672. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14673. }
  14674. if m.id == nil || m.oldValue == nil {
  14675. return v, errors.New("OldStatus requires an ID field in the mutation")
  14676. }
  14677. oldValue, err := m.oldValue(ctx)
  14678. if err != nil {
  14679. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14680. }
  14681. return oldValue.Status, nil
  14682. }
  14683. // AddStatus adds u to the "status" field.
  14684. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14685. if m.addstatus != nil {
  14686. *m.addstatus += u
  14687. } else {
  14688. m.addstatus = &u
  14689. }
  14690. }
  14691. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14692. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14693. v := m.addstatus
  14694. if v == nil {
  14695. return
  14696. }
  14697. return *v, true
  14698. }
  14699. // ClearStatus clears the value of the "status" field.
  14700. func (m *LabelRelationshipMutation) ClearStatus() {
  14701. m.status = nil
  14702. m.addstatus = nil
  14703. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14704. }
  14705. // StatusCleared returns if the "status" field was cleared in this mutation.
  14706. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14707. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14708. return ok
  14709. }
  14710. // ResetStatus resets all changes to the "status" field.
  14711. func (m *LabelRelationshipMutation) ResetStatus() {
  14712. m.status = nil
  14713. m.addstatus = nil
  14714. delete(m.clearedFields, labelrelationship.FieldStatus)
  14715. }
  14716. // SetLabelID sets the "label_id" field.
  14717. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14718. m.labels = &u
  14719. }
  14720. // LabelID returns the value of the "label_id" field in the mutation.
  14721. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14722. v := m.labels
  14723. if v == nil {
  14724. return
  14725. }
  14726. return *v, true
  14727. }
  14728. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14729. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14731. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14732. if !m.op.Is(OpUpdateOne) {
  14733. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14734. }
  14735. if m.id == nil || m.oldValue == nil {
  14736. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14737. }
  14738. oldValue, err := m.oldValue(ctx)
  14739. if err != nil {
  14740. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14741. }
  14742. return oldValue.LabelID, nil
  14743. }
  14744. // ResetLabelID resets all changes to the "label_id" field.
  14745. func (m *LabelRelationshipMutation) ResetLabelID() {
  14746. m.labels = nil
  14747. }
  14748. // SetContactID sets the "contact_id" field.
  14749. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14750. m.contacts = &u
  14751. }
  14752. // ContactID returns the value of the "contact_id" field in the mutation.
  14753. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14754. v := m.contacts
  14755. if v == nil {
  14756. return
  14757. }
  14758. return *v, true
  14759. }
  14760. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14761. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14763. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14764. if !m.op.Is(OpUpdateOne) {
  14765. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14766. }
  14767. if m.id == nil || m.oldValue == nil {
  14768. return v, errors.New("OldContactID requires an ID field in the mutation")
  14769. }
  14770. oldValue, err := m.oldValue(ctx)
  14771. if err != nil {
  14772. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14773. }
  14774. return oldValue.ContactID, nil
  14775. }
  14776. // ResetContactID resets all changes to the "contact_id" field.
  14777. func (m *LabelRelationshipMutation) ResetContactID() {
  14778. m.contacts = nil
  14779. }
  14780. // SetOrganizationID sets the "organization_id" field.
  14781. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14782. m.organization_id = &u
  14783. m.addorganization_id = nil
  14784. }
  14785. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14786. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14787. v := m.organization_id
  14788. if v == nil {
  14789. return
  14790. }
  14791. return *v, true
  14792. }
  14793. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14794. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14796. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14797. if !m.op.Is(OpUpdateOne) {
  14798. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14799. }
  14800. if m.id == nil || m.oldValue == nil {
  14801. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14802. }
  14803. oldValue, err := m.oldValue(ctx)
  14804. if err != nil {
  14805. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14806. }
  14807. return oldValue.OrganizationID, nil
  14808. }
  14809. // AddOrganizationID adds u to the "organization_id" field.
  14810. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14811. if m.addorganization_id != nil {
  14812. *m.addorganization_id += u
  14813. } else {
  14814. m.addorganization_id = &u
  14815. }
  14816. }
  14817. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14818. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14819. v := m.addorganization_id
  14820. if v == nil {
  14821. return
  14822. }
  14823. return *v, true
  14824. }
  14825. // ClearOrganizationID clears the value of the "organization_id" field.
  14826. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14827. m.organization_id = nil
  14828. m.addorganization_id = nil
  14829. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14830. }
  14831. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14832. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14833. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14834. return ok
  14835. }
  14836. // ResetOrganizationID resets all changes to the "organization_id" field.
  14837. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14838. m.organization_id = nil
  14839. m.addorganization_id = nil
  14840. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14841. }
  14842. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14843. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14844. m.contacts = &id
  14845. }
  14846. // ClearContacts clears the "contacts" edge to the Contact entity.
  14847. func (m *LabelRelationshipMutation) ClearContacts() {
  14848. m.clearedcontacts = true
  14849. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14850. }
  14851. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14852. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14853. return m.clearedcontacts
  14854. }
  14855. // ContactsID returns the "contacts" edge ID in the mutation.
  14856. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14857. if m.contacts != nil {
  14858. return *m.contacts, true
  14859. }
  14860. return
  14861. }
  14862. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14863. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14864. // ContactsID instead. It exists only for internal usage by the builders.
  14865. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14866. if id := m.contacts; id != nil {
  14867. ids = append(ids, *id)
  14868. }
  14869. return
  14870. }
  14871. // ResetContacts resets all changes to the "contacts" edge.
  14872. func (m *LabelRelationshipMutation) ResetContacts() {
  14873. m.contacts = nil
  14874. m.clearedcontacts = false
  14875. }
  14876. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14877. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14878. m.labels = &id
  14879. }
  14880. // ClearLabels clears the "labels" edge to the Label entity.
  14881. func (m *LabelRelationshipMutation) ClearLabels() {
  14882. m.clearedlabels = true
  14883. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14884. }
  14885. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14886. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14887. return m.clearedlabels
  14888. }
  14889. // LabelsID returns the "labels" edge ID in the mutation.
  14890. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  14891. if m.labels != nil {
  14892. return *m.labels, true
  14893. }
  14894. return
  14895. }
  14896. // LabelsIDs returns the "labels" edge IDs in the mutation.
  14897. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14898. // LabelsID instead. It exists only for internal usage by the builders.
  14899. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  14900. if id := m.labels; id != nil {
  14901. ids = append(ids, *id)
  14902. }
  14903. return
  14904. }
  14905. // ResetLabels resets all changes to the "labels" edge.
  14906. func (m *LabelRelationshipMutation) ResetLabels() {
  14907. m.labels = nil
  14908. m.clearedlabels = false
  14909. }
  14910. // Where appends a list predicates to the LabelRelationshipMutation builder.
  14911. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  14912. m.predicates = append(m.predicates, ps...)
  14913. }
  14914. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  14915. // users can use type-assertion to append predicates that do not depend on any generated package.
  14916. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  14917. p := make([]predicate.LabelRelationship, len(ps))
  14918. for i := range ps {
  14919. p[i] = ps[i]
  14920. }
  14921. m.Where(p...)
  14922. }
  14923. // Op returns the operation name.
  14924. func (m *LabelRelationshipMutation) Op() Op {
  14925. return m.op
  14926. }
  14927. // SetOp allows setting the mutation operation.
  14928. func (m *LabelRelationshipMutation) SetOp(op Op) {
  14929. m.op = op
  14930. }
  14931. // Type returns the node type of this mutation (LabelRelationship).
  14932. func (m *LabelRelationshipMutation) Type() string {
  14933. return m.typ
  14934. }
  14935. // Fields returns all fields that were changed during this mutation. Note that in
  14936. // order to get all numeric fields that were incremented/decremented, call
  14937. // AddedFields().
  14938. func (m *LabelRelationshipMutation) Fields() []string {
  14939. fields := make([]string, 0, 6)
  14940. if m.created_at != nil {
  14941. fields = append(fields, labelrelationship.FieldCreatedAt)
  14942. }
  14943. if m.updated_at != nil {
  14944. fields = append(fields, labelrelationship.FieldUpdatedAt)
  14945. }
  14946. if m.status != nil {
  14947. fields = append(fields, labelrelationship.FieldStatus)
  14948. }
  14949. if m.labels != nil {
  14950. fields = append(fields, labelrelationship.FieldLabelID)
  14951. }
  14952. if m.contacts != nil {
  14953. fields = append(fields, labelrelationship.FieldContactID)
  14954. }
  14955. if m.organization_id != nil {
  14956. fields = append(fields, labelrelationship.FieldOrganizationID)
  14957. }
  14958. return fields
  14959. }
  14960. // Field returns the value of a field with the given name. The second boolean
  14961. // return value indicates that this field was not set, or was not defined in the
  14962. // schema.
  14963. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  14964. switch name {
  14965. case labelrelationship.FieldCreatedAt:
  14966. return m.CreatedAt()
  14967. case labelrelationship.FieldUpdatedAt:
  14968. return m.UpdatedAt()
  14969. case labelrelationship.FieldStatus:
  14970. return m.Status()
  14971. case labelrelationship.FieldLabelID:
  14972. return m.LabelID()
  14973. case labelrelationship.FieldContactID:
  14974. return m.ContactID()
  14975. case labelrelationship.FieldOrganizationID:
  14976. return m.OrganizationID()
  14977. }
  14978. return nil, false
  14979. }
  14980. // OldField returns the old value of the field from the database. An error is
  14981. // returned if the mutation operation is not UpdateOne, or the query to the
  14982. // database failed.
  14983. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14984. switch name {
  14985. case labelrelationship.FieldCreatedAt:
  14986. return m.OldCreatedAt(ctx)
  14987. case labelrelationship.FieldUpdatedAt:
  14988. return m.OldUpdatedAt(ctx)
  14989. case labelrelationship.FieldStatus:
  14990. return m.OldStatus(ctx)
  14991. case labelrelationship.FieldLabelID:
  14992. return m.OldLabelID(ctx)
  14993. case labelrelationship.FieldContactID:
  14994. return m.OldContactID(ctx)
  14995. case labelrelationship.FieldOrganizationID:
  14996. return m.OldOrganizationID(ctx)
  14997. }
  14998. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  14999. }
  15000. // SetField sets the value of a field with the given name. It returns an error if
  15001. // the field is not defined in the schema, or if the type mismatched the field
  15002. // type.
  15003. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15004. switch name {
  15005. case labelrelationship.FieldCreatedAt:
  15006. v, ok := value.(time.Time)
  15007. if !ok {
  15008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15009. }
  15010. m.SetCreatedAt(v)
  15011. return nil
  15012. case labelrelationship.FieldUpdatedAt:
  15013. v, ok := value.(time.Time)
  15014. if !ok {
  15015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15016. }
  15017. m.SetUpdatedAt(v)
  15018. return nil
  15019. case labelrelationship.FieldStatus:
  15020. v, ok := value.(uint8)
  15021. if !ok {
  15022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15023. }
  15024. m.SetStatus(v)
  15025. return nil
  15026. case labelrelationship.FieldLabelID:
  15027. v, ok := value.(uint64)
  15028. if !ok {
  15029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15030. }
  15031. m.SetLabelID(v)
  15032. return nil
  15033. case labelrelationship.FieldContactID:
  15034. v, ok := value.(uint64)
  15035. if !ok {
  15036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15037. }
  15038. m.SetContactID(v)
  15039. return nil
  15040. case labelrelationship.FieldOrganizationID:
  15041. v, ok := value.(uint64)
  15042. if !ok {
  15043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15044. }
  15045. m.SetOrganizationID(v)
  15046. return nil
  15047. }
  15048. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15049. }
  15050. // AddedFields returns all numeric fields that were incremented/decremented during
  15051. // this mutation.
  15052. func (m *LabelRelationshipMutation) AddedFields() []string {
  15053. var fields []string
  15054. if m.addstatus != nil {
  15055. fields = append(fields, labelrelationship.FieldStatus)
  15056. }
  15057. if m.addorganization_id != nil {
  15058. fields = append(fields, labelrelationship.FieldOrganizationID)
  15059. }
  15060. return fields
  15061. }
  15062. // AddedField returns the numeric value that was incremented/decremented on a field
  15063. // with the given name. The second boolean return value indicates that this field
  15064. // was not set, or was not defined in the schema.
  15065. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15066. switch name {
  15067. case labelrelationship.FieldStatus:
  15068. return m.AddedStatus()
  15069. case labelrelationship.FieldOrganizationID:
  15070. return m.AddedOrganizationID()
  15071. }
  15072. return nil, false
  15073. }
  15074. // AddField adds the value to the field with the given name. It returns an error if
  15075. // the field is not defined in the schema, or if the type mismatched the field
  15076. // type.
  15077. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15078. switch name {
  15079. case labelrelationship.FieldStatus:
  15080. v, ok := value.(int8)
  15081. if !ok {
  15082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15083. }
  15084. m.AddStatus(v)
  15085. return nil
  15086. case labelrelationship.FieldOrganizationID:
  15087. v, ok := value.(int64)
  15088. if !ok {
  15089. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15090. }
  15091. m.AddOrganizationID(v)
  15092. return nil
  15093. }
  15094. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15095. }
  15096. // ClearedFields returns all nullable fields that were cleared during this
  15097. // mutation.
  15098. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15099. var fields []string
  15100. if m.FieldCleared(labelrelationship.FieldStatus) {
  15101. fields = append(fields, labelrelationship.FieldStatus)
  15102. }
  15103. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15104. fields = append(fields, labelrelationship.FieldOrganizationID)
  15105. }
  15106. return fields
  15107. }
  15108. // FieldCleared returns a boolean indicating if a field with the given name was
  15109. // cleared in this mutation.
  15110. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15111. _, ok := m.clearedFields[name]
  15112. return ok
  15113. }
  15114. // ClearField clears the value of the field with the given name. It returns an
  15115. // error if the field is not defined in the schema.
  15116. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15117. switch name {
  15118. case labelrelationship.FieldStatus:
  15119. m.ClearStatus()
  15120. return nil
  15121. case labelrelationship.FieldOrganizationID:
  15122. m.ClearOrganizationID()
  15123. return nil
  15124. }
  15125. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15126. }
  15127. // ResetField resets all changes in the mutation for the field with the given name.
  15128. // It returns an error if the field is not defined in the schema.
  15129. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15130. switch name {
  15131. case labelrelationship.FieldCreatedAt:
  15132. m.ResetCreatedAt()
  15133. return nil
  15134. case labelrelationship.FieldUpdatedAt:
  15135. m.ResetUpdatedAt()
  15136. return nil
  15137. case labelrelationship.FieldStatus:
  15138. m.ResetStatus()
  15139. return nil
  15140. case labelrelationship.FieldLabelID:
  15141. m.ResetLabelID()
  15142. return nil
  15143. case labelrelationship.FieldContactID:
  15144. m.ResetContactID()
  15145. return nil
  15146. case labelrelationship.FieldOrganizationID:
  15147. m.ResetOrganizationID()
  15148. return nil
  15149. }
  15150. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15151. }
  15152. // AddedEdges returns all edge names that were set/added in this mutation.
  15153. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15154. edges := make([]string, 0, 2)
  15155. if m.contacts != nil {
  15156. edges = append(edges, labelrelationship.EdgeContacts)
  15157. }
  15158. if m.labels != nil {
  15159. edges = append(edges, labelrelationship.EdgeLabels)
  15160. }
  15161. return edges
  15162. }
  15163. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15164. // name in this mutation.
  15165. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15166. switch name {
  15167. case labelrelationship.EdgeContacts:
  15168. if id := m.contacts; id != nil {
  15169. return []ent.Value{*id}
  15170. }
  15171. case labelrelationship.EdgeLabels:
  15172. if id := m.labels; id != nil {
  15173. return []ent.Value{*id}
  15174. }
  15175. }
  15176. return nil
  15177. }
  15178. // RemovedEdges returns all edge names that were removed in this mutation.
  15179. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15180. edges := make([]string, 0, 2)
  15181. return edges
  15182. }
  15183. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15184. // the given name in this mutation.
  15185. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15186. return nil
  15187. }
  15188. // ClearedEdges returns all edge names that were cleared in this mutation.
  15189. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15190. edges := make([]string, 0, 2)
  15191. if m.clearedcontacts {
  15192. edges = append(edges, labelrelationship.EdgeContacts)
  15193. }
  15194. if m.clearedlabels {
  15195. edges = append(edges, labelrelationship.EdgeLabels)
  15196. }
  15197. return edges
  15198. }
  15199. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15200. // was cleared in this mutation.
  15201. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15202. switch name {
  15203. case labelrelationship.EdgeContacts:
  15204. return m.clearedcontacts
  15205. case labelrelationship.EdgeLabels:
  15206. return m.clearedlabels
  15207. }
  15208. return false
  15209. }
  15210. // ClearEdge clears the value of the edge with the given name. It returns an error
  15211. // if that edge is not defined in the schema.
  15212. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15213. switch name {
  15214. case labelrelationship.EdgeContacts:
  15215. m.ClearContacts()
  15216. return nil
  15217. case labelrelationship.EdgeLabels:
  15218. m.ClearLabels()
  15219. return nil
  15220. }
  15221. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15222. }
  15223. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15224. // It returns an error if the edge is not defined in the schema.
  15225. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15226. switch name {
  15227. case labelrelationship.EdgeContacts:
  15228. m.ResetContacts()
  15229. return nil
  15230. case labelrelationship.EdgeLabels:
  15231. m.ResetLabels()
  15232. return nil
  15233. }
  15234. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15235. }
  15236. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15237. type LabelTaggingMutation struct {
  15238. config
  15239. op Op
  15240. typ string
  15241. id *uint64
  15242. created_at *time.Time
  15243. updated_at *time.Time
  15244. status *uint8
  15245. addstatus *int8
  15246. deleted_at *time.Time
  15247. organization_id *uint64
  15248. addorganization_id *int64
  15249. _type *int
  15250. add_type *int
  15251. conditions *string
  15252. action_label_add *[]uint64
  15253. appendaction_label_add []uint64
  15254. action_label_del *[]uint64
  15255. appendaction_label_del []uint64
  15256. clearedFields map[string]struct{}
  15257. done bool
  15258. oldValue func(context.Context) (*LabelTagging, error)
  15259. predicates []predicate.LabelTagging
  15260. }
  15261. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15262. // labeltaggingOption allows management of the mutation configuration using functional options.
  15263. type labeltaggingOption func(*LabelTaggingMutation)
  15264. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15265. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15266. m := &LabelTaggingMutation{
  15267. config: c,
  15268. op: op,
  15269. typ: TypeLabelTagging,
  15270. clearedFields: make(map[string]struct{}),
  15271. }
  15272. for _, opt := range opts {
  15273. opt(m)
  15274. }
  15275. return m
  15276. }
  15277. // withLabelTaggingID sets the ID field of the mutation.
  15278. func withLabelTaggingID(id uint64) labeltaggingOption {
  15279. return func(m *LabelTaggingMutation) {
  15280. var (
  15281. err error
  15282. once sync.Once
  15283. value *LabelTagging
  15284. )
  15285. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15286. once.Do(func() {
  15287. if m.done {
  15288. err = errors.New("querying old values post mutation is not allowed")
  15289. } else {
  15290. value, err = m.Client().LabelTagging.Get(ctx, id)
  15291. }
  15292. })
  15293. return value, err
  15294. }
  15295. m.id = &id
  15296. }
  15297. }
  15298. // withLabelTagging sets the old LabelTagging of the mutation.
  15299. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15300. return func(m *LabelTaggingMutation) {
  15301. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15302. return node, nil
  15303. }
  15304. m.id = &node.ID
  15305. }
  15306. }
  15307. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15308. // executed in a transaction (ent.Tx), a transactional client is returned.
  15309. func (m LabelTaggingMutation) Client() *Client {
  15310. client := &Client{config: m.config}
  15311. client.init()
  15312. return client
  15313. }
  15314. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15315. // it returns an error otherwise.
  15316. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15317. if _, ok := m.driver.(*txDriver); !ok {
  15318. return nil, errors.New("ent: mutation is not running in a transaction")
  15319. }
  15320. tx := &Tx{config: m.config}
  15321. tx.init()
  15322. return tx, nil
  15323. }
  15324. // SetID sets the value of the id field. Note that this
  15325. // operation is only accepted on creation of LabelTagging entities.
  15326. func (m *LabelTaggingMutation) SetID(id uint64) {
  15327. m.id = &id
  15328. }
  15329. // ID returns the ID value in the mutation. Note that the ID is only available
  15330. // if it was provided to the builder or after it was returned from the database.
  15331. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15332. if m.id == nil {
  15333. return
  15334. }
  15335. return *m.id, true
  15336. }
  15337. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15338. // That means, if the mutation is applied within a transaction with an isolation level such
  15339. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15340. // or updated by the mutation.
  15341. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15342. switch {
  15343. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15344. id, exists := m.ID()
  15345. if exists {
  15346. return []uint64{id}, nil
  15347. }
  15348. fallthrough
  15349. case m.op.Is(OpUpdate | OpDelete):
  15350. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15351. default:
  15352. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15353. }
  15354. }
  15355. // SetCreatedAt sets the "created_at" field.
  15356. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15357. m.created_at = &t
  15358. }
  15359. // CreatedAt returns the value of the "created_at" field in the mutation.
  15360. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15361. v := m.created_at
  15362. if v == nil {
  15363. return
  15364. }
  15365. return *v, true
  15366. }
  15367. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15368. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15370. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15371. if !m.op.Is(OpUpdateOne) {
  15372. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15373. }
  15374. if m.id == nil || m.oldValue == nil {
  15375. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15376. }
  15377. oldValue, err := m.oldValue(ctx)
  15378. if err != nil {
  15379. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15380. }
  15381. return oldValue.CreatedAt, nil
  15382. }
  15383. // ResetCreatedAt resets all changes to the "created_at" field.
  15384. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15385. m.created_at = nil
  15386. }
  15387. // SetUpdatedAt sets the "updated_at" field.
  15388. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15389. m.updated_at = &t
  15390. }
  15391. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15392. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15393. v := m.updated_at
  15394. if v == nil {
  15395. return
  15396. }
  15397. return *v, true
  15398. }
  15399. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15400. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15402. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15403. if !m.op.Is(OpUpdateOne) {
  15404. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15405. }
  15406. if m.id == nil || m.oldValue == nil {
  15407. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15408. }
  15409. oldValue, err := m.oldValue(ctx)
  15410. if err != nil {
  15411. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15412. }
  15413. return oldValue.UpdatedAt, nil
  15414. }
  15415. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15416. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15417. m.updated_at = nil
  15418. }
  15419. // SetStatus sets the "status" field.
  15420. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15421. m.status = &u
  15422. m.addstatus = nil
  15423. }
  15424. // Status returns the value of the "status" field in the mutation.
  15425. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15426. v := m.status
  15427. if v == nil {
  15428. return
  15429. }
  15430. return *v, true
  15431. }
  15432. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15433. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15435. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15436. if !m.op.Is(OpUpdateOne) {
  15437. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15438. }
  15439. if m.id == nil || m.oldValue == nil {
  15440. return v, errors.New("OldStatus requires an ID field in the mutation")
  15441. }
  15442. oldValue, err := m.oldValue(ctx)
  15443. if err != nil {
  15444. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15445. }
  15446. return oldValue.Status, nil
  15447. }
  15448. // AddStatus adds u to the "status" field.
  15449. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15450. if m.addstatus != nil {
  15451. *m.addstatus += u
  15452. } else {
  15453. m.addstatus = &u
  15454. }
  15455. }
  15456. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15457. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15458. v := m.addstatus
  15459. if v == nil {
  15460. return
  15461. }
  15462. return *v, true
  15463. }
  15464. // ClearStatus clears the value of the "status" field.
  15465. func (m *LabelTaggingMutation) ClearStatus() {
  15466. m.status = nil
  15467. m.addstatus = nil
  15468. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15469. }
  15470. // StatusCleared returns if the "status" field was cleared in this mutation.
  15471. func (m *LabelTaggingMutation) StatusCleared() bool {
  15472. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15473. return ok
  15474. }
  15475. // ResetStatus resets all changes to the "status" field.
  15476. func (m *LabelTaggingMutation) ResetStatus() {
  15477. m.status = nil
  15478. m.addstatus = nil
  15479. delete(m.clearedFields, labeltagging.FieldStatus)
  15480. }
  15481. // SetDeletedAt sets the "deleted_at" field.
  15482. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15483. m.deleted_at = &t
  15484. }
  15485. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15486. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15487. v := m.deleted_at
  15488. if v == nil {
  15489. return
  15490. }
  15491. return *v, true
  15492. }
  15493. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15494. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15496. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15497. if !m.op.Is(OpUpdateOne) {
  15498. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15499. }
  15500. if m.id == nil || m.oldValue == nil {
  15501. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15502. }
  15503. oldValue, err := m.oldValue(ctx)
  15504. if err != nil {
  15505. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15506. }
  15507. return oldValue.DeletedAt, nil
  15508. }
  15509. // ClearDeletedAt clears the value of the "deleted_at" field.
  15510. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15511. m.deleted_at = nil
  15512. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15513. }
  15514. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15515. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15516. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15517. return ok
  15518. }
  15519. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15520. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15521. m.deleted_at = nil
  15522. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15523. }
  15524. // SetOrganizationID sets the "organization_id" field.
  15525. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15526. m.organization_id = &u
  15527. m.addorganization_id = nil
  15528. }
  15529. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15530. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15531. v := m.organization_id
  15532. if v == nil {
  15533. return
  15534. }
  15535. return *v, true
  15536. }
  15537. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15538. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15540. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15541. if !m.op.Is(OpUpdateOne) {
  15542. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15543. }
  15544. if m.id == nil || m.oldValue == nil {
  15545. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15546. }
  15547. oldValue, err := m.oldValue(ctx)
  15548. if err != nil {
  15549. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15550. }
  15551. return oldValue.OrganizationID, nil
  15552. }
  15553. // AddOrganizationID adds u to the "organization_id" field.
  15554. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15555. if m.addorganization_id != nil {
  15556. *m.addorganization_id += u
  15557. } else {
  15558. m.addorganization_id = &u
  15559. }
  15560. }
  15561. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15562. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15563. v := m.addorganization_id
  15564. if v == nil {
  15565. return
  15566. }
  15567. return *v, true
  15568. }
  15569. // ResetOrganizationID resets all changes to the "organization_id" field.
  15570. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15571. m.organization_id = nil
  15572. m.addorganization_id = nil
  15573. }
  15574. // SetType sets the "type" field.
  15575. func (m *LabelTaggingMutation) SetType(i int) {
  15576. m._type = &i
  15577. m.add_type = nil
  15578. }
  15579. // GetType returns the value of the "type" field in the mutation.
  15580. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15581. v := m._type
  15582. if v == nil {
  15583. return
  15584. }
  15585. return *v, true
  15586. }
  15587. // OldType returns the old "type" field's value of the LabelTagging entity.
  15588. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15590. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15591. if !m.op.Is(OpUpdateOne) {
  15592. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15593. }
  15594. if m.id == nil || m.oldValue == nil {
  15595. return v, errors.New("OldType requires an ID field in the mutation")
  15596. }
  15597. oldValue, err := m.oldValue(ctx)
  15598. if err != nil {
  15599. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15600. }
  15601. return oldValue.Type, nil
  15602. }
  15603. // AddType adds i to the "type" field.
  15604. func (m *LabelTaggingMutation) AddType(i int) {
  15605. if m.add_type != nil {
  15606. *m.add_type += i
  15607. } else {
  15608. m.add_type = &i
  15609. }
  15610. }
  15611. // AddedType returns the value that was added to the "type" field in this mutation.
  15612. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15613. v := m.add_type
  15614. if v == nil {
  15615. return
  15616. }
  15617. return *v, true
  15618. }
  15619. // ResetType resets all changes to the "type" field.
  15620. func (m *LabelTaggingMutation) ResetType() {
  15621. m._type = nil
  15622. m.add_type = nil
  15623. }
  15624. // SetConditions sets the "conditions" field.
  15625. func (m *LabelTaggingMutation) SetConditions(s string) {
  15626. m.conditions = &s
  15627. }
  15628. // Conditions returns the value of the "conditions" field in the mutation.
  15629. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15630. v := m.conditions
  15631. if v == nil {
  15632. return
  15633. }
  15634. return *v, true
  15635. }
  15636. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15637. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15638. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15639. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15640. if !m.op.Is(OpUpdateOne) {
  15641. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15642. }
  15643. if m.id == nil || m.oldValue == nil {
  15644. return v, errors.New("OldConditions requires an ID field in the mutation")
  15645. }
  15646. oldValue, err := m.oldValue(ctx)
  15647. if err != nil {
  15648. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15649. }
  15650. return oldValue.Conditions, nil
  15651. }
  15652. // ResetConditions resets all changes to the "conditions" field.
  15653. func (m *LabelTaggingMutation) ResetConditions() {
  15654. m.conditions = nil
  15655. }
  15656. // SetActionLabelAdd sets the "action_label_add" field.
  15657. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15658. m.action_label_add = &u
  15659. m.appendaction_label_add = nil
  15660. }
  15661. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15662. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15663. v := m.action_label_add
  15664. if v == nil {
  15665. return
  15666. }
  15667. return *v, true
  15668. }
  15669. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15670. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15671. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15672. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15673. if !m.op.Is(OpUpdateOne) {
  15674. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15675. }
  15676. if m.id == nil || m.oldValue == nil {
  15677. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15678. }
  15679. oldValue, err := m.oldValue(ctx)
  15680. if err != nil {
  15681. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15682. }
  15683. return oldValue.ActionLabelAdd, nil
  15684. }
  15685. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15686. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15687. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15688. }
  15689. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15690. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15691. if len(m.appendaction_label_add) == 0 {
  15692. return nil, false
  15693. }
  15694. return m.appendaction_label_add, true
  15695. }
  15696. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15697. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15698. m.action_label_add = nil
  15699. m.appendaction_label_add = nil
  15700. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15701. }
  15702. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15703. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15704. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15705. return ok
  15706. }
  15707. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15708. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15709. m.action_label_add = nil
  15710. m.appendaction_label_add = nil
  15711. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15712. }
  15713. // SetActionLabelDel sets the "action_label_del" field.
  15714. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15715. m.action_label_del = &u
  15716. m.appendaction_label_del = nil
  15717. }
  15718. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15719. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15720. v := m.action_label_del
  15721. if v == nil {
  15722. return
  15723. }
  15724. return *v, true
  15725. }
  15726. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15727. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15729. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15730. if !m.op.Is(OpUpdateOne) {
  15731. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15732. }
  15733. if m.id == nil || m.oldValue == nil {
  15734. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15735. }
  15736. oldValue, err := m.oldValue(ctx)
  15737. if err != nil {
  15738. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15739. }
  15740. return oldValue.ActionLabelDel, nil
  15741. }
  15742. // AppendActionLabelDel adds u to the "action_label_del" field.
  15743. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15744. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15745. }
  15746. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15747. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15748. if len(m.appendaction_label_del) == 0 {
  15749. return nil, false
  15750. }
  15751. return m.appendaction_label_del, true
  15752. }
  15753. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15754. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15755. m.action_label_del = nil
  15756. m.appendaction_label_del = nil
  15757. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15758. }
  15759. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15760. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15761. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15762. return ok
  15763. }
  15764. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15765. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15766. m.action_label_del = nil
  15767. m.appendaction_label_del = nil
  15768. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15769. }
  15770. // Where appends a list predicates to the LabelTaggingMutation builder.
  15771. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15772. m.predicates = append(m.predicates, ps...)
  15773. }
  15774. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15775. // users can use type-assertion to append predicates that do not depend on any generated package.
  15776. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15777. p := make([]predicate.LabelTagging, len(ps))
  15778. for i := range ps {
  15779. p[i] = ps[i]
  15780. }
  15781. m.Where(p...)
  15782. }
  15783. // Op returns the operation name.
  15784. func (m *LabelTaggingMutation) Op() Op {
  15785. return m.op
  15786. }
  15787. // SetOp allows setting the mutation operation.
  15788. func (m *LabelTaggingMutation) SetOp(op Op) {
  15789. m.op = op
  15790. }
  15791. // Type returns the node type of this mutation (LabelTagging).
  15792. func (m *LabelTaggingMutation) Type() string {
  15793. return m.typ
  15794. }
  15795. // Fields returns all fields that were changed during this mutation. Note that in
  15796. // order to get all numeric fields that were incremented/decremented, call
  15797. // AddedFields().
  15798. func (m *LabelTaggingMutation) Fields() []string {
  15799. fields := make([]string, 0, 9)
  15800. if m.created_at != nil {
  15801. fields = append(fields, labeltagging.FieldCreatedAt)
  15802. }
  15803. if m.updated_at != nil {
  15804. fields = append(fields, labeltagging.FieldUpdatedAt)
  15805. }
  15806. if m.status != nil {
  15807. fields = append(fields, labeltagging.FieldStatus)
  15808. }
  15809. if m.deleted_at != nil {
  15810. fields = append(fields, labeltagging.FieldDeletedAt)
  15811. }
  15812. if m.organization_id != nil {
  15813. fields = append(fields, labeltagging.FieldOrganizationID)
  15814. }
  15815. if m._type != nil {
  15816. fields = append(fields, labeltagging.FieldType)
  15817. }
  15818. if m.conditions != nil {
  15819. fields = append(fields, labeltagging.FieldConditions)
  15820. }
  15821. if m.action_label_add != nil {
  15822. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15823. }
  15824. if m.action_label_del != nil {
  15825. fields = append(fields, labeltagging.FieldActionLabelDel)
  15826. }
  15827. return fields
  15828. }
  15829. // Field returns the value of a field with the given name. The second boolean
  15830. // return value indicates that this field was not set, or was not defined in the
  15831. // schema.
  15832. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15833. switch name {
  15834. case labeltagging.FieldCreatedAt:
  15835. return m.CreatedAt()
  15836. case labeltagging.FieldUpdatedAt:
  15837. return m.UpdatedAt()
  15838. case labeltagging.FieldStatus:
  15839. return m.Status()
  15840. case labeltagging.FieldDeletedAt:
  15841. return m.DeletedAt()
  15842. case labeltagging.FieldOrganizationID:
  15843. return m.OrganizationID()
  15844. case labeltagging.FieldType:
  15845. return m.GetType()
  15846. case labeltagging.FieldConditions:
  15847. return m.Conditions()
  15848. case labeltagging.FieldActionLabelAdd:
  15849. return m.ActionLabelAdd()
  15850. case labeltagging.FieldActionLabelDel:
  15851. return m.ActionLabelDel()
  15852. }
  15853. return nil, false
  15854. }
  15855. // OldField returns the old value of the field from the database. An error is
  15856. // returned if the mutation operation is not UpdateOne, or the query to the
  15857. // database failed.
  15858. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15859. switch name {
  15860. case labeltagging.FieldCreatedAt:
  15861. return m.OldCreatedAt(ctx)
  15862. case labeltagging.FieldUpdatedAt:
  15863. return m.OldUpdatedAt(ctx)
  15864. case labeltagging.FieldStatus:
  15865. return m.OldStatus(ctx)
  15866. case labeltagging.FieldDeletedAt:
  15867. return m.OldDeletedAt(ctx)
  15868. case labeltagging.FieldOrganizationID:
  15869. return m.OldOrganizationID(ctx)
  15870. case labeltagging.FieldType:
  15871. return m.OldType(ctx)
  15872. case labeltagging.FieldConditions:
  15873. return m.OldConditions(ctx)
  15874. case labeltagging.FieldActionLabelAdd:
  15875. return m.OldActionLabelAdd(ctx)
  15876. case labeltagging.FieldActionLabelDel:
  15877. return m.OldActionLabelDel(ctx)
  15878. }
  15879. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15880. }
  15881. // SetField sets the value of a field with the given name. It returns an error if
  15882. // the field is not defined in the schema, or if the type mismatched the field
  15883. // type.
  15884. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15885. switch name {
  15886. case labeltagging.FieldCreatedAt:
  15887. v, ok := value.(time.Time)
  15888. if !ok {
  15889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15890. }
  15891. m.SetCreatedAt(v)
  15892. return nil
  15893. case labeltagging.FieldUpdatedAt:
  15894. v, ok := value.(time.Time)
  15895. if !ok {
  15896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15897. }
  15898. m.SetUpdatedAt(v)
  15899. return nil
  15900. case labeltagging.FieldStatus:
  15901. v, ok := value.(uint8)
  15902. if !ok {
  15903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15904. }
  15905. m.SetStatus(v)
  15906. return nil
  15907. case labeltagging.FieldDeletedAt:
  15908. v, ok := value.(time.Time)
  15909. if !ok {
  15910. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15911. }
  15912. m.SetDeletedAt(v)
  15913. return nil
  15914. case labeltagging.FieldOrganizationID:
  15915. v, ok := value.(uint64)
  15916. if !ok {
  15917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15918. }
  15919. m.SetOrganizationID(v)
  15920. return nil
  15921. case labeltagging.FieldType:
  15922. v, ok := value.(int)
  15923. if !ok {
  15924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15925. }
  15926. m.SetType(v)
  15927. return nil
  15928. case labeltagging.FieldConditions:
  15929. v, ok := value.(string)
  15930. if !ok {
  15931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15932. }
  15933. m.SetConditions(v)
  15934. return nil
  15935. case labeltagging.FieldActionLabelAdd:
  15936. v, ok := value.([]uint64)
  15937. if !ok {
  15938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15939. }
  15940. m.SetActionLabelAdd(v)
  15941. return nil
  15942. case labeltagging.FieldActionLabelDel:
  15943. v, ok := value.([]uint64)
  15944. if !ok {
  15945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15946. }
  15947. m.SetActionLabelDel(v)
  15948. return nil
  15949. }
  15950. return fmt.Errorf("unknown LabelTagging field %s", name)
  15951. }
  15952. // AddedFields returns all numeric fields that were incremented/decremented during
  15953. // this mutation.
  15954. func (m *LabelTaggingMutation) AddedFields() []string {
  15955. var fields []string
  15956. if m.addstatus != nil {
  15957. fields = append(fields, labeltagging.FieldStatus)
  15958. }
  15959. if m.addorganization_id != nil {
  15960. fields = append(fields, labeltagging.FieldOrganizationID)
  15961. }
  15962. if m.add_type != nil {
  15963. fields = append(fields, labeltagging.FieldType)
  15964. }
  15965. return fields
  15966. }
  15967. // AddedField returns the numeric value that was incremented/decremented on a field
  15968. // with the given name. The second boolean return value indicates that this field
  15969. // was not set, or was not defined in the schema.
  15970. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  15971. switch name {
  15972. case labeltagging.FieldStatus:
  15973. return m.AddedStatus()
  15974. case labeltagging.FieldOrganizationID:
  15975. return m.AddedOrganizationID()
  15976. case labeltagging.FieldType:
  15977. return m.AddedType()
  15978. }
  15979. return nil, false
  15980. }
  15981. // AddField adds the value to the field with the given name. It returns an error if
  15982. // the field is not defined in the schema, or if the type mismatched the field
  15983. // type.
  15984. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  15985. switch name {
  15986. case labeltagging.FieldStatus:
  15987. v, ok := value.(int8)
  15988. if !ok {
  15989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15990. }
  15991. m.AddStatus(v)
  15992. return nil
  15993. case labeltagging.FieldOrganizationID:
  15994. v, ok := value.(int64)
  15995. if !ok {
  15996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15997. }
  15998. m.AddOrganizationID(v)
  15999. return nil
  16000. case labeltagging.FieldType:
  16001. v, ok := value.(int)
  16002. if !ok {
  16003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16004. }
  16005. m.AddType(v)
  16006. return nil
  16007. }
  16008. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16009. }
  16010. // ClearedFields returns all nullable fields that were cleared during this
  16011. // mutation.
  16012. func (m *LabelTaggingMutation) ClearedFields() []string {
  16013. var fields []string
  16014. if m.FieldCleared(labeltagging.FieldStatus) {
  16015. fields = append(fields, labeltagging.FieldStatus)
  16016. }
  16017. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16018. fields = append(fields, labeltagging.FieldDeletedAt)
  16019. }
  16020. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16021. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16022. }
  16023. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16024. fields = append(fields, labeltagging.FieldActionLabelDel)
  16025. }
  16026. return fields
  16027. }
  16028. // FieldCleared returns a boolean indicating if a field with the given name was
  16029. // cleared in this mutation.
  16030. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16031. _, ok := m.clearedFields[name]
  16032. return ok
  16033. }
  16034. // ClearField clears the value of the field with the given name. It returns an
  16035. // error if the field is not defined in the schema.
  16036. func (m *LabelTaggingMutation) ClearField(name string) error {
  16037. switch name {
  16038. case labeltagging.FieldStatus:
  16039. m.ClearStatus()
  16040. return nil
  16041. case labeltagging.FieldDeletedAt:
  16042. m.ClearDeletedAt()
  16043. return nil
  16044. case labeltagging.FieldActionLabelAdd:
  16045. m.ClearActionLabelAdd()
  16046. return nil
  16047. case labeltagging.FieldActionLabelDel:
  16048. m.ClearActionLabelDel()
  16049. return nil
  16050. }
  16051. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16052. }
  16053. // ResetField resets all changes in the mutation for the field with the given name.
  16054. // It returns an error if the field is not defined in the schema.
  16055. func (m *LabelTaggingMutation) ResetField(name string) error {
  16056. switch name {
  16057. case labeltagging.FieldCreatedAt:
  16058. m.ResetCreatedAt()
  16059. return nil
  16060. case labeltagging.FieldUpdatedAt:
  16061. m.ResetUpdatedAt()
  16062. return nil
  16063. case labeltagging.FieldStatus:
  16064. m.ResetStatus()
  16065. return nil
  16066. case labeltagging.FieldDeletedAt:
  16067. m.ResetDeletedAt()
  16068. return nil
  16069. case labeltagging.FieldOrganizationID:
  16070. m.ResetOrganizationID()
  16071. return nil
  16072. case labeltagging.FieldType:
  16073. m.ResetType()
  16074. return nil
  16075. case labeltagging.FieldConditions:
  16076. m.ResetConditions()
  16077. return nil
  16078. case labeltagging.FieldActionLabelAdd:
  16079. m.ResetActionLabelAdd()
  16080. return nil
  16081. case labeltagging.FieldActionLabelDel:
  16082. m.ResetActionLabelDel()
  16083. return nil
  16084. }
  16085. return fmt.Errorf("unknown LabelTagging field %s", name)
  16086. }
  16087. // AddedEdges returns all edge names that were set/added in this mutation.
  16088. func (m *LabelTaggingMutation) AddedEdges() []string {
  16089. edges := make([]string, 0, 0)
  16090. return edges
  16091. }
  16092. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16093. // name in this mutation.
  16094. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16095. return nil
  16096. }
  16097. // RemovedEdges returns all edge names that were removed in this mutation.
  16098. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16099. edges := make([]string, 0, 0)
  16100. return edges
  16101. }
  16102. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16103. // the given name in this mutation.
  16104. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16105. return nil
  16106. }
  16107. // ClearedEdges returns all edge names that were cleared in this mutation.
  16108. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16109. edges := make([]string, 0, 0)
  16110. return edges
  16111. }
  16112. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16113. // was cleared in this mutation.
  16114. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16115. return false
  16116. }
  16117. // ClearEdge clears the value of the edge with the given name. It returns an error
  16118. // if that edge is not defined in the schema.
  16119. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16120. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16121. }
  16122. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16123. // It returns an error if the edge is not defined in the schema.
  16124. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16125. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16126. }
  16127. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16128. type MessageMutation struct {
  16129. config
  16130. op Op
  16131. typ string
  16132. id *int
  16133. wx_wxid *string
  16134. wxid *string
  16135. content *string
  16136. clearedFields map[string]struct{}
  16137. done bool
  16138. oldValue func(context.Context) (*Message, error)
  16139. predicates []predicate.Message
  16140. }
  16141. var _ ent.Mutation = (*MessageMutation)(nil)
  16142. // messageOption allows management of the mutation configuration using functional options.
  16143. type messageOption func(*MessageMutation)
  16144. // newMessageMutation creates new mutation for the Message entity.
  16145. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16146. m := &MessageMutation{
  16147. config: c,
  16148. op: op,
  16149. typ: TypeMessage,
  16150. clearedFields: make(map[string]struct{}),
  16151. }
  16152. for _, opt := range opts {
  16153. opt(m)
  16154. }
  16155. return m
  16156. }
  16157. // withMessageID sets the ID field of the mutation.
  16158. func withMessageID(id int) messageOption {
  16159. return func(m *MessageMutation) {
  16160. var (
  16161. err error
  16162. once sync.Once
  16163. value *Message
  16164. )
  16165. m.oldValue = func(ctx context.Context) (*Message, error) {
  16166. once.Do(func() {
  16167. if m.done {
  16168. err = errors.New("querying old values post mutation is not allowed")
  16169. } else {
  16170. value, err = m.Client().Message.Get(ctx, id)
  16171. }
  16172. })
  16173. return value, err
  16174. }
  16175. m.id = &id
  16176. }
  16177. }
  16178. // withMessage sets the old Message of the mutation.
  16179. func withMessage(node *Message) messageOption {
  16180. return func(m *MessageMutation) {
  16181. m.oldValue = func(context.Context) (*Message, error) {
  16182. return node, nil
  16183. }
  16184. m.id = &node.ID
  16185. }
  16186. }
  16187. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16188. // executed in a transaction (ent.Tx), a transactional client is returned.
  16189. func (m MessageMutation) Client() *Client {
  16190. client := &Client{config: m.config}
  16191. client.init()
  16192. return client
  16193. }
  16194. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16195. // it returns an error otherwise.
  16196. func (m MessageMutation) Tx() (*Tx, error) {
  16197. if _, ok := m.driver.(*txDriver); !ok {
  16198. return nil, errors.New("ent: mutation is not running in a transaction")
  16199. }
  16200. tx := &Tx{config: m.config}
  16201. tx.init()
  16202. return tx, nil
  16203. }
  16204. // ID returns the ID value in the mutation. Note that the ID is only available
  16205. // if it was provided to the builder or after it was returned from the database.
  16206. func (m *MessageMutation) ID() (id int, exists bool) {
  16207. if m.id == nil {
  16208. return
  16209. }
  16210. return *m.id, true
  16211. }
  16212. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16213. // That means, if the mutation is applied within a transaction with an isolation level such
  16214. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16215. // or updated by the mutation.
  16216. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16217. switch {
  16218. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16219. id, exists := m.ID()
  16220. if exists {
  16221. return []int{id}, nil
  16222. }
  16223. fallthrough
  16224. case m.op.Is(OpUpdate | OpDelete):
  16225. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16226. default:
  16227. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16228. }
  16229. }
  16230. // SetWxWxid sets the "wx_wxid" field.
  16231. func (m *MessageMutation) SetWxWxid(s string) {
  16232. m.wx_wxid = &s
  16233. }
  16234. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16235. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16236. v := m.wx_wxid
  16237. if v == nil {
  16238. return
  16239. }
  16240. return *v, true
  16241. }
  16242. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16243. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16244. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16245. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16246. if !m.op.Is(OpUpdateOne) {
  16247. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16248. }
  16249. if m.id == nil || m.oldValue == nil {
  16250. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16251. }
  16252. oldValue, err := m.oldValue(ctx)
  16253. if err != nil {
  16254. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16255. }
  16256. return oldValue.WxWxid, nil
  16257. }
  16258. // ClearWxWxid clears the value of the "wx_wxid" field.
  16259. func (m *MessageMutation) ClearWxWxid() {
  16260. m.wx_wxid = nil
  16261. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16262. }
  16263. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16264. func (m *MessageMutation) WxWxidCleared() bool {
  16265. _, ok := m.clearedFields[message.FieldWxWxid]
  16266. return ok
  16267. }
  16268. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16269. func (m *MessageMutation) ResetWxWxid() {
  16270. m.wx_wxid = nil
  16271. delete(m.clearedFields, message.FieldWxWxid)
  16272. }
  16273. // SetWxid sets the "wxid" field.
  16274. func (m *MessageMutation) SetWxid(s string) {
  16275. m.wxid = &s
  16276. }
  16277. // Wxid returns the value of the "wxid" field in the mutation.
  16278. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16279. v := m.wxid
  16280. if v == nil {
  16281. return
  16282. }
  16283. return *v, true
  16284. }
  16285. // OldWxid returns the old "wxid" field's value of the Message entity.
  16286. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16287. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16288. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16289. if !m.op.Is(OpUpdateOne) {
  16290. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16291. }
  16292. if m.id == nil || m.oldValue == nil {
  16293. return v, errors.New("OldWxid requires an ID field in the mutation")
  16294. }
  16295. oldValue, err := m.oldValue(ctx)
  16296. if err != nil {
  16297. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16298. }
  16299. return oldValue.Wxid, nil
  16300. }
  16301. // ResetWxid resets all changes to the "wxid" field.
  16302. func (m *MessageMutation) ResetWxid() {
  16303. m.wxid = nil
  16304. }
  16305. // SetContent sets the "content" field.
  16306. func (m *MessageMutation) SetContent(s string) {
  16307. m.content = &s
  16308. }
  16309. // Content returns the value of the "content" field in the mutation.
  16310. func (m *MessageMutation) Content() (r string, exists bool) {
  16311. v := m.content
  16312. if v == nil {
  16313. return
  16314. }
  16315. return *v, true
  16316. }
  16317. // OldContent returns the old "content" field's value of the Message entity.
  16318. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16320. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16321. if !m.op.Is(OpUpdateOne) {
  16322. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16323. }
  16324. if m.id == nil || m.oldValue == nil {
  16325. return v, errors.New("OldContent requires an ID field in the mutation")
  16326. }
  16327. oldValue, err := m.oldValue(ctx)
  16328. if err != nil {
  16329. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16330. }
  16331. return oldValue.Content, nil
  16332. }
  16333. // ResetContent resets all changes to the "content" field.
  16334. func (m *MessageMutation) ResetContent() {
  16335. m.content = nil
  16336. }
  16337. // Where appends a list predicates to the MessageMutation builder.
  16338. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16339. m.predicates = append(m.predicates, ps...)
  16340. }
  16341. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16342. // users can use type-assertion to append predicates that do not depend on any generated package.
  16343. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16344. p := make([]predicate.Message, len(ps))
  16345. for i := range ps {
  16346. p[i] = ps[i]
  16347. }
  16348. m.Where(p...)
  16349. }
  16350. // Op returns the operation name.
  16351. func (m *MessageMutation) Op() Op {
  16352. return m.op
  16353. }
  16354. // SetOp allows setting the mutation operation.
  16355. func (m *MessageMutation) SetOp(op Op) {
  16356. m.op = op
  16357. }
  16358. // Type returns the node type of this mutation (Message).
  16359. func (m *MessageMutation) Type() string {
  16360. return m.typ
  16361. }
  16362. // Fields returns all fields that were changed during this mutation. Note that in
  16363. // order to get all numeric fields that were incremented/decremented, call
  16364. // AddedFields().
  16365. func (m *MessageMutation) Fields() []string {
  16366. fields := make([]string, 0, 3)
  16367. if m.wx_wxid != nil {
  16368. fields = append(fields, message.FieldWxWxid)
  16369. }
  16370. if m.wxid != nil {
  16371. fields = append(fields, message.FieldWxid)
  16372. }
  16373. if m.content != nil {
  16374. fields = append(fields, message.FieldContent)
  16375. }
  16376. return fields
  16377. }
  16378. // Field returns the value of a field with the given name. The second boolean
  16379. // return value indicates that this field was not set, or was not defined in the
  16380. // schema.
  16381. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16382. switch name {
  16383. case message.FieldWxWxid:
  16384. return m.WxWxid()
  16385. case message.FieldWxid:
  16386. return m.Wxid()
  16387. case message.FieldContent:
  16388. return m.Content()
  16389. }
  16390. return nil, false
  16391. }
  16392. // OldField returns the old value of the field from the database. An error is
  16393. // returned if the mutation operation is not UpdateOne, or the query to the
  16394. // database failed.
  16395. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16396. switch name {
  16397. case message.FieldWxWxid:
  16398. return m.OldWxWxid(ctx)
  16399. case message.FieldWxid:
  16400. return m.OldWxid(ctx)
  16401. case message.FieldContent:
  16402. return m.OldContent(ctx)
  16403. }
  16404. return nil, fmt.Errorf("unknown Message field %s", name)
  16405. }
  16406. // SetField sets the value of a field with the given name. It returns an error if
  16407. // the field is not defined in the schema, or if the type mismatched the field
  16408. // type.
  16409. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16410. switch name {
  16411. case message.FieldWxWxid:
  16412. v, ok := value.(string)
  16413. if !ok {
  16414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16415. }
  16416. m.SetWxWxid(v)
  16417. return nil
  16418. case message.FieldWxid:
  16419. v, ok := value.(string)
  16420. if !ok {
  16421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16422. }
  16423. m.SetWxid(v)
  16424. return nil
  16425. case message.FieldContent:
  16426. v, ok := value.(string)
  16427. if !ok {
  16428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16429. }
  16430. m.SetContent(v)
  16431. return nil
  16432. }
  16433. return fmt.Errorf("unknown Message field %s", name)
  16434. }
  16435. // AddedFields returns all numeric fields that were incremented/decremented during
  16436. // this mutation.
  16437. func (m *MessageMutation) AddedFields() []string {
  16438. return nil
  16439. }
  16440. // AddedField returns the numeric value that was incremented/decremented on a field
  16441. // with the given name. The second boolean return value indicates that this field
  16442. // was not set, or was not defined in the schema.
  16443. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16444. return nil, false
  16445. }
  16446. // AddField adds the value to the field with the given name. It returns an error if
  16447. // the field is not defined in the schema, or if the type mismatched the field
  16448. // type.
  16449. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16450. switch name {
  16451. }
  16452. return fmt.Errorf("unknown Message numeric field %s", name)
  16453. }
  16454. // ClearedFields returns all nullable fields that were cleared during this
  16455. // mutation.
  16456. func (m *MessageMutation) ClearedFields() []string {
  16457. var fields []string
  16458. if m.FieldCleared(message.FieldWxWxid) {
  16459. fields = append(fields, message.FieldWxWxid)
  16460. }
  16461. return fields
  16462. }
  16463. // FieldCleared returns a boolean indicating if a field with the given name was
  16464. // cleared in this mutation.
  16465. func (m *MessageMutation) FieldCleared(name string) bool {
  16466. _, ok := m.clearedFields[name]
  16467. return ok
  16468. }
  16469. // ClearField clears the value of the field with the given name. It returns an
  16470. // error if the field is not defined in the schema.
  16471. func (m *MessageMutation) ClearField(name string) error {
  16472. switch name {
  16473. case message.FieldWxWxid:
  16474. m.ClearWxWxid()
  16475. return nil
  16476. }
  16477. return fmt.Errorf("unknown Message nullable field %s", name)
  16478. }
  16479. // ResetField resets all changes in the mutation for the field with the given name.
  16480. // It returns an error if the field is not defined in the schema.
  16481. func (m *MessageMutation) ResetField(name string) error {
  16482. switch name {
  16483. case message.FieldWxWxid:
  16484. m.ResetWxWxid()
  16485. return nil
  16486. case message.FieldWxid:
  16487. m.ResetWxid()
  16488. return nil
  16489. case message.FieldContent:
  16490. m.ResetContent()
  16491. return nil
  16492. }
  16493. return fmt.Errorf("unknown Message field %s", name)
  16494. }
  16495. // AddedEdges returns all edge names that were set/added in this mutation.
  16496. func (m *MessageMutation) AddedEdges() []string {
  16497. edges := make([]string, 0, 0)
  16498. return edges
  16499. }
  16500. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16501. // name in this mutation.
  16502. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16503. return nil
  16504. }
  16505. // RemovedEdges returns all edge names that were removed in this mutation.
  16506. func (m *MessageMutation) RemovedEdges() []string {
  16507. edges := make([]string, 0, 0)
  16508. return edges
  16509. }
  16510. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16511. // the given name in this mutation.
  16512. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16513. return nil
  16514. }
  16515. // ClearedEdges returns all edge names that were cleared in this mutation.
  16516. func (m *MessageMutation) ClearedEdges() []string {
  16517. edges := make([]string, 0, 0)
  16518. return edges
  16519. }
  16520. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16521. // was cleared in this mutation.
  16522. func (m *MessageMutation) EdgeCleared(name string) bool {
  16523. return false
  16524. }
  16525. // ClearEdge clears the value of the edge with the given name. It returns an error
  16526. // if that edge is not defined in the schema.
  16527. func (m *MessageMutation) ClearEdge(name string) error {
  16528. return fmt.Errorf("unknown Message unique edge %s", name)
  16529. }
  16530. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16531. // It returns an error if the edge is not defined in the schema.
  16532. func (m *MessageMutation) ResetEdge(name string) error {
  16533. return fmt.Errorf("unknown Message edge %s", name)
  16534. }
  16535. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16536. type MessageRecordsMutation struct {
  16537. config
  16538. op Op
  16539. typ string
  16540. id *uint64
  16541. created_at *time.Time
  16542. updated_at *time.Time
  16543. status *uint8
  16544. addstatus *int8
  16545. bot_wxid *string
  16546. contact_type *int
  16547. addcontact_type *int
  16548. contact_wxid *string
  16549. content_type *int
  16550. addcontent_type *int
  16551. content *string
  16552. meta *custom_types.Meta
  16553. error_detail *string
  16554. send_time *time.Time
  16555. source_type *int
  16556. addsource_type *int
  16557. organization_id *uint64
  16558. addorganization_id *int64
  16559. clearedFields map[string]struct{}
  16560. sop_stage *uint64
  16561. clearedsop_stage bool
  16562. sop_node *uint64
  16563. clearedsop_node bool
  16564. message_contact *uint64
  16565. clearedmessage_contact bool
  16566. done bool
  16567. oldValue func(context.Context) (*MessageRecords, error)
  16568. predicates []predicate.MessageRecords
  16569. }
  16570. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16571. // messagerecordsOption allows management of the mutation configuration using functional options.
  16572. type messagerecordsOption func(*MessageRecordsMutation)
  16573. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16574. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16575. m := &MessageRecordsMutation{
  16576. config: c,
  16577. op: op,
  16578. typ: TypeMessageRecords,
  16579. clearedFields: make(map[string]struct{}),
  16580. }
  16581. for _, opt := range opts {
  16582. opt(m)
  16583. }
  16584. return m
  16585. }
  16586. // withMessageRecordsID sets the ID field of the mutation.
  16587. func withMessageRecordsID(id uint64) messagerecordsOption {
  16588. return func(m *MessageRecordsMutation) {
  16589. var (
  16590. err error
  16591. once sync.Once
  16592. value *MessageRecords
  16593. )
  16594. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16595. once.Do(func() {
  16596. if m.done {
  16597. err = errors.New("querying old values post mutation is not allowed")
  16598. } else {
  16599. value, err = m.Client().MessageRecords.Get(ctx, id)
  16600. }
  16601. })
  16602. return value, err
  16603. }
  16604. m.id = &id
  16605. }
  16606. }
  16607. // withMessageRecords sets the old MessageRecords of the mutation.
  16608. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16609. return func(m *MessageRecordsMutation) {
  16610. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16611. return node, nil
  16612. }
  16613. m.id = &node.ID
  16614. }
  16615. }
  16616. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16617. // executed in a transaction (ent.Tx), a transactional client is returned.
  16618. func (m MessageRecordsMutation) Client() *Client {
  16619. client := &Client{config: m.config}
  16620. client.init()
  16621. return client
  16622. }
  16623. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16624. // it returns an error otherwise.
  16625. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16626. if _, ok := m.driver.(*txDriver); !ok {
  16627. return nil, errors.New("ent: mutation is not running in a transaction")
  16628. }
  16629. tx := &Tx{config: m.config}
  16630. tx.init()
  16631. return tx, nil
  16632. }
  16633. // SetID sets the value of the id field. Note that this
  16634. // operation is only accepted on creation of MessageRecords entities.
  16635. func (m *MessageRecordsMutation) SetID(id uint64) {
  16636. m.id = &id
  16637. }
  16638. // ID returns the ID value in the mutation. Note that the ID is only available
  16639. // if it was provided to the builder or after it was returned from the database.
  16640. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16641. if m.id == nil {
  16642. return
  16643. }
  16644. return *m.id, true
  16645. }
  16646. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16647. // That means, if the mutation is applied within a transaction with an isolation level such
  16648. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16649. // or updated by the mutation.
  16650. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16651. switch {
  16652. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16653. id, exists := m.ID()
  16654. if exists {
  16655. return []uint64{id}, nil
  16656. }
  16657. fallthrough
  16658. case m.op.Is(OpUpdate | OpDelete):
  16659. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16660. default:
  16661. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16662. }
  16663. }
  16664. // SetCreatedAt sets the "created_at" field.
  16665. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16666. m.created_at = &t
  16667. }
  16668. // CreatedAt returns the value of the "created_at" field in the mutation.
  16669. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16670. v := m.created_at
  16671. if v == nil {
  16672. return
  16673. }
  16674. return *v, true
  16675. }
  16676. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16677. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16679. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16680. if !m.op.Is(OpUpdateOne) {
  16681. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16682. }
  16683. if m.id == nil || m.oldValue == nil {
  16684. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16685. }
  16686. oldValue, err := m.oldValue(ctx)
  16687. if err != nil {
  16688. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16689. }
  16690. return oldValue.CreatedAt, nil
  16691. }
  16692. // ResetCreatedAt resets all changes to the "created_at" field.
  16693. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16694. m.created_at = nil
  16695. }
  16696. // SetUpdatedAt sets the "updated_at" field.
  16697. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16698. m.updated_at = &t
  16699. }
  16700. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16701. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16702. v := m.updated_at
  16703. if v == nil {
  16704. return
  16705. }
  16706. return *v, true
  16707. }
  16708. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16709. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16710. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16711. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16712. if !m.op.Is(OpUpdateOne) {
  16713. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16714. }
  16715. if m.id == nil || m.oldValue == nil {
  16716. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16717. }
  16718. oldValue, err := m.oldValue(ctx)
  16719. if err != nil {
  16720. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16721. }
  16722. return oldValue.UpdatedAt, nil
  16723. }
  16724. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16725. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16726. m.updated_at = nil
  16727. }
  16728. // SetStatus sets the "status" field.
  16729. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16730. m.status = &u
  16731. m.addstatus = nil
  16732. }
  16733. // Status returns the value of the "status" field in the mutation.
  16734. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16735. v := m.status
  16736. if v == nil {
  16737. return
  16738. }
  16739. return *v, true
  16740. }
  16741. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16742. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16744. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16745. if !m.op.Is(OpUpdateOne) {
  16746. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16747. }
  16748. if m.id == nil || m.oldValue == nil {
  16749. return v, errors.New("OldStatus requires an ID field in the mutation")
  16750. }
  16751. oldValue, err := m.oldValue(ctx)
  16752. if err != nil {
  16753. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16754. }
  16755. return oldValue.Status, nil
  16756. }
  16757. // AddStatus adds u to the "status" field.
  16758. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16759. if m.addstatus != nil {
  16760. *m.addstatus += u
  16761. } else {
  16762. m.addstatus = &u
  16763. }
  16764. }
  16765. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16766. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16767. v := m.addstatus
  16768. if v == nil {
  16769. return
  16770. }
  16771. return *v, true
  16772. }
  16773. // ClearStatus clears the value of the "status" field.
  16774. func (m *MessageRecordsMutation) ClearStatus() {
  16775. m.status = nil
  16776. m.addstatus = nil
  16777. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16778. }
  16779. // StatusCleared returns if the "status" field was cleared in this mutation.
  16780. func (m *MessageRecordsMutation) StatusCleared() bool {
  16781. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16782. return ok
  16783. }
  16784. // ResetStatus resets all changes to the "status" field.
  16785. func (m *MessageRecordsMutation) ResetStatus() {
  16786. m.status = nil
  16787. m.addstatus = nil
  16788. delete(m.clearedFields, messagerecords.FieldStatus)
  16789. }
  16790. // SetBotWxid sets the "bot_wxid" field.
  16791. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16792. m.bot_wxid = &s
  16793. }
  16794. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16795. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16796. v := m.bot_wxid
  16797. if v == nil {
  16798. return
  16799. }
  16800. return *v, true
  16801. }
  16802. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16803. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16805. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16806. if !m.op.Is(OpUpdateOne) {
  16807. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16808. }
  16809. if m.id == nil || m.oldValue == nil {
  16810. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16811. }
  16812. oldValue, err := m.oldValue(ctx)
  16813. if err != nil {
  16814. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16815. }
  16816. return oldValue.BotWxid, nil
  16817. }
  16818. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16819. func (m *MessageRecordsMutation) ResetBotWxid() {
  16820. m.bot_wxid = nil
  16821. }
  16822. // SetContactID sets the "contact_id" field.
  16823. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16824. m.message_contact = &u
  16825. }
  16826. // ContactID returns the value of the "contact_id" field in the mutation.
  16827. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16828. v := m.message_contact
  16829. if v == nil {
  16830. return
  16831. }
  16832. return *v, true
  16833. }
  16834. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16835. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16836. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16837. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16838. if !m.op.Is(OpUpdateOne) {
  16839. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16840. }
  16841. if m.id == nil || m.oldValue == nil {
  16842. return v, errors.New("OldContactID requires an ID field in the mutation")
  16843. }
  16844. oldValue, err := m.oldValue(ctx)
  16845. if err != nil {
  16846. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16847. }
  16848. return oldValue.ContactID, nil
  16849. }
  16850. // ClearContactID clears the value of the "contact_id" field.
  16851. func (m *MessageRecordsMutation) ClearContactID() {
  16852. m.message_contact = nil
  16853. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16854. }
  16855. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16856. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16857. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16858. return ok
  16859. }
  16860. // ResetContactID resets all changes to the "contact_id" field.
  16861. func (m *MessageRecordsMutation) ResetContactID() {
  16862. m.message_contact = nil
  16863. delete(m.clearedFields, messagerecords.FieldContactID)
  16864. }
  16865. // SetContactType sets the "contact_type" field.
  16866. func (m *MessageRecordsMutation) SetContactType(i int) {
  16867. m.contact_type = &i
  16868. m.addcontact_type = nil
  16869. }
  16870. // ContactType returns the value of the "contact_type" field in the mutation.
  16871. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16872. v := m.contact_type
  16873. if v == nil {
  16874. return
  16875. }
  16876. return *v, true
  16877. }
  16878. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16879. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16881. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16882. if !m.op.Is(OpUpdateOne) {
  16883. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16884. }
  16885. if m.id == nil || m.oldValue == nil {
  16886. return v, errors.New("OldContactType requires an ID field in the mutation")
  16887. }
  16888. oldValue, err := m.oldValue(ctx)
  16889. if err != nil {
  16890. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  16891. }
  16892. return oldValue.ContactType, nil
  16893. }
  16894. // AddContactType adds i to the "contact_type" field.
  16895. func (m *MessageRecordsMutation) AddContactType(i int) {
  16896. if m.addcontact_type != nil {
  16897. *m.addcontact_type += i
  16898. } else {
  16899. m.addcontact_type = &i
  16900. }
  16901. }
  16902. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  16903. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  16904. v := m.addcontact_type
  16905. if v == nil {
  16906. return
  16907. }
  16908. return *v, true
  16909. }
  16910. // ResetContactType resets all changes to the "contact_type" field.
  16911. func (m *MessageRecordsMutation) ResetContactType() {
  16912. m.contact_type = nil
  16913. m.addcontact_type = nil
  16914. }
  16915. // SetContactWxid sets the "contact_wxid" field.
  16916. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  16917. m.contact_wxid = &s
  16918. }
  16919. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  16920. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  16921. v := m.contact_wxid
  16922. if v == nil {
  16923. return
  16924. }
  16925. return *v, true
  16926. }
  16927. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  16928. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16929. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16930. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  16931. if !m.op.Is(OpUpdateOne) {
  16932. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  16933. }
  16934. if m.id == nil || m.oldValue == nil {
  16935. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  16936. }
  16937. oldValue, err := m.oldValue(ctx)
  16938. if err != nil {
  16939. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  16940. }
  16941. return oldValue.ContactWxid, nil
  16942. }
  16943. // ResetContactWxid resets all changes to the "contact_wxid" field.
  16944. func (m *MessageRecordsMutation) ResetContactWxid() {
  16945. m.contact_wxid = nil
  16946. }
  16947. // SetContentType sets the "content_type" field.
  16948. func (m *MessageRecordsMutation) SetContentType(i int) {
  16949. m.content_type = &i
  16950. m.addcontent_type = nil
  16951. }
  16952. // ContentType returns the value of the "content_type" field in the mutation.
  16953. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  16954. v := m.content_type
  16955. if v == nil {
  16956. return
  16957. }
  16958. return *v, true
  16959. }
  16960. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  16961. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16963. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  16964. if !m.op.Is(OpUpdateOne) {
  16965. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  16966. }
  16967. if m.id == nil || m.oldValue == nil {
  16968. return v, errors.New("OldContentType requires an ID field in the mutation")
  16969. }
  16970. oldValue, err := m.oldValue(ctx)
  16971. if err != nil {
  16972. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  16973. }
  16974. return oldValue.ContentType, nil
  16975. }
  16976. // AddContentType adds i to the "content_type" field.
  16977. func (m *MessageRecordsMutation) AddContentType(i int) {
  16978. if m.addcontent_type != nil {
  16979. *m.addcontent_type += i
  16980. } else {
  16981. m.addcontent_type = &i
  16982. }
  16983. }
  16984. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  16985. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  16986. v := m.addcontent_type
  16987. if v == nil {
  16988. return
  16989. }
  16990. return *v, true
  16991. }
  16992. // ResetContentType resets all changes to the "content_type" field.
  16993. func (m *MessageRecordsMutation) ResetContentType() {
  16994. m.content_type = nil
  16995. m.addcontent_type = nil
  16996. }
  16997. // SetContent sets the "content" field.
  16998. func (m *MessageRecordsMutation) SetContent(s string) {
  16999. m.content = &s
  17000. }
  17001. // Content returns the value of the "content" field in the mutation.
  17002. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17003. v := m.content
  17004. if v == nil {
  17005. return
  17006. }
  17007. return *v, true
  17008. }
  17009. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17010. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17012. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17013. if !m.op.Is(OpUpdateOne) {
  17014. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17015. }
  17016. if m.id == nil || m.oldValue == nil {
  17017. return v, errors.New("OldContent requires an ID field in the mutation")
  17018. }
  17019. oldValue, err := m.oldValue(ctx)
  17020. if err != nil {
  17021. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17022. }
  17023. return oldValue.Content, nil
  17024. }
  17025. // ResetContent resets all changes to the "content" field.
  17026. func (m *MessageRecordsMutation) ResetContent() {
  17027. m.content = nil
  17028. }
  17029. // SetMeta sets the "meta" field.
  17030. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17031. m.meta = &ct
  17032. }
  17033. // Meta returns the value of the "meta" field in the mutation.
  17034. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17035. v := m.meta
  17036. if v == nil {
  17037. return
  17038. }
  17039. return *v, true
  17040. }
  17041. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17042. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17044. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17045. if !m.op.Is(OpUpdateOne) {
  17046. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17047. }
  17048. if m.id == nil || m.oldValue == nil {
  17049. return v, errors.New("OldMeta requires an ID field in the mutation")
  17050. }
  17051. oldValue, err := m.oldValue(ctx)
  17052. if err != nil {
  17053. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17054. }
  17055. return oldValue.Meta, nil
  17056. }
  17057. // ClearMeta clears the value of the "meta" field.
  17058. func (m *MessageRecordsMutation) ClearMeta() {
  17059. m.meta = nil
  17060. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17061. }
  17062. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17063. func (m *MessageRecordsMutation) MetaCleared() bool {
  17064. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17065. return ok
  17066. }
  17067. // ResetMeta resets all changes to the "meta" field.
  17068. func (m *MessageRecordsMutation) ResetMeta() {
  17069. m.meta = nil
  17070. delete(m.clearedFields, messagerecords.FieldMeta)
  17071. }
  17072. // SetErrorDetail sets the "error_detail" field.
  17073. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17074. m.error_detail = &s
  17075. }
  17076. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17077. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17078. v := m.error_detail
  17079. if v == nil {
  17080. return
  17081. }
  17082. return *v, true
  17083. }
  17084. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17085. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17087. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17088. if !m.op.Is(OpUpdateOne) {
  17089. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17090. }
  17091. if m.id == nil || m.oldValue == nil {
  17092. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17093. }
  17094. oldValue, err := m.oldValue(ctx)
  17095. if err != nil {
  17096. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17097. }
  17098. return oldValue.ErrorDetail, nil
  17099. }
  17100. // ResetErrorDetail resets all changes to the "error_detail" field.
  17101. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17102. m.error_detail = nil
  17103. }
  17104. // SetSendTime sets the "send_time" field.
  17105. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17106. m.send_time = &t
  17107. }
  17108. // SendTime returns the value of the "send_time" field in the mutation.
  17109. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17110. v := m.send_time
  17111. if v == nil {
  17112. return
  17113. }
  17114. return *v, true
  17115. }
  17116. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17117. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17118. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17119. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17120. if !m.op.Is(OpUpdateOne) {
  17121. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17122. }
  17123. if m.id == nil || m.oldValue == nil {
  17124. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17125. }
  17126. oldValue, err := m.oldValue(ctx)
  17127. if err != nil {
  17128. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17129. }
  17130. return oldValue.SendTime, nil
  17131. }
  17132. // ClearSendTime clears the value of the "send_time" field.
  17133. func (m *MessageRecordsMutation) ClearSendTime() {
  17134. m.send_time = nil
  17135. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17136. }
  17137. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17138. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17139. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17140. return ok
  17141. }
  17142. // ResetSendTime resets all changes to the "send_time" field.
  17143. func (m *MessageRecordsMutation) ResetSendTime() {
  17144. m.send_time = nil
  17145. delete(m.clearedFields, messagerecords.FieldSendTime)
  17146. }
  17147. // SetSourceType sets the "source_type" field.
  17148. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17149. m.source_type = &i
  17150. m.addsource_type = nil
  17151. }
  17152. // SourceType returns the value of the "source_type" field in the mutation.
  17153. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17154. v := m.source_type
  17155. if v == nil {
  17156. return
  17157. }
  17158. return *v, true
  17159. }
  17160. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17161. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17163. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17164. if !m.op.Is(OpUpdateOne) {
  17165. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17166. }
  17167. if m.id == nil || m.oldValue == nil {
  17168. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17169. }
  17170. oldValue, err := m.oldValue(ctx)
  17171. if err != nil {
  17172. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17173. }
  17174. return oldValue.SourceType, nil
  17175. }
  17176. // AddSourceType adds i to the "source_type" field.
  17177. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17178. if m.addsource_type != nil {
  17179. *m.addsource_type += i
  17180. } else {
  17181. m.addsource_type = &i
  17182. }
  17183. }
  17184. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17185. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17186. v := m.addsource_type
  17187. if v == nil {
  17188. return
  17189. }
  17190. return *v, true
  17191. }
  17192. // ResetSourceType resets all changes to the "source_type" field.
  17193. func (m *MessageRecordsMutation) ResetSourceType() {
  17194. m.source_type = nil
  17195. m.addsource_type = nil
  17196. }
  17197. // SetSourceID sets the "source_id" field.
  17198. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17199. m.sop_stage = &u
  17200. }
  17201. // SourceID returns the value of the "source_id" field in the mutation.
  17202. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17203. v := m.sop_stage
  17204. if v == nil {
  17205. return
  17206. }
  17207. return *v, true
  17208. }
  17209. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17210. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17211. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17212. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17213. if !m.op.Is(OpUpdateOne) {
  17214. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17215. }
  17216. if m.id == nil || m.oldValue == nil {
  17217. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17218. }
  17219. oldValue, err := m.oldValue(ctx)
  17220. if err != nil {
  17221. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17222. }
  17223. return oldValue.SourceID, nil
  17224. }
  17225. // ClearSourceID clears the value of the "source_id" field.
  17226. func (m *MessageRecordsMutation) ClearSourceID() {
  17227. m.sop_stage = nil
  17228. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17229. }
  17230. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17231. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17232. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17233. return ok
  17234. }
  17235. // ResetSourceID resets all changes to the "source_id" field.
  17236. func (m *MessageRecordsMutation) ResetSourceID() {
  17237. m.sop_stage = nil
  17238. delete(m.clearedFields, messagerecords.FieldSourceID)
  17239. }
  17240. // SetSubSourceID sets the "sub_source_id" field.
  17241. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17242. m.sop_node = &u
  17243. }
  17244. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17245. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17246. v := m.sop_node
  17247. if v == nil {
  17248. return
  17249. }
  17250. return *v, true
  17251. }
  17252. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17253. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17254. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17255. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17256. if !m.op.Is(OpUpdateOne) {
  17257. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17258. }
  17259. if m.id == nil || m.oldValue == nil {
  17260. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17261. }
  17262. oldValue, err := m.oldValue(ctx)
  17263. if err != nil {
  17264. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17265. }
  17266. return oldValue.SubSourceID, nil
  17267. }
  17268. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17269. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17270. m.sop_node = nil
  17271. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17272. }
  17273. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17274. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17275. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17276. return ok
  17277. }
  17278. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17279. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17280. m.sop_node = nil
  17281. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17282. }
  17283. // SetOrganizationID sets the "organization_id" field.
  17284. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17285. m.organization_id = &u
  17286. m.addorganization_id = nil
  17287. }
  17288. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17289. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17290. v := m.organization_id
  17291. if v == nil {
  17292. return
  17293. }
  17294. return *v, true
  17295. }
  17296. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17297. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17299. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17300. if !m.op.Is(OpUpdateOne) {
  17301. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17302. }
  17303. if m.id == nil || m.oldValue == nil {
  17304. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17305. }
  17306. oldValue, err := m.oldValue(ctx)
  17307. if err != nil {
  17308. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17309. }
  17310. return oldValue.OrganizationID, nil
  17311. }
  17312. // AddOrganizationID adds u to the "organization_id" field.
  17313. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17314. if m.addorganization_id != nil {
  17315. *m.addorganization_id += u
  17316. } else {
  17317. m.addorganization_id = &u
  17318. }
  17319. }
  17320. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17321. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17322. v := m.addorganization_id
  17323. if v == nil {
  17324. return
  17325. }
  17326. return *v, true
  17327. }
  17328. // ClearOrganizationID clears the value of the "organization_id" field.
  17329. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17330. m.organization_id = nil
  17331. m.addorganization_id = nil
  17332. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17333. }
  17334. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17335. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17336. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17337. return ok
  17338. }
  17339. // ResetOrganizationID resets all changes to the "organization_id" field.
  17340. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17341. m.organization_id = nil
  17342. m.addorganization_id = nil
  17343. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17344. }
  17345. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17346. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17347. m.sop_stage = &id
  17348. }
  17349. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17350. func (m *MessageRecordsMutation) ClearSopStage() {
  17351. m.clearedsop_stage = true
  17352. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17353. }
  17354. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17355. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17356. return m.SourceIDCleared() || m.clearedsop_stage
  17357. }
  17358. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17359. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17360. if m.sop_stage != nil {
  17361. return *m.sop_stage, true
  17362. }
  17363. return
  17364. }
  17365. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17366. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17367. // SopStageID instead. It exists only for internal usage by the builders.
  17368. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17369. if id := m.sop_stage; id != nil {
  17370. ids = append(ids, *id)
  17371. }
  17372. return
  17373. }
  17374. // ResetSopStage resets all changes to the "sop_stage" edge.
  17375. func (m *MessageRecordsMutation) ResetSopStage() {
  17376. m.sop_stage = nil
  17377. m.clearedsop_stage = false
  17378. }
  17379. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17380. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17381. m.sop_node = &id
  17382. }
  17383. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17384. func (m *MessageRecordsMutation) ClearSopNode() {
  17385. m.clearedsop_node = true
  17386. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17387. }
  17388. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17389. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17390. return m.SubSourceIDCleared() || m.clearedsop_node
  17391. }
  17392. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17393. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17394. if m.sop_node != nil {
  17395. return *m.sop_node, true
  17396. }
  17397. return
  17398. }
  17399. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17400. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17401. // SopNodeID instead. It exists only for internal usage by the builders.
  17402. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17403. if id := m.sop_node; id != nil {
  17404. ids = append(ids, *id)
  17405. }
  17406. return
  17407. }
  17408. // ResetSopNode resets all changes to the "sop_node" edge.
  17409. func (m *MessageRecordsMutation) ResetSopNode() {
  17410. m.sop_node = nil
  17411. m.clearedsop_node = false
  17412. }
  17413. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17414. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17415. m.message_contact = &id
  17416. }
  17417. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17418. func (m *MessageRecordsMutation) ClearMessageContact() {
  17419. m.clearedmessage_contact = true
  17420. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17421. }
  17422. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17423. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17424. return m.ContactIDCleared() || m.clearedmessage_contact
  17425. }
  17426. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17427. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17428. if m.message_contact != nil {
  17429. return *m.message_contact, true
  17430. }
  17431. return
  17432. }
  17433. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17434. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17435. // MessageContactID instead. It exists only for internal usage by the builders.
  17436. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17437. if id := m.message_contact; id != nil {
  17438. ids = append(ids, *id)
  17439. }
  17440. return
  17441. }
  17442. // ResetMessageContact resets all changes to the "message_contact" edge.
  17443. func (m *MessageRecordsMutation) ResetMessageContact() {
  17444. m.message_contact = nil
  17445. m.clearedmessage_contact = false
  17446. }
  17447. // Where appends a list predicates to the MessageRecordsMutation builder.
  17448. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17449. m.predicates = append(m.predicates, ps...)
  17450. }
  17451. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17452. // users can use type-assertion to append predicates that do not depend on any generated package.
  17453. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17454. p := make([]predicate.MessageRecords, len(ps))
  17455. for i := range ps {
  17456. p[i] = ps[i]
  17457. }
  17458. m.Where(p...)
  17459. }
  17460. // Op returns the operation name.
  17461. func (m *MessageRecordsMutation) Op() Op {
  17462. return m.op
  17463. }
  17464. // SetOp allows setting the mutation operation.
  17465. func (m *MessageRecordsMutation) SetOp(op Op) {
  17466. m.op = op
  17467. }
  17468. // Type returns the node type of this mutation (MessageRecords).
  17469. func (m *MessageRecordsMutation) Type() string {
  17470. return m.typ
  17471. }
  17472. // Fields returns all fields that were changed during this mutation. Note that in
  17473. // order to get all numeric fields that were incremented/decremented, call
  17474. // AddedFields().
  17475. func (m *MessageRecordsMutation) Fields() []string {
  17476. fields := make([]string, 0, 16)
  17477. if m.created_at != nil {
  17478. fields = append(fields, messagerecords.FieldCreatedAt)
  17479. }
  17480. if m.updated_at != nil {
  17481. fields = append(fields, messagerecords.FieldUpdatedAt)
  17482. }
  17483. if m.status != nil {
  17484. fields = append(fields, messagerecords.FieldStatus)
  17485. }
  17486. if m.bot_wxid != nil {
  17487. fields = append(fields, messagerecords.FieldBotWxid)
  17488. }
  17489. if m.message_contact != nil {
  17490. fields = append(fields, messagerecords.FieldContactID)
  17491. }
  17492. if m.contact_type != nil {
  17493. fields = append(fields, messagerecords.FieldContactType)
  17494. }
  17495. if m.contact_wxid != nil {
  17496. fields = append(fields, messagerecords.FieldContactWxid)
  17497. }
  17498. if m.content_type != nil {
  17499. fields = append(fields, messagerecords.FieldContentType)
  17500. }
  17501. if m.content != nil {
  17502. fields = append(fields, messagerecords.FieldContent)
  17503. }
  17504. if m.meta != nil {
  17505. fields = append(fields, messagerecords.FieldMeta)
  17506. }
  17507. if m.error_detail != nil {
  17508. fields = append(fields, messagerecords.FieldErrorDetail)
  17509. }
  17510. if m.send_time != nil {
  17511. fields = append(fields, messagerecords.FieldSendTime)
  17512. }
  17513. if m.source_type != nil {
  17514. fields = append(fields, messagerecords.FieldSourceType)
  17515. }
  17516. if m.sop_stage != nil {
  17517. fields = append(fields, messagerecords.FieldSourceID)
  17518. }
  17519. if m.sop_node != nil {
  17520. fields = append(fields, messagerecords.FieldSubSourceID)
  17521. }
  17522. if m.organization_id != nil {
  17523. fields = append(fields, messagerecords.FieldOrganizationID)
  17524. }
  17525. return fields
  17526. }
  17527. // Field returns the value of a field with the given name. The second boolean
  17528. // return value indicates that this field was not set, or was not defined in the
  17529. // schema.
  17530. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17531. switch name {
  17532. case messagerecords.FieldCreatedAt:
  17533. return m.CreatedAt()
  17534. case messagerecords.FieldUpdatedAt:
  17535. return m.UpdatedAt()
  17536. case messagerecords.FieldStatus:
  17537. return m.Status()
  17538. case messagerecords.FieldBotWxid:
  17539. return m.BotWxid()
  17540. case messagerecords.FieldContactID:
  17541. return m.ContactID()
  17542. case messagerecords.FieldContactType:
  17543. return m.ContactType()
  17544. case messagerecords.FieldContactWxid:
  17545. return m.ContactWxid()
  17546. case messagerecords.FieldContentType:
  17547. return m.ContentType()
  17548. case messagerecords.FieldContent:
  17549. return m.Content()
  17550. case messagerecords.FieldMeta:
  17551. return m.Meta()
  17552. case messagerecords.FieldErrorDetail:
  17553. return m.ErrorDetail()
  17554. case messagerecords.FieldSendTime:
  17555. return m.SendTime()
  17556. case messagerecords.FieldSourceType:
  17557. return m.SourceType()
  17558. case messagerecords.FieldSourceID:
  17559. return m.SourceID()
  17560. case messagerecords.FieldSubSourceID:
  17561. return m.SubSourceID()
  17562. case messagerecords.FieldOrganizationID:
  17563. return m.OrganizationID()
  17564. }
  17565. return nil, false
  17566. }
  17567. // OldField returns the old value of the field from the database. An error is
  17568. // returned if the mutation operation is not UpdateOne, or the query to the
  17569. // database failed.
  17570. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17571. switch name {
  17572. case messagerecords.FieldCreatedAt:
  17573. return m.OldCreatedAt(ctx)
  17574. case messagerecords.FieldUpdatedAt:
  17575. return m.OldUpdatedAt(ctx)
  17576. case messagerecords.FieldStatus:
  17577. return m.OldStatus(ctx)
  17578. case messagerecords.FieldBotWxid:
  17579. return m.OldBotWxid(ctx)
  17580. case messagerecords.FieldContactID:
  17581. return m.OldContactID(ctx)
  17582. case messagerecords.FieldContactType:
  17583. return m.OldContactType(ctx)
  17584. case messagerecords.FieldContactWxid:
  17585. return m.OldContactWxid(ctx)
  17586. case messagerecords.FieldContentType:
  17587. return m.OldContentType(ctx)
  17588. case messagerecords.FieldContent:
  17589. return m.OldContent(ctx)
  17590. case messagerecords.FieldMeta:
  17591. return m.OldMeta(ctx)
  17592. case messagerecords.FieldErrorDetail:
  17593. return m.OldErrorDetail(ctx)
  17594. case messagerecords.FieldSendTime:
  17595. return m.OldSendTime(ctx)
  17596. case messagerecords.FieldSourceType:
  17597. return m.OldSourceType(ctx)
  17598. case messagerecords.FieldSourceID:
  17599. return m.OldSourceID(ctx)
  17600. case messagerecords.FieldSubSourceID:
  17601. return m.OldSubSourceID(ctx)
  17602. case messagerecords.FieldOrganizationID:
  17603. return m.OldOrganizationID(ctx)
  17604. }
  17605. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17606. }
  17607. // SetField sets the value of a field with the given name. It returns an error if
  17608. // the field is not defined in the schema, or if the type mismatched the field
  17609. // type.
  17610. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17611. switch name {
  17612. case messagerecords.FieldCreatedAt:
  17613. v, ok := value.(time.Time)
  17614. if !ok {
  17615. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17616. }
  17617. m.SetCreatedAt(v)
  17618. return nil
  17619. case messagerecords.FieldUpdatedAt:
  17620. v, ok := value.(time.Time)
  17621. if !ok {
  17622. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17623. }
  17624. m.SetUpdatedAt(v)
  17625. return nil
  17626. case messagerecords.FieldStatus:
  17627. v, ok := value.(uint8)
  17628. if !ok {
  17629. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17630. }
  17631. m.SetStatus(v)
  17632. return nil
  17633. case messagerecords.FieldBotWxid:
  17634. v, ok := value.(string)
  17635. if !ok {
  17636. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17637. }
  17638. m.SetBotWxid(v)
  17639. return nil
  17640. case messagerecords.FieldContactID:
  17641. v, ok := value.(uint64)
  17642. if !ok {
  17643. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17644. }
  17645. m.SetContactID(v)
  17646. return nil
  17647. case messagerecords.FieldContactType:
  17648. v, ok := value.(int)
  17649. if !ok {
  17650. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17651. }
  17652. m.SetContactType(v)
  17653. return nil
  17654. case messagerecords.FieldContactWxid:
  17655. v, ok := value.(string)
  17656. if !ok {
  17657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17658. }
  17659. m.SetContactWxid(v)
  17660. return nil
  17661. case messagerecords.FieldContentType:
  17662. v, ok := value.(int)
  17663. if !ok {
  17664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17665. }
  17666. m.SetContentType(v)
  17667. return nil
  17668. case messagerecords.FieldContent:
  17669. v, ok := value.(string)
  17670. if !ok {
  17671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17672. }
  17673. m.SetContent(v)
  17674. return nil
  17675. case messagerecords.FieldMeta:
  17676. v, ok := value.(custom_types.Meta)
  17677. if !ok {
  17678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17679. }
  17680. m.SetMeta(v)
  17681. return nil
  17682. case messagerecords.FieldErrorDetail:
  17683. v, ok := value.(string)
  17684. if !ok {
  17685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17686. }
  17687. m.SetErrorDetail(v)
  17688. return nil
  17689. case messagerecords.FieldSendTime:
  17690. v, ok := value.(time.Time)
  17691. if !ok {
  17692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17693. }
  17694. m.SetSendTime(v)
  17695. return nil
  17696. case messagerecords.FieldSourceType:
  17697. v, ok := value.(int)
  17698. if !ok {
  17699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17700. }
  17701. m.SetSourceType(v)
  17702. return nil
  17703. case messagerecords.FieldSourceID:
  17704. v, ok := value.(uint64)
  17705. if !ok {
  17706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17707. }
  17708. m.SetSourceID(v)
  17709. return nil
  17710. case messagerecords.FieldSubSourceID:
  17711. v, ok := value.(uint64)
  17712. if !ok {
  17713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17714. }
  17715. m.SetSubSourceID(v)
  17716. return nil
  17717. case messagerecords.FieldOrganizationID:
  17718. v, ok := value.(uint64)
  17719. if !ok {
  17720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17721. }
  17722. m.SetOrganizationID(v)
  17723. return nil
  17724. }
  17725. return fmt.Errorf("unknown MessageRecords field %s", name)
  17726. }
  17727. // AddedFields returns all numeric fields that were incremented/decremented during
  17728. // this mutation.
  17729. func (m *MessageRecordsMutation) AddedFields() []string {
  17730. var fields []string
  17731. if m.addstatus != nil {
  17732. fields = append(fields, messagerecords.FieldStatus)
  17733. }
  17734. if m.addcontact_type != nil {
  17735. fields = append(fields, messagerecords.FieldContactType)
  17736. }
  17737. if m.addcontent_type != nil {
  17738. fields = append(fields, messagerecords.FieldContentType)
  17739. }
  17740. if m.addsource_type != nil {
  17741. fields = append(fields, messagerecords.FieldSourceType)
  17742. }
  17743. if m.addorganization_id != nil {
  17744. fields = append(fields, messagerecords.FieldOrganizationID)
  17745. }
  17746. return fields
  17747. }
  17748. // AddedField returns the numeric value that was incremented/decremented on a field
  17749. // with the given name. The second boolean return value indicates that this field
  17750. // was not set, or was not defined in the schema.
  17751. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17752. switch name {
  17753. case messagerecords.FieldStatus:
  17754. return m.AddedStatus()
  17755. case messagerecords.FieldContactType:
  17756. return m.AddedContactType()
  17757. case messagerecords.FieldContentType:
  17758. return m.AddedContentType()
  17759. case messagerecords.FieldSourceType:
  17760. return m.AddedSourceType()
  17761. case messagerecords.FieldOrganizationID:
  17762. return m.AddedOrganizationID()
  17763. }
  17764. return nil, false
  17765. }
  17766. // AddField adds the value to the field with the given name. It returns an error if
  17767. // the field is not defined in the schema, or if the type mismatched the field
  17768. // type.
  17769. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17770. switch name {
  17771. case messagerecords.FieldStatus:
  17772. v, ok := value.(int8)
  17773. if !ok {
  17774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17775. }
  17776. m.AddStatus(v)
  17777. return nil
  17778. case messagerecords.FieldContactType:
  17779. v, ok := value.(int)
  17780. if !ok {
  17781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17782. }
  17783. m.AddContactType(v)
  17784. return nil
  17785. case messagerecords.FieldContentType:
  17786. v, ok := value.(int)
  17787. if !ok {
  17788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17789. }
  17790. m.AddContentType(v)
  17791. return nil
  17792. case messagerecords.FieldSourceType:
  17793. v, ok := value.(int)
  17794. if !ok {
  17795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17796. }
  17797. m.AddSourceType(v)
  17798. return nil
  17799. case messagerecords.FieldOrganizationID:
  17800. v, ok := value.(int64)
  17801. if !ok {
  17802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17803. }
  17804. m.AddOrganizationID(v)
  17805. return nil
  17806. }
  17807. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17808. }
  17809. // ClearedFields returns all nullable fields that were cleared during this
  17810. // mutation.
  17811. func (m *MessageRecordsMutation) ClearedFields() []string {
  17812. var fields []string
  17813. if m.FieldCleared(messagerecords.FieldStatus) {
  17814. fields = append(fields, messagerecords.FieldStatus)
  17815. }
  17816. if m.FieldCleared(messagerecords.FieldContactID) {
  17817. fields = append(fields, messagerecords.FieldContactID)
  17818. }
  17819. if m.FieldCleared(messagerecords.FieldMeta) {
  17820. fields = append(fields, messagerecords.FieldMeta)
  17821. }
  17822. if m.FieldCleared(messagerecords.FieldSendTime) {
  17823. fields = append(fields, messagerecords.FieldSendTime)
  17824. }
  17825. if m.FieldCleared(messagerecords.FieldSourceID) {
  17826. fields = append(fields, messagerecords.FieldSourceID)
  17827. }
  17828. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17829. fields = append(fields, messagerecords.FieldSubSourceID)
  17830. }
  17831. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17832. fields = append(fields, messagerecords.FieldOrganizationID)
  17833. }
  17834. return fields
  17835. }
  17836. // FieldCleared returns a boolean indicating if a field with the given name was
  17837. // cleared in this mutation.
  17838. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17839. _, ok := m.clearedFields[name]
  17840. return ok
  17841. }
  17842. // ClearField clears the value of the field with the given name. It returns an
  17843. // error if the field is not defined in the schema.
  17844. func (m *MessageRecordsMutation) ClearField(name string) error {
  17845. switch name {
  17846. case messagerecords.FieldStatus:
  17847. m.ClearStatus()
  17848. return nil
  17849. case messagerecords.FieldContactID:
  17850. m.ClearContactID()
  17851. return nil
  17852. case messagerecords.FieldMeta:
  17853. m.ClearMeta()
  17854. return nil
  17855. case messagerecords.FieldSendTime:
  17856. m.ClearSendTime()
  17857. return nil
  17858. case messagerecords.FieldSourceID:
  17859. m.ClearSourceID()
  17860. return nil
  17861. case messagerecords.FieldSubSourceID:
  17862. m.ClearSubSourceID()
  17863. return nil
  17864. case messagerecords.FieldOrganizationID:
  17865. m.ClearOrganizationID()
  17866. return nil
  17867. }
  17868. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17869. }
  17870. // ResetField resets all changes in the mutation for the field with the given name.
  17871. // It returns an error if the field is not defined in the schema.
  17872. func (m *MessageRecordsMutation) ResetField(name string) error {
  17873. switch name {
  17874. case messagerecords.FieldCreatedAt:
  17875. m.ResetCreatedAt()
  17876. return nil
  17877. case messagerecords.FieldUpdatedAt:
  17878. m.ResetUpdatedAt()
  17879. return nil
  17880. case messagerecords.FieldStatus:
  17881. m.ResetStatus()
  17882. return nil
  17883. case messagerecords.FieldBotWxid:
  17884. m.ResetBotWxid()
  17885. return nil
  17886. case messagerecords.FieldContactID:
  17887. m.ResetContactID()
  17888. return nil
  17889. case messagerecords.FieldContactType:
  17890. m.ResetContactType()
  17891. return nil
  17892. case messagerecords.FieldContactWxid:
  17893. m.ResetContactWxid()
  17894. return nil
  17895. case messagerecords.FieldContentType:
  17896. m.ResetContentType()
  17897. return nil
  17898. case messagerecords.FieldContent:
  17899. m.ResetContent()
  17900. return nil
  17901. case messagerecords.FieldMeta:
  17902. m.ResetMeta()
  17903. return nil
  17904. case messagerecords.FieldErrorDetail:
  17905. m.ResetErrorDetail()
  17906. return nil
  17907. case messagerecords.FieldSendTime:
  17908. m.ResetSendTime()
  17909. return nil
  17910. case messagerecords.FieldSourceType:
  17911. m.ResetSourceType()
  17912. return nil
  17913. case messagerecords.FieldSourceID:
  17914. m.ResetSourceID()
  17915. return nil
  17916. case messagerecords.FieldSubSourceID:
  17917. m.ResetSubSourceID()
  17918. return nil
  17919. case messagerecords.FieldOrganizationID:
  17920. m.ResetOrganizationID()
  17921. return nil
  17922. }
  17923. return fmt.Errorf("unknown MessageRecords field %s", name)
  17924. }
  17925. // AddedEdges returns all edge names that were set/added in this mutation.
  17926. func (m *MessageRecordsMutation) AddedEdges() []string {
  17927. edges := make([]string, 0, 3)
  17928. if m.sop_stage != nil {
  17929. edges = append(edges, messagerecords.EdgeSopStage)
  17930. }
  17931. if m.sop_node != nil {
  17932. edges = append(edges, messagerecords.EdgeSopNode)
  17933. }
  17934. if m.message_contact != nil {
  17935. edges = append(edges, messagerecords.EdgeMessageContact)
  17936. }
  17937. return edges
  17938. }
  17939. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17940. // name in this mutation.
  17941. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  17942. switch name {
  17943. case messagerecords.EdgeSopStage:
  17944. if id := m.sop_stage; id != nil {
  17945. return []ent.Value{*id}
  17946. }
  17947. case messagerecords.EdgeSopNode:
  17948. if id := m.sop_node; id != nil {
  17949. return []ent.Value{*id}
  17950. }
  17951. case messagerecords.EdgeMessageContact:
  17952. if id := m.message_contact; id != nil {
  17953. return []ent.Value{*id}
  17954. }
  17955. }
  17956. return nil
  17957. }
  17958. // RemovedEdges returns all edge names that were removed in this mutation.
  17959. func (m *MessageRecordsMutation) RemovedEdges() []string {
  17960. edges := make([]string, 0, 3)
  17961. return edges
  17962. }
  17963. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  17964. // the given name in this mutation.
  17965. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  17966. return nil
  17967. }
  17968. // ClearedEdges returns all edge names that were cleared in this mutation.
  17969. func (m *MessageRecordsMutation) ClearedEdges() []string {
  17970. edges := make([]string, 0, 3)
  17971. if m.clearedsop_stage {
  17972. edges = append(edges, messagerecords.EdgeSopStage)
  17973. }
  17974. if m.clearedsop_node {
  17975. edges = append(edges, messagerecords.EdgeSopNode)
  17976. }
  17977. if m.clearedmessage_contact {
  17978. edges = append(edges, messagerecords.EdgeMessageContact)
  17979. }
  17980. return edges
  17981. }
  17982. // EdgeCleared returns a boolean which indicates if the edge with the given name
  17983. // was cleared in this mutation.
  17984. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  17985. switch name {
  17986. case messagerecords.EdgeSopStage:
  17987. return m.clearedsop_stage
  17988. case messagerecords.EdgeSopNode:
  17989. return m.clearedsop_node
  17990. case messagerecords.EdgeMessageContact:
  17991. return m.clearedmessage_contact
  17992. }
  17993. return false
  17994. }
  17995. // ClearEdge clears the value of the edge with the given name. It returns an error
  17996. // if that edge is not defined in the schema.
  17997. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  17998. switch name {
  17999. case messagerecords.EdgeSopStage:
  18000. m.ClearSopStage()
  18001. return nil
  18002. case messagerecords.EdgeSopNode:
  18003. m.ClearSopNode()
  18004. return nil
  18005. case messagerecords.EdgeMessageContact:
  18006. m.ClearMessageContact()
  18007. return nil
  18008. }
  18009. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18010. }
  18011. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18012. // It returns an error if the edge is not defined in the schema.
  18013. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18014. switch name {
  18015. case messagerecords.EdgeSopStage:
  18016. m.ResetSopStage()
  18017. return nil
  18018. case messagerecords.EdgeSopNode:
  18019. m.ResetSopNode()
  18020. return nil
  18021. case messagerecords.EdgeMessageContact:
  18022. m.ResetMessageContact()
  18023. return nil
  18024. }
  18025. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18026. }
  18027. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18028. type MsgMutation struct {
  18029. config
  18030. op Op
  18031. typ string
  18032. id *uint64
  18033. created_at *time.Time
  18034. updated_at *time.Time
  18035. deleted_at *time.Time
  18036. status *uint8
  18037. addstatus *int8
  18038. fromwxid *string
  18039. toid *string
  18040. msgtype *int32
  18041. addmsgtype *int32
  18042. msg *string
  18043. batch_no *string
  18044. clearedFields map[string]struct{}
  18045. done bool
  18046. oldValue func(context.Context) (*Msg, error)
  18047. predicates []predicate.Msg
  18048. }
  18049. var _ ent.Mutation = (*MsgMutation)(nil)
  18050. // msgOption allows management of the mutation configuration using functional options.
  18051. type msgOption func(*MsgMutation)
  18052. // newMsgMutation creates new mutation for the Msg entity.
  18053. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18054. m := &MsgMutation{
  18055. config: c,
  18056. op: op,
  18057. typ: TypeMsg,
  18058. clearedFields: make(map[string]struct{}),
  18059. }
  18060. for _, opt := range opts {
  18061. opt(m)
  18062. }
  18063. return m
  18064. }
  18065. // withMsgID sets the ID field of the mutation.
  18066. func withMsgID(id uint64) msgOption {
  18067. return func(m *MsgMutation) {
  18068. var (
  18069. err error
  18070. once sync.Once
  18071. value *Msg
  18072. )
  18073. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18074. once.Do(func() {
  18075. if m.done {
  18076. err = errors.New("querying old values post mutation is not allowed")
  18077. } else {
  18078. value, err = m.Client().Msg.Get(ctx, id)
  18079. }
  18080. })
  18081. return value, err
  18082. }
  18083. m.id = &id
  18084. }
  18085. }
  18086. // withMsg sets the old Msg of the mutation.
  18087. func withMsg(node *Msg) msgOption {
  18088. return func(m *MsgMutation) {
  18089. m.oldValue = func(context.Context) (*Msg, error) {
  18090. return node, nil
  18091. }
  18092. m.id = &node.ID
  18093. }
  18094. }
  18095. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18096. // executed in a transaction (ent.Tx), a transactional client is returned.
  18097. func (m MsgMutation) Client() *Client {
  18098. client := &Client{config: m.config}
  18099. client.init()
  18100. return client
  18101. }
  18102. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18103. // it returns an error otherwise.
  18104. func (m MsgMutation) Tx() (*Tx, error) {
  18105. if _, ok := m.driver.(*txDriver); !ok {
  18106. return nil, errors.New("ent: mutation is not running in a transaction")
  18107. }
  18108. tx := &Tx{config: m.config}
  18109. tx.init()
  18110. return tx, nil
  18111. }
  18112. // SetID sets the value of the id field. Note that this
  18113. // operation is only accepted on creation of Msg entities.
  18114. func (m *MsgMutation) SetID(id uint64) {
  18115. m.id = &id
  18116. }
  18117. // ID returns the ID value in the mutation. Note that the ID is only available
  18118. // if it was provided to the builder or after it was returned from the database.
  18119. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18120. if m.id == nil {
  18121. return
  18122. }
  18123. return *m.id, true
  18124. }
  18125. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18126. // That means, if the mutation is applied within a transaction with an isolation level such
  18127. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18128. // or updated by the mutation.
  18129. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18130. switch {
  18131. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18132. id, exists := m.ID()
  18133. if exists {
  18134. return []uint64{id}, nil
  18135. }
  18136. fallthrough
  18137. case m.op.Is(OpUpdate | OpDelete):
  18138. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18139. default:
  18140. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18141. }
  18142. }
  18143. // SetCreatedAt sets the "created_at" field.
  18144. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18145. m.created_at = &t
  18146. }
  18147. // CreatedAt returns the value of the "created_at" field in the mutation.
  18148. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18149. v := m.created_at
  18150. if v == nil {
  18151. return
  18152. }
  18153. return *v, true
  18154. }
  18155. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18156. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18158. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18159. if !m.op.Is(OpUpdateOne) {
  18160. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18161. }
  18162. if m.id == nil || m.oldValue == nil {
  18163. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18164. }
  18165. oldValue, err := m.oldValue(ctx)
  18166. if err != nil {
  18167. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18168. }
  18169. return oldValue.CreatedAt, nil
  18170. }
  18171. // ResetCreatedAt resets all changes to the "created_at" field.
  18172. func (m *MsgMutation) ResetCreatedAt() {
  18173. m.created_at = nil
  18174. }
  18175. // SetUpdatedAt sets the "updated_at" field.
  18176. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18177. m.updated_at = &t
  18178. }
  18179. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18180. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18181. v := m.updated_at
  18182. if v == nil {
  18183. return
  18184. }
  18185. return *v, true
  18186. }
  18187. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18188. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18190. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18191. if !m.op.Is(OpUpdateOne) {
  18192. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18193. }
  18194. if m.id == nil || m.oldValue == nil {
  18195. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18196. }
  18197. oldValue, err := m.oldValue(ctx)
  18198. if err != nil {
  18199. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18200. }
  18201. return oldValue.UpdatedAt, nil
  18202. }
  18203. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18204. func (m *MsgMutation) ResetUpdatedAt() {
  18205. m.updated_at = nil
  18206. }
  18207. // SetDeletedAt sets the "deleted_at" field.
  18208. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18209. m.deleted_at = &t
  18210. }
  18211. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18212. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18213. v := m.deleted_at
  18214. if v == nil {
  18215. return
  18216. }
  18217. return *v, true
  18218. }
  18219. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18220. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18221. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18222. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18223. if !m.op.Is(OpUpdateOne) {
  18224. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18225. }
  18226. if m.id == nil || m.oldValue == nil {
  18227. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18228. }
  18229. oldValue, err := m.oldValue(ctx)
  18230. if err != nil {
  18231. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18232. }
  18233. return oldValue.DeletedAt, nil
  18234. }
  18235. // ClearDeletedAt clears the value of the "deleted_at" field.
  18236. func (m *MsgMutation) ClearDeletedAt() {
  18237. m.deleted_at = nil
  18238. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18239. }
  18240. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18241. func (m *MsgMutation) DeletedAtCleared() bool {
  18242. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18243. return ok
  18244. }
  18245. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18246. func (m *MsgMutation) ResetDeletedAt() {
  18247. m.deleted_at = nil
  18248. delete(m.clearedFields, msg.FieldDeletedAt)
  18249. }
  18250. // SetStatus sets the "status" field.
  18251. func (m *MsgMutation) SetStatus(u uint8) {
  18252. m.status = &u
  18253. m.addstatus = nil
  18254. }
  18255. // Status returns the value of the "status" field in the mutation.
  18256. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18257. v := m.status
  18258. if v == nil {
  18259. return
  18260. }
  18261. return *v, true
  18262. }
  18263. // OldStatus returns the old "status" field's value of the Msg entity.
  18264. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18265. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18266. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18267. if !m.op.Is(OpUpdateOne) {
  18268. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18269. }
  18270. if m.id == nil || m.oldValue == nil {
  18271. return v, errors.New("OldStatus requires an ID field in the mutation")
  18272. }
  18273. oldValue, err := m.oldValue(ctx)
  18274. if err != nil {
  18275. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18276. }
  18277. return oldValue.Status, nil
  18278. }
  18279. // AddStatus adds u to the "status" field.
  18280. func (m *MsgMutation) AddStatus(u int8) {
  18281. if m.addstatus != nil {
  18282. *m.addstatus += u
  18283. } else {
  18284. m.addstatus = &u
  18285. }
  18286. }
  18287. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18288. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18289. v := m.addstatus
  18290. if v == nil {
  18291. return
  18292. }
  18293. return *v, true
  18294. }
  18295. // ClearStatus clears the value of the "status" field.
  18296. func (m *MsgMutation) ClearStatus() {
  18297. m.status = nil
  18298. m.addstatus = nil
  18299. m.clearedFields[msg.FieldStatus] = struct{}{}
  18300. }
  18301. // StatusCleared returns if the "status" field was cleared in this mutation.
  18302. func (m *MsgMutation) StatusCleared() bool {
  18303. _, ok := m.clearedFields[msg.FieldStatus]
  18304. return ok
  18305. }
  18306. // ResetStatus resets all changes to the "status" field.
  18307. func (m *MsgMutation) ResetStatus() {
  18308. m.status = nil
  18309. m.addstatus = nil
  18310. delete(m.clearedFields, msg.FieldStatus)
  18311. }
  18312. // SetFromwxid sets the "fromwxid" field.
  18313. func (m *MsgMutation) SetFromwxid(s string) {
  18314. m.fromwxid = &s
  18315. }
  18316. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18317. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18318. v := m.fromwxid
  18319. if v == nil {
  18320. return
  18321. }
  18322. return *v, true
  18323. }
  18324. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18325. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18327. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18328. if !m.op.Is(OpUpdateOne) {
  18329. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18330. }
  18331. if m.id == nil || m.oldValue == nil {
  18332. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18333. }
  18334. oldValue, err := m.oldValue(ctx)
  18335. if err != nil {
  18336. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18337. }
  18338. return oldValue.Fromwxid, nil
  18339. }
  18340. // ClearFromwxid clears the value of the "fromwxid" field.
  18341. func (m *MsgMutation) ClearFromwxid() {
  18342. m.fromwxid = nil
  18343. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18344. }
  18345. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18346. func (m *MsgMutation) FromwxidCleared() bool {
  18347. _, ok := m.clearedFields[msg.FieldFromwxid]
  18348. return ok
  18349. }
  18350. // ResetFromwxid resets all changes to the "fromwxid" field.
  18351. func (m *MsgMutation) ResetFromwxid() {
  18352. m.fromwxid = nil
  18353. delete(m.clearedFields, msg.FieldFromwxid)
  18354. }
  18355. // SetToid sets the "toid" field.
  18356. func (m *MsgMutation) SetToid(s string) {
  18357. m.toid = &s
  18358. }
  18359. // Toid returns the value of the "toid" field in the mutation.
  18360. func (m *MsgMutation) Toid() (r string, exists bool) {
  18361. v := m.toid
  18362. if v == nil {
  18363. return
  18364. }
  18365. return *v, true
  18366. }
  18367. // OldToid returns the old "toid" field's value of the Msg entity.
  18368. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18369. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18370. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18371. if !m.op.Is(OpUpdateOne) {
  18372. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18373. }
  18374. if m.id == nil || m.oldValue == nil {
  18375. return v, errors.New("OldToid requires an ID field in the mutation")
  18376. }
  18377. oldValue, err := m.oldValue(ctx)
  18378. if err != nil {
  18379. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18380. }
  18381. return oldValue.Toid, nil
  18382. }
  18383. // ClearToid clears the value of the "toid" field.
  18384. func (m *MsgMutation) ClearToid() {
  18385. m.toid = nil
  18386. m.clearedFields[msg.FieldToid] = struct{}{}
  18387. }
  18388. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18389. func (m *MsgMutation) ToidCleared() bool {
  18390. _, ok := m.clearedFields[msg.FieldToid]
  18391. return ok
  18392. }
  18393. // ResetToid resets all changes to the "toid" field.
  18394. func (m *MsgMutation) ResetToid() {
  18395. m.toid = nil
  18396. delete(m.clearedFields, msg.FieldToid)
  18397. }
  18398. // SetMsgtype sets the "msgtype" field.
  18399. func (m *MsgMutation) SetMsgtype(i int32) {
  18400. m.msgtype = &i
  18401. m.addmsgtype = nil
  18402. }
  18403. // Msgtype returns the value of the "msgtype" field in the mutation.
  18404. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18405. v := m.msgtype
  18406. if v == nil {
  18407. return
  18408. }
  18409. return *v, true
  18410. }
  18411. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18412. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18414. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18415. if !m.op.Is(OpUpdateOne) {
  18416. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18417. }
  18418. if m.id == nil || m.oldValue == nil {
  18419. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18420. }
  18421. oldValue, err := m.oldValue(ctx)
  18422. if err != nil {
  18423. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18424. }
  18425. return oldValue.Msgtype, nil
  18426. }
  18427. // AddMsgtype adds i to the "msgtype" field.
  18428. func (m *MsgMutation) AddMsgtype(i int32) {
  18429. if m.addmsgtype != nil {
  18430. *m.addmsgtype += i
  18431. } else {
  18432. m.addmsgtype = &i
  18433. }
  18434. }
  18435. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18436. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18437. v := m.addmsgtype
  18438. if v == nil {
  18439. return
  18440. }
  18441. return *v, true
  18442. }
  18443. // ClearMsgtype clears the value of the "msgtype" field.
  18444. func (m *MsgMutation) ClearMsgtype() {
  18445. m.msgtype = nil
  18446. m.addmsgtype = nil
  18447. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18448. }
  18449. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18450. func (m *MsgMutation) MsgtypeCleared() bool {
  18451. _, ok := m.clearedFields[msg.FieldMsgtype]
  18452. return ok
  18453. }
  18454. // ResetMsgtype resets all changes to the "msgtype" field.
  18455. func (m *MsgMutation) ResetMsgtype() {
  18456. m.msgtype = nil
  18457. m.addmsgtype = nil
  18458. delete(m.clearedFields, msg.FieldMsgtype)
  18459. }
  18460. // SetMsg sets the "msg" field.
  18461. func (m *MsgMutation) SetMsg(s string) {
  18462. m.msg = &s
  18463. }
  18464. // Msg returns the value of the "msg" field in the mutation.
  18465. func (m *MsgMutation) Msg() (r string, exists bool) {
  18466. v := m.msg
  18467. if v == nil {
  18468. return
  18469. }
  18470. return *v, true
  18471. }
  18472. // OldMsg returns the old "msg" field's value of the Msg entity.
  18473. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18475. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18476. if !m.op.Is(OpUpdateOne) {
  18477. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18478. }
  18479. if m.id == nil || m.oldValue == nil {
  18480. return v, errors.New("OldMsg requires an ID field in the mutation")
  18481. }
  18482. oldValue, err := m.oldValue(ctx)
  18483. if err != nil {
  18484. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18485. }
  18486. return oldValue.Msg, nil
  18487. }
  18488. // ClearMsg clears the value of the "msg" field.
  18489. func (m *MsgMutation) ClearMsg() {
  18490. m.msg = nil
  18491. m.clearedFields[msg.FieldMsg] = struct{}{}
  18492. }
  18493. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18494. func (m *MsgMutation) MsgCleared() bool {
  18495. _, ok := m.clearedFields[msg.FieldMsg]
  18496. return ok
  18497. }
  18498. // ResetMsg resets all changes to the "msg" field.
  18499. func (m *MsgMutation) ResetMsg() {
  18500. m.msg = nil
  18501. delete(m.clearedFields, msg.FieldMsg)
  18502. }
  18503. // SetBatchNo sets the "batch_no" field.
  18504. func (m *MsgMutation) SetBatchNo(s string) {
  18505. m.batch_no = &s
  18506. }
  18507. // BatchNo returns the value of the "batch_no" field in the mutation.
  18508. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18509. v := m.batch_no
  18510. if v == nil {
  18511. return
  18512. }
  18513. return *v, true
  18514. }
  18515. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18516. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18518. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18519. if !m.op.Is(OpUpdateOne) {
  18520. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18521. }
  18522. if m.id == nil || m.oldValue == nil {
  18523. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18524. }
  18525. oldValue, err := m.oldValue(ctx)
  18526. if err != nil {
  18527. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18528. }
  18529. return oldValue.BatchNo, nil
  18530. }
  18531. // ClearBatchNo clears the value of the "batch_no" field.
  18532. func (m *MsgMutation) ClearBatchNo() {
  18533. m.batch_no = nil
  18534. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18535. }
  18536. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18537. func (m *MsgMutation) BatchNoCleared() bool {
  18538. _, ok := m.clearedFields[msg.FieldBatchNo]
  18539. return ok
  18540. }
  18541. // ResetBatchNo resets all changes to the "batch_no" field.
  18542. func (m *MsgMutation) ResetBatchNo() {
  18543. m.batch_no = nil
  18544. delete(m.clearedFields, msg.FieldBatchNo)
  18545. }
  18546. // Where appends a list predicates to the MsgMutation builder.
  18547. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18548. m.predicates = append(m.predicates, ps...)
  18549. }
  18550. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18551. // users can use type-assertion to append predicates that do not depend on any generated package.
  18552. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18553. p := make([]predicate.Msg, len(ps))
  18554. for i := range ps {
  18555. p[i] = ps[i]
  18556. }
  18557. m.Where(p...)
  18558. }
  18559. // Op returns the operation name.
  18560. func (m *MsgMutation) Op() Op {
  18561. return m.op
  18562. }
  18563. // SetOp allows setting the mutation operation.
  18564. func (m *MsgMutation) SetOp(op Op) {
  18565. m.op = op
  18566. }
  18567. // Type returns the node type of this mutation (Msg).
  18568. func (m *MsgMutation) Type() string {
  18569. return m.typ
  18570. }
  18571. // Fields returns all fields that were changed during this mutation. Note that in
  18572. // order to get all numeric fields that were incremented/decremented, call
  18573. // AddedFields().
  18574. func (m *MsgMutation) Fields() []string {
  18575. fields := make([]string, 0, 9)
  18576. if m.created_at != nil {
  18577. fields = append(fields, msg.FieldCreatedAt)
  18578. }
  18579. if m.updated_at != nil {
  18580. fields = append(fields, msg.FieldUpdatedAt)
  18581. }
  18582. if m.deleted_at != nil {
  18583. fields = append(fields, msg.FieldDeletedAt)
  18584. }
  18585. if m.status != nil {
  18586. fields = append(fields, msg.FieldStatus)
  18587. }
  18588. if m.fromwxid != nil {
  18589. fields = append(fields, msg.FieldFromwxid)
  18590. }
  18591. if m.toid != nil {
  18592. fields = append(fields, msg.FieldToid)
  18593. }
  18594. if m.msgtype != nil {
  18595. fields = append(fields, msg.FieldMsgtype)
  18596. }
  18597. if m.msg != nil {
  18598. fields = append(fields, msg.FieldMsg)
  18599. }
  18600. if m.batch_no != nil {
  18601. fields = append(fields, msg.FieldBatchNo)
  18602. }
  18603. return fields
  18604. }
  18605. // Field returns the value of a field with the given name. The second boolean
  18606. // return value indicates that this field was not set, or was not defined in the
  18607. // schema.
  18608. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18609. switch name {
  18610. case msg.FieldCreatedAt:
  18611. return m.CreatedAt()
  18612. case msg.FieldUpdatedAt:
  18613. return m.UpdatedAt()
  18614. case msg.FieldDeletedAt:
  18615. return m.DeletedAt()
  18616. case msg.FieldStatus:
  18617. return m.Status()
  18618. case msg.FieldFromwxid:
  18619. return m.Fromwxid()
  18620. case msg.FieldToid:
  18621. return m.Toid()
  18622. case msg.FieldMsgtype:
  18623. return m.Msgtype()
  18624. case msg.FieldMsg:
  18625. return m.Msg()
  18626. case msg.FieldBatchNo:
  18627. return m.BatchNo()
  18628. }
  18629. return nil, false
  18630. }
  18631. // OldField returns the old value of the field from the database. An error is
  18632. // returned if the mutation operation is not UpdateOne, or the query to the
  18633. // database failed.
  18634. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18635. switch name {
  18636. case msg.FieldCreatedAt:
  18637. return m.OldCreatedAt(ctx)
  18638. case msg.FieldUpdatedAt:
  18639. return m.OldUpdatedAt(ctx)
  18640. case msg.FieldDeletedAt:
  18641. return m.OldDeletedAt(ctx)
  18642. case msg.FieldStatus:
  18643. return m.OldStatus(ctx)
  18644. case msg.FieldFromwxid:
  18645. return m.OldFromwxid(ctx)
  18646. case msg.FieldToid:
  18647. return m.OldToid(ctx)
  18648. case msg.FieldMsgtype:
  18649. return m.OldMsgtype(ctx)
  18650. case msg.FieldMsg:
  18651. return m.OldMsg(ctx)
  18652. case msg.FieldBatchNo:
  18653. return m.OldBatchNo(ctx)
  18654. }
  18655. return nil, fmt.Errorf("unknown Msg field %s", name)
  18656. }
  18657. // SetField sets the value of a field with the given name. It returns an error if
  18658. // the field is not defined in the schema, or if the type mismatched the field
  18659. // type.
  18660. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18661. switch name {
  18662. case msg.FieldCreatedAt:
  18663. v, ok := value.(time.Time)
  18664. if !ok {
  18665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18666. }
  18667. m.SetCreatedAt(v)
  18668. return nil
  18669. case msg.FieldUpdatedAt:
  18670. v, ok := value.(time.Time)
  18671. if !ok {
  18672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18673. }
  18674. m.SetUpdatedAt(v)
  18675. return nil
  18676. case msg.FieldDeletedAt:
  18677. v, ok := value.(time.Time)
  18678. if !ok {
  18679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18680. }
  18681. m.SetDeletedAt(v)
  18682. return nil
  18683. case msg.FieldStatus:
  18684. v, ok := value.(uint8)
  18685. if !ok {
  18686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18687. }
  18688. m.SetStatus(v)
  18689. return nil
  18690. case msg.FieldFromwxid:
  18691. v, ok := value.(string)
  18692. if !ok {
  18693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18694. }
  18695. m.SetFromwxid(v)
  18696. return nil
  18697. case msg.FieldToid:
  18698. v, ok := value.(string)
  18699. if !ok {
  18700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18701. }
  18702. m.SetToid(v)
  18703. return nil
  18704. case msg.FieldMsgtype:
  18705. v, ok := value.(int32)
  18706. if !ok {
  18707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18708. }
  18709. m.SetMsgtype(v)
  18710. return nil
  18711. case msg.FieldMsg:
  18712. v, ok := value.(string)
  18713. if !ok {
  18714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18715. }
  18716. m.SetMsg(v)
  18717. return nil
  18718. case msg.FieldBatchNo:
  18719. v, ok := value.(string)
  18720. if !ok {
  18721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18722. }
  18723. m.SetBatchNo(v)
  18724. return nil
  18725. }
  18726. return fmt.Errorf("unknown Msg field %s", name)
  18727. }
  18728. // AddedFields returns all numeric fields that were incremented/decremented during
  18729. // this mutation.
  18730. func (m *MsgMutation) AddedFields() []string {
  18731. var fields []string
  18732. if m.addstatus != nil {
  18733. fields = append(fields, msg.FieldStatus)
  18734. }
  18735. if m.addmsgtype != nil {
  18736. fields = append(fields, msg.FieldMsgtype)
  18737. }
  18738. return fields
  18739. }
  18740. // AddedField returns the numeric value that was incremented/decremented on a field
  18741. // with the given name. The second boolean return value indicates that this field
  18742. // was not set, or was not defined in the schema.
  18743. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18744. switch name {
  18745. case msg.FieldStatus:
  18746. return m.AddedStatus()
  18747. case msg.FieldMsgtype:
  18748. return m.AddedMsgtype()
  18749. }
  18750. return nil, false
  18751. }
  18752. // AddField adds the value to the field with the given name. It returns an error if
  18753. // the field is not defined in the schema, or if the type mismatched the field
  18754. // type.
  18755. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18756. switch name {
  18757. case msg.FieldStatus:
  18758. v, ok := value.(int8)
  18759. if !ok {
  18760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18761. }
  18762. m.AddStatus(v)
  18763. return nil
  18764. case msg.FieldMsgtype:
  18765. v, ok := value.(int32)
  18766. if !ok {
  18767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18768. }
  18769. m.AddMsgtype(v)
  18770. return nil
  18771. }
  18772. return fmt.Errorf("unknown Msg numeric field %s", name)
  18773. }
  18774. // ClearedFields returns all nullable fields that were cleared during this
  18775. // mutation.
  18776. func (m *MsgMutation) ClearedFields() []string {
  18777. var fields []string
  18778. if m.FieldCleared(msg.FieldDeletedAt) {
  18779. fields = append(fields, msg.FieldDeletedAt)
  18780. }
  18781. if m.FieldCleared(msg.FieldStatus) {
  18782. fields = append(fields, msg.FieldStatus)
  18783. }
  18784. if m.FieldCleared(msg.FieldFromwxid) {
  18785. fields = append(fields, msg.FieldFromwxid)
  18786. }
  18787. if m.FieldCleared(msg.FieldToid) {
  18788. fields = append(fields, msg.FieldToid)
  18789. }
  18790. if m.FieldCleared(msg.FieldMsgtype) {
  18791. fields = append(fields, msg.FieldMsgtype)
  18792. }
  18793. if m.FieldCleared(msg.FieldMsg) {
  18794. fields = append(fields, msg.FieldMsg)
  18795. }
  18796. if m.FieldCleared(msg.FieldBatchNo) {
  18797. fields = append(fields, msg.FieldBatchNo)
  18798. }
  18799. return fields
  18800. }
  18801. // FieldCleared returns a boolean indicating if a field with the given name was
  18802. // cleared in this mutation.
  18803. func (m *MsgMutation) FieldCleared(name string) bool {
  18804. _, ok := m.clearedFields[name]
  18805. return ok
  18806. }
  18807. // ClearField clears the value of the field with the given name. It returns an
  18808. // error if the field is not defined in the schema.
  18809. func (m *MsgMutation) ClearField(name string) error {
  18810. switch name {
  18811. case msg.FieldDeletedAt:
  18812. m.ClearDeletedAt()
  18813. return nil
  18814. case msg.FieldStatus:
  18815. m.ClearStatus()
  18816. return nil
  18817. case msg.FieldFromwxid:
  18818. m.ClearFromwxid()
  18819. return nil
  18820. case msg.FieldToid:
  18821. m.ClearToid()
  18822. return nil
  18823. case msg.FieldMsgtype:
  18824. m.ClearMsgtype()
  18825. return nil
  18826. case msg.FieldMsg:
  18827. m.ClearMsg()
  18828. return nil
  18829. case msg.FieldBatchNo:
  18830. m.ClearBatchNo()
  18831. return nil
  18832. }
  18833. return fmt.Errorf("unknown Msg nullable field %s", name)
  18834. }
  18835. // ResetField resets all changes in the mutation for the field with the given name.
  18836. // It returns an error if the field is not defined in the schema.
  18837. func (m *MsgMutation) ResetField(name string) error {
  18838. switch name {
  18839. case msg.FieldCreatedAt:
  18840. m.ResetCreatedAt()
  18841. return nil
  18842. case msg.FieldUpdatedAt:
  18843. m.ResetUpdatedAt()
  18844. return nil
  18845. case msg.FieldDeletedAt:
  18846. m.ResetDeletedAt()
  18847. return nil
  18848. case msg.FieldStatus:
  18849. m.ResetStatus()
  18850. return nil
  18851. case msg.FieldFromwxid:
  18852. m.ResetFromwxid()
  18853. return nil
  18854. case msg.FieldToid:
  18855. m.ResetToid()
  18856. return nil
  18857. case msg.FieldMsgtype:
  18858. m.ResetMsgtype()
  18859. return nil
  18860. case msg.FieldMsg:
  18861. m.ResetMsg()
  18862. return nil
  18863. case msg.FieldBatchNo:
  18864. m.ResetBatchNo()
  18865. return nil
  18866. }
  18867. return fmt.Errorf("unknown Msg field %s", name)
  18868. }
  18869. // AddedEdges returns all edge names that were set/added in this mutation.
  18870. func (m *MsgMutation) AddedEdges() []string {
  18871. edges := make([]string, 0, 0)
  18872. return edges
  18873. }
  18874. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18875. // name in this mutation.
  18876. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18877. return nil
  18878. }
  18879. // RemovedEdges returns all edge names that were removed in this mutation.
  18880. func (m *MsgMutation) RemovedEdges() []string {
  18881. edges := make([]string, 0, 0)
  18882. return edges
  18883. }
  18884. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18885. // the given name in this mutation.
  18886. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18887. return nil
  18888. }
  18889. // ClearedEdges returns all edge names that were cleared in this mutation.
  18890. func (m *MsgMutation) ClearedEdges() []string {
  18891. edges := make([]string, 0, 0)
  18892. return edges
  18893. }
  18894. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18895. // was cleared in this mutation.
  18896. func (m *MsgMutation) EdgeCleared(name string) bool {
  18897. return false
  18898. }
  18899. // ClearEdge clears the value of the edge with the given name. It returns an error
  18900. // if that edge is not defined in the schema.
  18901. func (m *MsgMutation) ClearEdge(name string) error {
  18902. return fmt.Errorf("unknown Msg unique edge %s", name)
  18903. }
  18904. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18905. // It returns an error if the edge is not defined in the schema.
  18906. func (m *MsgMutation) ResetEdge(name string) error {
  18907. return fmt.Errorf("unknown Msg edge %s", name)
  18908. }
  18909. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  18910. type PayRechargeMutation struct {
  18911. config
  18912. op Op
  18913. typ string
  18914. id *uint64
  18915. created_at *time.Time
  18916. updated_at *time.Time
  18917. deleted_at *time.Time
  18918. user_id *string
  18919. number *float32
  18920. addnumber *float32
  18921. status *int
  18922. addstatus *int
  18923. money *float32
  18924. addmoney *float32
  18925. out_trade_no *string
  18926. organization_id *uint64
  18927. addorganization_id *int64
  18928. clearedFields map[string]struct{}
  18929. done bool
  18930. oldValue func(context.Context) (*PayRecharge, error)
  18931. predicates []predicate.PayRecharge
  18932. }
  18933. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  18934. // payrechargeOption allows management of the mutation configuration using functional options.
  18935. type payrechargeOption func(*PayRechargeMutation)
  18936. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  18937. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  18938. m := &PayRechargeMutation{
  18939. config: c,
  18940. op: op,
  18941. typ: TypePayRecharge,
  18942. clearedFields: make(map[string]struct{}),
  18943. }
  18944. for _, opt := range opts {
  18945. opt(m)
  18946. }
  18947. return m
  18948. }
  18949. // withPayRechargeID sets the ID field of the mutation.
  18950. func withPayRechargeID(id uint64) payrechargeOption {
  18951. return func(m *PayRechargeMutation) {
  18952. var (
  18953. err error
  18954. once sync.Once
  18955. value *PayRecharge
  18956. )
  18957. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  18958. once.Do(func() {
  18959. if m.done {
  18960. err = errors.New("querying old values post mutation is not allowed")
  18961. } else {
  18962. value, err = m.Client().PayRecharge.Get(ctx, id)
  18963. }
  18964. })
  18965. return value, err
  18966. }
  18967. m.id = &id
  18968. }
  18969. }
  18970. // withPayRecharge sets the old PayRecharge of the mutation.
  18971. func withPayRecharge(node *PayRecharge) payrechargeOption {
  18972. return func(m *PayRechargeMutation) {
  18973. m.oldValue = func(context.Context) (*PayRecharge, error) {
  18974. return node, nil
  18975. }
  18976. m.id = &node.ID
  18977. }
  18978. }
  18979. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18980. // executed in a transaction (ent.Tx), a transactional client is returned.
  18981. func (m PayRechargeMutation) Client() *Client {
  18982. client := &Client{config: m.config}
  18983. client.init()
  18984. return client
  18985. }
  18986. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18987. // it returns an error otherwise.
  18988. func (m PayRechargeMutation) Tx() (*Tx, error) {
  18989. if _, ok := m.driver.(*txDriver); !ok {
  18990. return nil, errors.New("ent: mutation is not running in a transaction")
  18991. }
  18992. tx := &Tx{config: m.config}
  18993. tx.init()
  18994. return tx, nil
  18995. }
  18996. // SetID sets the value of the id field. Note that this
  18997. // operation is only accepted on creation of PayRecharge entities.
  18998. func (m *PayRechargeMutation) SetID(id uint64) {
  18999. m.id = &id
  19000. }
  19001. // ID returns the ID value in the mutation. Note that the ID is only available
  19002. // if it was provided to the builder or after it was returned from the database.
  19003. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19004. if m.id == nil {
  19005. return
  19006. }
  19007. return *m.id, true
  19008. }
  19009. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19010. // That means, if the mutation is applied within a transaction with an isolation level such
  19011. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19012. // or updated by the mutation.
  19013. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19014. switch {
  19015. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19016. id, exists := m.ID()
  19017. if exists {
  19018. return []uint64{id}, nil
  19019. }
  19020. fallthrough
  19021. case m.op.Is(OpUpdate | OpDelete):
  19022. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19023. default:
  19024. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19025. }
  19026. }
  19027. // SetCreatedAt sets the "created_at" field.
  19028. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19029. m.created_at = &t
  19030. }
  19031. // CreatedAt returns the value of the "created_at" field in the mutation.
  19032. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19033. v := m.created_at
  19034. if v == nil {
  19035. return
  19036. }
  19037. return *v, true
  19038. }
  19039. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19040. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19042. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19043. if !m.op.Is(OpUpdateOne) {
  19044. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19045. }
  19046. if m.id == nil || m.oldValue == nil {
  19047. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19048. }
  19049. oldValue, err := m.oldValue(ctx)
  19050. if err != nil {
  19051. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19052. }
  19053. return oldValue.CreatedAt, nil
  19054. }
  19055. // ResetCreatedAt resets all changes to the "created_at" field.
  19056. func (m *PayRechargeMutation) ResetCreatedAt() {
  19057. m.created_at = nil
  19058. }
  19059. // SetUpdatedAt sets the "updated_at" field.
  19060. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19061. m.updated_at = &t
  19062. }
  19063. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19064. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19065. v := m.updated_at
  19066. if v == nil {
  19067. return
  19068. }
  19069. return *v, true
  19070. }
  19071. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19072. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19074. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19075. if !m.op.Is(OpUpdateOne) {
  19076. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19077. }
  19078. if m.id == nil || m.oldValue == nil {
  19079. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19080. }
  19081. oldValue, err := m.oldValue(ctx)
  19082. if err != nil {
  19083. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19084. }
  19085. return oldValue.UpdatedAt, nil
  19086. }
  19087. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19088. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19089. m.updated_at = nil
  19090. }
  19091. // SetDeletedAt sets the "deleted_at" field.
  19092. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19093. m.deleted_at = &t
  19094. }
  19095. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19096. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19097. v := m.deleted_at
  19098. if v == nil {
  19099. return
  19100. }
  19101. return *v, true
  19102. }
  19103. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19104. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19105. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19106. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19107. if !m.op.Is(OpUpdateOne) {
  19108. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19109. }
  19110. if m.id == nil || m.oldValue == nil {
  19111. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19112. }
  19113. oldValue, err := m.oldValue(ctx)
  19114. if err != nil {
  19115. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19116. }
  19117. return oldValue.DeletedAt, nil
  19118. }
  19119. // ClearDeletedAt clears the value of the "deleted_at" field.
  19120. func (m *PayRechargeMutation) ClearDeletedAt() {
  19121. m.deleted_at = nil
  19122. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19123. }
  19124. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19125. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19126. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19127. return ok
  19128. }
  19129. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19130. func (m *PayRechargeMutation) ResetDeletedAt() {
  19131. m.deleted_at = nil
  19132. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19133. }
  19134. // SetUserID sets the "user_id" field.
  19135. func (m *PayRechargeMutation) SetUserID(s string) {
  19136. m.user_id = &s
  19137. }
  19138. // UserID returns the value of the "user_id" field in the mutation.
  19139. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19140. v := m.user_id
  19141. if v == nil {
  19142. return
  19143. }
  19144. return *v, true
  19145. }
  19146. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19147. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19148. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19149. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19150. if !m.op.Is(OpUpdateOne) {
  19151. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19152. }
  19153. if m.id == nil || m.oldValue == nil {
  19154. return v, errors.New("OldUserID requires an ID field in the mutation")
  19155. }
  19156. oldValue, err := m.oldValue(ctx)
  19157. if err != nil {
  19158. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19159. }
  19160. return oldValue.UserID, nil
  19161. }
  19162. // ResetUserID resets all changes to the "user_id" field.
  19163. func (m *PayRechargeMutation) ResetUserID() {
  19164. m.user_id = nil
  19165. }
  19166. // SetNumber sets the "number" field.
  19167. func (m *PayRechargeMutation) SetNumber(f float32) {
  19168. m.number = &f
  19169. m.addnumber = nil
  19170. }
  19171. // Number returns the value of the "number" field in the mutation.
  19172. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19173. v := m.number
  19174. if v == nil {
  19175. return
  19176. }
  19177. return *v, true
  19178. }
  19179. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19180. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19182. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19183. if !m.op.Is(OpUpdateOne) {
  19184. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19185. }
  19186. if m.id == nil || m.oldValue == nil {
  19187. return v, errors.New("OldNumber requires an ID field in the mutation")
  19188. }
  19189. oldValue, err := m.oldValue(ctx)
  19190. if err != nil {
  19191. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19192. }
  19193. return oldValue.Number, nil
  19194. }
  19195. // AddNumber adds f to the "number" field.
  19196. func (m *PayRechargeMutation) AddNumber(f float32) {
  19197. if m.addnumber != nil {
  19198. *m.addnumber += f
  19199. } else {
  19200. m.addnumber = &f
  19201. }
  19202. }
  19203. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19204. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19205. v := m.addnumber
  19206. if v == nil {
  19207. return
  19208. }
  19209. return *v, true
  19210. }
  19211. // ResetNumber resets all changes to the "number" field.
  19212. func (m *PayRechargeMutation) ResetNumber() {
  19213. m.number = nil
  19214. m.addnumber = nil
  19215. }
  19216. // SetStatus sets the "status" field.
  19217. func (m *PayRechargeMutation) SetStatus(i int) {
  19218. m.status = &i
  19219. m.addstatus = nil
  19220. }
  19221. // Status returns the value of the "status" field in the mutation.
  19222. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19223. v := m.status
  19224. if v == nil {
  19225. return
  19226. }
  19227. return *v, true
  19228. }
  19229. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19230. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19232. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19233. if !m.op.Is(OpUpdateOne) {
  19234. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19235. }
  19236. if m.id == nil || m.oldValue == nil {
  19237. return v, errors.New("OldStatus requires an ID field in the mutation")
  19238. }
  19239. oldValue, err := m.oldValue(ctx)
  19240. if err != nil {
  19241. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19242. }
  19243. return oldValue.Status, nil
  19244. }
  19245. // AddStatus adds i to the "status" field.
  19246. func (m *PayRechargeMutation) AddStatus(i int) {
  19247. if m.addstatus != nil {
  19248. *m.addstatus += i
  19249. } else {
  19250. m.addstatus = &i
  19251. }
  19252. }
  19253. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19254. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19255. v := m.addstatus
  19256. if v == nil {
  19257. return
  19258. }
  19259. return *v, true
  19260. }
  19261. // ClearStatus clears the value of the "status" field.
  19262. func (m *PayRechargeMutation) ClearStatus() {
  19263. m.status = nil
  19264. m.addstatus = nil
  19265. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19266. }
  19267. // StatusCleared returns if the "status" field was cleared in this mutation.
  19268. func (m *PayRechargeMutation) StatusCleared() bool {
  19269. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19270. return ok
  19271. }
  19272. // ResetStatus resets all changes to the "status" field.
  19273. func (m *PayRechargeMutation) ResetStatus() {
  19274. m.status = nil
  19275. m.addstatus = nil
  19276. delete(m.clearedFields, payrecharge.FieldStatus)
  19277. }
  19278. // SetMoney sets the "money" field.
  19279. func (m *PayRechargeMutation) SetMoney(f float32) {
  19280. m.money = &f
  19281. m.addmoney = nil
  19282. }
  19283. // Money returns the value of the "money" field in the mutation.
  19284. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19285. v := m.money
  19286. if v == nil {
  19287. return
  19288. }
  19289. return *v, true
  19290. }
  19291. // OldMoney returns the old "money" 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) OldMoney(ctx context.Context) (v float32, err error) {
  19295. if !m.op.Is(OpUpdateOne) {
  19296. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19297. }
  19298. if m.id == nil || m.oldValue == nil {
  19299. return v, errors.New("OldMoney 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 OldMoney: %w", err)
  19304. }
  19305. return oldValue.Money, nil
  19306. }
  19307. // AddMoney adds f to the "money" field.
  19308. func (m *PayRechargeMutation) AddMoney(f float32) {
  19309. if m.addmoney != nil {
  19310. *m.addmoney += f
  19311. } else {
  19312. m.addmoney = &f
  19313. }
  19314. }
  19315. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19316. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19317. v := m.addmoney
  19318. if v == nil {
  19319. return
  19320. }
  19321. return *v, true
  19322. }
  19323. // ClearMoney clears the value of the "money" field.
  19324. func (m *PayRechargeMutation) ClearMoney() {
  19325. m.money = nil
  19326. m.addmoney = nil
  19327. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19328. }
  19329. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19330. func (m *PayRechargeMutation) MoneyCleared() bool {
  19331. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19332. return ok
  19333. }
  19334. // ResetMoney resets all changes to the "money" field.
  19335. func (m *PayRechargeMutation) ResetMoney() {
  19336. m.money = nil
  19337. m.addmoney = nil
  19338. delete(m.clearedFields, payrecharge.FieldMoney)
  19339. }
  19340. // SetOutTradeNo sets the "out_trade_no" field.
  19341. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19342. m.out_trade_no = &s
  19343. }
  19344. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19345. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19346. v := m.out_trade_no
  19347. if v == nil {
  19348. return
  19349. }
  19350. return *v, true
  19351. }
  19352. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19353. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19355. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19356. if !m.op.Is(OpUpdateOne) {
  19357. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19358. }
  19359. if m.id == nil || m.oldValue == nil {
  19360. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19361. }
  19362. oldValue, err := m.oldValue(ctx)
  19363. if err != nil {
  19364. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19365. }
  19366. return oldValue.OutTradeNo, nil
  19367. }
  19368. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19369. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19370. m.out_trade_no = nil
  19371. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19372. }
  19373. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19374. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19375. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19376. return ok
  19377. }
  19378. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19379. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19380. m.out_trade_no = nil
  19381. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19382. }
  19383. // SetOrganizationID sets the "organization_id" field.
  19384. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19385. m.organization_id = &u
  19386. m.addorganization_id = nil
  19387. }
  19388. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19389. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19390. v := m.organization_id
  19391. if v == nil {
  19392. return
  19393. }
  19394. return *v, true
  19395. }
  19396. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19397. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19399. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19400. if !m.op.Is(OpUpdateOne) {
  19401. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19402. }
  19403. if m.id == nil || m.oldValue == nil {
  19404. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19405. }
  19406. oldValue, err := m.oldValue(ctx)
  19407. if err != nil {
  19408. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19409. }
  19410. return oldValue.OrganizationID, nil
  19411. }
  19412. // AddOrganizationID adds u to the "organization_id" field.
  19413. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19414. if m.addorganization_id != nil {
  19415. *m.addorganization_id += u
  19416. } else {
  19417. m.addorganization_id = &u
  19418. }
  19419. }
  19420. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19421. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19422. v := m.addorganization_id
  19423. if v == nil {
  19424. return
  19425. }
  19426. return *v, true
  19427. }
  19428. // ResetOrganizationID resets all changes to the "organization_id" field.
  19429. func (m *PayRechargeMutation) ResetOrganizationID() {
  19430. m.organization_id = nil
  19431. m.addorganization_id = nil
  19432. }
  19433. // Where appends a list predicates to the PayRechargeMutation builder.
  19434. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19435. m.predicates = append(m.predicates, ps...)
  19436. }
  19437. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19438. // users can use type-assertion to append predicates that do not depend on any generated package.
  19439. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19440. p := make([]predicate.PayRecharge, len(ps))
  19441. for i := range ps {
  19442. p[i] = ps[i]
  19443. }
  19444. m.Where(p...)
  19445. }
  19446. // Op returns the operation name.
  19447. func (m *PayRechargeMutation) Op() Op {
  19448. return m.op
  19449. }
  19450. // SetOp allows setting the mutation operation.
  19451. func (m *PayRechargeMutation) SetOp(op Op) {
  19452. m.op = op
  19453. }
  19454. // Type returns the node type of this mutation (PayRecharge).
  19455. func (m *PayRechargeMutation) Type() string {
  19456. return m.typ
  19457. }
  19458. // Fields returns all fields that were changed during this mutation. Note that in
  19459. // order to get all numeric fields that were incremented/decremented, call
  19460. // AddedFields().
  19461. func (m *PayRechargeMutation) Fields() []string {
  19462. fields := make([]string, 0, 9)
  19463. if m.created_at != nil {
  19464. fields = append(fields, payrecharge.FieldCreatedAt)
  19465. }
  19466. if m.updated_at != nil {
  19467. fields = append(fields, payrecharge.FieldUpdatedAt)
  19468. }
  19469. if m.deleted_at != nil {
  19470. fields = append(fields, payrecharge.FieldDeletedAt)
  19471. }
  19472. if m.user_id != nil {
  19473. fields = append(fields, payrecharge.FieldUserID)
  19474. }
  19475. if m.number != nil {
  19476. fields = append(fields, payrecharge.FieldNumber)
  19477. }
  19478. if m.status != nil {
  19479. fields = append(fields, payrecharge.FieldStatus)
  19480. }
  19481. if m.money != nil {
  19482. fields = append(fields, payrecharge.FieldMoney)
  19483. }
  19484. if m.out_trade_no != nil {
  19485. fields = append(fields, payrecharge.FieldOutTradeNo)
  19486. }
  19487. if m.organization_id != nil {
  19488. fields = append(fields, payrecharge.FieldOrganizationID)
  19489. }
  19490. return fields
  19491. }
  19492. // Field returns the value of a field with the given name. The second boolean
  19493. // return value indicates that this field was not set, or was not defined in the
  19494. // schema.
  19495. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19496. switch name {
  19497. case payrecharge.FieldCreatedAt:
  19498. return m.CreatedAt()
  19499. case payrecharge.FieldUpdatedAt:
  19500. return m.UpdatedAt()
  19501. case payrecharge.FieldDeletedAt:
  19502. return m.DeletedAt()
  19503. case payrecharge.FieldUserID:
  19504. return m.UserID()
  19505. case payrecharge.FieldNumber:
  19506. return m.Number()
  19507. case payrecharge.FieldStatus:
  19508. return m.Status()
  19509. case payrecharge.FieldMoney:
  19510. return m.Money()
  19511. case payrecharge.FieldOutTradeNo:
  19512. return m.OutTradeNo()
  19513. case payrecharge.FieldOrganizationID:
  19514. return m.OrganizationID()
  19515. }
  19516. return nil, false
  19517. }
  19518. // OldField returns the old value of the field from the database. An error is
  19519. // returned if the mutation operation is not UpdateOne, or the query to the
  19520. // database failed.
  19521. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19522. switch name {
  19523. case payrecharge.FieldCreatedAt:
  19524. return m.OldCreatedAt(ctx)
  19525. case payrecharge.FieldUpdatedAt:
  19526. return m.OldUpdatedAt(ctx)
  19527. case payrecharge.FieldDeletedAt:
  19528. return m.OldDeletedAt(ctx)
  19529. case payrecharge.FieldUserID:
  19530. return m.OldUserID(ctx)
  19531. case payrecharge.FieldNumber:
  19532. return m.OldNumber(ctx)
  19533. case payrecharge.FieldStatus:
  19534. return m.OldStatus(ctx)
  19535. case payrecharge.FieldMoney:
  19536. return m.OldMoney(ctx)
  19537. case payrecharge.FieldOutTradeNo:
  19538. return m.OldOutTradeNo(ctx)
  19539. case payrecharge.FieldOrganizationID:
  19540. return m.OldOrganizationID(ctx)
  19541. }
  19542. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19543. }
  19544. // SetField sets the value of a field with the given name. It returns an error if
  19545. // the field is not defined in the schema, or if the type mismatched the field
  19546. // type.
  19547. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19548. switch name {
  19549. case payrecharge.FieldCreatedAt:
  19550. v, ok := value.(time.Time)
  19551. if !ok {
  19552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19553. }
  19554. m.SetCreatedAt(v)
  19555. return nil
  19556. case payrecharge.FieldUpdatedAt:
  19557. v, ok := value.(time.Time)
  19558. if !ok {
  19559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19560. }
  19561. m.SetUpdatedAt(v)
  19562. return nil
  19563. case payrecharge.FieldDeletedAt:
  19564. v, ok := value.(time.Time)
  19565. if !ok {
  19566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19567. }
  19568. m.SetDeletedAt(v)
  19569. return nil
  19570. case payrecharge.FieldUserID:
  19571. v, ok := value.(string)
  19572. if !ok {
  19573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19574. }
  19575. m.SetUserID(v)
  19576. return nil
  19577. case payrecharge.FieldNumber:
  19578. v, ok := value.(float32)
  19579. if !ok {
  19580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19581. }
  19582. m.SetNumber(v)
  19583. return nil
  19584. case payrecharge.FieldStatus:
  19585. v, ok := value.(int)
  19586. if !ok {
  19587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19588. }
  19589. m.SetStatus(v)
  19590. return nil
  19591. case payrecharge.FieldMoney:
  19592. v, ok := value.(float32)
  19593. if !ok {
  19594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19595. }
  19596. m.SetMoney(v)
  19597. return nil
  19598. case payrecharge.FieldOutTradeNo:
  19599. v, ok := value.(string)
  19600. if !ok {
  19601. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19602. }
  19603. m.SetOutTradeNo(v)
  19604. return nil
  19605. case payrecharge.FieldOrganizationID:
  19606. v, ok := value.(uint64)
  19607. if !ok {
  19608. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19609. }
  19610. m.SetOrganizationID(v)
  19611. return nil
  19612. }
  19613. return fmt.Errorf("unknown PayRecharge field %s", name)
  19614. }
  19615. // AddedFields returns all numeric fields that were incremented/decremented during
  19616. // this mutation.
  19617. func (m *PayRechargeMutation) AddedFields() []string {
  19618. var fields []string
  19619. if m.addnumber != nil {
  19620. fields = append(fields, payrecharge.FieldNumber)
  19621. }
  19622. if m.addstatus != nil {
  19623. fields = append(fields, payrecharge.FieldStatus)
  19624. }
  19625. if m.addmoney != nil {
  19626. fields = append(fields, payrecharge.FieldMoney)
  19627. }
  19628. if m.addorganization_id != nil {
  19629. fields = append(fields, payrecharge.FieldOrganizationID)
  19630. }
  19631. return fields
  19632. }
  19633. // AddedField returns the numeric value that was incremented/decremented on a field
  19634. // with the given name. The second boolean return value indicates that this field
  19635. // was not set, or was not defined in the schema.
  19636. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19637. switch name {
  19638. case payrecharge.FieldNumber:
  19639. return m.AddedNumber()
  19640. case payrecharge.FieldStatus:
  19641. return m.AddedStatus()
  19642. case payrecharge.FieldMoney:
  19643. return m.AddedMoney()
  19644. case payrecharge.FieldOrganizationID:
  19645. return m.AddedOrganizationID()
  19646. }
  19647. return nil, false
  19648. }
  19649. // AddField adds the value to the field with the given name. It returns an error if
  19650. // the field is not defined in the schema, or if the type mismatched the field
  19651. // type.
  19652. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19653. switch name {
  19654. case payrecharge.FieldNumber:
  19655. v, ok := value.(float32)
  19656. if !ok {
  19657. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19658. }
  19659. m.AddNumber(v)
  19660. return nil
  19661. case payrecharge.FieldStatus:
  19662. v, ok := value.(int)
  19663. if !ok {
  19664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19665. }
  19666. m.AddStatus(v)
  19667. return nil
  19668. case payrecharge.FieldMoney:
  19669. v, ok := value.(float32)
  19670. if !ok {
  19671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19672. }
  19673. m.AddMoney(v)
  19674. return nil
  19675. case payrecharge.FieldOrganizationID:
  19676. v, ok := value.(int64)
  19677. if !ok {
  19678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19679. }
  19680. m.AddOrganizationID(v)
  19681. return nil
  19682. }
  19683. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19684. }
  19685. // ClearedFields returns all nullable fields that were cleared during this
  19686. // mutation.
  19687. func (m *PayRechargeMutation) ClearedFields() []string {
  19688. var fields []string
  19689. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19690. fields = append(fields, payrecharge.FieldDeletedAt)
  19691. }
  19692. if m.FieldCleared(payrecharge.FieldStatus) {
  19693. fields = append(fields, payrecharge.FieldStatus)
  19694. }
  19695. if m.FieldCleared(payrecharge.FieldMoney) {
  19696. fields = append(fields, payrecharge.FieldMoney)
  19697. }
  19698. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19699. fields = append(fields, payrecharge.FieldOutTradeNo)
  19700. }
  19701. return fields
  19702. }
  19703. // FieldCleared returns a boolean indicating if a field with the given name was
  19704. // cleared in this mutation.
  19705. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19706. _, ok := m.clearedFields[name]
  19707. return ok
  19708. }
  19709. // ClearField clears the value of the field with the given name. It returns an
  19710. // error if the field is not defined in the schema.
  19711. func (m *PayRechargeMutation) ClearField(name string) error {
  19712. switch name {
  19713. case payrecharge.FieldDeletedAt:
  19714. m.ClearDeletedAt()
  19715. return nil
  19716. case payrecharge.FieldStatus:
  19717. m.ClearStatus()
  19718. return nil
  19719. case payrecharge.FieldMoney:
  19720. m.ClearMoney()
  19721. return nil
  19722. case payrecharge.FieldOutTradeNo:
  19723. m.ClearOutTradeNo()
  19724. return nil
  19725. }
  19726. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19727. }
  19728. // ResetField resets all changes in the mutation for the field with the given name.
  19729. // It returns an error if the field is not defined in the schema.
  19730. func (m *PayRechargeMutation) ResetField(name string) error {
  19731. switch name {
  19732. case payrecharge.FieldCreatedAt:
  19733. m.ResetCreatedAt()
  19734. return nil
  19735. case payrecharge.FieldUpdatedAt:
  19736. m.ResetUpdatedAt()
  19737. return nil
  19738. case payrecharge.FieldDeletedAt:
  19739. m.ResetDeletedAt()
  19740. return nil
  19741. case payrecharge.FieldUserID:
  19742. m.ResetUserID()
  19743. return nil
  19744. case payrecharge.FieldNumber:
  19745. m.ResetNumber()
  19746. return nil
  19747. case payrecharge.FieldStatus:
  19748. m.ResetStatus()
  19749. return nil
  19750. case payrecharge.FieldMoney:
  19751. m.ResetMoney()
  19752. return nil
  19753. case payrecharge.FieldOutTradeNo:
  19754. m.ResetOutTradeNo()
  19755. return nil
  19756. case payrecharge.FieldOrganizationID:
  19757. m.ResetOrganizationID()
  19758. return nil
  19759. }
  19760. return fmt.Errorf("unknown PayRecharge field %s", name)
  19761. }
  19762. // AddedEdges returns all edge names that were set/added in this mutation.
  19763. func (m *PayRechargeMutation) AddedEdges() []string {
  19764. edges := make([]string, 0, 0)
  19765. return edges
  19766. }
  19767. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19768. // name in this mutation.
  19769. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19770. return nil
  19771. }
  19772. // RemovedEdges returns all edge names that were removed in this mutation.
  19773. func (m *PayRechargeMutation) RemovedEdges() []string {
  19774. edges := make([]string, 0, 0)
  19775. return edges
  19776. }
  19777. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19778. // the given name in this mutation.
  19779. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19780. return nil
  19781. }
  19782. // ClearedEdges returns all edge names that were cleared in this mutation.
  19783. func (m *PayRechargeMutation) ClearedEdges() []string {
  19784. edges := make([]string, 0, 0)
  19785. return edges
  19786. }
  19787. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19788. // was cleared in this mutation.
  19789. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19790. return false
  19791. }
  19792. // ClearEdge clears the value of the edge with the given name. It returns an error
  19793. // if that edge is not defined in the schema.
  19794. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19795. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19796. }
  19797. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19798. // It returns an error if the edge is not defined in the schema.
  19799. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19800. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19801. }
  19802. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19803. type ServerMutation struct {
  19804. config
  19805. op Op
  19806. typ string
  19807. id *uint64
  19808. created_at *time.Time
  19809. updated_at *time.Time
  19810. status *uint8
  19811. addstatus *int8
  19812. deleted_at *time.Time
  19813. name *string
  19814. public_ip *string
  19815. private_ip *string
  19816. admin_port *string
  19817. clearedFields map[string]struct{}
  19818. wxs map[uint64]struct{}
  19819. removedwxs map[uint64]struct{}
  19820. clearedwxs bool
  19821. done bool
  19822. oldValue func(context.Context) (*Server, error)
  19823. predicates []predicate.Server
  19824. }
  19825. var _ ent.Mutation = (*ServerMutation)(nil)
  19826. // serverOption allows management of the mutation configuration using functional options.
  19827. type serverOption func(*ServerMutation)
  19828. // newServerMutation creates new mutation for the Server entity.
  19829. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19830. m := &ServerMutation{
  19831. config: c,
  19832. op: op,
  19833. typ: TypeServer,
  19834. clearedFields: make(map[string]struct{}),
  19835. }
  19836. for _, opt := range opts {
  19837. opt(m)
  19838. }
  19839. return m
  19840. }
  19841. // withServerID sets the ID field of the mutation.
  19842. func withServerID(id uint64) serverOption {
  19843. return func(m *ServerMutation) {
  19844. var (
  19845. err error
  19846. once sync.Once
  19847. value *Server
  19848. )
  19849. m.oldValue = func(ctx context.Context) (*Server, error) {
  19850. once.Do(func() {
  19851. if m.done {
  19852. err = errors.New("querying old values post mutation is not allowed")
  19853. } else {
  19854. value, err = m.Client().Server.Get(ctx, id)
  19855. }
  19856. })
  19857. return value, err
  19858. }
  19859. m.id = &id
  19860. }
  19861. }
  19862. // withServer sets the old Server of the mutation.
  19863. func withServer(node *Server) serverOption {
  19864. return func(m *ServerMutation) {
  19865. m.oldValue = func(context.Context) (*Server, error) {
  19866. return node, nil
  19867. }
  19868. m.id = &node.ID
  19869. }
  19870. }
  19871. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19872. // executed in a transaction (ent.Tx), a transactional client is returned.
  19873. func (m ServerMutation) Client() *Client {
  19874. client := &Client{config: m.config}
  19875. client.init()
  19876. return client
  19877. }
  19878. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19879. // it returns an error otherwise.
  19880. func (m ServerMutation) Tx() (*Tx, error) {
  19881. if _, ok := m.driver.(*txDriver); !ok {
  19882. return nil, errors.New("ent: mutation is not running in a transaction")
  19883. }
  19884. tx := &Tx{config: m.config}
  19885. tx.init()
  19886. return tx, nil
  19887. }
  19888. // SetID sets the value of the id field. Note that this
  19889. // operation is only accepted on creation of Server entities.
  19890. func (m *ServerMutation) SetID(id uint64) {
  19891. m.id = &id
  19892. }
  19893. // ID returns the ID value in the mutation. Note that the ID is only available
  19894. // if it was provided to the builder or after it was returned from the database.
  19895. func (m *ServerMutation) ID() (id uint64, exists bool) {
  19896. if m.id == nil {
  19897. return
  19898. }
  19899. return *m.id, true
  19900. }
  19901. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19902. // That means, if the mutation is applied within a transaction with an isolation level such
  19903. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19904. // or updated by the mutation.
  19905. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  19906. switch {
  19907. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19908. id, exists := m.ID()
  19909. if exists {
  19910. return []uint64{id}, nil
  19911. }
  19912. fallthrough
  19913. case m.op.Is(OpUpdate | OpDelete):
  19914. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  19915. default:
  19916. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19917. }
  19918. }
  19919. // SetCreatedAt sets the "created_at" field.
  19920. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  19921. m.created_at = &t
  19922. }
  19923. // CreatedAt returns the value of the "created_at" field in the mutation.
  19924. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  19925. v := m.created_at
  19926. if v == nil {
  19927. return
  19928. }
  19929. return *v, true
  19930. }
  19931. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  19932. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19934. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19935. if !m.op.Is(OpUpdateOne) {
  19936. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19937. }
  19938. if m.id == nil || m.oldValue == nil {
  19939. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19940. }
  19941. oldValue, err := m.oldValue(ctx)
  19942. if err != nil {
  19943. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19944. }
  19945. return oldValue.CreatedAt, nil
  19946. }
  19947. // ResetCreatedAt resets all changes to the "created_at" field.
  19948. func (m *ServerMutation) ResetCreatedAt() {
  19949. m.created_at = nil
  19950. }
  19951. // SetUpdatedAt sets the "updated_at" field.
  19952. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  19953. m.updated_at = &t
  19954. }
  19955. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19956. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  19957. v := m.updated_at
  19958. if v == nil {
  19959. return
  19960. }
  19961. return *v, true
  19962. }
  19963. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  19964. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19966. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19967. if !m.op.Is(OpUpdateOne) {
  19968. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19969. }
  19970. if m.id == nil || m.oldValue == nil {
  19971. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19972. }
  19973. oldValue, err := m.oldValue(ctx)
  19974. if err != nil {
  19975. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19976. }
  19977. return oldValue.UpdatedAt, nil
  19978. }
  19979. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19980. func (m *ServerMutation) ResetUpdatedAt() {
  19981. m.updated_at = nil
  19982. }
  19983. // SetStatus sets the "status" field.
  19984. func (m *ServerMutation) SetStatus(u uint8) {
  19985. m.status = &u
  19986. m.addstatus = nil
  19987. }
  19988. // Status returns the value of the "status" field in the mutation.
  19989. func (m *ServerMutation) Status() (r uint8, exists bool) {
  19990. v := m.status
  19991. if v == nil {
  19992. return
  19993. }
  19994. return *v, true
  19995. }
  19996. // OldStatus returns the old "status" field's value of the Server entity.
  19997. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19999. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20000. if !m.op.Is(OpUpdateOne) {
  20001. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20002. }
  20003. if m.id == nil || m.oldValue == nil {
  20004. return v, errors.New("OldStatus requires an ID field in the mutation")
  20005. }
  20006. oldValue, err := m.oldValue(ctx)
  20007. if err != nil {
  20008. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20009. }
  20010. return oldValue.Status, nil
  20011. }
  20012. // AddStatus adds u to the "status" field.
  20013. func (m *ServerMutation) AddStatus(u int8) {
  20014. if m.addstatus != nil {
  20015. *m.addstatus += u
  20016. } else {
  20017. m.addstatus = &u
  20018. }
  20019. }
  20020. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20021. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20022. v := m.addstatus
  20023. if v == nil {
  20024. return
  20025. }
  20026. return *v, true
  20027. }
  20028. // ClearStatus clears the value of the "status" field.
  20029. func (m *ServerMutation) ClearStatus() {
  20030. m.status = nil
  20031. m.addstatus = nil
  20032. m.clearedFields[server.FieldStatus] = struct{}{}
  20033. }
  20034. // StatusCleared returns if the "status" field was cleared in this mutation.
  20035. func (m *ServerMutation) StatusCleared() bool {
  20036. _, ok := m.clearedFields[server.FieldStatus]
  20037. return ok
  20038. }
  20039. // ResetStatus resets all changes to the "status" field.
  20040. func (m *ServerMutation) ResetStatus() {
  20041. m.status = nil
  20042. m.addstatus = nil
  20043. delete(m.clearedFields, server.FieldStatus)
  20044. }
  20045. // SetDeletedAt sets the "deleted_at" field.
  20046. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20047. m.deleted_at = &t
  20048. }
  20049. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20050. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20051. v := m.deleted_at
  20052. if v == nil {
  20053. return
  20054. }
  20055. return *v, true
  20056. }
  20057. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20058. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20060. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20061. if !m.op.Is(OpUpdateOne) {
  20062. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20063. }
  20064. if m.id == nil || m.oldValue == nil {
  20065. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20066. }
  20067. oldValue, err := m.oldValue(ctx)
  20068. if err != nil {
  20069. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20070. }
  20071. return oldValue.DeletedAt, nil
  20072. }
  20073. // ClearDeletedAt clears the value of the "deleted_at" field.
  20074. func (m *ServerMutation) ClearDeletedAt() {
  20075. m.deleted_at = nil
  20076. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20077. }
  20078. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20079. func (m *ServerMutation) DeletedAtCleared() bool {
  20080. _, ok := m.clearedFields[server.FieldDeletedAt]
  20081. return ok
  20082. }
  20083. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20084. func (m *ServerMutation) ResetDeletedAt() {
  20085. m.deleted_at = nil
  20086. delete(m.clearedFields, server.FieldDeletedAt)
  20087. }
  20088. // SetName sets the "name" field.
  20089. func (m *ServerMutation) SetName(s string) {
  20090. m.name = &s
  20091. }
  20092. // Name returns the value of the "name" field in the mutation.
  20093. func (m *ServerMutation) Name() (r string, exists bool) {
  20094. v := m.name
  20095. if v == nil {
  20096. return
  20097. }
  20098. return *v, true
  20099. }
  20100. // OldName returns the old "name" field's value of the Server entity.
  20101. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20103. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20104. if !m.op.Is(OpUpdateOne) {
  20105. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20106. }
  20107. if m.id == nil || m.oldValue == nil {
  20108. return v, errors.New("OldName requires an ID field in the mutation")
  20109. }
  20110. oldValue, err := m.oldValue(ctx)
  20111. if err != nil {
  20112. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20113. }
  20114. return oldValue.Name, nil
  20115. }
  20116. // ResetName resets all changes to the "name" field.
  20117. func (m *ServerMutation) ResetName() {
  20118. m.name = nil
  20119. }
  20120. // SetPublicIP sets the "public_ip" field.
  20121. func (m *ServerMutation) SetPublicIP(s string) {
  20122. m.public_ip = &s
  20123. }
  20124. // PublicIP returns the value of the "public_ip" field in the mutation.
  20125. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20126. v := m.public_ip
  20127. if v == nil {
  20128. return
  20129. }
  20130. return *v, true
  20131. }
  20132. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20133. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20134. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20135. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20136. if !m.op.Is(OpUpdateOne) {
  20137. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20138. }
  20139. if m.id == nil || m.oldValue == nil {
  20140. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20141. }
  20142. oldValue, err := m.oldValue(ctx)
  20143. if err != nil {
  20144. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20145. }
  20146. return oldValue.PublicIP, nil
  20147. }
  20148. // ResetPublicIP resets all changes to the "public_ip" field.
  20149. func (m *ServerMutation) ResetPublicIP() {
  20150. m.public_ip = nil
  20151. }
  20152. // SetPrivateIP sets the "private_ip" field.
  20153. func (m *ServerMutation) SetPrivateIP(s string) {
  20154. m.private_ip = &s
  20155. }
  20156. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20157. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20158. v := m.private_ip
  20159. if v == nil {
  20160. return
  20161. }
  20162. return *v, true
  20163. }
  20164. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20165. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20166. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20167. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20168. if !m.op.Is(OpUpdateOne) {
  20169. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20170. }
  20171. if m.id == nil || m.oldValue == nil {
  20172. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20173. }
  20174. oldValue, err := m.oldValue(ctx)
  20175. if err != nil {
  20176. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20177. }
  20178. return oldValue.PrivateIP, nil
  20179. }
  20180. // ResetPrivateIP resets all changes to the "private_ip" field.
  20181. func (m *ServerMutation) ResetPrivateIP() {
  20182. m.private_ip = nil
  20183. }
  20184. // SetAdminPort sets the "admin_port" field.
  20185. func (m *ServerMutation) SetAdminPort(s string) {
  20186. m.admin_port = &s
  20187. }
  20188. // AdminPort returns the value of the "admin_port" field in the mutation.
  20189. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20190. v := m.admin_port
  20191. if v == nil {
  20192. return
  20193. }
  20194. return *v, true
  20195. }
  20196. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20197. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20199. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20200. if !m.op.Is(OpUpdateOne) {
  20201. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20202. }
  20203. if m.id == nil || m.oldValue == nil {
  20204. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20205. }
  20206. oldValue, err := m.oldValue(ctx)
  20207. if err != nil {
  20208. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20209. }
  20210. return oldValue.AdminPort, nil
  20211. }
  20212. // ResetAdminPort resets all changes to the "admin_port" field.
  20213. func (m *ServerMutation) ResetAdminPort() {
  20214. m.admin_port = nil
  20215. }
  20216. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20217. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20218. if m.wxs == nil {
  20219. m.wxs = make(map[uint64]struct{})
  20220. }
  20221. for i := range ids {
  20222. m.wxs[ids[i]] = struct{}{}
  20223. }
  20224. }
  20225. // ClearWxs clears the "wxs" edge to the Wx entity.
  20226. func (m *ServerMutation) ClearWxs() {
  20227. m.clearedwxs = true
  20228. }
  20229. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20230. func (m *ServerMutation) WxsCleared() bool {
  20231. return m.clearedwxs
  20232. }
  20233. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20234. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20235. if m.removedwxs == nil {
  20236. m.removedwxs = make(map[uint64]struct{})
  20237. }
  20238. for i := range ids {
  20239. delete(m.wxs, ids[i])
  20240. m.removedwxs[ids[i]] = struct{}{}
  20241. }
  20242. }
  20243. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20244. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20245. for id := range m.removedwxs {
  20246. ids = append(ids, id)
  20247. }
  20248. return
  20249. }
  20250. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20251. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20252. for id := range m.wxs {
  20253. ids = append(ids, id)
  20254. }
  20255. return
  20256. }
  20257. // ResetWxs resets all changes to the "wxs" edge.
  20258. func (m *ServerMutation) ResetWxs() {
  20259. m.wxs = nil
  20260. m.clearedwxs = false
  20261. m.removedwxs = nil
  20262. }
  20263. // Where appends a list predicates to the ServerMutation builder.
  20264. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20265. m.predicates = append(m.predicates, ps...)
  20266. }
  20267. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20268. // users can use type-assertion to append predicates that do not depend on any generated package.
  20269. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20270. p := make([]predicate.Server, len(ps))
  20271. for i := range ps {
  20272. p[i] = ps[i]
  20273. }
  20274. m.Where(p...)
  20275. }
  20276. // Op returns the operation name.
  20277. func (m *ServerMutation) Op() Op {
  20278. return m.op
  20279. }
  20280. // SetOp allows setting the mutation operation.
  20281. func (m *ServerMutation) SetOp(op Op) {
  20282. m.op = op
  20283. }
  20284. // Type returns the node type of this mutation (Server).
  20285. func (m *ServerMutation) Type() string {
  20286. return m.typ
  20287. }
  20288. // Fields returns all fields that were changed during this mutation. Note that in
  20289. // order to get all numeric fields that were incremented/decremented, call
  20290. // AddedFields().
  20291. func (m *ServerMutation) Fields() []string {
  20292. fields := make([]string, 0, 8)
  20293. if m.created_at != nil {
  20294. fields = append(fields, server.FieldCreatedAt)
  20295. }
  20296. if m.updated_at != nil {
  20297. fields = append(fields, server.FieldUpdatedAt)
  20298. }
  20299. if m.status != nil {
  20300. fields = append(fields, server.FieldStatus)
  20301. }
  20302. if m.deleted_at != nil {
  20303. fields = append(fields, server.FieldDeletedAt)
  20304. }
  20305. if m.name != nil {
  20306. fields = append(fields, server.FieldName)
  20307. }
  20308. if m.public_ip != nil {
  20309. fields = append(fields, server.FieldPublicIP)
  20310. }
  20311. if m.private_ip != nil {
  20312. fields = append(fields, server.FieldPrivateIP)
  20313. }
  20314. if m.admin_port != nil {
  20315. fields = append(fields, server.FieldAdminPort)
  20316. }
  20317. return fields
  20318. }
  20319. // Field returns the value of a field with the given name. The second boolean
  20320. // return value indicates that this field was not set, or was not defined in the
  20321. // schema.
  20322. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20323. switch name {
  20324. case server.FieldCreatedAt:
  20325. return m.CreatedAt()
  20326. case server.FieldUpdatedAt:
  20327. return m.UpdatedAt()
  20328. case server.FieldStatus:
  20329. return m.Status()
  20330. case server.FieldDeletedAt:
  20331. return m.DeletedAt()
  20332. case server.FieldName:
  20333. return m.Name()
  20334. case server.FieldPublicIP:
  20335. return m.PublicIP()
  20336. case server.FieldPrivateIP:
  20337. return m.PrivateIP()
  20338. case server.FieldAdminPort:
  20339. return m.AdminPort()
  20340. }
  20341. return nil, false
  20342. }
  20343. // OldField returns the old value of the field from the database. An error is
  20344. // returned if the mutation operation is not UpdateOne, or the query to the
  20345. // database failed.
  20346. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20347. switch name {
  20348. case server.FieldCreatedAt:
  20349. return m.OldCreatedAt(ctx)
  20350. case server.FieldUpdatedAt:
  20351. return m.OldUpdatedAt(ctx)
  20352. case server.FieldStatus:
  20353. return m.OldStatus(ctx)
  20354. case server.FieldDeletedAt:
  20355. return m.OldDeletedAt(ctx)
  20356. case server.FieldName:
  20357. return m.OldName(ctx)
  20358. case server.FieldPublicIP:
  20359. return m.OldPublicIP(ctx)
  20360. case server.FieldPrivateIP:
  20361. return m.OldPrivateIP(ctx)
  20362. case server.FieldAdminPort:
  20363. return m.OldAdminPort(ctx)
  20364. }
  20365. return nil, fmt.Errorf("unknown Server field %s", name)
  20366. }
  20367. // SetField sets the value of a field with the given name. It returns an error if
  20368. // the field is not defined in the schema, or if the type mismatched the field
  20369. // type.
  20370. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20371. switch name {
  20372. case server.FieldCreatedAt:
  20373. v, ok := value.(time.Time)
  20374. if !ok {
  20375. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20376. }
  20377. m.SetCreatedAt(v)
  20378. return nil
  20379. case server.FieldUpdatedAt:
  20380. v, ok := value.(time.Time)
  20381. if !ok {
  20382. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20383. }
  20384. m.SetUpdatedAt(v)
  20385. return nil
  20386. case server.FieldStatus:
  20387. v, ok := value.(uint8)
  20388. if !ok {
  20389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20390. }
  20391. m.SetStatus(v)
  20392. return nil
  20393. case server.FieldDeletedAt:
  20394. v, ok := value.(time.Time)
  20395. if !ok {
  20396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20397. }
  20398. m.SetDeletedAt(v)
  20399. return nil
  20400. case server.FieldName:
  20401. v, ok := value.(string)
  20402. if !ok {
  20403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20404. }
  20405. m.SetName(v)
  20406. return nil
  20407. case server.FieldPublicIP:
  20408. v, ok := value.(string)
  20409. if !ok {
  20410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20411. }
  20412. m.SetPublicIP(v)
  20413. return nil
  20414. case server.FieldPrivateIP:
  20415. v, ok := value.(string)
  20416. if !ok {
  20417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20418. }
  20419. m.SetPrivateIP(v)
  20420. return nil
  20421. case server.FieldAdminPort:
  20422. v, ok := value.(string)
  20423. if !ok {
  20424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20425. }
  20426. m.SetAdminPort(v)
  20427. return nil
  20428. }
  20429. return fmt.Errorf("unknown Server field %s", name)
  20430. }
  20431. // AddedFields returns all numeric fields that were incremented/decremented during
  20432. // this mutation.
  20433. func (m *ServerMutation) AddedFields() []string {
  20434. var fields []string
  20435. if m.addstatus != nil {
  20436. fields = append(fields, server.FieldStatus)
  20437. }
  20438. return fields
  20439. }
  20440. // AddedField returns the numeric value that was incremented/decremented on a field
  20441. // with the given name. The second boolean return value indicates that this field
  20442. // was not set, or was not defined in the schema.
  20443. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20444. switch name {
  20445. case server.FieldStatus:
  20446. return m.AddedStatus()
  20447. }
  20448. return nil, false
  20449. }
  20450. // AddField adds the value to the field with the given name. It returns an error if
  20451. // the field is not defined in the schema, or if the type mismatched the field
  20452. // type.
  20453. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20454. switch name {
  20455. case server.FieldStatus:
  20456. v, ok := value.(int8)
  20457. if !ok {
  20458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20459. }
  20460. m.AddStatus(v)
  20461. return nil
  20462. }
  20463. return fmt.Errorf("unknown Server numeric field %s", name)
  20464. }
  20465. // ClearedFields returns all nullable fields that were cleared during this
  20466. // mutation.
  20467. func (m *ServerMutation) ClearedFields() []string {
  20468. var fields []string
  20469. if m.FieldCleared(server.FieldStatus) {
  20470. fields = append(fields, server.FieldStatus)
  20471. }
  20472. if m.FieldCleared(server.FieldDeletedAt) {
  20473. fields = append(fields, server.FieldDeletedAt)
  20474. }
  20475. return fields
  20476. }
  20477. // FieldCleared returns a boolean indicating if a field with the given name was
  20478. // cleared in this mutation.
  20479. func (m *ServerMutation) FieldCleared(name string) bool {
  20480. _, ok := m.clearedFields[name]
  20481. return ok
  20482. }
  20483. // ClearField clears the value of the field with the given name. It returns an
  20484. // error if the field is not defined in the schema.
  20485. func (m *ServerMutation) ClearField(name string) error {
  20486. switch name {
  20487. case server.FieldStatus:
  20488. m.ClearStatus()
  20489. return nil
  20490. case server.FieldDeletedAt:
  20491. m.ClearDeletedAt()
  20492. return nil
  20493. }
  20494. return fmt.Errorf("unknown Server nullable field %s", name)
  20495. }
  20496. // ResetField resets all changes in the mutation for the field with the given name.
  20497. // It returns an error if the field is not defined in the schema.
  20498. func (m *ServerMutation) ResetField(name string) error {
  20499. switch name {
  20500. case server.FieldCreatedAt:
  20501. m.ResetCreatedAt()
  20502. return nil
  20503. case server.FieldUpdatedAt:
  20504. m.ResetUpdatedAt()
  20505. return nil
  20506. case server.FieldStatus:
  20507. m.ResetStatus()
  20508. return nil
  20509. case server.FieldDeletedAt:
  20510. m.ResetDeletedAt()
  20511. return nil
  20512. case server.FieldName:
  20513. m.ResetName()
  20514. return nil
  20515. case server.FieldPublicIP:
  20516. m.ResetPublicIP()
  20517. return nil
  20518. case server.FieldPrivateIP:
  20519. m.ResetPrivateIP()
  20520. return nil
  20521. case server.FieldAdminPort:
  20522. m.ResetAdminPort()
  20523. return nil
  20524. }
  20525. return fmt.Errorf("unknown Server field %s", name)
  20526. }
  20527. // AddedEdges returns all edge names that were set/added in this mutation.
  20528. func (m *ServerMutation) AddedEdges() []string {
  20529. edges := make([]string, 0, 1)
  20530. if m.wxs != nil {
  20531. edges = append(edges, server.EdgeWxs)
  20532. }
  20533. return edges
  20534. }
  20535. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20536. // name in this mutation.
  20537. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20538. switch name {
  20539. case server.EdgeWxs:
  20540. ids := make([]ent.Value, 0, len(m.wxs))
  20541. for id := range m.wxs {
  20542. ids = append(ids, id)
  20543. }
  20544. return ids
  20545. }
  20546. return nil
  20547. }
  20548. // RemovedEdges returns all edge names that were removed in this mutation.
  20549. func (m *ServerMutation) RemovedEdges() []string {
  20550. edges := make([]string, 0, 1)
  20551. if m.removedwxs != nil {
  20552. edges = append(edges, server.EdgeWxs)
  20553. }
  20554. return edges
  20555. }
  20556. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20557. // the given name in this mutation.
  20558. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20559. switch name {
  20560. case server.EdgeWxs:
  20561. ids := make([]ent.Value, 0, len(m.removedwxs))
  20562. for id := range m.removedwxs {
  20563. ids = append(ids, id)
  20564. }
  20565. return ids
  20566. }
  20567. return nil
  20568. }
  20569. // ClearedEdges returns all edge names that were cleared in this mutation.
  20570. func (m *ServerMutation) ClearedEdges() []string {
  20571. edges := make([]string, 0, 1)
  20572. if m.clearedwxs {
  20573. edges = append(edges, server.EdgeWxs)
  20574. }
  20575. return edges
  20576. }
  20577. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20578. // was cleared in this mutation.
  20579. func (m *ServerMutation) EdgeCleared(name string) bool {
  20580. switch name {
  20581. case server.EdgeWxs:
  20582. return m.clearedwxs
  20583. }
  20584. return false
  20585. }
  20586. // ClearEdge clears the value of the edge with the given name. It returns an error
  20587. // if that edge is not defined in the schema.
  20588. func (m *ServerMutation) ClearEdge(name string) error {
  20589. switch name {
  20590. }
  20591. return fmt.Errorf("unknown Server unique edge %s", name)
  20592. }
  20593. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20594. // It returns an error if the edge is not defined in the schema.
  20595. func (m *ServerMutation) ResetEdge(name string) error {
  20596. switch name {
  20597. case server.EdgeWxs:
  20598. m.ResetWxs()
  20599. return nil
  20600. }
  20601. return fmt.Errorf("unknown Server edge %s", name)
  20602. }
  20603. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20604. type SopNodeMutation struct {
  20605. config
  20606. op Op
  20607. typ string
  20608. id *uint64
  20609. created_at *time.Time
  20610. updated_at *time.Time
  20611. status *uint8
  20612. addstatus *int8
  20613. deleted_at *time.Time
  20614. parent_id *uint64
  20615. addparent_id *int64
  20616. name *string
  20617. condition_type *int
  20618. addcondition_type *int
  20619. condition_list *[]string
  20620. appendcondition_list []string
  20621. no_reply_condition *uint64
  20622. addno_reply_condition *int64
  20623. no_reply_unit *string
  20624. action_message *[]custom_types.Action
  20625. appendaction_message []custom_types.Action
  20626. action_label_add *[]uint64
  20627. appendaction_label_add []uint64
  20628. action_label_del *[]uint64
  20629. appendaction_label_del []uint64
  20630. action_forward **custom_types.ActionForward
  20631. clearedFields map[string]struct{}
  20632. sop_stage *uint64
  20633. clearedsop_stage bool
  20634. node_messages map[uint64]struct{}
  20635. removednode_messages map[uint64]struct{}
  20636. clearednode_messages bool
  20637. done bool
  20638. oldValue func(context.Context) (*SopNode, error)
  20639. predicates []predicate.SopNode
  20640. }
  20641. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20642. // sopnodeOption allows management of the mutation configuration using functional options.
  20643. type sopnodeOption func(*SopNodeMutation)
  20644. // newSopNodeMutation creates new mutation for the SopNode entity.
  20645. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20646. m := &SopNodeMutation{
  20647. config: c,
  20648. op: op,
  20649. typ: TypeSopNode,
  20650. clearedFields: make(map[string]struct{}),
  20651. }
  20652. for _, opt := range opts {
  20653. opt(m)
  20654. }
  20655. return m
  20656. }
  20657. // withSopNodeID sets the ID field of the mutation.
  20658. func withSopNodeID(id uint64) sopnodeOption {
  20659. return func(m *SopNodeMutation) {
  20660. var (
  20661. err error
  20662. once sync.Once
  20663. value *SopNode
  20664. )
  20665. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20666. once.Do(func() {
  20667. if m.done {
  20668. err = errors.New("querying old values post mutation is not allowed")
  20669. } else {
  20670. value, err = m.Client().SopNode.Get(ctx, id)
  20671. }
  20672. })
  20673. return value, err
  20674. }
  20675. m.id = &id
  20676. }
  20677. }
  20678. // withSopNode sets the old SopNode of the mutation.
  20679. func withSopNode(node *SopNode) sopnodeOption {
  20680. return func(m *SopNodeMutation) {
  20681. m.oldValue = func(context.Context) (*SopNode, error) {
  20682. return node, nil
  20683. }
  20684. m.id = &node.ID
  20685. }
  20686. }
  20687. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20688. // executed in a transaction (ent.Tx), a transactional client is returned.
  20689. func (m SopNodeMutation) Client() *Client {
  20690. client := &Client{config: m.config}
  20691. client.init()
  20692. return client
  20693. }
  20694. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20695. // it returns an error otherwise.
  20696. func (m SopNodeMutation) Tx() (*Tx, error) {
  20697. if _, ok := m.driver.(*txDriver); !ok {
  20698. return nil, errors.New("ent: mutation is not running in a transaction")
  20699. }
  20700. tx := &Tx{config: m.config}
  20701. tx.init()
  20702. return tx, nil
  20703. }
  20704. // SetID sets the value of the id field. Note that this
  20705. // operation is only accepted on creation of SopNode entities.
  20706. func (m *SopNodeMutation) SetID(id uint64) {
  20707. m.id = &id
  20708. }
  20709. // ID returns the ID value in the mutation. Note that the ID is only available
  20710. // if it was provided to the builder or after it was returned from the database.
  20711. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20712. if m.id == nil {
  20713. return
  20714. }
  20715. return *m.id, true
  20716. }
  20717. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20718. // That means, if the mutation is applied within a transaction with an isolation level such
  20719. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20720. // or updated by the mutation.
  20721. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20722. switch {
  20723. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20724. id, exists := m.ID()
  20725. if exists {
  20726. return []uint64{id}, nil
  20727. }
  20728. fallthrough
  20729. case m.op.Is(OpUpdate | OpDelete):
  20730. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20731. default:
  20732. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20733. }
  20734. }
  20735. // SetCreatedAt sets the "created_at" field.
  20736. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20737. m.created_at = &t
  20738. }
  20739. // CreatedAt returns the value of the "created_at" field in the mutation.
  20740. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20741. v := m.created_at
  20742. if v == nil {
  20743. return
  20744. }
  20745. return *v, true
  20746. }
  20747. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20748. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20750. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20751. if !m.op.Is(OpUpdateOne) {
  20752. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20753. }
  20754. if m.id == nil || m.oldValue == nil {
  20755. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20756. }
  20757. oldValue, err := m.oldValue(ctx)
  20758. if err != nil {
  20759. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20760. }
  20761. return oldValue.CreatedAt, nil
  20762. }
  20763. // ResetCreatedAt resets all changes to the "created_at" field.
  20764. func (m *SopNodeMutation) ResetCreatedAt() {
  20765. m.created_at = nil
  20766. }
  20767. // SetUpdatedAt sets the "updated_at" field.
  20768. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20769. m.updated_at = &t
  20770. }
  20771. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20772. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20773. v := m.updated_at
  20774. if v == nil {
  20775. return
  20776. }
  20777. return *v, true
  20778. }
  20779. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20780. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20782. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20783. if !m.op.Is(OpUpdateOne) {
  20784. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20785. }
  20786. if m.id == nil || m.oldValue == nil {
  20787. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20788. }
  20789. oldValue, err := m.oldValue(ctx)
  20790. if err != nil {
  20791. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20792. }
  20793. return oldValue.UpdatedAt, nil
  20794. }
  20795. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20796. func (m *SopNodeMutation) ResetUpdatedAt() {
  20797. m.updated_at = nil
  20798. }
  20799. // SetStatus sets the "status" field.
  20800. func (m *SopNodeMutation) SetStatus(u uint8) {
  20801. m.status = &u
  20802. m.addstatus = nil
  20803. }
  20804. // Status returns the value of the "status" field in the mutation.
  20805. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20806. v := m.status
  20807. if v == nil {
  20808. return
  20809. }
  20810. return *v, true
  20811. }
  20812. // OldStatus returns the old "status" field's value of the SopNode entity.
  20813. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20815. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20816. if !m.op.Is(OpUpdateOne) {
  20817. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20818. }
  20819. if m.id == nil || m.oldValue == nil {
  20820. return v, errors.New("OldStatus requires an ID field in the mutation")
  20821. }
  20822. oldValue, err := m.oldValue(ctx)
  20823. if err != nil {
  20824. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20825. }
  20826. return oldValue.Status, nil
  20827. }
  20828. // AddStatus adds u to the "status" field.
  20829. func (m *SopNodeMutation) AddStatus(u int8) {
  20830. if m.addstatus != nil {
  20831. *m.addstatus += u
  20832. } else {
  20833. m.addstatus = &u
  20834. }
  20835. }
  20836. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20837. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20838. v := m.addstatus
  20839. if v == nil {
  20840. return
  20841. }
  20842. return *v, true
  20843. }
  20844. // ClearStatus clears the value of the "status" field.
  20845. func (m *SopNodeMutation) ClearStatus() {
  20846. m.status = nil
  20847. m.addstatus = nil
  20848. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20849. }
  20850. // StatusCleared returns if the "status" field was cleared in this mutation.
  20851. func (m *SopNodeMutation) StatusCleared() bool {
  20852. _, ok := m.clearedFields[sopnode.FieldStatus]
  20853. return ok
  20854. }
  20855. // ResetStatus resets all changes to the "status" field.
  20856. func (m *SopNodeMutation) ResetStatus() {
  20857. m.status = nil
  20858. m.addstatus = nil
  20859. delete(m.clearedFields, sopnode.FieldStatus)
  20860. }
  20861. // SetDeletedAt sets the "deleted_at" field.
  20862. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20863. m.deleted_at = &t
  20864. }
  20865. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20866. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20867. v := m.deleted_at
  20868. if v == nil {
  20869. return
  20870. }
  20871. return *v, true
  20872. }
  20873. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20874. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20875. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20876. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20877. if !m.op.Is(OpUpdateOne) {
  20878. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20879. }
  20880. if m.id == nil || m.oldValue == nil {
  20881. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20882. }
  20883. oldValue, err := m.oldValue(ctx)
  20884. if err != nil {
  20885. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20886. }
  20887. return oldValue.DeletedAt, nil
  20888. }
  20889. // ClearDeletedAt clears the value of the "deleted_at" field.
  20890. func (m *SopNodeMutation) ClearDeletedAt() {
  20891. m.deleted_at = nil
  20892. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  20893. }
  20894. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20895. func (m *SopNodeMutation) DeletedAtCleared() bool {
  20896. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  20897. return ok
  20898. }
  20899. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20900. func (m *SopNodeMutation) ResetDeletedAt() {
  20901. m.deleted_at = nil
  20902. delete(m.clearedFields, sopnode.FieldDeletedAt)
  20903. }
  20904. // SetStageID sets the "stage_id" field.
  20905. func (m *SopNodeMutation) SetStageID(u uint64) {
  20906. m.sop_stage = &u
  20907. }
  20908. // StageID returns the value of the "stage_id" field in the mutation.
  20909. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  20910. v := m.sop_stage
  20911. if v == nil {
  20912. return
  20913. }
  20914. return *v, true
  20915. }
  20916. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  20917. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20918. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20919. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  20920. if !m.op.Is(OpUpdateOne) {
  20921. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  20922. }
  20923. if m.id == nil || m.oldValue == nil {
  20924. return v, errors.New("OldStageID requires an ID field in the mutation")
  20925. }
  20926. oldValue, err := m.oldValue(ctx)
  20927. if err != nil {
  20928. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  20929. }
  20930. return oldValue.StageID, nil
  20931. }
  20932. // ResetStageID resets all changes to the "stage_id" field.
  20933. func (m *SopNodeMutation) ResetStageID() {
  20934. m.sop_stage = nil
  20935. }
  20936. // SetParentID sets the "parent_id" field.
  20937. func (m *SopNodeMutation) SetParentID(u uint64) {
  20938. m.parent_id = &u
  20939. m.addparent_id = nil
  20940. }
  20941. // ParentID returns the value of the "parent_id" field in the mutation.
  20942. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  20943. v := m.parent_id
  20944. if v == nil {
  20945. return
  20946. }
  20947. return *v, true
  20948. }
  20949. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  20950. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20952. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  20953. if !m.op.Is(OpUpdateOne) {
  20954. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  20955. }
  20956. if m.id == nil || m.oldValue == nil {
  20957. return v, errors.New("OldParentID requires an ID field in the mutation")
  20958. }
  20959. oldValue, err := m.oldValue(ctx)
  20960. if err != nil {
  20961. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  20962. }
  20963. return oldValue.ParentID, nil
  20964. }
  20965. // AddParentID adds u to the "parent_id" field.
  20966. func (m *SopNodeMutation) AddParentID(u int64) {
  20967. if m.addparent_id != nil {
  20968. *m.addparent_id += u
  20969. } else {
  20970. m.addparent_id = &u
  20971. }
  20972. }
  20973. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  20974. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  20975. v := m.addparent_id
  20976. if v == nil {
  20977. return
  20978. }
  20979. return *v, true
  20980. }
  20981. // ResetParentID resets all changes to the "parent_id" field.
  20982. func (m *SopNodeMutation) ResetParentID() {
  20983. m.parent_id = nil
  20984. m.addparent_id = nil
  20985. }
  20986. // SetName sets the "name" field.
  20987. func (m *SopNodeMutation) SetName(s string) {
  20988. m.name = &s
  20989. }
  20990. // Name returns the value of the "name" field in the mutation.
  20991. func (m *SopNodeMutation) Name() (r string, exists bool) {
  20992. v := m.name
  20993. if v == nil {
  20994. return
  20995. }
  20996. return *v, true
  20997. }
  20998. // OldName returns the old "name" field's value of the SopNode entity.
  20999. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21001. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21002. if !m.op.Is(OpUpdateOne) {
  21003. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21004. }
  21005. if m.id == nil || m.oldValue == nil {
  21006. return v, errors.New("OldName requires an ID field in the mutation")
  21007. }
  21008. oldValue, err := m.oldValue(ctx)
  21009. if err != nil {
  21010. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21011. }
  21012. return oldValue.Name, nil
  21013. }
  21014. // ResetName resets all changes to the "name" field.
  21015. func (m *SopNodeMutation) ResetName() {
  21016. m.name = nil
  21017. }
  21018. // SetConditionType sets the "condition_type" field.
  21019. func (m *SopNodeMutation) SetConditionType(i int) {
  21020. m.condition_type = &i
  21021. m.addcondition_type = nil
  21022. }
  21023. // ConditionType returns the value of the "condition_type" field in the mutation.
  21024. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21025. v := m.condition_type
  21026. if v == nil {
  21027. return
  21028. }
  21029. return *v, true
  21030. }
  21031. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21032. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21033. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21034. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21035. if !m.op.Is(OpUpdateOne) {
  21036. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21037. }
  21038. if m.id == nil || m.oldValue == nil {
  21039. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21040. }
  21041. oldValue, err := m.oldValue(ctx)
  21042. if err != nil {
  21043. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21044. }
  21045. return oldValue.ConditionType, nil
  21046. }
  21047. // AddConditionType adds i to the "condition_type" field.
  21048. func (m *SopNodeMutation) AddConditionType(i int) {
  21049. if m.addcondition_type != nil {
  21050. *m.addcondition_type += i
  21051. } else {
  21052. m.addcondition_type = &i
  21053. }
  21054. }
  21055. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21056. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21057. v := m.addcondition_type
  21058. if v == nil {
  21059. return
  21060. }
  21061. return *v, true
  21062. }
  21063. // ResetConditionType resets all changes to the "condition_type" field.
  21064. func (m *SopNodeMutation) ResetConditionType() {
  21065. m.condition_type = nil
  21066. m.addcondition_type = nil
  21067. }
  21068. // SetConditionList sets the "condition_list" field.
  21069. func (m *SopNodeMutation) SetConditionList(s []string) {
  21070. m.condition_list = &s
  21071. m.appendcondition_list = nil
  21072. }
  21073. // ConditionList returns the value of the "condition_list" field in the mutation.
  21074. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21075. v := m.condition_list
  21076. if v == nil {
  21077. return
  21078. }
  21079. return *v, true
  21080. }
  21081. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21082. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21083. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21084. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21085. if !m.op.Is(OpUpdateOne) {
  21086. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21087. }
  21088. if m.id == nil || m.oldValue == nil {
  21089. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21090. }
  21091. oldValue, err := m.oldValue(ctx)
  21092. if err != nil {
  21093. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21094. }
  21095. return oldValue.ConditionList, nil
  21096. }
  21097. // AppendConditionList adds s to the "condition_list" field.
  21098. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21099. m.appendcondition_list = append(m.appendcondition_list, s...)
  21100. }
  21101. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21102. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21103. if len(m.appendcondition_list) == 0 {
  21104. return nil, false
  21105. }
  21106. return m.appendcondition_list, true
  21107. }
  21108. // ClearConditionList clears the value of the "condition_list" field.
  21109. func (m *SopNodeMutation) ClearConditionList() {
  21110. m.condition_list = nil
  21111. m.appendcondition_list = nil
  21112. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21113. }
  21114. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21115. func (m *SopNodeMutation) ConditionListCleared() bool {
  21116. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21117. return ok
  21118. }
  21119. // ResetConditionList resets all changes to the "condition_list" field.
  21120. func (m *SopNodeMutation) ResetConditionList() {
  21121. m.condition_list = nil
  21122. m.appendcondition_list = nil
  21123. delete(m.clearedFields, sopnode.FieldConditionList)
  21124. }
  21125. // SetNoReplyCondition sets the "no_reply_condition" field.
  21126. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21127. m.no_reply_condition = &u
  21128. m.addno_reply_condition = nil
  21129. }
  21130. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21131. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21132. v := m.no_reply_condition
  21133. if v == nil {
  21134. return
  21135. }
  21136. return *v, true
  21137. }
  21138. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21139. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21140. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21141. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21142. if !m.op.Is(OpUpdateOne) {
  21143. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21144. }
  21145. if m.id == nil || m.oldValue == nil {
  21146. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21147. }
  21148. oldValue, err := m.oldValue(ctx)
  21149. if err != nil {
  21150. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21151. }
  21152. return oldValue.NoReplyCondition, nil
  21153. }
  21154. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21155. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21156. if m.addno_reply_condition != nil {
  21157. *m.addno_reply_condition += u
  21158. } else {
  21159. m.addno_reply_condition = &u
  21160. }
  21161. }
  21162. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21163. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21164. v := m.addno_reply_condition
  21165. if v == nil {
  21166. return
  21167. }
  21168. return *v, true
  21169. }
  21170. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21171. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21172. m.no_reply_condition = nil
  21173. m.addno_reply_condition = nil
  21174. }
  21175. // SetNoReplyUnit sets the "no_reply_unit" field.
  21176. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21177. m.no_reply_unit = &s
  21178. }
  21179. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21180. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21181. v := m.no_reply_unit
  21182. if v == nil {
  21183. return
  21184. }
  21185. return *v, true
  21186. }
  21187. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21188. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21189. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21190. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21191. if !m.op.Is(OpUpdateOne) {
  21192. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21193. }
  21194. if m.id == nil || m.oldValue == nil {
  21195. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21196. }
  21197. oldValue, err := m.oldValue(ctx)
  21198. if err != nil {
  21199. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21200. }
  21201. return oldValue.NoReplyUnit, nil
  21202. }
  21203. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21204. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21205. m.no_reply_unit = nil
  21206. }
  21207. // SetActionMessage sets the "action_message" field.
  21208. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21209. m.action_message = &ct
  21210. m.appendaction_message = nil
  21211. }
  21212. // ActionMessage returns the value of the "action_message" field in the mutation.
  21213. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21214. v := m.action_message
  21215. if v == nil {
  21216. return
  21217. }
  21218. return *v, true
  21219. }
  21220. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21221. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21222. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21223. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21224. if !m.op.Is(OpUpdateOne) {
  21225. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21226. }
  21227. if m.id == nil || m.oldValue == nil {
  21228. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21229. }
  21230. oldValue, err := m.oldValue(ctx)
  21231. if err != nil {
  21232. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21233. }
  21234. return oldValue.ActionMessage, nil
  21235. }
  21236. // AppendActionMessage adds ct to the "action_message" field.
  21237. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21238. m.appendaction_message = append(m.appendaction_message, ct...)
  21239. }
  21240. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21241. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21242. if len(m.appendaction_message) == 0 {
  21243. return nil, false
  21244. }
  21245. return m.appendaction_message, true
  21246. }
  21247. // ClearActionMessage clears the value of the "action_message" field.
  21248. func (m *SopNodeMutation) ClearActionMessage() {
  21249. m.action_message = nil
  21250. m.appendaction_message = nil
  21251. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21252. }
  21253. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21254. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21255. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21256. return ok
  21257. }
  21258. // ResetActionMessage resets all changes to the "action_message" field.
  21259. func (m *SopNodeMutation) ResetActionMessage() {
  21260. m.action_message = nil
  21261. m.appendaction_message = nil
  21262. delete(m.clearedFields, sopnode.FieldActionMessage)
  21263. }
  21264. // SetActionLabelAdd sets the "action_label_add" field.
  21265. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21266. m.action_label_add = &u
  21267. m.appendaction_label_add = nil
  21268. }
  21269. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21270. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21271. v := m.action_label_add
  21272. if v == nil {
  21273. return
  21274. }
  21275. return *v, true
  21276. }
  21277. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21278. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21279. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21280. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21281. if !m.op.Is(OpUpdateOne) {
  21282. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21283. }
  21284. if m.id == nil || m.oldValue == nil {
  21285. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21286. }
  21287. oldValue, err := m.oldValue(ctx)
  21288. if err != nil {
  21289. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21290. }
  21291. return oldValue.ActionLabelAdd, nil
  21292. }
  21293. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21294. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21295. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21296. }
  21297. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21298. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21299. if len(m.appendaction_label_add) == 0 {
  21300. return nil, false
  21301. }
  21302. return m.appendaction_label_add, true
  21303. }
  21304. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21305. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21306. m.action_label_add = nil
  21307. m.appendaction_label_add = nil
  21308. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21309. }
  21310. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21311. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21312. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21313. return ok
  21314. }
  21315. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21316. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21317. m.action_label_add = nil
  21318. m.appendaction_label_add = nil
  21319. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21320. }
  21321. // SetActionLabelDel sets the "action_label_del" field.
  21322. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21323. m.action_label_del = &u
  21324. m.appendaction_label_del = nil
  21325. }
  21326. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21327. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21328. v := m.action_label_del
  21329. if v == nil {
  21330. return
  21331. }
  21332. return *v, true
  21333. }
  21334. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21335. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21336. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21337. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21338. if !m.op.Is(OpUpdateOne) {
  21339. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21340. }
  21341. if m.id == nil || m.oldValue == nil {
  21342. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21343. }
  21344. oldValue, err := m.oldValue(ctx)
  21345. if err != nil {
  21346. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21347. }
  21348. return oldValue.ActionLabelDel, nil
  21349. }
  21350. // AppendActionLabelDel adds u to the "action_label_del" field.
  21351. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21352. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21353. }
  21354. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21355. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21356. if len(m.appendaction_label_del) == 0 {
  21357. return nil, false
  21358. }
  21359. return m.appendaction_label_del, true
  21360. }
  21361. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21362. func (m *SopNodeMutation) ClearActionLabelDel() {
  21363. m.action_label_del = nil
  21364. m.appendaction_label_del = nil
  21365. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21366. }
  21367. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21368. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21369. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21370. return ok
  21371. }
  21372. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21373. func (m *SopNodeMutation) ResetActionLabelDel() {
  21374. m.action_label_del = nil
  21375. m.appendaction_label_del = nil
  21376. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21377. }
  21378. // SetActionForward sets the "action_forward" field.
  21379. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21380. m.action_forward = &ctf
  21381. }
  21382. // ActionForward returns the value of the "action_forward" field in the mutation.
  21383. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21384. v := m.action_forward
  21385. if v == nil {
  21386. return
  21387. }
  21388. return *v, true
  21389. }
  21390. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21391. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21392. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21393. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21394. if !m.op.Is(OpUpdateOne) {
  21395. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21396. }
  21397. if m.id == nil || m.oldValue == nil {
  21398. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21399. }
  21400. oldValue, err := m.oldValue(ctx)
  21401. if err != nil {
  21402. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21403. }
  21404. return oldValue.ActionForward, nil
  21405. }
  21406. // ClearActionForward clears the value of the "action_forward" field.
  21407. func (m *SopNodeMutation) ClearActionForward() {
  21408. m.action_forward = nil
  21409. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21410. }
  21411. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21412. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21413. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21414. return ok
  21415. }
  21416. // ResetActionForward resets all changes to the "action_forward" field.
  21417. func (m *SopNodeMutation) ResetActionForward() {
  21418. m.action_forward = nil
  21419. delete(m.clearedFields, sopnode.FieldActionForward)
  21420. }
  21421. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21422. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21423. m.sop_stage = &id
  21424. }
  21425. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21426. func (m *SopNodeMutation) ClearSopStage() {
  21427. m.clearedsop_stage = true
  21428. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21429. }
  21430. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21431. func (m *SopNodeMutation) SopStageCleared() bool {
  21432. return m.clearedsop_stage
  21433. }
  21434. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21435. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21436. if m.sop_stage != nil {
  21437. return *m.sop_stage, true
  21438. }
  21439. return
  21440. }
  21441. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21442. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21443. // SopStageID instead. It exists only for internal usage by the builders.
  21444. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21445. if id := m.sop_stage; id != nil {
  21446. ids = append(ids, *id)
  21447. }
  21448. return
  21449. }
  21450. // ResetSopStage resets all changes to the "sop_stage" edge.
  21451. func (m *SopNodeMutation) ResetSopStage() {
  21452. m.sop_stage = nil
  21453. m.clearedsop_stage = false
  21454. }
  21455. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21456. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21457. if m.node_messages == nil {
  21458. m.node_messages = make(map[uint64]struct{})
  21459. }
  21460. for i := range ids {
  21461. m.node_messages[ids[i]] = struct{}{}
  21462. }
  21463. }
  21464. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21465. func (m *SopNodeMutation) ClearNodeMessages() {
  21466. m.clearednode_messages = true
  21467. }
  21468. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21469. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21470. return m.clearednode_messages
  21471. }
  21472. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21473. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21474. if m.removednode_messages == nil {
  21475. m.removednode_messages = make(map[uint64]struct{})
  21476. }
  21477. for i := range ids {
  21478. delete(m.node_messages, ids[i])
  21479. m.removednode_messages[ids[i]] = struct{}{}
  21480. }
  21481. }
  21482. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21483. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21484. for id := range m.removednode_messages {
  21485. ids = append(ids, id)
  21486. }
  21487. return
  21488. }
  21489. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21490. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21491. for id := range m.node_messages {
  21492. ids = append(ids, id)
  21493. }
  21494. return
  21495. }
  21496. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21497. func (m *SopNodeMutation) ResetNodeMessages() {
  21498. m.node_messages = nil
  21499. m.clearednode_messages = false
  21500. m.removednode_messages = nil
  21501. }
  21502. // Where appends a list predicates to the SopNodeMutation builder.
  21503. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21504. m.predicates = append(m.predicates, ps...)
  21505. }
  21506. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21507. // users can use type-assertion to append predicates that do not depend on any generated package.
  21508. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21509. p := make([]predicate.SopNode, len(ps))
  21510. for i := range ps {
  21511. p[i] = ps[i]
  21512. }
  21513. m.Where(p...)
  21514. }
  21515. // Op returns the operation name.
  21516. func (m *SopNodeMutation) Op() Op {
  21517. return m.op
  21518. }
  21519. // SetOp allows setting the mutation operation.
  21520. func (m *SopNodeMutation) SetOp(op Op) {
  21521. m.op = op
  21522. }
  21523. // Type returns the node type of this mutation (SopNode).
  21524. func (m *SopNodeMutation) Type() string {
  21525. return m.typ
  21526. }
  21527. // Fields returns all fields that were changed during this mutation. Note that in
  21528. // order to get all numeric fields that were incremented/decremented, call
  21529. // AddedFields().
  21530. func (m *SopNodeMutation) Fields() []string {
  21531. fields := make([]string, 0, 15)
  21532. if m.created_at != nil {
  21533. fields = append(fields, sopnode.FieldCreatedAt)
  21534. }
  21535. if m.updated_at != nil {
  21536. fields = append(fields, sopnode.FieldUpdatedAt)
  21537. }
  21538. if m.status != nil {
  21539. fields = append(fields, sopnode.FieldStatus)
  21540. }
  21541. if m.deleted_at != nil {
  21542. fields = append(fields, sopnode.FieldDeletedAt)
  21543. }
  21544. if m.sop_stage != nil {
  21545. fields = append(fields, sopnode.FieldStageID)
  21546. }
  21547. if m.parent_id != nil {
  21548. fields = append(fields, sopnode.FieldParentID)
  21549. }
  21550. if m.name != nil {
  21551. fields = append(fields, sopnode.FieldName)
  21552. }
  21553. if m.condition_type != nil {
  21554. fields = append(fields, sopnode.FieldConditionType)
  21555. }
  21556. if m.condition_list != nil {
  21557. fields = append(fields, sopnode.FieldConditionList)
  21558. }
  21559. if m.no_reply_condition != nil {
  21560. fields = append(fields, sopnode.FieldNoReplyCondition)
  21561. }
  21562. if m.no_reply_unit != nil {
  21563. fields = append(fields, sopnode.FieldNoReplyUnit)
  21564. }
  21565. if m.action_message != nil {
  21566. fields = append(fields, sopnode.FieldActionMessage)
  21567. }
  21568. if m.action_label_add != nil {
  21569. fields = append(fields, sopnode.FieldActionLabelAdd)
  21570. }
  21571. if m.action_label_del != nil {
  21572. fields = append(fields, sopnode.FieldActionLabelDel)
  21573. }
  21574. if m.action_forward != nil {
  21575. fields = append(fields, sopnode.FieldActionForward)
  21576. }
  21577. return fields
  21578. }
  21579. // Field returns the value of a field with the given name. The second boolean
  21580. // return value indicates that this field was not set, or was not defined in the
  21581. // schema.
  21582. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21583. switch name {
  21584. case sopnode.FieldCreatedAt:
  21585. return m.CreatedAt()
  21586. case sopnode.FieldUpdatedAt:
  21587. return m.UpdatedAt()
  21588. case sopnode.FieldStatus:
  21589. return m.Status()
  21590. case sopnode.FieldDeletedAt:
  21591. return m.DeletedAt()
  21592. case sopnode.FieldStageID:
  21593. return m.StageID()
  21594. case sopnode.FieldParentID:
  21595. return m.ParentID()
  21596. case sopnode.FieldName:
  21597. return m.Name()
  21598. case sopnode.FieldConditionType:
  21599. return m.ConditionType()
  21600. case sopnode.FieldConditionList:
  21601. return m.ConditionList()
  21602. case sopnode.FieldNoReplyCondition:
  21603. return m.NoReplyCondition()
  21604. case sopnode.FieldNoReplyUnit:
  21605. return m.NoReplyUnit()
  21606. case sopnode.FieldActionMessage:
  21607. return m.ActionMessage()
  21608. case sopnode.FieldActionLabelAdd:
  21609. return m.ActionLabelAdd()
  21610. case sopnode.FieldActionLabelDel:
  21611. return m.ActionLabelDel()
  21612. case sopnode.FieldActionForward:
  21613. return m.ActionForward()
  21614. }
  21615. return nil, false
  21616. }
  21617. // OldField returns the old value of the field from the database. An error is
  21618. // returned if the mutation operation is not UpdateOne, or the query to the
  21619. // database failed.
  21620. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21621. switch name {
  21622. case sopnode.FieldCreatedAt:
  21623. return m.OldCreatedAt(ctx)
  21624. case sopnode.FieldUpdatedAt:
  21625. return m.OldUpdatedAt(ctx)
  21626. case sopnode.FieldStatus:
  21627. return m.OldStatus(ctx)
  21628. case sopnode.FieldDeletedAt:
  21629. return m.OldDeletedAt(ctx)
  21630. case sopnode.FieldStageID:
  21631. return m.OldStageID(ctx)
  21632. case sopnode.FieldParentID:
  21633. return m.OldParentID(ctx)
  21634. case sopnode.FieldName:
  21635. return m.OldName(ctx)
  21636. case sopnode.FieldConditionType:
  21637. return m.OldConditionType(ctx)
  21638. case sopnode.FieldConditionList:
  21639. return m.OldConditionList(ctx)
  21640. case sopnode.FieldNoReplyCondition:
  21641. return m.OldNoReplyCondition(ctx)
  21642. case sopnode.FieldNoReplyUnit:
  21643. return m.OldNoReplyUnit(ctx)
  21644. case sopnode.FieldActionMessage:
  21645. return m.OldActionMessage(ctx)
  21646. case sopnode.FieldActionLabelAdd:
  21647. return m.OldActionLabelAdd(ctx)
  21648. case sopnode.FieldActionLabelDel:
  21649. return m.OldActionLabelDel(ctx)
  21650. case sopnode.FieldActionForward:
  21651. return m.OldActionForward(ctx)
  21652. }
  21653. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21654. }
  21655. // SetField sets the value of a field with the given name. It returns an error if
  21656. // the field is not defined in the schema, or if the type mismatched the field
  21657. // type.
  21658. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21659. switch name {
  21660. case sopnode.FieldCreatedAt:
  21661. v, ok := value.(time.Time)
  21662. if !ok {
  21663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21664. }
  21665. m.SetCreatedAt(v)
  21666. return nil
  21667. case sopnode.FieldUpdatedAt:
  21668. v, ok := value.(time.Time)
  21669. if !ok {
  21670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21671. }
  21672. m.SetUpdatedAt(v)
  21673. return nil
  21674. case sopnode.FieldStatus:
  21675. v, ok := value.(uint8)
  21676. if !ok {
  21677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21678. }
  21679. m.SetStatus(v)
  21680. return nil
  21681. case sopnode.FieldDeletedAt:
  21682. v, ok := value.(time.Time)
  21683. if !ok {
  21684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21685. }
  21686. m.SetDeletedAt(v)
  21687. return nil
  21688. case sopnode.FieldStageID:
  21689. v, ok := value.(uint64)
  21690. if !ok {
  21691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21692. }
  21693. m.SetStageID(v)
  21694. return nil
  21695. case sopnode.FieldParentID:
  21696. v, ok := value.(uint64)
  21697. if !ok {
  21698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21699. }
  21700. m.SetParentID(v)
  21701. return nil
  21702. case sopnode.FieldName:
  21703. v, ok := value.(string)
  21704. if !ok {
  21705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21706. }
  21707. m.SetName(v)
  21708. return nil
  21709. case sopnode.FieldConditionType:
  21710. v, ok := value.(int)
  21711. if !ok {
  21712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21713. }
  21714. m.SetConditionType(v)
  21715. return nil
  21716. case sopnode.FieldConditionList:
  21717. v, ok := value.([]string)
  21718. if !ok {
  21719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21720. }
  21721. m.SetConditionList(v)
  21722. return nil
  21723. case sopnode.FieldNoReplyCondition:
  21724. v, ok := value.(uint64)
  21725. if !ok {
  21726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21727. }
  21728. m.SetNoReplyCondition(v)
  21729. return nil
  21730. case sopnode.FieldNoReplyUnit:
  21731. v, ok := value.(string)
  21732. if !ok {
  21733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21734. }
  21735. m.SetNoReplyUnit(v)
  21736. return nil
  21737. case sopnode.FieldActionMessage:
  21738. v, ok := value.([]custom_types.Action)
  21739. if !ok {
  21740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21741. }
  21742. m.SetActionMessage(v)
  21743. return nil
  21744. case sopnode.FieldActionLabelAdd:
  21745. v, ok := value.([]uint64)
  21746. if !ok {
  21747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21748. }
  21749. m.SetActionLabelAdd(v)
  21750. return nil
  21751. case sopnode.FieldActionLabelDel:
  21752. v, ok := value.([]uint64)
  21753. if !ok {
  21754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21755. }
  21756. m.SetActionLabelDel(v)
  21757. return nil
  21758. case sopnode.FieldActionForward:
  21759. v, ok := value.(*custom_types.ActionForward)
  21760. if !ok {
  21761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21762. }
  21763. m.SetActionForward(v)
  21764. return nil
  21765. }
  21766. return fmt.Errorf("unknown SopNode field %s", name)
  21767. }
  21768. // AddedFields returns all numeric fields that were incremented/decremented during
  21769. // this mutation.
  21770. func (m *SopNodeMutation) AddedFields() []string {
  21771. var fields []string
  21772. if m.addstatus != nil {
  21773. fields = append(fields, sopnode.FieldStatus)
  21774. }
  21775. if m.addparent_id != nil {
  21776. fields = append(fields, sopnode.FieldParentID)
  21777. }
  21778. if m.addcondition_type != nil {
  21779. fields = append(fields, sopnode.FieldConditionType)
  21780. }
  21781. if m.addno_reply_condition != nil {
  21782. fields = append(fields, sopnode.FieldNoReplyCondition)
  21783. }
  21784. return fields
  21785. }
  21786. // AddedField returns the numeric value that was incremented/decremented on a field
  21787. // with the given name. The second boolean return value indicates that this field
  21788. // was not set, or was not defined in the schema.
  21789. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21790. switch name {
  21791. case sopnode.FieldStatus:
  21792. return m.AddedStatus()
  21793. case sopnode.FieldParentID:
  21794. return m.AddedParentID()
  21795. case sopnode.FieldConditionType:
  21796. return m.AddedConditionType()
  21797. case sopnode.FieldNoReplyCondition:
  21798. return m.AddedNoReplyCondition()
  21799. }
  21800. return nil, false
  21801. }
  21802. // AddField adds the value to the field with the given name. It returns an error if
  21803. // the field is not defined in the schema, or if the type mismatched the field
  21804. // type.
  21805. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21806. switch name {
  21807. case sopnode.FieldStatus:
  21808. v, ok := value.(int8)
  21809. if !ok {
  21810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21811. }
  21812. m.AddStatus(v)
  21813. return nil
  21814. case sopnode.FieldParentID:
  21815. v, ok := value.(int64)
  21816. if !ok {
  21817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21818. }
  21819. m.AddParentID(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.AddConditionType(v)
  21827. return nil
  21828. case sopnode.FieldNoReplyCondition:
  21829. v, ok := value.(int64)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.AddNoReplyCondition(v)
  21834. return nil
  21835. }
  21836. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21837. }
  21838. // ClearedFields returns all nullable fields that were cleared during this
  21839. // mutation.
  21840. func (m *SopNodeMutation) ClearedFields() []string {
  21841. var fields []string
  21842. if m.FieldCleared(sopnode.FieldStatus) {
  21843. fields = append(fields, sopnode.FieldStatus)
  21844. }
  21845. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21846. fields = append(fields, sopnode.FieldDeletedAt)
  21847. }
  21848. if m.FieldCleared(sopnode.FieldConditionList) {
  21849. fields = append(fields, sopnode.FieldConditionList)
  21850. }
  21851. if m.FieldCleared(sopnode.FieldActionMessage) {
  21852. fields = append(fields, sopnode.FieldActionMessage)
  21853. }
  21854. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21855. fields = append(fields, sopnode.FieldActionLabelAdd)
  21856. }
  21857. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21858. fields = append(fields, sopnode.FieldActionLabelDel)
  21859. }
  21860. if m.FieldCleared(sopnode.FieldActionForward) {
  21861. fields = append(fields, sopnode.FieldActionForward)
  21862. }
  21863. return fields
  21864. }
  21865. // FieldCleared returns a boolean indicating if a field with the given name was
  21866. // cleared in this mutation.
  21867. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21868. _, ok := m.clearedFields[name]
  21869. return ok
  21870. }
  21871. // ClearField clears the value of the field with the given name. It returns an
  21872. // error if the field is not defined in the schema.
  21873. func (m *SopNodeMutation) ClearField(name string) error {
  21874. switch name {
  21875. case sopnode.FieldStatus:
  21876. m.ClearStatus()
  21877. return nil
  21878. case sopnode.FieldDeletedAt:
  21879. m.ClearDeletedAt()
  21880. return nil
  21881. case sopnode.FieldConditionList:
  21882. m.ClearConditionList()
  21883. return nil
  21884. case sopnode.FieldActionMessage:
  21885. m.ClearActionMessage()
  21886. return nil
  21887. case sopnode.FieldActionLabelAdd:
  21888. m.ClearActionLabelAdd()
  21889. return nil
  21890. case sopnode.FieldActionLabelDel:
  21891. m.ClearActionLabelDel()
  21892. return nil
  21893. case sopnode.FieldActionForward:
  21894. m.ClearActionForward()
  21895. return nil
  21896. }
  21897. return fmt.Errorf("unknown SopNode nullable field %s", name)
  21898. }
  21899. // ResetField resets all changes in the mutation for the field with the given name.
  21900. // It returns an error if the field is not defined in the schema.
  21901. func (m *SopNodeMutation) ResetField(name string) error {
  21902. switch name {
  21903. case sopnode.FieldCreatedAt:
  21904. m.ResetCreatedAt()
  21905. return nil
  21906. case sopnode.FieldUpdatedAt:
  21907. m.ResetUpdatedAt()
  21908. return nil
  21909. case sopnode.FieldStatus:
  21910. m.ResetStatus()
  21911. return nil
  21912. case sopnode.FieldDeletedAt:
  21913. m.ResetDeletedAt()
  21914. return nil
  21915. case sopnode.FieldStageID:
  21916. m.ResetStageID()
  21917. return nil
  21918. case sopnode.FieldParentID:
  21919. m.ResetParentID()
  21920. return nil
  21921. case sopnode.FieldName:
  21922. m.ResetName()
  21923. return nil
  21924. case sopnode.FieldConditionType:
  21925. m.ResetConditionType()
  21926. return nil
  21927. case sopnode.FieldConditionList:
  21928. m.ResetConditionList()
  21929. return nil
  21930. case sopnode.FieldNoReplyCondition:
  21931. m.ResetNoReplyCondition()
  21932. return nil
  21933. case sopnode.FieldNoReplyUnit:
  21934. m.ResetNoReplyUnit()
  21935. return nil
  21936. case sopnode.FieldActionMessage:
  21937. m.ResetActionMessage()
  21938. return nil
  21939. case sopnode.FieldActionLabelAdd:
  21940. m.ResetActionLabelAdd()
  21941. return nil
  21942. case sopnode.FieldActionLabelDel:
  21943. m.ResetActionLabelDel()
  21944. return nil
  21945. case sopnode.FieldActionForward:
  21946. m.ResetActionForward()
  21947. return nil
  21948. }
  21949. return fmt.Errorf("unknown SopNode field %s", name)
  21950. }
  21951. // AddedEdges returns all edge names that were set/added in this mutation.
  21952. func (m *SopNodeMutation) AddedEdges() []string {
  21953. edges := make([]string, 0, 2)
  21954. if m.sop_stage != nil {
  21955. edges = append(edges, sopnode.EdgeSopStage)
  21956. }
  21957. if m.node_messages != nil {
  21958. edges = append(edges, sopnode.EdgeNodeMessages)
  21959. }
  21960. return edges
  21961. }
  21962. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21963. // name in this mutation.
  21964. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  21965. switch name {
  21966. case sopnode.EdgeSopStage:
  21967. if id := m.sop_stage; id != nil {
  21968. return []ent.Value{*id}
  21969. }
  21970. case sopnode.EdgeNodeMessages:
  21971. ids := make([]ent.Value, 0, len(m.node_messages))
  21972. for id := range m.node_messages {
  21973. ids = append(ids, id)
  21974. }
  21975. return ids
  21976. }
  21977. return nil
  21978. }
  21979. // RemovedEdges returns all edge names that were removed in this mutation.
  21980. func (m *SopNodeMutation) RemovedEdges() []string {
  21981. edges := make([]string, 0, 2)
  21982. if m.removednode_messages != nil {
  21983. edges = append(edges, sopnode.EdgeNodeMessages)
  21984. }
  21985. return edges
  21986. }
  21987. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  21988. // the given name in this mutation.
  21989. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  21990. switch name {
  21991. case sopnode.EdgeNodeMessages:
  21992. ids := make([]ent.Value, 0, len(m.removednode_messages))
  21993. for id := range m.removednode_messages {
  21994. ids = append(ids, id)
  21995. }
  21996. return ids
  21997. }
  21998. return nil
  21999. }
  22000. // ClearedEdges returns all edge names that were cleared in this mutation.
  22001. func (m *SopNodeMutation) ClearedEdges() []string {
  22002. edges := make([]string, 0, 2)
  22003. if m.clearedsop_stage {
  22004. edges = append(edges, sopnode.EdgeSopStage)
  22005. }
  22006. if m.clearednode_messages {
  22007. edges = append(edges, sopnode.EdgeNodeMessages)
  22008. }
  22009. return edges
  22010. }
  22011. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22012. // was cleared in this mutation.
  22013. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22014. switch name {
  22015. case sopnode.EdgeSopStage:
  22016. return m.clearedsop_stage
  22017. case sopnode.EdgeNodeMessages:
  22018. return m.clearednode_messages
  22019. }
  22020. return false
  22021. }
  22022. // ClearEdge clears the value of the edge with the given name. It returns an error
  22023. // if that edge is not defined in the schema.
  22024. func (m *SopNodeMutation) ClearEdge(name string) error {
  22025. switch name {
  22026. case sopnode.EdgeSopStage:
  22027. m.ClearSopStage()
  22028. return nil
  22029. }
  22030. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22031. }
  22032. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22033. // It returns an error if the edge is not defined in the schema.
  22034. func (m *SopNodeMutation) ResetEdge(name string) error {
  22035. switch name {
  22036. case sopnode.EdgeSopStage:
  22037. m.ResetSopStage()
  22038. return nil
  22039. case sopnode.EdgeNodeMessages:
  22040. m.ResetNodeMessages()
  22041. return nil
  22042. }
  22043. return fmt.Errorf("unknown SopNode edge %s", name)
  22044. }
  22045. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22046. type SopStageMutation struct {
  22047. config
  22048. op Op
  22049. typ string
  22050. id *uint64
  22051. created_at *time.Time
  22052. updated_at *time.Time
  22053. status *uint8
  22054. addstatus *int8
  22055. deleted_at *time.Time
  22056. name *string
  22057. condition_type *int
  22058. addcondition_type *int
  22059. condition_operator *int
  22060. addcondition_operator *int
  22061. condition_list *[]custom_types.Condition
  22062. appendcondition_list []custom_types.Condition
  22063. action_message *[]custom_types.Action
  22064. appendaction_message []custom_types.Action
  22065. action_label_add *[]uint64
  22066. appendaction_label_add []uint64
  22067. action_label_del *[]uint64
  22068. appendaction_label_del []uint64
  22069. action_forward **custom_types.ActionForward
  22070. index_sort *int
  22071. addindex_sort *int
  22072. clearedFields map[string]struct{}
  22073. sop_task *uint64
  22074. clearedsop_task bool
  22075. stage_nodes map[uint64]struct{}
  22076. removedstage_nodes map[uint64]struct{}
  22077. clearedstage_nodes bool
  22078. stage_messages map[uint64]struct{}
  22079. removedstage_messages map[uint64]struct{}
  22080. clearedstage_messages bool
  22081. done bool
  22082. oldValue func(context.Context) (*SopStage, error)
  22083. predicates []predicate.SopStage
  22084. }
  22085. var _ ent.Mutation = (*SopStageMutation)(nil)
  22086. // sopstageOption allows management of the mutation configuration using functional options.
  22087. type sopstageOption func(*SopStageMutation)
  22088. // newSopStageMutation creates new mutation for the SopStage entity.
  22089. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22090. m := &SopStageMutation{
  22091. config: c,
  22092. op: op,
  22093. typ: TypeSopStage,
  22094. clearedFields: make(map[string]struct{}),
  22095. }
  22096. for _, opt := range opts {
  22097. opt(m)
  22098. }
  22099. return m
  22100. }
  22101. // withSopStageID sets the ID field of the mutation.
  22102. func withSopStageID(id uint64) sopstageOption {
  22103. return func(m *SopStageMutation) {
  22104. var (
  22105. err error
  22106. once sync.Once
  22107. value *SopStage
  22108. )
  22109. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22110. once.Do(func() {
  22111. if m.done {
  22112. err = errors.New("querying old values post mutation is not allowed")
  22113. } else {
  22114. value, err = m.Client().SopStage.Get(ctx, id)
  22115. }
  22116. })
  22117. return value, err
  22118. }
  22119. m.id = &id
  22120. }
  22121. }
  22122. // withSopStage sets the old SopStage of the mutation.
  22123. func withSopStage(node *SopStage) sopstageOption {
  22124. return func(m *SopStageMutation) {
  22125. m.oldValue = func(context.Context) (*SopStage, error) {
  22126. return node, nil
  22127. }
  22128. m.id = &node.ID
  22129. }
  22130. }
  22131. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22132. // executed in a transaction (ent.Tx), a transactional client is returned.
  22133. func (m SopStageMutation) Client() *Client {
  22134. client := &Client{config: m.config}
  22135. client.init()
  22136. return client
  22137. }
  22138. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22139. // it returns an error otherwise.
  22140. func (m SopStageMutation) Tx() (*Tx, error) {
  22141. if _, ok := m.driver.(*txDriver); !ok {
  22142. return nil, errors.New("ent: mutation is not running in a transaction")
  22143. }
  22144. tx := &Tx{config: m.config}
  22145. tx.init()
  22146. return tx, nil
  22147. }
  22148. // SetID sets the value of the id field. Note that this
  22149. // operation is only accepted on creation of SopStage entities.
  22150. func (m *SopStageMutation) SetID(id uint64) {
  22151. m.id = &id
  22152. }
  22153. // ID returns the ID value in the mutation. Note that the ID is only available
  22154. // if it was provided to the builder or after it was returned from the database.
  22155. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22156. if m.id == nil {
  22157. return
  22158. }
  22159. return *m.id, true
  22160. }
  22161. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22162. // That means, if the mutation is applied within a transaction with an isolation level such
  22163. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22164. // or updated by the mutation.
  22165. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22166. switch {
  22167. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22168. id, exists := m.ID()
  22169. if exists {
  22170. return []uint64{id}, nil
  22171. }
  22172. fallthrough
  22173. case m.op.Is(OpUpdate | OpDelete):
  22174. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22175. default:
  22176. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22177. }
  22178. }
  22179. // SetCreatedAt sets the "created_at" field.
  22180. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22181. m.created_at = &t
  22182. }
  22183. // CreatedAt returns the value of the "created_at" field in the mutation.
  22184. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22185. v := m.created_at
  22186. if v == nil {
  22187. return
  22188. }
  22189. return *v, true
  22190. }
  22191. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22192. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22194. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22195. if !m.op.Is(OpUpdateOne) {
  22196. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22197. }
  22198. if m.id == nil || m.oldValue == nil {
  22199. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22200. }
  22201. oldValue, err := m.oldValue(ctx)
  22202. if err != nil {
  22203. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22204. }
  22205. return oldValue.CreatedAt, nil
  22206. }
  22207. // ResetCreatedAt resets all changes to the "created_at" field.
  22208. func (m *SopStageMutation) ResetCreatedAt() {
  22209. m.created_at = nil
  22210. }
  22211. // SetUpdatedAt sets the "updated_at" field.
  22212. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22213. m.updated_at = &t
  22214. }
  22215. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22216. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22217. v := m.updated_at
  22218. if v == nil {
  22219. return
  22220. }
  22221. return *v, true
  22222. }
  22223. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22224. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22226. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22227. if !m.op.Is(OpUpdateOne) {
  22228. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22229. }
  22230. if m.id == nil || m.oldValue == nil {
  22231. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22232. }
  22233. oldValue, err := m.oldValue(ctx)
  22234. if err != nil {
  22235. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22236. }
  22237. return oldValue.UpdatedAt, nil
  22238. }
  22239. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22240. func (m *SopStageMutation) ResetUpdatedAt() {
  22241. m.updated_at = nil
  22242. }
  22243. // SetStatus sets the "status" field.
  22244. func (m *SopStageMutation) SetStatus(u uint8) {
  22245. m.status = &u
  22246. m.addstatus = nil
  22247. }
  22248. // Status returns the value of the "status" field in the mutation.
  22249. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22250. v := m.status
  22251. if v == nil {
  22252. return
  22253. }
  22254. return *v, true
  22255. }
  22256. // OldStatus returns the old "status" field's value of the SopStage entity.
  22257. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22259. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22260. if !m.op.Is(OpUpdateOne) {
  22261. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22262. }
  22263. if m.id == nil || m.oldValue == nil {
  22264. return v, errors.New("OldStatus requires an ID field in the mutation")
  22265. }
  22266. oldValue, err := m.oldValue(ctx)
  22267. if err != nil {
  22268. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22269. }
  22270. return oldValue.Status, nil
  22271. }
  22272. // AddStatus adds u to the "status" field.
  22273. func (m *SopStageMutation) AddStatus(u int8) {
  22274. if m.addstatus != nil {
  22275. *m.addstatus += u
  22276. } else {
  22277. m.addstatus = &u
  22278. }
  22279. }
  22280. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22281. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22282. v := m.addstatus
  22283. if v == nil {
  22284. return
  22285. }
  22286. return *v, true
  22287. }
  22288. // ClearStatus clears the value of the "status" field.
  22289. func (m *SopStageMutation) ClearStatus() {
  22290. m.status = nil
  22291. m.addstatus = nil
  22292. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22293. }
  22294. // StatusCleared returns if the "status" field was cleared in this mutation.
  22295. func (m *SopStageMutation) StatusCleared() bool {
  22296. _, ok := m.clearedFields[sopstage.FieldStatus]
  22297. return ok
  22298. }
  22299. // ResetStatus resets all changes to the "status" field.
  22300. func (m *SopStageMutation) ResetStatus() {
  22301. m.status = nil
  22302. m.addstatus = nil
  22303. delete(m.clearedFields, sopstage.FieldStatus)
  22304. }
  22305. // SetDeletedAt sets the "deleted_at" field.
  22306. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22307. m.deleted_at = &t
  22308. }
  22309. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22310. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22311. v := m.deleted_at
  22312. if v == nil {
  22313. return
  22314. }
  22315. return *v, true
  22316. }
  22317. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22318. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22319. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22320. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22321. if !m.op.Is(OpUpdateOne) {
  22322. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22323. }
  22324. if m.id == nil || m.oldValue == nil {
  22325. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22326. }
  22327. oldValue, err := m.oldValue(ctx)
  22328. if err != nil {
  22329. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22330. }
  22331. return oldValue.DeletedAt, nil
  22332. }
  22333. // ClearDeletedAt clears the value of the "deleted_at" field.
  22334. func (m *SopStageMutation) ClearDeletedAt() {
  22335. m.deleted_at = nil
  22336. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22337. }
  22338. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22339. func (m *SopStageMutation) DeletedAtCleared() bool {
  22340. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22341. return ok
  22342. }
  22343. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22344. func (m *SopStageMutation) ResetDeletedAt() {
  22345. m.deleted_at = nil
  22346. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22347. }
  22348. // SetTaskID sets the "task_id" field.
  22349. func (m *SopStageMutation) SetTaskID(u uint64) {
  22350. m.sop_task = &u
  22351. }
  22352. // TaskID returns the value of the "task_id" field in the mutation.
  22353. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22354. v := m.sop_task
  22355. if v == nil {
  22356. return
  22357. }
  22358. return *v, true
  22359. }
  22360. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22361. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22363. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22364. if !m.op.Is(OpUpdateOne) {
  22365. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22366. }
  22367. if m.id == nil || m.oldValue == nil {
  22368. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22369. }
  22370. oldValue, err := m.oldValue(ctx)
  22371. if err != nil {
  22372. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22373. }
  22374. return oldValue.TaskID, nil
  22375. }
  22376. // ResetTaskID resets all changes to the "task_id" field.
  22377. func (m *SopStageMutation) ResetTaskID() {
  22378. m.sop_task = nil
  22379. }
  22380. // SetName sets the "name" field.
  22381. func (m *SopStageMutation) SetName(s string) {
  22382. m.name = &s
  22383. }
  22384. // Name returns the value of the "name" field in the mutation.
  22385. func (m *SopStageMutation) Name() (r string, exists bool) {
  22386. v := m.name
  22387. if v == nil {
  22388. return
  22389. }
  22390. return *v, true
  22391. }
  22392. // OldName returns the old "name" field's value of the SopStage entity.
  22393. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22395. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22396. if !m.op.Is(OpUpdateOne) {
  22397. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22398. }
  22399. if m.id == nil || m.oldValue == nil {
  22400. return v, errors.New("OldName requires an ID field in the mutation")
  22401. }
  22402. oldValue, err := m.oldValue(ctx)
  22403. if err != nil {
  22404. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22405. }
  22406. return oldValue.Name, nil
  22407. }
  22408. // ResetName resets all changes to the "name" field.
  22409. func (m *SopStageMutation) ResetName() {
  22410. m.name = nil
  22411. }
  22412. // SetConditionType sets the "condition_type" field.
  22413. func (m *SopStageMutation) SetConditionType(i int) {
  22414. m.condition_type = &i
  22415. m.addcondition_type = nil
  22416. }
  22417. // ConditionType returns the value of the "condition_type" field in the mutation.
  22418. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22419. v := m.condition_type
  22420. if v == nil {
  22421. return
  22422. }
  22423. return *v, true
  22424. }
  22425. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22426. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22427. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22428. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22429. if !m.op.Is(OpUpdateOne) {
  22430. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22431. }
  22432. if m.id == nil || m.oldValue == nil {
  22433. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22434. }
  22435. oldValue, err := m.oldValue(ctx)
  22436. if err != nil {
  22437. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22438. }
  22439. return oldValue.ConditionType, nil
  22440. }
  22441. // AddConditionType adds i to the "condition_type" field.
  22442. func (m *SopStageMutation) AddConditionType(i int) {
  22443. if m.addcondition_type != nil {
  22444. *m.addcondition_type += i
  22445. } else {
  22446. m.addcondition_type = &i
  22447. }
  22448. }
  22449. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22450. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22451. v := m.addcondition_type
  22452. if v == nil {
  22453. return
  22454. }
  22455. return *v, true
  22456. }
  22457. // ResetConditionType resets all changes to the "condition_type" field.
  22458. func (m *SopStageMutation) ResetConditionType() {
  22459. m.condition_type = nil
  22460. m.addcondition_type = nil
  22461. }
  22462. // SetConditionOperator sets the "condition_operator" field.
  22463. func (m *SopStageMutation) SetConditionOperator(i int) {
  22464. m.condition_operator = &i
  22465. m.addcondition_operator = nil
  22466. }
  22467. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22468. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22469. v := m.condition_operator
  22470. if v == nil {
  22471. return
  22472. }
  22473. return *v, true
  22474. }
  22475. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22476. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22478. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22479. if !m.op.Is(OpUpdateOne) {
  22480. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22481. }
  22482. if m.id == nil || m.oldValue == nil {
  22483. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22484. }
  22485. oldValue, err := m.oldValue(ctx)
  22486. if err != nil {
  22487. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22488. }
  22489. return oldValue.ConditionOperator, nil
  22490. }
  22491. // AddConditionOperator adds i to the "condition_operator" field.
  22492. func (m *SopStageMutation) AddConditionOperator(i int) {
  22493. if m.addcondition_operator != nil {
  22494. *m.addcondition_operator += i
  22495. } else {
  22496. m.addcondition_operator = &i
  22497. }
  22498. }
  22499. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22500. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22501. v := m.addcondition_operator
  22502. if v == nil {
  22503. return
  22504. }
  22505. return *v, true
  22506. }
  22507. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22508. func (m *SopStageMutation) ResetConditionOperator() {
  22509. m.condition_operator = nil
  22510. m.addcondition_operator = nil
  22511. }
  22512. // SetConditionList sets the "condition_list" field.
  22513. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22514. m.condition_list = &ct
  22515. m.appendcondition_list = nil
  22516. }
  22517. // ConditionList returns the value of the "condition_list" field in the mutation.
  22518. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22519. v := m.condition_list
  22520. if v == nil {
  22521. return
  22522. }
  22523. return *v, true
  22524. }
  22525. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22526. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22528. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22529. if !m.op.Is(OpUpdateOne) {
  22530. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22531. }
  22532. if m.id == nil || m.oldValue == nil {
  22533. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22534. }
  22535. oldValue, err := m.oldValue(ctx)
  22536. if err != nil {
  22537. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22538. }
  22539. return oldValue.ConditionList, nil
  22540. }
  22541. // AppendConditionList adds ct to the "condition_list" field.
  22542. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22543. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22544. }
  22545. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22546. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22547. if len(m.appendcondition_list) == 0 {
  22548. return nil, false
  22549. }
  22550. return m.appendcondition_list, true
  22551. }
  22552. // ResetConditionList resets all changes to the "condition_list" field.
  22553. func (m *SopStageMutation) ResetConditionList() {
  22554. m.condition_list = nil
  22555. m.appendcondition_list = nil
  22556. }
  22557. // SetActionMessage sets the "action_message" field.
  22558. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22559. m.action_message = &ct
  22560. m.appendaction_message = nil
  22561. }
  22562. // ActionMessage returns the value of the "action_message" field in the mutation.
  22563. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22564. v := m.action_message
  22565. if v == nil {
  22566. return
  22567. }
  22568. return *v, true
  22569. }
  22570. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22571. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22572. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22573. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22574. if !m.op.Is(OpUpdateOne) {
  22575. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22576. }
  22577. if m.id == nil || m.oldValue == nil {
  22578. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22579. }
  22580. oldValue, err := m.oldValue(ctx)
  22581. if err != nil {
  22582. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22583. }
  22584. return oldValue.ActionMessage, nil
  22585. }
  22586. // AppendActionMessage adds ct to the "action_message" field.
  22587. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22588. m.appendaction_message = append(m.appendaction_message, ct...)
  22589. }
  22590. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22591. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22592. if len(m.appendaction_message) == 0 {
  22593. return nil, false
  22594. }
  22595. return m.appendaction_message, true
  22596. }
  22597. // ClearActionMessage clears the value of the "action_message" field.
  22598. func (m *SopStageMutation) ClearActionMessage() {
  22599. m.action_message = nil
  22600. m.appendaction_message = nil
  22601. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22602. }
  22603. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22604. func (m *SopStageMutation) ActionMessageCleared() bool {
  22605. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22606. return ok
  22607. }
  22608. // ResetActionMessage resets all changes to the "action_message" field.
  22609. func (m *SopStageMutation) ResetActionMessage() {
  22610. m.action_message = nil
  22611. m.appendaction_message = nil
  22612. delete(m.clearedFields, sopstage.FieldActionMessage)
  22613. }
  22614. // SetActionLabelAdd sets the "action_label_add" field.
  22615. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22616. m.action_label_add = &u
  22617. m.appendaction_label_add = nil
  22618. }
  22619. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22620. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22621. v := m.action_label_add
  22622. if v == nil {
  22623. return
  22624. }
  22625. return *v, true
  22626. }
  22627. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22628. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22630. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22631. if !m.op.Is(OpUpdateOne) {
  22632. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22633. }
  22634. if m.id == nil || m.oldValue == nil {
  22635. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22636. }
  22637. oldValue, err := m.oldValue(ctx)
  22638. if err != nil {
  22639. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22640. }
  22641. return oldValue.ActionLabelAdd, nil
  22642. }
  22643. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22644. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22645. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22646. }
  22647. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22648. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22649. if len(m.appendaction_label_add) == 0 {
  22650. return nil, false
  22651. }
  22652. return m.appendaction_label_add, true
  22653. }
  22654. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22655. func (m *SopStageMutation) ClearActionLabelAdd() {
  22656. m.action_label_add = nil
  22657. m.appendaction_label_add = nil
  22658. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22659. }
  22660. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22661. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22662. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22663. return ok
  22664. }
  22665. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22666. func (m *SopStageMutation) ResetActionLabelAdd() {
  22667. m.action_label_add = nil
  22668. m.appendaction_label_add = nil
  22669. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22670. }
  22671. // SetActionLabelDel sets the "action_label_del" field.
  22672. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22673. m.action_label_del = &u
  22674. m.appendaction_label_del = nil
  22675. }
  22676. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22677. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22678. v := m.action_label_del
  22679. if v == nil {
  22680. return
  22681. }
  22682. return *v, true
  22683. }
  22684. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22685. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22687. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22688. if !m.op.Is(OpUpdateOne) {
  22689. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22690. }
  22691. if m.id == nil || m.oldValue == nil {
  22692. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22693. }
  22694. oldValue, err := m.oldValue(ctx)
  22695. if err != nil {
  22696. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22697. }
  22698. return oldValue.ActionLabelDel, nil
  22699. }
  22700. // AppendActionLabelDel adds u to the "action_label_del" field.
  22701. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22702. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22703. }
  22704. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22705. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22706. if len(m.appendaction_label_del) == 0 {
  22707. return nil, false
  22708. }
  22709. return m.appendaction_label_del, true
  22710. }
  22711. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22712. func (m *SopStageMutation) ClearActionLabelDel() {
  22713. m.action_label_del = nil
  22714. m.appendaction_label_del = nil
  22715. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22716. }
  22717. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22718. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22719. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22720. return ok
  22721. }
  22722. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22723. func (m *SopStageMutation) ResetActionLabelDel() {
  22724. m.action_label_del = nil
  22725. m.appendaction_label_del = nil
  22726. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22727. }
  22728. // SetActionForward sets the "action_forward" field.
  22729. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22730. m.action_forward = &ctf
  22731. }
  22732. // ActionForward returns the value of the "action_forward" field in the mutation.
  22733. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22734. v := m.action_forward
  22735. if v == nil {
  22736. return
  22737. }
  22738. return *v, true
  22739. }
  22740. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22741. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22742. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22743. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22744. if !m.op.Is(OpUpdateOne) {
  22745. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22746. }
  22747. if m.id == nil || m.oldValue == nil {
  22748. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22749. }
  22750. oldValue, err := m.oldValue(ctx)
  22751. if err != nil {
  22752. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22753. }
  22754. return oldValue.ActionForward, nil
  22755. }
  22756. // ClearActionForward clears the value of the "action_forward" field.
  22757. func (m *SopStageMutation) ClearActionForward() {
  22758. m.action_forward = nil
  22759. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22760. }
  22761. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22762. func (m *SopStageMutation) ActionForwardCleared() bool {
  22763. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22764. return ok
  22765. }
  22766. // ResetActionForward resets all changes to the "action_forward" field.
  22767. func (m *SopStageMutation) ResetActionForward() {
  22768. m.action_forward = nil
  22769. delete(m.clearedFields, sopstage.FieldActionForward)
  22770. }
  22771. // SetIndexSort sets the "index_sort" field.
  22772. func (m *SopStageMutation) SetIndexSort(i int) {
  22773. m.index_sort = &i
  22774. m.addindex_sort = nil
  22775. }
  22776. // IndexSort returns the value of the "index_sort" field in the mutation.
  22777. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22778. v := m.index_sort
  22779. if v == nil {
  22780. return
  22781. }
  22782. return *v, true
  22783. }
  22784. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22785. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22786. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22787. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22788. if !m.op.Is(OpUpdateOne) {
  22789. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22790. }
  22791. if m.id == nil || m.oldValue == nil {
  22792. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22793. }
  22794. oldValue, err := m.oldValue(ctx)
  22795. if err != nil {
  22796. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22797. }
  22798. return oldValue.IndexSort, nil
  22799. }
  22800. // AddIndexSort adds i to the "index_sort" field.
  22801. func (m *SopStageMutation) AddIndexSort(i int) {
  22802. if m.addindex_sort != nil {
  22803. *m.addindex_sort += i
  22804. } else {
  22805. m.addindex_sort = &i
  22806. }
  22807. }
  22808. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22809. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22810. v := m.addindex_sort
  22811. if v == nil {
  22812. return
  22813. }
  22814. return *v, true
  22815. }
  22816. // ClearIndexSort clears the value of the "index_sort" field.
  22817. func (m *SopStageMutation) ClearIndexSort() {
  22818. m.index_sort = nil
  22819. m.addindex_sort = nil
  22820. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22821. }
  22822. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22823. func (m *SopStageMutation) IndexSortCleared() bool {
  22824. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22825. return ok
  22826. }
  22827. // ResetIndexSort resets all changes to the "index_sort" field.
  22828. func (m *SopStageMutation) ResetIndexSort() {
  22829. m.index_sort = nil
  22830. m.addindex_sort = nil
  22831. delete(m.clearedFields, sopstage.FieldIndexSort)
  22832. }
  22833. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22834. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22835. m.sop_task = &id
  22836. }
  22837. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22838. func (m *SopStageMutation) ClearSopTask() {
  22839. m.clearedsop_task = true
  22840. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22841. }
  22842. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22843. func (m *SopStageMutation) SopTaskCleared() bool {
  22844. return m.clearedsop_task
  22845. }
  22846. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22847. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22848. if m.sop_task != nil {
  22849. return *m.sop_task, true
  22850. }
  22851. return
  22852. }
  22853. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22854. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22855. // SopTaskID instead. It exists only for internal usage by the builders.
  22856. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22857. if id := m.sop_task; id != nil {
  22858. ids = append(ids, *id)
  22859. }
  22860. return
  22861. }
  22862. // ResetSopTask resets all changes to the "sop_task" edge.
  22863. func (m *SopStageMutation) ResetSopTask() {
  22864. m.sop_task = nil
  22865. m.clearedsop_task = false
  22866. }
  22867. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22868. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22869. if m.stage_nodes == nil {
  22870. m.stage_nodes = make(map[uint64]struct{})
  22871. }
  22872. for i := range ids {
  22873. m.stage_nodes[ids[i]] = struct{}{}
  22874. }
  22875. }
  22876. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22877. func (m *SopStageMutation) ClearStageNodes() {
  22878. m.clearedstage_nodes = true
  22879. }
  22880. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22881. func (m *SopStageMutation) StageNodesCleared() bool {
  22882. return m.clearedstage_nodes
  22883. }
  22884. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22885. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22886. if m.removedstage_nodes == nil {
  22887. m.removedstage_nodes = make(map[uint64]struct{})
  22888. }
  22889. for i := range ids {
  22890. delete(m.stage_nodes, ids[i])
  22891. m.removedstage_nodes[ids[i]] = struct{}{}
  22892. }
  22893. }
  22894. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  22895. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  22896. for id := range m.removedstage_nodes {
  22897. ids = append(ids, id)
  22898. }
  22899. return
  22900. }
  22901. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  22902. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  22903. for id := range m.stage_nodes {
  22904. ids = append(ids, id)
  22905. }
  22906. return
  22907. }
  22908. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  22909. func (m *SopStageMutation) ResetStageNodes() {
  22910. m.stage_nodes = nil
  22911. m.clearedstage_nodes = false
  22912. m.removedstage_nodes = nil
  22913. }
  22914. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  22915. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  22916. if m.stage_messages == nil {
  22917. m.stage_messages = make(map[uint64]struct{})
  22918. }
  22919. for i := range ids {
  22920. m.stage_messages[ids[i]] = struct{}{}
  22921. }
  22922. }
  22923. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  22924. func (m *SopStageMutation) ClearStageMessages() {
  22925. m.clearedstage_messages = true
  22926. }
  22927. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  22928. func (m *SopStageMutation) StageMessagesCleared() bool {
  22929. return m.clearedstage_messages
  22930. }
  22931. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  22932. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  22933. if m.removedstage_messages == nil {
  22934. m.removedstage_messages = make(map[uint64]struct{})
  22935. }
  22936. for i := range ids {
  22937. delete(m.stage_messages, ids[i])
  22938. m.removedstage_messages[ids[i]] = struct{}{}
  22939. }
  22940. }
  22941. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  22942. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  22943. for id := range m.removedstage_messages {
  22944. ids = append(ids, id)
  22945. }
  22946. return
  22947. }
  22948. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  22949. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  22950. for id := range m.stage_messages {
  22951. ids = append(ids, id)
  22952. }
  22953. return
  22954. }
  22955. // ResetStageMessages resets all changes to the "stage_messages" edge.
  22956. func (m *SopStageMutation) ResetStageMessages() {
  22957. m.stage_messages = nil
  22958. m.clearedstage_messages = false
  22959. m.removedstage_messages = nil
  22960. }
  22961. // Where appends a list predicates to the SopStageMutation builder.
  22962. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  22963. m.predicates = append(m.predicates, ps...)
  22964. }
  22965. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  22966. // users can use type-assertion to append predicates that do not depend on any generated package.
  22967. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  22968. p := make([]predicate.SopStage, len(ps))
  22969. for i := range ps {
  22970. p[i] = ps[i]
  22971. }
  22972. m.Where(p...)
  22973. }
  22974. // Op returns the operation name.
  22975. func (m *SopStageMutation) Op() Op {
  22976. return m.op
  22977. }
  22978. // SetOp allows setting the mutation operation.
  22979. func (m *SopStageMutation) SetOp(op Op) {
  22980. m.op = op
  22981. }
  22982. // Type returns the node type of this mutation (SopStage).
  22983. func (m *SopStageMutation) Type() string {
  22984. return m.typ
  22985. }
  22986. // Fields returns all fields that were changed during this mutation. Note that in
  22987. // order to get all numeric fields that were incremented/decremented, call
  22988. // AddedFields().
  22989. func (m *SopStageMutation) Fields() []string {
  22990. fields := make([]string, 0, 14)
  22991. if m.created_at != nil {
  22992. fields = append(fields, sopstage.FieldCreatedAt)
  22993. }
  22994. if m.updated_at != nil {
  22995. fields = append(fields, sopstage.FieldUpdatedAt)
  22996. }
  22997. if m.status != nil {
  22998. fields = append(fields, sopstage.FieldStatus)
  22999. }
  23000. if m.deleted_at != nil {
  23001. fields = append(fields, sopstage.FieldDeletedAt)
  23002. }
  23003. if m.sop_task != nil {
  23004. fields = append(fields, sopstage.FieldTaskID)
  23005. }
  23006. if m.name != nil {
  23007. fields = append(fields, sopstage.FieldName)
  23008. }
  23009. if m.condition_type != nil {
  23010. fields = append(fields, sopstage.FieldConditionType)
  23011. }
  23012. if m.condition_operator != nil {
  23013. fields = append(fields, sopstage.FieldConditionOperator)
  23014. }
  23015. if m.condition_list != nil {
  23016. fields = append(fields, sopstage.FieldConditionList)
  23017. }
  23018. if m.action_message != nil {
  23019. fields = append(fields, sopstage.FieldActionMessage)
  23020. }
  23021. if m.action_label_add != nil {
  23022. fields = append(fields, sopstage.FieldActionLabelAdd)
  23023. }
  23024. if m.action_label_del != nil {
  23025. fields = append(fields, sopstage.FieldActionLabelDel)
  23026. }
  23027. if m.action_forward != nil {
  23028. fields = append(fields, sopstage.FieldActionForward)
  23029. }
  23030. if m.index_sort != nil {
  23031. fields = append(fields, sopstage.FieldIndexSort)
  23032. }
  23033. return fields
  23034. }
  23035. // Field returns the value of a field with the given name. The second boolean
  23036. // return value indicates that this field was not set, or was not defined in the
  23037. // schema.
  23038. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23039. switch name {
  23040. case sopstage.FieldCreatedAt:
  23041. return m.CreatedAt()
  23042. case sopstage.FieldUpdatedAt:
  23043. return m.UpdatedAt()
  23044. case sopstage.FieldStatus:
  23045. return m.Status()
  23046. case sopstage.FieldDeletedAt:
  23047. return m.DeletedAt()
  23048. case sopstage.FieldTaskID:
  23049. return m.TaskID()
  23050. case sopstage.FieldName:
  23051. return m.Name()
  23052. case sopstage.FieldConditionType:
  23053. return m.ConditionType()
  23054. case sopstage.FieldConditionOperator:
  23055. return m.ConditionOperator()
  23056. case sopstage.FieldConditionList:
  23057. return m.ConditionList()
  23058. case sopstage.FieldActionMessage:
  23059. return m.ActionMessage()
  23060. case sopstage.FieldActionLabelAdd:
  23061. return m.ActionLabelAdd()
  23062. case sopstage.FieldActionLabelDel:
  23063. return m.ActionLabelDel()
  23064. case sopstage.FieldActionForward:
  23065. return m.ActionForward()
  23066. case sopstage.FieldIndexSort:
  23067. return m.IndexSort()
  23068. }
  23069. return nil, false
  23070. }
  23071. // OldField returns the old value of the field from the database. An error is
  23072. // returned if the mutation operation is not UpdateOne, or the query to the
  23073. // database failed.
  23074. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23075. switch name {
  23076. case sopstage.FieldCreatedAt:
  23077. return m.OldCreatedAt(ctx)
  23078. case sopstage.FieldUpdatedAt:
  23079. return m.OldUpdatedAt(ctx)
  23080. case sopstage.FieldStatus:
  23081. return m.OldStatus(ctx)
  23082. case sopstage.FieldDeletedAt:
  23083. return m.OldDeletedAt(ctx)
  23084. case sopstage.FieldTaskID:
  23085. return m.OldTaskID(ctx)
  23086. case sopstage.FieldName:
  23087. return m.OldName(ctx)
  23088. case sopstage.FieldConditionType:
  23089. return m.OldConditionType(ctx)
  23090. case sopstage.FieldConditionOperator:
  23091. return m.OldConditionOperator(ctx)
  23092. case sopstage.FieldConditionList:
  23093. return m.OldConditionList(ctx)
  23094. case sopstage.FieldActionMessage:
  23095. return m.OldActionMessage(ctx)
  23096. case sopstage.FieldActionLabelAdd:
  23097. return m.OldActionLabelAdd(ctx)
  23098. case sopstage.FieldActionLabelDel:
  23099. return m.OldActionLabelDel(ctx)
  23100. case sopstage.FieldActionForward:
  23101. return m.OldActionForward(ctx)
  23102. case sopstage.FieldIndexSort:
  23103. return m.OldIndexSort(ctx)
  23104. }
  23105. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23106. }
  23107. // SetField sets the value of a field with the given name. It returns an error if
  23108. // the field is not defined in the schema, or if the type mismatched the field
  23109. // type.
  23110. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23111. switch name {
  23112. case sopstage.FieldCreatedAt:
  23113. v, ok := value.(time.Time)
  23114. if !ok {
  23115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23116. }
  23117. m.SetCreatedAt(v)
  23118. return nil
  23119. case sopstage.FieldUpdatedAt:
  23120. v, ok := value.(time.Time)
  23121. if !ok {
  23122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23123. }
  23124. m.SetUpdatedAt(v)
  23125. return nil
  23126. case sopstage.FieldStatus:
  23127. v, ok := value.(uint8)
  23128. if !ok {
  23129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23130. }
  23131. m.SetStatus(v)
  23132. return nil
  23133. case sopstage.FieldDeletedAt:
  23134. v, ok := value.(time.Time)
  23135. if !ok {
  23136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23137. }
  23138. m.SetDeletedAt(v)
  23139. return nil
  23140. case sopstage.FieldTaskID:
  23141. v, ok := value.(uint64)
  23142. if !ok {
  23143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23144. }
  23145. m.SetTaskID(v)
  23146. return nil
  23147. case sopstage.FieldName:
  23148. v, ok := value.(string)
  23149. if !ok {
  23150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23151. }
  23152. m.SetName(v)
  23153. return nil
  23154. case sopstage.FieldConditionType:
  23155. v, ok := value.(int)
  23156. if !ok {
  23157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23158. }
  23159. m.SetConditionType(v)
  23160. return nil
  23161. case sopstage.FieldConditionOperator:
  23162. v, ok := value.(int)
  23163. if !ok {
  23164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23165. }
  23166. m.SetConditionOperator(v)
  23167. return nil
  23168. case sopstage.FieldConditionList:
  23169. v, ok := value.([]custom_types.Condition)
  23170. if !ok {
  23171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23172. }
  23173. m.SetConditionList(v)
  23174. return nil
  23175. case sopstage.FieldActionMessage:
  23176. v, ok := value.([]custom_types.Action)
  23177. if !ok {
  23178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23179. }
  23180. m.SetActionMessage(v)
  23181. return nil
  23182. case sopstage.FieldActionLabelAdd:
  23183. v, ok := value.([]uint64)
  23184. if !ok {
  23185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23186. }
  23187. m.SetActionLabelAdd(v)
  23188. return nil
  23189. case sopstage.FieldActionLabelDel:
  23190. v, ok := value.([]uint64)
  23191. if !ok {
  23192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23193. }
  23194. m.SetActionLabelDel(v)
  23195. return nil
  23196. case sopstage.FieldActionForward:
  23197. v, ok := value.(*custom_types.ActionForward)
  23198. if !ok {
  23199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23200. }
  23201. m.SetActionForward(v)
  23202. return nil
  23203. case sopstage.FieldIndexSort:
  23204. v, ok := value.(int)
  23205. if !ok {
  23206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23207. }
  23208. m.SetIndexSort(v)
  23209. return nil
  23210. }
  23211. return fmt.Errorf("unknown SopStage field %s", name)
  23212. }
  23213. // AddedFields returns all numeric fields that were incremented/decremented during
  23214. // this mutation.
  23215. func (m *SopStageMutation) AddedFields() []string {
  23216. var fields []string
  23217. if m.addstatus != nil {
  23218. fields = append(fields, sopstage.FieldStatus)
  23219. }
  23220. if m.addcondition_type != nil {
  23221. fields = append(fields, sopstage.FieldConditionType)
  23222. }
  23223. if m.addcondition_operator != nil {
  23224. fields = append(fields, sopstage.FieldConditionOperator)
  23225. }
  23226. if m.addindex_sort != nil {
  23227. fields = append(fields, sopstage.FieldIndexSort)
  23228. }
  23229. return fields
  23230. }
  23231. // AddedField returns the numeric value that was incremented/decremented on a field
  23232. // with the given name. The second boolean return value indicates that this field
  23233. // was not set, or was not defined in the schema.
  23234. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23235. switch name {
  23236. case sopstage.FieldStatus:
  23237. return m.AddedStatus()
  23238. case sopstage.FieldConditionType:
  23239. return m.AddedConditionType()
  23240. case sopstage.FieldConditionOperator:
  23241. return m.AddedConditionOperator()
  23242. case sopstage.FieldIndexSort:
  23243. return m.AddedIndexSort()
  23244. }
  23245. return nil, false
  23246. }
  23247. // AddField adds the value to the field with the given name. It returns an error if
  23248. // the field is not defined in the schema, or if the type mismatched the field
  23249. // type.
  23250. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23251. switch name {
  23252. case sopstage.FieldStatus:
  23253. v, ok := value.(int8)
  23254. if !ok {
  23255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23256. }
  23257. m.AddStatus(v)
  23258. return nil
  23259. case sopstage.FieldConditionType:
  23260. v, ok := value.(int)
  23261. if !ok {
  23262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23263. }
  23264. m.AddConditionType(v)
  23265. return nil
  23266. case sopstage.FieldConditionOperator:
  23267. v, ok := value.(int)
  23268. if !ok {
  23269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23270. }
  23271. m.AddConditionOperator(v)
  23272. return nil
  23273. case sopstage.FieldIndexSort:
  23274. v, ok := value.(int)
  23275. if !ok {
  23276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23277. }
  23278. m.AddIndexSort(v)
  23279. return nil
  23280. }
  23281. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23282. }
  23283. // ClearedFields returns all nullable fields that were cleared during this
  23284. // mutation.
  23285. func (m *SopStageMutation) ClearedFields() []string {
  23286. var fields []string
  23287. if m.FieldCleared(sopstage.FieldStatus) {
  23288. fields = append(fields, sopstage.FieldStatus)
  23289. }
  23290. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23291. fields = append(fields, sopstage.FieldDeletedAt)
  23292. }
  23293. if m.FieldCleared(sopstage.FieldActionMessage) {
  23294. fields = append(fields, sopstage.FieldActionMessage)
  23295. }
  23296. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23297. fields = append(fields, sopstage.FieldActionLabelAdd)
  23298. }
  23299. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23300. fields = append(fields, sopstage.FieldActionLabelDel)
  23301. }
  23302. if m.FieldCleared(sopstage.FieldActionForward) {
  23303. fields = append(fields, sopstage.FieldActionForward)
  23304. }
  23305. if m.FieldCleared(sopstage.FieldIndexSort) {
  23306. fields = append(fields, sopstage.FieldIndexSort)
  23307. }
  23308. return fields
  23309. }
  23310. // FieldCleared returns a boolean indicating if a field with the given name was
  23311. // cleared in this mutation.
  23312. func (m *SopStageMutation) FieldCleared(name string) bool {
  23313. _, ok := m.clearedFields[name]
  23314. return ok
  23315. }
  23316. // ClearField clears the value of the field with the given name. It returns an
  23317. // error if the field is not defined in the schema.
  23318. func (m *SopStageMutation) ClearField(name string) error {
  23319. switch name {
  23320. case sopstage.FieldStatus:
  23321. m.ClearStatus()
  23322. return nil
  23323. case sopstage.FieldDeletedAt:
  23324. m.ClearDeletedAt()
  23325. return nil
  23326. case sopstage.FieldActionMessage:
  23327. m.ClearActionMessage()
  23328. return nil
  23329. case sopstage.FieldActionLabelAdd:
  23330. m.ClearActionLabelAdd()
  23331. return nil
  23332. case sopstage.FieldActionLabelDel:
  23333. m.ClearActionLabelDel()
  23334. return nil
  23335. case sopstage.FieldActionForward:
  23336. m.ClearActionForward()
  23337. return nil
  23338. case sopstage.FieldIndexSort:
  23339. m.ClearIndexSort()
  23340. return nil
  23341. }
  23342. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23343. }
  23344. // ResetField resets all changes in the mutation for the field with the given name.
  23345. // It returns an error if the field is not defined in the schema.
  23346. func (m *SopStageMutation) ResetField(name string) error {
  23347. switch name {
  23348. case sopstage.FieldCreatedAt:
  23349. m.ResetCreatedAt()
  23350. return nil
  23351. case sopstage.FieldUpdatedAt:
  23352. m.ResetUpdatedAt()
  23353. return nil
  23354. case sopstage.FieldStatus:
  23355. m.ResetStatus()
  23356. return nil
  23357. case sopstage.FieldDeletedAt:
  23358. m.ResetDeletedAt()
  23359. return nil
  23360. case sopstage.FieldTaskID:
  23361. m.ResetTaskID()
  23362. return nil
  23363. case sopstage.FieldName:
  23364. m.ResetName()
  23365. return nil
  23366. case sopstage.FieldConditionType:
  23367. m.ResetConditionType()
  23368. return nil
  23369. case sopstage.FieldConditionOperator:
  23370. m.ResetConditionOperator()
  23371. return nil
  23372. case sopstage.FieldConditionList:
  23373. m.ResetConditionList()
  23374. return nil
  23375. case sopstage.FieldActionMessage:
  23376. m.ResetActionMessage()
  23377. return nil
  23378. case sopstage.FieldActionLabelAdd:
  23379. m.ResetActionLabelAdd()
  23380. return nil
  23381. case sopstage.FieldActionLabelDel:
  23382. m.ResetActionLabelDel()
  23383. return nil
  23384. case sopstage.FieldActionForward:
  23385. m.ResetActionForward()
  23386. return nil
  23387. case sopstage.FieldIndexSort:
  23388. m.ResetIndexSort()
  23389. return nil
  23390. }
  23391. return fmt.Errorf("unknown SopStage field %s", name)
  23392. }
  23393. // AddedEdges returns all edge names that were set/added in this mutation.
  23394. func (m *SopStageMutation) AddedEdges() []string {
  23395. edges := make([]string, 0, 3)
  23396. if m.sop_task != nil {
  23397. edges = append(edges, sopstage.EdgeSopTask)
  23398. }
  23399. if m.stage_nodes != nil {
  23400. edges = append(edges, sopstage.EdgeStageNodes)
  23401. }
  23402. if m.stage_messages != nil {
  23403. edges = append(edges, sopstage.EdgeStageMessages)
  23404. }
  23405. return edges
  23406. }
  23407. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23408. // name in this mutation.
  23409. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23410. switch name {
  23411. case sopstage.EdgeSopTask:
  23412. if id := m.sop_task; id != nil {
  23413. return []ent.Value{*id}
  23414. }
  23415. case sopstage.EdgeStageNodes:
  23416. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23417. for id := range m.stage_nodes {
  23418. ids = append(ids, id)
  23419. }
  23420. return ids
  23421. case sopstage.EdgeStageMessages:
  23422. ids := make([]ent.Value, 0, len(m.stage_messages))
  23423. for id := range m.stage_messages {
  23424. ids = append(ids, id)
  23425. }
  23426. return ids
  23427. }
  23428. return nil
  23429. }
  23430. // RemovedEdges returns all edge names that were removed in this mutation.
  23431. func (m *SopStageMutation) RemovedEdges() []string {
  23432. edges := make([]string, 0, 3)
  23433. if m.removedstage_nodes != nil {
  23434. edges = append(edges, sopstage.EdgeStageNodes)
  23435. }
  23436. if m.removedstage_messages != nil {
  23437. edges = append(edges, sopstage.EdgeStageMessages)
  23438. }
  23439. return edges
  23440. }
  23441. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23442. // the given name in this mutation.
  23443. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23444. switch name {
  23445. case sopstage.EdgeStageNodes:
  23446. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23447. for id := range m.removedstage_nodes {
  23448. ids = append(ids, id)
  23449. }
  23450. return ids
  23451. case sopstage.EdgeStageMessages:
  23452. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23453. for id := range m.removedstage_messages {
  23454. ids = append(ids, id)
  23455. }
  23456. return ids
  23457. }
  23458. return nil
  23459. }
  23460. // ClearedEdges returns all edge names that were cleared in this mutation.
  23461. func (m *SopStageMutation) ClearedEdges() []string {
  23462. edges := make([]string, 0, 3)
  23463. if m.clearedsop_task {
  23464. edges = append(edges, sopstage.EdgeSopTask)
  23465. }
  23466. if m.clearedstage_nodes {
  23467. edges = append(edges, sopstage.EdgeStageNodes)
  23468. }
  23469. if m.clearedstage_messages {
  23470. edges = append(edges, sopstage.EdgeStageMessages)
  23471. }
  23472. return edges
  23473. }
  23474. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23475. // was cleared in this mutation.
  23476. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23477. switch name {
  23478. case sopstage.EdgeSopTask:
  23479. return m.clearedsop_task
  23480. case sopstage.EdgeStageNodes:
  23481. return m.clearedstage_nodes
  23482. case sopstage.EdgeStageMessages:
  23483. return m.clearedstage_messages
  23484. }
  23485. return false
  23486. }
  23487. // ClearEdge clears the value of the edge with the given name. It returns an error
  23488. // if that edge is not defined in the schema.
  23489. func (m *SopStageMutation) ClearEdge(name string) error {
  23490. switch name {
  23491. case sopstage.EdgeSopTask:
  23492. m.ClearSopTask()
  23493. return nil
  23494. }
  23495. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23496. }
  23497. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23498. // It returns an error if the edge is not defined in the schema.
  23499. func (m *SopStageMutation) ResetEdge(name string) error {
  23500. switch name {
  23501. case sopstage.EdgeSopTask:
  23502. m.ResetSopTask()
  23503. return nil
  23504. case sopstage.EdgeStageNodes:
  23505. m.ResetStageNodes()
  23506. return nil
  23507. case sopstage.EdgeStageMessages:
  23508. m.ResetStageMessages()
  23509. return nil
  23510. }
  23511. return fmt.Errorf("unknown SopStage edge %s", name)
  23512. }
  23513. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23514. type SopTaskMutation struct {
  23515. config
  23516. op Op
  23517. typ string
  23518. id *uint64
  23519. created_at *time.Time
  23520. updated_at *time.Time
  23521. status *uint8
  23522. addstatus *int8
  23523. deleted_at *time.Time
  23524. name *string
  23525. bot_wxid_list *[]string
  23526. appendbot_wxid_list []string
  23527. _type *int
  23528. add_type *int
  23529. plan_start_time *time.Time
  23530. plan_end_time *time.Time
  23531. creator_id *string
  23532. organization_id *uint64
  23533. addorganization_id *int64
  23534. token *[]string
  23535. appendtoken []string
  23536. clearedFields map[string]struct{}
  23537. task_stages map[uint64]struct{}
  23538. removedtask_stages map[uint64]struct{}
  23539. clearedtask_stages bool
  23540. done bool
  23541. oldValue func(context.Context) (*SopTask, error)
  23542. predicates []predicate.SopTask
  23543. }
  23544. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23545. // soptaskOption allows management of the mutation configuration using functional options.
  23546. type soptaskOption func(*SopTaskMutation)
  23547. // newSopTaskMutation creates new mutation for the SopTask entity.
  23548. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23549. m := &SopTaskMutation{
  23550. config: c,
  23551. op: op,
  23552. typ: TypeSopTask,
  23553. clearedFields: make(map[string]struct{}),
  23554. }
  23555. for _, opt := range opts {
  23556. opt(m)
  23557. }
  23558. return m
  23559. }
  23560. // withSopTaskID sets the ID field of the mutation.
  23561. func withSopTaskID(id uint64) soptaskOption {
  23562. return func(m *SopTaskMutation) {
  23563. var (
  23564. err error
  23565. once sync.Once
  23566. value *SopTask
  23567. )
  23568. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23569. once.Do(func() {
  23570. if m.done {
  23571. err = errors.New("querying old values post mutation is not allowed")
  23572. } else {
  23573. value, err = m.Client().SopTask.Get(ctx, id)
  23574. }
  23575. })
  23576. return value, err
  23577. }
  23578. m.id = &id
  23579. }
  23580. }
  23581. // withSopTask sets the old SopTask of the mutation.
  23582. func withSopTask(node *SopTask) soptaskOption {
  23583. return func(m *SopTaskMutation) {
  23584. m.oldValue = func(context.Context) (*SopTask, error) {
  23585. return node, nil
  23586. }
  23587. m.id = &node.ID
  23588. }
  23589. }
  23590. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23591. // executed in a transaction (ent.Tx), a transactional client is returned.
  23592. func (m SopTaskMutation) Client() *Client {
  23593. client := &Client{config: m.config}
  23594. client.init()
  23595. return client
  23596. }
  23597. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23598. // it returns an error otherwise.
  23599. func (m SopTaskMutation) Tx() (*Tx, error) {
  23600. if _, ok := m.driver.(*txDriver); !ok {
  23601. return nil, errors.New("ent: mutation is not running in a transaction")
  23602. }
  23603. tx := &Tx{config: m.config}
  23604. tx.init()
  23605. return tx, nil
  23606. }
  23607. // SetID sets the value of the id field. Note that this
  23608. // operation is only accepted on creation of SopTask entities.
  23609. func (m *SopTaskMutation) SetID(id uint64) {
  23610. m.id = &id
  23611. }
  23612. // ID returns the ID value in the mutation. Note that the ID is only available
  23613. // if it was provided to the builder or after it was returned from the database.
  23614. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23615. if m.id == nil {
  23616. return
  23617. }
  23618. return *m.id, true
  23619. }
  23620. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23621. // That means, if the mutation is applied within a transaction with an isolation level such
  23622. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23623. // or updated by the mutation.
  23624. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23625. switch {
  23626. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23627. id, exists := m.ID()
  23628. if exists {
  23629. return []uint64{id}, nil
  23630. }
  23631. fallthrough
  23632. case m.op.Is(OpUpdate | OpDelete):
  23633. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23634. default:
  23635. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23636. }
  23637. }
  23638. // SetCreatedAt sets the "created_at" field.
  23639. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23640. m.created_at = &t
  23641. }
  23642. // CreatedAt returns the value of the "created_at" field in the mutation.
  23643. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23644. v := m.created_at
  23645. if v == nil {
  23646. return
  23647. }
  23648. return *v, true
  23649. }
  23650. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23651. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23653. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23654. if !m.op.Is(OpUpdateOne) {
  23655. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23656. }
  23657. if m.id == nil || m.oldValue == nil {
  23658. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23659. }
  23660. oldValue, err := m.oldValue(ctx)
  23661. if err != nil {
  23662. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23663. }
  23664. return oldValue.CreatedAt, nil
  23665. }
  23666. // ResetCreatedAt resets all changes to the "created_at" field.
  23667. func (m *SopTaskMutation) ResetCreatedAt() {
  23668. m.created_at = nil
  23669. }
  23670. // SetUpdatedAt sets the "updated_at" field.
  23671. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23672. m.updated_at = &t
  23673. }
  23674. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23675. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23676. v := m.updated_at
  23677. if v == nil {
  23678. return
  23679. }
  23680. return *v, true
  23681. }
  23682. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23683. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23685. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23686. if !m.op.Is(OpUpdateOne) {
  23687. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23688. }
  23689. if m.id == nil || m.oldValue == nil {
  23690. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23691. }
  23692. oldValue, err := m.oldValue(ctx)
  23693. if err != nil {
  23694. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23695. }
  23696. return oldValue.UpdatedAt, nil
  23697. }
  23698. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23699. func (m *SopTaskMutation) ResetUpdatedAt() {
  23700. m.updated_at = nil
  23701. }
  23702. // SetStatus sets the "status" field.
  23703. func (m *SopTaskMutation) SetStatus(u uint8) {
  23704. m.status = &u
  23705. m.addstatus = nil
  23706. }
  23707. // Status returns the value of the "status" field in the mutation.
  23708. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23709. v := m.status
  23710. if v == nil {
  23711. return
  23712. }
  23713. return *v, true
  23714. }
  23715. // OldStatus returns the old "status" field's value of the SopTask entity.
  23716. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23717. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23718. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23719. if !m.op.Is(OpUpdateOne) {
  23720. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23721. }
  23722. if m.id == nil || m.oldValue == nil {
  23723. return v, errors.New("OldStatus requires an ID field in the mutation")
  23724. }
  23725. oldValue, err := m.oldValue(ctx)
  23726. if err != nil {
  23727. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23728. }
  23729. return oldValue.Status, nil
  23730. }
  23731. // AddStatus adds u to the "status" field.
  23732. func (m *SopTaskMutation) AddStatus(u int8) {
  23733. if m.addstatus != nil {
  23734. *m.addstatus += u
  23735. } else {
  23736. m.addstatus = &u
  23737. }
  23738. }
  23739. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23740. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23741. v := m.addstatus
  23742. if v == nil {
  23743. return
  23744. }
  23745. return *v, true
  23746. }
  23747. // ClearStatus clears the value of the "status" field.
  23748. func (m *SopTaskMutation) ClearStatus() {
  23749. m.status = nil
  23750. m.addstatus = nil
  23751. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23752. }
  23753. // StatusCleared returns if the "status" field was cleared in this mutation.
  23754. func (m *SopTaskMutation) StatusCleared() bool {
  23755. _, ok := m.clearedFields[soptask.FieldStatus]
  23756. return ok
  23757. }
  23758. // ResetStatus resets all changes to the "status" field.
  23759. func (m *SopTaskMutation) ResetStatus() {
  23760. m.status = nil
  23761. m.addstatus = nil
  23762. delete(m.clearedFields, soptask.FieldStatus)
  23763. }
  23764. // SetDeletedAt sets the "deleted_at" field.
  23765. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23766. m.deleted_at = &t
  23767. }
  23768. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23769. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23770. v := m.deleted_at
  23771. if v == nil {
  23772. return
  23773. }
  23774. return *v, true
  23775. }
  23776. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23777. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23779. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23780. if !m.op.Is(OpUpdateOne) {
  23781. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23782. }
  23783. if m.id == nil || m.oldValue == nil {
  23784. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23785. }
  23786. oldValue, err := m.oldValue(ctx)
  23787. if err != nil {
  23788. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23789. }
  23790. return oldValue.DeletedAt, nil
  23791. }
  23792. // ClearDeletedAt clears the value of the "deleted_at" field.
  23793. func (m *SopTaskMutation) ClearDeletedAt() {
  23794. m.deleted_at = nil
  23795. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23796. }
  23797. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23798. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23799. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23800. return ok
  23801. }
  23802. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23803. func (m *SopTaskMutation) ResetDeletedAt() {
  23804. m.deleted_at = nil
  23805. delete(m.clearedFields, soptask.FieldDeletedAt)
  23806. }
  23807. // SetName sets the "name" field.
  23808. func (m *SopTaskMutation) SetName(s string) {
  23809. m.name = &s
  23810. }
  23811. // Name returns the value of the "name" field in the mutation.
  23812. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23813. v := m.name
  23814. if v == nil {
  23815. return
  23816. }
  23817. return *v, true
  23818. }
  23819. // OldName returns the old "name" field's value of the SopTask entity.
  23820. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23821. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23822. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23823. if !m.op.Is(OpUpdateOne) {
  23824. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23825. }
  23826. if m.id == nil || m.oldValue == nil {
  23827. return v, errors.New("OldName requires an ID field in the mutation")
  23828. }
  23829. oldValue, err := m.oldValue(ctx)
  23830. if err != nil {
  23831. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23832. }
  23833. return oldValue.Name, nil
  23834. }
  23835. // ResetName resets all changes to the "name" field.
  23836. func (m *SopTaskMutation) ResetName() {
  23837. m.name = nil
  23838. }
  23839. // SetBotWxidList sets the "bot_wxid_list" field.
  23840. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23841. m.bot_wxid_list = &s
  23842. m.appendbot_wxid_list = nil
  23843. }
  23844. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23845. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23846. v := m.bot_wxid_list
  23847. if v == nil {
  23848. return
  23849. }
  23850. return *v, true
  23851. }
  23852. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23853. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23855. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23856. if !m.op.Is(OpUpdateOne) {
  23857. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23858. }
  23859. if m.id == nil || m.oldValue == nil {
  23860. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23861. }
  23862. oldValue, err := m.oldValue(ctx)
  23863. if err != nil {
  23864. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23865. }
  23866. return oldValue.BotWxidList, nil
  23867. }
  23868. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23869. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23870. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23871. }
  23872. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23873. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23874. if len(m.appendbot_wxid_list) == 0 {
  23875. return nil, false
  23876. }
  23877. return m.appendbot_wxid_list, true
  23878. }
  23879. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23880. func (m *SopTaskMutation) ClearBotWxidList() {
  23881. m.bot_wxid_list = nil
  23882. m.appendbot_wxid_list = nil
  23883. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23884. }
  23885. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23886. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23887. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  23888. return ok
  23889. }
  23890. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  23891. func (m *SopTaskMutation) ResetBotWxidList() {
  23892. m.bot_wxid_list = nil
  23893. m.appendbot_wxid_list = nil
  23894. delete(m.clearedFields, soptask.FieldBotWxidList)
  23895. }
  23896. // SetType sets the "type" field.
  23897. func (m *SopTaskMutation) SetType(i int) {
  23898. m._type = &i
  23899. m.add_type = nil
  23900. }
  23901. // GetType returns the value of the "type" field in the mutation.
  23902. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  23903. v := m._type
  23904. if v == nil {
  23905. return
  23906. }
  23907. return *v, true
  23908. }
  23909. // OldType returns the old "type" field's value of the SopTask entity.
  23910. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23912. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  23913. if !m.op.Is(OpUpdateOne) {
  23914. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23915. }
  23916. if m.id == nil || m.oldValue == nil {
  23917. return v, errors.New("OldType requires an ID field in the mutation")
  23918. }
  23919. oldValue, err := m.oldValue(ctx)
  23920. if err != nil {
  23921. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23922. }
  23923. return oldValue.Type, nil
  23924. }
  23925. // AddType adds i to the "type" field.
  23926. func (m *SopTaskMutation) AddType(i int) {
  23927. if m.add_type != nil {
  23928. *m.add_type += i
  23929. } else {
  23930. m.add_type = &i
  23931. }
  23932. }
  23933. // AddedType returns the value that was added to the "type" field in this mutation.
  23934. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  23935. v := m.add_type
  23936. if v == nil {
  23937. return
  23938. }
  23939. return *v, true
  23940. }
  23941. // ResetType resets all changes to the "type" field.
  23942. func (m *SopTaskMutation) ResetType() {
  23943. m._type = nil
  23944. m.add_type = nil
  23945. }
  23946. // SetPlanStartTime sets the "plan_start_time" field.
  23947. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  23948. m.plan_start_time = &t
  23949. }
  23950. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  23951. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  23952. v := m.plan_start_time
  23953. if v == nil {
  23954. return
  23955. }
  23956. return *v, true
  23957. }
  23958. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  23959. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23960. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23961. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  23962. if !m.op.Is(OpUpdateOne) {
  23963. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  23964. }
  23965. if m.id == nil || m.oldValue == nil {
  23966. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  23967. }
  23968. oldValue, err := m.oldValue(ctx)
  23969. if err != nil {
  23970. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  23971. }
  23972. return oldValue.PlanStartTime, nil
  23973. }
  23974. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  23975. func (m *SopTaskMutation) ClearPlanStartTime() {
  23976. m.plan_start_time = nil
  23977. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  23978. }
  23979. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  23980. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  23981. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  23982. return ok
  23983. }
  23984. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  23985. func (m *SopTaskMutation) ResetPlanStartTime() {
  23986. m.plan_start_time = nil
  23987. delete(m.clearedFields, soptask.FieldPlanStartTime)
  23988. }
  23989. // SetPlanEndTime sets the "plan_end_time" field.
  23990. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  23991. m.plan_end_time = &t
  23992. }
  23993. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  23994. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  23995. v := m.plan_end_time
  23996. if v == nil {
  23997. return
  23998. }
  23999. return *v, true
  24000. }
  24001. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24002. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24004. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24005. if !m.op.Is(OpUpdateOne) {
  24006. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24007. }
  24008. if m.id == nil || m.oldValue == nil {
  24009. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24010. }
  24011. oldValue, err := m.oldValue(ctx)
  24012. if err != nil {
  24013. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24014. }
  24015. return oldValue.PlanEndTime, nil
  24016. }
  24017. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24018. func (m *SopTaskMutation) ClearPlanEndTime() {
  24019. m.plan_end_time = nil
  24020. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24021. }
  24022. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24023. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24024. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24025. return ok
  24026. }
  24027. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24028. func (m *SopTaskMutation) ResetPlanEndTime() {
  24029. m.plan_end_time = nil
  24030. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24031. }
  24032. // SetCreatorID sets the "creator_id" field.
  24033. func (m *SopTaskMutation) SetCreatorID(s string) {
  24034. m.creator_id = &s
  24035. }
  24036. // CreatorID returns the value of the "creator_id" field in the mutation.
  24037. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24038. v := m.creator_id
  24039. if v == nil {
  24040. return
  24041. }
  24042. return *v, true
  24043. }
  24044. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24045. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24047. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24048. if !m.op.Is(OpUpdateOne) {
  24049. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24050. }
  24051. if m.id == nil || m.oldValue == nil {
  24052. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24053. }
  24054. oldValue, err := m.oldValue(ctx)
  24055. if err != nil {
  24056. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24057. }
  24058. return oldValue.CreatorID, nil
  24059. }
  24060. // ClearCreatorID clears the value of the "creator_id" field.
  24061. func (m *SopTaskMutation) ClearCreatorID() {
  24062. m.creator_id = nil
  24063. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24064. }
  24065. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24066. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24067. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24068. return ok
  24069. }
  24070. // ResetCreatorID resets all changes to the "creator_id" field.
  24071. func (m *SopTaskMutation) ResetCreatorID() {
  24072. m.creator_id = nil
  24073. delete(m.clearedFields, soptask.FieldCreatorID)
  24074. }
  24075. // SetOrganizationID sets the "organization_id" field.
  24076. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24077. m.organization_id = &u
  24078. m.addorganization_id = nil
  24079. }
  24080. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24081. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24082. v := m.organization_id
  24083. if v == nil {
  24084. return
  24085. }
  24086. return *v, true
  24087. }
  24088. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24089. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24091. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24092. if !m.op.Is(OpUpdateOne) {
  24093. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24094. }
  24095. if m.id == nil || m.oldValue == nil {
  24096. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24097. }
  24098. oldValue, err := m.oldValue(ctx)
  24099. if err != nil {
  24100. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24101. }
  24102. return oldValue.OrganizationID, nil
  24103. }
  24104. // AddOrganizationID adds u to the "organization_id" field.
  24105. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24106. if m.addorganization_id != nil {
  24107. *m.addorganization_id += u
  24108. } else {
  24109. m.addorganization_id = &u
  24110. }
  24111. }
  24112. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24113. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24114. v := m.addorganization_id
  24115. if v == nil {
  24116. return
  24117. }
  24118. return *v, true
  24119. }
  24120. // ClearOrganizationID clears the value of the "organization_id" field.
  24121. func (m *SopTaskMutation) ClearOrganizationID() {
  24122. m.organization_id = nil
  24123. m.addorganization_id = nil
  24124. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24125. }
  24126. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24127. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24128. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24129. return ok
  24130. }
  24131. // ResetOrganizationID resets all changes to the "organization_id" field.
  24132. func (m *SopTaskMutation) ResetOrganizationID() {
  24133. m.organization_id = nil
  24134. m.addorganization_id = nil
  24135. delete(m.clearedFields, soptask.FieldOrganizationID)
  24136. }
  24137. // SetToken sets the "token" field.
  24138. func (m *SopTaskMutation) SetToken(s []string) {
  24139. m.token = &s
  24140. m.appendtoken = nil
  24141. }
  24142. // Token returns the value of the "token" field in the mutation.
  24143. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24144. v := m.token
  24145. if v == nil {
  24146. return
  24147. }
  24148. return *v, true
  24149. }
  24150. // OldToken returns the old "token" field's value of the SopTask entity.
  24151. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24152. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24153. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24154. if !m.op.Is(OpUpdateOne) {
  24155. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24156. }
  24157. if m.id == nil || m.oldValue == nil {
  24158. return v, errors.New("OldToken requires an ID field in the mutation")
  24159. }
  24160. oldValue, err := m.oldValue(ctx)
  24161. if err != nil {
  24162. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24163. }
  24164. return oldValue.Token, nil
  24165. }
  24166. // AppendToken adds s to the "token" field.
  24167. func (m *SopTaskMutation) AppendToken(s []string) {
  24168. m.appendtoken = append(m.appendtoken, s...)
  24169. }
  24170. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24171. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24172. if len(m.appendtoken) == 0 {
  24173. return nil, false
  24174. }
  24175. return m.appendtoken, true
  24176. }
  24177. // ClearToken clears the value of the "token" field.
  24178. func (m *SopTaskMutation) ClearToken() {
  24179. m.token = nil
  24180. m.appendtoken = nil
  24181. m.clearedFields[soptask.FieldToken] = struct{}{}
  24182. }
  24183. // TokenCleared returns if the "token" field was cleared in this mutation.
  24184. func (m *SopTaskMutation) TokenCleared() bool {
  24185. _, ok := m.clearedFields[soptask.FieldToken]
  24186. return ok
  24187. }
  24188. // ResetToken resets all changes to the "token" field.
  24189. func (m *SopTaskMutation) ResetToken() {
  24190. m.token = nil
  24191. m.appendtoken = nil
  24192. delete(m.clearedFields, soptask.FieldToken)
  24193. }
  24194. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24195. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24196. if m.task_stages == nil {
  24197. m.task_stages = make(map[uint64]struct{})
  24198. }
  24199. for i := range ids {
  24200. m.task_stages[ids[i]] = struct{}{}
  24201. }
  24202. }
  24203. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24204. func (m *SopTaskMutation) ClearTaskStages() {
  24205. m.clearedtask_stages = true
  24206. }
  24207. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24208. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24209. return m.clearedtask_stages
  24210. }
  24211. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24212. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24213. if m.removedtask_stages == nil {
  24214. m.removedtask_stages = make(map[uint64]struct{})
  24215. }
  24216. for i := range ids {
  24217. delete(m.task_stages, ids[i])
  24218. m.removedtask_stages[ids[i]] = struct{}{}
  24219. }
  24220. }
  24221. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24222. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24223. for id := range m.removedtask_stages {
  24224. ids = append(ids, id)
  24225. }
  24226. return
  24227. }
  24228. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24229. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24230. for id := range m.task_stages {
  24231. ids = append(ids, id)
  24232. }
  24233. return
  24234. }
  24235. // ResetTaskStages resets all changes to the "task_stages" edge.
  24236. func (m *SopTaskMutation) ResetTaskStages() {
  24237. m.task_stages = nil
  24238. m.clearedtask_stages = false
  24239. m.removedtask_stages = nil
  24240. }
  24241. // Where appends a list predicates to the SopTaskMutation builder.
  24242. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24243. m.predicates = append(m.predicates, ps...)
  24244. }
  24245. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24246. // users can use type-assertion to append predicates that do not depend on any generated package.
  24247. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24248. p := make([]predicate.SopTask, len(ps))
  24249. for i := range ps {
  24250. p[i] = ps[i]
  24251. }
  24252. m.Where(p...)
  24253. }
  24254. // Op returns the operation name.
  24255. func (m *SopTaskMutation) Op() Op {
  24256. return m.op
  24257. }
  24258. // SetOp allows setting the mutation operation.
  24259. func (m *SopTaskMutation) SetOp(op Op) {
  24260. m.op = op
  24261. }
  24262. // Type returns the node type of this mutation (SopTask).
  24263. func (m *SopTaskMutation) Type() string {
  24264. return m.typ
  24265. }
  24266. // Fields returns all fields that were changed during this mutation. Note that in
  24267. // order to get all numeric fields that were incremented/decremented, call
  24268. // AddedFields().
  24269. func (m *SopTaskMutation) Fields() []string {
  24270. fields := make([]string, 0, 12)
  24271. if m.created_at != nil {
  24272. fields = append(fields, soptask.FieldCreatedAt)
  24273. }
  24274. if m.updated_at != nil {
  24275. fields = append(fields, soptask.FieldUpdatedAt)
  24276. }
  24277. if m.status != nil {
  24278. fields = append(fields, soptask.FieldStatus)
  24279. }
  24280. if m.deleted_at != nil {
  24281. fields = append(fields, soptask.FieldDeletedAt)
  24282. }
  24283. if m.name != nil {
  24284. fields = append(fields, soptask.FieldName)
  24285. }
  24286. if m.bot_wxid_list != nil {
  24287. fields = append(fields, soptask.FieldBotWxidList)
  24288. }
  24289. if m._type != nil {
  24290. fields = append(fields, soptask.FieldType)
  24291. }
  24292. if m.plan_start_time != nil {
  24293. fields = append(fields, soptask.FieldPlanStartTime)
  24294. }
  24295. if m.plan_end_time != nil {
  24296. fields = append(fields, soptask.FieldPlanEndTime)
  24297. }
  24298. if m.creator_id != nil {
  24299. fields = append(fields, soptask.FieldCreatorID)
  24300. }
  24301. if m.organization_id != nil {
  24302. fields = append(fields, soptask.FieldOrganizationID)
  24303. }
  24304. if m.token != nil {
  24305. fields = append(fields, soptask.FieldToken)
  24306. }
  24307. return fields
  24308. }
  24309. // Field returns the value of a field with the given name. The second boolean
  24310. // return value indicates that this field was not set, or was not defined in the
  24311. // schema.
  24312. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24313. switch name {
  24314. case soptask.FieldCreatedAt:
  24315. return m.CreatedAt()
  24316. case soptask.FieldUpdatedAt:
  24317. return m.UpdatedAt()
  24318. case soptask.FieldStatus:
  24319. return m.Status()
  24320. case soptask.FieldDeletedAt:
  24321. return m.DeletedAt()
  24322. case soptask.FieldName:
  24323. return m.Name()
  24324. case soptask.FieldBotWxidList:
  24325. return m.BotWxidList()
  24326. case soptask.FieldType:
  24327. return m.GetType()
  24328. case soptask.FieldPlanStartTime:
  24329. return m.PlanStartTime()
  24330. case soptask.FieldPlanEndTime:
  24331. return m.PlanEndTime()
  24332. case soptask.FieldCreatorID:
  24333. return m.CreatorID()
  24334. case soptask.FieldOrganizationID:
  24335. return m.OrganizationID()
  24336. case soptask.FieldToken:
  24337. return m.Token()
  24338. }
  24339. return nil, false
  24340. }
  24341. // OldField returns the old value of the field from the database. An error is
  24342. // returned if the mutation operation is not UpdateOne, or the query to the
  24343. // database failed.
  24344. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24345. switch name {
  24346. case soptask.FieldCreatedAt:
  24347. return m.OldCreatedAt(ctx)
  24348. case soptask.FieldUpdatedAt:
  24349. return m.OldUpdatedAt(ctx)
  24350. case soptask.FieldStatus:
  24351. return m.OldStatus(ctx)
  24352. case soptask.FieldDeletedAt:
  24353. return m.OldDeletedAt(ctx)
  24354. case soptask.FieldName:
  24355. return m.OldName(ctx)
  24356. case soptask.FieldBotWxidList:
  24357. return m.OldBotWxidList(ctx)
  24358. case soptask.FieldType:
  24359. return m.OldType(ctx)
  24360. case soptask.FieldPlanStartTime:
  24361. return m.OldPlanStartTime(ctx)
  24362. case soptask.FieldPlanEndTime:
  24363. return m.OldPlanEndTime(ctx)
  24364. case soptask.FieldCreatorID:
  24365. return m.OldCreatorID(ctx)
  24366. case soptask.FieldOrganizationID:
  24367. return m.OldOrganizationID(ctx)
  24368. case soptask.FieldToken:
  24369. return m.OldToken(ctx)
  24370. }
  24371. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24372. }
  24373. // SetField sets the value of a field with the given name. It returns an error if
  24374. // the field is not defined in the schema, or if the type mismatched the field
  24375. // type.
  24376. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24377. switch name {
  24378. case soptask.FieldCreatedAt:
  24379. v, ok := value.(time.Time)
  24380. if !ok {
  24381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24382. }
  24383. m.SetCreatedAt(v)
  24384. return nil
  24385. case soptask.FieldUpdatedAt:
  24386. v, ok := value.(time.Time)
  24387. if !ok {
  24388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24389. }
  24390. m.SetUpdatedAt(v)
  24391. return nil
  24392. case soptask.FieldStatus:
  24393. v, ok := value.(uint8)
  24394. if !ok {
  24395. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24396. }
  24397. m.SetStatus(v)
  24398. return nil
  24399. case soptask.FieldDeletedAt:
  24400. v, ok := value.(time.Time)
  24401. if !ok {
  24402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24403. }
  24404. m.SetDeletedAt(v)
  24405. return nil
  24406. case soptask.FieldName:
  24407. v, ok := value.(string)
  24408. if !ok {
  24409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24410. }
  24411. m.SetName(v)
  24412. return nil
  24413. case soptask.FieldBotWxidList:
  24414. v, ok := value.([]string)
  24415. if !ok {
  24416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24417. }
  24418. m.SetBotWxidList(v)
  24419. return nil
  24420. case soptask.FieldType:
  24421. v, ok := value.(int)
  24422. if !ok {
  24423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24424. }
  24425. m.SetType(v)
  24426. return nil
  24427. case soptask.FieldPlanStartTime:
  24428. v, ok := value.(time.Time)
  24429. if !ok {
  24430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24431. }
  24432. m.SetPlanStartTime(v)
  24433. return nil
  24434. case soptask.FieldPlanEndTime:
  24435. v, ok := value.(time.Time)
  24436. if !ok {
  24437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24438. }
  24439. m.SetPlanEndTime(v)
  24440. return nil
  24441. case soptask.FieldCreatorID:
  24442. v, ok := value.(string)
  24443. if !ok {
  24444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24445. }
  24446. m.SetCreatorID(v)
  24447. return nil
  24448. case soptask.FieldOrganizationID:
  24449. v, ok := value.(uint64)
  24450. if !ok {
  24451. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24452. }
  24453. m.SetOrganizationID(v)
  24454. return nil
  24455. case soptask.FieldToken:
  24456. v, ok := value.([]string)
  24457. if !ok {
  24458. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24459. }
  24460. m.SetToken(v)
  24461. return nil
  24462. }
  24463. return fmt.Errorf("unknown SopTask field %s", name)
  24464. }
  24465. // AddedFields returns all numeric fields that were incremented/decremented during
  24466. // this mutation.
  24467. func (m *SopTaskMutation) AddedFields() []string {
  24468. var fields []string
  24469. if m.addstatus != nil {
  24470. fields = append(fields, soptask.FieldStatus)
  24471. }
  24472. if m.add_type != nil {
  24473. fields = append(fields, soptask.FieldType)
  24474. }
  24475. if m.addorganization_id != nil {
  24476. fields = append(fields, soptask.FieldOrganizationID)
  24477. }
  24478. return fields
  24479. }
  24480. // AddedField returns the numeric value that was incremented/decremented on a field
  24481. // with the given name. The second boolean return value indicates that this field
  24482. // was not set, or was not defined in the schema.
  24483. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24484. switch name {
  24485. case soptask.FieldStatus:
  24486. return m.AddedStatus()
  24487. case soptask.FieldType:
  24488. return m.AddedType()
  24489. case soptask.FieldOrganizationID:
  24490. return m.AddedOrganizationID()
  24491. }
  24492. return nil, false
  24493. }
  24494. // AddField adds the value to the field with the given name. It returns an error if
  24495. // the field is not defined in the schema, or if the type mismatched the field
  24496. // type.
  24497. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24498. switch name {
  24499. case soptask.FieldStatus:
  24500. v, ok := value.(int8)
  24501. if !ok {
  24502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24503. }
  24504. m.AddStatus(v)
  24505. return nil
  24506. case soptask.FieldType:
  24507. v, ok := value.(int)
  24508. if !ok {
  24509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24510. }
  24511. m.AddType(v)
  24512. return nil
  24513. case soptask.FieldOrganizationID:
  24514. v, ok := value.(int64)
  24515. if !ok {
  24516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24517. }
  24518. m.AddOrganizationID(v)
  24519. return nil
  24520. }
  24521. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24522. }
  24523. // ClearedFields returns all nullable fields that were cleared during this
  24524. // mutation.
  24525. func (m *SopTaskMutation) ClearedFields() []string {
  24526. var fields []string
  24527. if m.FieldCleared(soptask.FieldStatus) {
  24528. fields = append(fields, soptask.FieldStatus)
  24529. }
  24530. if m.FieldCleared(soptask.FieldDeletedAt) {
  24531. fields = append(fields, soptask.FieldDeletedAt)
  24532. }
  24533. if m.FieldCleared(soptask.FieldBotWxidList) {
  24534. fields = append(fields, soptask.FieldBotWxidList)
  24535. }
  24536. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24537. fields = append(fields, soptask.FieldPlanStartTime)
  24538. }
  24539. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24540. fields = append(fields, soptask.FieldPlanEndTime)
  24541. }
  24542. if m.FieldCleared(soptask.FieldCreatorID) {
  24543. fields = append(fields, soptask.FieldCreatorID)
  24544. }
  24545. if m.FieldCleared(soptask.FieldOrganizationID) {
  24546. fields = append(fields, soptask.FieldOrganizationID)
  24547. }
  24548. if m.FieldCleared(soptask.FieldToken) {
  24549. fields = append(fields, soptask.FieldToken)
  24550. }
  24551. return fields
  24552. }
  24553. // FieldCleared returns a boolean indicating if a field with the given name was
  24554. // cleared in this mutation.
  24555. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24556. _, ok := m.clearedFields[name]
  24557. return ok
  24558. }
  24559. // ClearField clears the value of the field with the given name. It returns an
  24560. // error if the field is not defined in the schema.
  24561. func (m *SopTaskMutation) ClearField(name string) error {
  24562. switch name {
  24563. case soptask.FieldStatus:
  24564. m.ClearStatus()
  24565. return nil
  24566. case soptask.FieldDeletedAt:
  24567. m.ClearDeletedAt()
  24568. return nil
  24569. case soptask.FieldBotWxidList:
  24570. m.ClearBotWxidList()
  24571. return nil
  24572. case soptask.FieldPlanStartTime:
  24573. m.ClearPlanStartTime()
  24574. return nil
  24575. case soptask.FieldPlanEndTime:
  24576. m.ClearPlanEndTime()
  24577. return nil
  24578. case soptask.FieldCreatorID:
  24579. m.ClearCreatorID()
  24580. return nil
  24581. case soptask.FieldOrganizationID:
  24582. m.ClearOrganizationID()
  24583. return nil
  24584. case soptask.FieldToken:
  24585. m.ClearToken()
  24586. return nil
  24587. }
  24588. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24589. }
  24590. // ResetField resets all changes in the mutation for the field with the given name.
  24591. // It returns an error if the field is not defined in the schema.
  24592. func (m *SopTaskMutation) ResetField(name string) error {
  24593. switch name {
  24594. case soptask.FieldCreatedAt:
  24595. m.ResetCreatedAt()
  24596. return nil
  24597. case soptask.FieldUpdatedAt:
  24598. m.ResetUpdatedAt()
  24599. return nil
  24600. case soptask.FieldStatus:
  24601. m.ResetStatus()
  24602. return nil
  24603. case soptask.FieldDeletedAt:
  24604. m.ResetDeletedAt()
  24605. return nil
  24606. case soptask.FieldName:
  24607. m.ResetName()
  24608. return nil
  24609. case soptask.FieldBotWxidList:
  24610. m.ResetBotWxidList()
  24611. return nil
  24612. case soptask.FieldType:
  24613. m.ResetType()
  24614. return nil
  24615. case soptask.FieldPlanStartTime:
  24616. m.ResetPlanStartTime()
  24617. return nil
  24618. case soptask.FieldPlanEndTime:
  24619. m.ResetPlanEndTime()
  24620. return nil
  24621. case soptask.FieldCreatorID:
  24622. m.ResetCreatorID()
  24623. return nil
  24624. case soptask.FieldOrganizationID:
  24625. m.ResetOrganizationID()
  24626. return nil
  24627. case soptask.FieldToken:
  24628. m.ResetToken()
  24629. return nil
  24630. }
  24631. return fmt.Errorf("unknown SopTask field %s", name)
  24632. }
  24633. // AddedEdges returns all edge names that were set/added in this mutation.
  24634. func (m *SopTaskMutation) AddedEdges() []string {
  24635. edges := make([]string, 0, 1)
  24636. if m.task_stages != nil {
  24637. edges = append(edges, soptask.EdgeTaskStages)
  24638. }
  24639. return edges
  24640. }
  24641. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24642. // name in this mutation.
  24643. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24644. switch name {
  24645. case soptask.EdgeTaskStages:
  24646. ids := make([]ent.Value, 0, len(m.task_stages))
  24647. for id := range m.task_stages {
  24648. ids = append(ids, id)
  24649. }
  24650. return ids
  24651. }
  24652. return nil
  24653. }
  24654. // RemovedEdges returns all edge names that were removed in this mutation.
  24655. func (m *SopTaskMutation) RemovedEdges() []string {
  24656. edges := make([]string, 0, 1)
  24657. if m.removedtask_stages != nil {
  24658. edges = append(edges, soptask.EdgeTaskStages)
  24659. }
  24660. return edges
  24661. }
  24662. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24663. // the given name in this mutation.
  24664. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24665. switch name {
  24666. case soptask.EdgeTaskStages:
  24667. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24668. for id := range m.removedtask_stages {
  24669. ids = append(ids, id)
  24670. }
  24671. return ids
  24672. }
  24673. return nil
  24674. }
  24675. // ClearedEdges returns all edge names that were cleared in this mutation.
  24676. func (m *SopTaskMutation) ClearedEdges() []string {
  24677. edges := make([]string, 0, 1)
  24678. if m.clearedtask_stages {
  24679. edges = append(edges, soptask.EdgeTaskStages)
  24680. }
  24681. return edges
  24682. }
  24683. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24684. // was cleared in this mutation.
  24685. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24686. switch name {
  24687. case soptask.EdgeTaskStages:
  24688. return m.clearedtask_stages
  24689. }
  24690. return false
  24691. }
  24692. // ClearEdge clears the value of the edge with the given name. It returns an error
  24693. // if that edge is not defined in the schema.
  24694. func (m *SopTaskMutation) ClearEdge(name string) error {
  24695. switch name {
  24696. }
  24697. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24698. }
  24699. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24700. // It returns an error if the edge is not defined in the schema.
  24701. func (m *SopTaskMutation) ResetEdge(name string) error {
  24702. switch name {
  24703. case soptask.EdgeTaskStages:
  24704. m.ResetTaskStages()
  24705. return nil
  24706. }
  24707. return fmt.Errorf("unknown SopTask edge %s", name)
  24708. }
  24709. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24710. type TokenMutation struct {
  24711. config
  24712. op Op
  24713. typ string
  24714. id *uint64
  24715. created_at *time.Time
  24716. updated_at *time.Time
  24717. deleted_at *time.Time
  24718. expire_at *time.Time
  24719. token *string
  24720. mac *string
  24721. organization_id *uint64
  24722. addorganization_id *int64
  24723. custom_agent_base *string
  24724. custom_agent_key *string
  24725. openai_base *string
  24726. openai_key *string
  24727. clearedFields map[string]struct{}
  24728. agent *uint64
  24729. clearedagent bool
  24730. done bool
  24731. oldValue func(context.Context) (*Token, error)
  24732. predicates []predicate.Token
  24733. }
  24734. var _ ent.Mutation = (*TokenMutation)(nil)
  24735. // tokenOption allows management of the mutation configuration using functional options.
  24736. type tokenOption func(*TokenMutation)
  24737. // newTokenMutation creates new mutation for the Token entity.
  24738. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24739. m := &TokenMutation{
  24740. config: c,
  24741. op: op,
  24742. typ: TypeToken,
  24743. clearedFields: make(map[string]struct{}),
  24744. }
  24745. for _, opt := range opts {
  24746. opt(m)
  24747. }
  24748. return m
  24749. }
  24750. // withTokenID sets the ID field of the mutation.
  24751. func withTokenID(id uint64) tokenOption {
  24752. return func(m *TokenMutation) {
  24753. var (
  24754. err error
  24755. once sync.Once
  24756. value *Token
  24757. )
  24758. m.oldValue = func(ctx context.Context) (*Token, error) {
  24759. once.Do(func() {
  24760. if m.done {
  24761. err = errors.New("querying old values post mutation is not allowed")
  24762. } else {
  24763. value, err = m.Client().Token.Get(ctx, id)
  24764. }
  24765. })
  24766. return value, err
  24767. }
  24768. m.id = &id
  24769. }
  24770. }
  24771. // withToken sets the old Token of the mutation.
  24772. func withToken(node *Token) tokenOption {
  24773. return func(m *TokenMutation) {
  24774. m.oldValue = func(context.Context) (*Token, error) {
  24775. return node, nil
  24776. }
  24777. m.id = &node.ID
  24778. }
  24779. }
  24780. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24781. // executed in a transaction (ent.Tx), a transactional client is returned.
  24782. func (m TokenMutation) Client() *Client {
  24783. client := &Client{config: m.config}
  24784. client.init()
  24785. return client
  24786. }
  24787. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24788. // it returns an error otherwise.
  24789. func (m TokenMutation) Tx() (*Tx, error) {
  24790. if _, ok := m.driver.(*txDriver); !ok {
  24791. return nil, errors.New("ent: mutation is not running in a transaction")
  24792. }
  24793. tx := &Tx{config: m.config}
  24794. tx.init()
  24795. return tx, nil
  24796. }
  24797. // SetID sets the value of the id field. Note that this
  24798. // operation is only accepted on creation of Token entities.
  24799. func (m *TokenMutation) SetID(id uint64) {
  24800. m.id = &id
  24801. }
  24802. // ID returns the ID value in the mutation. Note that the ID is only available
  24803. // if it was provided to the builder or after it was returned from the database.
  24804. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24805. if m.id == nil {
  24806. return
  24807. }
  24808. return *m.id, true
  24809. }
  24810. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24811. // That means, if the mutation is applied within a transaction with an isolation level such
  24812. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24813. // or updated by the mutation.
  24814. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24815. switch {
  24816. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24817. id, exists := m.ID()
  24818. if exists {
  24819. return []uint64{id}, nil
  24820. }
  24821. fallthrough
  24822. case m.op.Is(OpUpdate | OpDelete):
  24823. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24824. default:
  24825. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24826. }
  24827. }
  24828. // SetCreatedAt sets the "created_at" field.
  24829. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24830. m.created_at = &t
  24831. }
  24832. // CreatedAt returns the value of the "created_at" field in the mutation.
  24833. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24834. v := m.created_at
  24835. if v == nil {
  24836. return
  24837. }
  24838. return *v, true
  24839. }
  24840. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24841. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24843. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24844. if !m.op.Is(OpUpdateOne) {
  24845. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24846. }
  24847. if m.id == nil || m.oldValue == nil {
  24848. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24849. }
  24850. oldValue, err := m.oldValue(ctx)
  24851. if err != nil {
  24852. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24853. }
  24854. return oldValue.CreatedAt, nil
  24855. }
  24856. // ResetCreatedAt resets all changes to the "created_at" field.
  24857. func (m *TokenMutation) ResetCreatedAt() {
  24858. m.created_at = nil
  24859. }
  24860. // SetUpdatedAt sets the "updated_at" field.
  24861. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24862. m.updated_at = &t
  24863. }
  24864. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24865. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24866. v := m.updated_at
  24867. if v == nil {
  24868. return
  24869. }
  24870. return *v, true
  24871. }
  24872. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24873. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24875. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24876. if !m.op.Is(OpUpdateOne) {
  24877. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24878. }
  24879. if m.id == nil || m.oldValue == nil {
  24880. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24881. }
  24882. oldValue, err := m.oldValue(ctx)
  24883. if err != nil {
  24884. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24885. }
  24886. return oldValue.UpdatedAt, nil
  24887. }
  24888. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24889. func (m *TokenMutation) ResetUpdatedAt() {
  24890. m.updated_at = nil
  24891. }
  24892. // SetDeletedAt sets the "deleted_at" field.
  24893. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  24894. m.deleted_at = &t
  24895. }
  24896. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24897. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  24898. v := m.deleted_at
  24899. if v == nil {
  24900. return
  24901. }
  24902. return *v, true
  24903. }
  24904. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  24905. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24907. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24908. if !m.op.Is(OpUpdateOne) {
  24909. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24910. }
  24911. if m.id == nil || m.oldValue == nil {
  24912. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24913. }
  24914. oldValue, err := m.oldValue(ctx)
  24915. if err != nil {
  24916. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24917. }
  24918. return oldValue.DeletedAt, nil
  24919. }
  24920. // ClearDeletedAt clears the value of the "deleted_at" field.
  24921. func (m *TokenMutation) ClearDeletedAt() {
  24922. m.deleted_at = nil
  24923. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  24924. }
  24925. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24926. func (m *TokenMutation) DeletedAtCleared() bool {
  24927. _, ok := m.clearedFields[token.FieldDeletedAt]
  24928. return ok
  24929. }
  24930. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24931. func (m *TokenMutation) ResetDeletedAt() {
  24932. m.deleted_at = nil
  24933. delete(m.clearedFields, token.FieldDeletedAt)
  24934. }
  24935. // SetExpireAt sets the "expire_at" field.
  24936. func (m *TokenMutation) SetExpireAt(t time.Time) {
  24937. m.expire_at = &t
  24938. }
  24939. // ExpireAt returns the value of the "expire_at" field in the mutation.
  24940. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  24941. v := m.expire_at
  24942. if v == nil {
  24943. return
  24944. }
  24945. return *v, true
  24946. }
  24947. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  24948. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24949. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24950. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  24951. if !m.op.Is(OpUpdateOne) {
  24952. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  24953. }
  24954. if m.id == nil || m.oldValue == nil {
  24955. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  24956. }
  24957. oldValue, err := m.oldValue(ctx)
  24958. if err != nil {
  24959. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  24960. }
  24961. return oldValue.ExpireAt, nil
  24962. }
  24963. // ClearExpireAt clears the value of the "expire_at" field.
  24964. func (m *TokenMutation) ClearExpireAt() {
  24965. m.expire_at = nil
  24966. m.clearedFields[token.FieldExpireAt] = struct{}{}
  24967. }
  24968. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  24969. func (m *TokenMutation) ExpireAtCleared() bool {
  24970. _, ok := m.clearedFields[token.FieldExpireAt]
  24971. return ok
  24972. }
  24973. // ResetExpireAt resets all changes to the "expire_at" field.
  24974. func (m *TokenMutation) ResetExpireAt() {
  24975. m.expire_at = nil
  24976. delete(m.clearedFields, token.FieldExpireAt)
  24977. }
  24978. // SetToken sets the "token" field.
  24979. func (m *TokenMutation) SetToken(s string) {
  24980. m.token = &s
  24981. }
  24982. // Token returns the value of the "token" field in the mutation.
  24983. func (m *TokenMutation) Token() (r string, exists bool) {
  24984. v := m.token
  24985. if v == nil {
  24986. return
  24987. }
  24988. return *v, true
  24989. }
  24990. // OldToken returns the old "token" field's value of the Token entity.
  24991. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24993. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  24994. if !m.op.Is(OpUpdateOne) {
  24995. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24996. }
  24997. if m.id == nil || m.oldValue == nil {
  24998. return v, errors.New("OldToken requires an ID field in the mutation")
  24999. }
  25000. oldValue, err := m.oldValue(ctx)
  25001. if err != nil {
  25002. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25003. }
  25004. return oldValue.Token, nil
  25005. }
  25006. // ClearToken clears the value of the "token" field.
  25007. func (m *TokenMutation) ClearToken() {
  25008. m.token = nil
  25009. m.clearedFields[token.FieldToken] = struct{}{}
  25010. }
  25011. // TokenCleared returns if the "token" field was cleared in this mutation.
  25012. func (m *TokenMutation) TokenCleared() bool {
  25013. _, ok := m.clearedFields[token.FieldToken]
  25014. return ok
  25015. }
  25016. // ResetToken resets all changes to the "token" field.
  25017. func (m *TokenMutation) ResetToken() {
  25018. m.token = nil
  25019. delete(m.clearedFields, token.FieldToken)
  25020. }
  25021. // SetMAC sets the "mac" field.
  25022. func (m *TokenMutation) SetMAC(s string) {
  25023. m.mac = &s
  25024. }
  25025. // MAC returns the value of the "mac" field in the mutation.
  25026. func (m *TokenMutation) MAC() (r string, exists bool) {
  25027. v := m.mac
  25028. if v == nil {
  25029. return
  25030. }
  25031. return *v, true
  25032. }
  25033. // OldMAC returns the old "mac" field's value of the Token entity.
  25034. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25036. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25037. if !m.op.Is(OpUpdateOne) {
  25038. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25039. }
  25040. if m.id == nil || m.oldValue == nil {
  25041. return v, errors.New("OldMAC requires an ID field in the mutation")
  25042. }
  25043. oldValue, err := m.oldValue(ctx)
  25044. if err != nil {
  25045. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25046. }
  25047. return oldValue.MAC, nil
  25048. }
  25049. // ClearMAC clears the value of the "mac" field.
  25050. func (m *TokenMutation) ClearMAC() {
  25051. m.mac = nil
  25052. m.clearedFields[token.FieldMAC] = struct{}{}
  25053. }
  25054. // MACCleared returns if the "mac" field was cleared in this mutation.
  25055. func (m *TokenMutation) MACCleared() bool {
  25056. _, ok := m.clearedFields[token.FieldMAC]
  25057. return ok
  25058. }
  25059. // ResetMAC resets all changes to the "mac" field.
  25060. func (m *TokenMutation) ResetMAC() {
  25061. m.mac = nil
  25062. delete(m.clearedFields, token.FieldMAC)
  25063. }
  25064. // SetOrganizationID sets the "organization_id" field.
  25065. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25066. m.organization_id = &u
  25067. m.addorganization_id = nil
  25068. }
  25069. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25070. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25071. v := m.organization_id
  25072. if v == nil {
  25073. return
  25074. }
  25075. return *v, true
  25076. }
  25077. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25078. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25080. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25081. if !m.op.Is(OpUpdateOne) {
  25082. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25083. }
  25084. if m.id == nil || m.oldValue == nil {
  25085. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25086. }
  25087. oldValue, err := m.oldValue(ctx)
  25088. if err != nil {
  25089. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25090. }
  25091. return oldValue.OrganizationID, nil
  25092. }
  25093. // AddOrganizationID adds u to the "organization_id" field.
  25094. func (m *TokenMutation) AddOrganizationID(u int64) {
  25095. if m.addorganization_id != nil {
  25096. *m.addorganization_id += u
  25097. } else {
  25098. m.addorganization_id = &u
  25099. }
  25100. }
  25101. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25102. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25103. v := m.addorganization_id
  25104. if v == nil {
  25105. return
  25106. }
  25107. return *v, true
  25108. }
  25109. // ResetOrganizationID resets all changes to the "organization_id" field.
  25110. func (m *TokenMutation) ResetOrganizationID() {
  25111. m.organization_id = nil
  25112. m.addorganization_id = nil
  25113. }
  25114. // SetAgentID sets the "agent_id" field.
  25115. func (m *TokenMutation) SetAgentID(u uint64) {
  25116. m.agent = &u
  25117. }
  25118. // AgentID returns the value of the "agent_id" field in the mutation.
  25119. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25120. v := m.agent
  25121. if v == nil {
  25122. return
  25123. }
  25124. return *v, true
  25125. }
  25126. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25127. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25128. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25129. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25130. if !m.op.Is(OpUpdateOne) {
  25131. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25132. }
  25133. if m.id == nil || m.oldValue == nil {
  25134. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25135. }
  25136. oldValue, err := m.oldValue(ctx)
  25137. if err != nil {
  25138. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25139. }
  25140. return oldValue.AgentID, nil
  25141. }
  25142. // ResetAgentID resets all changes to the "agent_id" field.
  25143. func (m *TokenMutation) ResetAgentID() {
  25144. m.agent = nil
  25145. }
  25146. // SetCustomAgentBase sets the "custom_agent_base" field.
  25147. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25148. m.custom_agent_base = &s
  25149. }
  25150. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25151. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25152. v := m.custom_agent_base
  25153. if v == nil {
  25154. return
  25155. }
  25156. return *v, true
  25157. }
  25158. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25159. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25160. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25161. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25162. if !m.op.Is(OpUpdateOne) {
  25163. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25164. }
  25165. if m.id == nil || m.oldValue == nil {
  25166. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25167. }
  25168. oldValue, err := m.oldValue(ctx)
  25169. if err != nil {
  25170. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25171. }
  25172. return oldValue.CustomAgentBase, nil
  25173. }
  25174. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25175. func (m *TokenMutation) ClearCustomAgentBase() {
  25176. m.custom_agent_base = nil
  25177. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25178. }
  25179. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25180. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25181. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25182. return ok
  25183. }
  25184. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25185. func (m *TokenMutation) ResetCustomAgentBase() {
  25186. m.custom_agent_base = nil
  25187. delete(m.clearedFields, token.FieldCustomAgentBase)
  25188. }
  25189. // SetCustomAgentKey sets the "custom_agent_key" field.
  25190. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25191. m.custom_agent_key = &s
  25192. }
  25193. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25194. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25195. v := m.custom_agent_key
  25196. if v == nil {
  25197. return
  25198. }
  25199. return *v, true
  25200. }
  25201. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25202. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25204. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25205. if !m.op.Is(OpUpdateOne) {
  25206. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25207. }
  25208. if m.id == nil || m.oldValue == nil {
  25209. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25210. }
  25211. oldValue, err := m.oldValue(ctx)
  25212. if err != nil {
  25213. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25214. }
  25215. return oldValue.CustomAgentKey, nil
  25216. }
  25217. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25218. func (m *TokenMutation) ClearCustomAgentKey() {
  25219. m.custom_agent_key = nil
  25220. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25221. }
  25222. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25223. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25224. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25225. return ok
  25226. }
  25227. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25228. func (m *TokenMutation) ResetCustomAgentKey() {
  25229. m.custom_agent_key = nil
  25230. delete(m.clearedFields, token.FieldCustomAgentKey)
  25231. }
  25232. // SetOpenaiBase sets the "openai_base" field.
  25233. func (m *TokenMutation) SetOpenaiBase(s string) {
  25234. m.openai_base = &s
  25235. }
  25236. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25237. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25238. v := m.openai_base
  25239. if v == nil {
  25240. return
  25241. }
  25242. return *v, true
  25243. }
  25244. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25245. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25247. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25248. if !m.op.Is(OpUpdateOne) {
  25249. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25250. }
  25251. if m.id == nil || m.oldValue == nil {
  25252. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25253. }
  25254. oldValue, err := m.oldValue(ctx)
  25255. if err != nil {
  25256. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25257. }
  25258. return oldValue.OpenaiBase, nil
  25259. }
  25260. // ClearOpenaiBase clears the value of the "openai_base" field.
  25261. func (m *TokenMutation) ClearOpenaiBase() {
  25262. m.openai_base = nil
  25263. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25264. }
  25265. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25266. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25267. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25268. return ok
  25269. }
  25270. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25271. func (m *TokenMutation) ResetOpenaiBase() {
  25272. m.openai_base = nil
  25273. delete(m.clearedFields, token.FieldOpenaiBase)
  25274. }
  25275. // SetOpenaiKey sets the "openai_key" field.
  25276. func (m *TokenMutation) SetOpenaiKey(s string) {
  25277. m.openai_key = &s
  25278. }
  25279. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25280. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25281. v := m.openai_key
  25282. if v == nil {
  25283. return
  25284. }
  25285. return *v, true
  25286. }
  25287. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25288. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25289. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25290. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25291. if !m.op.Is(OpUpdateOne) {
  25292. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25293. }
  25294. if m.id == nil || m.oldValue == nil {
  25295. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25296. }
  25297. oldValue, err := m.oldValue(ctx)
  25298. if err != nil {
  25299. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25300. }
  25301. return oldValue.OpenaiKey, nil
  25302. }
  25303. // ClearOpenaiKey clears the value of the "openai_key" field.
  25304. func (m *TokenMutation) ClearOpenaiKey() {
  25305. m.openai_key = nil
  25306. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25307. }
  25308. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25309. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25310. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25311. return ok
  25312. }
  25313. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25314. func (m *TokenMutation) ResetOpenaiKey() {
  25315. m.openai_key = nil
  25316. delete(m.clearedFields, token.FieldOpenaiKey)
  25317. }
  25318. // ClearAgent clears the "agent" edge to the Agent entity.
  25319. func (m *TokenMutation) ClearAgent() {
  25320. m.clearedagent = true
  25321. m.clearedFields[token.FieldAgentID] = struct{}{}
  25322. }
  25323. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25324. func (m *TokenMutation) AgentCleared() bool {
  25325. return m.clearedagent
  25326. }
  25327. // AgentIDs returns the "agent" edge IDs in the mutation.
  25328. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25329. // AgentID instead. It exists only for internal usage by the builders.
  25330. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25331. if id := m.agent; id != nil {
  25332. ids = append(ids, *id)
  25333. }
  25334. return
  25335. }
  25336. // ResetAgent resets all changes to the "agent" edge.
  25337. func (m *TokenMutation) ResetAgent() {
  25338. m.agent = nil
  25339. m.clearedagent = false
  25340. }
  25341. // Where appends a list predicates to the TokenMutation builder.
  25342. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25343. m.predicates = append(m.predicates, ps...)
  25344. }
  25345. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25346. // users can use type-assertion to append predicates that do not depend on any generated package.
  25347. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25348. p := make([]predicate.Token, len(ps))
  25349. for i := range ps {
  25350. p[i] = ps[i]
  25351. }
  25352. m.Where(p...)
  25353. }
  25354. // Op returns the operation name.
  25355. func (m *TokenMutation) Op() Op {
  25356. return m.op
  25357. }
  25358. // SetOp allows setting the mutation operation.
  25359. func (m *TokenMutation) SetOp(op Op) {
  25360. m.op = op
  25361. }
  25362. // Type returns the node type of this mutation (Token).
  25363. func (m *TokenMutation) Type() string {
  25364. return m.typ
  25365. }
  25366. // Fields returns all fields that were changed during this mutation. Note that in
  25367. // order to get all numeric fields that were incremented/decremented, call
  25368. // AddedFields().
  25369. func (m *TokenMutation) Fields() []string {
  25370. fields := make([]string, 0, 12)
  25371. if m.created_at != nil {
  25372. fields = append(fields, token.FieldCreatedAt)
  25373. }
  25374. if m.updated_at != nil {
  25375. fields = append(fields, token.FieldUpdatedAt)
  25376. }
  25377. if m.deleted_at != nil {
  25378. fields = append(fields, token.FieldDeletedAt)
  25379. }
  25380. if m.expire_at != nil {
  25381. fields = append(fields, token.FieldExpireAt)
  25382. }
  25383. if m.token != nil {
  25384. fields = append(fields, token.FieldToken)
  25385. }
  25386. if m.mac != nil {
  25387. fields = append(fields, token.FieldMAC)
  25388. }
  25389. if m.organization_id != nil {
  25390. fields = append(fields, token.FieldOrganizationID)
  25391. }
  25392. if m.agent != nil {
  25393. fields = append(fields, token.FieldAgentID)
  25394. }
  25395. if m.custom_agent_base != nil {
  25396. fields = append(fields, token.FieldCustomAgentBase)
  25397. }
  25398. if m.custom_agent_key != nil {
  25399. fields = append(fields, token.FieldCustomAgentKey)
  25400. }
  25401. if m.openai_base != nil {
  25402. fields = append(fields, token.FieldOpenaiBase)
  25403. }
  25404. if m.openai_key != nil {
  25405. fields = append(fields, token.FieldOpenaiKey)
  25406. }
  25407. return fields
  25408. }
  25409. // Field returns the value of a field with the given name. The second boolean
  25410. // return value indicates that this field was not set, or was not defined in the
  25411. // schema.
  25412. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25413. switch name {
  25414. case token.FieldCreatedAt:
  25415. return m.CreatedAt()
  25416. case token.FieldUpdatedAt:
  25417. return m.UpdatedAt()
  25418. case token.FieldDeletedAt:
  25419. return m.DeletedAt()
  25420. case token.FieldExpireAt:
  25421. return m.ExpireAt()
  25422. case token.FieldToken:
  25423. return m.Token()
  25424. case token.FieldMAC:
  25425. return m.MAC()
  25426. case token.FieldOrganizationID:
  25427. return m.OrganizationID()
  25428. case token.FieldAgentID:
  25429. return m.AgentID()
  25430. case token.FieldCustomAgentBase:
  25431. return m.CustomAgentBase()
  25432. case token.FieldCustomAgentKey:
  25433. return m.CustomAgentKey()
  25434. case token.FieldOpenaiBase:
  25435. return m.OpenaiBase()
  25436. case token.FieldOpenaiKey:
  25437. return m.OpenaiKey()
  25438. }
  25439. return nil, false
  25440. }
  25441. // OldField returns the old value of the field from the database. An error is
  25442. // returned if the mutation operation is not UpdateOne, or the query to the
  25443. // database failed.
  25444. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25445. switch name {
  25446. case token.FieldCreatedAt:
  25447. return m.OldCreatedAt(ctx)
  25448. case token.FieldUpdatedAt:
  25449. return m.OldUpdatedAt(ctx)
  25450. case token.FieldDeletedAt:
  25451. return m.OldDeletedAt(ctx)
  25452. case token.FieldExpireAt:
  25453. return m.OldExpireAt(ctx)
  25454. case token.FieldToken:
  25455. return m.OldToken(ctx)
  25456. case token.FieldMAC:
  25457. return m.OldMAC(ctx)
  25458. case token.FieldOrganizationID:
  25459. return m.OldOrganizationID(ctx)
  25460. case token.FieldAgentID:
  25461. return m.OldAgentID(ctx)
  25462. case token.FieldCustomAgentBase:
  25463. return m.OldCustomAgentBase(ctx)
  25464. case token.FieldCustomAgentKey:
  25465. return m.OldCustomAgentKey(ctx)
  25466. case token.FieldOpenaiBase:
  25467. return m.OldOpenaiBase(ctx)
  25468. case token.FieldOpenaiKey:
  25469. return m.OldOpenaiKey(ctx)
  25470. }
  25471. return nil, fmt.Errorf("unknown Token field %s", name)
  25472. }
  25473. // SetField sets the value of a field with the given name. It returns an error if
  25474. // the field is not defined in the schema, or if the type mismatched the field
  25475. // type.
  25476. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25477. switch name {
  25478. case token.FieldCreatedAt:
  25479. v, ok := value.(time.Time)
  25480. if !ok {
  25481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25482. }
  25483. m.SetCreatedAt(v)
  25484. return nil
  25485. case token.FieldUpdatedAt:
  25486. v, ok := value.(time.Time)
  25487. if !ok {
  25488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25489. }
  25490. m.SetUpdatedAt(v)
  25491. return nil
  25492. case token.FieldDeletedAt:
  25493. v, ok := value.(time.Time)
  25494. if !ok {
  25495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25496. }
  25497. m.SetDeletedAt(v)
  25498. return nil
  25499. case token.FieldExpireAt:
  25500. v, ok := value.(time.Time)
  25501. if !ok {
  25502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25503. }
  25504. m.SetExpireAt(v)
  25505. return nil
  25506. case token.FieldToken:
  25507. v, ok := value.(string)
  25508. if !ok {
  25509. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25510. }
  25511. m.SetToken(v)
  25512. return nil
  25513. case token.FieldMAC:
  25514. v, ok := value.(string)
  25515. if !ok {
  25516. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25517. }
  25518. m.SetMAC(v)
  25519. return nil
  25520. case token.FieldOrganizationID:
  25521. v, ok := value.(uint64)
  25522. if !ok {
  25523. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25524. }
  25525. m.SetOrganizationID(v)
  25526. return nil
  25527. case token.FieldAgentID:
  25528. v, ok := value.(uint64)
  25529. if !ok {
  25530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25531. }
  25532. m.SetAgentID(v)
  25533. return nil
  25534. case token.FieldCustomAgentBase:
  25535. v, ok := value.(string)
  25536. if !ok {
  25537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25538. }
  25539. m.SetCustomAgentBase(v)
  25540. return nil
  25541. case token.FieldCustomAgentKey:
  25542. v, ok := value.(string)
  25543. if !ok {
  25544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25545. }
  25546. m.SetCustomAgentKey(v)
  25547. return nil
  25548. case token.FieldOpenaiBase:
  25549. v, ok := value.(string)
  25550. if !ok {
  25551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25552. }
  25553. m.SetOpenaiBase(v)
  25554. return nil
  25555. case token.FieldOpenaiKey:
  25556. v, ok := value.(string)
  25557. if !ok {
  25558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25559. }
  25560. m.SetOpenaiKey(v)
  25561. return nil
  25562. }
  25563. return fmt.Errorf("unknown Token field %s", name)
  25564. }
  25565. // AddedFields returns all numeric fields that were incremented/decremented during
  25566. // this mutation.
  25567. func (m *TokenMutation) AddedFields() []string {
  25568. var fields []string
  25569. if m.addorganization_id != nil {
  25570. fields = append(fields, token.FieldOrganizationID)
  25571. }
  25572. return fields
  25573. }
  25574. // AddedField returns the numeric value that was incremented/decremented on a field
  25575. // with the given name. The second boolean return value indicates that this field
  25576. // was not set, or was not defined in the schema.
  25577. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25578. switch name {
  25579. case token.FieldOrganizationID:
  25580. return m.AddedOrganizationID()
  25581. }
  25582. return nil, false
  25583. }
  25584. // AddField adds the value to the field with the given name. It returns an error if
  25585. // the field is not defined in the schema, or if the type mismatched the field
  25586. // type.
  25587. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25588. switch name {
  25589. case token.FieldOrganizationID:
  25590. v, ok := value.(int64)
  25591. if !ok {
  25592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25593. }
  25594. m.AddOrganizationID(v)
  25595. return nil
  25596. }
  25597. return fmt.Errorf("unknown Token numeric field %s", name)
  25598. }
  25599. // ClearedFields returns all nullable fields that were cleared during this
  25600. // mutation.
  25601. func (m *TokenMutation) ClearedFields() []string {
  25602. var fields []string
  25603. if m.FieldCleared(token.FieldDeletedAt) {
  25604. fields = append(fields, token.FieldDeletedAt)
  25605. }
  25606. if m.FieldCleared(token.FieldExpireAt) {
  25607. fields = append(fields, token.FieldExpireAt)
  25608. }
  25609. if m.FieldCleared(token.FieldToken) {
  25610. fields = append(fields, token.FieldToken)
  25611. }
  25612. if m.FieldCleared(token.FieldMAC) {
  25613. fields = append(fields, token.FieldMAC)
  25614. }
  25615. if m.FieldCleared(token.FieldCustomAgentBase) {
  25616. fields = append(fields, token.FieldCustomAgentBase)
  25617. }
  25618. if m.FieldCleared(token.FieldCustomAgentKey) {
  25619. fields = append(fields, token.FieldCustomAgentKey)
  25620. }
  25621. if m.FieldCleared(token.FieldOpenaiBase) {
  25622. fields = append(fields, token.FieldOpenaiBase)
  25623. }
  25624. if m.FieldCleared(token.FieldOpenaiKey) {
  25625. fields = append(fields, token.FieldOpenaiKey)
  25626. }
  25627. return fields
  25628. }
  25629. // FieldCleared returns a boolean indicating if a field with the given name was
  25630. // cleared in this mutation.
  25631. func (m *TokenMutation) FieldCleared(name string) bool {
  25632. _, ok := m.clearedFields[name]
  25633. return ok
  25634. }
  25635. // ClearField clears the value of the field with the given name. It returns an
  25636. // error if the field is not defined in the schema.
  25637. func (m *TokenMutation) ClearField(name string) error {
  25638. switch name {
  25639. case token.FieldDeletedAt:
  25640. m.ClearDeletedAt()
  25641. return nil
  25642. case token.FieldExpireAt:
  25643. m.ClearExpireAt()
  25644. return nil
  25645. case token.FieldToken:
  25646. m.ClearToken()
  25647. return nil
  25648. case token.FieldMAC:
  25649. m.ClearMAC()
  25650. return nil
  25651. case token.FieldCustomAgentBase:
  25652. m.ClearCustomAgentBase()
  25653. return nil
  25654. case token.FieldCustomAgentKey:
  25655. m.ClearCustomAgentKey()
  25656. return nil
  25657. case token.FieldOpenaiBase:
  25658. m.ClearOpenaiBase()
  25659. return nil
  25660. case token.FieldOpenaiKey:
  25661. m.ClearOpenaiKey()
  25662. return nil
  25663. }
  25664. return fmt.Errorf("unknown Token nullable field %s", name)
  25665. }
  25666. // ResetField resets all changes in the mutation for the field with the given name.
  25667. // It returns an error if the field is not defined in the schema.
  25668. func (m *TokenMutation) ResetField(name string) error {
  25669. switch name {
  25670. case token.FieldCreatedAt:
  25671. m.ResetCreatedAt()
  25672. return nil
  25673. case token.FieldUpdatedAt:
  25674. m.ResetUpdatedAt()
  25675. return nil
  25676. case token.FieldDeletedAt:
  25677. m.ResetDeletedAt()
  25678. return nil
  25679. case token.FieldExpireAt:
  25680. m.ResetExpireAt()
  25681. return nil
  25682. case token.FieldToken:
  25683. m.ResetToken()
  25684. return nil
  25685. case token.FieldMAC:
  25686. m.ResetMAC()
  25687. return nil
  25688. case token.FieldOrganizationID:
  25689. m.ResetOrganizationID()
  25690. return nil
  25691. case token.FieldAgentID:
  25692. m.ResetAgentID()
  25693. return nil
  25694. case token.FieldCustomAgentBase:
  25695. m.ResetCustomAgentBase()
  25696. return nil
  25697. case token.FieldCustomAgentKey:
  25698. m.ResetCustomAgentKey()
  25699. return nil
  25700. case token.FieldOpenaiBase:
  25701. m.ResetOpenaiBase()
  25702. return nil
  25703. case token.FieldOpenaiKey:
  25704. m.ResetOpenaiKey()
  25705. return nil
  25706. }
  25707. return fmt.Errorf("unknown Token field %s", name)
  25708. }
  25709. // AddedEdges returns all edge names that were set/added in this mutation.
  25710. func (m *TokenMutation) AddedEdges() []string {
  25711. edges := make([]string, 0, 1)
  25712. if m.agent != nil {
  25713. edges = append(edges, token.EdgeAgent)
  25714. }
  25715. return edges
  25716. }
  25717. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25718. // name in this mutation.
  25719. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25720. switch name {
  25721. case token.EdgeAgent:
  25722. if id := m.agent; id != nil {
  25723. return []ent.Value{*id}
  25724. }
  25725. }
  25726. return nil
  25727. }
  25728. // RemovedEdges returns all edge names that were removed in this mutation.
  25729. func (m *TokenMutation) RemovedEdges() []string {
  25730. edges := make([]string, 0, 1)
  25731. return edges
  25732. }
  25733. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25734. // the given name in this mutation.
  25735. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25736. return nil
  25737. }
  25738. // ClearedEdges returns all edge names that were cleared in this mutation.
  25739. func (m *TokenMutation) ClearedEdges() []string {
  25740. edges := make([]string, 0, 1)
  25741. if m.clearedagent {
  25742. edges = append(edges, token.EdgeAgent)
  25743. }
  25744. return edges
  25745. }
  25746. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25747. // was cleared in this mutation.
  25748. func (m *TokenMutation) EdgeCleared(name string) bool {
  25749. switch name {
  25750. case token.EdgeAgent:
  25751. return m.clearedagent
  25752. }
  25753. return false
  25754. }
  25755. // ClearEdge clears the value of the edge with the given name. It returns an error
  25756. // if that edge is not defined in the schema.
  25757. func (m *TokenMutation) ClearEdge(name string) error {
  25758. switch name {
  25759. case token.EdgeAgent:
  25760. m.ClearAgent()
  25761. return nil
  25762. }
  25763. return fmt.Errorf("unknown Token unique edge %s", name)
  25764. }
  25765. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25766. // It returns an error if the edge is not defined in the schema.
  25767. func (m *TokenMutation) ResetEdge(name string) error {
  25768. switch name {
  25769. case token.EdgeAgent:
  25770. m.ResetAgent()
  25771. return nil
  25772. }
  25773. return fmt.Errorf("unknown Token edge %s", name)
  25774. }
  25775. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25776. type TutorialMutation struct {
  25777. config
  25778. op Op
  25779. typ string
  25780. id *uint64
  25781. created_at *time.Time
  25782. updated_at *time.Time
  25783. deleted_at *time.Time
  25784. index *int
  25785. addindex *int
  25786. title *string
  25787. content *string
  25788. organization_id *uint64
  25789. addorganization_id *int64
  25790. clearedFields map[string]struct{}
  25791. employee *uint64
  25792. clearedemployee bool
  25793. done bool
  25794. oldValue func(context.Context) (*Tutorial, error)
  25795. predicates []predicate.Tutorial
  25796. }
  25797. var _ ent.Mutation = (*TutorialMutation)(nil)
  25798. // tutorialOption allows management of the mutation configuration using functional options.
  25799. type tutorialOption func(*TutorialMutation)
  25800. // newTutorialMutation creates new mutation for the Tutorial entity.
  25801. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25802. m := &TutorialMutation{
  25803. config: c,
  25804. op: op,
  25805. typ: TypeTutorial,
  25806. clearedFields: make(map[string]struct{}),
  25807. }
  25808. for _, opt := range opts {
  25809. opt(m)
  25810. }
  25811. return m
  25812. }
  25813. // withTutorialID sets the ID field of the mutation.
  25814. func withTutorialID(id uint64) tutorialOption {
  25815. return func(m *TutorialMutation) {
  25816. var (
  25817. err error
  25818. once sync.Once
  25819. value *Tutorial
  25820. )
  25821. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25822. once.Do(func() {
  25823. if m.done {
  25824. err = errors.New("querying old values post mutation is not allowed")
  25825. } else {
  25826. value, err = m.Client().Tutorial.Get(ctx, id)
  25827. }
  25828. })
  25829. return value, err
  25830. }
  25831. m.id = &id
  25832. }
  25833. }
  25834. // withTutorial sets the old Tutorial of the mutation.
  25835. func withTutorial(node *Tutorial) tutorialOption {
  25836. return func(m *TutorialMutation) {
  25837. m.oldValue = func(context.Context) (*Tutorial, error) {
  25838. return node, nil
  25839. }
  25840. m.id = &node.ID
  25841. }
  25842. }
  25843. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25844. // executed in a transaction (ent.Tx), a transactional client is returned.
  25845. func (m TutorialMutation) Client() *Client {
  25846. client := &Client{config: m.config}
  25847. client.init()
  25848. return client
  25849. }
  25850. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25851. // it returns an error otherwise.
  25852. func (m TutorialMutation) Tx() (*Tx, error) {
  25853. if _, ok := m.driver.(*txDriver); !ok {
  25854. return nil, errors.New("ent: mutation is not running in a transaction")
  25855. }
  25856. tx := &Tx{config: m.config}
  25857. tx.init()
  25858. return tx, nil
  25859. }
  25860. // SetID sets the value of the id field. Note that this
  25861. // operation is only accepted on creation of Tutorial entities.
  25862. func (m *TutorialMutation) SetID(id uint64) {
  25863. m.id = &id
  25864. }
  25865. // ID returns the ID value in the mutation. Note that the ID is only available
  25866. // if it was provided to the builder or after it was returned from the database.
  25867. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25868. if m.id == nil {
  25869. return
  25870. }
  25871. return *m.id, true
  25872. }
  25873. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25874. // That means, if the mutation is applied within a transaction with an isolation level such
  25875. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25876. // or updated by the mutation.
  25877. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25878. switch {
  25879. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25880. id, exists := m.ID()
  25881. if exists {
  25882. return []uint64{id}, nil
  25883. }
  25884. fallthrough
  25885. case m.op.Is(OpUpdate | OpDelete):
  25886. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25887. default:
  25888. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25889. }
  25890. }
  25891. // SetCreatedAt sets the "created_at" field.
  25892. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  25893. m.created_at = &t
  25894. }
  25895. // CreatedAt returns the value of the "created_at" field in the mutation.
  25896. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  25897. v := m.created_at
  25898. if v == nil {
  25899. return
  25900. }
  25901. return *v, true
  25902. }
  25903. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  25904. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25905. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25906. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25907. if !m.op.Is(OpUpdateOne) {
  25908. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25909. }
  25910. if m.id == nil || m.oldValue == nil {
  25911. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25912. }
  25913. oldValue, err := m.oldValue(ctx)
  25914. if err != nil {
  25915. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25916. }
  25917. return oldValue.CreatedAt, nil
  25918. }
  25919. // ResetCreatedAt resets all changes to the "created_at" field.
  25920. func (m *TutorialMutation) ResetCreatedAt() {
  25921. m.created_at = nil
  25922. }
  25923. // SetUpdatedAt sets the "updated_at" field.
  25924. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  25925. m.updated_at = &t
  25926. }
  25927. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25928. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  25929. v := m.updated_at
  25930. if v == nil {
  25931. return
  25932. }
  25933. return *v, true
  25934. }
  25935. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  25936. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25937. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25938. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25939. if !m.op.Is(OpUpdateOne) {
  25940. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25941. }
  25942. if m.id == nil || m.oldValue == nil {
  25943. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25944. }
  25945. oldValue, err := m.oldValue(ctx)
  25946. if err != nil {
  25947. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25948. }
  25949. return oldValue.UpdatedAt, nil
  25950. }
  25951. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25952. func (m *TutorialMutation) ResetUpdatedAt() {
  25953. m.updated_at = nil
  25954. }
  25955. // SetDeletedAt sets the "deleted_at" field.
  25956. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  25957. m.deleted_at = &t
  25958. }
  25959. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25960. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  25961. v := m.deleted_at
  25962. if v == nil {
  25963. return
  25964. }
  25965. return *v, true
  25966. }
  25967. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  25968. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25970. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25971. if !m.op.Is(OpUpdateOne) {
  25972. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25973. }
  25974. if m.id == nil || m.oldValue == nil {
  25975. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25976. }
  25977. oldValue, err := m.oldValue(ctx)
  25978. if err != nil {
  25979. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25980. }
  25981. return oldValue.DeletedAt, nil
  25982. }
  25983. // ClearDeletedAt clears the value of the "deleted_at" field.
  25984. func (m *TutorialMutation) ClearDeletedAt() {
  25985. m.deleted_at = nil
  25986. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  25987. }
  25988. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25989. func (m *TutorialMutation) DeletedAtCleared() bool {
  25990. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  25991. return ok
  25992. }
  25993. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25994. func (m *TutorialMutation) ResetDeletedAt() {
  25995. m.deleted_at = nil
  25996. delete(m.clearedFields, tutorial.FieldDeletedAt)
  25997. }
  25998. // SetEmployeeID sets the "employee_id" field.
  25999. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26000. m.employee = &u
  26001. }
  26002. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26003. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26004. v := m.employee
  26005. if v == nil {
  26006. return
  26007. }
  26008. return *v, true
  26009. }
  26010. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26011. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26013. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26014. if !m.op.Is(OpUpdateOne) {
  26015. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26016. }
  26017. if m.id == nil || m.oldValue == nil {
  26018. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26019. }
  26020. oldValue, err := m.oldValue(ctx)
  26021. if err != nil {
  26022. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26023. }
  26024. return oldValue.EmployeeID, nil
  26025. }
  26026. // ResetEmployeeID resets all changes to the "employee_id" field.
  26027. func (m *TutorialMutation) ResetEmployeeID() {
  26028. m.employee = nil
  26029. }
  26030. // SetIndex sets the "index" field.
  26031. func (m *TutorialMutation) SetIndex(i int) {
  26032. m.index = &i
  26033. m.addindex = nil
  26034. }
  26035. // Index returns the value of the "index" field in the mutation.
  26036. func (m *TutorialMutation) Index() (r int, exists bool) {
  26037. v := m.index
  26038. if v == nil {
  26039. return
  26040. }
  26041. return *v, true
  26042. }
  26043. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26044. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26046. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26047. if !m.op.Is(OpUpdateOne) {
  26048. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26049. }
  26050. if m.id == nil || m.oldValue == nil {
  26051. return v, errors.New("OldIndex requires an ID field in the mutation")
  26052. }
  26053. oldValue, err := m.oldValue(ctx)
  26054. if err != nil {
  26055. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26056. }
  26057. return oldValue.Index, nil
  26058. }
  26059. // AddIndex adds i to the "index" field.
  26060. func (m *TutorialMutation) AddIndex(i int) {
  26061. if m.addindex != nil {
  26062. *m.addindex += i
  26063. } else {
  26064. m.addindex = &i
  26065. }
  26066. }
  26067. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26068. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26069. v := m.addindex
  26070. if v == nil {
  26071. return
  26072. }
  26073. return *v, true
  26074. }
  26075. // ResetIndex resets all changes to the "index" field.
  26076. func (m *TutorialMutation) ResetIndex() {
  26077. m.index = nil
  26078. m.addindex = nil
  26079. }
  26080. // SetTitle sets the "title" field.
  26081. func (m *TutorialMutation) SetTitle(s string) {
  26082. m.title = &s
  26083. }
  26084. // Title returns the value of the "title" field in the mutation.
  26085. func (m *TutorialMutation) Title() (r string, exists bool) {
  26086. v := m.title
  26087. if v == nil {
  26088. return
  26089. }
  26090. return *v, true
  26091. }
  26092. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26093. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26094. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26095. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26096. if !m.op.Is(OpUpdateOne) {
  26097. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26098. }
  26099. if m.id == nil || m.oldValue == nil {
  26100. return v, errors.New("OldTitle requires an ID field in the mutation")
  26101. }
  26102. oldValue, err := m.oldValue(ctx)
  26103. if err != nil {
  26104. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26105. }
  26106. return oldValue.Title, nil
  26107. }
  26108. // ResetTitle resets all changes to the "title" field.
  26109. func (m *TutorialMutation) ResetTitle() {
  26110. m.title = nil
  26111. }
  26112. // SetContent sets the "content" field.
  26113. func (m *TutorialMutation) SetContent(s string) {
  26114. m.content = &s
  26115. }
  26116. // Content returns the value of the "content" field in the mutation.
  26117. func (m *TutorialMutation) Content() (r string, exists bool) {
  26118. v := m.content
  26119. if v == nil {
  26120. return
  26121. }
  26122. return *v, true
  26123. }
  26124. // OldContent returns the old "content" field's value of the Tutorial entity.
  26125. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26127. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26128. if !m.op.Is(OpUpdateOne) {
  26129. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26130. }
  26131. if m.id == nil || m.oldValue == nil {
  26132. return v, errors.New("OldContent requires an ID field in the mutation")
  26133. }
  26134. oldValue, err := m.oldValue(ctx)
  26135. if err != nil {
  26136. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26137. }
  26138. return oldValue.Content, nil
  26139. }
  26140. // ResetContent resets all changes to the "content" field.
  26141. func (m *TutorialMutation) ResetContent() {
  26142. m.content = nil
  26143. }
  26144. // SetOrganizationID sets the "organization_id" field.
  26145. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26146. m.organization_id = &u
  26147. m.addorganization_id = nil
  26148. }
  26149. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26150. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26151. v := m.organization_id
  26152. if v == nil {
  26153. return
  26154. }
  26155. return *v, true
  26156. }
  26157. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26158. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26160. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26161. if !m.op.Is(OpUpdateOne) {
  26162. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26163. }
  26164. if m.id == nil || m.oldValue == nil {
  26165. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26166. }
  26167. oldValue, err := m.oldValue(ctx)
  26168. if err != nil {
  26169. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26170. }
  26171. return oldValue.OrganizationID, nil
  26172. }
  26173. // AddOrganizationID adds u to the "organization_id" field.
  26174. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26175. if m.addorganization_id != nil {
  26176. *m.addorganization_id += u
  26177. } else {
  26178. m.addorganization_id = &u
  26179. }
  26180. }
  26181. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26182. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26183. v := m.addorganization_id
  26184. if v == nil {
  26185. return
  26186. }
  26187. return *v, true
  26188. }
  26189. // ResetOrganizationID resets all changes to the "organization_id" field.
  26190. func (m *TutorialMutation) ResetOrganizationID() {
  26191. m.organization_id = nil
  26192. m.addorganization_id = nil
  26193. }
  26194. // ClearEmployee clears the "employee" edge to the Employee entity.
  26195. func (m *TutorialMutation) ClearEmployee() {
  26196. m.clearedemployee = true
  26197. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26198. }
  26199. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26200. func (m *TutorialMutation) EmployeeCleared() bool {
  26201. return m.clearedemployee
  26202. }
  26203. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26204. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26205. // EmployeeID instead. It exists only for internal usage by the builders.
  26206. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26207. if id := m.employee; id != nil {
  26208. ids = append(ids, *id)
  26209. }
  26210. return
  26211. }
  26212. // ResetEmployee resets all changes to the "employee" edge.
  26213. func (m *TutorialMutation) ResetEmployee() {
  26214. m.employee = nil
  26215. m.clearedemployee = false
  26216. }
  26217. // Where appends a list predicates to the TutorialMutation builder.
  26218. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26219. m.predicates = append(m.predicates, ps...)
  26220. }
  26221. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26222. // users can use type-assertion to append predicates that do not depend on any generated package.
  26223. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26224. p := make([]predicate.Tutorial, len(ps))
  26225. for i := range ps {
  26226. p[i] = ps[i]
  26227. }
  26228. m.Where(p...)
  26229. }
  26230. // Op returns the operation name.
  26231. func (m *TutorialMutation) Op() Op {
  26232. return m.op
  26233. }
  26234. // SetOp allows setting the mutation operation.
  26235. func (m *TutorialMutation) SetOp(op Op) {
  26236. m.op = op
  26237. }
  26238. // Type returns the node type of this mutation (Tutorial).
  26239. func (m *TutorialMutation) Type() string {
  26240. return m.typ
  26241. }
  26242. // Fields returns all fields that were changed during this mutation. Note that in
  26243. // order to get all numeric fields that were incremented/decremented, call
  26244. // AddedFields().
  26245. func (m *TutorialMutation) Fields() []string {
  26246. fields := make([]string, 0, 8)
  26247. if m.created_at != nil {
  26248. fields = append(fields, tutorial.FieldCreatedAt)
  26249. }
  26250. if m.updated_at != nil {
  26251. fields = append(fields, tutorial.FieldUpdatedAt)
  26252. }
  26253. if m.deleted_at != nil {
  26254. fields = append(fields, tutorial.FieldDeletedAt)
  26255. }
  26256. if m.employee != nil {
  26257. fields = append(fields, tutorial.FieldEmployeeID)
  26258. }
  26259. if m.index != nil {
  26260. fields = append(fields, tutorial.FieldIndex)
  26261. }
  26262. if m.title != nil {
  26263. fields = append(fields, tutorial.FieldTitle)
  26264. }
  26265. if m.content != nil {
  26266. fields = append(fields, tutorial.FieldContent)
  26267. }
  26268. if m.organization_id != nil {
  26269. fields = append(fields, tutorial.FieldOrganizationID)
  26270. }
  26271. return fields
  26272. }
  26273. // Field returns the value of a field with the given name. The second boolean
  26274. // return value indicates that this field was not set, or was not defined in the
  26275. // schema.
  26276. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26277. switch name {
  26278. case tutorial.FieldCreatedAt:
  26279. return m.CreatedAt()
  26280. case tutorial.FieldUpdatedAt:
  26281. return m.UpdatedAt()
  26282. case tutorial.FieldDeletedAt:
  26283. return m.DeletedAt()
  26284. case tutorial.FieldEmployeeID:
  26285. return m.EmployeeID()
  26286. case tutorial.FieldIndex:
  26287. return m.Index()
  26288. case tutorial.FieldTitle:
  26289. return m.Title()
  26290. case tutorial.FieldContent:
  26291. return m.Content()
  26292. case tutorial.FieldOrganizationID:
  26293. return m.OrganizationID()
  26294. }
  26295. return nil, false
  26296. }
  26297. // OldField returns the old value of the field from the database. An error is
  26298. // returned if the mutation operation is not UpdateOne, or the query to the
  26299. // database failed.
  26300. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26301. switch name {
  26302. case tutorial.FieldCreatedAt:
  26303. return m.OldCreatedAt(ctx)
  26304. case tutorial.FieldUpdatedAt:
  26305. return m.OldUpdatedAt(ctx)
  26306. case tutorial.FieldDeletedAt:
  26307. return m.OldDeletedAt(ctx)
  26308. case tutorial.FieldEmployeeID:
  26309. return m.OldEmployeeID(ctx)
  26310. case tutorial.FieldIndex:
  26311. return m.OldIndex(ctx)
  26312. case tutorial.FieldTitle:
  26313. return m.OldTitle(ctx)
  26314. case tutorial.FieldContent:
  26315. return m.OldContent(ctx)
  26316. case tutorial.FieldOrganizationID:
  26317. return m.OldOrganizationID(ctx)
  26318. }
  26319. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26320. }
  26321. // SetField sets the value of a field with the given name. It returns an error if
  26322. // the field is not defined in the schema, or if the type mismatched the field
  26323. // type.
  26324. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26325. switch name {
  26326. case tutorial.FieldCreatedAt:
  26327. v, ok := value.(time.Time)
  26328. if !ok {
  26329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26330. }
  26331. m.SetCreatedAt(v)
  26332. return nil
  26333. case tutorial.FieldUpdatedAt:
  26334. v, ok := value.(time.Time)
  26335. if !ok {
  26336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26337. }
  26338. m.SetUpdatedAt(v)
  26339. return nil
  26340. case tutorial.FieldDeletedAt:
  26341. v, ok := value.(time.Time)
  26342. if !ok {
  26343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26344. }
  26345. m.SetDeletedAt(v)
  26346. return nil
  26347. case tutorial.FieldEmployeeID:
  26348. v, ok := value.(uint64)
  26349. if !ok {
  26350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26351. }
  26352. m.SetEmployeeID(v)
  26353. return nil
  26354. case tutorial.FieldIndex:
  26355. v, ok := value.(int)
  26356. if !ok {
  26357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26358. }
  26359. m.SetIndex(v)
  26360. return nil
  26361. case tutorial.FieldTitle:
  26362. v, ok := value.(string)
  26363. if !ok {
  26364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26365. }
  26366. m.SetTitle(v)
  26367. return nil
  26368. case tutorial.FieldContent:
  26369. v, ok := value.(string)
  26370. if !ok {
  26371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26372. }
  26373. m.SetContent(v)
  26374. return nil
  26375. case tutorial.FieldOrganizationID:
  26376. v, ok := value.(uint64)
  26377. if !ok {
  26378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26379. }
  26380. m.SetOrganizationID(v)
  26381. return nil
  26382. }
  26383. return fmt.Errorf("unknown Tutorial field %s", name)
  26384. }
  26385. // AddedFields returns all numeric fields that were incremented/decremented during
  26386. // this mutation.
  26387. func (m *TutorialMutation) AddedFields() []string {
  26388. var fields []string
  26389. if m.addindex != nil {
  26390. fields = append(fields, tutorial.FieldIndex)
  26391. }
  26392. if m.addorganization_id != nil {
  26393. fields = append(fields, tutorial.FieldOrganizationID)
  26394. }
  26395. return fields
  26396. }
  26397. // AddedField returns the numeric value that was incremented/decremented on a field
  26398. // with the given name. The second boolean return value indicates that this field
  26399. // was not set, or was not defined in the schema.
  26400. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26401. switch name {
  26402. case tutorial.FieldIndex:
  26403. return m.AddedIndex()
  26404. case tutorial.FieldOrganizationID:
  26405. return m.AddedOrganizationID()
  26406. }
  26407. return nil, false
  26408. }
  26409. // AddField adds the value to the field with the given name. It returns an error if
  26410. // the field is not defined in the schema, or if the type mismatched the field
  26411. // type.
  26412. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26413. switch name {
  26414. case tutorial.FieldIndex:
  26415. v, ok := value.(int)
  26416. if !ok {
  26417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26418. }
  26419. m.AddIndex(v)
  26420. return nil
  26421. case tutorial.FieldOrganizationID:
  26422. v, ok := value.(int64)
  26423. if !ok {
  26424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26425. }
  26426. m.AddOrganizationID(v)
  26427. return nil
  26428. }
  26429. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26430. }
  26431. // ClearedFields returns all nullable fields that were cleared during this
  26432. // mutation.
  26433. func (m *TutorialMutation) ClearedFields() []string {
  26434. var fields []string
  26435. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26436. fields = append(fields, tutorial.FieldDeletedAt)
  26437. }
  26438. return fields
  26439. }
  26440. // FieldCleared returns a boolean indicating if a field with the given name was
  26441. // cleared in this mutation.
  26442. func (m *TutorialMutation) FieldCleared(name string) bool {
  26443. _, ok := m.clearedFields[name]
  26444. return ok
  26445. }
  26446. // ClearField clears the value of the field with the given name. It returns an
  26447. // error if the field is not defined in the schema.
  26448. func (m *TutorialMutation) ClearField(name string) error {
  26449. switch name {
  26450. case tutorial.FieldDeletedAt:
  26451. m.ClearDeletedAt()
  26452. return nil
  26453. }
  26454. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26455. }
  26456. // ResetField resets all changes in the mutation for the field with the given name.
  26457. // It returns an error if the field is not defined in the schema.
  26458. func (m *TutorialMutation) ResetField(name string) error {
  26459. switch name {
  26460. case tutorial.FieldCreatedAt:
  26461. m.ResetCreatedAt()
  26462. return nil
  26463. case tutorial.FieldUpdatedAt:
  26464. m.ResetUpdatedAt()
  26465. return nil
  26466. case tutorial.FieldDeletedAt:
  26467. m.ResetDeletedAt()
  26468. return nil
  26469. case tutorial.FieldEmployeeID:
  26470. m.ResetEmployeeID()
  26471. return nil
  26472. case tutorial.FieldIndex:
  26473. m.ResetIndex()
  26474. return nil
  26475. case tutorial.FieldTitle:
  26476. m.ResetTitle()
  26477. return nil
  26478. case tutorial.FieldContent:
  26479. m.ResetContent()
  26480. return nil
  26481. case tutorial.FieldOrganizationID:
  26482. m.ResetOrganizationID()
  26483. return nil
  26484. }
  26485. return fmt.Errorf("unknown Tutorial field %s", name)
  26486. }
  26487. // AddedEdges returns all edge names that were set/added in this mutation.
  26488. func (m *TutorialMutation) AddedEdges() []string {
  26489. edges := make([]string, 0, 1)
  26490. if m.employee != nil {
  26491. edges = append(edges, tutorial.EdgeEmployee)
  26492. }
  26493. return edges
  26494. }
  26495. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26496. // name in this mutation.
  26497. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26498. switch name {
  26499. case tutorial.EdgeEmployee:
  26500. if id := m.employee; id != nil {
  26501. return []ent.Value{*id}
  26502. }
  26503. }
  26504. return nil
  26505. }
  26506. // RemovedEdges returns all edge names that were removed in this mutation.
  26507. func (m *TutorialMutation) RemovedEdges() []string {
  26508. edges := make([]string, 0, 1)
  26509. return edges
  26510. }
  26511. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26512. // the given name in this mutation.
  26513. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26514. return nil
  26515. }
  26516. // ClearedEdges returns all edge names that were cleared in this mutation.
  26517. func (m *TutorialMutation) ClearedEdges() []string {
  26518. edges := make([]string, 0, 1)
  26519. if m.clearedemployee {
  26520. edges = append(edges, tutorial.EdgeEmployee)
  26521. }
  26522. return edges
  26523. }
  26524. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26525. // was cleared in this mutation.
  26526. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26527. switch name {
  26528. case tutorial.EdgeEmployee:
  26529. return m.clearedemployee
  26530. }
  26531. return false
  26532. }
  26533. // ClearEdge clears the value of the edge with the given name. It returns an error
  26534. // if that edge is not defined in the schema.
  26535. func (m *TutorialMutation) ClearEdge(name string) error {
  26536. switch name {
  26537. case tutorial.EdgeEmployee:
  26538. m.ClearEmployee()
  26539. return nil
  26540. }
  26541. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26542. }
  26543. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26544. // It returns an error if the edge is not defined in the schema.
  26545. func (m *TutorialMutation) ResetEdge(name string) error {
  26546. switch name {
  26547. case tutorial.EdgeEmployee:
  26548. m.ResetEmployee()
  26549. return nil
  26550. }
  26551. return fmt.Errorf("unknown Tutorial edge %s", name)
  26552. }
  26553. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26554. type UsageDetailMutation struct {
  26555. config
  26556. op Op
  26557. typ string
  26558. id *uint64
  26559. created_at *time.Time
  26560. updated_at *time.Time
  26561. status *uint8
  26562. addstatus *int8
  26563. _type *int
  26564. add_type *int
  26565. bot_id *string
  26566. receiver_id *string
  26567. app *int
  26568. addapp *int
  26569. session_id *uint64
  26570. addsession_id *int64
  26571. request *string
  26572. response *string
  26573. original_data *custom_types.OriginalData
  26574. total_tokens *uint64
  26575. addtotal_tokens *int64
  26576. prompt_tokens *uint64
  26577. addprompt_tokens *int64
  26578. completion_tokens *uint64
  26579. addcompletion_tokens *int64
  26580. organization_id *uint64
  26581. addorganization_id *int64
  26582. clearedFields map[string]struct{}
  26583. done bool
  26584. oldValue func(context.Context) (*UsageDetail, error)
  26585. predicates []predicate.UsageDetail
  26586. }
  26587. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26588. // usagedetailOption allows management of the mutation configuration using functional options.
  26589. type usagedetailOption func(*UsageDetailMutation)
  26590. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26591. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26592. m := &UsageDetailMutation{
  26593. config: c,
  26594. op: op,
  26595. typ: TypeUsageDetail,
  26596. clearedFields: make(map[string]struct{}),
  26597. }
  26598. for _, opt := range opts {
  26599. opt(m)
  26600. }
  26601. return m
  26602. }
  26603. // withUsageDetailID sets the ID field of the mutation.
  26604. func withUsageDetailID(id uint64) usagedetailOption {
  26605. return func(m *UsageDetailMutation) {
  26606. var (
  26607. err error
  26608. once sync.Once
  26609. value *UsageDetail
  26610. )
  26611. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26612. once.Do(func() {
  26613. if m.done {
  26614. err = errors.New("querying old values post mutation is not allowed")
  26615. } else {
  26616. value, err = m.Client().UsageDetail.Get(ctx, id)
  26617. }
  26618. })
  26619. return value, err
  26620. }
  26621. m.id = &id
  26622. }
  26623. }
  26624. // withUsageDetail sets the old UsageDetail of the mutation.
  26625. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26626. return func(m *UsageDetailMutation) {
  26627. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26628. return node, nil
  26629. }
  26630. m.id = &node.ID
  26631. }
  26632. }
  26633. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26634. // executed in a transaction (ent.Tx), a transactional client is returned.
  26635. func (m UsageDetailMutation) Client() *Client {
  26636. client := &Client{config: m.config}
  26637. client.init()
  26638. return client
  26639. }
  26640. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26641. // it returns an error otherwise.
  26642. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26643. if _, ok := m.driver.(*txDriver); !ok {
  26644. return nil, errors.New("ent: mutation is not running in a transaction")
  26645. }
  26646. tx := &Tx{config: m.config}
  26647. tx.init()
  26648. return tx, nil
  26649. }
  26650. // SetID sets the value of the id field. Note that this
  26651. // operation is only accepted on creation of UsageDetail entities.
  26652. func (m *UsageDetailMutation) SetID(id uint64) {
  26653. m.id = &id
  26654. }
  26655. // ID returns the ID value in the mutation. Note that the ID is only available
  26656. // if it was provided to the builder or after it was returned from the database.
  26657. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26658. if m.id == nil {
  26659. return
  26660. }
  26661. return *m.id, true
  26662. }
  26663. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26664. // That means, if the mutation is applied within a transaction with an isolation level such
  26665. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26666. // or updated by the mutation.
  26667. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26668. switch {
  26669. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26670. id, exists := m.ID()
  26671. if exists {
  26672. return []uint64{id}, nil
  26673. }
  26674. fallthrough
  26675. case m.op.Is(OpUpdate | OpDelete):
  26676. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26677. default:
  26678. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26679. }
  26680. }
  26681. // SetCreatedAt sets the "created_at" field.
  26682. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26683. m.created_at = &t
  26684. }
  26685. // CreatedAt returns the value of the "created_at" field in the mutation.
  26686. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26687. v := m.created_at
  26688. if v == nil {
  26689. return
  26690. }
  26691. return *v, true
  26692. }
  26693. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26694. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26695. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26696. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26697. if !m.op.Is(OpUpdateOne) {
  26698. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26699. }
  26700. if m.id == nil || m.oldValue == nil {
  26701. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26702. }
  26703. oldValue, err := m.oldValue(ctx)
  26704. if err != nil {
  26705. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26706. }
  26707. return oldValue.CreatedAt, nil
  26708. }
  26709. // ResetCreatedAt resets all changes to the "created_at" field.
  26710. func (m *UsageDetailMutation) ResetCreatedAt() {
  26711. m.created_at = nil
  26712. }
  26713. // SetUpdatedAt sets the "updated_at" field.
  26714. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26715. m.updated_at = &t
  26716. }
  26717. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26718. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26719. v := m.updated_at
  26720. if v == nil {
  26721. return
  26722. }
  26723. return *v, true
  26724. }
  26725. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26726. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26728. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26729. if !m.op.Is(OpUpdateOne) {
  26730. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26731. }
  26732. if m.id == nil || m.oldValue == nil {
  26733. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26734. }
  26735. oldValue, err := m.oldValue(ctx)
  26736. if err != nil {
  26737. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26738. }
  26739. return oldValue.UpdatedAt, nil
  26740. }
  26741. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26742. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26743. m.updated_at = nil
  26744. }
  26745. // SetStatus sets the "status" field.
  26746. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26747. m.status = &u
  26748. m.addstatus = nil
  26749. }
  26750. // Status returns the value of the "status" field in the mutation.
  26751. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26752. v := m.status
  26753. if v == nil {
  26754. return
  26755. }
  26756. return *v, true
  26757. }
  26758. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26759. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26761. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26762. if !m.op.Is(OpUpdateOne) {
  26763. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26764. }
  26765. if m.id == nil || m.oldValue == nil {
  26766. return v, errors.New("OldStatus requires an ID field in the mutation")
  26767. }
  26768. oldValue, err := m.oldValue(ctx)
  26769. if err != nil {
  26770. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26771. }
  26772. return oldValue.Status, nil
  26773. }
  26774. // AddStatus adds u to the "status" field.
  26775. func (m *UsageDetailMutation) AddStatus(u int8) {
  26776. if m.addstatus != nil {
  26777. *m.addstatus += u
  26778. } else {
  26779. m.addstatus = &u
  26780. }
  26781. }
  26782. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26783. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26784. v := m.addstatus
  26785. if v == nil {
  26786. return
  26787. }
  26788. return *v, true
  26789. }
  26790. // ClearStatus clears the value of the "status" field.
  26791. func (m *UsageDetailMutation) ClearStatus() {
  26792. m.status = nil
  26793. m.addstatus = nil
  26794. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26795. }
  26796. // StatusCleared returns if the "status" field was cleared in this mutation.
  26797. func (m *UsageDetailMutation) StatusCleared() bool {
  26798. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26799. return ok
  26800. }
  26801. // ResetStatus resets all changes to the "status" field.
  26802. func (m *UsageDetailMutation) ResetStatus() {
  26803. m.status = nil
  26804. m.addstatus = nil
  26805. delete(m.clearedFields, usagedetail.FieldStatus)
  26806. }
  26807. // SetType sets the "type" field.
  26808. func (m *UsageDetailMutation) SetType(i int) {
  26809. m._type = &i
  26810. m.add_type = nil
  26811. }
  26812. // GetType returns the value of the "type" field in the mutation.
  26813. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26814. v := m._type
  26815. if v == nil {
  26816. return
  26817. }
  26818. return *v, true
  26819. }
  26820. // OldType returns the old "type" field's value of the UsageDetail entity.
  26821. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26823. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26824. if !m.op.Is(OpUpdateOne) {
  26825. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26826. }
  26827. if m.id == nil || m.oldValue == nil {
  26828. return v, errors.New("OldType requires an ID field in the mutation")
  26829. }
  26830. oldValue, err := m.oldValue(ctx)
  26831. if err != nil {
  26832. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26833. }
  26834. return oldValue.Type, nil
  26835. }
  26836. // AddType adds i to the "type" field.
  26837. func (m *UsageDetailMutation) AddType(i int) {
  26838. if m.add_type != nil {
  26839. *m.add_type += i
  26840. } else {
  26841. m.add_type = &i
  26842. }
  26843. }
  26844. // AddedType returns the value that was added to the "type" field in this mutation.
  26845. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26846. v := m.add_type
  26847. if v == nil {
  26848. return
  26849. }
  26850. return *v, true
  26851. }
  26852. // ClearType clears the value of the "type" field.
  26853. func (m *UsageDetailMutation) ClearType() {
  26854. m._type = nil
  26855. m.add_type = nil
  26856. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26857. }
  26858. // TypeCleared returns if the "type" field was cleared in this mutation.
  26859. func (m *UsageDetailMutation) TypeCleared() bool {
  26860. _, ok := m.clearedFields[usagedetail.FieldType]
  26861. return ok
  26862. }
  26863. // ResetType resets all changes to the "type" field.
  26864. func (m *UsageDetailMutation) ResetType() {
  26865. m._type = nil
  26866. m.add_type = nil
  26867. delete(m.clearedFields, usagedetail.FieldType)
  26868. }
  26869. // SetBotID sets the "bot_id" field.
  26870. func (m *UsageDetailMutation) SetBotID(s string) {
  26871. m.bot_id = &s
  26872. }
  26873. // BotID returns the value of the "bot_id" field in the mutation.
  26874. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26875. v := m.bot_id
  26876. if v == nil {
  26877. return
  26878. }
  26879. return *v, true
  26880. }
  26881. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26882. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26883. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26884. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26885. if !m.op.Is(OpUpdateOne) {
  26886. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26887. }
  26888. if m.id == nil || m.oldValue == nil {
  26889. return v, errors.New("OldBotID requires an ID field in the mutation")
  26890. }
  26891. oldValue, err := m.oldValue(ctx)
  26892. if err != nil {
  26893. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26894. }
  26895. return oldValue.BotID, nil
  26896. }
  26897. // ResetBotID resets all changes to the "bot_id" field.
  26898. func (m *UsageDetailMutation) ResetBotID() {
  26899. m.bot_id = nil
  26900. }
  26901. // SetReceiverID sets the "receiver_id" field.
  26902. func (m *UsageDetailMutation) SetReceiverID(s string) {
  26903. m.receiver_id = &s
  26904. }
  26905. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  26906. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  26907. v := m.receiver_id
  26908. if v == nil {
  26909. return
  26910. }
  26911. return *v, true
  26912. }
  26913. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  26914. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26916. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  26917. if !m.op.Is(OpUpdateOne) {
  26918. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  26919. }
  26920. if m.id == nil || m.oldValue == nil {
  26921. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  26922. }
  26923. oldValue, err := m.oldValue(ctx)
  26924. if err != nil {
  26925. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  26926. }
  26927. return oldValue.ReceiverID, nil
  26928. }
  26929. // ResetReceiverID resets all changes to the "receiver_id" field.
  26930. func (m *UsageDetailMutation) ResetReceiverID() {
  26931. m.receiver_id = nil
  26932. }
  26933. // SetApp sets the "app" field.
  26934. func (m *UsageDetailMutation) SetApp(i int) {
  26935. m.app = &i
  26936. m.addapp = nil
  26937. }
  26938. // App returns the value of the "app" field in the mutation.
  26939. func (m *UsageDetailMutation) App() (r int, exists bool) {
  26940. v := m.app
  26941. if v == nil {
  26942. return
  26943. }
  26944. return *v, true
  26945. }
  26946. // OldApp returns the old "app" field's value of the UsageDetail entity.
  26947. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26949. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  26950. if !m.op.Is(OpUpdateOne) {
  26951. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  26952. }
  26953. if m.id == nil || m.oldValue == nil {
  26954. return v, errors.New("OldApp requires an ID field in the mutation")
  26955. }
  26956. oldValue, err := m.oldValue(ctx)
  26957. if err != nil {
  26958. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  26959. }
  26960. return oldValue.App, nil
  26961. }
  26962. // AddApp adds i to the "app" field.
  26963. func (m *UsageDetailMutation) AddApp(i int) {
  26964. if m.addapp != nil {
  26965. *m.addapp += i
  26966. } else {
  26967. m.addapp = &i
  26968. }
  26969. }
  26970. // AddedApp returns the value that was added to the "app" field in this mutation.
  26971. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  26972. v := m.addapp
  26973. if v == nil {
  26974. return
  26975. }
  26976. return *v, true
  26977. }
  26978. // ClearApp clears the value of the "app" field.
  26979. func (m *UsageDetailMutation) ClearApp() {
  26980. m.app = nil
  26981. m.addapp = nil
  26982. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  26983. }
  26984. // AppCleared returns if the "app" field was cleared in this mutation.
  26985. func (m *UsageDetailMutation) AppCleared() bool {
  26986. _, ok := m.clearedFields[usagedetail.FieldApp]
  26987. return ok
  26988. }
  26989. // ResetApp resets all changes to the "app" field.
  26990. func (m *UsageDetailMutation) ResetApp() {
  26991. m.app = nil
  26992. m.addapp = nil
  26993. delete(m.clearedFields, usagedetail.FieldApp)
  26994. }
  26995. // SetSessionID sets the "session_id" field.
  26996. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  26997. m.session_id = &u
  26998. m.addsession_id = nil
  26999. }
  27000. // SessionID returns the value of the "session_id" field in the mutation.
  27001. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27002. v := m.session_id
  27003. if v == nil {
  27004. return
  27005. }
  27006. return *v, true
  27007. }
  27008. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27009. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27010. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27011. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27012. if !m.op.Is(OpUpdateOne) {
  27013. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27014. }
  27015. if m.id == nil || m.oldValue == nil {
  27016. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27017. }
  27018. oldValue, err := m.oldValue(ctx)
  27019. if err != nil {
  27020. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27021. }
  27022. return oldValue.SessionID, nil
  27023. }
  27024. // AddSessionID adds u to the "session_id" field.
  27025. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27026. if m.addsession_id != nil {
  27027. *m.addsession_id += u
  27028. } else {
  27029. m.addsession_id = &u
  27030. }
  27031. }
  27032. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27033. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27034. v := m.addsession_id
  27035. if v == nil {
  27036. return
  27037. }
  27038. return *v, true
  27039. }
  27040. // ClearSessionID clears the value of the "session_id" field.
  27041. func (m *UsageDetailMutation) ClearSessionID() {
  27042. m.session_id = nil
  27043. m.addsession_id = nil
  27044. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27045. }
  27046. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27047. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27048. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27049. return ok
  27050. }
  27051. // ResetSessionID resets all changes to the "session_id" field.
  27052. func (m *UsageDetailMutation) ResetSessionID() {
  27053. m.session_id = nil
  27054. m.addsession_id = nil
  27055. delete(m.clearedFields, usagedetail.FieldSessionID)
  27056. }
  27057. // SetRequest sets the "request" field.
  27058. func (m *UsageDetailMutation) SetRequest(s string) {
  27059. m.request = &s
  27060. }
  27061. // Request returns the value of the "request" field in the mutation.
  27062. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27063. v := m.request
  27064. if v == nil {
  27065. return
  27066. }
  27067. return *v, true
  27068. }
  27069. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27070. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27072. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27073. if !m.op.Is(OpUpdateOne) {
  27074. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27075. }
  27076. if m.id == nil || m.oldValue == nil {
  27077. return v, errors.New("OldRequest requires an ID field in the mutation")
  27078. }
  27079. oldValue, err := m.oldValue(ctx)
  27080. if err != nil {
  27081. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27082. }
  27083. return oldValue.Request, nil
  27084. }
  27085. // ResetRequest resets all changes to the "request" field.
  27086. func (m *UsageDetailMutation) ResetRequest() {
  27087. m.request = nil
  27088. }
  27089. // SetResponse sets the "response" field.
  27090. func (m *UsageDetailMutation) SetResponse(s string) {
  27091. m.response = &s
  27092. }
  27093. // Response returns the value of the "response" field in the mutation.
  27094. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27095. v := m.response
  27096. if v == nil {
  27097. return
  27098. }
  27099. return *v, true
  27100. }
  27101. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27102. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27104. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27105. if !m.op.Is(OpUpdateOne) {
  27106. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27107. }
  27108. if m.id == nil || m.oldValue == nil {
  27109. return v, errors.New("OldResponse requires an ID field in the mutation")
  27110. }
  27111. oldValue, err := m.oldValue(ctx)
  27112. if err != nil {
  27113. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27114. }
  27115. return oldValue.Response, nil
  27116. }
  27117. // ResetResponse resets all changes to the "response" field.
  27118. func (m *UsageDetailMutation) ResetResponse() {
  27119. m.response = nil
  27120. }
  27121. // SetOriginalData sets the "original_data" field.
  27122. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27123. m.original_data = &ctd
  27124. }
  27125. // OriginalData returns the value of the "original_data" field in the mutation.
  27126. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27127. v := m.original_data
  27128. if v == nil {
  27129. return
  27130. }
  27131. return *v, true
  27132. }
  27133. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27134. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27136. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27137. if !m.op.Is(OpUpdateOne) {
  27138. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27139. }
  27140. if m.id == nil || m.oldValue == nil {
  27141. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27142. }
  27143. oldValue, err := m.oldValue(ctx)
  27144. if err != nil {
  27145. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27146. }
  27147. return oldValue.OriginalData, nil
  27148. }
  27149. // ResetOriginalData resets all changes to the "original_data" field.
  27150. func (m *UsageDetailMutation) ResetOriginalData() {
  27151. m.original_data = nil
  27152. }
  27153. // SetTotalTokens sets the "total_tokens" field.
  27154. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27155. m.total_tokens = &u
  27156. m.addtotal_tokens = nil
  27157. }
  27158. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27159. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27160. v := m.total_tokens
  27161. if v == nil {
  27162. return
  27163. }
  27164. return *v, true
  27165. }
  27166. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27167. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27169. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27170. if !m.op.Is(OpUpdateOne) {
  27171. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27172. }
  27173. if m.id == nil || m.oldValue == nil {
  27174. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27175. }
  27176. oldValue, err := m.oldValue(ctx)
  27177. if err != nil {
  27178. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27179. }
  27180. return oldValue.TotalTokens, nil
  27181. }
  27182. // AddTotalTokens adds u to the "total_tokens" field.
  27183. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27184. if m.addtotal_tokens != nil {
  27185. *m.addtotal_tokens += u
  27186. } else {
  27187. m.addtotal_tokens = &u
  27188. }
  27189. }
  27190. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27191. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27192. v := m.addtotal_tokens
  27193. if v == nil {
  27194. return
  27195. }
  27196. return *v, true
  27197. }
  27198. // ClearTotalTokens clears the value of the "total_tokens" field.
  27199. func (m *UsageDetailMutation) ClearTotalTokens() {
  27200. m.total_tokens = nil
  27201. m.addtotal_tokens = nil
  27202. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27203. }
  27204. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27205. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27206. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27207. return ok
  27208. }
  27209. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27210. func (m *UsageDetailMutation) ResetTotalTokens() {
  27211. m.total_tokens = nil
  27212. m.addtotal_tokens = nil
  27213. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27214. }
  27215. // SetPromptTokens sets the "prompt_tokens" field.
  27216. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27217. m.prompt_tokens = &u
  27218. m.addprompt_tokens = nil
  27219. }
  27220. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27221. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27222. v := m.prompt_tokens
  27223. if v == nil {
  27224. return
  27225. }
  27226. return *v, true
  27227. }
  27228. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27229. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27231. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27232. if !m.op.Is(OpUpdateOne) {
  27233. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27234. }
  27235. if m.id == nil || m.oldValue == nil {
  27236. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27237. }
  27238. oldValue, err := m.oldValue(ctx)
  27239. if err != nil {
  27240. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27241. }
  27242. return oldValue.PromptTokens, nil
  27243. }
  27244. // AddPromptTokens adds u to the "prompt_tokens" field.
  27245. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27246. if m.addprompt_tokens != nil {
  27247. *m.addprompt_tokens += u
  27248. } else {
  27249. m.addprompt_tokens = &u
  27250. }
  27251. }
  27252. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27253. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27254. v := m.addprompt_tokens
  27255. if v == nil {
  27256. return
  27257. }
  27258. return *v, true
  27259. }
  27260. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27261. func (m *UsageDetailMutation) ClearPromptTokens() {
  27262. m.prompt_tokens = nil
  27263. m.addprompt_tokens = nil
  27264. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27265. }
  27266. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27267. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27268. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27269. return ok
  27270. }
  27271. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27272. func (m *UsageDetailMutation) ResetPromptTokens() {
  27273. m.prompt_tokens = nil
  27274. m.addprompt_tokens = nil
  27275. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27276. }
  27277. // SetCompletionTokens sets the "completion_tokens" field.
  27278. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27279. m.completion_tokens = &u
  27280. m.addcompletion_tokens = nil
  27281. }
  27282. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27283. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27284. v := m.completion_tokens
  27285. if v == nil {
  27286. return
  27287. }
  27288. return *v, true
  27289. }
  27290. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27291. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27292. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27293. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27294. if !m.op.Is(OpUpdateOne) {
  27295. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27296. }
  27297. if m.id == nil || m.oldValue == nil {
  27298. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27299. }
  27300. oldValue, err := m.oldValue(ctx)
  27301. if err != nil {
  27302. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27303. }
  27304. return oldValue.CompletionTokens, nil
  27305. }
  27306. // AddCompletionTokens adds u to the "completion_tokens" field.
  27307. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27308. if m.addcompletion_tokens != nil {
  27309. *m.addcompletion_tokens += u
  27310. } else {
  27311. m.addcompletion_tokens = &u
  27312. }
  27313. }
  27314. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27315. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27316. v := m.addcompletion_tokens
  27317. if v == nil {
  27318. return
  27319. }
  27320. return *v, true
  27321. }
  27322. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27323. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27324. m.completion_tokens = nil
  27325. m.addcompletion_tokens = nil
  27326. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27327. }
  27328. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27329. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27330. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27331. return ok
  27332. }
  27333. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27334. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27335. m.completion_tokens = nil
  27336. m.addcompletion_tokens = nil
  27337. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27338. }
  27339. // SetOrganizationID sets the "organization_id" field.
  27340. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27341. m.organization_id = &u
  27342. m.addorganization_id = nil
  27343. }
  27344. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27345. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27346. v := m.organization_id
  27347. if v == nil {
  27348. return
  27349. }
  27350. return *v, true
  27351. }
  27352. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27353. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27355. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27356. if !m.op.Is(OpUpdateOne) {
  27357. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27358. }
  27359. if m.id == nil || m.oldValue == nil {
  27360. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27361. }
  27362. oldValue, err := m.oldValue(ctx)
  27363. if err != nil {
  27364. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27365. }
  27366. return oldValue.OrganizationID, nil
  27367. }
  27368. // AddOrganizationID adds u to the "organization_id" field.
  27369. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27370. if m.addorganization_id != nil {
  27371. *m.addorganization_id += u
  27372. } else {
  27373. m.addorganization_id = &u
  27374. }
  27375. }
  27376. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27377. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27378. v := m.addorganization_id
  27379. if v == nil {
  27380. return
  27381. }
  27382. return *v, true
  27383. }
  27384. // ClearOrganizationID clears the value of the "organization_id" field.
  27385. func (m *UsageDetailMutation) ClearOrganizationID() {
  27386. m.organization_id = nil
  27387. m.addorganization_id = nil
  27388. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27389. }
  27390. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27391. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27392. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27393. return ok
  27394. }
  27395. // ResetOrganizationID resets all changes to the "organization_id" field.
  27396. func (m *UsageDetailMutation) ResetOrganizationID() {
  27397. m.organization_id = nil
  27398. m.addorganization_id = nil
  27399. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27400. }
  27401. // Where appends a list predicates to the UsageDetailMutation builder.
  27402. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27403. m.predicates = append(m.predicates, ps...)
  27404. }
  27405. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27406. // users can use type-assertion to append predicates that do not depend on any generated package.
  27407. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27408. p := make([]predicate.UsageDetail, len(ps))
  27409. for i := range ps {
  27410. p[i] = ps[i]
  27411. }
  27412. m.Where(p...)
  27413. }
  27414. // Op returns the operation name.
  27415. func (m *UsageDetailMutation) Op() Op {
  27416. return m.op
  27417. }
  27418. // SetOp allows setting the mutation operation.
  27419. func (m *UsageDetailMutation) SetOp(op Op) {
  27420. m.op = op
  27421. }
  27422. // Type returns the node type of this mutation (UsageDetail).
  27423. func (m *UsageDetailMutation) Type() string {
  27424. return m.typ
  27425. }
  27426. // Fields returns all fields that were changed during this mutation. Note that in
  27427. // order to get all numeric fields that were incremented/decremented, call
  27428. // AddedFields().
  27429. func (m *UsageDetailMutation) Fields() []string {
  27430. fields := make([]string, 0, 15)
  27431. if m.created_at != nil {
  27432. fields = append(fields, usagedetail.FieldCreatedAt)
  27433. }
  27434. if m.updated_at != nil {
  27435. fields = append(fields, usagedetail.FieldUpdatedAt)
  27436. }
  27437. if m.status != nil {
  27438. fields = append(fields, usagedetail.FieldStatus)
  27439. }
  27440. if m._type != nil {
  27441. fields = append(fields, usagedetail.FieldType)
  27442. }
  27443. if m.bot_id != nil {
  27444. fields = append(fields, usagedetail.FieldBotID)
  27445. }
  27446. if m.receiver_id != nil {
  27447. fields = append(fields, usagedetail.FieldReceiverID)
  27448. }
  27449. if m.app != nil {
  27450. fields = append(fields, usagedetail.FieldApp)
  27451. }
  27452. if m.session_id != nil {
  27453. fields = append(fields, usagedetail.FieldSessionID)
  27454. }
  27455. if m.request != nil {
  27456. fields = append(fields, usagedetail.FieldRequest)
  27457. }
  27458. if m.response != nil {
  27459. fields = append(fields, usagedetail.FieldResponse)
  27460. }
  27461. if m.original_data != nil {
  27462. fields = append(fields, usagedetail.FieldOriginalData)
  27463. }
  27464. if m.total_tokens != nil {
  27465. fields = append(fields, usagedetail.FieldTotalTokens)
  27466. }
  27467. if m.prompt_tokens != nil {
  27468. fields = append(fields, usagedetail.FieldPromptTokens)
  27469. }
  27470. if m.completion_tokens != nil {
  27471. fields = append(fields, usagedetail.FieldCompletionTokens)
  27472. }
  27473. if m.organization_id != nil {
  27474. fields = append(fields, usagedetail.FieldOrganizationID)
  27475. }
  27476. return fields
  27477. }
  27478. // Field returns the value of a field with the given name. The second boolean
  27479. // return value indicates that this field was not set, or was not defined in the
  27480. // schema.
  27481. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27482. switch name {
  27483. case usagedetail.FieldCreatedAt:
  27484. return m.CreatedAt()
  27485. case usagedetail.FieldUpdatedAt:
  27486. return m.UpdatedAt()
  27487. case usagedetail.FieldStatus:
  27488. return m.Status()
  27489. case usagedetail.FieldType:
  27490. return m.GetType()
  27491. case usagedetail.FieldBotID:
  27492. return m.BotID()
  27493. case usagedetail.FieldReceiverID:
  27494. return m.ReceiverID()
  27495. case usagedetail.FieldApp:
  27496. return m.App()
  27497. case usagedetail.FieldSessionID:
  27498. return m.SessionID()
  27499. case usagedetail.FieldRequest:
  27500. return m.Request()
  27501. case usagedetail.FieldResponse:
  27502. return m.Response()
  27503. case usagedetail.FieldOriginalData:
  27504. return m.OriginalData()
  27505. case usagedetail.FieldTotalTokens:
  27506. return m.TotalTokens()
  27507. case usagedetail.FieldPromptTokens:
  27508. return m.PromptTokens()
  27509. case usagedetail.FieldCompletionTokens:
  27510. return m.CompletionTokens()
  27511. case usagedetail.FieldOrganizationID:
  27512. return m.OrganizationID()
  27513. }
  27514. return nil, false
  27515. }
  27516. // OldField returns the old value of the field from the database. An error is
  27517. // returned if the mutation operation is not UpdateOne, or the query to the
  27518. // database failed.
  27519. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27520. switch name {
  27521. case usagedetail.FieldCreatedAt:
  27522. return m.OldCreatedAt(ctx)
  27523. case usagedetail.FieldUpdatedAt:
  27524. return m.OldUpdatedAt(ctx)
  27525. case usagedetail.FieldStatus:
  27526. return m.OldStatus(ctx)
  27527. case usagedetail.FieldType:
  27528. return m.OldType(ctx)
  27529. case usagedetail.FieldBotID:
  27530. return m.OldBotID(ctx)
  27531. case usagedetail.FieldReceiverID:
  27532. return m.OldReceiverID(ctx)
  27533. case usagedetail.FieldApp:
  27534. return m.OldApp(ctx)
  27535. case usagedetail.FieldSessionID:
  27536. return m.OldSessionID(ctx)
  27537. case usagedetail.FieldRequest:
  27538. return m.OldRequest(ctx)
  27539. case usagedetail.FieldResponse:
  27540. return m.OldResponse(ctx)
  27541. case usagedetail.FieldOriginalData:
  27542. return m.OldOriginalData(ctx)
  27543. case usagedetail.FieldTotalTokens:
  27544. return m.OldTotalTokens(ctx)
  27545. case usagedetail.FieldPromptTokens:
  27546. return m.OldPromptTokens(ctx)
  27547. case usagedetail.FieldCompletionTokens:
  27548. return m.OldCompletionTokens(ctx)
  27549. case usagedetail.FieldOrganizationID:
  27550. return m.OldOrganizationID(ctx)
  27551. }
  27552. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27553. }
  27554. // SetField sets the value of a field with the given name. It returns an error if
  27555. // the field is not defined in the schema, or if the type mismatched the field
  27556. // type.
  27557. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27558. switch name {
  27559. case usagedetail.FieldCreatedAt:
  27560. v, ok := value.(time.Time)
  27561. if !ok {
  27562. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27563. }
  27564. m.SetCreatedAt(v)
  27565. return nil
  27566. case usagedetail.FieldUpdatedAt:
  27567. v, ok := value.(time.Time)
  27568. if !ok {
  27569. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27570. }
  27571. m.SetUpdatedAt(v)
  27572. return nil
  27573. case usagedetail.FieldStatus:
  27574. v, ok := value.(uint8)
  27575. if !ok {
  27576. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27577. }
  27578. m.SetStatus(v)
  27579. return nil
  27580. case usagedetail.FieldType:
  27581. v, ok := value.(int)
  27582. if !ok {
  27583. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27584. }
  27585. m.SetType(v)
  27586. return nil
  27587. case usagedetail.FieldBotID:
  27588. v, ok := value.(string)
  27589. if !ok {
  27590. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27591. }
  27592. m.SetBotID(v)
  27593. return nil
  27594. case usagedetail.FieldReceiverID:
  27595. v, ok := value.(string)
  27596. if !ok {
  27597. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27598. }
  27599. m.SetReceiverID(v)
  27600. return nil
  27601. case usagedetail.FieldApp:
  27602. v, ok := value.(int)
  27603. if !ok {
  27604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27605. }
  27606. m.SetApp(v)
  27607. return nil
  27608. case usagedetail.FieldSessionID:
  27609. v, ok := value.(uint64)
  27610. if !ok {
  27611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27612. }
  27613. m.SetSessionID(v)
  27614. return nil
  27615. case usagedetail.FieldRequest:
  27616. v, ok := value.(string)
  27617. if !ok {
  27618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27619. }
  27620. m.SetRequest(v)
  27621. return nil
  27622. case usagedetail.FieldResponse:
  27623. v, ok := value.(string)
  27624. if !ok {
  27625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27626. }
  27627. m.SetResponse(v)
  27628. return nil
  27629. case usagedetail.FieldOriginalData:
  27630. v, ok := value.(custom_types.OriginalData)
  27631. if !ok {
  27632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27633. }
  27634. m.SetOriginalData(v)
  27635. return nil
  27636. case usagedetail.FieldTotalTokens:
  27637. v, ok := value.(uint64)
  27638. if !ok {
  27639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27640. }
  27641. m.SetTotalTokens(v)
  27642. return nil
  27643. case usagedetail.FieldPromptTokens:
  27644. v, ok := value.(uint64)
  27645. if !ok {
  27646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27647. }
  27648. m.SetPromptTokens(v)
  27649. return nil
  27650. case usagedetail.FieldCompletionTokens:
  27651. v, ok := value.(uint64)
  27652. if !ok {
  27653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27654. }
  27655. m.SetCompletionTokens(v)
  27656. return nil
  27657. case usagedetail.FieldOrganizationID:
  27658. v, ok := value.(uint64)
  27659. if !ok {
  27660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27661. }
  27662. m.SetOrganizationID(v)
  27663. return nil
  27664. }
  27665. return fmt.Errorf("unknown UsageDetail field %s", name)
  27666. }
  27667. // AddedFields returns all numeric fields that were incremented/decremented during
  27668. // this mutation.
  27669. func (m *UsageDetailMutation) AddedFields() []string {
  27670. var fields []string
  27671. if m.addstatus != nil {
  27672. fields = append(fields, usagedetail.FieldStatus)
  27673. }
  27674. if m.add_type != nil {
  27675. fields = append(fields, usagedetail.FieldType)
  27676. }
  27677. if m.addapp != nil {
  27678. fields = append(fields, usagedetail.FieldApp)
  27679. }
  27680. if m.addsession_id != nil {
  27681. fields = append(fields, usagedetail.FieldSessionID)
  27682. }
  27683. if m.addtotal_tokens != nil {
  27684. fields = append(fields, usagedetail.FieldTotalTokens)
  27685. }
  27686. if m.addprompt_tokens != nil {
  27687. fields = append(fields, usagedetail.FieldPromptTokens)
  27688. }
  27689. if m.addcompletion_tokens != nil {
  27690. fields = append(fields, usagedetail.FieldCompletionTokens)
  27691. }
  27692. if m.addorganization_id != nil {
  27693. fields = append(fields, usagedetail.FieldOrganizationID)
  27694. }
  27695. return fields
  27696. }
  27697. // AddedField returns the numeric value that was incremented/decremented on a field
  27698. // with the given name. The second boolean return value indicates that this field
  27699. // was not set, or was not defined in the schema.
  27700. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27701. switch name {
  27702. case usagedetail.FieldStatus:
  27703. return m.AddedStatus()
  27704. case usagedetail.FieldType:
  27705. return m.AddedType()
  27706. case usagedetail.FieldApp:
  27707. return m.AddedApp()
  27708. case usagedetail.FieldSessionID:
  27709. return m.AddedSessionID()
  27710. case usagedetail.FieldTotalTokens:
  27711. return m.AddedTotalTokens()
  27712. case usagedetail.FieldPromptTokens:
  27713. return m.AddedPromptTokens()
  27714. case usagedetail.FieldCompletionTokens:
  27715. return m.AddedCompletionTokens()
  27716. case usagedetail.FieldOrganizationID:
  27717. return m.AddedOrganizationID()
  27718. }
  27719. return nil, false
  27720. }
  27721. // AddField adds the value to the field with the given name. It returns an error if
  27722. // the field is not defined in the schema, or if the type mismatched the field
  27723. // type.
  27724. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27725. switch name {
  27726. case usagedetail.FieldStatus:
  27727. v, ok := value.(int8)
  27728. if !ok {
  27729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27730. }
  27731. m.AddStatus(v)
  27732. return nil
  27733. case usagedetail.FieldType:
  27734. v, ok := value.(int)
  27735. if !ok {
  27736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27737. }
  27738. m.AddType(v)
  27739. return nil
  27740. case usagedetail.FieldApp:
  27741. v, ok := value.(int)
  27742. if !ok {
  27743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27744. }
  27745. m.AddApp(v)
  27746. return nil
  27747. case usagedetail.FieldSessionID:
  27748. v, ok := value.(int64)
  27749. if !ok {
  27750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27751. }
  27752. m.AddSessionID(v)
  27753. return nil
  27754. case usagedetail.FieldTotalTokens:
  27755. v, ok := value.(int64)
  27756. if !ok {
  27757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27758. }
  27759. m.AddTotalTokens(v)
  27760. return nil
  27761. case usagedetail.FieldPromptTokens:
  27762. v, ok := value.(int64)
  27763. if !ok {
  27764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27765. }
  27766. m.AddPromptTokens(v)
  27767. return nil
  27768. case usagedetail.FieldCompletionTokens:
  27769. v, ok := value.(int64)
  27770. if !ok {
  27771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27772. }
  27773. m.AddCompletionTokens(v)
  27774. return nil
  27775. case usagedetail.FieldOrganizationID:
  27776. v, ok := value.(int64)
  27777. if !ok {
  27778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27779. }
  27780. m.AddOrganizationID(v)
  27781. return nil
  27782. }
  27783. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27784. }
  27785. // ClearedFields returns all nullable fields that were cleared during this
  27786. // mutation.
  27787. func (m *UsageDetailMutation) ClearedFields() []string {
  27788. var fields []string
  27789. if m.FieldCleared(usagedetail.FieldStatus) {
  27790. fields = append(fields, usagedetail.FieldStatus)
  27791. }
  27792. if m.FieldCleared(usagedetail.FieldType) {
  27793. fields = append(fields, usagedetail.FieldType)
  27794. }
  27795. if m.FieldCleared(usagedetail.FieldApp) {
  27796. fields = append(fields, usagedetail.FieldApp)
  27797. }
  27798. if m.FieldCleared(usagedetail.FieldSessionID) {
  27799. fields = append(fields, usagedetail.FieldSessionID)
  27800. }
  27801. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27802. fields = append(fields, usagedetail.FieldTotalTokens)
  27803. }
  27804. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27805. fields = append(fields, usagedetail.FieldPromptTokens)
  27806. }
  27807. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27808. fields = append(fields, usagedetail.FieldCompletionTokens)
  27809. }
  27810. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27811. fields = append(fields, usagedetail.FieldOrganizationID)
  27812. }
  27813. return fields
  27814. }
  27815. // FieldCleared returns a boolean indicating if a field with the given name was
  27816. // cleared in this mutation.
  27817. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27818. _, ok := m.clearedFields[name]
  27819. return ok
  27820. }
  27821. // ClearField clears the value of the field with the given name. It returns an
  27822. // error if the field is not defined in the schema.
  27823. func (m *UsageDetailMutation) ClearField(name string) error {
  27824. switch name {
  27825. case usagedetail.FieldStatus:
  27826. m.ClearStatus()
  27827. return nil
  27828. case usagedetail.FieldType:
  27829. m.ClearType()
  27830. return nil
  27831. case usagedetail.FieldApp:
  27832. m.ClearApp()
  27833. return nil
  27834. case usagedetail.FieldSessionID:
  27835. m.ClearSessionID()
  27836. return nil
  27837. case usagedetail.FieldTotalTokens:
  27838. m.ClearTotalTokens()
  27839. return nil
  27840. case usagedetail.FieldPromptTokens:
  27841. m.ClearPromptTokens()
  27842. return nil
  27843. case usagedetail.FieldCompletionTokens:
  27844. m.ClearCompletionTokens()
  27845. return nil
  27846. case usagedetail.FieldOrganizationID:
  27847. m.ClearOrganizationID()
  27848. return nil
  27849. }
  27850. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27851. }
  27852. // ResetField resets all changes in the mutation for the field with the given name.
  27853. // It returns an error if the field is not defined in the schema.
  27854. func (m *UsageDetailMutation) ResetField(name string) error {
  27855. switch name {
  27856. case usagedetail.FieldCreatedAt:
  27857. m.ResetCreatedAt()
  27858. return nil
  27859. case usagedetail.FieldUpdatedAt:
  27860. m.ResetUpdatedAt()
  27861. return nil
  27862. case usagedetail.FieldStatus:
  27863. m.ResetStatus()
  27864. return nil
  27865. case usagedetail.FieldType:
  27866. m.ResetType()
  27867. return nil
  27868. case usagedetail.FieldBotID:
  27869. m.ResetBotID()
  27870. return nil
  27871. case usagedetail.FieldReceiverID:
  27872. m.ResetReceiverID()
  27873. return nil
  27874. case usagedetail.FieldApp:
  27875. m.ResetApp()
  27876. return nil
  27877. case usagedetail.FieldSessionID:
  27878. m.ResetSessionID()
  27879. return nil
  27880. case usagedetail.FieldRequest:
  27881. m.ResetRequest()
  27882. return nil
  27883. case usagedetail.FieldResponse:
  27884. m.ResetResponse()
  27885. return nil
  27886. case usagedetail.FieldOriginalData:
  27887. m.ResetOriginalData()
  27888. return nil
  27889. case usagedetail.FieldTotalTokens:
  27890. m.ResetTotalTokens()
  27891. return nil
  27892. case usagedetail.FieldPromptTokens:
  27893. m.ResetPromptTokens()
  27894. return nil
  27895. case usagedetail.FieldCompletionTokens:
  27896. m.ResetCompletionTokens()
  27897. return nil
  27898. case usagedetail.FieldOrganizationID:
  27899. m.ResetOrganizationID()
  27900. return nil
  27901. }
  27902. return fmt.Errorf("unknown UsageDetail field %s", name)
  27903. }
  27904. // AddedEdges returns all edge names that were set/added in this mutation.
  27905. func (m *UsageDetailMutation) AddedEdges() []string {
  27906. edges := make([]string, 0, 0)
  27907. return edges
  27908. }
  27909. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27910. // name in this mutation.
  27911. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  27912. return nil
  27913. }
  27914. // RemovedEdges returns all edge names that were removed in this mutation.
  27915. func (m *UsageDetailMutation) RemovedEdges() []string {
  27916. edges := make([]string, 0, 0)
  27917. return edges
  27918. }
  27919. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27920. // the given name in this mutation.
  27921. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  27922. return nil
  27923. }
  27924. // ClearedEdges returns all edge names that were cleared in this mutation.
  27925. func (m *UsageDetailMutation) ClearedEdges() []string {
  27926. edges := make([]string, 0, 0)
  27927. return edges
  27928. }
  27929. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27930. // was cleared in this mutation.
  27931. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  27932. return false
  27933. }
  27934. // ClearEdge clears the value of the edge with the given name. It returns an error
  27935. // if that edge is not defined in the schema.
  27936. func (m *UsageDetailMutation) ClearEdge(name string) error {
  27937. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  27938. }
  27939. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27940. // It returns an error if the edge is not defined in the schema.
  27941. func (m *UsageDetailMutation) ResetEdge(name string) error {
  27942. return fmt.Errorf("unknown UsageDetail edge %s", name)
  27943. }
  27944. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  27945. type UsageStatisticDayMutation struct {
  27946. config
  27947. op Op
  27948. typ string
  27949. id *uint64
  27950. created_at *time.Time
  27951. updated_at *time.Time
  27952. status *uint8
  27953. addstatus *int8
  27954. deleted_at *time.Time
  27955. addtime *uint64
  27956. addaddtime *int64
  27957. _type *int
  27958. add_type *int
  27959. bot_id *string
  27960. organization_id *uint64
  27961. addorganization_id *int64
  27962. ai_response *uint64
  27963. addai_response *int64
  27964. sop_run *uint64
  27965. addsop_run *int64
  27966. total_friend *uint64
  27967. addtotal_friend *int64
  27968. total_group *uint64
  27969. addtotal_group *int64
  27970. account_balance *uint64
  27971. addaccount_balance *int64
  27972. consume_token *uint64
  27973. addconsume_token *int64
  27974. active_user *uint64
  27975. addactive_user *int64
  27976. new_user *int64
  27977. addnew_user *int64
  27978. label_dist *[]custom_types.LabelDist
  27979. appendlabel_dist []custom_types.LabelDist
  27980. clearedFields map[string]struct{}
  27981. done bool
  27982. oldValue func(context.Context) (*UsageStatisticDay, error)
  27983. predicates []predicate.UsageStatisticDay
  27984. }
  27985. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  27986. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  27987. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  27988. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  27989. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  27990. m := &UsageStatisticDayMutation{
  27991. config: c,
  27992. op: op,
  27993. typ: TypeUsageStatisticDay,
  27994. clearedFields: make(map[string]struct{}),
  27995. }
  27996. for _, opt := range opts {
  27997. opt(m)
  27998. }
  27999. return m
  28000. }
  28001. // withUsageStatisticDayID sets the ID field of the mutation.
  28002. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28003. return func(m *UsageStatisticDayMutation) {
  28004. var (
  28005. err error
  28006. once sync.Once
  28007. value *UsageStatisticDay
  28008. )
  28009. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28010. once.Do(func() {
  28011. if m.done {
  28012. err = errors.New("querying old values post mutation is not allowed")
  28013. } else {
  28014. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28015. }
  28016. })
  28017. return value, err
  28018. }
  28019. m.id = &id
  28020. }
  28021. }
  28022. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28023. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28024. return func(m *UsageStatisticDayMutation) {
  28025. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28026. return node, nil
  28027. }
  28028. m.id = &node.ID
  28029. }
  28030. }
  28031. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28032. // executed in a transaction (ent.Tx), a transactional client is returned.
  28033. func (m UsageStatisticDayMutation) Client() *Client {
  28034. client := &Client{config: m.config}
  28035. client.init()
  28036. return client
  28037. }
  28038. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28039. // it returns an error otherwise.
  28040. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28041. if _, ok := m.driver.(*txDriver); !ok {
  28042. return nil, errors.New("ent: mutation is not running in a transaction")
  28043. }
  28044. tx := &Tx{config: m.config}
  28045. tx.init()
  28046. return tx, nil
  28047. }
  28048. // SetID sets the value of the id field. Note that this
  28049. // operation is only accepted on creation of UsageStatisticDay entities.
  28050. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28051. m.id = &id
  28052. }
  28053. // ID returns the ID value in the mutation. Note that the ID is only available
  28054. // if it was provided to the builder or after it was returned from the database.
  28055. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28056. if m.id == nil {
  28057. return
  28058. }
  28059. return *m.id, true
  28060. }
  28061. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28062. // That means, if the mutation is applied within a transaction with an isolation level such
  28063. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28064. // or updated by the mutation.
  28065. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28066. switch {
  28067. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28068. id, exists := m.ID()
  28069. if exists {
  28070. return []uint64{id}, nil
  28071. }
  28072. fallthrough
  28073. case m.op.Is(OpUpdate | OpDelete):
  28074. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28075. default:
  28076. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28077. }
  28078. }
  28079. // SetCreatedAt sets the "created_at" field.
  28080. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28081. m.created_at = &t
  28082. }
  28083. // CreatedAt returns the value of the "created_at" field in the mutation.
  28084. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28085. v := m.created_at
  28086. if v == nil {
  28087. return
  28088. }
  28089. return *v, true
  28090. }
  28091. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28092. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28093. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28094. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28095. if !m.op.Is(OpUpdateOne) {
  28096. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28097. }
  28098. if m.id == nil || m.oldValue == nil {
  28099. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28100. }
  28101. oldValue, err := m.oldValue(ctx)
  28102. if err != nil {
  28103. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28104. }
  28105. return oldValue.CreatedAt, nil
  28106. }
  28107. // ResetCreatedAt resets all changes to the "created_at" field.
  28108. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28109. m.created_at = nil
  28110. }
  28111. // SetUpdatedAt sets the "updated_at" field.
  28112. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28113. m.updated_at = &t
  28114. }
  28115. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28116. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28117. v := m.updated_at
  28118. if v == nil {
  28119. return
  28120. }
  28121. return *v, true
  28122. }
  28123. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28124. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28126. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28127. if !m.op.Is(OpUpdateOne) {
  28128. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28129. }
  28130. if m.id == nil || m.oldValue == nil {
  28131. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28132. }
  28133. oldValue, err := m.oldValue(ctx)
  28134. if err != nil {
  28135. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28136. }
  28137. return oldValue.UpdatedAt, nil
  28138. }
  28139. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28140. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28141. m.updated_at = nil
  28142. }
  28143. // SetStatus sets the "status" field.
  28144. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28145. m.status = &u
  28146. m.addstatus = nil
  28147. }
  28148. // Status returns the value of the "status" field in the mutation.
  28149. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28150. v := m.status
  28151. if v == nil {
  28152. return
  28153. }
  28154. return *v, true
  28155. }
  28156. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28157. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28159. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28160. if !m.op.Is(OpUpdateOne) {
  28161. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28162. }
  28163. if m.id == nil || m.oldValue == nil {
  28164. return v, errors.New("OldStatus requires an ID field in the mutation")
  28165. }
  28166. oldValue, err := m.oldValue(ctx)
  28167. if err != nil {
  28168. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28169. }
  28170. return oldValue.Status, nil
  28171. }
  28172. // AddStatus adds u to the "status" field.
  28173. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28174. if m.addstatus != nil {
  28175. *m.addstatus += u
  28176. } else {
  28177. m.addstatus = &u
  28178. }
  28179. }
  28180. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28181. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28182. v := m.addstatus
  28183. if v == nil {
  28184. return
  28185. }
  28186. return *v, true
  28187. }
  28188. // ClearStatus clears the value of the "status" field.
  28189. func (m *UsageStatisticDayMutation) ClearStatus() {
  28190. m.status = nil
  28191. m.addstatus = nil
  28192. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28193. }
  28194. // StatusCleared returns if the "status" field was cleared in this mutation.
  28195. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28196. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28197. return ok
  28198. }
  28199. // ResetStatus resets all changes to the "status" field.
  28200. func (m *UsageStatisticDayMutation) ResetStatus() {
  28201. m.status = nil
  28202. m.addstatus = nil
  28203. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28204. }
  28205. // SetDeletedAt sets the "deleted_at" field.
  28206. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28207. m.deleted_at = &t
  28208. }
  28209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28210. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28211. v := m.deleted_at
  28212. if v == nil {
  28213. return
  28214. }
  28215. return *v, true
  28216. }
  28217. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28218. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28220. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28221. if !m.op.Is(OpUpdateOne) {
  28222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28223. }
  28224. if m.id == nil || m.oldValue == nil {
  28225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28226. }
  28227. oldValue, err := m.oldValue(ctx)
  28228. if err != nil {
  28229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28230. }
  28231. return oldValue.DeletedAt, nil
  28232. }
  28233. // ClearDeletedAt clears the value of the "deleted_at" field.
  28234. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28235. m.deleted_at = nil
  28236. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28237. }
  28238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28239. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28240. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28241. return ok
  28242. }
  28243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28244. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28245. m.deleted_at = nil
  28246. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28247. }
  28248. // SetAddtime sets the "addtime" field.
  28249. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28250. m.addtime = &u
  28251. m.addaddtime = nil
  28252. }
  28253. // Addtime returns the value of the "addtime" field in the mutation.
  28254. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28255. v := m.addtime
  28256. if v == nil {
  28257. return
  28258. }
  28259. return *v, true
  28260. }
  28261. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28262. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28264. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28265. if !m.op.Is(OpUpdateOne) {
  28266. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28267. }
  28268. if m.id == nil || m.oldValue == nil {
  28269. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28270. }
  28271. oldValue, err := m.oldValue(ctx)
  28272. if err != nil {
  28273. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28274. }
  28275. return oldValue.Addtime, nil
  28276. }
  28277. // AddAddtime adds u to the "addtime" field.
  28278. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28279. if m.addaddtime != nil {
  28280. *m.addaddtime += u
  28281. } else {
  28282. m.addaddtime = &u
  28283. }
  28284. }
  28285. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28286. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28287. v := m.addaddtime
  28288. if v == nil {
  28289. return
  28290. }
  28291. return *v, true
  28292. }
  28293. // ResetAddtime resets all changes to the "addtime" field.
  28294. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28295. m.addtime = nil
  28296. m.addaddtime = nil
  28297. }
  28298. // SetType sets the "type" field.
  28299. func (m *UsageStatisticDayMutation) SetType(i int) {
  28300. m._type = &i
  28301. m.add_type = nil
  28302. }
  28303. // GetType returns the value of the "type" field in the mutation.
  28304. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28305. v := m._type
  28306. if v == nil {
  28307. return
  28308. }
  28309. return *v, true
  28310. }
  28311. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28312. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28314. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28315. if !m.op.Is(OpUpdateOne) {
  28316. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28317. }
  28318. if m.id == nil || m.oldValue == nil {
  28319. return v, errors.New("OldType requires an ID field in the mutation")
  28320. }
  28321. oldValue, err := m.oldValue(ctx)
  28322. if err != nil {
  28323. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28324. }
  28325. return oldValue.Type, nil
  28326. }
  28327. // AddType adds i to the "type" field.
  28328. func (m *UsageStatisticDayMutation) AddType(i int) {
  28329. if m.add_type != nil {
  28330. *m.add_type += i
  28331. } else {
  28332. m.add_type = &i
  28333. }
  28334. }
  28335. // AddedType returns the value that was added to the "type" field in this mutation.
  28336. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28337. v := m.add_type
  28338. if v == nil {
  28339. return
  28340. }
  28341. return *v, true
  28342. }
  28343. // ResetType resets all changes to the "type" field.
  28344. func (m *UsageStatisticDayMutation) ResetType() {
  28345. m._type = nil
  28346. m.add_type = nil
  28347. }
  28348. // SetBotID sets the "bot_id" field.
  28349. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28350. m.bot_id = &s
  28351. }
  28352. // BotID returns the value of the "bot_id" field in the mutation.
  28353. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28354. v := m.bot_id
  28355. if v == nil {
  28356. return
  28357. }
  28358. return *v, true
  28359. }
  28360. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28361. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28363. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28364. if !m.op.Is(OpUpdateOne) {
  28365. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28366. }
  28367. if m.id == nil || m.oldValue == nil {
  28368. return v, errors.New("OldBotID requires an ID field in the mutation")
  28369. }
  28370. oldValue, err := m.oldValue(ctx)
  28371. if err != nil {
  28372. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28373. }
  28374. return oldValue.BotID, nil
  28375. }
  28376. // ClearBotID clears the value of the "bot_id" field.
  28377. func (m *UsageStatisticDayMutation) ClearBotID() {
  28378. m.bot_id = nil
  28379. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28380. }
  28381. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28382. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28383. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28384. return ok
  28385. }
  28386. // ResetBotID resets all changes to the "bot_id" field.
  28387. func (m *UsageStatisticDayMutation) ResetBotID() {
  28388. m.bot_id = nil
  28389. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28390. }
  28391. // SetOrganizationID sets the "organization_id" field.
  28392. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28393. m.organization_id = &u
  28394. m.addorganization_id = nil
  28395. }
  28396. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28397. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28398. v := m.organization_id
  28399. if v == nil {
  28400. return
  28401. }
  28402. return *v, true
  28403. }
  28404. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28405. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28406. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28407. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28408. if !m.op.Is(OpUpdateOne) {
  28409. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28410. }
  28411. if m.id == nil || m.oldValue == nil {
  28412. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28413. }
  28414. oldValue, err := m.oldValue(ctx)
  28415. if err != nil {
  28416. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28417. }
  28418. return oldValue.OrganizationID, nil
  28419. }
  28420. // AddOrganizationID adds u to the "organization_id" field.
  28421. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28422. if m.addorganization_id != nil {
  28423. *m.addorganization_id += u
  28424. } else {
  28425. m.addorganization_id = &u
  28426. }
  28427. }
  28428. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28429. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28430. v := m.addorganization_id
  28431. if v == nil {
  28432. return
  28433. }
  28434. return *v, true
  28435. }
  28436. // ClearOrganizationID clears the value of the "organization_id" field.
  28437. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28438. m.organization_id = nil
  28439. m.addorganization_id = nil
  28440. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28441. }
  28442. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28443. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28444. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28445. return ok
  28446. }
  28447. // ResetOrganizationID resets all changes to the "organization_id" field.
  28448. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28449. m.organization_id = nil
  28450. m.addorganization_id = nil
  28451. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28452. }
  28453. // SetAiResponse sets the "ai_response" field.
  28454. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28455. m.ai_response = &u
  28456. m.addai_response = nil
  28457. }
  28458. // AiResponse returns the value of the "ai_response" field in the mutation.
  28459. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28460. v := m.ai_response
  28461. if v == nil {
  28462. return
  28463. }
  28464. return *v, true
  28465. }
  28466. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28467. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28468. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28469. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28470. if !m.op.Is(OpUpdateOne) {
  28471. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28472. }
  28473. if m.id == nil || m.oldValue == nil {
  28474. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28475. }
  28476. oldValue, err := m.oldValue(ctx)
  28477. if err != nil {
  28478. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28479. }
  28480. return oldValue.AiResponse, nil
  28481. }
  28482. // AddAiResponse adds u to the "ai_response" field.
  28483. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28484. if m.addai_response != nil {
  28485. *m.addai_response += u
  28486. } else {
  28487. m.addai_response = &u
  28488. }
  28489. }
  28490. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28491. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28492. v := m.addai_response
  28493. if v == nil {
  28494. return
  28495. }
  28496. return *v, true
  28497. }
  28498. // ResetAiResponse resets all changes to the "ai_response" field.
  28499. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28500. m.ai_response = nil
  28501. m.addai_response = nil
  28502. }
  28503. // SetSopRun sets the "sop_run" field.
  28504. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28505. m.sop_run = &u
  28506. m.addsop_run = nil
  28507. }
  28508. // SopRun returns the value of the "sop_run" field in the mutation.
  28509. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28510. v := m.sop_run
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldSopRun returns the old "sop_run" 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) OldSopRun(ctx context.Context) (v uint64, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  28529. }
  28530. return oldValue.SopRun, nil
  28531. }
  28532. // AddSopRun adds u to the "sop_run" field.
  28533. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28534. if m.addsop_run != nil {
  28535. *m.addsop_run += u
  28536. } else {
  28537. m.addsop_run = &u
  28538. }
  28539. }
  28540. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28541. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28542. v := m.addsop_run
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ResetSopRun resets all changes to the "sop_run" field.
  28549. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28550. m.sop_run = nil
  28551. m.addsop_run = nil
  28552. }
  28553. // SetTotalFriend sets the "total_friend" field.
  28554. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28555. m.total_friend = &u
  28556. m.addtotal_friend = nil
  28557. }
  28558. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28559. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28560. v := m.total_friend
  28561. if v == nil {
  28562. return
  28563. }
  28564. return *v, true
  28565. }
  28566. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28567. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28568. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28569. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28570. if !m.op.Is(OpUpdateOne) {
  28571. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28572. }
  28573. if m.id == nil || m.oldValue == nil {
  28574. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28575. }
  28576. oldValue, err := m.oldValue(ctx)
  28577. if err != nil {
  28578. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28579. }
  28580. return oldValue.TotalFriend, nil
  28581. }
  28582. // AddTotalFriend adds u to the "total_friend" field.
  28583. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28584. if m.addtotal_friend != nil {
  28585. *m.addtotal_friend += u
  28586. } else {
  28587. m.addtotal_friend = &u
  28588. }
  28589. }
  28590. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28591. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28592. v := m.addtotal_friend
  28593. if v == nil {
  28594. return
  28595. }
  28596. return *v, true
  28597. }
  28598. // ResetTotalFriend resets all changes to the "total_friend" field.
  28599. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28600. m.total_friend = nil
  28601. m.addtotal_friend = nil
  28602. }
  28603. // SetTotalGroup sets the "total_group" field.
  28604. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28605. m.total_group = &u
  28606. m.addtotal_group = nil
  28607. }
  28608. // TotalGroup returns the value of the "total_group" field in the mutation.
  28609. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28610. v := m.total_group
  28611. if v == nil {
  28612. return
  28613. }
  28614. return *v, true
  28615. }
  28616. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28617. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28618. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28619. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28620. if !m.op.Is(OpUpdateOne) {
  28621. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28622. }
  28623. if m.id == nil || m.oldValue == nil {
  28624. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28625. }
  28626. oldValue, err := m.oldValue(ctx)
  28627. if err != nil {
  28628. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28629. }
  28630. return oldValue.TotalGroup, nil
  28631. }
  28632. // AddTotalGroup adds u to the "total_group" field.
  28633. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28634. if m.addtotal_group != nil {
  28635. *m.addtotal_group += u
  28636. } else {
  28637. m.addtotal_group = &u
  28638. }
  28639. }
  28640. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28641. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28642. v := m.addtotal_group
  28643. if v == nil {
  28644. return
  28645. }
  28646. return *v, true
  28647. }
  28648. // ResetTotalGroup resets all changes to the "total_group" field.
  28649. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28650. m.total_group = nil
  28651. m.addtotal_group = nil
  28652. }
  28653. // SetAccountBalance sets the "account_balance" field.
  28654. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28655. m.account_balance = &u
  28656. m.addaccount_balance = nil
  28657. }
  28658. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28659. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28660. v := m.account_balance
  28661. if v == nil {
  28662. return
  28663. }
  28664. return *v, true
  28665. }
  28666. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28667. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28668. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28669. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28670. if !m.op.Is(OpUpdateOne) {
  28671. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28672. }
  28673. if m.id == nil || m.oldValue == nil {
  28674. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28675. }
  28676. oldValue, err := m.oldValue(ctx)
  28677. if err != nil {
  28678. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28679. }
  28680. return oldValue.AccountBalance, nil
  28681. }
  28682. // AddAccountBalance adds u to the "account_balance" field.
  28683. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28684. if m.addaccount_balance != nil {
  28685. *m.addaccount_balance += u
  28686. } else {
  28687. m.addaccount_balance = &u
  28688. }
  28689. }
  28690. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28691. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28692. v := m.addaccount_balance
  28693. if v == nil {
  28694. return
  28695. }
  28696. return *v, true
  28697. }
  28698. // ResetAccountBalance resets all changes to the "account_balance" field.
  28699. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28700. m.account_balance = nil
  28701. m.addaccount_balance = nil
  28702. }
  28703. // SetConsumeToken sets the "consume_token" field.
  28704. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28705. m.consume_token = &u
  28706. m.addconsume_token = nil
  28707. }
  28708. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28709. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28710. v := m.consume_token
  28711. if v == nil {
  28712. return
  28713. }
  28714. return *v, true
  28715. }
  28716. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28717. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28718. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28719. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28720. if !m.op.Is(OpUpdateOne) {
  28721. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28722. }
  28723. if m.id == nil || m.oldValue == nil {
  28724. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28725. }
  28726. oldValue, err := m.oldValue(ctx)
  28727. if err != nil {
  28728. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28729. }
  28730. return oldValue.ConsumeToken, nil
  28731. }
  28732. // AddConsumeToken adds u to the "consume_token" field.
  28733. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28734. if m.addconsume_token != nil {
  28735. *m.addconsume_token += u
  28736. } else {
  28737. m.addconsume_token = &u
  28738. }
  28739. }
  28740. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28741. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28742. v := m.addconsume_token
  28743. if v == nil {
  28744. return
  28745. }
  28746. return *v, true
  28747. }
  28748. // ResetConsumeToken resets all changes to the "consume_token" field.
  28749. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28750. m.consume_token = nil
  28751. m.addconsume_token = nil
  28752. }
  28753. // SetActiveUser sets the "active_user" field.
  28754. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28755. m.active_user = &u
  28756. m.addactive_user = nil
  28757. }
  28758. // ActiveUser returns the value of the "active_user" field in the mutation.
  28759. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28760. v := m.active_user
  28761. if v == nil {
  28762. return
  28763. }
  28764. return *v, true
  28765. }
  28766. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28767. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28768. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28769. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28770. if !m.op.Is(OpUpdateOne) {
  28771. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28772. }
  28773. if m.id == nil || m.oldValue == nil {
  28774. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28775. }
  28776. oldValue, err := m.oldValue(ctx)
  28777. if err != nil {
  28778. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28779. }
  28780. return oldValue.ActiveUser, nil
  28781. }
  28782. // AddActiveUser adds u to the "active_user" field.
  28783. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28784. if m.addactive_user != nil {
  28785. *m.addactive_user += u
  28786. } else {
  28787. m.addactive_user = &u
  28788. }
  28789. }
  28790. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28791. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28792. v := m.addactive_user
  28793. if v == nil {
  28794. return
  28795. }
  28796. return *v, true
  28797. }
  28798. // ResetActiveUser resets all changes to the "active_user" field.
  28799. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28800. m.active_user = nil
  28801. m.addactive_user = nil
  28802. }
  28803. // SetNewUser sets the "new_user" field.
  28804. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28805. m.new_user = &i
  28806. m.addnew_user = nil
  28807. }
  28808. // NewUser returns the value of the "new_user" field in the mutation.
  28809. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28810. v := m.new_user
  28811. if v == nil {
  28812. return
  28813. }
  28814. return *v, true
  28815. }
  28816. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28817. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28819. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28820. if !m.op.Is(OpUpdateOne) {
  28821. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28822. }
  28823. if m.id == nil || m.oldValue == nil {
  28824. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28825. }
  28826. oldValue, err := m.oldValue(ctx)
  28827. if err != nil {
  28828. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28829. }
  28830. return oldValue.NewUser, nil
  28831. }
  28832. // AddNewUser adds i to the "new_user" field.
  28833. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28834. if m.addnew_user != nil {
  28835. *m.addnew_user += i
  28836. } else {
  28837. m.addnew_user = &i
  28838. }
  28839. }
  28840. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28841. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28842. v := m.addnew_user
  28843. if v == nil {
  28844. return
  28845. }
  28846. return *v, true
  28847. }
  28848. // ResetNewUser resets all changes to the "new_user" field.
  28849. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28850. m.new_user = nil
  28851. m.addnew_user = nil
  28852. }
  28853. // SetLabelDist sets the "label_dist" field.
  28854. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28855. m.label_dist = &ctd
  28856. m.appendlabel_dist = nil
  28857. }
  28858. // LabelDist returns the value of the "label_dist" field in the mutation.
  28859. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28860. v := m.label_dist
  28861. if v == nil {
  28862. return
  28863. }
  28864. return *v, true
  28865. }
  28866. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28867. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28869. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28870. if !m.op.Is(OpUpdateOne) {
  28871. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28872. }
  28873. if m.id == nil || m.oldValue == nil {
  28874. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28875. }
  28876. oldValue, err := m.oldValue(ctx)
  28877. if err != nil {
  28878. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28879. }
  28880. return oldValue.LabelDist, nil
  28881. }
  28882. // AppendLabelDist adds ctd to the "label_dist" field.
  28883. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28884. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28885. }
  28886. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28887. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28888. if len(m.appendlabel_dist) == 0 {
  28889. return nil, false
  28890. }
  28891. return m.appendlabel_dist, true
  28892. }
  28893. // ResetLabelDist resets all changes to the "label_dist" field.
  28894. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  28895. m.label_dist = nil
  28896. m.appendlabel_dist = nil
  28897. }
  28898. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  28899. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  28900. m.predicates = append(m.predicates, ps...)
  28901. }
  28902. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  28903. // users can use type-assertion to append predicates that do not depend on any generated package.
  28904. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  28905. p := make([]predicate.UsageStatisticDay, len(ps))
  28906. for i := range ps {
  28907. p[i] = ps[i]
  28908. }
  28909. m.Where(p...)
  28910. }
  28911. // Op returns the operation name.
  28912. func (m *UsageStatisticDayMutation) Op() Op {
  28913. return m.op
  28914. }
  28915. // SetOp allows setting the mutation operation.
  28916. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  28917. m.op = op
  28918. }
  28919. // Type returns the node type of this mutation (UsageStatisticDay).
  28920. func (m *UsageStatisticDayMutation) Type() string {
  28921. return m.typ
  28922. }
  28923. // Fields returns all fields that were changed during this mutation. Note that in
  28924. // order to get all numeric fields that were incremented/decremented, call
  28925. // AddedFields().
  28926. func (m *UsageStatisticDayMutation) Fields() []string {
  28927. fields := make([]string, 0, 17)
  28928. if m.created_at != nil {
  28929. fields = append(fields, usagestatisticday.FieldCreatedAt)
  28930. }
  28931. if m.updated_at != nil {
  28932. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  28933. }
  28934. if m.status != nil {
  28935. fields = append(fields, usagestatisticday.FieldStatus)
  28936. }
  28937. if m.deleted_at != nil {
  28938. fields = append(fields, usagestatisticday.FieldDeletedAt)
  28939. }
  28940. if m.addtime != nil {
  28941. fields = append(fields, usagestatisticday.FieldAddtime)
  28942. }
  28943. if m._type != nil {
  28944. fields = append(fields, usagestatisticday.FieldType)
  28945. }
  28946. if m.bot_id != nil {
  28947. fields = append(fields, usagestatisticday.FieldBotID)
  28948. }
  28949. if m.organization_id != nil {
  28950. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28951. }
  28952. if m.ai_response != nil {
  28953. fields = append(fields, usagestatisticday.FieldAiResponse)
  28954. }
  28955. if m.sop_run != nil {
  28956. fields = append(fields, usagestatisticday.FieldSopRun)
  28957. }
  28958. if m.total_friend != nil {
  28959. fields = append(fields, usagestatisticday.FieldTotalFriend)
  28960. }
  28961. if m.total_group != nil {
  28962. fields = append(fields, usagestatisticday.FieldTotalGroup)
  28963. }
  28964. if m.account_balance != nil {
  28965. fields = append(fields, usagestatisticday.FieldAccountBalance)
  28966. }
  28967. if m.consume_token != nil {
  28968. fields = append(fields, usagestatisticday.FieldConsumeToken)
  28969. }
  28970. if m.active_user != nil {
  28971. fields = append(fields, usagestatisticday.FieldActiveUser)
  28972. }
  28973. if m.new_user != nil {
  28974. fields = append(fields, usagestatisticday.FieldNewUser)
  28975. }
  28976. if m.label_dist != nil {
  28977. fields = append(fields, usagestatisticday.FieldLabelDist)
  28978. }
  28979. return fields
  28980. }
  28981. // Field returns the value of a field with the given name. The second boolean
  28982. // return value indicates that this field was not set, or was not defined in the
  28983. // schema.
  28984. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  28985. switch name {
  28986. case usagestatisticday.FieldCreatedAt:
  28987. return m.CreatedAt()
  28988. case usagestatisticday.FieldUpdatedAt:
  28989. return m.UpdatedAt()
  28990. case usagestatisticday.FieldStatus:
  28991. return m.Status()
  28992. case usagestatisticday.FieldDeletedAt:
  28993. return m.DeletedAt()
  28994. case usagestatisticday.FieldAddtime:
  28995. return m.Addtime()
  28996. case usagestatisticday.FieldType:
  28997. return m.GetType()
  28998. case usagestatisticday.FieldBotID:
  28999. return m.BotID()
  29000. case usagestatisticday.FieldOrganizationID:
  29001. return m.OrganizationID()
  29002. case usagestatisticday.FieldAiResponse:
  29003. return m.AiResponse()
  29004. case usagestatisticday.FieldSopRun:
  29005. return m.SopRun()
  29006. case usagestatisticday.FieldTotalFriend:
  29007. return m.TotalFriend()
  29008. case usagestatisticday.FieldTotalGroup:
  29009. return m.TotalGroup()
  29010. case usagestatisticday.FieldAccountBalance:
  29011. return m.AccountBalance()
  29012. case usagestatisticday.FieldConsumeToken:
  29013. return m.ConsumeToken()
  29014. case usagestatisticday.FieldActiveUser:
  29015. return m.ActiveUser()
  29016. case usagestatisticday.FieldNewUser:
  29017. return m.NewUser()
  29018. case usagestatisticday.FieldLabelDist:
  29019. return m.LabelDist()
  29020. }
  29021. return nil, false
  29022. }
  29023. // OldField returns the old value of the field from the database. An error is
  29024. // returned if the mutation operation is not UpdateOne, or the query to the
  29025. // database failed.
  29026. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29027. switch name {
  29028. case usagestatisticday.FieldCreatedAt:
  29029. return m.OldCreatedAt(ctx)
  29030. case usagestatisticday.FieldUpdatedAt:
  29031. return m.OldUpdatedAt(ctx)
  29032. case usagestatisticday.FieldStatus:
  29033. return m.OldStatus(ctx)
  29034. case usagestatisticday.FieldDeletedAt:
  29035. return m.OldDeletedAt(ctx)
  29036. case usagestatisticday.FieldAddtime:
  29037. return m.OldAddtime(ctx)
  29038. case usagestatisticday.FieldType:
  29039. return m.OldType(ctx)
  29040. case usagestatisticday.FieldBotID:
  29041. return m.OldBotID(ctx)
  29042. case usagestatisticday.FieldOrganizationID:
  29043. return m.OldOrganizationID(ctx)
  29044. case usagestatisticday.FieldAiResponse:
  29045. return m.OldAiResponse(ctx)
  29046. case usagestatisticday.FieldSopRun:
  29047. return m.OldSopRun(ctx)
  29048. case usagestatisticday.FieldTotalFriend:
  29049. return m.OldTotalFriend(ctx)
  29050. case usagestatisticday.FieldTotalGroup:
  29051. return m.OldTotalGroup(ctx)
  29052. case usagestatisticday.FieldAccountBalance:
  29053. return m.OldAccountBalance(ctx)
  29054. case usagestatisticday.FieldConsumeToken:
  29055. return m.OldConsumeToken(ctx)
  29056. case usagestatisticday.FieldActiveUser:
  29057. return m.OldActiveUser(ctx)
  29058. case usagestatisticday.FieldNewUser:
  29059. return m.OldNewUser(ctx)
  29060. case usagestatisticday.FieldLabelDist:
  29061. return m.OldLabelDist(ctx)
  29062. }
  29063. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29064. }
  29065. // SetField sets the value of a field with the given name. It returns an error if
  29066. // the field is not defined in the schema, or if the type mismatched the field
  29067. // type.
  29068. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29069. switch name {
  29070. case usagestatisticday.FieldCreatedAt:
  29071. v, ok := value.(time.Time)
  29072. if !ok {
  29073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29074. }
  29075. m.SetCreatedAt(v)
  29076. return nil
  29077. case usagestatisticday.FieldUpdatedAt:
  29078. v, ok := value.(time.Time)
  29079. if !ok {
  29080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29081. }
  29082. m.SetUpdatedAt(v)
  29083. return nil
  29084. case usagestatisticday.FieldStatus:
  29085. v, ok := value.(uint8)
  29086. if !ok {
  29087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29088. }
  29089. m.SetStatus(v)
  29090. return nil
  29091. case usagestatisticday.FieldDeletedAt:
  29092. v, ok := value.(time.Time)
  29093. if !ok {
  29094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29095. }
  29096. m.SetDeletedAt(v)
  29097. return nil
  29098. case usagestatisticday.FieldAddtime:
  29099. v, ok := value.(uint64)
  29100. if !ok {
  29101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29102. }
  29103. m.SetAddtime(v)
  29104. return nil
  29105. case usagestatisticday.FieldType:
  29106. v, ok := value.(int)
  29107. if !ok {
  29108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29109. }
  29110. m.SetType(v)
  29111. return nil
  29112. case usagestatisticday.FieldBotID:
  29113. v, ok := value.(string)
  29114. if !ok {
  29115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29116. }
  29117. m.SetBotID(v)
  29118. return nil
  29119. case usagestatisticday.FieldOrganizationID:
  29120. v, ok := value.(uint64)
  29121. if !ok {
  29122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29123. }
  29124. m.SetOrganizationID(v)
  29125. return nil
  29126. case usagestatisticday.FieldAiResponse:
  29127. v, ok := value.(uint64)
  29128. if !ok {
  29129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29130. }
  29131. m.SetAiResponse(v)
  29132. return nil
  29133. case usagestatisticday.FieldSopRun:
  29134. v, ok := value.(uint64)
  29135. if !ok {
  29136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29137. }
  29138. m.SetSopRun(v)
  29139. return nil
  29140. case usagestatisticday.FieldTotalFriend:
  29141. v, ok := value.(uint64)
  29142. if !ok {
  29143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29144. }
  29145. m.SetTotalFriend(v)
  29146. return nil
  29147. case usagestatisticday.FieldTotalGroup:
  29148. v, ok := value.(uint64)
  29149. if !ok {
  29150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29151. }
  29152. m.SetTotalGroup(v)
  29153. return nil
  29154. case usagestatisticday.FieldAccountBalance:
  29155. v, ok := value.(uint64)
  29156. if !ok {
  29157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29158. }
  29159. m.SetAccountBalance(v)
  29160. return nil
  29161. case usagestatisticday.FieldConsumeToken:
  29162. v, ok := value.(uint64)
  29163. if !ok {
  29164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29165. }
  29166. m.SetConsumeToken(v)
  29167. return nil
  29168. case usagestatisticday.FieldActiveUser:
  29169. v, ok := value.(uint64)
  29170. if !ok {
  29171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29172. }
  29173. m.SetActiveUser(v)
  29174. return nil
  29175. case usagestatisticday.FieldNewUser:
  29176. v, ok := value.(int64)
  29177. if !ok {
  29178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29179. }
  29180. m.SetNewUser(v)
  29181. return nil
  29182. case usagestatisticday.FieldLabelDist:
  29183. v, ok := value.([]custom_types.LabelDist)
  29184. if !ok {
  29185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29186. }
  29187. m.SetLabelDist(v)
  29188. return nil
  29189. }
  29190. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29191. }
  29192. // AddedFields returns all numeric fields that were incremented/decremented during
  29193. // this mutation.
  29194. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29195. var fields []string
  29196. if m.addstatus != nil {
  29197. fields = append(fields, usagestatisticday.FieldStatus)
  29198. }
  29199. if m.addaddtime != nil {
  29200. fields = append(fields, usagestatisticday.FieldAddtime)
  29201. }
  29202. if m.add_type != nil {
  29203. fields = append(fields, usagestatisticday.FieldType)
  29204. }
  29205. if m.addorganization_id != nil {
  29206. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29207. }
  29208. if m.addai_response != nil {
  29209. fields = append(fields, usagestatisticday.FieldAiResponse)
  29210. }
  29211. if m.addsop_run != nil {
  29212. fields = append(fields, usagestatisticday.FieldSopRun)
  29213. }
  29214. if m.addtotal_friend != nil {
  29215. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29216. }
  29217. if m.addtotal_group != nil {
  29218. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29219. }
  29220. if m.addaccount_balance != nil {
  29221. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29222. }
  29223. if m.addconsume_token != nil {
  29224. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29225. }
  29226. if m.addactive_user != nil {
  29227. fields = append(fields, usagestatisticday.FieldActiveUser)
  29228. }
  29229. if m.addnew_user != nil {
  29230. fields = append(fields, usagestatisticday.FieldNewUser)
  29231. }
  29232. return fields
  29233. }
  29234. // AddedField returns the numeric value that was incremented/decremented on a field
  29235. // with the given name. The second boolean return value indicates that this field
  29236. // was not set, or was not defined in the schema.
  29237. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29238. switch name {
  29239. case usagestatisticday.FieldStatus:
  29240. return m.AddedStatus()
  29241. case usagestatisticday.FieldAddtime:
  29242. return m.AddedAddtime()
  29243. case usagestatisticday.FieldType:
  29244. return m.AddedType()
  29245. case usagestatisticday.FieldOrganizationID:
  29246. return m.AddedOrganizationID()
  29247. case usagestatisticday.FieldAiResponse:
  29248. return m.AddedAiResponse()
  29249. case usagestatisticday.FieldSopRun:
  29250. return m.AddedSopRun()
  29251. case usagestatisticday.FieldTotalFriend:
  29252. return m.AddedTotalFriend()
  29253. case usagestatisticday.FieldTotalGroup:
  29254. return m.AddedTotalGroup()
  29255. case usagestatisticday.FieldAccountBalance:
  29256. return m.AddedAccountBalance()
  29257. case usagestatisticday.FieldConsumeToken:
  29258. return m.AddedConsumeToken()
  29259. case usagestatisticday.FieldActiveUser:
  29260. return m.AddedActiveUser()
  29261. case usagestatisticday.FieldNewUser:
  29262. return m.AddedNewUser()
  29263. }
  29264. return nil, false
  29265. }
  29266. // AddField adds the value to the field with the given name. It returns an error if
  29267. // the field is not defined in the schema, or if the type mismatched the field
  29268. // type.
  29269. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29270. switch name {
  29271. case usagestatisticday.FieldStatus:
  29272. v, ok := value.(int8)
  29273. if !ok {
  29274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29275. }
  29276. m.AddStatus(v)
  29277. return nil
  29278. case usagestatisticday.FieldAddtime:
  29279. v, ok := value.(int64)
  29280. if !ok {
  29281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29282. }
  29283. m.AddAddtime(v)
  29284. return nil
  29285. case usagestatisticday.FieldType:
  29286. v, ok := value.(int)
  29287. if !ok {
  29288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29289. }
  29290. m.AddType(v)
  29291. return nil
  29292. case usagestatisticday.FieldOrganizationID:
  29293. v, ok := value.(int64)
  29294. if !ok {
  29295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29296. }
  29297. m.AddOrganizationID(v)
  29298. return nil
  29299. case usagestatisticday.FieldAiResponse:
  29300. v, ok := value.(int64)
  29301. if !ok {
  29302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29303. }
  29304. m.AddAiResponse(v)
  29305. return nil
  29306. case usagestatisticday.FieldSopRun:
  29307. v, ok := value.(int64)
  29308. if !ok {
  29309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29310. }
  29311. m.AddSopRun(v)
  29312. return nil
  29313. case usagestatisticday.FieldTotalFriend:
  29314. v, ok := value.(int64)
  29315. if !ok {
  29316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29317. }
  29318. m.AddTotalFriend(v)
  29319. return nil
  29320. case usagestatisticday.FieldTotalGroup:
  29321. v, ok := value.(int64)
  29322. if !ok {
  29323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29324. }
  29325. m.AddTotalGroup(v)
  29326. return nil
  29327. case usagestatisticday.FieldAccountBalance:
  29328. v, ok := value.(int64)
  29329. if !ok {
  29330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29331. }
  29332. m.AddAccountBalance(v)
  29333. return nil
  29334. case usagestatisticday.FieldConsumeToken:
  29335. v, ok := value.(int64)
  29336. if !ok {
  29337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29338. }
  29339. m.AddConsumeToken(v)
  29340. return nil
  29341. case usagestatisticday.FieldActiveUser:
  29342. v, ok := value.(int64)
  29343. if !ok {
  29344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29345. }
  29346. m.AddActiveUser(v)
  29347. return nil
  29348. case usagestatisticday.FieldNewUser:
  29349. v, ok := value.(int64)
  29350. if !ok {
  29351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29352. }
  29353. m.AddNewUser(v)
  29354. return nil
  29355. }
  29356. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29357. }
  29358. // ClearedFields returns all nullable fields that were cleared during this
  29359. // mutation.
  29360. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29361. var fields []string
  29362. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29363. fields = append(fields, usagestatisticday.FieldStatus)
  29364. }
  29365. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29366. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29367. }
  29368. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29369. fields = append(fields, usagestatisticday.FieldBotID)
  29370. }
  29371. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29372. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29373. }
  29374. return fields
  29375. }
  29376. // FieldCleared returns a boolean indicating if a field with the given name was
  29377. // cleared in this mutation.
  29378. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29379. _, ok := m.clearedFields[name]
  29380. return ok
  29381. }
  29382. // ClearField clears the value of the field with the given name. It returns an
  29383. // error if the field is not defined in the schema.
  29384. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29385. switch name {
  29386. case usagestatisticday.FieldStatus:
  29387. m.ClearStatus()
  29388. return nil
  29389. case usagestatisticday.FieldDeletedAt:
  29390. m.ClearDeletedAt()
  29391. return nil
  29392. case usagestatisticday.FieldBotID:
  29393. m.ClearBotID()
  29394. return nil
  29395. case usagestatisticday.FieldOrganizationID:
  29396. m.ClearOrganizationID()
  29397. return nil
  29398. }
  29399. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29400. }
  29401. // ResetField resets all changes in the mutation for the field with the given name.
  29402. // It returns an error if the field is not defined in the schema.
  29403. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29404. switch name {
  29405. case usagestatisticday.FieldCreatedAt:
  29406. m.ResetCreatedAt()
  29407. return nil
  29408. case usagestatisticday.FieldUpdatedAt:
  29409. m.ResetUpdatedAt()
  29410. return nil
  29411. case usagestatisticday.FieldStatus:
  29412. m.ResetStatus()
  29413. return nil
  29414. case usagestatisticday.FieldDeletedAt:
  29415. m.ResetDeletedAt()
  29416. return nil
  29417. case usagestatisticday.FieldAddtime:
  29418. m.ResetAddtime()
  29419. return nil
  29420. case usagestatisticday.FieldType:
  29421. m.ResetType()
  29422. return nil
  29423. case usagestatisticday.FieldBotID:
  29424. m.ResetBotID()
  29425. return nil
  29426. case usagestatisticday.FieldOrganizationID:
  29427. m.ResetOrganizationID()
  29428. return nil
  29429. case usagestatisticday.FieldAiResponse:
  29430. m.ResetAiResponse()
  29431. return nil
  29432. case usagestatisticday.FieldSopRun:
  29433. m.ResetSopRun()
  29434. return nil
  29435. case usagestatisticday.FieldTotalFriend:
  29436. m.ResetTotalFriend()
  29437. return nil
  29438. case usagestatisticday.FieldTotalGroup:
  29439. m.ResetTotalGroup()
  29440. return nil
  29441. case usagestatisticday.FieldAccountBalance:
  29442. m.ResetAccountBalance()
  29443. return nil
  29444. case usagestatisticday.FieldConsumeToken:
  29445. m.ResetConsumeToken()
  29446. return nil
  29447. case usagestatisticday.FieldActiveUser:
  29448. m.ResetActiveUser()
  29449. return nil
  29450. case usagestatisticday.FieldNewUser:
  29451. m.ResetNewUser()
  29452. return nil
  29453. case usagestatisticday.FieldLabelDist:
  29454. m.ResetLabelDist()
  29455. return nil
  29456. }
  29457. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29458. }
  29459. // AddedEdges returns all edge names that were set/added in this mutation.
  29460. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29461. edges := make([]string, 0, 0)
  29462. return edges
  29463. }
  29464. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29465. // name in this mutation.
  29466. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29467. return nil
  29468. }
  29469. // RemovedEdges returns all edge names that were removed in this mutation.
  29470. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29471. edges := make([]string, 0, 0)
  29472. return edges
  29473. }
  29474. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29475. // the given name in this mutation.
  29476. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29477. return nil
  29478. }
  29479. // ClearedEdges returns all edge names that were cleared in this mutation.
  29480. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29481. edges := make([]string, 0, 0)
  29482. return edges
  29483. }
  29484. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29485. // was cleared in this mutation.
  29486. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29487. return false
  29488. }
  29489. // ClearEdge clears the value of the edge with the given name. It returns an error
  29490. // if that edge is not defined in the schema.
  29491. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29492. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29493. }
  29494. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29495. // It returns an error if the edge is not defined in the schema.
  29496. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29497. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29498. }
  29499. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29500. type UsageStatisticHourMutation struct {
  29501. config
  29502. op Op
  29503. typ string
  29504. id *uint64
  29505. created_at *time.Time
  29506. updated_at *time.Time
  29507. status *uint8
  29508. addstatus *int8
  29509. deleted_at *time.Time
  29510. addtime *uint64
  29511. addaddtime *int64
  29512. _type *int
  29513. add_type *int
  29514. bot_id *string
  29515. organization_id *uint64
  29516. addorganization_id *int64
  29517. ai_response *uint64
  29518. addai_response *int64
  29519. sop_run *uint64
  29520. addsop_run *int64
  29521. total_friend *uint64
  29522. addtotal_friend *int64
  29523. total_group *uint64
  29524. addtotal_group *int64
  29525. account_balance *uint64
  29526. addaccount_balance *int64
  29527. consume_token *uint64
  29528. addconsume_token *int64
  29529. active_user *uint64
  29530. addactive_user *int64
  29531. new_user *int64
  29532. addnew_user *int64
  29533. label_dist *[]custom_types.LabelDist
  29534. appendlabel_dist []custom_types.LabelDist
  29535. clearedFields map[string]struct{}
  29536. done bool
  29537. oldValue func(context.Context) (*UsageStatisticHour, error)
  29538. predicates []predicate.UsageStatisticHour
  29539. }
  29540. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29541. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29542. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29543. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29544. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29545. m := &UsageStatisticHourMutation{
  29546. config: c,
  29547. op: op,
  29548. typ: TypeUsageStatisticHour,
  29549. clearedFields: make(map[string]struct{}),
  29550. }
  29551. for _, opt := range opts {
  29552. opt(m)
  29553. }
  29554. return m
  29555. }
  29556. // withUsageStatisticHourID sets the ID field of the mutation.
  29557. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29558. return func(m *UsageStatisticHourMutation) {
  29559. var (
  29560. err error
  29561. once sync.Once
  29562. value *UsageStatisticHour
  29563. )
  29564. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29565. once.Do(func() {
  29566. if m.done {
  29567. err = errors.New("querying old values post mutation is not allowed")
  29568. } else {
  29569. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29570. }
  29571. })
  29572. return value, err
  29573. }
  29574. m.id = &id
  29575. }
  29576. }
  29577. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29578. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29579. return func(m *UsageStatisticHourMutation) {
  29580. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29581. return node, nil
  29582. }
  29583. m.id = &node.ID
  29584. }
  29585. }
  29586. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29587. // executed in a transaction (ent.Tx), a transactional client is returned.
  29588. func (m UsageStatisticHourMutation) Client() *Client {
  29589. client := &Client{config: m.config}
  29590. client.init()
  29591. return client
  29592. }
  29593. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29594. // it returns an error otherwise.
  29595. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29596. if _, ok := m.driver.(*txDriver); !ok {
  29597. return nil, errors.New("ent: mutation is not running in a transaction")
  29598. }
  29599. tx := &Tx{config: m.config}
  29600. tx.init()
  29601. return tx, nil
  29602. }
  29603. // SetID sets the value of the id field. Note that this
  29604. // operation is only accepted on creation of UsageStatisticHour entities.
  29605. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29606. m.id = &id
  29607. }
  29608. // ID returns the ID value in the mutation. Note that the ID is only available
  29609. // if it was provided to the builder or after it was returned from the database.
  29610. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29611. if m.id == nil {
  29612. return
  29613. }
  29614. return *m.id, true
  29615. }
  29616. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29617. // That means, if the mutation is applied within a transaction with an isolation level such
  29618. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29619. // or updated by the mutation.
  29620. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29621. switch {
  29622. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29623. id, exists := m.ID()
  29624. if exists {
  29625. return []uint64{id}, nil
  29626. }
  29627. fallthrough
  29628. case m.op.Is(OpUpdate | OpDelete):
  29629. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29630. default:
  29631. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29632. }
  29633. }
  29634. // SetCreatedAt sets the "created_at" field.
  29635. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29636. m.created_at = &t
  29637. }
  29638. // CreatedAt returns the value of the "created_at" field in the mutation.
  29639. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29640. v := m.created_at
  29641. if v == nil {
  29642. return
  29643. }
  29644. return *v, true
  29645. }
  29646. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29647. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29648. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29649. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29650. if !m.op.Is(OpUpdateOne) {
  29651. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29652. }
  29653. if m.id == nil || m.oldValue == nil {
  29654. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29655. }
  29656. oldValue, err := m.oldValue(ctx)
  29657. if err != nil {
  29658. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29659. }
  29660. return oldValue.CreatedAt, nil
  29661. }
  29662. // ResetCreatedAt resets all changes to the "created_at" field.
  29663. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29664. m.created_at = nil
  29665. }
  29666. // SetUpdatedAt sets the "updated_at" field.
  29667. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29668. m.updated_at = &t
  29669. }
  29670. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29671. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29672. v := m.updated_at
  29673. if v == nil {
  29674. return
  29675. }
  29676. return *v, true
  29677. }
  29678. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29679. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29681. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29682. if !m.op.Is(OpUpdateOne) {
  29683. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29684. }
  29685. if m.id == nil || m.oldValue == nil {
  29686. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29687. }
  29688. oldValue, err := m.oldValue(ctx)
  29689. if err != nil {
  29690. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29691. }
  29692. return oldValue.UpdatedAt, nil
  29693. }
  29694. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29695. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29696. m.updated_at = nil
  29697. }
  29698. // SetStatus sets the "status" field.
  29699. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29700. m.status = &u
  29701. m.addstatus = nil
  29702. }
  29703. // Status returns the value of the "status" field in the mutation.
  29704. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29705. v := m.status
  29706. if v == nil {
  29707. return
  29708. }
  29709. return *v, true
  29710. }
  29711. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29712. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29714. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29715. if !m.op.Is(OpUpdateOne) {
  29716. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29717. }
  29718. if m.id == nil || m.oldValue == nil {
  29719. return v, errors.New("OldStatus requires an ID field in the mutation")
  29720. }
  29721. oldValue, err := m.oldValue(ctx)
  29722. if err != nil {
  29723. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29724. }
  29725. return oldValue.Status, nil
  29726. }
  29727. // AddStatus adds u to the "status" field.
  29728. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29729. if m.addstatus != nil {
  29730. *m.addstatus += u
  29731. } else {
  29732. m.addstatus = &u
  29733. }
  29734. }
  29735. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29736. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29737. v := m.addstatus
  29738. if v == nil {
  29739. return
  29740. }
  29741. return *v, true
  29742. }
  29743. // ClearStatus clears the value of the "status" field.
  29744. func (m *UsageStatisticHourMutation) ClearStatus() {
  29745. m.status = nil
  29746. m.addstatus = nil
  29747. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29748. }
  29749. // StatusCleared returns if the "status" field was cleared in this mutation.
  29750. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29751. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29752. return ok
  29753. }
  29754. // ResetStatus resets all changes to the "status" field.
  29755. func (m *UsageStatisticHourMutation) ResetStatus() {
  29756. m.status = nil
  29757. m.addstatus = nil
  29758. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29759. }
  29760. // SetDeletedAt sets the "deleted_at" field.
  29761. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29762. m.deleted_at = &t
  29763. }
  29764. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29765. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29766. v := m.deleted_at
  29767. if v == nil {
  29768. return
  29769. }
  29770. return *v, true
  29771. }
  29772. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29773. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29775. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29776. if !m.op.Is(OpUpdateOne) {
  29777. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29778. }
  29779. if m.id == nil || m.oldValue == nil {
  29780. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29781. }
  29782. oldValue, err := m.oldValue(ctx)
  29783. if err != nil {
  29784. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29785. }
  29786. return oldValue.DeletedAt, nil
  29787. }
  29788. // ClearDeletedAt clears the value of the "deleted_at" field.
  29789. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29790. m.deleted_at = nil
  29791. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29792. }
  29793. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29794. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29795. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29796. return ok
  29797. }
  29798. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29799. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29800. m.deleted_at = nil
  29801. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29802. }
  29803. // SetAddtime sets the "addtime" field.
  29804. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29805. m.addtime = &u
  29806. m.addaddtime = nil
  29807. }
  29808. // Addtime returns the value of the "addtime" field in the mutation.
  29809. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29810. v := m.addtime
  29811. if v == nil {
  29812. return
  29813. }
  29814. return *v, true
  29815. }
  29816. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29817. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29819. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29820. if !m.op.Is(OpUpdateOne) {
  29821. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29822. }
  29823. if m.id == nil || m.oldValue == nil {
  29824. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29825. }
  29826. oldValue, err := m.oldValue(ctx)
  29827. if err != nil {
  29828. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29829. }
  29830. return oldValue.Addtime, nil
  29831. }
  29832. // AddAddtime adds u to the "addtime" field.
  29833. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29834. if m.addaddtime != nil {
  29835. *m.addaddtime += u
  29836. } else {
  29837. m.addaddtime = &u
  29838. }
  29839. }
  29840. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29841. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29842. v := m.addaddtime
  29843. if v == nil {
  29844. return
  29845. }
  29846. return *v, true
  29847. }
  29848. // ResetAddtime resets all changes to the "addtime" field.
  29849. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29850. m.addtime = nil
  29851. m.addaddtime = nil
  29852. }
  29853. // SetType sets the "type" field.
  29854. func (m *UsageStatisticHourMutation) SetType(i int) {
  29855. m._type = &i
  29856. m.add_type = nil
  29857. }
  29858. // GetType returns the value of the "type" field in the mutation.
  29859. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29860. v := m._type
  29861. if v == nil {
  29862. return
  29863. }
  29864. return *v, true
  29865. }
  29866. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29867. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29868. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29869. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29870. if !m.op.Is(OpUpdateOne) {
  29871. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29872. }
  29873. if m.id == nil || m.oldValue == nil {
  29874. return v, errors.New("OldType requires an ID field in the mutation")
  29875. }
  29876. oldValue, err := m.oldValue(ctx)
  29877. if err != nil {
  29878. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29879. }
  29880. return oldValue.Type, nil
  29881. }
  29882. // AddType adds i to the "type" field.
  29883. func (m *UsageStatisticHourMutation) AddType(i int) {
  29884. if m.add_type != nil {
  29885. *m.add_type += i
  29886. } else {
  29887. m.add_type = &i
  29888. }
  29889. }
  29890. // AddedType returns the value that was added to the "type" field in this mutation.
  29891. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  29892. v := m.add_type
  29893. if v == nil {
  29894. return
  29895. }
  29896. return *v, true
  29897. }
  29898. // ResetType resets all changes to the "type" field.
  29899. func (m *UsageStatisticHourMutation) ResetType() {
  29900. m._type = nil
  29901. m.add_type = nil
  29902. }
  29903. // SetBotID sets the "bot_id" field.
  29904. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  29905. m.bot_id = &s
  29906. }
  29907. // BotID returns the value of the "bot_id" field in the mutation.
  29908. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  29909. v := m.bot_id
  29910. if v == nil {
  29911. return
  29912. }
  29913. return *v, true
  29914. }
  29915. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  29916. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29917. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29918. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  29919. if !m.op.Is(OpUpdateOne) {
  29920. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29921. }
  29922. if m.id == nil || m.oldValue == nil {
  29923. return v, errors.New("OldBotID requires an ID field in the mutation")
  29924. }
  29925. oldValue, err := m.oldValue(ctx)
  29926. if err != nil {
  29927. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29928. }
  29929. return oldValue.BotID, nil
  29930. }
  29931. // ClearBotID clears the value of the "bot_id" field.
  29932. func (m *UsageStatisticHourMutation) ClearBotID() {
  29933. m.bot_id = nil
  29934. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  29935. }
  29936. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29937. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  29938. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  29939. return ok
  29940. }
  29941. // ResetBotID resets all changes to the "bot_id" field.
  29942. func (m *UsageStatisticHourMutation) ResetBotID() {
  29943. m.bot_id = nil
  29944. delete(m.clearedFields, usagestatistichour.FieldBotID)
  29945. }
  29946. // SetOrganizationID sets the "organization_id" field.
  29947. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  29948. m.organization_id = &u
  29949. m.addorganization_id = nil
  29950. }
  29951. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29952. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  29953. v := m.organization_id
  29954. if v == nil {
  29955. return
  29956. }
  29957. return *v, true
  29958. }
  29959. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  29960. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29962. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29963. if !m.op.Is(OpUpdateOne) {
  29964. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  29965. }
  29966. if m.id == nil || m.oldValue == nil {
  29967. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  29968. }
  29969. oldValue, err := m.oldValue(ctx)
  29970. if err != nil {
  29971. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  29972. }
  29973. return oldValue.OrganizationID, nil
  29974. }
  29975. // AddOrganizationID adds u to the "organization_id" field.
  29976. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  29977. if m.addorganization_id != nil {
  29978. *m.addorganization_id += u
  29979. } else {
  29980. m.addorganization_id = &u
  29981. }
  29982. }
  29983. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  29984. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  29985. v := m.addorganization_id
  29986. if v == nil {
  29987. return
  29988. }
  29989. return *v, true
  29990. }
  29991. // ClearOrganizationID clears the value of the "organization_id" field.
  29992. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  29993. m.organization_id = nil
  29994. m.addorganization_id = nil
  29995. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  29996. }
  29997. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  29998. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  29999. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30000. return ok
  30001. }
  30002. // ResetOrganizationID resets all changes to the "organization_id" field.
  30003. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30004. m.organization_id = nil
  30005. m.addorganization_id = nil
  30006. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30007. }
  30008. // SetAiResponse sets the "ai_response" field.
  30009. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30010. m.ai_response = &u
  30011. m.addai_response = nil
  30012. }
  30013. // AiResponse returns the value of the "ai_response" field in the mutation.
  30014. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30015. v := m.ai_response
  30016. if v == nil {
  30017. return
  30018. }
  30019. return *v, true
  30020. }
  30021. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30022. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30024. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30025. if !m.op.Is(OpUpdateOne) {
  30026. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30027. }
  30028. if m.id == nil || m.oldValue == nil {
  30029. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30030. }
  30031. oldValue, err := m.oldValue(ctx)
  30032. if err != nil {
  30033. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30034. }
  30035. return oldValue.AiResponse, nil
  30036. }
  30037. // AddAiResponse adds u to the "ai_response" field.
  30038. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30039. if m.addai_response != nil {
  30040. *m.addai_response += u
  30041. } else {
  30042. m.addai_response = &u
  30043. }
  30044. }
  30045. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30046. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30047. v := m.addai_response
  30048. if v == nil {
  30049. return
  30050. }
  30051. return *v, true
  30052. }
  30053. // ResetAiResponse resets all changes to the "ai_response" field.
  30054. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30055. m.ai_response = nil
  30056. m.addai_response = nil
  30057. }
  30058. // SetSopRun sets the "sop_run" field.
  30059. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30060. m.sop_run = &u
  30061. m.addsop_run = nil
  30062. }
  30063. // SopRun returns the value of the "sop_run" field in the mutation.
  30064. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30065. v := m.sop_run
  30066. if v == nil {
  30067. return
  30068. }
  30069. return *v, true
  30070. }
  30071. // OldSopRun returns the old "sop_run" 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) OldSopRun(ctx context.Context) (v uint64, err error) {
  30075. if !m.op.Is(OpUpdateOne) {
  30076. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30077. }
  30078. if m.id == nil || m.oldValue == nil {
  30079. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  30084. }
  30085. return oldValue.SopRun, nil
  30086. }
  30087. // AddSopRun adds u to the "sop_run" field.
  30088. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30089. if m.addsop_run != nil {
  30090. *m.addsop_run += u
  30091. } else {
  30092. m.addsop_run = &u
  30093. }
  30094. }
  30095. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30096. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30097. v := m.addsop_run
  30098. if v == nil {
  30099. return
  30100. }
  30101. return *v, true
  30102. }
  30103. // ResetSopRun resets all changes to the "sop_run" field.
  30104. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30105. m.sop_run = nil
  30106. m.addsop_run = nil
  30107. }
  30108. // SetTotalFriend sets the "total_friend" field.
  30109. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30110. m.total_friend = &u
  30111. m.addtotal_friend = nil
  30112. }
  30113. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30114. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30115. v := m.total_friend
  30116. if v == nil {
  30117. return
  30118. }
  30119. return *v, true
  30120. }
  30121. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30122. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30124. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30125. if !m.op.Is(OpUpdateOne) {
  30126. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30127. }
  30128. if m.id == nil || m.oldValue == nil {
  30129. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30130. }
  30131. oldValue, err := m.oldValue(ctx)
  30132. if err != nil {
  30133. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30134. }
  30135. return oldValue.TotalFriend, nil
  30136. }
  30137. // AddTotalFriend adds u to the "total_friend" field.
  30138. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30139. if m.addtotal_friend != nil {
  30140. *m.addtotal_friend += u
  30141. } else {
  30142. m.addtotal_friend = &u
  30143. }
  30144. }
  30145. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30146. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30147. v := m.addtotal_friend
  30148. if v == nil {
  30149. return
  30150. }
  30151. return *v, true
  30152. }
  30153. // ResetTotalFriend resets all changes to the "total_friend" field.
  30154. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30155. m.total_friend = nil
  30156. m.addtotal_friend = nil
  30157. }
  30158. // SetTotalGroup sets the "total_group" field.
  30159. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30160. m.total_group = &u
  30161. m.addtotal_group = nil
  30162. }
  30163. // TotalGroup returns the value of the "total_group" field in the mutation.
  30164. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30165. v := m.total_group
  30166. if v == nil {
  30167. return
  30168. }
  30169. return *v, true
  30170. }
  30171. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30172. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30173. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30174. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30175. if !m.op.Is(OpUpdateOne) {
  30176. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30177. }
  30178. if m.id == nil || m.oldValue == nil {
  30179. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30180. }
  30181. oldValue, err := m.oldValue(ctx)
  30182. if err != nil {
  30183. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30184. }
  30185. return oldValue.TotalGroup, nil
  30186. }
  30187. // AddTotalGroup adds u to the "total_group" field.
  30188. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30189. if m.addtotal_group != nil {
  30190. *m.addtotal_group += u
  30191. } else {
  30192. m.addtotal_group = &u
  30193. }
  30194. }
  30195. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30196. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30197. v := m.addtotal_group
  30198. if v == nil {
  30199. return
  30200. }
  30201. return *v, true
  30202. }
  30203. // ResetTotalGroup resets all changes to the "total_group" field.
  30204. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30205. m.total_group = nil
  30206. m.addtotal_group = nil
  30207. }
  30208. // SetAccountBalance sets the "account_balance" field.
  30209. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30210. m.account_balance = &u
  30211. m.addaccount_balance = nil
  30212. }
  30213. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30214. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30215. v := m.account_balance
  30216. if v == nil {
  30217. return
  30218. }
  30219. return *v, true
  30220. }
  30221. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30222. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30223. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30224. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30225. if !m.op.Is(OpUpdateOne) {
  30226. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30227. }
  30228. if m.id == nil || m.oldValue == nil {
  30229. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30230. }
  30231. oldValue, err := m.oldValue(ctx)
  30232. if err != nil {
  30233. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30234. }
  30235. return oldValue.AccountBalance, nil
  30236. }
  30237. // AddAccountBalance adds u to the "account_balance" field.
  30238. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30239. if m.addaccount_balance != nil {
  30240. *m.addaccount_balance += u
  30241. } else {
  30242. m.addaccount_balance = &u
  30243. }
  30244. }
  30245. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30246. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30247. v := m.addaccount_balance
  30248. if v == nil {
  30249. return
  30250. }
  30251. return *v, true
  30252. }
  30253. // ResetAccountBalance resets all changes to the "account_balance" field.
  30254. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30255. m.account_balance = nil
  30256. m.addaccount_balance = nil
  30257. }
  30258. // SetConsumeToken sets the "consume_token" field.
  30259. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30260. m.consume_token = &u
  30261. m.addconsume_token = nil
  30262. }
  30263. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30264. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30265. v := m.consume_token
  30266. if v == nil {
  30267. return
  30268. }
  30269. return *v, true
  30270. }
  30271. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30272. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30274. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30275. if !m.op.Is(OpUpdateOne) {
  30276. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30277. }
  30278. if m.id == nil || m.oldValue == nil {
  30279. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30280. }
  30281. oldValue, err := m.oldValue(ctx)
  30282. if err != nil {
  30283. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30284. }
  30285. return oldValue.ConsumeToken, nil
  30286. }
  30287. // AddConsumeToken adds u to the "consume_token" field.
  30288. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30289. if m.addconsume_token != nil {
  30290. *m.addconsume_token += u
  30291. } else {
  30292. m.addconsume_token = &u
  30293. }
  30294. }
  30295. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30296. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30297. v := m.addconsume_token
  30298. if v == nil {
  30299. return
  30300. }
  30301. return *v, true
  30302. }
  30303. // ResetConsumeToken resets all changes to the "consume_token" field.
  30304. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30305. m.consume_token = nil
  30306. m.addconsume_token = nil
  30307. }
  30308. // SetActiveUser sets the "active_user" field.
  30309. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30310. m.active_user = &u
  30311. m.addactive_user = nil
  30312. }
  30313. // ActiveUser returns the value of the "active_user" field in the mutation.
  30314. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30315. v := m.active_user
  30316. if v == nil {
  30317. return
  30318. }
  30319. return *v, true
  30320. }
  30321. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30322. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30324. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30325. if !m.op.Is(OpUpdateOne) {
  30326. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30327. }
  30328. if m.id == nil || m.oldValue == nil {
  30329. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30330. }
  30331. oldValue, err := m.oldValue(ctx)
  30332. if err != nil {
  30333. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30334. }
  30335. return oldValue.ActiveUser, nil
  30336. }
  30337. // AddActiveUser adds u to the "active_user" field.
  30338. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30339. if m.addactive_user != nil {
  30340. *m.addactive_user += u
  30341. } else {
  30342. m.addactive_user = &u
  30343. }
  30344. }
  30345. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30346. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30347. v := m.addactive_user
  30348. if v == nil {
  30349. return
  30350. }
  30351. return *v, true
  30352. }
  30353. // ResetActiveUser resets all changes to the "active_user" field.
  30354. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30355. m.active_user = nil
  30356. m.addactive_user = nil
  30357. }
  30358. // SetNewUser sets the "new_user" field.
  30359. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30360. m.new_user = &i
  30361. m.addnew_user = nil
  30362. }
  30363. // NewUser returns the value of the "new_user" field in the mutation.
  30364. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30365. v := m.new_user
  30366. if v == nil {
  30367. return
  30368. }
  30369. return *v, true
  30370. }
  30371. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30372. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30374. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30375. if !m.op.Is(OpUpdateOne) {
  30376. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30377. }
  30378. if m.id == nil || m.oldValue == nil {
  30379. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30380. }
  30381. oldValue, err := m.oldValue(ctx)
  30382. if err != nil {
  30383. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30384. }
  30385. return oldValue.NewUser, nil
  30386. }
  30387. // AddNewUser adds i to the "new_user" field.
  30388. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30389. if m.addnew_user != nil {
  30390. *m.addnew_user += i
  30391. } else {
  30392. m.addnew_user = &i
  30393. }
  30394. }
  30395. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30396. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30397. v := m.addnew_user
  30398. if v == nil {
  30399. return
  30400. }
  30401. return *v, true
  30402. }
  30403. // ResetNewUser resets all changes to the "new_user" field.
  30404. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30405. m.new_user = nil
  30406. m.addnew_user = nil
  30407. }
  30408. // SetLabelDist sets the "label_dist" field.
  30409. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30410. m.label_dist = &ctd
  30411. m.appendlabel_dist = nil
  30412. }
  30413. // LabelDist returns the value of the "label_dist" field in the mutation.
  30414. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30415. v := m.label_dist
  30416. if v == nil {
  30417. return
  30418. }
  30419. return *v, true
  30420. }
  30421. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30422. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30424. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30425. if !m.op.Is(OpUpdateOne) {
  30426. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30427. }
  30428. if m.id == nil || m.oldValue == nil {
  30429. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30430. }
  30431. oldValue, err := m.oldValue(ctx)
  30432. if err != nil {
  30433. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30434. }
  30435. return oldValue.LabelDist, nil
  30436. }
  30437. // AppendLabelDist adds ctd to the "label_dist" field.
  30438. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30439. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30440. }
  30441. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30442. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30443. if len(m.appendlabel_dist) == 0 {
  30444. return nil, false
  30445. }
  30446. return m.appendlabel_dist, true
  30447. }
  30448. // ResetLabelDist resets all changes to the "label_dist" field.
  30449. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30450. m.label_dist = nil
  30451. m.appendlabel_dist = nil
  30452. }
  30453. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30454. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30455. m.predicates = append(m.predicates, ps...)
  30456. }
  30457. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30458. // users can use type-assertion to append predicates that do not depend on any generated package.
  30459. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30460. p := make([]predicate.UsageStatisticHour, len(ps))
  30461. for i := range ps {
  30462. p[i] = ps[i]
  30463. }
  30464. m.Where(p...)
  30465. }
  30466. // Op returns the operation name.
  30467. func (m *UsageStatisticHourMutation) Op() Op {
  30468. return m.op
  30469. }
  30470. // SetOp allows setting the mutation operation.
  30471. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30472. m.op = op
  30473. }
  30474. // Type returns the node type of this mutation (UsageStatisticHour).
  30475. func (m *UsageStatisticHourMutation) Type() string {
  30476. return m.typ
  30477. }
  30478. // Fields returns all fields that were changed during this mutation. Note that in
  30479. // order to get all numeric fields that were incremented/decremented, call
  30480. // AddedFields().
  30481. func (m *UsageStatisticHourMutation) Fields() []string {
  30482. fields := make([]string, 0, 17)
  30483. if m.created_at != nil {
  30484. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30485. }
  30486. if m.updated_at != nil {
  30487. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30488. }
  30489. if m.status != nil {
  30490. fields = append(fields, usagestatistichour.FieldStatus)
  30491. }
  30492. if m.deleted_at != nil {
  30493. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30494. }
  30495. if m.addtime != nil {
  30496. fields = append(fields, usagestatistichour.FieldAddtime)
  30497. }
  30498. if m._type != nil {
  30499. fields = append(fields, usagestatistichour.FieldType)
  30500. }
  30501. if m.bot_id != nil {
  30502. fields = append(fields, usagestatistichour.FieldBotID)
  30503. }
  30504. if m.organization_id != nil {
  30505. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30506. }
  30507. if m.ai_response != nil {
  30508. fields = append(fields, usagestatistichour.FieldAiResponse)
  30509. }
  30510. if m.sop_run != nil {
  30511. fields = append(fields, usagestatistichour.FieldSopRun)
  30512. }
  30513. if m.total_friend != nil {
  30514. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30515. }
  30516. if m.total_group != nil {
  30517. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30518. }
  30519. if m.account_balance != nil {
  30520. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30521. }
  30522. if m.consume_token != nil {
  30523. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30524. }
  30525. if m.active_user != nil {
  30526. fields = append(fields, usagestatistichour.FieldActiveUser)
  30527. }
  30528. if m.new_user != nil {
  30529. fields = append(fields, usagestatistichour.FieldNewUser)
  30530. }
  30531. if m.label_dist != nil {
  30532. fields = append(fields, usagestatistichour.FieldLabelDist)
  30533. }
  30534. return fields
  30535. }
  30536. // Field returns the value of a field with the given name. The second boolean
  30537. // return value indicates that this field was not set, or was not defined in the
  30538. // schema.
  30539. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30540. switch name {
  30541. case usagestatistichour.FieldCreatedAt:
  30542. return m.CreatedAt()
  30543. case usagestatistichour.FieldUpdatedAt:
  30544. return m.UpdatedAt()
  30545. case usagestatistichour.FieldStatus:
  30546. return m.Status()
  30547. case usagestatistichour.FieldDeletedAt:
  30548. return m.DeletedAt()
  30549. case usagestatistichour.FieldAddtime:
  30550. return m.Addtime()
  30551. case usagestatistichour.FieldType:
  30552. return m.GetType()
  30553. case usagestatistichour.FieldBotID:
  30554. return m.BotID()
  30555. case usagestatistichour.FieldOrganizationID:
  30556. return m.OrganizationID()
  30557. case usagestatistichour.FieldAiResponse:
  30558. return m.AiResponse()
  30559. case usagestatistichour.FieldSopRun:
  30560. return m.SopRun()
  30561. case usagestatistichour.FieldTotalFriend:
  30562. return m.TotalFriend()
  30563. case usagestatistichour.FieldTotalGroup:
  30564. return m.TotalGroup()
  30565. case usagestatistichour.FieldAccountBalance:
  30566. return m.AccountBalance()
  30567. case usagestatistichour.FieldConsumeToken:
  30568. return m.ConsumeToken()
  30569. case usagestatistichour.FieldActiveUser:
  30570. return m.ActiveUser()
  30571. case usagestatistichour.FieldNewUser:
  30572. return m.NewUser()
  30573. case usagestatistichour.FieldLabelDist:
  30574. return m.LabelDist()
  30575. }
  30576. return nil, false
  30577. }
  30578. // OldField returns the old value of the field from the database. An error is
  30579. // returned if the mutation operation is not UpdateOne, or the query to the
  30580. // database failed.
  30581. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30582. switch name {
  30583. case usagestatistichour.FieldCreatedAt:
  30584. return m.OldCreatedAt(ctx)
  30585. case usagestatistichour.FieldUpdatedAt:
  30586. return m.OldUpdatedAt(ctx)
  30587. case usagestatistichour.FieldStatus:
  30588. return m.OldStatus(ctx)
  30589. case usagestatistichour.FieldDeletedAt:
  30590. return m.OldDeletedAt(ctx)
  30591. case usagestatistichour.FieldAddtime:
  30592. return m.OldAddtime(ctx)
  30593. case usagestatistichour.FieldType:
  30594. return m.OldType(ctx)
  30595. case usagestatistichour.FieldBotID:
  30596. return m.OldBotID(ctx)
  30597. case usagestatistichour.FieldOrganizationID:
  30598. return m.OldOrganizationID(ctx)
  30599. case usagestatistichour.FieldAiResponse:
  30600. return m.OldAiResponse(ctx)
  30601. case usagestatistichour.FieldSopRun:
  30602. return m.OldSopRun(ctx)
  30603. case usagestatistichour.FieldTotalFriend:
  30604. return m.OldTotalFriend(ctx)
  30605. case usagestatistichour.FieldTotalGroup:
  30606. return m.OldTotalGroup(ctx)
  30607. case usagestatistichour.FieldAccountBalance:
  30608. return m.OldAccountBalance(ctx)
  30609. case usagestatistichour.FieldConsumeToken:
  30610. return m.OldConsumeToken(ctx)
  30611. case usagestatistichour.FieldActiveUser:
  30612. return m.OldActiveUser(ctx)
  30613. case usagestatistichour.FieldNewUser:
  30614. return m.OldNewUser(ctx)
  30615. case usagestatistichour.FieldLabelDist:
  30616. return m.OldLabelDist(ctx)
  30617. }
  30618. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30619. }
  30620. // SetField sets the value of a field with the given name. It returns an error if
  30621. // the field is not defined in the schema, or if the type mismatched the field
  30622. // type.
  30623. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30624. switch name {
  30625. case usagestatistichour.FieldCreatedAt:
  30626. v, ok := value.(time.Time)
  30627. if !ok {
  30628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30629. }
  30630. m.SetCreatedAt(v)
  30631. return nil
  30632. case usagestatistichour.FieldUpdatedAt:
  30633. v, ok := value.(time.Time)
  30634. if !ok {
  30635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30636. }
  30637. m.SetUpdatedAt(v)
  30638. return nil
  30639. case usagestatistichour.FieldStatus:
  30640. v, ok := value.(uint8)
  30641. if !ok {
  30642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30643. }
  30644. m.SetStatus(v)
  30645. return nil
  30646. case usagestatistichour.FieldDeletedAt:
  30647. v, ok := value.(time.Time)
  30648. if !ok {
  30649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30650. }
  30651. m.SetDeletedAt(v)
  30652. return nil
  30653. case usagestatistichour.FieldAddtime:
  30654. v, ok := value.(uint64)
  30655. if !ok {
  30656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30657. }
  30658. m.SetAddtime(v)
  30659. return nil
  30660. case usagestatistichour.FieldType:
  30661. v, ok := value.(int)
  30662. if !ok {
  30663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30664. }
  30665. m.SetType(v)
  30666. return nil
  30667. case usagestatistichour.FieldBotID:
  30668. v, ok := value.(string)
  30669. if !ok {
  30670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30671. }
  30672. m.SetBotID(v)
  30673. return nil
  30674. case usagestatistichour.FieldOrganizationID:
  30675. v, ok := value.(uint64)
  30676. if !ok {
  30677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30678. }
  30679. m.SetOrganizationID(v)
  30680. return nil
  30681. case usagestatistichour.FieldAiResponse:
  30682. v, ok := value.(uint64)
  30683. if !ok {
  30684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30685. }
  30686. m.SetAiResponse(v)
  30687. return nil
  30688. case usagestatistichour.FieldSopRun:
  30689. v, ok := value.(uint64)
  30690. if !ok {
  30691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30692. }
  30693. m.SetSopRun(v)
  30694. return nil
  30695. case usagestatistichour.FieldTotalFriend:
  30696. v, ok := value.(uint64)
  30697. if !ok {
  30698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30699. }
  30700. m.SetTotalFriend(v)
  30701. return nil
  30702. case usagestatistichour.FieldTotalGroup:
  30703. v, ok := value.(uint64)
  30704. if !ok {
  30705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30706. }
  30707. m.SetTotalGroup(v)
  30708. return nil
  30709. case usagestatistichour.FieldAccountBalance:
  30710. v, ok := value.(uint64)
  30711. if !ok {
  30712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30713. }
  30714. m.SetAccountBalance(v)
  30715. return nil
  30716. case usagestatistichour.FieldConsumeToken:
  30717. v, ok := value.(uint64)
  30718. if !ok {
  30719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30720. }
  30721. m.SetConsumeToken(v)
  30722. return nil
  30723. case usagestatistichour.FieldActiveUser:
  30724. v, ok := value.(uint64)
  30725. if !ok {
  30726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30727. }
  30728. m.SetActiveUser(v)
  30729. return nil
  30730. case usagestatistichour.FieldNewUser:
  30731. v, ok := value.(int64)
  30732. if !ok {
  30733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30734. }
  30735. m.SetNewUser(v)
  30736. return nil
  30737. case usagestatistichour.FieldLabelDist:
  30738. v, ok := value.([]custom_types.LabelDist)
  30739. if !ok {
  30740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30741. }
  30742. m.SetLabelDist(v)
  30743. return nil
  30744. }
  30745. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30746. }
  30747. // AddedFields returns all numeric fields that were incremented/decremented during
  30748. // this mutation.
  30749. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30750. var fields []string
  30751. if m.addstatus != nil {
  30752. fields = append(fields, usagestatistichour.FieldStatus)
  30753. }
  30754. if m.addaddtime != nil {
  30755. fields = append(fields, usagestatistichour.FieldAddtime)
  30756. }
  30757. if m.add_type != nil {
  30758. fields = append(fields, usagestatistichour.FieldType)
  30759. }
  30760. if m.addorganization_id != nil {
  30761. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30762. }
  30763. if m.addai_response != nil {
  30764. fields = append(fields, usagestatistichour.FieldAiResponse)
  30765. }
  30766. if m.addsop_run != nil {
  30767. fields = append(fields, usagestatistichour.FieldSopRun)
  30768. }
  30769. if m.addtotal_friend != nil {
  30770. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30771. }
  30772. if m.addtotal_group != nil {
  30773. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30774. }
  30775. if m.addaccount_balance != nil {
  30776. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30777. }
  30778. if m.addconsume_token != nil {
  30779. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30780. }
  30781. if m.addactive_user != nil {
  30782. fields = append(fields, usagestatistichour.FieldActiveUser)
  30783. }
  30784. if m.addnew_user != nil {
  30785. fields = append(fields, usagestatistichour.FieldNewUser)
  30786. }
  30787. return fields
  30788. }
  30789. // AddedField returns the numeric value that was incremented/decremented on a field
  30790. // with the given name. The second boolean return value indicates that this field
  30791. // was not set, or was not defined in the schema.
  30792. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30793. switch name {
  30794. case usagestatistichour.FieldStatus:
  30795. return m.AddedStatus()
  30796. case usagestatistichour.FieldAddtime:
  30797. return m.AddedAddtime()
  30798. case usagestatistichour.FieldType:
  30799. return m.AddedType()
  30800. case usagestatistichour.FieldOrganizationID:
  30801. return m.AddedOrganizationID()
  30802. case usagestatistichour.FieldAiResponse:
  30803. return m.AddedAiResponse()
  30804. case usagestatistichour.FieldSopRun:
  30805. return m.AddedSopRun()
  30806. case usagestatistichour.FieldTotalFriend:
  30807. return m.AddedTotalFriend()
  30808. case usagestatistichour.FieldTotalGroup:
  30809. return m.AddedTotalGroup()
  30810. case usagestatistichour.FieldAccountBalance:
  30811. return m.AddedAccountBalance()
  30812. case usagestatistichour.FieldConsumeToken:
  30813. return m.AddedConsumeToken()
  30814. case usagestatistichour.FieldActiveUser:
  30815. return m.AddedActiveUser()
  30816. case usagestatistichour.FieldNewUser:
  30817. return m.AddedNewUser()
  30818. }
  30819. return nil, false
  30820. }
  30821. // AddField adds the value to the field with the given name. It returns an error if
  30822. // the field is not defined in the schema, or if the type mismatched the field
  30823. // type.
  30824. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30825. switch name {
  30826. case usagestatistichour.FieldStatus:
  30827. v, ok := value.(int8)
  30828. if !ok {
  30829. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30830. }
  30831. m.AddStatus(v)
  30832. return nil
  30833. case usagestatistichour.FieldAddtime:
  30834. v, ok := value.(int64)
  30835. if !ok {
  30836. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30837. }
  30838. m.AddAddtime(v)
  30839. return nil
  30840. case usagestatistichour.FieldType:
  30841. v, ok := value.(int)
  30842. if !ok {
  30843. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30844. }
  30845. m.AddType(v)
  30846. return nil
  30847. case usagestatistichour.FieldOrganizationID:
  30848. v, ok := value.(int64)
  30849. if !ok {
  30850. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30851. }
  30852. m.AddOrganizationID(v)
  30853. return nil
  30854. case usagestatistichour.FieldAiResponse:
  30855. v, ok := value.(int64)
  30856. if !ok {
  30857. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30858. }
  30859. m.AddAiResponse(v)
  30860. return nil
  30861. case usagestatistichour.FieldSopRun:
  30862. v, ok := value.(int64)
  30863. if !ok {
  30864. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30865. }
  30866. m.AddSopRun(v)
  30867. return nil
  30868. case usagestatistichour.FieldTotalFriend:
  30869. v, ok := value.(int64)
  30870. if !ok {
  30871. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30872. }
  30873. m.AddTotalFriend(v)
  30874. return nil
  30875. case usagestatistichour.FieldTotalGroup:
  30876. v, ok := value.(int64)
  30877. if !ok {
  30878. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30879. }
  30880. m.AddTotalGroup(v)
  30881. return nil
  30882. case usagestatistichour.FieldAccountBalance:
  30883. v, ok := value.(int64)
  30884. if !ok {
  30885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30886. }
  30887. m.AddAccountBalance(v)
  30888. return nil
  30889. case usagestatistichour.FieldConsumeToken:
  30890. v, ok := value.(int64)
  30891. if !ok {
  30892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30893. }
  30894. m.AddConsumeToken(v)
  30895. return nil
  30896. case usagestatistichour.FieldActiveUser:
  30897. v, ok := value.(int64)
  30898. if !ok {
  30899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30900. }
  30901. m.AddActiveUser(v)
  30902. return nil
  30903. case usagestatistichour.FieldNewUser:
  30904. v, ok := value.(int64)
  30905. if !ok {
  30906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30907. }
  30908. m.AddNewUser(v)
  30909. return nil
  30910. }
  30911. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  30912. }
  30913. // ClearedFields returns all nullable fields that were cleared during this
  30914. // mutation.
  30915. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  30916. var fields []string
  30917. if m.FieldCleared(usagestatistichour.FieldStatus) {
  30918. fields = append(fields, usagestatistichour.FieldStatus)
  30919. }
  30920. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  30921. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30922. }
  30923. if m.FieldCleared(usagestatistichour.FieldBotID) {
  30924. fields = append(fields, usagestatistichour.FieldBotID)
  30925. }
  30926. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  30927. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30928. }
  30929. return fields
  30930. }
  30931. // FieldCleared returns a boolean indicating if a field with the given name was
  30932. // cleared in this mutation.
  30933. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  30934. _, ok := m.clearedFields[name]
  30935. return ok
  30936. }
  30937. // ClearField clears the value of the field with the given name. It returns an
  30938. // error if the field is not defined in the schema.
  30939. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  30940. switch name {
  30941. case usagestatistichour.FieldStatus:
  30942. m.ClearStatus()
  30943. return nil
  30944. case usagestatistichour.FieldDeletedAt:
  30945. m.ClearDeletedAt()
  30946. return nil
  30947. case usagestatistichour.FieldBotID:
  30948. m.ClearBotID()
  30949. return nil
  30950. case usagestatistichour.FieldOrganizationID:
  30951. m.ClearOrganizationID()
  30952. return nil
  30953. }
  30954. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  30955. }
  30956. // ResetField resets all changes in the mutation for the field with the given name.
  30957. // It returns an error if the field is not defined in the schema.
  30958. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  30959. switch name {
  30960. case usagestatistichour.FieldCreatedAt:
  30961. m.ResetCreatedAt()
  30962. return nil
  30963. case usagestatistichour.FieldUpdatedAt:
  30964. m.ResetUpdatedAt()
  30965. return nil
  30966. case usagestatistichour.FieldStatus:
  30967. m.ResetStatus()
  30968. return nil
  30969. case usagestatistichour.FieldDeletedAt:
  30970. m.ResetDeletedAt()
  30971. return nil
  30972. case usagestatistichour.FieldAddtime:
  30973. m.ResetAddtime()
  30974. return nil
  30975. case usagestatistichour.FieldType:
  30976. m.ResetType()
  30977. return nil
  30978. case usagestatistichour.FieldBotID:
  30979. m.ResetBotID()
  30980. return nil
  30981. case usagestatistichour.FieldOrganizationID:
  30982. m.ResetOrganizationID()
  30983. return nil
  30984. case usagestatistichour.FieldAiResponse:
  30985. m.ResetAiResponse()
  30986. return nil
  30987. case usagestatistichour.FieldSopRun:
  30988. m.ResetSopRun()
  30989. return nil
  30990. case usagestatistichour.FieldTotalFriend:
  30991. m.ResetTotalFriend()
  30992. return nil
  30993. case usagestatistichour.FieldTotalGroup:
  30994. m.ResetTotalGroup()
  30995. return nil
  30996. case usagestatistichour.FieldAccountBalance:
  30997. m.ResetAccountBalance()
  30998. return nil
  30999. case usagestatistichour.FieldConsumeToken:
  31000. m.ResetConsumeToken()
  31001. return nil
  31002. case usagestatistichour.FieldActiveUser:
  31003. m.ResetActiveUser()
  31004. return nil
  31005. case usagestatistichour.FieldNewUser:
  31006. m.ResetNewUser()
  31007. return nil
  31008. case usagestatistichour.FieldLabelDist:
  31009. m.ResetLabelDist()
  31010. return nil
  31011. }
  31012. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31013. }
  31014. // AddedEdges returns all edge names that were set/added in this mutation.
  31015. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31016. edges := make([]string, 0, 0)
  31017. return edges
  31018. }
  31019. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31020. // name in this mutation.
  31021. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31022. return nil
  31023. }
  31024. // RemovedEdges returns all edge names that were removed in this mutation.
  31025. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31026. edges := make([]string, 0, 0)
  31027. return edges
  31028. }
  31029. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31030. // the given name in this mutation.
  31031. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31032. return nil
  31033. }
  31034. // ClearedEdges returns all edge names that were cleared in this mutation.
  31035. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31036. edges := make([]string, 0, 0)
  31037. return edges
  31038. }
  31039. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31040. // was cleared in this mutation.
  31041. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31042. return false
  31043. }
  31044. // ClearEdge clears the value of the edge with the given name. It returns an error
  31045. // if that edge is not defined in the schema.
  31046. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31047. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31048. }
  31049. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31050. // It returns an error if the edge is not defined in the schema.
  31051. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31052. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31053. }
  31054. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31055. type UsageStatisticMonthMutation struct {
  31056. config
  31057. op Op
  31058. typ string
  31059. id *uint64
  31060. created_at *time.Time
  31061. updated_at *time.Time
  31062. status *uint8
  31063. addstatus *int8
  31064. deleted_at *time.Time
  31065. addtime *uint64
  31066. addaddtime *int64
  31067. _type *int
  31068. add_type *int
  31069. bot_id *string
  31070. organization_id *uint64
  31071. addorganization_id *int64
  31072. ai_response *uint64
  31073. addai_response *int64
  31074. sop_run *uint64
  31075. addsop_run *int64
  31076. total_friend *uint64
  31077. addtotal_friend *int64
  31078. total_group *uint64
  31079. addtotal_group *int64
  31080. account_balance *uint64
  31081. addaccount_balance *int64
  31082. consume_token *uint64
  31083. addconsume_token *int64
  31084. active_user *uint64
  31085. addactive_user *int64
  31086. new_user *int64
  31087. addnew_user *int64
  31088. label_dist *[]custom_types.LabelDist
  31089. appendlabel_dist []custom_types.LabelDist
  31090. clearedFields map[string]struct{}
  31091. done bool
  31092. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31093. predicates []predicate.UsageStatisticMonth
  31094. }
  31095. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31096. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31097. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31098. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31099. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31100. m := &UsageStatisticMonthMutation{
  31101. config: c,
  31102. op: op,
  31103. typ: TypeUsageStatisticMonth,
  31104. clearedFields: make(map[string]struct{}),
  31105. }
  31106. for _, opt := range opts {
  31107. opt(m)
  31108. }
  31109. return m
  31110. }
  31111. // withUsageStatisticMonthID sets the ID field of the mutation.
  31112. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31113. return func(m *UsageStatisticMonthMutation) {
  31114. var (
  31115. err error
  31116. once sync.Once
  31117. value *UsageStatisticMonth
  31118. )
  31119. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31120. once.Do(func() {
  31121. if m.done {
  31122. err = errors.New("querying old values post mutation is not allowed")
  31123. } else {
  31124. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31125. }
  31126. })
  31127. return value, err
  31128. }
  31129. m.id = &id
  31130. }
  31131. }
  31132. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31133. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31134. return func(m *UsageStatisticMonthMutation) {
  31135. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31136. return node, nil
  31137. }
  31138. m.id = &node.ID
  31139. }
  31140. }
  31141. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31142. // executed in a transaction (ent.Tx), a transactional client is returned.
  31143. func (m UsageStatisticMonthMutation) Client() *Client {
  31144. client := &Client{config: m.config}
  31145. client.init()
  31146. return client
  31147. }
  31148. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31149. // it returns an error otherwise.
  31150. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31151. if _, ok := m.driver.(*txDriver); !ok {
  31152. return nil, errors.New("ent: mutation is not running in a transaction")
  31153. }
  31154. tx := &Tx{config: m.config}
  31155. tx.init()
  31156. return tx, nil
  31157. }
  31158. // SetID sets the value of the id field. Note that this
  31159. // operation is only accepted on creation of UsageStatisticMonth entities.
  31160. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31161. m.id = &id
  31162. }
  31163. // ID returns the ID value in the mutation. Note that the ID is only available
  31164. // if it was provided to the builder or after it was returned from the database.
  31165. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31166. if m.id == nil {
  31167. return
  31168. }
  31169. return *m.id, true
  31170. }
  31171. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31172. // That means, if the mutation is applied within a transaction with an isolation level such
  31173. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31174. // or updated by the mutation.
  31175. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31176. switch {
  31177. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31178. id, exists := m.ID()
  31179. if exists {
  31180. return []uint64{id}, nil
  31181. }
  31182. fallthrough
  31183. case m.op.Is(OpUpdate | OpDelete):
  31184. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31185. default:
  31186. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31187. }
  31188. }
  31189. // SetCreatedAt sets the "created_at" field.
  31190. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31191. m.created_at = &t
  31192. }
  31193. // CreatedAt returns the value of the "created_at" field in the mutation.
  31194. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31195. v := m.created_at
  31196. if v == nil {
  31197. return
  31198. }
  31199. return *v, true
  31200. }
  31201. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31202. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31203. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31204. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31205. if !m.op.Is(OpUpdateOne) {
  31206. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31207. }
  31208. if m.id == nil || m.oldValue == nil {
  31209. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31210. }
  31211. oldValue, err := m.oldValue(ctx)
  31212. if err != nil {
  31213. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31214. }
  31215. return oldValue.CreatedAt, nil
  31216. }
  31217. // ResetCreatedAt resets all changes to the "created_at" field.
  31218. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31219. m.created_at = nil
  31220. }
  31221. // SetUpdatedAt sets the "updated_at" field.
  31222. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31223. m.updated_at = &t
  31224. }
  31225. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31226. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31227. v := m.updated_at
  31228. if v == nil {
  31229. return
  31230. }
  31231. return *v, true
  31232. }
  31233. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31234. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31236. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31237. if !m.op.Is(OpUpdateOne) {
  31238. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31239. }
  31240. if m.id == nil || m.oldValue == nil {
  31241. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31242. }
  31243. oldValue, err := m.oldValue(ctx)
  31244. if err != nil {
  31245. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31246. }
  31247. return oldValue.UpdatedAt, nil
  31248. }
  31249. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31250. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31251. m.updated_at = nil
  31252. }
  31253. // SetStatus sets the "status" field.
  31254. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31255. m.status = &u
  31256. m.addstatus = nil
  31257. }
  31258. // Status returns the value of the "status" field in the mutation.
  31259. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31260. v := m.status
  31261. if v == nil {
  31262. return
  31263. }
  31264. return *v, true
  31265. }
  31266. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31267. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31269. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31270. if !m.op.Is(OpUpdateOne) {
  31271. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31272. }
  31273. if m.id == nil || m.oldValue == nil {
  31274. return v, errors.New("OldStatus requires an ID field in the mutation")
  31275. }
  31276. oldValue, err := m.oldValue(ctx)
  31277. if err != nil {
  31278. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31279. }
  31280. return oldValue.Status, nil
  31281. }
  31282. // AddStatus adds u to the "status" field.
  31283. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31284. if m.addstatus != nil {
  31285. *m.addstatus += u
  31286. } else {
  31287. m.addstatus = &u
  31288. }
  31289. }
  31290. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31291. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31292. v := m.addstatus
  31293. if v == nil {
  31294. return
  31295. }
  31296. return *v, true
  31297. }
  31298. // ClearStatus clears the value of the "status" field.
  31299. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31300. m.status = nil
  31301. m.addstatus = nil
  31302. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31303. }
  31304. // StatusCleared returns if the "status" field was cleared in this mutation.
  31305. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31306. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31307. return ok
  31308. }
  31309. // ResetStatus resets all changes to the "status" field.
  31310. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31311. m.status = nil
  31312. m.addstatus = nil
  31313. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31314. }
  31315. // SetDeletedAt sets the "deleted_at" field.
  31316. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31317. m.deleted_at = &t
  31318. }
  31319. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31320. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31321. v := m.deleted_at
  31322. if v == nil {
  31323. return
  31324. }
  31325. return *v, true
  31326. }
  31327. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31328. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31330. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31331. if !m.op.Is(OpUpdateOne) {
  31332. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31333. }
  31334. if m.id == nil || m.oldValue == nil {
  31335. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31336. }
  31337. oldValue, err := m.oldValue(ctx)
  31338. if err != nil {
  31339. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31340. }
  31341. return oldValue.DeletedAt, nil
  31342. }
  31343. // ClearDeletedAt clears the value of the "deleted_at" field.
  31344. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31345. m.deleted_at = nil
  31346. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31347. }
  31348. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31349. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31350. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31351. return ok
  31352. }
  31353. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31354. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31355. m.deleted_at = nil
  31356. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31357. }
  31358. // SetAddtime sets the "addtime" field.
  31359. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31360. m.addtime = &u
  31361. m.addaddtime = nil
  31362. }
  31363. // Addtime returns the value of the "addtime" field in the mutation.
  31364. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31365. v := m.addtime
  31366. if v == nil {
  31367. return
  31368. }
  31369. return *v, true
  31370. }
  31371. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31372. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31373. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31374. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31375. if !m.op.Is(OpUpdateOne) {
  31376. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31377. }
  31378. if m.id == nil || m.oldValue == nil {
  31379. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31380. }
  31381. oldValue, err := m.oldValue(ctx)
  31382. if err != nil {
  31383. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31384. }
  31385. return oldValue.Addtime, nil
  31386. }
  31387. // AddAddtime adds u to the "addtime" field.
  31388. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31389. if m.addaddtime != nil {
  31390. *m.addaddtime += u
  31391. } else {
  31392. m.addaddtime = &u
  31393. }
  31394. }
  31395. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31396. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31397. v := m.addaddtime
  31398. if v == nil {
  31399. return
  31400. }
  31401. return *v, true
  31402. }
  31403. // ResetAddtime resets all changes to the "addtime" field.
  31404. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31405. m.addtime = nil
  31406. m.addaddtime = nil
  31407. }
  31408. // SetType sets the "type" field.
  31409. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31410. m._type = &i
  31411. m.add_type = nil
  31412. }
  31413. // GetType returns the value of the "type" field in the mutation.
  31414. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31415. v := m._type
  31416. if v == nil {
  31417. return
  31418. }
  31419. return *v, true
  31420. }
  31421. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31422. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31423. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31424. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31425. if !m.op.Is(OpUpdateOne) {
  31426. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31427. }
  31428. if m.id == nil || m.oldValue == nil {
  31429. return v, errors.New("OldType requires an ID field in the mutation")
  31430. }
  31431. oldValue, err := m.oldValue(ctx)
  31432. if err != nil {
  31433. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31434. }
  31435. return oldValue.Type, nil
  31436. }
  31437. // AddType adds i to the "type" field.
  31438. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31439. if m.add_type != nil {
  31440. *m.add_type += i
  31441. } else {
  31442. m.add_type = &i
  31443. }
  31444. }
  31445. // AddedType returns the value that was added to the "type" field in this mutation.
  31446. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31447. v := m.add_type
  31448. if v == nil {
  31449. return
  31450. }
  31451. return *v, true
  31452. }
  31453. // ResetType resets all changes to the "type" field.
  31454. func (m *UsageStatisticMonthMutation) ResetType() {
  31455. m._type = nil
  31456. m.add_type = nil
  31457. }
  31458. // SetBotID sets the "bot_id" field.
  31459. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31460. m.bot_id = &s
  31461. }
  31462. // BotID returns the value of the "bot_id" field in the mutation.
  31463. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31464. v := m.bot_id
  31465. if v == nil {
  31466. return
  31467. }
  31468. return *v, true
  31469. }
  31470. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31471. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31473. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31474. if !m.op.Is(OpUpdateOne) {
  31475. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31476. }
  31477. if m.id == nil || m.oldValue == nil {
  31478. return v, errors.New("OldBotID requires an ID field in the mutation")
  31479. }
  31480. oldValue, err := m.oldValue(ctx)
  31481. if err != nil {
  31482. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31483. }
  31484. return oldValue.BotID, nil
  31485. }
  31486. // ClearBotID clears the value of the "bot_id" field.
  31487. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31488. m.bot_id = nil
  31489. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31490. }
  31491. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31492. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31493. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31494. return ok
  31495. }
  31496. // ResetBotID resets all changes to the "bot_id" field.
  31497. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31498. m.bot_id = nil
  31499. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31500. }
  31501. // SetOrganizationID sets the "organization_id" field.
  31502. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31503. m.organization_id = &u
  31504. m.addorganization_id = nil
  31505. }
  31506. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31507. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31508. v := m.organization_id
  31509. if v == nil {
  31510. return
  31511. }
  31512. return *v, true
  31513. }
  31514. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31515. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31516. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31517. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31518. if !m.op.Is(OpUpdateOne) {
  31519. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31520. }
  31521. if m.id == nil || m.oldValue == nil {
  31522. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31523. }
  31524. oldValue, err := m.oldValue(ctx)
  31525. if err != nil {
  31526. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31527. }
  31528. return oldValue.OrganizationID, nil
  31529. }
  31530. // AddOrganizationID adds u to the "organization_id" field.
  31531. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31532. if m.addorganization_id != nil {
  31533. *m.addorganization_id += u
  31534. } else {
  31535. m.addorganization_id = &u
  31536. }
  31537. }
  31538. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31539. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31540. v := m.addorganization_id
  31541. if v == nil {
  31542. return
  31543. }
  31544. return *v, true
  31545. }
  31546. // ClearOrganizationID clears the value of the "organization_id" field.
  31547. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31548. m.organization_id = nil
  31549. m.addorganization_id = nil
  31550. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31551. }
  31552. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31553. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31554. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31555. return ok
  31556. }
  31557. // ResetOrganizationID resets all changes to the "organization_id" field.
  31558. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31559. m.organization_id = nil
  31560. m.addorganization_id = nil
  31561. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31562. }
  31563. // SetAiResponse sets the "ai_response" field.
  31564. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31565. m.ai_response = &u
  31566. m.addai_response = nil
  31567. }
  31568. // AiResponse returns the value of the "ai_response" field in the mutation.
  31569. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31570. v := m.ai_response
  31571. if v == nil {
  31572. return
  31573. }
  31574. return *v, true
  31575. }
  31576. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31577. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31578. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31579. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31580. if !m.op.Is(OpUpdateOne) {
  31581. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31582. }
  31583. if m.id == nil || m.oldValue == nil {
  31584. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31585. }
  31586. oldValue, err := m.oldValue(ctx)
  31587. if err != nil {
  31588. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31589. }
  31590. return oldValue.AiResponse, nil
  31591. }
  31592. // AddAiResponse adds u to the "ai_response" field.
  31593. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31594. if m.addai_response != nil {
  31595. *m.addai_response += u
  31596. } else {
  31597. m.addai_response = &u
  31598. }
  31599. }
  31600. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31601. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31602. v := m.addai_response
  31603. if v == nil {
  31604. return
  31605. }
  31606. return *v, true
  31607. }
  31608. // ResetAiResponse resets all changes to the "ai_response" field.
  31609. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31610. m.ai_response = nil
  31611. m.addai_response = nil
  31612. }
  31613. // SetSopRun sets the "sop_run" field.
  31614. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31615. m.sop_run = &u
  31616. m.addsop_run = nil
  31617. }
  31618. // SopRun returns the value of the "sop_run" field in the mutation.
  31619. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31620. v := m.sop_run
  31621. if v == nil {
  31622. return
  31623. }
  31624. return *v, true
  31625. }
  31626. // OldSopRun returns the old "sop_run" 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) OldSopRun(ctx context.Context) (v uint64, err error) {
  31630. if !m.op.Is(OpUpdateOne) {
  31631. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31632. }
  31633. if m.id == nil || m.oldValue == nil {
  31634. return v, errors.New("OldSopRun 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 OldSopRun: %w", err)
  31639. }
  31640. return oldValue.SopRun, nil
  31641. }
  31642. // AddSopRun adds u to the "sop_run" field.
  31643. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31644. if m.addsop_run != nil {
  31645. *m.addsop_run += u
  31646. } else {
  31647. m.addsop_run = &u
  31648. }
  31649. }
  31650. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31651. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31652. v := m.addsop_run
  31653. if v == nil {
  31654. return
  31655. }
  31656. return *v, true
  31657. }
  31658. // ResetSopRun resets all changes to the "sop_run" field.
  31659. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31660. m.sop_run = nil
  31661. m.addsop_run = nil
  31662. }
  31663. // SetTotalFriend sets the "total_friend" field.
  31664. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31665. m.total_friend = &u
  31666. m.addtotal_friend = nil
  31667. }
  31668. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31669. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31670. v := m.total_friend
  31671. if v == nil {
  31672. return
  31673. }
  31674. return *v, true
  31675. }
  31676. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31677. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31678. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31679. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31680. if !m.op.Is(OpUpdateOne) {
  31681. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31682. }
  31683. if m.id == nil || m.oldValue == nil {
  31684. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31685. }
  31686. oldValue, err := m.oldValue(ctx)
  31687. if err != nil {
  31688. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31689. }
  31690. return oldValue.TotalFriend, nil
  31691. }
  31692. // AddTotalFriend adds u to the "total_friend" field.
  31693. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31694. if m.addtotal_friend != nil {
  31695. *m.addtotal_friend += u
  31696. } else {
  31697. m.addtotal_friend = &u
  31698. }
  31699. }
  31700. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31701. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31702. v := m.addtotal_friend
  31703. if v == nil {
  31704. return
  31705. }
  31706. return *v, true
  31707. }
  31708. // ResetTotalFriend resets all changes to the "total_friend" field.
  31709. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31710. m.total_friend = nil
  31711. m.addtotal_friend = nil
  31712. }
  31713. // SetTotalGroup sets the "total_group" field.
  31714. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31715. m.total_group = &u
  31716. m.addtotal_group = nil
  31717. }
  31718. // TotalGroup returns the value of the "total_group" field in the mutation.
  31719. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31720. v := m.total_group
  31721. if v == nil {
  31722. return
  31723. }
  31724. return *v, true
  31725. }
  31726. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31727. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31728. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31729. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31730. if !m.op.Is(OpUpdateOne) {
  31731. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31732. }
  31733. if m.id == nil || m.oldValue == nil {
  31734. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31735. }
  31736. oldValue, err := m.oldValue(ctx)
  31737. if err != nil {
  31738. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31739. }
  31740. return oldValue.TotalGroup, nil
  31741. }
  31742. // AddTotalGroup adds u to the "total_group" field.
  31743. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31744. if m.addtotal_group != nil {
  31745. *m.addtotal_group += u
  31746. } else {
  31747. m.addtotal_group = &u
  31748. }
  31749. }
  31750. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31751. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31752. v := m.addtotal_group
  31753. if v == nil {
  31754. return
  31755. }
  31756. return *v, true
  31757. }
  31758. // ResetTotalGroup resets all changes to the "total_group" field.
  31759. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31760. m.total_group = nil
  31761. m.addtotal_group = nil
  31762. }
  31763. // SetAccountBalance sets the "account_balance" field.
  31764. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31765. m.account_balance = &u
  31766. m.addaccount_balance = nil
  31767. }
  31768. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31769. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31770. v := m.account_balance
  31771. if v == nil {
  31772. return
  31773. }
  31774. return *v, true
  31775. }
  31776. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31777. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31779. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31780. if !m.op.Is(OpUpdateOne) {
  31781. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31782. }
  31783. if m.id == nil || m.oldValue == nil {
  31784. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31785. }
  31786. oldValue, err := m.oldValue(ctx)
  31787. if err != nil {
  31788. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31789. }
  31790. return oldValue.AccountBalance, nil
  31791. }
  31792. // AddAccountBalance adds u to the "account_balance" field.
  31793. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31794. if m.addaccount_balance != nil {
  31795. *m.addaccount_balance += u
  31796. } else {
  31797. m.addaccount_balance = &u
  31798. }
  31799. }
  31800. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31801. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31802. v := m.addaccount_balance
  31803. if v == nil {
  31804. return
  31805. }
  31806. return *v, true
  31807. }
  31808. // ResetAccountBalance resets all changes to the "account_balance" field.
  31809. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31810. m.account_balance = nil
  31811. m.addaccount_balance = nil
  31812. }
  31813. // SetConsumeToken sets the "consume_token" field.
  31814. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31815. m.consume_token = &u
  31816. m.addconsume_token = nil
  31817. }
  31818. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31819. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31820. v := m.consume_token
  31821. if v == nil {
  31822. return
  31823. }
  31824. return *v, true
  31825. }
  31826. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31827. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31829. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31830. if !m.op.Is(OpUpdateOne) {
  31831. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31832. }
  31833. if m.id == nil || m.oldValue == nil {
  31834. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31835. }
  31836. oldValue, err := m.oldValue(ctx)
  31837. if err != nil {
  31838. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31839. }
  31840. return oldValue.ConsumeToken, nil
  31841. }
  31842. // AddConsumeToken adds u to the "consume_token" field.
  31843. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31844. if m.addconsume_token != nil {
  31845. *m.addconsume_token += u
  31846. } else {
  31847. m.addconsume_token = &u
  31848. }
  31849. }
  31850. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31851. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31852. v := m.addconsume_token
  31853. if v == nil {
  31854. return
  31855. }
  31856. return *v, true
  31857. }
  31858. // ResetConsumeToken resets all changes to the "consume_token" field.
  31859. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31860. m.consume_token = nil
  31861. m.addconsume_token = nil
  31862. }
  31863. // SetActiveUser sets the "active_user" field.
  31864. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31865. m.active_user = &u
  31866. m.addactive_user = nil
  31867. }
  31868. // ActiveUser returns the value of the "active_user" field in the mutation.
  31869. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31870. v := m.active_user
  31871. if v == nil {
  31872. return
  31873. }
  31874. return *v, true
  31875. }
  31876. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31877. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31879. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31880. if !m.op.Is(OpUpdateOne) {
  31881. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31882. }
  31883. if m.id == nil || m.oldValue == nil {
  31884. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31885. }
  31886. oldValue, err := m.oldValue(ctx)
  31887. if err != nil {
  31888. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31889. }
  31890. return oldValue.ActiveUser, nil
  31891. }
  31892. // AddActiveUser adds u to the "active_user" field.
  31893. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  31894. if m.addactive_user != nil {
  31895. *m.addactive_user += u
  31896. } else {
  31897. m.addactive_user = &u
  31898. }
  31899. }
  31900. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31901. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  31902. v := m.addactive_user
  31903. if v == nil {
  31904. return
  31905. }
  31906. return *v, true
  31907. }
  31908. // ResetActiveUser resets all changes to the "active_user" field.
  31909. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  31910. m.active_user = nil
  31911. m.addactive_user = nil
  31912. }
  31913. // SetNewUser sets the "new_user" field.
  31914. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  31915. m.new_user = &i
  31916. m.addnew_user = nil
  31917. }
  31918. // NewUser returns the value of the "new_user" field in the mutation.
  31919. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  31920. v := m.new_user
  31921. if v == nil {
  31922. return
  31923. }
  31924. return *v, true
  31925. }
  31926. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  31927. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31928. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31929. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31930. if !m.op.Is(OpUpdateOne) {
  31931. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31932. }
  31933. if m.id == nil || m.oldValue == nil {
  31934. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31935. }
  31936. oldValue, err := m.oldValue(ctx)
  31937. if err != nil {
  31938. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31939. }
  31940. return oldValue.NewUser, nil
  31941. }
  31942. // AddNewUser adds i to the "new_user" field.
  31943. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  31944. if m.addnew_user != nil {
  31945. *m.addnew_user += i
  31946. } else {
  31947. m.addnew_user = &i
  31948. }
  31949. }
  31950. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31951. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  31952. v := m.addnew_user
  31953. if v == nil {
  31954. return
  31955. }
  31956. return *v, true
  31957. }
  31958. // ResetNewUser resets all changes to the "new_user" field.
  31959. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  31960. m.new_user = nil
  31961. m.addnew_user = nil
  31962. }
  31963. // SetLabelDist sets the "label_dist" field.
  31964. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  31965. m.label_dist = &ctd
  31966. m.appendlabel_dist = nil
  31967. }
  31968. // LabelDist returns the value of the "label_dist" field in the mutation.
  31969. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  31970. v := m.label_dist
  31971. if v == nil {
  31972. return
  31973. }
  31974. return *v, true
  31975. }
  31976. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  31977. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31978. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31979. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  31980. if !m.op.Is(OpUpdateOne) {
  31981. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  31982. }
  31983. if m.id == nil || m.oldValue == nil {
  31984. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  31985. }
  31986. oldValue, err := m.oldValue(ctx)
  31987. if err != nil {
  31988. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  31989. }
  31990. return oldValue.LabelDist, nil
  31991. }
  31992. // AppendLabelDist adds ctd to the "label_dist" field.
  31993. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  31994. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  31995. }
  31996. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  31997. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  31998. if len(m.appendlabel_dist) == 0 {
  31999. return nil, false
  32000. }
  32001. return m.appendlabel_dist, true
  32002. }
  32003. // ResetLabelDist resets all changes to the "label_dist" field.
  32004. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32005. m.label_dist = nil
  32006. m.appendlabel_dist = nil
  32007. }
  32008. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32009. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32010. m.predicates = append(m.predicates, ps...)
  32011. }
  32012. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32013. // users can use type-assertion to append predicates that do not depend on any generated package.
  32014. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32015. p := make([]predicate.UsageStatisticMonth, len(ps))
  32016. for i := range ps {
  32017. p[i] = ps[i]
  32018. }
  32019. m.Where(p...)
  32020. }
  32021. // Op returns the operation name.
  32022. func (m *UsageStatisticMonthMutation) Op() Op {
  32023. return m.op
  32024. }
  32025. // SetOp allows setting the mutation operation.
  32026. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32027. m.op = op
  32028. }
  32029. // Type returns the node type of this mutation (UsageStatisticMonth).
  32030. func (m *UsageStatisticMonthMutation) Type() string {
  32031. return m.typ
  32032. }
  32033. // Fields returns all fields that were changed during this mutation. Note that in
  32034. // order to get all numeric fields that were incremented/decremented, call
  32035. // AddedFields().
  32036. func (m *UsageStatisticMonthMutation) Fields() []string {
  32037. fields := make([]string, 0, 17)
  32038. if m.created_at != nil {
  32039. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32040. }
  32041. if m.updated_at != nil {
  32042. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32043. }
  32044. if m.status != nil {
  32045. fields = append(fields, usagestatisticmonth.FieldStatus)
  32046. }
  32047. if m.deleted_at != nil {
  32048. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32049. }
  32050. if m.addtime != nil {
  32051. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32052. }
  32053. if m._type != nil {
  32054. fields = append(fields, usagestatisticmonth.FieldType)
  32055. }
  32056. if m.bot_id != nil {
  32057. fields = append(fields, usagestatisticmonth.FieldBotID)
  32058. }
  32059. if m.organization_id != nil {
  32060. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32061. }
  32062. if m.ai_response != nil {
  32063. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32064. }
  32065. if m.sop_run != nil {
  32066. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32067. }
  32068. if m.total_friend != nil {
  32069. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32070. }
  32071. if m.total_group != nil {
  32072. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32073. }
  32074. if m.account_balance != nil {
  32075. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32076. }
  32077. if m.consume_token != nil {
  32078. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32079. }
  32080. if m.active_user != nil {
  32081. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32082. }
  32083. if m.new_user != nil {
  32084. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32085. }
  32086. if m.label_dist != nil {
  32087. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32088. }
  32089. return fields
  32090. }
  32091. // Field returns the value of a field with the given name. The second boolean
  32092. // return value indicates that this field was not set, or was not defined in the
  32093. // schema.
  32094. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32095. switch name {
  32096. case usagestatisticmonth.FieldCreatedAt:
  32097. return m.CreatedAt()
  32098. case usagestatisticmonth.FieldUpdatedAt:
  32099. return m.UpdatedAt()
  32100. case usagestatisticmonth.FieldStatus:
  32101. return m.Status()
  32102. case usagestatisticmonth.FieldDeletedAt:
  32103. return m.DeletedAt()
  32104. case usagestatisticmonth.FieldAddtime:
  32105. return m.Addtime()
  32106. case usagestatisticmonth.FieldType:
  32107. return m.GetType()
  32108. case usagestatisticmonth.FieldBotID:
  32109. return m.BotID()
  32110. case usagestatisticmonth.FieldOrganizationID:
  32111. return m.OrganizationID()
  32112. case usagestatisticmonth.FieldAiResponse:
  32113. return m.AiResponse()
  32114. case usagestatisticmonth.FieldSopRun:
  32115. return m.SopRun()
  32116. case usagestatisticmonth.FieldTotalFriend:
  32117. return m.TotalFriend()
  32118. case usagestatisticmonth.FieldTotalGroup:
  32119. return m.TotalGroup()
  32120. case usagestatisticmonth.FieldAccountBalance:
  32121. return m.AccountBalance()
  32122. case usagestatisticmonth.FieldConsumeToken:
  32123. return m.ConsumeToken()
  32124. case usagestatisticmonth.FieldActiveUser:
  32125. return m.ActiveUser()
  32126. case usagestatisticmonth.FieldNewUser:
  32127. return m.NewUser()
  32128. case usagestatisticmonth.FieldLabelDist:
  32129. return m.LabelDist()
  32130. }
  32131. return nil, false
  32132. }
  32133. // OldField returns the old value of the field from the database. An error is
  32134. // returned if the mutation operation is not UpdateOne, or the query to the
  32135. // database failed.
  32136. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32137. switch name {
  32138. case usagestatisticmonth.FieldCreatedAt:
  32139. return m.OldCreatedAt(ctx)
  32140. case usagestatisticmonth.FieldUpdatedAt:
  32141. return m.OldUpdatedAt(ctx)
  32142. case usagestatisticmonth.FieldStatus:
  32143. return m.OldStatus(ctx)
  32144. case usagestatisticmonth.FieldDeletedAt:
  32145. return m.OldDeletedAt(ctx)
  32146. case usagestatisticmonth.FieldAddtime:
  32147. return m.OldAddtime(ctx)
  32148. case usagestatisticmonth.FieldType:
  32149. return m.OldType(ctx)
  32150. case usagestatisticmonth.FieldBotID:
  32151. return m.OldBotID(ctx)
  32152. case usagestatisticmonth.FieldOrganizationID:
  32153. return m.OldOrganizationID(ctx)
  32154. case usagestatisticmonth.FieldAiResponse:
  32155. return m.OldAiResponse(ctx)
  32156. case usagestatisticmonth.FieldSopRun:
  32157. return m.OldSopRun(ctx)
  32158. case usagestatisticmonth.FieldTotalFriend:
  32159. return m.OldTotalFriend(ctx)
  32160. case usagestatisticmonth.FieldTotalGroup:
  32161. return m.OldTotalGroup(ctx)
  32162. case usagestatisticmonth.FieldAccountBalance:
  32163. return m.OldAccountBalance(ctx)
  32164. case usagestatisticmonth.FieldConsumeToken:
  32165. return m.OldConsumeToken(ctx)
  32166. case usagestatisticmonth.FieldActiveUser:
  32167. return m.OldActiveUser(ctx)
  32168. case usagestatisticmonth.FieldNewUser:
  32169. return m.OldNewUser(ctx)
  32170. case usagestatisticmonth.FieldLabelDist:
  32171. return m.OldLabelDist(ctx)
  32172. }
  32173. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32174. }
  32175. // SetField sets the value of a field with the given name. It returns an error if
  32176. // the field is not defined in the schema, or if the type mismatched the field
  32177. // type.
  32178. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32179. switch name {
  32180. case usagestatisticmonth.FieldCreatedAt:
  32181. v, ok := value.(time.Time)
  32182. if !ok {
  32183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32184. }
  32185. m.SetCreatedAt(v)
  32186. return nil
  32187. case usagestatisticmonth.FieldUpdatedAt:
  32188. v, ok := value.(time.Time)
  32189. if !ok {
  32190. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32191. }
  32192. m.SetUpdatedAt(v)
  32193. return nil
  32194. case usagestatisticmonth.FieldStatus:
  32195. v, ok := value.(uint8)
  32196. if !ok {
  32197. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32198. }
  32199. m.SetStatus(v)
  32200. return nil
  32201. case usagestatisticmonth.FieldDeletedAt:
  32202. v, ok := value.(time.Time)
  32203. if !ok {
  32204. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32205. }
  32206. m.SetDeletedAt(v)
  32207. return nil
  32208. case usagestatisticmonth.FieldAddtime:
  32209. v, ok := value.(uint64)
  32210. if !ok {
  32211. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32212. }
  32213. m.SetAddtime(v)
  32214. return nil
  32215. case usagestatisticmonth.FieldType:
  32216. v, ok := value.(int)
  32217. if !ok {
  32218. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32219. }
  32220. m.SetType(v)
  32221. return nil
  32222. case usagestatisticmonth.FieldBotID:
  32223. v, ok := value.(string)
  32224. if !ok {
  32225. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32226. }
  32227. m.SetBotID(v)
  32228. return nil
  32229. case usagestatisticmonth.FieldOrganizationID:
  32230. v, ok := value.(uint64)
  32231. if !ok {
  32232. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32233. }
  32234. m.SetOrganizationID(v)
  32235. return nil
  32236. case usagestatisticmonth.FieldAiResponse:
  32237. v, ok := value.(uint64)
  32238. if !ok {
  32239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32240. }
  32241. m.SetAiResponse(v)
  32242. return nil
  32243. case usagestatisticmonth.FieldSopRun:
  32244. v, ok := value.(uint64)
  32245. if !ok {
  32246. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32247. }
  32248. m.SetSopRun(v)
  32249. return nil
  32250. case usagestatisticmonth.FieldTotalFriend:
  32251. v, ok := value.(uint64)
  32252. if !ok {
  32253. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32254. }
  32255. m.SetTotalFriend(v)
  32256. return nil
  32257. case usagestatisticmonth.FieldTotalGroup:
  32258. v, ok := value.(uint64)
  32259. if !ok {
  32260. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32261. }
  32262. m.SetTotalGroup(v)
  32263. return nil
  32264. case usagestatisticmonth.FieldAccountBalance:
  32265. v, ok := value.(uint64)
  32266. if !ok {
  32267. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32268. }
  32269. m.SetAccountBalance(v)
  32270. return nil
  32271. case usagestatisticmonth.FieldConsumeToken:
  32272. v, ok := value.(uint64)
  32273. if !ok {
  32274. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32275. }
  32276. m.SetConsumeToken(v)
  32277. return nil
  32278. case usagestatisticmonth.FieldActiveUser:
  32279. v, ok := value.(uint64)
  32280. if !ok {
  32281. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32282. }
  32283. m.SetActiveUser(v)
  32284. return nil
  32285. case usagestatisticmonth.FieldNewUser:
  32286. v, ok := value.(int64)
  32287. if !ok {
  32288. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32289. }
  32290. m.SetNewUser(v)
  32291. return nil
  32292. case usagestatisticmonth.FieldLabelDist:
  32293. v, ok := value.([]custom_types.LabelDist)
  32294. if !ok {
  32295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32296. }
  32297. m.SetLabelDist(v)
  32298. return nil
  32299. }
  32300. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32301. }
  32302. // AddedFields returns all numeric fields that were incremented/decremented during
  32303. // this mutation.
  32304. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32305. var fields []string
  32306. if m.addstatus != nil {
  32307. fields = append(fields, usagestatisticmonth.FieldStatus)
  32308. }
  32309. if m.addaddtime != nil {
  32310. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32311. }
  32312. if m.add_type != nil {
  32313. fields = append(fields, usagestatisticmonth.FieldType)
  32314. }
  32315. if m.addorganization_id != nil {
  32316. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32317. }
  32318. if m.addai_response != nil {
  32319. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32320. }
  32321. if m.addsop_run != nil {
  32322. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32323. }
  32324. if m.addtotal_friend != nil {
  32325. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32326. }
  32327. if m.addtotal_group != nil {
  32328. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32329. }
  32330. if m.addaccount_balance != nil {
  32331. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32332. }
  32333. if m.addconsume_token != nil {
  32334. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32335. }
  32336. if m.addactive_user != nil {
  32337. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32338. }
  32339. if m.addnew_user != nil {
  32340. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32341. }
  32342. return fields
  32343. }
  32344. // AddedField returns the numeric value that was incremented/decremented on a field
  32345. // with the given name. The second boolean return value indicates that this field
  32346. // was not set, or was not defined in the schema.
  32347. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32348. switch name {
  32349. case usagestatisticmonth.FieldStatus:
  32350. return m.AddedStatus()
  32351. case usagestatisticmonth.FieldAddtime:
  32352. return m.AddedAddtime()
  32353. case usagestatisticmonth.FieldType:
  32354. return m.AddedType()
  32355. case usagestatisticmonth.FieldOrganizationID:
  32356. return m.AddedOrganizationID()
  32357. case usagestatisticmonth.FieldAiResponse:
  32358. return m.AddedAiResponse()
  32359. case usagestatisticmonth.FieldSopRun:
  32360. return m.AddedSopRun()
  32361. case usagestatisticmonth.FieldTotalFriend:
  32362. return m.AddedTotalFriend()
  32363. case usagestatisticmonth.FieldTotalGroup:
  32364. return m.AddedTotalGroup()
  32365. case usagestatisticmonth.FieldAccountBalance:
  32366. return m.AddedAccountBalance()
  32367. case usagestatisticmonth.FieldConsumeToken:
  32368. return m.AddedConsumeToken()
  32369. case usagestatisticmonth.FieldActiveUser:
  32370. return m.AddedActiveUser()
  32371. case usagestatisticmonth.FieldNewUser:
  32372. return m.AddedNewUser()
  32373. }
  32374. return nil, false
  32375. }
  32376. // AddField adds the value to the field with the given name. It returns an error if
  32377. // the field is not defined in the schema, or if the type mismatched the field
  32378. // type.
  32379. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32380. switch name {
  32381. case usagestatisticmonth.FieldStatus:
  32382. v, ok := value.(int8)
  32383. if !ok {
  32384. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32385. }
  32386. m.AddStatus(v)
  32387. return nil
  32388. case usagestatisticmonth.FieldAddtime:
  32389. v, ok := value.(int64)
  32390. if !ok {
  32391. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32392. }
  32393. m.AddAddtime(v)
  32394. return nil
  32395. case usagestatisticmonth.FieldType:
  32396. v, ok := value.(int)
  32397. if !ok {
  32398. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32399. }
  32400. m.AddType(v)
  32401. return nil
  32402. case usagestatisticmonth.FieldOrganizationID:
  32403. v, ok := value.(int64)
  32404. if !ok {
  32405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32406. }
  32407. m.AddOrganizationID(v)
  32408. return nil
  32409. case usagestatisticmonth.FieldAiResponse:
  32410. v, ok := value.(int64)
  32411. if !ok {
  32412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32413. }
  32414. m.AddAiResponse(v)
  32415. return nil
  32416. case usagestatisticmonth.FieldSopRun:
  32417. v, ok := value.(int64)
  32418. if !ok {
  32419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32420. }
  32421. m.AddSopRun(v)
  32422. return nil
  32423. case usagestatisticmonth.FieldTotalFriend:
  32424. v, ok := value.(int64)
  32425. if !ok {
  32426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32427. }
  32428. m.AddTotalFriend(v)
  32429. return nil
  32430. case usagestatisticmonth.FieldTotalGroup:
  32431. v, ok := value.(int64)
  32432. if !ok {
  32433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32434. }
  32435. m.AddTotalGroup(v)
  32436. return nil
  32437. case usagestatisticmonth.FieldAccountBalance:
  32438. v, ok := value.(int64)
  32439. if !ok {
  32440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32441. }
  32442. m.AddAccountBalance(v)
  32443. return nil
  32444. case usagestatisticmonth.FieldConsumeToken:
  32445. v, ok := value.(int64)
  32446. if !ok {
  32447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32448. }
  32449. m.AddConsumeToken(v)
  32450. return nil
  32451. case usagestatisticmonth.FieldActiveUser:
  32452. v, ok := value.(int64)
  32453. if !ok {
  32454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32455. }
  32456. m.AddActiveUser(v)
  32457. return nil
  32458. case usagestatisticmonth.FieldNewUser:
  32459. v, ok := value.(int64)
  32460. if !ok {
  32461. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32462. }
  32463. m.AddNewUser(v)
  32464. return nil
  32465. }
  32466. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32467. }
  32468. // ClearedFields returns all nullable fields that were cleared during this
  32469. // mutation.
  32470. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32471. var fields []string
  32472. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32473. fields = append(fields, usagestatisticmonth.FieldStatus)
  32474. }
  32475. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32476. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32477. }
  32478. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32479. fields = append(fields, usagestatisticmonth.FieldBotID)
  32480. }
  32481. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32482. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32483. }
  32484. return fields
  32485. }
  32486. // FieldCleared returns a boolean indicating if a field with the given name was
  32487. // cleared in this mutation.
  32488. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32489. _, ok := m.clearedFields[name]
  32490. return ok
  32491. }
  32492. // ClearField clears the value of the field with the given name. It returns an
  32493. // error if the field is not defined in the schema.
  32494. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32495. switch name {
  32496. case usagestatisticmonth.FieldStatus:
  32497. m.ClearStatus()
  32498. return nil
  32499. case usagestatisticmonth.FieldDeletedAt:
  32500. m.ClearDeletedAt()
  32501. return nil
  32502. case usagestatisticmonth.FieldBotID:
  32503. m.ClearBotID()
  32504. return nil
  32505. case usagestatisticmonth.FieldOrganizationID:
  32506. m.ClearOrganizationID()
  32507. return nil
  32508. }
  32509. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32510. }
  32511. // ResetField resets all changes in the mutation for the field with the given name.
  32512. // It returns an error if the field is not defined in the schema.
  32513. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32514. switch name {
  32515. case usagestatisticmonth.FieldCreatedAt:
  32516. m.ResetCreatedAt()
  32517. return nil
  32518. case usagestatisticmonth.FieldUpdatedAt:
  32519. m.ResetUpdatedAt()
  32520. return nil
  32521. case usagestatisticmonth.FieldStatus:
  32522. m.ResetStatus()
  32523. return nil
  32524. case usagestatisticmonth.FieldDeletedAt:
  32525. m.ResetDeletedAt()
  32526. return nil
  32527. case usagestatisticmonth.FieldAddtime:
  32528. m.ResetAddtime()
  32529. return nil
  32530. case usagestatisticmonth.FieldType:
  32531. m.ResetType()
  32532. return nil
  32533. case usagestatisticmonth.FieldBotID:
  32534. m.ResetBotID()
  32535. return nil
  32536. case usagestatisticmonth.FieldOrganizationID:
  32537. m.ResetOrganizationID()
  32538. return nil
  32539. case usagestatisticmonth.FieldAiResponse:
  32540. m.ResetAiResponse()
  32541. return nil
  32542. case usagestatisticmonth.FieldSopRun:
  32543. m.ResetSopRun()
  32544. return nil
  32545. case usagestatisticmonth.FieldTotalFriend:
  32546. m.ResetTotalFriend()
  32547. return nil
  32548. case usagestatisticmonth.FieldTotalGroup:
  32549. m.ResetTotalGroup()
  32550. return nil
  32551. case usagestatisticmonth.FieldAccountBalance:
  32552. m.ResetAccountBalance()
  32553. return nil
  32554. case usagestatisticmonth.FieldConsumeToken:
  32555. m.ResetConsumeToken()
  32556. return nil
  32557. case usagestatisticmonth.FieldActiveUser:
  32558. m.ResetActiveUser()
  32559. return nil
  32560. case usagestatisticmonth.FieldNewUser:
  32561. m.ResetNewUser()
  32562. return nil
  32563. case usagestatisticmonth.FieldLabelDist:
  32564. m.ResetLabelDist()
  32565. return nil
  32566. }
  32567. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32568. }
  32569. // AddedEdges returns all edge names that were set/added in this mutation.
  32570. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32571. edges := make([]string, 0, 0)
  32572. return edges
  32573. }
  32574. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32575. // name in this mutation.
  32576. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32577. return nil
  32578. }
  32579. // RemovedEdges returns all edge names that were removed in this mutation.
  32580. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32581. edges := make([]string, 0, 0)
  32582. return edges
  32583. }
  32584. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32585. // the given name in this mutation.
  32586. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32587. return nil
  32588. }
  32589. // ClearedEdges returns all edge names that were cleared in this mutation.
  32590. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32591. edges := make([]string, 0, 0)
  32592. return edges
  32593. }
  32594. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32595. // was cleared in this mutation.
  32596. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32597. return false
  32598. }
  32599. // ClearEdge clears the value of the edge with the given name. It returns an error
  32600. // if that edge is not defined in the schema.
  32601. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32602. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32603. }
  32604. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32605. // It returns an error if the edge is not defined in the schema.
  32606. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32607. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32608. }
  32609. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32610. type UsageTotalMutation struct {
  32611. config
  32612. op Op
  32613. typ string
  32614. id *uint64
  32615. created_at *time.Time
  32616. updated_at *time.Time
  32617. status *uint8
  32618. addstatus *int8
  32619. _type *int
  32620. add_type *int
  32621. bot_id *string
  32622. total_tokens *uint64
  32623. addtotal_tokens *int64
  32624. start_index *uint64
  32625. addstart_index *int64
  32626. end_index *uint64
  32627. addend_index *int64
  32628. organization_id *uint64
  32629. addorganization_id *int64
  32630. clearedFields map[string]struct{}
  32631. done bool
  32632. oldValue func(context.Context) (*UsageTotal, error)
  32633. predicates []predicate.UsageTotal
  32634. }
  32635. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32636. // usagetotalOption allows management of the mutation configuration using functional options.
  32637. type usagetotalOption func(*UsageTotalMutation)
  32638. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32639. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32640. m := &UsageTotalMutation{
  32641. config: c,
  32642. op: op,
  32643. typ: TypeUsageTotal,
  32644. clearedFields: make(map[string]struct{}),
  32645. }
  32646. for _, opt := range opts {
  32647. opt(m)
  32648. }
  32649. return m
  32650. }
  32651. // withUsageTotalID sets the ID field of the mutation.
  32652. func withUsageTotalID(id uint64) usagetotalOption {
  32653. return func(m *UsageTotalMutation) {
  32654. var (
  32655. err error
  32656. once sync.Once
  32657. value *UsageTotal
  32658. )
  32659. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32660. once.Do(func() {
  32661. if m.done {
  32662. err = errors.New("querying old values post mutation is not allowed")
  32663. } else {
  32664. value, err = m.Client().UsageTotal.Get(ctx, id)
  32665. }
  32666. })
  32667. return value, err
  32668. }
  32669. m.id = &id
  32670. }
  32671. }
  32672. // withUsageTotal sets the old UsageTotal of the mutation.
  32673. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32674. return func(m *UsageTotalMutation) {
  32675. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32676. return node, nil
  32677. }
  32678. m.id = &node.ID
  32679. }
  32680. }
  32681. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32682. // executed in a transaction (ent.Tx), a transactional client is returned.
  32683. func (m UsageTotalMutation) Client() *Client {
  32684. client := &Client{config: m.config}
  32685. client.init()
  32686. return client
  32687. }
  32688. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32689. // it returns an error otherwise.
  32690. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32691. if _, ok := m.driver.(*txDriver); !ok {
  32692. return nil, errors.New("ent: mutation is not running in a transaction")
  32693. }
  32694. tx := &Tx{config: m.config}
  32695. tx.init()
  32696. return tx, nil
  32697. }
  32698. // SetID sets the value of the id field. Note that this
  32699. // operation is only accepted on creation of UsageTotal entities.
  32700. func (m *UsageTotalMutation) SetID(id uint64) {
  32701. m.id = &id
  32702. }
  32703. // ID returns the ID value in the mutation. Note that the ID is only available
  32704. // if it was provided to the builder or after it was returned from the database.
  32705. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32706. if m.id == nil {
  32707. return
  32708. }
  32709. return *m.id, true
  32710. }
  32711. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32712. // That means, if the mutation is applied within a transaction with an isolation level such
  32713. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32714. // or updated by the mutation.
  32715. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32716. switch {
  32717. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32718. id, exists := m.ID()
  32719. if exists {
  32720. return []uint64{id}, nil
  32721. }
  32722. fallthrough
  32723. case m.op.Is(OpUpdate | OpDelete):
  32724. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32725. default:
  32726. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32727. }
  32728. }
  32729. // SetCreatedAt sets the "created_at" field.
  32730. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32731. m.created_at = &t
  32732. }
  32733. // CreatedAt returns the value of the "created_at" field in the mutation.
  32734. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32735. v := m.created_at
  32736. if v == nil {
  32737. return
  32738. }
  32739. return *v, true
  32740. }
  32741. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32742. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32744. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32745. if !m.op.Is(OpUpdateOne) {
  32746. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32747. }
  32748. if m.id == nil || m.oldValue == nil {
  32749. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32750. }
  32751. oldValue, err := m.oldValue(ctx)
  32752. if err != nil {
  32753. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32754. }
  32755. return oldValue.CreatedAt, nil
  32756. }
  32757. // ResetCreatedAt resets all changes to the "created_at" field.
  32758. func (m *UsageTotalMutation) ResetCreatedAt() {
  32759. m.created_at = nil
  32760. }
  32761. // SetUpdatedAt sets the "updated_at" field.
  32762. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32763. m.updated_at = &t
  32764. }
  32765. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32766. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32767. v := m.updated_at
  32768. if v == nil {
  32769. return
  32770. }
  32771. return *v, true
  32772. }
  32773. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32774. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32776. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32777. if !m.op.Is(OpUpdateOne) {
  32778. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32779. }
  32780. if m.id == nil || m.oldValue == nil {
  32781. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32782. }
  32783. oldValue, err := m.oldValue(ctx)
  32784. if err != nil {
  32785. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32786. }
  32787. return oldValue.UpdatedAt, nil
  32788. }
  32789. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32790. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32791. m.updated_at = nil
  32792. }
  32793. // SetStatus sets the "status" field.
  32794. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32795. m.status = &u
  32796. m.addstatus = nil
  32797. }
  32798. // Status returns the value of the "status" field in the mutation.
  32799. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32800. v := m.status
  32801. if v == nil {
  32802. return
  32803. }
  32804. return *v, true
  32805. }
  32806. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32807. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32809. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32810. if !m.op.Is(OpUpdateOne) {
  32811. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32812. }
  32813. if m.id == nil || m.oldValue == nil {
  32814. return v, errors.New("OldStatus requires an ID field in the mutation")
  32815. }
  32816. oldValue, err := m.oldValue(ctx)
  32817. if err != nil {
  32818. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32819. }
  32820. return oldValue.Status, nil
  32821. }
  32822. // AddStatus adds u to the "status" field.
  32823. func (m *UsageTotalMutation) AddStatus(u int8) {
  32824. if m.addstatus != nil {
  32825. *m.addstatus += u
  32826. } else {
  32827. m.addstatus = &u
  32828. }
  32829. }
  32830. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32831. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32832. v := m.addstatus
  32833. if v == nil {
  32834. return
  32835. }
  32836. return *v, true
  32837. }
  32838. // ClearStatus clears the value of the "status" field.
  32839. func (m *UsageTotalMutation) ClearStatus() {
  32840. m.status = nil
  32841. m.addstatus = nil
  32842. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32843. }
  32844. // StatusCleared returns if the "status" field was cleared in this mutation.
  32845. func (m *UsageTotalMutation) StatusCleared() bool {
  32846. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32847. return ok
  32848. }
  32849. // ResetStatus resets all changes to the "status" field.
  32850. func (m *UsageTotalMutation) ResetStatus() {
  32851. m.status = nil
  32852. m.addstatus = nil
  32853. delete(m.clearedFields, usagetotal.FieldStatus)
  32854. }
  32855. // SetType sets the "type" field.
  32856. func (m *UsageTotalMutation) SetType(i int) {
  32857. m._type = &i
  32858. m.add_type = nil
  32859. }
  32860. // GetType returns the value of the "type" field in the mutation.
  32861. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32862. v := m._type
  32863. if v == nil {
  32864. return
  32865. }
  32866. return *v, true
  32867. }
  32868. // OldType returns the old "type" field's value of the UsageTotal entity.
  32869. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32870. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32871. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32872. if !m.op.Is(OpUpdateOne) {
  32873. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32874. }
  32875. if m.id == nil || m.oldValue == nil {
  32876. return v, errors.New("OldType requires an ID field in the mutation")
  32877. }
  32878. oldValue, err := m.oldValue(ctx)
  32879. if err != nil {
  32880. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32881. }
  32882. return oldValue.Type, nil
  32883. }
  32884. // AddType adds i to the "type" field.
  32885. func (m *UsageTotalMutation) AddType(i int) {
  32886. if m.add_type != nil {
  32887. *m.add_type += i
  32888. } else {
  32889. m.add_type = &i
  32890. }
  32891. }
  32892. // AddedType returns the value that was added to the "type" field in this mutation.
  32893. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  32894. v := m.add_type
  32895. if v == nil {
  32896. return
  32897. }
  32898. return *v, true
  32899. }
  32900. // ClearType clears the value of the "type" field.
  32901. func (m *UsageTotalMutation) ClearType() {
  32902. m._type = nil
  32903. m.add_type = nil
  32904. m.clearedFields[usagetotal.FieldType] = struct{}{}
  32905. }
  32906. // TypeCleared returns if the "type" field was cleared in this mutation.
  32907. func (m *UsageTotalMutation) TypeCleared() bool {
  32908. _, ok := m.clearedFields[usagetotal.FieldType]
  32909. return ok
  32910. }
  32911. // ResetType resets all changes to the "type" field.
  32912. func (m *UsageTotalMutation) ResetType() {
  32913. m._type = nil
  32914. m.add_type = nil
  32915. delete(m.clearedFields, usagetotal.FieldType)
  32916. }
  32917. // SetBotID sets the "bot_id" field.
  32918. func (m *UsageTotalMutation) SetBotID(s string) {
  32919. m.bot_id = &s
  32920. }
  32921. // BotID returns the value of the "bot_id" field in the mutation.
  32922. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  32923. v := m.bot_id
  32924. if v == nil {
  32925. return
  32926. }
  32927. return *v, true
  32928. }
  32929. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  32930. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32931. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32932. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  32933. if !m.op.Is(OpUpdateOne) {
  32934. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32935. }
  32936. if m.id == nil || m.oldValue == nil {
  32937. return v, errors.New("OldBotID requires an ID field in the mutation")
  32938. }
  32939. oldValue, err := m.oldValue(ctx)
  32940. if err != nil {
  32941. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32942. }
  32943. return oldValue.BotID, nil
  32944. }
  32945. // ResetBotID resets all changes to the "bot_id" field.
  32946. func (m *UsageTotalMutation) ResetBotID() {
  32947. m.bot_id = nil
  32948. }
  32949. // SetTotalTokens sets the "total_tokens" field.
  32950. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  32951. m.total_tokens = &u
  32952. m.addtotal_tokens = nil
  32953. }
  32954. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  32955. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  32956. v := m.total_tokens
  32957. if v == nil {
  32958. return
  32959. }
  32960. return *v, true
  32961. }
  32962. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  32963. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32965. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  32966. if !m.op.Is(OpUpdateOne) {
  32967. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  32968. }
  32969. if m.id == nil || m.oldValue == nil {
  32970. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  32971. }
  32972. oldValue, err := m.oldValue(ctx)
  32973. if err != nil {
  32974. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  32975. }
  32976. return oldValue.TotalTokens, nil
  32977. }
  32978. // AddTotalTokens adds u to the "total_tokens" field.
  32979. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  32980. if m.addtotal_tokens != nil {
  32981. *m.addtotal_tokens += u
  32982. } else {
  32983. m.addtotal_tokens = &u
  32984. }
  32985. }
  32986. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  32987. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  32988. v := m.addtotal_tokens
  32989. if v == nil {
  32990. return
  32991. }
  32992. return *v, true
  32993. }
  32994. // ClearTotalTokens clears the value of the "total_tokens" field.
  32995. func (m *UsageTotalMutation) ClearTotalTokens() {
  32996. m.total_tokens = nil
  32997. m.addtotal_tokens = nil
  32998. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  32999. }
  33000. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33001. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33002. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33003. return ok
  33004. }
  33005. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33006. func (m *UsageTotalMutation) ResetTotalTokens() {
  33007. m.total_tokens = nil
  33008. m.addtotal_tokens = nil
  33009. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33010. }
  33011. // SetStartIndex sets the "start_index" field.
  33012. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33013. m.start_index = &u
  33014. m.addstart_index = nil
  33015. }
  33016. // StartIndex returns the value of the "start_index" field in the mutation.
  33017. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33018. v := m.start_index
  33019. if v == nil {
  33020. return
  33021. }
  33022. return *v, true
  33023. }
  33024. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33025. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33027. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33028. if !m.op.Is(OpUpdateOne) {
  33029. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33030. }
  33031. if m.id == nil || m.oldValue == nil {
  33032. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33033. }
  33034. oldValue, err := m.oldValue(ctx)
  33035. if err != nil {
  33036. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33037. }
  33038. return oldValue.StartIndex, nil
  33039. }
  33040. // AddStartIndex adds u to the "start_index" field.
  33041. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33042. if m.addstart_index != nil {
  33043. *m.addstart_index += u
  33044. } else {
  33045. m.addstart_index = &u
  33046. }
  33047. }
  33048. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33049. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33050. v := m.addstart_index
  33051. if v == nil {
  33052. return
  33053. }
  33054. return *v, true
  33055. }
  33056. // ClearStartIndex clears the value of the "start_index" field.
  33057. func (m *UsageTotalMutation) ClearStartIndex() {
  33058. m.start_index = nil
  33059. m.addstart_index = nil
  33060. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33061. }
  33062. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33063. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33064. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33065. return ok
  33066. }
  33067. // ResetStartIndex resets all changes to the "start_index" field.
  33068. func (m *UsageTotalMutation) ResetStartIndex() {
  33069. m.start_index = nil
  33070. m.addstart_index = nil
  33071. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33072. }
  33073. // SetEndIndex sets the "end_index" field.
  33074. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33075. m.end_index = &u
  33076. m.addend_index = nil
  33077. }
  33078. // EndIndex returns the value of the "end_index" field in the mutation.
  33079. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33080. v := m.end_index
  33081. if v == nil {
  33082. return
  33083. }
  33084. return *v, true
  33085. }
  33086. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33087. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33089. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33090. if !m.op.Is(OpUpdateOne) {
  33091. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33092. }
  33093. if m.id == nil || m.oldValue == nil {
  33094. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33095. }
  33096. oldValue, err := m.oldValue(ctx)
  33097. if err != nil {
  33098. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33099. }
  33100. return oldValue.EndIndex, nil
  33101. }
  33102. // AddEndIndex adds u to the "end_index" field.
  33103. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33104. if m.addend_index != nil {
  33105. *m.addend_index += u
  33106. } else {
  33107. m.addend_index = &u
  33108. }
  33109. }
  33110. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33111. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33112. v := m.addend_index
  33113. if v == nil {
  33114. return
  33115. }
  33116. return *v, true
  33117. }
  33118. // ClearEndIndex clears the value of the "end_index" field.
  33119. func (m *UsageTotalMutation) ClearEndIndex() {
  33120. m.end_index = nil
  33121. m.addend_index = nil
  33122. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33123. }
  33124. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33125. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33126. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33127. return ok
  33128. }
  33129. // ResetEndIndex resets all changes to the "end_index" field.
  33130. func (m *UsageTotalMutation) ResetEndIndex() {
  33131. m.end_index = nil
  33132. m.addend_index = nil
  33133. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33134. }
  33135. // SetOrganizationID sets the "organization_id" field.
  33136. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33137. m.organization_id = &u
  33138. m.addorganization_id = nil
  33139. }
  33140. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33141. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33142. v := m.organization_id
  33143. if v == nil {
  33144. return
  33145. }
  33146. return *v, true
  33147. }
  33148. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33149. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33150. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33151. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33152. if !m.op.Is(OpUpdateOne) {
  33153. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33154. }
  33155. if m.id == nil || m.oldValue == nil {
  33156. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33157. }
  33158. oldValue, err := m.oldValue(ctx)
  33159. if err != nil {
  33160. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33161. }
  33162. return oldValue.OrganizationID, nil
  33163. }
  33164. // AddOrganizationID adds u to the "organization_id" field.
  33165. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33166. if m.addorganization_id != nil {
  33167. *m.addorganization_id += u
  33168. } else {
  33169. m.addorganization_id = &u
  33170. }
  33171. }
  33172. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33173. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33174. v := m.addorganization_id
  33175. if v == nil {
  33176. return
  33177. }
  33178. return *v, true
  33179. }
  33180. // ClearOrganizationID clears the value of the "organization_id" field.
  33181. func (m *UsageTotalMutation) ClearOrganizationID() {
  33182. m.organization_id = nil
  33183. m.addorganization_id = nil
  33184. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33185. }
  33186. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33187. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33188. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33189. return ok
  33190. }
  33191. // ResetOrganizationID resets all changes to the "organization_id" field.
  33192. func (m *UsageTotalMutation) ResetOrganizationID() {
  33193. m.organization_id = nil
  33194. m.addorganization_id = nil
  33195. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33196. }
  33197. // Where appends a list predicates to the UsageTotalMutation builder.
  33198. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33199. m.predicates = append(m.predicates, ps...)
  33200. }
  33201. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33202. // users can use type-assertion to append predicates that do not depend on any generated package.
  33203. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33204. p := make([]predicate.UsageTotal, len(ps))
  33205. for i := range ps {
  33206. p[i] = ps[i]
  33207. }
  33208. m.Where(p...)
  33209. }
  33210. // Op returns the operation name.
  33211. func (m *UsageTotalMutation) Op() Op {
  33212. return m.op
  33213. }
  33214. // SetOp allows setting the mutation operation.
  33215. func (m *UsageTotalMutation) SetOp(op Op) {
  33216. m.op = op
  33217. }
  33218. // Type returns the node type of this mutation (UsageTotal).
  33219. func (m *UsageTotalMutation) Type() string {
  33220. return m.typ
  33221. }
  33222. // Fields returns all fields that were changed during this mutation. Note that in
  33223. // order to get all numeric fields that were incremented/decremented, call
  33224. // AddedFields().
  33225. func (m *UsageTotalMutation) Fields() []string {
  33226. fields := make([]string, 0, 9)
  33227. if m.created_at != nil {
  33228. fields = append(fields, usagetotal.FieldCreatedAt)
  33229. }
  33230. if m.updated_at != nil {
  33231. fields = append(fields, usagetotal.FieldUpdatedAt)
  33232. }
  33233. if m.status != nil {
  33234. fields = append(fields, usagetotal.FieldStatus)
  33235. }
  33236. if m._type != nil {
  33237. fields = append(fields, usagetotal.FieldType)
  33238. }
  33239. if m.bot_id != nil {
  33240. fields = append(fields, usagetotal.FieldBotID)
  33241. }
  33242. if m.total_tokens != nil {
  33243. fields = append(fields, usagetotal.FieldTotalTokens)
  33244. }
  33245. if m.start_index != nil {
  33246. fields = append(fields, usagetotal.FieldStartIndex)
  33247. }
  33248. if m.end_index != nil {
  33249. fields = append(fields, usagetotal.FieldEndIndex)
  33250. }
  33251. if m.organization_id != nil {
  33252. fields = append(fields, usagetotal.FieldOrganizationID)
  33253. }
  33254. return fields
  33255. }
  33256. // Field returns the value of a field with the given name. The second boolean
  33257. // return value indicates that this field was not set, or was not defined in the
  33258. // schema.
  33259. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33260. switch name {
  33261. case usagetotal.FieldCreatedAt:
  33262. return m.CreatedAt()
  33263. case usagetotal.FieldUpdatedAt:
  33264. return m.UpdatedAt()
  33265. case usagetotal.FieldStatus:
  33266. return m.Status()
  33267. case usagetotal.FieldType:
  33268. return m.GetType()
  33269. case usagetotal.FieldBotID:
  33270. return m.BotID()
  33271. case usagetotal.FieldTotalTokens:
  33272. return m.TotalTokens()
  33273. case usagetotal.FieldStartIndex:
  33274. return m.StartIndex()
  33275. case usagetotal.FieldEndIndex:
  33276. return m.EndIndex()
  33277. case usagetotal.FieldOrganizationID:
  33278. return m.OrganizationID()
  33279. }
  33280. return nil, false
  33281. }
  33282. // OldField returns the old value of the field from the database. An error is
  33283. // returned if the mutation operation is not UpdateOne, or the query to the
  33284. // database failed.
  33285. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33286. switch name {
  33287. case usagetotal.FieldCreatedAt:
  33288. return m.OldCreatedAt(ctx)
  33289. case usagetotal.FieldUpdatedAt:
  33290. return m.OldUpdatedAt(ctx)
  33291. case usagetotal.FieldStatus:
  33292. return m.OldStatus(ctx)
  33293. case usagetotal.FieldType:
  33294. return m.OldType(ctx)
  33295. case usagetotal.FieldBotID:
  33296. return m.OldBotID(ctx)
  33297. case usagetotal.FieldTotalTokens:
  33298. return m.OldTotalTokens(ctx)
  33299. case usagetotal.FieldStartIndex:
  33300. return m.OldStartIndex(ctx)
  33301. case usagetotal.FieldEndIndex:
  33302. return m.OldEndIndex(ctx)
  33303. case usagetotal.FieldOrganizationID:
  33304. return m.OldOrganizationID(ctx)
  33305. }
  33306. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33307. }
  33308. // SetField sets the value of a field with the given name. It returns an error if
  33309. // the field is not defined in the schema, or if the type mismatched the field
  33310. // type.
  33311. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33312. switch name {
  33313. case usagetotal.FieldCreatedAt:
  33314. v, ok := value.(time.Time)
  33315. if !ok {
  33316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33317. }
  33318. m.SetCreatedAt(v)
  33319. return nil
  33320. case usagetotal.FieldUpdatedAt:
  33321. v, ok := value.(time.Time)
  33322. if !ok {
  33323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33324. }
  33325. m.SetUpdatedAt(v)
  33326. return nil
  33327. case usagetotal.FieldStatus:
  33328. v, ok := value.(uint8)
  33329. if !ok {
  33330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33331. }
  33332. m.SetStatus(v)
  33333. return nil
  33334. case usagetotal.FieldType:
  33335. v, ok := value.(int)
  33336. if !ok {
  33337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33338. }
  33339. m.SetType(v)
  33340. return nil
  33341. case usagetotal.FieldBotID:
  33342. v, ok := value.(string)
  33343. if !ok {
  33344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33345. }
  33346. m.SetBotID(v)
  33347. return nil
  33348. case usagetotal.FieldTotalTokens:
  33349. v, ok := value.(uint64)
  33350. if !ok {
  33351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33352. }
  33353. m.SetTotalTokens(v)
  33354. return nil
  33355. case usagetotal.FieldStartIndex:
  33356. v, ok := value.(uint64)
  33357. if !ok {
  33358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33359. }
  33360. m.SetStartIndex(v)
  33361. return nil
  33362. case usagetotal.FieldEndIndex:
  33363. v, ok := value.(uint64)
  33364. if !ok {
  33365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33366. }
  33367. m.SetEndIndex(v)
  33368. return nil
  33369. case usagetotal.FieldOrganizationID:
  33370. v, ok := value.(uint64)
  33371. if !ok {
  33372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33373. }
  33374. m.SetOrganizationID(v)
  33375. return nil
  33376. }
  33377. return fmt.Errorf("unknown UsageTotal field %s", name)
  33378. }
  33379. // AddedFields returns all numeric fields that were incremented/decremented during
  33380. // this mutation.
  33381. func (m *UsageTotalMutation) AddedFields() []string {
  33382. var fields []string
  33383. if m.addstatus != nil {
  33384. fields = append(fields, usagetotal.FieldStatus)
  33385. }
  33386. if m.add_type != nil {
  33387. fields = append(fields, usagetotal.FieldType)
  33388. }
  33389. if m.addtotal_tokens != nil {
  33390. fields = append(fields, usagetotal.FieldTotalTokens)
  33391. }
  33392. if m.addstart_index != nil {
  33393. fields = append(fields, usagetotal.FieldStartIndex)
  33394. }
  33395. if m.addend_index != nil {
  33396. fields = append(fields, usagetotal.FieldEndIndex)
  33397. }
  33398. if m.addorganization_id != nil {
  33399. fields = append(fields, usagetotal.FieldOrganizationID)
  33400. }
  33401. return fields
  33402. }
  33403. // AddedField returns the numeric value that was incremented/decremented on a field
  33404. // with the given name. The second boolean return value indicates that this field
  33405. // was not set, or was not defined in the schema.
  33406. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33407. switch name {
  33408. case usagetotal.FieldStatus:
  33409. return m.AddedStatus()
  33410. case usagetotal.FieldType:
  33411. return m.AddedType()
  33412. case usagetotal.FieldTotalTokens:
  33413. return m.AddedTotalTokens()
  33414. case usagetotal.FieldStartIndex:
  33415. return m.AddedStartIndex()
  33416. case usagetotal.FieldEndIndex:
  33417. return m.AddedEndIndex()
  33418. case usagetotal.FieldOrganizationID:
  33419. return m.AddedOrganizationID()
  33420. }
  33421. return nil, false
  33422. }
  33423. // AddField adds the value to the field with the given name. It returns an error if
  33424. // the field is not defined in the schema, or if the type mismatched the field
  33425. // type.
  33426. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33427. switch name {
  33428. case usagetotal.FieldStatus:
  33429. v, ok := value.(int8)
  33430. if !ok {
  33431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33432. }
  33433. m.AddStatus(v)
  33434. return nil
  33435. case usagetotal.FieldType:
  33436. v, ok := value.(int)
  33437. if !ok {
  33438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33439. }
  33440. m.AddType(v)
  33441. return nil
  33442. case usagetotal.FieldTotalTokens:
  33443. v, ok := value.(int64)
  33444. if !ok {
  33445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33446. }
  33447. m.AddTotalTokens(v)
  33448. return nil
  33449. case usagetotal.FieldStartIndex:
  33450. v, ok := value.(int64)
  33451. if !ok {
  33452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33453. }
  33454. m.AddStartIndex(v)
  33455. return nil
  33456. case usagetotal.FieldEndIndex:
  33457. v, ok := value.(int64)
  33458. if !ok {
  33459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33460. }
  33461. m.AddEndIndex(v)
  33462. return nil
  33463. case usagetotal.FieldOrganizationID:
  33464. v, ok := value.(int64)
  33465. if !ok {
  33466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33467. }
  33468. m.AddOrganizationID(v)
  33469. return nil
  33470. }
  33471. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33472. }
  33473. // ClearedFields returns all nullable fields that were cleared during this
  33474. // mutation.
  33475. func (m *UsageTotalMutation) ClearedFields() []string {
  33476. var fields []string
  33477. if m.FieldCleared(usagetotal.FieldStatus) {
  33478. fields = append(fields, usagetotal.FieldStatus)
  33479. }
  33480. if m.FieldCleared(usagetotal.FieldType) {
  33481. fields = append(fields, usagetotal.FieldType)
  33482. }
  33483. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33484. fields = append(fields, usagetotal.FieldTotalTokens)
  33485. }
  33486. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33487. fields = append(fields, usagetotal.FieldStartIndex)
  33488. }
  33489. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33490. fields = append(fields, usagetotal.FieldEndIndex)
  33491. }
  33492. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33493. fields = append(fields, usagetotal.FieldOrganizationID)
  33494. }
  33495. return fields
  33496. }
  33497. // FieldCleared returns a boolean indicating if a field with the given name was
  33498. // cleared in this mutation.
  33499. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33500. _, ok := m.clearedFields[name]
  33501. return ok
  33502. }
  33503. // ClearField clears the value of the field with the given name. It returns an
  33504. // error if the field is not defined in the schema.
  33505. func (m *UsageTotalMutation) ClearField(name string) error {
  33506. switch name {
  33507. case usagetotal.FieldStatus:
  33508. m.ClearStatus()
  33509. return nil
  33510. case usagetotal.FieldType:
  33511. m.ClearType()
  33512. return nil
  33513. case usagetotal.FieldTotalTokens:
  33514. m.ClearTotalTokens()
  33515. return nil
  33516. case usagetotal.FieldStartIndex:
  33517. m.ClearStartIndex()
  33518. return nil
  33519. case usagetotal.FieldEndIndex:
  33520. m.ClearEndIndex()
  33521. return nil
  33522. case usagetotal.FieldOrganizationID:
  33523. m.ClearOrganizationID()
  33524. return nil
  33525. }
  33526. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33527. }
  33528. // ResetField resets all changes in the mutation for the field with the given name.
  33529. // It returns an error if the field is not defined in the schema.
  33530. func (m *UsageTotalMutation) ResetField(name string) error {
  33531. switch name {
  33532. case usagetotal.FieldCreatedAt:
  33533. m.ResetCreatedAt()
  33534. return nil
  33535. case usagetotal.FieldUpdatedAt:
  33536. m.ResetUpdatedAt()
  33537. return nil
  33538. case usagetotal.FieldStatus:
  33539. m.ResetStatus()
  33540. return nil
  33541. case usagetotal.FieldType:
  33542. m.ResetType()
  33543. return nil
  33544. case usagetotal.FieldBotID:
  33545. m.ResetBotID()
  33546. return nil
  33547. case usagetotal.FieldTotalTokens:
  33548. m.ResetTotalTokens()
  33549. return nil
  33550. case usagetotal.FieldStartIndex:
  33551. m.ResetStartIndex()
  33552. return nil
  33553. case usagetotal.FieldEndIndex:
  33554. m.ResetEndIndex()
  33555. return nil
  33556. case usagetotal.FieldOrganizationID:
  33557. m.ResetOrganizationID()
  33558. return nil
  33559. }
  33560. return fmt.Errorf("unknown UsageTotal field %s", name)
  33561. }
  33562. // AddedEdges returns all edge names that were set/added in this mutation.
  33563. func (m *UsageTotalMutation) AddedEdges() []string {
  33564. edges := make([]string, 0, 0)
  33565. return edges
  33566. }
  33567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33568. // name in this mutation.
  33569. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33570. return nil
  33571. }
  33572. // RemovedEdges returns all edge names that were removed in this mutation.
  33573. func (m *UsageTotalMutation) RemovedEdges() []string {
  33574. edges := make([]string, 0, 0)
  33575. return edges
  33576. }
  33577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33578. // the given name in this mutation.
  33579. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33580. return nil
  33581. }
  33582. // ClearedEdges returns all edge names that were cleared in this mutation.
  33583. func (m *UsageTotalMutation) ClearedEdges() []string {
  33584. edges := make([]string, 0, 0)
  33585. return edges
  33586. }
  33587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33588. // was cleared in this mutation.
  33589. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33590. return false
  33591. }
  33592. // ClearEdge clears the value of the edge with the given name. It returns an error
  33593. // if that edge is not defined in the schema.
  33594. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33595. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33596. }
  33597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33598. // It returns an error if the edge is not defined in the schema.
  33599. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33600. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33601. }
  33602. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33603. type WhatsappMutation struct {
  33604. config
  33605. op Op
  33606. typ string
  33607. id *uint64
  33608. created_at *time.Time
  33609. updated_at *time.Time
  33610. status *uint8
  33611. addstatus *int8
  33612. deleted_at *time.Time
  33613. ak *string
  33614. sk *string
  33615. callback *string
  33616. account *string
  33617. nickname *string
  33618. phone *string
  33619. organization_id *uint64
  33620. addorganization_id *int64
  33621. agent_id *uint64
  33622. addagent_id *int64
  33623. api_base *string
  33624. api_key *string
  33625. allow_list *[]string
  33626. appendallow_list []string
  33627. group_allow_list *[]string
  33628. appendgroup_allow_list []string
  33629. block_list *[]string
  33630. appendblock_list []string
  33631. group_block_list *[]string
  33632. appendgroup_block_list []string
  33633. clearedFields map[string]struct{}
  33634. done bool
  33635. oldValue func(context.Context) (*Whatsapp, error)
  33636. predicates []predicate.Whatsapp
  33637. }
  33638. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33639. // whatsappOption allows management of the mutation configuration using functional options.
  33640. type whatsappOption func(*WhatsappMutation)
  33641. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33642. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33643. m := &WhatsappMutation{
  33644. config: c,
  33645. op: op,
  33646. typ: TypeWhatsapp,
  33647. clearedFields: make(map[string]struct{}),
  33648. }
  33649. for _, opt := range opts {
  33650. opt(m)
  33651. }
  33652. return m
  33653. }
  33654. // withWhatsappID sets the ID field of the mutation.
  33655. func withWhatsappID(id uint64) whatsappOption {
  33656. return func(m *WhatsappMutation) {
  33657. var (
  33658. err error
  33659. once sync.Once
  33660. value *Whatsapp
  33661. )
  33662. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33663. once.Do(func() {
  33664. if m.done {
  33665. err = errors.New("querying old values post mutation is not allowed")
  33666. } else {
  33667. value, err = m.Client().Whatsapp.Get(ctx, id)
  33668. }
  33669. })
  33670. return value, err
  33671. }
  33672. m.id = &id
  33673. }
  33674. }
  33675. // withWhatsapp sets the old Whatsapp of the mutation.
  33676. func withWhatsapp(node *Whatsapp) whatsappOption {
  33677. return func(m *WhatsappMutation) {
  33678. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33679. return node, nil
  33680. }
  33681. m.id = &node.ID
  33682. }
  33683. }
  33684. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33685. // executed in a transaction (ent.Tx), a transactional client is returned.
  33686. func (m WhatsappMutation) Client() *Client {
  33687. client := &Client{config: m.config}
  33688. client.init()
  33689. return client
  33690. }
  33691. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33692. // it returns an error otherwise.
  33693. func (m WhatsappMutation) Tx() (*Tx, error) {
  33694. if _, ok := m.driver.(*txDriver); !ok {
  33695. return nil, errors.New("ent: mutation is not running in a transaction")
  33696. }
  33697. tx := &Tx{config: m.config}
  33698. tx.init()
  33699. return tx, nil
  33700. }
  33701. // SetID sets the value of the id field. Note that this
  33702. // operation is only accepted on creation of Whatsapp entities.
  33703. func (m *WhatsappMutation) SetID(id uint64) {
  33704. m.id = &id
  33705. }
  33706. // ID returns the ID value in the mutation. Note that the ID is only available
  33707. // if it was provided to the builder or after it was returned from the database.
  33708. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33709. if m.id == nil {
  33710. return
  33711. }
  33712. return *m.id, true
  33713. }
  33714. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33715. // That means, if the mutation is applied within a transaction with an isolation level such
  33716. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33717. // or updated by the mutation.
  33718. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33719. switch {
  33720. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33721. id, exists := m.ID()
  33722. if exists {
  33723. return []uint64{id}, nil
  33724. }
  33725. fallthrough
  33726. case m.op.Is(OpUpdate | OpDelete):
  33727. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33728. default:
  33729. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33730. }
  33731. }
  33732. // SetCreatedAt sets the "created_at" field.
  33733. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33734. m.created_at = &t
  33735. }
  33736. // CreatedAt returns the value of the "created_at" field in the mutation.
  33737. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33738. v := m.created_at
  33739. if v == nil {
  33740. return
  33741. }
  33742. return *v, true
  33743. }
  33744. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33745. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33747. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33748. if !m.op.Is(OpUpdateOne) {
  33749. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33750. }
  33751. if m.id == nil || m.oldValue == nil {
  33752. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33753. }
  33754. oldValue, err := m.oldValue(ctx)
  33755. if err != nil {
  33756. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33757. }
  33758. return oldValue.CreatedAt, nil
  33759. }
  33760. // ResetCreatedAt resets all changes to the "created_at" field.
  33761. func (m *WhatsappMutation) ResetCreatedAt() {
  33762. m.created_at = nil
  33763. }
  33764. // SetUpdatedAt sets the "updated_at" field.
  33765. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33766. m.updated_at = &t
  33767. }
  33768. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33769. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33770. v := m.updated_at
  33771. if v == nil {
  33772. return
  33773. }
  33774. return *v, true
  33775. }
  33776. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33777. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33779. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33780. if !m.op.Is(OpUpdateOne) {
  33781. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33782. }
  33783. if m.id == nil || m.oldValue == nil {
  33784. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33785. }
  33786. oldValue, err := m.oldValue(ctx)
  33787. if err != nil {
  33788. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33789. }
  33790. return oldValue.UpdatedAt, nil
  33791. }
  33792. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33793. func (m *WhatsappMutation) ResetUpdatedAt() {
  33794. m.updated_at = nil
  33795. }
  33796. // SetStatus sets the "status" field.
  33797. func (m *WhatsappMutation) SetStatus(u uint8) {
  33798. m.status = &u
  33799. m.addstatus = nil
  33800. }
  33801. // Status returns the value of the "status" field in the mutation.
  33802. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33803. v := m.status
  33804. if v == nil {
  33805. return
  33806. }
  33807. return *v, true
  33808. }
  33809. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33810. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33812. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33813. if !m.op.Is(OpUpdateOne) {
  33814. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33815. }
  33816. if m.id == nil || m.oldValue == nil {
  33817. return v, errors.New("OldStatus requires an ID field in the mutation")
  33818. }
  33819. oldValue, err := m.oldValue(ctx)
  33820. if err != nil {
  33821. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33822. }
  33823. return oldValue.Status, nil
  33824. }
  33825. // AddStatus adds u to the "status" field.
  33826. func (m *WhatsappMutation) AddStatus(u int8) {
  33827. if m.addstatus != nil {
  33828. *m.addstatus += u
  33829. } else {
  33830. m.addstatus = &u
  33831. }
  33832. }
  33833. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33834. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33835. v := m.addstatus
  33836. if v == nil {
  33837. return
  33838. }
  33839. return *v, true
  33840. }
  33841. // ClearStatus clears the value of the "status" field.
  33842. func (m *WhatsappMutation) ClearStatus() {
  33843. m.status = nil
  33844. m.addstatus = nil
  33845. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33846. }
  33847. // StatusCleared returns if the "status" field was cleared in this mutation.
  33848. func (m *WhatsappMutation) StatusCleared() bool {
  33849. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33850. return ok
  33851. }
  33852. // ResetStatus resets all changes to the "status" field.
  33853. func (m *WhatsappMutation) ResetStatus() {
  33854. m.status = nil
  33855. m.addstatus = nil
  33856. delete(m.clearedFields, whatsapp.FieldStatus)
  33857. }
  33858. // SetDeletedAt sets the "deleted_at" field.
  33859. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33860. m.deleted_at = &t
  33861. }
  33862. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33863. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33864. v := m.deleted_at
  33865. if v == nil {
  33866. return
  33867. }
  33868. return *v, true
  33869. }
  33870. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  33871. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33873. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33874. if !m.op.Is(OpUpdateOne) {
  33875. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33876. }
  33877. if m.id == nil || m.oldValue == nil {
  33878. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33879. }
  33880. oldValue, err := m.oldValue(ctx)
  33881. if err != nil {
  33882. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33883. }
  33884. return oldValue.DeletedAt, nil
  33885. }
  33886. // ClearDeletedAt clears the value of the "deleted_at" field.
  33887. func (m *WhatsappMutation) ClearDeletedAt() {
  33888. m.deleted_at = nil
  33889. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  33890. }
  33891. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33892. func (m *WhatsappMutation) DeletedAtCleared() bool {
  33893. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  33894. return ok
  33895. }
  33896. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33897. func (m *WhatsappMutation) ResetDeletedAt() {
  33898. m.deleted_at = nil
  33899. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  33900. }
  33901. // SetAk sets the "ak" field.
  33902. func (m *WhatsappMutation) SetAk(s string) {
  33903. m.ak = &s
  33904. }
  33905. // Ak returns the value of the "ak" field in the mutation.
  33906. func (m *WhatsappMutation) Ak() (r string, exists bool) {
  33907. v := m.ak
  33908. if v == nil {
  33909. return
  33910. }
  33911. return *v, true
  33912. }
  33913. // OldAk returns the old "ak" field's value of the Whatsapp entity.
  33914. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33915. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33916. func (m *WhatsappMutation) OldAk(ctx context.Context) (v string, err error) {
  33917. if !m.op.Is(OpUpdateOne) {
  33918. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  33919. }
  33920. if m.id == nil || m.oldValue == nil {
  33921. return v, errors.New("OldAk requires an ID field in the mutation")
  33922. }
  33923. oldValue, err := m.oldValue(ctx)
  33924. if err != nil {
  33925. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  33926. }
  33927. return oldValue.Ak, nil
  33928. }
  33929. // ClearAk clears the value of the "ak" field.
  33930. func (m *WhatsappMutation) ClearAk() {
  33931. m.ak = nil
  33932. m.clearedFields[whatsapp.FieldAk] = struct{}{}
  33933. }
  33934. // AkCleared returns if the "ak" field was cleared in this mutation.
  33935. func (m *WhatsappMutation) AkCleared() bool {
  33936. _, ok := m.clearedFields[whatsapp.FieldAk]
  33937. return ok
  33938. }
  33939. // ResetAk resets all changes to the "ak" field.
  33940. func (m *WhatsappMutation) ResetAk() {
  33941. m.ak = nil
  33942. delete(m.clearedFields, whatsapp.FieldAk)
  33943. }
  33944. // SetSk sets the "sk" field.
  33945. func (m *WhatsappMutation) SetSk(s string) {
  33946. m.sk = &s
  33947. }
  33948. // Sk returns the value of the "sk" field in the mutation.
  33949. func (m *WhatsappMutation) Sk() (r string, exists bool) {
  33950. v := m.sk
  33951. if v == nil {
  33952. return
  33953. }
  33954. return *v, true
  33955. }
  33956. // OldSk returns the old "sk" field's value of the Whatsapp entity.
  33957. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33958. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33959. func (m *WhatsappMutation) OldSk(ctx context.Context) (v string, err error) {
  33960. if !m.op.Is(OpUpdateOne) {
  33961. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  33962. }
  33963. if m.id == nil || m.oldValue == nil {
  33964. return v, errors.New("OldSk requires an ID field in the mutation")
  33965. }
  33966. oldValue, err := m.oldValue(ctx)
  33967. if err != nil {
  33968. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  33969. }
  33970. return oldValue.Sk, nil
  33971. }
  33972. // ResetSk resets all changes to the "sk" field.
  33973. func (m *WhatsappMutation) ResetSk() {
  33974. m.sk = nil
  33975. }
  33976. // SetCallback sets the "callback" field.
  33977. func (m *WhatsappMutation) SetCallback(s string) {
  33978. m.callback = &s
  33979. }
  33980. // Callback returns the value of the "callback" field in the mutation.
  33981. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  33982. v := m.callback
  33983. if v == nil {
  33984. return
  33985. }
  33986. return *v, true
  33987. }
  33988. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  33989. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33991. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  33992. if !m.op.Is(OpUpdateOne) {
  33993. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  33994. }
  33995. if m.id == nil || m.oldValue == nil {
  33996. return v, errors.New("OldCallback requires an ID field in the mutation")
  33997. }
  33998. oldValue, err := m.oldValue(ctx)
  33999. if err != nil {
  34000. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34001. }
  34002. return oldValue.Callback, nil
  34003. }
  34004. // ResetCallback resets all changes to the "callback" field.
  34005. func (m *WhatsappMutation) ResetCallback() {
  34006. m.callback = nil
  34007. }
  34008. // SetAccount sets the "account" field.
  34009. func (m *WhatsappMutation) SetAccount(s string) {
  34010. m.account = &s
  34011. }
  34012. // Account returns the value of the "account" field in the mutation.
  34013. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34014. v := m.account
  34015. if v == nil {
  34016. return
  34017. }
  34018. return *v, true
  34019. }
  34020. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34021. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34023. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34024. if !m.op.Is(OpUpdateOne) {
  34025. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34026. }
  34027. if m.id == nil || m.oldValue == nil {
  34028. return v, errors.New("OldAccount requires an ID field in the mutation")
  34029. }
  34030. oldValue, err := m.oldValue(ctx)
  34031. if err != nil {
  34032. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34033. }
  34034. return oldValue.Account, nil
  34035. }
  34036. // ResetAccount resets all changes to the "account" field.
  34037. func (m *WhatsappMutation) ResetAccount() {
  34038. m.account = nil
  34039. }
  34040. // SetNickname sets the "nickname" field.
  34041. func (m *WhatsappMutation) SetNickname(s string) {
  34042. m.nickname = &s
  34043. }
  34044. // Nickname returns the value of the "nickname" field in the mutation.
  34045. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34046. v := m.nickname
  34047. if v == nil {
  34048. return
  34049. }
  34050. return *v, true
  34051. }
  34052. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34053. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34055. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34056. if !m.op.Is(OpUpdateOne) {
  34057. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34058. }
  34059. if m.id == nil || m.oldValue == nil {
  34060. return v, errors.New("OldNickname requires an ID field in the mutation")
  34061. }
  34062. oldValue, err := m.oldValue(ctx)
  34063. if err != nil {
  34064. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34065. }
  34066. return oldValue.Nickname, nil
  34067. }
  34068. // ResetNickname resets all changes to the "nickname" field.
  34069. func (m *WhatsappMutation) ResetNickname() {
  34070. m.nickname = nil
  34071. }
  34072. // SetPhone sets the "phone" field.
  34073. func (m *WhatsappMutation) SetPhone(s string) {
  34074. m.phone = &s
  34075. }
  34076. // Phone returns the value of the "phone" field in the mutation.
  34077. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34078. v := m.phone
  34079. if v == nil {
  34080. return
  34081. }
  34082. return *v, true
  34083. }
  34084. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34085. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34087. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34088. if !m.op.Is(OpUpdateOne) {
  34089. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34090. }
  34091. if m.id == nil || m.oldValue == nil {
  34092. return v, errors.New("OldPhone requires an ID field in the mutation")
  34093. }
  34094. oldValue, err := m.oldValue(ctx)
  34095. if err != nil {
  34096. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34097. }
  34098. return oldValue.Phone, nil
  34099. }
  34100. // ResetPhone resets all changes to the "phone" field.
  34101. func (m *WhatsappMutation) ResetPhone() {
  34102. m.phone = nil
  34103. }
  34104. // SetOrganizationID sets the "organization_id" field.
  34105. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34106. m.organization_id = &u
  34107. m.addorganization_id = nil
  34108. }
  34109. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34110. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34111. v := m.organization_id
  34112. if v == nil {
  34113. return
  34114. }
  34115. return *v, true
  34116. }
  34117. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34118. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34120. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34121. if !m.op.Is(OpUpdateOne) {
  34122. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34123. }
  34124. if m.id == nil || m.oldValue == nil {
  34125. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34126. }
  34127. oldValue, err := m.oldValue(ctx)
  34128. if err != nil {
  34129. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34130. }
  34131. return oldValue.OrganizationID, nil
  34132. }
  34133. // AddOrganizationID adds u to the "organization_id" field.
  34134. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34135. if m.addorganization_id != nil {
  34136. *m.addorganization_id += u
  34137. } else {
  34138. m.addorganization_id = &u
  34139. }
  34140. }
  34141. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34142. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34143. v := m.addorganization_id
  34144. if v == nil {
  34145. return
  34146. }
  34147. return *v, true
  34148. }
  34149. // ClearOrganizationID clears the value of the "organization_id" field.
  34150. func (m *WhatsappMutation) ClearOrganizationID() {
  34151. m.organization_id = nil
  34152. m.addorganization_id = nil
  34153. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34154. }
  34155. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34156. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34157. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34158. return ok
  34159. }
  34160. // ResetOrganizationID resets all changes to the "organization_id" field.
  34161. func (m *WhatsappMutation) ResetOrganizationID() {
  34162. m.organization_id = nil
  34163. m.addorganization_id = nil
  34164. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34165. }
  34166. // SetAgentID sets the "agent_id" field.
  34167. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34168. m.agent_id = &u
  34169. m.addagent_id = nil
  34170. }
  34171. // AgentID returns the value of the "agent_id" field in the mutation.
  34172. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34173. v := m.agent_id
  34174. if v == nil {
  34175. return
  34176. }
  34177. return *v, true
  34178. }
  34179. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34180. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34181. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34182. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34183. if !m.op.Is(OpUpdateOne) {
  34184. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34185. }
  34186. if m.id == nil || m.oldValue == nil {
  34187. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34188. }
  34189. oldValue, err := m.oldValue(ctx)
  34190. if err != nil {
  34191. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34192. }
  34193. return oldValue.AgentID, nil
  34194. }
  34195. // AddAgentID adds u to the "agent_id" field.
  34196. func (m *WhatsappMutation) AddAgentID(u int64) {
  34197. if m.addagent_id != nil {
  34198. *m.addagent_id += u
  34199. } else {
  34200. m.addagent_id = &u
  34201. }
  34202. }
  34203. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  34204. func (m *WhatsappMutation) AddedAgentID() (r int64, exists bool) {
  34205. v := m.addagent_id
  34206. if v == nil {
  34207. return
  34208. }
  34209. return *v, true
  34210. }
  34211. // ResetAgentID resets all changes to the "agent_id" field.
  34212. func (m *WhatsappMutation) ResetAgentID() {
  34213. m.agent_id = nil
  34214. m.addagent_id = nil
  34215. }
  34216. // SetAPIBase sets the "api_base" field.
  34217. func (m *WhatsappMutation) SetAPIBase(s string) {
  34218. m.api_base = &s
  34219. }
  34220. // APIBase returns the value of the "api_base" field in the mutation.
  34221. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34222. v := m.api_base
  34223. if v == nil {
  34224. return
  34225. }
  34226. return *v, true
  34227. }
  34228. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34229. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34231. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34232. if !m.op.Is(OpUpdateOne) {
  34233. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34234. }
  34235. if m.id == nil || m.oldValue == nil {
  34236. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34237. }
  34238. oldValue, err := m.oldValue(ctx)
  34239. if err != nil {
  34240. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34241. }
  34242. return oldValue.APIBase, nil
  34243. }
  34244. // ClearAPIBase clears the value of the "api_base" field.
  34245. func (m *WhatsappMutation) ClearAPIBase() {
  34246. m.api_base = nil
  34247. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34248. }
  34249. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34250. func (m *WhatsappMutation) APIBaseCleared() bool {
  34251. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34252. return ok
  34253. }
  34254. // ResetAPIBase resets all changes to the "api_base" field.
  34255. func (m *WhatsappMutation) ResetAPIBase() {
  34256. m.api_base = nil
  34257. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34258. }
  34259. // SetAPIKey sets the "api_key" field.
  34260. func (m *WhatsappMutation) SetAPIKey(s string) {
  34261. m.api_key = &s
  34262. }
  34263. // APIKey returns the value of the "api_key" field in the mutation.
  34264. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34265. v := m.api_key
  34266. if v == nil {
  34267. return
  34268. }
  34269. return *v, true
  34270. }
  34271. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34272. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34273. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34274. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34275. if !m.op.Is(OpUpdateOne) {
  34276. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34277. }
  34278. if m.id == nil || m.oldValue == nil {
  34279. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34280. }
  34281. oldValue, err := m.oldValue(ctx)
  34282. if err != nil {
  34283. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34284. }
  34285. return oldValue.APIKey, nil
  34286. }
  34287. // ClearAPIKey clears the value of the "api_key" field.
  34288. func (m *WhatsappMutation) ClearAPIKey() {
  34289. m.api_key = nil
  34290. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34291. }
  34292. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34293. func (m *WhatsappMutation) APIKeyCleared() bool {
  34294. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34295. return ok
  34296. }
  34297. // ResetAPIKey resets all changes to the "api_key" field.
  34298. func (m *WhatsappMutation) ResetAPIKey() {
  34299. m.api_key = nil
  34300. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34301. }
  34302. // SetAllowList sets the "allow_list" field.
  34303. func (m *WhatsappMutation) SetAllowList(s []string) {
  34304. m.allow_list = &s
  34305. m.appendallow_list = nil
  34306. }
  34307. // AllowList returns the value of the "allow_list" field in the mutation.
  34308. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34309. v := m.allow_list
  34310. if v == nil {
  34311. return
  34312. }
  34313. return *v, true
  34314. }
  34315. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34316. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34317. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34318. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34319. if !m.op.Is(OpUpdateOne) {
  34320. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34321. }
  34322. if m.id == nil || m.oldValue == nil {
  34323. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34324. }
  34325. oldValue, err := m.oldValue(ctx)
  34326. if err != nil {
  34327. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34328. }
  34329. return oldValue.AllowList, nil
  34330. }
  34331. // AppendAllowList adds s to the "allow_list" field.
  34332. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34333. m.appendallow_list = append(m.appendallow_list, s...)
  34334. }
  34335. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34336. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34337. if len(m.appendallow_list) == 0 {
  34338. return nil, false
  34339. }
  34340. return m.appendallow_list, true
  34341. }
  34342. // ClearAllowList clears the value of the "allow_list" field.
  34343. func (m *WhatsappMutation) ClearAllowList() {
  34344. m.allow_list = nil
  34345. m.appendallow_list = nil
  34346. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34347. }
  34348. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34349. func (m *WhatsappMutation) AllowListCleared() bool {
  34350. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34351. return ok
  34352. }
  34353. // ResetAllowList resets all changes to the "allow_list" field.
  34354. func (m *WhatsappMutation) ResetAllowList() {
  34355. m.allow_list = nil
  34356. m.appendallow_list = nil
  34357. delete(m.clearedFields, whatsapp.FieldAllowList)
  34358. }
  34359. // SetGroupAllowList sets the "group_allow_list" field.
  34360. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34361. m.group_allow_list = &s
  34362. m.appendgroup_allow_list = nil
  34363. }
  34364. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34365. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34366. v := m.group_allow_list
  34367. if v == nil {
  34368. return
  34369. }
  34370. return *v, true
  34371. }
  34372. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34373. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34374. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34375. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34376. if !m.op.Is(OpUpdateOne) {
  34377. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34378. }
  34379. if m.id == nil || m.oldValue == nil {
  34380. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34381. }
  34382. oldValue, err := m.oldValue(ctx)
  34383. if err != nil {
  34384. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34385. }
  34386. return oldValue.GroupAllowList, nil
  34387. }
  34388. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34389. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34390. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34391. }
  34392. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34393. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34394. if len(m.appendgroup_allow_list) == 0 {
  34395. return nil, false
  34396. }
  34397. return m.appendgroup_allow_list, true
  34398. }
  34399. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34400. func (m *WhatsappMutation) ClearGroupAllowList() {
  34401. m.group_allow_list = nil
  34402. m.appendgroup_allow_list = nil
  34403. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34404. }
  34405. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34406. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34407. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34408. return ok
  34409. }
  34410. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34411. func (m *WhatsappMutation) ResetGroupAllowList() {
  34412. m.group_allow_list = nil
  34413. m.appendgroup_allow_list = nil
  34414. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34415. }
  34416. // SetBlockList sets the "block_list" field.
  34417. func (m *WhatsappMutation) SetBlockList(s []string) {
  34418. m.block_list = &s
  34419. m.appendblock_list = nil
  34420. }
  34421. // BlockList returns the value of the "block_list" field in the mutation.
  34422. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34423. v := m.block_list
  34424. if v == nil {
  34425. return
  34426. }
  34427. return *v, true
  34428. }
  34429. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34430. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34432. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34433. if !m.op.Is(OpUpdateOne) {
  34434. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34435. }
  34436. if m.id == nil || m.oldValue == nil {
  34437. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34438. }
  34439. oldValue, err := m.oldValue(ctx)
  34440. if err != nil {
  34441. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34442. }
  34443. return oldValue.BlockList, nil
  34444. }
  34445. // AppendBlockList adds s to the "block_list" field.
  34446. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34447. m.appendblock_list = append(m.appendblock_list, s...)
  34448. }
  34449. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34450. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34451. if len(m.appendblock_list) == 0 {
  34452. return nil, false
  34453. }
  34454. return m.appendblock_list, true
  34455. }
  34456. // ClearBlockList clears the value of the "block_list" field.
  34457. func (m *WhatsappMutation) ClearBlockList() {
  34458. m.block_list = nil
  34459. m.appendblock_list = nil
  34460. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34461. }
  34462. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34463. func (m *WhatsappMutation) BlockListCleared() bool {
  34464. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34465. return ok
  34466. }
  34467. // ResetBlockList resets all changes to the "block_list" field.
  34468. func (m *WhatsappMutation) ResetBlockList() {
  34469. m.block_list = nil
  34470. m.appendblock_list = nil
  34471. delete(m.clearedFields, whatsapp.FieldBlockList)
  34472. }
  34473. // SetGroupBlockList sets the "group_block_list" field.
  34474. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34475. m.group_block_list = &s
  34476. m.appendgroup_block_list = nil
  34477. }
  34478. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34479. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34480. v := m.group_block_list
  34481. if v == nil {
  34482. return
  34483. }
  34484. return *v, true
  34485. }
  34486. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34487. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34488. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34489. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34490. if !m.op.Is(OpUpdateOne) {
  34491. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34492. }
  34493. if m.id == nil || m.oldValue == nil {
  34494. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34495. }
  34496. oldValue, err := m.oldValue(ctx)
  34497. if err != nil {
  34498. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34499. }
  34500. return oldValue.GroupBlockList, nil
  34501. }
  34502. // AppendGroupBlockList adds s to the "group_block_list" field.
  34503. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34504. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34505. }
  34506. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34507. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34508. if len(m.appendgroup_block_list) == 0 {
  34509. return nil, false
  34510. }
  34511. return m.appendgroup_block_list, true
  34512. }
  34513. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34514. func (m *WhatsappMutation) ClearGroupBlockList() {
  34515. m.group_block_list = nil
  34516. m.appendgroup_block_list = nil
  34517. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34518. }
  34519. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34520. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34521. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34522. return ok
  34523. }
  34524. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34525. func (m *WhatsappMutation) ResetGroupBlockList() {
  34526. m.group_block_list = nil
  34527. m.appendgroup_block_list = nil
  34528. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34529. }
  34530. // Where appends a list predicates to the WhatsappMutation builder.
  34531. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34532. m.predicates = append(m.predicates, ps...)
  34533. }
  34534. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34535. // users can use type-assertion to append predicates that do not depend on any generated package.
  34536. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34537. p := make([]predicate.Whatsapp, len(ps))
  34538. for i := range ps {
  34539. p[i] = ps[i]
  34540. }
  34541. m.Where(p...)
  34542. }
  34543. // Op returns the operation name.
  34544. func (m *WhatsappMutation) Op() Op {
  34545. return m.op
  34546. }
  34547. // SetOp allows setting the mutation operation.
  34548. func (m *WhatsappMutation) SetOp(op Op) {
  34549. m.op = op
  34550. }
  34551. // Type returns the node type of this mutation (Whatsapp).
  34552. func (m *WhatsappMutation) Type() string {
  34553. return m.typ
  34554. }
  34555. // Fields returns all fields that were changed during this mutation. Note that in
  34556. // order to get all numeric fields that were incremented/decremented, call
  34557. // AddedFields().
  34558. func (m *WhatsappMutation) Fields() []string {
  34559. fields := make([]string, 0, 18)
  34560. if m.created_at != nil {
  34561. fields = append(fields, whatsapp.FieldCreatedAt)
  34562. }
  34563. if m.updated_at != nil {
  34564. fields = append(fields, whatsapp.FieldUpdatedAt)
  34565. }
  34566. if m.status != nil {
  34567. fields = append(fields, whatsapp.FieldStatus)
  34568. }
  34569. if m.deleted_at != nil {
  34570. fields = append(fields, whatsapp.FieldDeletedAt)
  34571. }
  34572. if m.ak != nil {
  34573. fields = append(fields, whatsapp.FieldAk)
  34574. }
  34575. if m.sk != nil {
  34576. fields = append(fields, whatsapp.FieldSk)
  34577. }
  34578. if m.callback != nil {
  34579. fields = append(fields, whatsapp.FieldCallback)
  34580. }
  34581. if m.account != nil {
  34582. fields = append(fields, whatsapp.FieldAccount)
  34583. }
  34584. if m.nickname != nil {
  34585. fields = append(fields, whatsapp.FieldNickname)
  34586. }
  34587. if m.phone != nil {
  34588. fields = append(fields, whatsapp.FieldPhone)
  34589. }
  34590. if m.organization_id != nil {
  34591. fields = append(fields, whatsapp.FieldOrganizationID)
  34592. }
  34593. if m.agent_id != nil {
  34594. fields = append(fields, whatsapp.FieldAgentID)
  34595. }
  34596. if m.api_base != nil {
  34597. fields = append(fields, whatsapp.FieldAPIBase)
  34598. }
  34599. if m.api_key != nil {
  34600. fields = append(fields, whatsapp.FieldAPIKey)
  34601. }
  34602. if m.allow_list != nil {
  34603. fields = append(fields, whatsapp.FieldAllowList)
  34604. }
  34605. if m.group_allow_list != nil {
  34606. fields = append(fields, whatsapp.FieldGroupAllowList)
  34607. }
  34608. if m.block_list != nil {
  34609. fields = append(fields, whatsapp.FieldBlockList)
  34610. }
  34611. if m.group_block_list != nil {
  34612. fields = append(fields, whatsapp.FieldGroupBlockList)
  34613. }
  34614. return fields
  34615. }
  34616. // Field returns the value of a field with the given name. The second boolean
  34617. // return value indicates that this field was not set, or was not defined in the
  34618. // schema.
  34619. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34620. switch name {
  34621. case whatsapp.FieldCreatedAt:
  34622. return m.CreatedAt()
  34623. case whatsapp.FieldUpdatedAt:
  34624. return m.UpdatedAt()
  34625. case whatsapp.FieldStatus:
  34626. return m.Status()
  34627. case whatsapp.FieldDeletedAt:
  34628. return m.DeletedAt()
  34629. case whatsapp.FieldAk:
  34630. return m.Ak()
  34631. case whatsapp.FieldSk:
  34632. return m.Sk()
  34633. case whatsapp.FieldCallback:
  34634. return m.Callback()
  34635. case whatsapp.FieldAccount:
  34636. return m.Account()
  34637. case whatsapp.FieldNickname:
  34638. return m.Nickname()
  34639. case whatsapp.FieldPhone:
  34640. return m.Phone()
  34641. case whatsapp.FieldOrganizationID:
  34642. return m.OrganizationID()
  34643. case whatsapp.FieldAgentID:
  34644. return m.AgentID()
  34645. case whatsapp.FieldAPIBase:
  34646. return m.APIBase()
  34647. case whatsapp.FieldAPIKey:
  34648. return m.APIKey()
  34649. case whatsapp.FieldAllowList:
  34650. return m.AllowList()
  34651. case whatsapp.FieldGroupAllowList:
  34652. return m.GroupAllowList()
  34653. case whatsapp.FieldBlockList:
  34654. return m.BlockList()
  34655. case whatsapp.FieldGroupBlockList:
  34656. return m.GroupBlockList()
  34657. }
  34658. return nil, false
  34659. }
  34660. // OldField returns the old value of the field from the database. An error is
  34661. // returned if the mutation operation is not UpdateOne, or the query to the
  34662. // database failed.
  34663. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34664. switch name {
  34665. case whatsapp.FieldCreatedAt:
  34666. return m.OldCreatedAt(ctx)
  34667. case whatsapp.FieldUpdatedAt:
  34668. return m.OldUpdatedAt(ctx)
  34669. case whatsapp.FieldStatus:
  34670. return m.OldStatus(ctx)
  34671. case whatsapp.FieldDeletedAt:
  34672. return m.OldDeletedAt(ctx)
  34673. case whatsapp.FieldAk:
  34674. return m.OldAk(ctx)
  34675. case whatsapp.FieldSk:
  34676. return m.OldSk(ctx)
  34677. case whatsapp.FieldCallback:
  34678. return m.OldCallback(ctx)
  34679. case whatsapp.FieldAccount:
  34680. return m.OldAccount(ctx)
  34681. case whatsapp.FieldNickname:
  34682. return m.OldNickname(ctx)
  34683. case whatsapp.FieldPhone:
  34684. return m.OldPhone(ctx)
  34685. case whatsapp.FieldOrganizationID:
  34686. return m.OldOrganizationID(ctx)
  34687. case whatsapp.FieldAgentID:
  34688. return m.OldAgentID(ctx)
  34689. case whatsapp.FieldAPIBase:
  34690. return m.OldAPIBase(ctx)
  34691. case whatsapp.FieldAPIKey:
  34692. return m.OldAPIKey(ctx)
  34693. case whatsapp.FieldAllowList:
  34694. return m.OldAllowList(ctx)
  34695. case whatsapp.FieldGroupAllowList:
  34696. return m.OldGroupAllowList(ctx)
  34697. case whatsapp.FieldBlockList:
  34698. return m.OldBlockList(ctx)
  34699. case whatsapp.FieldGroupBlockList:
  34700. return m.OldGroupBlockList(ctx)
  34701. }
  34702. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34703. }
  34704. // SetField sets the value of a field with the given name. It returns an error if
  34705. // the field is not defined in the schema, or if the type mismatched the field
  34706. // type.
  34707. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34708. switch name {
  34709. case whatsapp.FieldCreatedAt:
  34710. v, ok := value.(time.Time)
  34711. if !ok {
  34712. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34713. }
  34714. m.SetCreatedAt(v)
  34715. return nil
  34716. case whatsapp.FieldUpdatedAt:
  34717. v, ok := value.(time.Time)
  34718. if !ok {
  34719. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34720. }
  34721. m.SetUpdatedAt(v)
  34722. return nil
  34723. case whatsapp.FieldStatus:
  34724. v, ok := value.(uint8)
  34725. if !ok {
  34726. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34727. }
  34728. m.SetStatus(v)
  34729. return nil
  34730. case whatsapp.FieldDeletedAt:
  34731. v, ok := value.(time.Time)
  34732. if !ok {
  34733. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34734. }
  34735. m.SetDeletedAt(v)
  34736. return nil
  34737. case whatsapp.FieldAk:
  34738. v, ok := value.(string)
  34739. if !ok {
  34740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34741. }
  34742. m.SetAk(v)
  34743. return nil
  34744. case whatsapp.FieldSk:
  34745. v, ok := value.(string)
  34746. if !ok {
  34747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34748. }
  34749. m.SetSk(v)
  34750. return nil
  34751. case whatsapp.FieldCallback:
  34752. v, ok := value.(string)
  34753. if !ok {
  34754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34755. }
  34756. m.SetCallback(v)
  34757. return nil
  34758. case whatsapp.FieldAccount:
  34759. v, ok := value.(string)
  34760. if !ok {
  34761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34762. }
  34763. m.SetAccount(v)
  34764. return nil
  34765. case whatsapp.FieldNickname:
  34766. v, ok := value.(string)
  34767. if !ok {
  34768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34769. }
  34770. m.SetNickname(v)
  34771. return nil
  34772. case whatsapp.FieldPhone:
  34773. v, ok := value.(string)
  34774. if !ok {
  34775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34776. }
  34777. m.SetPhone(v)
  34778. return nil
  34779. case whatsapp.FieldOrganizationID:
  34780. v, ok := value.(uint64)
  34781. if !ok {
  34782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34783. }
  34784. m.SetOrganizationID(v)
  34785. return nil
  34786. case whatsapp.FieldAgentID:
  34787. v, ok := value.(uint64)
  34788. if !ok {
  34789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34790. }
  34791. m.SetAgentID(v)
  34792. return nil
  34793. case whatsapp.FieldAPIBase:
  34794. v, ok := value.(string)
  34795. if !ok {
  34796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34797. }
  34798. m.SetAPIBase(v)
  34799. return nil
  34800. case whatsapp.FieldAPIKey:
  34801. v, ok := value.(string)
  34802. if !ok {
  34803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34804. }
  34805. m.SetAPIKey(v)
  34806. return nil
  34807. case whatsapp.FieldAllowList:
  34808. v, ok := value.([]string)
  34809. if !ok {
  34810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34811. }
  34812. m.SetAllowList(v)
  34813. return nil
  34814. case whatsapp.FieldGroupAllowList:
  34815. v, ok := value.([]string)
  34816. if !ok {
  34817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34818. }
  34819. m.SetGroupAllowList(v)
  34820. return nil
  34821. case whatsapp.FieldBlockList:
  34822. v, ok := value.([]string)
  34823. if !ok {
  34824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34825. }
  34826. m.SetBlockList(v)
  34827. return nil
  34828. case whatsapp.FieldGroupBlockList:
  34829. v, ok := value.([]string)
  34830. if !ok {
  34831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34832. }
  34833. m.SetGroupBlockList(v)
  34834. return nil
  34835. }
  34836. return fmt.Errorf("unknown Whatsapp field %s", name)
  34837. }
  34838. // AddedFields returns all numeric fields that were incremented/decremented during
  34839. // this mutation.
  34840. func (m *WhatsappMutation) AddedFields() []string {
  34841. var fields []string
  34842. if m.addstatus != nil {
  34843. fields = append(fields, whatsapp.FieldStatus)
  34844. }
  34845. if m.addorganization_id != nil {
  34846. fields = append(fields, whatsapp.FieldOrganizationID)
  34847. }
  34848. if m.addagent_id != nil {
  34849. fields = append(fields, whatsapp.FieldAgentID)
  34850. }
  34851. return fields
  34852. }
  34853. // AddedField returns the numeric value that was incremented/decremented on a field
  34854. // with the given name. The second boolean return value indicates that this field
  34855. // was not set, or was not defined in the schema.
  34856. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  34857. switch name {
  34858. case whatsapp.FieldStatus:
  34859. return m.AddedStatus()
  34860. case whatsapp.FieldOrganizationID:
  34861. return m.AddedOrganizationID()
  34862. case whatsapp.FieldAgentID:
  34863. return m.AddedAgentID()
  34864. }
  34865. return nil, false
  34866. }
  34867. // AddField adds the value to the field with the given name. It returns an error if
  34868. // the field is not defined in the schema, or if the type mismatched the field
  34869. // type.
  34870. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  34871. switch name {
  34872. case whatsapp.FieldStatus:
  34873. v, ok := value.(int8)
  34874. if !ok {
  34875. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34876. }
  34877. m.AddStatus(v)
  34878. return nil
  34879. case whatsapp.FieldOrganizationID:
  34880. v, ok := value.(int64)
  34881. if !ok {
  34882. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34883. }
  34884. m.AddOrganizationID(v)
  34885. return nil
  34886. case whatsapp.FieldAgentID:
  34887. v, ok := value.(int64)
  34888. if !ok {
  34889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34890. }
  34891. m.AddAgentID(v)
  34892. return nil
  34893. }
  34894. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  34895. }
  34896. // ClearedFields returns all nullable fields that were cleared during this
  34897. // mutation.
  34898. func (m *WhatsappMutation) ClearedFields() []string {
  34899. var fields []string
  34900. if m.FieldCleared(whatsapp.FieldStatus) {
  34901. fields = append(fields, whatsapp.FieldStatus)
  34902. }
  34903. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  34904. fields = append(fields, whatsapp.FieldDeletedAt)
  34905. }
  34906. if m.FieldCleared(whatsapp.FieldAk) {
  34907. fields = append(fields, whatsapp.FieldAk)
  34908. }
  34909. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  34910. fields = append(fields, whatsapp.FieldOrganizationID)
  34911. }
  34912. if m.FieldCleared(whatsapp.FieldAPIBase) {
  34913. fields = append(fields, whatsapp.FieldAPIBase)
  34914. }
  34915. if m.FieldCleared(whatsapp.FieldAPIKey) {
  34916. fields = append(fields, whatsapp.FieldAPIKey)
  34917. }
  34918. if m.FieldCleared(whatsapp.FieldAllowList) {
  34919. fields = append(fields, whatsapp.FieldAllowList)
  34920. }
  34921. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  34922. fields = append(fields, whatsapp.FieldGroupAllowList)
  34923. }
  34924. if m.FieldCleared(whatsapp.FieldBlockList) {
  34925. fields = append(fields, whatsapp.FieldBlockList)
  34926. }
  34927. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  34928. fields = append(fields, whatsapp.FieldGroupBlockList)
  34929. }
  34930. return fields
  34931. }
  34932. // FieldCleared returns a boolean indicating if a field with the given name was
  34933. // cleared in this mutation.
  34934. func (m *WhatsappMutation) FieldCleared(name string) bool {
  34935. _, ok := m.clearedFields[name]
  34936. return ok
  34937. }
  34938. // ClearField clears the value of the field with the given name. It returns an
  34939. // error if the field is not defined in the schema.
  34940. func (m *WhatsappMutation) ClearField(name string) error {
  34941. switch name {
  34942. case whatsapp.FieldStatus:
  34943. m.ClearStatus()
  34944. return nil
  34945. case whatsapp.FieldDeletedAt:
  34946. m.ClearDeletedAt()
  34947. return nil
  34948. case whatsapp.FieldAk:
  34949. m.ClearAk()
  34950. return nil
  34951. case whatsapp.FieldOrganizationID:
  34952. m.ClearOrganizationID()
  34953. return nil
  34954. case whatsapp.FieldAPIBase:
  34955. m.ClearAPIBase()
  34956. return nil
  34957. case whatsapp.FieldAPIKey:
  34958. m.ClearAPIKey()
  34959. return nil
  34960. case whatsapp.FieldAllowList:
  34961. m.ClearAllowList()
  34962. return nil
  34963. case whatsapp.FieldGroupAllowList:
  34964. m.ClearGroupAllowList()
  34965. return nil
  34966. case whatsapp.FieldBlockList:
  34967. m.ClearBlockList()
  34968. return nil
  34969. case whatsapp.FieldGroupBlockList:
  34970. m.ClearGroupBlockList()
  34971. return nil
  34972. }
  34973. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  34974. }
  34975. // ResetField resets all changes in the mutation for the field with the given name.
  34976. // It returns an error if the field is not defined in the schema.
  34977. func (m *WhatsappMutation) ResetField(name string) error {
  34978. switch name {
  34979. case whatsapp.FieldCreatedAt:
  34980. m.ResetCreatedAt()
  34981. return nil
  34982. case whatsapp.FieldUpdatedAt:
  34983. m.ResetUpdatedAt()
  34984. return nil
  34985. case whatsapp.FieldStatus:
  34986. m.ResetStatus()
  34987. return nil
  34988. case whatsapp.FieldDeletedAt:
  34989. m.ResetDeletedAt()
  34990. return nil
  34991. case whatsapp.FieldAk:
  34992. m.ResetAk()
  34993. return nil
  34994. case whatsapp.FieldSk:
  34995. m.ResetSk()
  34996. return nil
  34997. case whatsapp.FieldCallback:
  34998. m.ResetCallback()
  34999. return nil
  35000. case whatsapp.FieldAccount:
  35001. m.ResetAccount()
  35002. return nil
  35003. case whatsapp.FieldNickname:
  35004. m.ResetNickname()
  35005. return nil
  35006. case whatsapp.FieldPhone:
  35007. m.ResetPhone()
  35008. return nil
  35009. case whatsapp.FieldOrganizationID:
  35010. m.ResetOrganizationID()
  35011. return nil
  35012. case whatsapp.FieldAgentID:
  35013. m.ResetAgentID()
  35014. return nil
  35015. case whatsapp.FieldAPIBase:
  35016. m.ResetAPIBase()
  35017. return nil
  35018. case whatsapp.FieldAPIKey:
  35019. m.ResetAPIKey()
  35020. return nil
  35021. case whatsapp.FieldAllowList:
  35022. m.ResetAllowList()
  35023. return nil
  35024. case whatsapp.FieldGroupAllowList:
  35025. m.ResetGroupAllowList()
  35026. return nil
  35027. case whatsapp.FieldBlockList:
  35028. m.ResetBlockList()
  35029. return nil
  35030. case whatsapp.FieldGroupBlockList:
  35031. m.ResetGroupBlockList()
  35032. return nil
  35033. }
  35034. return fmt.Errorf("unknown Whatsapp field %s", name)
  35035. }
  35036. // AddedEdges returns all edge names that were set/added in this mutation.
  35037. func (m *WhatsappMutation) AddedEdges() []string {
  35038. edges := make([]string, 0, 0)
  35039. return edges
  35040. }
  35041. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35042. // name in this mutation.
  35043. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35044. return nil
  35045. }
  35046. // RemovedEdges returns all edge names that were removed in this mutation.
  35047. func (m *WhatsappMutation) RemovedEdges() []string {
  35048. edges := make([]string, 0, 0)
  35049. return edges
  35050. }
  35051. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35052. // the given name in this mutation.
  35053. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35054. return nil
  35055. }
  35056. // ClearedEdges returns all edge names that were cleared in this mutation.
  35057. func (m *WhatsappMutation) ClearedEdges() []string {
  35058. edges := make([]string, 0, 0)
  35059. return edges
  35060. }
  35061. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35062. // was cleared in this mutation.
  35063. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35064. return false
  35065. }
  35066. // ClearEdge clears the value of the edge with the given name. It returns an error
  35067. // if that edge is not defined in the schema.
  35068. func (m *WhatsappMutation) ClearEdge(name string) error {
  35069. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35070. }
  35071. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35072. // It returns an error if the edge is not defined in the schema.
  35073. func (m *WhatsappMutation) ResetEdge(name string) error {
  35074. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35075. }
  35076. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  35077. type WorkExperienceMutation struct {
  35078. config
  35079. op Op
  35080. typ string
  35081. id *uint64
  35082. created_at *time.Time
  35083. updated_at *time.Time
  35084. deleted_at *time.Time
  35085. start_date *time.Time
  35086. end_date *time.Time
  35087. company *string
  35088. experience *string
  35089. organization_id *uint64
  35090. addorganization_id *int64
  35091. clearedFields map[string]struct{}
  35092. employee *uint64
  35093. clearedemployee bool
  35094. done bool
  35095. oldValue func(context.Context) (*WorkExperience, error)
  35096. predicates []predicate.WorkExperience
  35097. }
  35098. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  35099. // workexperienceOption allows management of the mutation configuration using functional options.
  35100. type workexperienceOption func(*WorkExperienceMutation)
  35101. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  35102. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  35103. m := &WorkExperienceMutation{
  35104. config: c,
  35105. op: op,
  35106. typ: TypeWorkExperience,
  35107. clearedFields: make(map[string]struct{}),
  35108. }
  35109. for _, opt := range opts {
  35110. opt(m)
  35111. }
  35112. return m
  35113. }
  35114. // withWorkExperienceID sets the ID field of the mutation.
  35115. func withWorkExperienceID(id uint64) workexperienceOption {
  35116. return func(m *WorkExperienceMutation) {
  35117. var (
  35118. err error
  35119. once sync.Once
  35120. value *WorkExperience
  35121. )
  35122. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  35123. once.Do(func() {
  35124. if m.done {
  35125. err = errors.New("querying old values post mutation is not allowed")
  35126. } else {
  35127. value, err = m.Client().WorkExperience.Get(ctx, id)
  35128. }
  35129. })
  35130. return value, err
  35131. }
  35132. m.id = &id
  35133. }
  35134. }
  35135. // withWorkExperience sets the old WorkExperience of the mutation.
  35136. func withWorkExperience(node *WorkExperience) workexperienceOption {
  35137. return func(m *WorkExperienceMutation) {
  35138. m.oldValue = func(context.Context) (*WorkExperience, error) {
  35139. return node, nil
  35140. }
  35141. m.id = &node.ID
  35142. }
  35143. }
  35144. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35145. // executed in a transaction (ent.Tx), a transactional client is returned.
  35146. func (m WorkExperienceMutation) Client() *Client {
  35147. client := &Client{config: m.config}
  35148. client.init()
  35149. return client
  35150. }
  35151. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35152. // it returns an error otherwise.
  35153. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  35154. if _, ok := m.driver.(*txDriver); !ok {
  35155. return nil, errors.New("ent: mutation is not running in a transaction")
  35156. }
  35157. tx := &Tx{config: m.config}
  35158. tx.init()
  35159. return tx, nil
  35160. }
  35161. // SetID sets the value of the id field. Note that this
  35162. // operation is only accepted on creation of WorkExperience entities.
  35163. func (m *WorkExperienceMutation) SetID(id uint64) {
  35164. m.id = &id
  35165. }
  35166. // ID returns the ID value in the mutation. Note that the ID is only available
  35167. // if it was provided to the builder or after it was returned from the database.
  35168. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  35169. if m.id == nil {
  35170. return
  35171. }
  35172. return *m.id, true
  35173. }
  35174. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35175. // That means, if the mutation is applied within a transaction with an isolation level such
  35176. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35177. // or updated by the mutation.
  35178. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  35179. switch {
  35180. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35181. id, exists := m.ID()
  35182. if exists {
  35183. return []uint64{id}, nil
  35184. }
  35185. fallthrough
  35186. case m.op.Is(OpUpdate | OpDelete):
  35187. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  35188. default:
  35189. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35190. }
  35191. }
  35192. // SetCreatedAt sets the "created_at" field.
  35193. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  35194. m.created_at = &t
  35195. }
  35196. // CreatedAt returns the value of the "created_at" field in the mutation.
  35197. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  35198. v := m.created_at
  35199. if v == nil {
  35200. return
  35201. }
  35202. return *v, true
  35203. }
  35204. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  35205. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35207. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35208. if !m.op.Is(OpUpdateOne) {
  35209. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35210. }
  35211. if m.id == nil || m.oldValue == nil {
  35212. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35213. }
  35214. oldValue, err := m.oldValue(ctx)
  35215. if err != nil {
  35216. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35217. }
  35218. return oldValue.CreatedAt, nil
  35219. }
  35220. // ResetCreatedAt resets all changes to the "created_at" field.
  35221. func (m *WorkExperienceMutation) ResetCreatedAt() {
  35222. m.created_at = nil
  35223. }
  35224. // SetUpdatedAt sets the "updated_at" field.
  35225. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  35226. m.updated_at = &t
  35227. }
  35228. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35229. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  35230. v := m.updated_at
  35231. if v == nil {
  35232. return
  35233. }
  35234. return *v, true
  35235. }
  35236. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  35237. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35239. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35240. if !m.op.Is(OpUpdateOne) {
  35241. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35242. }
  35243. if m.id == nil || m.oldValue == nil {
  35244. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35245. }
  35246. oldValue, err := m.oldValue(ctx)
  35247. if err != nil {
  35248. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35249. }
  35250. return oldValue.UpdatedAt, nil
  35251. }
  35252. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35253. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  35254. m.updated_at = nil
  35255. }
  35256. // SetDeletedAt sets the "deleted_at" field.
  35257. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  35258. m.deleted_at = &t
  35259. }
  35260. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35261. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  35262. v := m.deleted_at
  35263. if v == nil {
  35264. return
  35265. }
  35266. return *v, true
  35267. }
  35268. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  35269. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35271. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35272. if !m.op.Is(OpUpdateOne) {
  35273. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35274. }
  35275. if m.id == nil || m.oldValue == nil {
  35276. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35277. }
  35278. oldValue, err := m.oldValue(ctx)
  35279. if err != nil {
  35280. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35281. }
  35282. return oldValue.DeletedAt, nil
  35283. }
  35284. // ClearDeletedAt clears the value of the "deleted_at" field.
  35285. func (m *WorkExperienceMutation) ClearDeletedAt() {
  35286. m.deleted_at = nil
  35287. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  35288. }
  35289. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35290. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  35291. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  35292. return ok
  35293. }
  35294. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35295. func (m *WorkExperienceMutation) ResetDeletedAt() {
  35296. m.deleted_at = nil
  35297. delete(m.clearedFields, workexperience.FieldDeletedAt)
  35298. }
  35299. // SetEmployeeID sets the "employee_id" field.
  35300. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  35301. m.employee = &u
  35302. }
  35303. // EmployeeID returns the value of the "employee_id" field in the mutation.
  35304. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  35305. v := m.employee
  35306. if v == nil {
  35307. return
  35308. }
  35309. return *v, true
  35310. }
  35311. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  35312. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35313. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35314. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  35315. if !m.op.Is(OpUpdateOne) {
  35316. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  35317. }
  35318. if m.id == nil || m.oldValue == nil {
  35319. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  35320. }
  35321. oldValue, err := m.oldValue(ctx)
  35322. if err != nil {
  35323. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  35324. }
  35325. return oldValue.EmployeeID, nil
  35326. }
  35327. // ResetEmployeeID resets all changes to the "employee_id" field.
  35328. func (m *WorkExperienceMutation) ResetEmployeeID() {
  35329. m.employee = nil
  35330. }
  35331. // SetStartDate sets the "start_date" field.
  35332. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  35333. m.start_date = &t
  35334. }
  35335. // StartDate returns the value of the "start_date" field in the mutation.
  35336. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  35337. v := m.start_date
  35338. if v == nil {
  35339. return
  35340. }
  35341. return *v, true
  35342. }
  35343. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  35344. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35346. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  35347. if !m.op.Is(OpUpdateOne) {
  35348. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  35349. }
  35350. if m.id == nil || m.oldValue == nil {
  35351. return v, errors.New("OldStartDate requires an ID field in the mutation")
  35352. }
  35353. oldValue, err := m.oldValue(ctx)
  35354. if err != nil {
  35355. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  35356. }
  35357. return oldValue.StartDate, nil
  35358. }
  35359. // ResetStartDate resets all changes to the "start_date" field.
  35360. func (m *WorkExperienceMutation) ResetStartDate() {
  35361. m.start_date = nil
  35362. }
  35363. // SetEndDate sets the "end_date" field.
  35364. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  35365. m.end_date = &t
  35366. }
  35367. // EndDate returns the value of the "end_date" field in the mutation.
  35368. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  35369. v := m.end_date
  35370. if v == nil {
  35371. return
  35372. }
  35373. return *v, true
  35374. }
  35375. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  35376. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35378. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  35379. if !m.op.Is(OpUpdateOne) {
  35380. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  35381. }
  35382. if m.id == nil || m.oldValue == nil {
  35383. return v, errors.New("OldEndDate requires an ID field in the mutation")
  35384. }
  35385. oldValue, err := m.oldValue(ctx)
  35386. if err != nil {
  35387. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  35388. }
  35389. return oldValue.EndDate, nil
  35390. }
  35391. // ResetEndDate resets all changes to the "end_date" field.
  35392. func (m *WorkExperienceMutation) ResetEndDate() {
  35393. m.end_date = nil
  35394. }
  35395. // SetCompany sets the "company" field.
  35396. func (m *WorkExperienceMutation) SetCompany(s string) {
  35397. m.company = &s
  35398. }
  35399. // Company returns the value of the "company" field in the mutation.
  35400. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  35401. v := m.company
  35402. if v == nil {
  35403. return
  35404. }
  35405. return *v, true
  35406. }
  35407. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  35408. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35410. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  35411. if !m.op.Is(OpUpdateOne) {
  35412. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35413. }
  35414. if m.id == nil || m.oldValue == nil {
  35415. return v, errors.New("OldCompany requires an ID field in the mutation")
  35416. }
  35417. oldValue, err := m.oldValue(ctx)
  35418. if err != nil {
  35419. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35420. }
  35421. return oldValue.Company, nil
  35422. }
  35423. // ResetCompany resets all changes to the "company" field.
  35424. func (m *WorkExperienceMutation) ResetCompany() {
  35425. m.company = nil
  35426. }
  35427. // SetExperience sets the "experience" field.
  35428. func (m *WorkExperienceMutation) SetExperience(s string) {
  35429. m.experience = &s
  35430. }
  35431. // Experience returns the value of the "experience" field in the mutation.
  35432. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  35433. v := m.experience
  35434. if v == nil {
  35435. return
  35436. }
  35437. return *v, true
  35438. }
  35439. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  35440. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35442. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  35443. if !m.op.Is(OpUpdateOne) {
  35444. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  35445. }
  35446. if m.id == nil || m.oldValue == nil {
  35447. return v, errors.New("OldExperience requires an ID field in the mutation")
  35448. }
  35449. oldValue, err := m.oldValue(ctx)
  35450. if err != nil {
  35451. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  35452. }
  35453. return oldValue.Experience, nil
  35454. }
  35455. // ResetExperience resets all changes to the "experience" field.
  35456. func (m *WorkExperienceMutation) ResetExperience() {
  35457. m.experience = nil
  35458. }
  35459. // SetOrganizationID sets the "organization_id" field.
  35460. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  35461. m.organization_id = &u
  35462. m.addorganization_id = nil
  35463. }
  35464. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35465. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  35466. v := m.organization_id
  35467. if v == nil {
  35468. return
  35469. }
  35470. return *v, true
  35471. }
  35472. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  35473. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35475. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35476. if !m.op.Is(OpUpdateOne) {
  35477. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35478. }
  35479. if m.id == nil || m.oldValue == nil {
  35480. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35481. }
  35482. oldValue, err := m.oldValue(ctx)
  35483. if err != nil {
  35484. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35485. }
  35486. return oldValue.OrganizationID, nil
  35487. }
  35488. // AddOrganizationID adds u to the "organization_id" field.
  35489. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  35490. if m.addorganization_id != nil {
  35491. *m.addorganization_id += u
  35492. } else {
  35493. m.addorganization_id = &u
  35494. }
  35495. }
  35496. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35497. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  35498. v := m.addorganization_id
  35499. if v == nil {
  35500. return
  35501. }
  35502. return *v, true
  35503. }
  35504. // ResetOrganizationID resets all changes to the "organization_id" field.
  35505. func (m *WorkExperienceMutation) ResetOrganizationID() {
  35506. m.organization_id = nil
  35507. m.addorganization_id = nil
  35508. }
  35509. // ClearEmployee clears the "employee" edge to the Employee entity.
  35510. func (m *WorkExperienceMutation) ClearEmployee() {
  35511. m.clearedemployee = true
  35512. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  35513. }
  35514. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  35515. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  35516. return m.clearedemployee
  35517. }
  35518. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  35519. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35520. // EmployeeID instead. It exists only for internal usage by the builders.
  35521. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  35522. if id := m.employee; id != nil {
  35523. ids = append(ids, *id)
  35524. }
  35525. return
  35526. }
  35527. // ResetEmployee resets all changes to the "employee" edge.
  35528. func (m *WorkExperienceMutation) ResetEmployee() {
  35529. m.employee = nil
  35530. m.clearedemployee = false
  35531. }
  35532. // Where appends a list predicates to the WorkExperienceMutation builder.
  35533. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  35534. m.predicates = append(m.predicates, ps...)
  35535. }
  35536. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  35537. // users can use type-assertion to append predicates that do not depend on any generated package.
  35538. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  35539. p := make([]predicate.WorkExperience, len(ps))
  35540. for i := range ps {
  35541. p[i] = ps[i]
  35542. }
  35543. m.Where(p...)
  35544. }
  35545. // Op returns the operation name.
  35546. func (m *WorkExperienceMutation) Op() Op {
  35547. return m.op
  35548. }
  35549. // SetOp allows setting the mutation operation.
  35550. func (m *WorkExperienceMutation) SetOp(op Op) {
  35551. m.op = op
  35552. }
  35553. // Type returns the node type of this mutation (WorkExperience).
  35554. func (m *WorkExperienceMutation) Type() string {
  35555. return m.typ
  35556. }
  35557. // Fields returns all fields that were changed during this mutation. Note that in
  35558. // order to get all numeric fields that were incremented/decremented, call
  35559. // AddedFields().
  35560. func (m *WorkExperienceMutation) Fields() []string {
  35561. fields := make([]string, 0, 9)
  35562. if m.created_at != nil {
  35563. fields = append(fields, workexperience.FieldCreatedAt)
  35564. }
  35565. if m.updated_at != nil {
  35566. fields = append(fields, workexperience.FieldUpdatedAt)
  35567. }
  35568. if m.deleted_at != nil {
  35569. fields = append(fields, workexperience.FieldDeletedAt)
  35570. }
  35571. if m.employee != nil {
  35572. fields = append(fields, workexperience.FieldEmployeeID)
  35573. }
  35574. if m.start_date != nil {
  35575. fields = append(fields, workexperience.FieldStartDate)
  35576. }
  35577. if m.end_date != nil {
  35578. fields = append(fields, workexperience.FieldEndDate)
  35579. }
  35580. if m.company != nil {
  35581. fields = append(fields, workexperience.FieldCompany)
  35582. }
  35583. if m.experience != nil {
  35584. fields = append(fields, workexperience.FieldExperience)
  35585. }
  35586. if m.organization_id != nil {
  35587. fields = append(fields, workexperience.FieldOrganizationID)
  35588. }
  35589. return fields
  35590. }
  35591. // Field returns the value of a field with the given name. The second boolean
  35592. // return value indicates that this field was not set, or was not defined in the
  35593. // schema.
  35594. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  35595. switch name {
  35596. case workexperience.FieldCreatedAt:
  35597. return m.CreatedAt()
  35598. case workexperience.FieldUpdatedAt:
  35599. return m.UpdatedAt()
  35600. case workexperience.FieldDeletedAt:
  35601. return m.DeletedAt()
  35602. case workexperience.FieldEmployeeID:
  35603. return m.EmployeeID()
  35604. case workexperience.FieldStartDate:
  35605. return m.StartDate()
  35606. case workexperience.FieldEndDate:
  35607. return m.EndDate()
  35608. case workexperience.FieldCompany:
  35609. return m.Company()
  35610. case workexperience.FieldExperience:
  35611. return m.Experience()
  35612. case workexperience.FieldOrganizationID:
  35613. return m.OrganizationID()
  35614. }
  35615. return nil, false
  35616. }
  35617. // OldField returns the old value of the field from the database. An error is
  35618. // returned if the mutation operation is not UpdateOne, or the query to the
  35619. // database failed.
  35620. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35621. switch name {
  35622. case workexperience.FieldCreatedAt:
  35623. return m.OldCreatedAt(ctx)
  35624. case workexperience.FieldUpdatedAt:
  35625. return m.OldUpdatedAt(ctx)
  35626. case workexperience.FieldDeletedAt:
  35627. return m.OldDeletedAt(ctx)
  35628. case workexperience.FieldEmployeeID:
  35629. return m.OldEmployeeID(ctx)
  35630. case workexperience.FieldStartDate:
  35631. return m.OldStartDate(ctx)
  35632. case workexperience.FieldEndDate:
  35633. return m.OldEndDate(ctx)
  35634. case workexperience.FieldCompany:
  35635. return m.OldCompany(ctx)
  35636. case workexperience.FieldExperience:
  35637. return m.OldExperience(ctx)
  35638. case workexperience.FieldOrganizationID:
  35639. return m.OldOrganizationID(ctx)
  35640. }
  35641. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  35642. }
  35643. // SetField sets the value of a field with the given name. It returns an error if
  35644. // the field is not defined in the schema, or if the type mismatched the field
  35645. // type.
  35646. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  35647. switch name {
  35648. case workexperience.FieldCreatedAt:
  35649. v, ok := value.(time.Time)
  35650. if !ok {
  35651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35652. }
  35653. m.SetCreatedAt(v)
  35654. return nil
  35655. case workexperience.FieldUpdatedAt:
  35656. v, ok := value.(time.Time)
  35657. if !ok {
  35658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35659. }
  35660. m.SetUpdatedAt(v)
  35661. return nil
  35662. case workexperience.FieldDeletedAt:
  35663. v, ok := value.(time.Time)
  35664. if !ok {
  35665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35666. }
  35667. m.SetDeletedAt(v)
  35668. return nil
  35669. case workexperience.FieldEmployeeID:
  35670. v, ok := value.(uint64)
  35671. if !ok {
  35672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35673. }
  35674. m.SetEmployeeID(v)
  35675. return nil
  35676. case workexperience.FieldStartDate:
  35677. v, ok := value.(time.Time)
  35678. if !ok {
  35679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35680. }
  35681. m.SetStartDate(v)
  35682. return nil
  35683. case workexperience.FieldEndDate:
  35684. v, ok := value.(time.Time)
  35685. if !ok {
  35686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35687. }
  35688. m.SetEndDate(v)
  35689. return nil
  35690. case workexperience.FieldCompany:
  35691. v, ok := value.(string)
  35692. if !ok {
  35693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35694. }
  35695. m.SetCompany(v)
  35696. return nil
  35697. case workexperience.FieldExperience:
  35698. v, ok := value.(string)
  35699. if !ok {
  35700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35701. }
  35702. m.SetExperience(v)
  35703. return nil
  35704. case workexperience.FieldOrganizationID:
  35705. v, ok := value.(uint64)
  35706. if !ok {
  35707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35708. }
  35709. m.SetOrganizationID(v)
  35710. return nil
  35711. }
  35712. return fmt.Errorf("unknown WorkExperience field %s", name)
  35713. }
  35714. // AddedFields returns all numeric fields that were incremented/decremented during
  35715. // this mutation.
  35716. func (m *WorkExperienceMutation) AddedFields() []string {
  35717. var fields []string
  35718. if m.addorganization_id != nil {
  35719. fields = append(fields, workexperience.FieldOrganizationID)
  35720. }
  35721. return fields
  35722. }
  35723. // AddedField returns the numeric value that was incremented/decremented on a field
  35724. // with the given name. The second boolean return value indicates that this field
  35725. // was not set, or was not defined in the schema.
  35726. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  35727. switch name {
  35728. case workexperience.FieldOrganizationID:
  35729. return m.AddedOrganizationID()
  35730. }
  35731. return nil, false
  35732. }
  35733. // AddField adds the value to the field with the given name. It returns an error if
  35734. // the field is not defined in the schema, or if the type mismatched the field
  35735. // type.
  35736. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  35737. switch name {
  35738. case workexperience.FieldOrganizationID:
  35739. v, ok := value.(int64)
  35740. if !ok {
  35741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35742. }
  35743. m.AddOrganizationID(v)
  35744. return nil
  35745. }
  35746. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  35747. }
  35748. // ClearedFields returns all nullable fields that were cleared during this
  35749. // mutation.
  35750. func (m *WorkExperienceMutation) ClearedFields() []string {
  35751. var fields []string
  35752. if m.FieldCleared(workexperience.FieldDeletedAt) {
  35753. fields = append(fields, workexperience.FieldDeletedAt)
  35754. }
  35755. return fields
  35756. }
  35757. // FieldCleared returns a boolean indicating if a field with the given name was
  35758. // cleared in this mutation.
  35759. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  35760. _, ok := m.clearedFields[name]
  35761. return ok
  35762. }
  35763. // ClearField clears the value of the field with the given name. It returns an
  35764. // error if the field is not defined in the schema.
  35765. func (m *WorkExperienceMutation) ClearField(name string) error {
  35766. switch name {
  35767. case workexperience.FieldDeletedAt:
  35768. m.ClearDeletedAt()
  35769. return nil
  35770. }
  35771. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  35772. }
  35773. // ResetField resets all changes in the mutation for the field with the given name.
  35774. // It returns an error if the field is not defined in the schema.
  35775. func (m *WorkExperienceMutation) ResetField(name string) error {
  35776. switch name {
  35777. case workexperience.FieldCreatedAt:
  35778. m.ResetCreatedAt()
  35779. return nil
  35780. case workexperience.FieldUpdatedAt:
  35781. m.ResetUpdatedAt()
  35782. return nil
  35783. case workexperience.FieldDeletedAt:
  35784. m.ResetDeletedAt()
  35785. return nil
  35786. case workexperience.FieldEmployeeID:
  35787. m.ResetEmployeeID()
  35788. return nil
  35789. case workexperience.FieldStartDate:
  35790. m.ResetStartDate()
  35791. return nil
  35792. case workexperience.FieldEndDate:
  35793. m.ResetEndDate()
  35794. return nil
  35795. case workexperience.FieldCompany:
  35796. m.ResetCompany()
  35797. return nil
  35798. case workexperience.FieldExperience:
  35799. m.ResetExperience()
  35800. return nil
  35801. case workexperience.FieldOrganizationID:
  35802. m.ResetOrganizationID()
  35803. return nil
  35804. }
  35805. return fmt.Errorf("unknown WorkExperience field %s", name)
  35806. }
  35807. // AddedEdges returns all edge names that were set/added in this mutation.
  35808. func (m *WorkExperienceMutation) AddedEdges() []string {
  35809. edges := make([]string, 0, 1)
  35810. if m.employee != nil {
  35811. edges = append(edges, workexperience.EdgeEmployee)
  35812. }
  35813. return edges
  35814. }
  35815. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35816. // name in this mutation.
  35817. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  35818. switch name {
  35819. case workexperience.EdgeEmployee:
  35820. if id := m.employee; id != nil {
  35821. return []ent.Value{*id}
  35822. }
  35823. }
  35824. return nil
  35825. }
  35826. // RemovedEdges returns all edge names that were removed in this mutation.
  35827. func (m *WorkExperienceMutation) RemovedEdges() []string {
  35828. edges := make([]string, 0, 1)
  35829. return edges
  35830. }
  35831. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35832. // the given name in this mutation.
  35833. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  35834. return nil
  35835. }
  35836. // ClearedEdges returns all edge names that were cleared in this mutation.
  35837. func (m *WorkExperienceMutation) ClearedEdges() []string {
  35838. edges := make([]string, 0, 1)
  35839. if m.clearedemployee {
  35840. edges = append(edges, workexperience.EdgeEmployee)
  35841. }
  35842. return edges
  35843. }
  35844. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35845. // was cleared in this mutation.
  35846. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  35847. switch name {
  35848. case workexperience.EdgeEmployee:
  35849. return m.clearedemployee
  35850. }
  35851. return false
  35852. }
  35853. // ClearEdge clears the value of the edge with the given name. It returns an error
  35854. // if that edge is not defined in the schema.
  35855. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  35856. switch name {
  35857. case workexperience.EdgeEmployee:
  35858. m.ClearEmployee()
  35859. return nil
  35860. }
  35861. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  35862. }
  35863. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35864. // It returns an error if the edge is not defined in the schema.
  35865. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  35866. switch name {
  35867. case workexperience.EdgeEmployee:
  35868. m.ResetEmployee()
  35869. return nil
  35870. }
  35871. return fmt.Errorf("unknown WorkExperience edge %s", name)
  35872. }
  35873. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  35874. type WpChatroomMutation struct {
  35875. config
  35876. op Op
  35877. typ string
  35878. id *uint64
  35879. created_at *time.Time
  35880. updated_at *time.Time
  35881. status *uint8
  35882. addstatus *int8
  35883. wx_wxid *string
  35884. chatroom_id *string
  35885. nickname *string
  35886. owner *string
  35887. avatar *string
  35888. member_list *[]string
  35889. appendmember_list []string
  35890. clearedFields map[string]struct{}
  35891. done bool
  35892. oldValue func(context.Context) (*WpChatroom, error)
  35893. predicates []predicate.WpChatroom
  35894. }
  35895. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  35896. // wpchatroomOption allows management of the mutation configuration using functional options.
  35897. type wpchatroomOption func(*WpChatroomMutation)
  35898. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  35899. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  35900. m := &WpChatroomMutation{
  35901. config: c,
  35902. op: op,
  35903. typ: TypeWpChatroom,
  35904. clearedFields: make(map[string]struct{}),
  35905. }
  35906. for _, opt := range opts {
  35907. opt(m)
  35908. }
  35909. return m
  35910. }
  35911. // withWpChatroomID sets the ID field of the mutation.
  35912. func withWpChatroomID(id uint64) wpchatroomOption {
  35913. return func(m *WpChatroomMutation) {
  35914. var (
  35915. err error
  35916. once sync.Once
  35917. value *WpChatroom
  35918. )
  35919. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  35920. once.Do(func() {
  35921. if m.done {
  35922. err = errors.New("querying old values post mutation is not allowed")
  35923. } else {
  35924. value, err = m.Client().WpChatroom.Get(ctx, id)
  35925. }
  35926. })
  35927. return value, err
  35928. }
  35929. m.id = &id
  35930. }
  35931. }
  35932. // withWpChatroom sets the old WpChatroom of the mutation.
  35933. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  35934. return func(m *WpChatroomMutation) {
  35935. m.oldValue = func(context.Context) (*WpChatroom, error) {
  35936. return node, nil
  35937. }
  35938. m.id = &node.ID
  35939. }
  35940. }
  35941. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35942. // executed in a transaction (ent.Tx), a transactional client is returned.
  35943. func (m WpChatroomMutation) Client() *Client {
  35944. client := &Client{config: m.config}
  35945. client.init()
  35946. return client
  35947. }
  35948. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35949. // it returns an error otherwise.
  35950. func (m WpChatroomMutation) Tx() (*Tx, error) {
  35951. if _, ok := m.driver.(*txDriver); !ok {
  35952. return nil, errors.New("ent: mutation is not running in a transaction")
  35953. }
  35954. tx := &Tx{config: m.config}
  35955. tx.init()
  35956. return tx, nil
  35957. }
  35958. // SetID sets the value of the id field. Note that this
  35959. // operation is only accepted on creation of WpChatroom entities.
  35960. func (m *WpChatroomMutation) SetID(id uint64) {
  35961. m.id = &id
  35962. }
  35963. // ID returns the ID value in the mutation. Note that the ID is only available
  35964. // if it was provided to the builder or after it was returned from the database.
  35965. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  35966. if m.id == nil {
  35967. return
  35968. }
  35969. return *m.id, true
  35970. }
  35971. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35972. // That means, if the mutation is applied within a transaction with an isolation level such
  35973. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35974. // or updated by the mutation.
  35975. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  35976. switch {
  35977. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35978. id, exists := m.ID()
  35979. if exists {
  35980. return []uint64{id}, nil
  35981. }
  35982. fallthrough
  35983. case m.op.Is(OpUpdate | OpDelete):
  35984. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  35985. default:
  35986. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35987. }
  35988. }
  35989. // SetCreatedAt sets the "created_at" field.
  35990. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  35991. m.created_at = &t
  35992. }
  35993. // CreatedAt returns the value of the "created_at" field in the mutation.
  35994. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  35995. v := m.created_at
  35996. if v == nil {
  35997. return
  35998. }
  35999. return *v, true
  36000. }
  36001. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  36002. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36003. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36004. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36005. if !m.op.Is(OpUpdateOne) {
  36006. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36007. }
  36008. if m.id == nil || m.oldValue == nil {
  36009. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36010. }
  36011. oldValue, err := m.oldValue(ctx)
  36012. if err != nil {
  36013. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36014. }
  36015. return oldValue.CreatedAt, nil
  36016. }
  36017. // ResetCreatedAt resets all changes to the "created_at" field.
  36018. func (m *WpChatroomMutation) ResetCreatedAt() {
  36019. m.created_at = nil
  36020. }
  36021. // SetUpdatedAt sets the "updated_at" field.
  36022. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  36023. m.updated_at = &t
  36024. }
  36025. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36026. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  36027. v := m.updated_at
  36028. if v == nil {
  36029. return
  36030. }
  36031. return *v, true
  36032. }
  36033. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  36034. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36036. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36037. if !m.op.Is(OpUpdateOne) {
  36038. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36039. }
  36040. if m.id == nil || m.oldValue == nil {
  36041. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36042. }
  36043. oldValue, err := m.oldValue(ctx)
  36044. if err != nil {
  36045. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36046. }
  36047. return oldValue.UpdatedAt, nil
  36048. }
  36049. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36050. func (m *WpChatroomMutation) ResetUpdatedAt() {
  36051. m.updated_at = nil
  36052. }
  36053. // SetStatus sets the "status" field.
  36054. func (m *WpChatroomMutation) SetStatus(u uint8) {
  36055. m.status = &u
  36056. m.addstatus = nil
  36057. }
  36058. // Status returns the value of the "status" field in the mutation.
  36059. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  36060. v := m.status
  36061. if v == nil {
  36062. return
  36063. }
  36064. return *v, true
  36065. }
  36066. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  36067. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36068. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36069. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36070. if !m.op.Is(OpUpdateOne) {
  36071. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36072. }
  36073. if m.id == nil || m.oldValue == nil {
  36074. return v, errors.New("OldStatus requires an ID field in the mutation")
  36075. }
  36076. oldValue, err := m.oldValue(ctx)
  36077. if err != nil {
  36078. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36079. }
  36080. return oldValue.Status, nil
  36081. }
  36082. // AddStatus adds u to the "status" field.
  36083. func (m *WpChatroomMutation) AddStatus(u int8) {
  36084. if m.addstatus != nil {
  36085. *m.addstatus += u
  36086. } else {
  36087. m.addstatus = &u
  36088. }
  36089. }
  36090. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36091. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  36092. v := m.addstatus
  36093. if v == nil {
  36094. return
  36095. }
  36096. return *v, true
  36097. }
  36098. // ClearStatus clears the value of the "status" field.
  36099. func (m *WpChatroomMutation) ClearStatus() {
  36100. m.status = nil
  36101. m.addstatus = nil
  36102. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  36103. }
  36104. // StatusCleared returns if the "status" field was cleared in this mutation.
  36105. func (m *WpChatroomMutation) StatusCleared() bool {
  36106. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  36107. return ok
  36108. }
  36109. // ResetStatus resets all changes to the "status" field.
  36110. func (m *WpChatroomMutation) ResetStatus() {
  36111. m.status = nil
  36112. m.addstatus = nil
  36113. delete(m.clearedFields, wpchatroom.FieldStatus)
  36114. }
  36115. // SetWxWxid sets the "wx_wxid" field.
  36116. func (m *WpChatroomMutation) SetWxWxid(s string) {
  36117. m.wx_wxid = &s
  36118. }
  36119. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36120. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  36121. v := m.wx_wxid
  36122. if v == nil {
  36123. return
  36124. }
  36125. return *v, true
  36126. }
  36127. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  36128. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36130. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36131. if !m.op.Is(OpUpdateOne) {
  36132. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36133. }
  36134. if m.id == nil || m.oldValue == nil {
  36135. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36136. }
  36137. oldValue, err := m.oldValue(ctx)
  36138. if err != nil {
  36139. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36140. }
  36141. return oldValue.WxWxid, nil
  36142. }
  36143. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36144. func (m *WpChatroomMutation) ResetWxWxid() {
  36145. m.wx_wxid = nil
  36146. }
  36147. // SetChatroomID sets the "chatroom_id" field.
  36148. func (m *WpChatroomMutation) SetChatroomID(s string) {
  36149. m.chatroom_id = &s
  36150. }
  36151. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  36152. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  36153. v := m.chatroom_id
  36154. if v == nil {
  36155. return
  36156. }
  36157. return *v, true
  36158. }
  36159. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  36160. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36162. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  36163. if !m.op.Is(OpUpdateOne) {
  36164. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  36165. }
  36166. if m.id == nil || m.oldValue == nil {
  36167. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  36168. }
  36169. oldValue, err := m.oldValue(ctx)
  36170. if err != nil {
  36171. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  36172. }
  36173. return oldValue.ChatroomID, nil
  36174. }
  36175. // ResetChatroomID resets all changes to the "chatroom_id" field.
  36176. func (m *WpChatroomMutation) ResetChatroomID() {
  36177. m.chatroom_id = nil
  36178. }
  36179. // SetNickname sets the "nickname" field.
  36180. func (m *WpChatroomMutation) SetNickname(s string) {
  36181. m.nickname = &s
  36182. }
  36183. // Nickname returns the value of the "nickname" field in the mutation.
  36184. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  36185. v := m.nickname
  36186. if v == nil {
  36187. return
  36188. }
  36189. return *v, true
  36190. }
  36191. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  36192. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36194. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  36195. if !m.op.Is(OpUpdateOne) {
  36196. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36197. }
  36198. if m.id == nil || m.oldValue == nil {
  36199. return v, errors.New("OldNickname requires an ID field in the mutation")
  36200. }
  36201. oldValue, err := m.oldValue(ctx)
  36202. if err != nil {
  36203. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36204. }
  36205. return oldValue.Nickname, nil
  36206. }
  36207. // ResetNickname resets all changes to the "nickname" field.
  36208. func (m *WpChatroomMutation) ResetNickname() {
  36209. m.nickname = nil
  36210. }
  36211. // SetOwner sets the "owner" field.
  36212. func (m *WpChatroomMutation) SetOwner(s string) {
  36213. m.owner = &s
  36214. }
  36215. // Owner returns the value of the "owner" field in the mutation.
  36216. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  36217. v := m.owner
  36218. if v == nil {
  36219. return
  36220. }
  36221. return *v, true
  36222. }
  36223. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  36224. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36226. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  36227. if !m.op.Is(OpUpdateOne) {
  36228. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  36229. }
  36230. if m.id == nil || m.oldValue == nil {
  36231. return v, errors.New("OldOwner requires an ID field in the mutation")
  36232. }
  36233. oldValue, err := m.oldValue(ctx)
  36234. if err != nil {
  36235. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  36236. }
  36237. return oldValue.Owner, nil
  36238. }
  36239. // ResetOwner resets all changes to the "owner" field.
  36240. func (m *WpChatroomMutation) ResetOwner() {
  36241. m.owner = nil
  36242. }
  36243. // SetAvatar sets the "avatar" field.
  36244. func (m *WpChatroomMutation) SetAvatar(s string) {
  36245. m.avatar = &s
  36246. }
  36247. // Avatar returns the value of the "avatar" field in the mutation.
  36248. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  36249. v := m.avatar
  36250. if v == nil {
  36251. return
  36252. }
  36253. return *v, true
  36254. }
  36255. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  36256. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36258. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36259. if !m.op.Is(OpUpdateOne) {
  36260. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36261. }
  36262. if m.id == nil || m.oldValue == nil {
  36263. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36264. }
  36265. oldValue, err := m.oldValue(ctx)
  36266. if err != nil {
  36267. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36268. }
  36269. return oldValue.Avatar, nil
  36270. }
  36271. // ResetAvatar resets all changes to the "avatar" field.
  36272. func (m *WpChatroomMutation) ResetAvatar() {
  36273. m.avatar = nil
  36274. }
  36275. // SetMemberList sets the "member_list" field.
  36276. func (m *WpChatroomMutation) SetMemberList(s []string) {
  36277. m.member_list = &s
  36278. m.appendmember_list = nil
  36279. }
  36280. // MemberList returns the value of the "member_list" field in the mutation.
  36281. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  36282. v := m.member_list
  36283. if v == nil {
  36284. return
  36285. }
  36286. return *v, true
  36287. }
  36288. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  36289. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36291. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  36292. if !m.op.Is(OpUpdateOne) {
  36293. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  36294. }
  36295. if m.id == nil || m.oldValue == nil {
  36296. return v, errors.New("OldMemberList requires an ID field in the mutation")
  36297. }
  36298. oldValue, err := m.oldValue(ctx)
  36299. if err != nil {
  36300. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  36301. }
  36302. return oldValue.MemberList, nil
  36303. }
  36304. // AppendMemberList adds s to the "member_list" field.
  36305. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  36306. m.appendmember_list = append(m.appendmember_list, s...)
  36307. }
  36308. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  36309. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  36310. if len(m.appendmember_list) == 0 {
  36311. return nil, false
  36312. }
  36313. return m.appendmember_list, true
  36314. }
  36315. // ResetMemberList resets all changes to the "member_list" field.
  36316. func (m *WpChatroomMutation) ResetMemberList() {
  36317. m.member_list = nil
  36318. m.appendmember_list = nil
  36319. }
  36320. // Where appends a list predicates to the WpChatroomMutation builder.
  36321. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  36322. m.predicates = append(m.predicates, ps...)
  36323. }
  36324. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  36325. // users can use type-assertion to append predicates that do not depend on any generated package.
  36326. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  36327. p := make([]predicate.WpChatroom, len(ps))
  36328. for i := range ps {
  36329. p[i] = ps[i]
  36330. }
  36331. m.Where(p...)
  36332. }
  36333. // Op returns the operation name.
  36334. func (m *WpChatroomMutation) Op() Op {
  36335. return m.op
  36336. }
  36337. // SetOp allows setting the mutation operation.
  36338. func (m *WpChatroomMutation) SetOp(op Op) {
  36339. m.op = op
  36340. }
  36341. // Type returns the node type of this mutation (WpChatroom).
  36342. func (m *WpChatroomMutation) Type() string {
  36343. return m.typ
  36344. }
  36345. // Fields returns all fields that were changed during this mutation. Note that in
  36346. // order to get all numeric fields that were incremented/decremented, call
  36347. // AddedFields().
  36348. func (m *WpChatroomMutation) Fields() []string {
  36349. fields := make([]string, 0, 9)
  36350. if m.created_at != nil {
  36351. fields = append(fields, wpchatroom.FieldCreatedAt)
  36352. }
  36353. if m.updated_at != nil {
  36354. fields = append(fields, wpchatroom.FieldUpdatedAt)
  36355. }
  36356. if m.status != nil {
  36357. fields = append(fields, wpchatroom.FieldStatus)
  36358. }
  36359. if m.wx_wxid != nil {
  36360. fields = append(fields, wpchatroom.FieldWxWxid)
  36361. }
  36362. if m.chatroom_id != nil {
  36363. fields = append(fields, wpchatroom.FieldChatroomID)
  36364. }
  36365. if m.nickname != nil {
  36366. fields = append(fields, wpchatroom.FieldNickname)
  36367. }
  36368. if m.owner != nil {
  36369. fields = append(fields, wpchatroom.FieldOwner)
  36370. }
  36371. if m.avatar != nil {
  36372. fields = append(fields, wpchatroom.FieldAvatar)
  36373. }
  36374. if m.member_list != nil {
  36375. fields = append(fields, wpchatroom.FieldMemberList)
  36376. }
  36377. return fields
  36378. }
  36379. // Field returns the value of a field with the given name. The second boolean
  36380. // return value indicates that this field was not set, or was not defined in the
  36381. // schema.
  36382. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  36383. switch name {
  36384. case wpchatroom.FieldCreatedAt:
  36385. return m.CreatedAt()
  36386. case wpchatroom.FieldUpdatedAt:
  36387. return m.UpdatedAt()
  36388. case wpchatroom.FieldStatus:
  36389. return m.Status()
  36390. case wpchatroom.FieldWxWxid:
  36391. return m.WxWxid()
  36392. case wpchatroom.FieldChatroomID:
  36393. return m.ChatroomID()
  36394. case wpchatroom.FieldNickname:
  36395. return m.Nickname()
  36396. case wpchatroom.FieldOwner:
  36397. return m.Owner()
  36398. case wpchatroom.FieldAvatar:
  36399. return m.Avatar()
  36400. case wpchatroom.FieldMemberList:
  36401. return m.MemberList()
  36402. }
  36403. return nil, false
  36404. }
  36405. // OldField returns the old value of the field from the database. An error is
  36406. // returned if the mutation operation is not UpdateOne, or the query to the
  36407. // database failed.
  36408. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36409. switch name {
  36410. case wpchatroom.FieldCreatedAt:
  36411. return m.OldCreatedAt(ctx)
  36412. case wpchatroom.FieldUpdatedAt:
  36413. return m.OldUpdatedAt(ctx)
  36414. case wpchatroom.FieldStatus:
  36415. return m.OldStatus(ctx)
  36416. case wpchatroom.FieldWxWxid:
  36417. return m.OldWxWxid(ctx)
  36418. case wpchatroom.FieldChatroomID:
  36419. return m.OldChatroomID(ctx)
  36420. case wpchatroom.FieldNickname:
  36421. return m.OldNickname(ctx)
  36422. case wpchatroom.FieldOwner:
  36423. return m.OldOwner(ctx)
  36424. case wpchatroom.FieldAvatar:
  36425. return m.OldAvatar(ctx)
  36426. case wpchatroom.FieldMemberList:
  36427. return m.OldMemberList(ctx)
  36428. }
  36429. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  36430. }
  36431. // SetField sets the value of a field with the given name. It returns an error if
  36432. // the field is not defined in the schema, or if the type mismatched the field
  36433. // type.
  36434. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  36435. switch name {
  36436. case wpchatroom.FieldCreatedAt:
  36437. v, ok := value.(time.Time)
  36438. if !ok {
  36439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36440. }
  36441. m.SetCreatedAt(v)
  36442. return nil
  36443. case wpchatroom.FieldUpdatedAt:
  36444. v, ok := value.(time.Time)
  36445. if !ok {
  36446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36447. }
  36448. m.SetUpdatedAt(v)
  36449. return nil
  36450. case wpchatroom.FieldStatus:
  36451. v, ok := value.(uint8)
  36452. if !ok {
  36453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36454. }
  36455. m.SetStatus(v)
  36456. return nil
  36457. case wpchatroom.FieldWxWxid:
  36458. v, ok := value.(string)
  36459. if !ok {
  36460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36461. }
  36462. m.SetWxWxid(v)
  36463. return nil
  36464. case wpchatroom.FieldChatroomID:
  36465. v, ok := value.(string)
  36466. if !ok {
  36467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36468. }
  36469. m.SetChatroomID(v)
  36470. return nil
  36471. case wpchatroom.FieldNickname:
  36472. v, ok := value.(string)
  36473. if !ok {
  36474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36475. }
  36476. m.SetNickname(v)
  36477. return nil
  36478. case wpchatroom.FieldOwner:
  36479. v, ok := value.(string)
  36480. if !ok {
  36481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36482. }
  36483. m.SetOwner(v)
  36484. return nil
  36485. case wpchatroom.FieldAvatar:
  36486. v, ok := value.(string)
  36487. if !ok {
  36488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36489. }
  36490. m.SetAvatar(v)
  36491. return nil
  36492. case wpchatroom.FieldMemberList:
  36493. v, ok := value.([]string)
  36494. if !ok {
  36495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36496. }
  36497. m.SetMemberList(v)
  36498. return nil
  36499. }
  36500. return fmt.Errorf("unknown WpChatroom field %s", name)
  36501. }
  36502. // AddedFields returns all numeric fields that were incremented/decremented during
  36503. // this mutation.
  36504. func (m *WpChatroomMutation) AddedFields() []string {
  36505. var fields []string
  36506. if m.addstatus != nil {
  36507. fields = append(fields, wpchatroom.FieldStatus)
  36508. }
  36509. return fields
  36510. }
  36511. // AddedField returns the numeric value that was incremented/decremented on a field
  36512. // with the given name. The second boolean return value indicates that this field
  36513. // was not set, or was not defined in the schema.
  36514. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  36515. switch name {
  36516. case wpchatroom.FieldStatus:
  36517. return m.AddedStatus()
  36518. }
  36519. return nil, false
  36520. }
  36521. // AddField adds the value to the field with the given name. It returns an error if
  36522. // the field is not defined in the schema, or if the type mismatched the field
  36523. // type.
  36524. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  36525. switch name {
  36526. case wpchatroom.FieldStatus:
  36527. v, ok := value.(int8)
  36528. if !ok {
  36529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36530. }
  36531. m.AddStatus(v)
  36532. return nil
  36533. }
  36534. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  36535. }
  36536. // ClearedFields returns all nullable fields that were cleared during this
  36537. // mutation.
  36538. func (m *WpChatroomMutation) ClearedFields() []string {
  36539. var fields []string
  36540. if m.FieldCleared(wpchatroom.FieldStatus) {
  36541. fields = append(fields, wpchatroom.FieldStatus)
  36542. }
  36543. return fields
  36544. }
  36545. // FieldCleared returns a boolean indicating if a field with the given name was
  36546. // cleared in this mutation.
  36547. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  36548. _, ok := m.clearedFields[name]
  36549. return ok
  36550. }
  36551. // ClearField clears the value of the field with the given name. It returns an
  36552. // error if the field is not defined in the schema.
  36553. func (m *WpChatroomMutation) ClearField(name string) error {
  36554. switch name {
  36555. case wpchatroom.FieldStatus:
  36556. m.ClearStatus()
  36557. return nil
  36558. }
  36559. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  36560. }
  36561. // ResetField resets all changes in the mutation for the field with the given name.
  36562. // It returns an error if the field is not defined in the schema.
  36563. func (m *WpChatroomMutation) ResetField(name string) error {
  36564. switch name {
  36565. case wpchatroom.FieldCreatedAt:
  36566. m.ResetCreatedAt()
  36567. return nil
  36568. case wpchatroom.FieldUpdatedAt:
  36569. m.ResetUpdatedAt()
  36570. return nil
  36571. case wpchatroom.FieldStatus:
  36572. m.ResetStatus()
  36573. return nil
  36574. case wpchatroom.FieldWxWxid:
  36575. m.ResetWxWxid()
  36576. return nil
  36577. case wpchatroom.FieldChatroomID:
  36578. m.ResetChatroomID()
  36579. return nil
  36580. case wpchatroom.FieldNickname:
  36581. m.ResetNickname()
  36582. return nil
  36583. case wpchatroom.FieldOwner:
  36584. m.ResetOwner()
  36585. return nil
  36586. case wpchatroom.FieldAvatar:
  36587. m.ResetAvatar()
  36588. return nil
  36589. case wpchatroom.FieldMemberList:
  36590. m.ResetMemberList()
  36591. return nil
  36592. }
  36593. return fmt.Errorf("unknown WpChatroom field %s", name)
  36594. }
  36595. // AddedEdges returns all edge names that were set/added in this mutation.
  36596. func (m *WpChatroomMutation) AddedEdges() []string {
  36597. edges := make([]string, 0, 0)
  36598. return edges
  36599. }
  36600. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36601. // name in this mutation.
  36602. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  36603. return nil
  36604. }
  36605. // RemovedEdges returns all edge names that were removed in this mutation.
  36606. func (m *WpChatroomMutation) RemovedEdges() []string {
  36607. edges := make([]string, 0, 0)
  36608. return edges
  36609. }
  36610. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36611. // the given name in this mutation.
  36612. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  36613. return nil
  36614. }
  36615. // ClearedEdges returns all edge names that were cleared in this mutation.
  36616. func (m *WpChatroomMutation) ClearedEdges() []string {
  36617. edges := make([]string, 0, 0)
  36618. return edges
  36619. }
  36620. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36621. // was cleared in this mutation.
  36622. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  36623. return false
  36624. }
  36625. // ClearEdge clears the value of the edge with the given name. It returns an error
  36626. // if that edge is not defined in the schema.
  36627. func (m *WpChatroomMutation) ClearEdge(name string) error {
  36628. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  36629. }
  36630. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36631. // It returns an error if the edge is not defined in the schema.
  36632. func (m *WpChatroomMutation) ResetEdge(name string) error {
  36633. return fmt.Errorf("unknown WpChatroom edge %s", name)
  36634. }
  36635. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  36636. type WpChatroomMemberMutation struct {
  36637. config
  36638. op Op
  36639. typ string
  36640. id *uint64
  36641. created_at *time.Time
  36642. updated_at *time.Time
  36643. status *uint8
  36644. addstatus *int8
  36645. wx_wxid *string
  36646. wxid *string
  36647. nickname *string
  36648. avatar *string
  36649. clearedFields map[string]struct{}
  36650. done bool
  36651. oldValue func(context.Context) (*WpChatroomMember, error)
  36652. predicates []predicate.WpChatroomMember
  36653. }
  36654. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  36655. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  36656. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  36657. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  36658. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  36659. m := &WpChatroomMemberMutation{
  36660. config: c,
  36661. op: op,
  36662. typ: TypeWpChatroomMember,
  36663. clearedFields: make(map[string]struct{}),
  36664. }
  36665. for _, opt := range opts {
  36666. opt(m)
  36667. }
  36668. return m
  36669. }
  36670. // withWpChatroomMemberID sets the ID field of the mutation.
  36671. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  36672. return func(m *WpChatroomMemberMutation) {
  36673. var (
  36674. err error
  36675. once sync.Once
  36676. value *WpChatroomMember
  36677. )
  36678. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  36679. once.Do(func() {
  36680. if m.done {
  36681. err = errors.New("querying old values post mutation is not allowed")
  36682. } else {
  36683. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  36684. }
  36685. })
  36686. return value, err
  36687. }
  36688. m.id = &id
  36689. }
  36690. }
  36691. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  36692. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  36693. return func(m *WpChatroomMemberMutation) {
  36694. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  36695. return node, nil
  36696. }
  36697. m.id = &node.ID
  36698. }
  36699. }
  36700. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36701. // executed in a transaction (ent.Tx), a transactional client is returned.
  36702. func (m WpChatroomMemberMutation) Client() *Client {
  36703. client := &Client{config: m.config}
  36704. client.init()
  36705. return client
  36706. }
  36707. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36708. // it returns an error otherwise.
  36709. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  36710. if _, ok := m.driver.(*txDriver); !ok {
  36711. return nil, errors.New("ent: mutation is not running in a transaction")
  36712. }
  36713. tx := &Tx{config: m.config}
  36714. tx.init()
  36715. return tx, nil
  36716. }
  36717. // SetID sets the value of the id field. Note that this
  36718. // operation is only accepted on creation of WpChatroomMember entities.
  36719. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  36720. m.id = &id
  36721. }
  36722. // ID returns the ID value in the mutation. Note that the ID is only available
  36723. // if it was provided to the builder or after it was returned from the database.
  36724. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  36725. if m.id == nil {
  36726. return
  36727. }
  36728. return *m.id, true
  36729. }
  36730. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36731. // That means, if the mutation is applied within a transaction with an isolation level such
  36732. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36733. // or updated by the mutation.
  36734. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  36735. switch {
  36736. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36737. id, exists := m.ID()
  36738. if exists {
  36739. return []uint64{id}, nil
  36740. }
  36741. fallthrough
  36742. case m.op.Is(OpUpdate | OpDelete):
  36743. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  36744. default:
  36745. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36746. }
  36747. }
  36748. // SetCreatedAt sets the "created_at" field.
  36749. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  36750. m.created_at = &t
  36751. }
  36752. // CreatedAt returns the value of the "created_at" field in the mutation.
  36753. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  36754. v := m.created_at
  36755. if v == nil {
  36756. return
  36757. }
  36758. return *v, true
  36759. }
  36760. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  36761. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36763. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36764. if !m.op.Is(OpUpdateOne) {
  36765. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36766. }
  36767. if m.id == nil || m.oldValue == nil {
  36768. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36769. }
  36770. oldValue, err := m.oldValue(ctx)
  36771. if err != nil {
  36772. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36773. }
  36774. return oldValue.CreatedAt, nil
  36775. }
  36776. // ResetCreatedAt resets all changes to the "created_at" field.
  36777. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  36778. m.created_at = nil
  36779. }
  36780. // SetUpdatedAt sets the "updated_at" field.
  36781. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  36782. m.updated_at = &t
  36783. }
  36784. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36785. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  36786. v := m.updated_at
  36787. if v == nil {
  36788. return
  36789. }
  36790. return *v, true
  36791. }
  36792. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  36793. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36794. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36795. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36796. if !m.op.Is(OpUpdateOne) {
  36797. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36798. }
  36799. if m.id == nil || m.oldValue == nil {
  36800. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36801. }
  36802. oldValue, err := m.oldValue(ctx)
  36803. if err != nil {
  36804. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36805. }
  36806. return oldValue.UpdatedAt, nil
  36807. }
  36808. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36809. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  36810. m.updated_at = nil
  36811. }
  36812. // SetStatus sets the "status" field.
  36813. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  36814. m.status = &u
  36815. m.addstatus = nil
  36816. }
  36817. // Status returns the value of the "status" field in the mutation.
  36818. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  36819. v := m.status
  36820. if v == nil {
  36821. return
  36822. }
  36823. return *v, true
  36824. }
  36825. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  36826. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36827. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36828. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36829. if !m.op.Is(OpUpdateOne) {
  36830. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36831. }
  36832. if m.id == nil || m.oldValue == nil {
  36833. return v, errors.New("OldStatus requires an ID field in the mutation")
  36834. }
  36835. oldValue, err := m.oldValue(ctx)
  36836. if err != nil {
  36837. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36838. }
  36839. return oldValue.Status, nil
  36840. }
  36841. // AddStatus adds u to the "status" field.
  36842. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  36843. if m.addstatus != nil {
  36844. *m.addstatus += u
  36845. } else {
  36846. m.addstatus = &u
  36847. }
  36848. }
  36849. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36850. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  36851. v := m.addstatus
  36852. if v == nil {
  36853. return
  36854. }
  36855. return *v, true
  36856. }
  36857. // ClearStatus clears the value of the "status" field.
  36858. func (m *WpChatroomMemberMutation) ClearStatus() {
  36859. m.status = nil
  36860. m.addstatus = nil
  36861. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  36862. }
  36863. // StatusCleared returns if the "status" field was cleared in this mutation.
  36864. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  36865. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  36866. return ok
  36867. }
  36868. // ResetStatus resets all changes to the "status" field.
  36869. func (m *WpChatroomMemberMutation) ResetStatus() {
  36870. m.status = nil
  36871. m.addstatus = nil
  36872. delete(m.clearedFields, wpchatroommember.FieldStatus)
  36873. }
  36874. // SetWxWxid sets the "wx_wxid" field.
  36875. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  36876. m.wx_wxid = &s
  36877. }
  36878. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36879. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  36880. v := m.wx_wxid
  36881. if v == nil {
  36882. return
  36883. }
  36884. return *v, true
  36885. }
  36886. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  36887. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36888. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36889. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36890. if !m.op.Is(OpUpdateOne) {
  36891. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36892. }
  36893. if m.id == nil || m.oldValue == nil {
  36894. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36895. }
  36896. oldValue, err := m.oldValue(ctx)
  36897. if err != nil {
  36898. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36899. }
  36900. return oldValue.WxWxid, nil
  36901. }
  36902. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36903. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  36904. m.wx_wxid = nil
  36905. }
  36906. // SetWxid sets the "wxid" field.
  36907. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  36908. m.wxid = &s
  36909. }
  36910. // Wxid returns the value of the "wxid" field in the mutation.
  36911. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  36912. v := m.wxid
  36913. if v == nil {
  36914. return
  36915. }
  36916. return *v, true
  36917. }
  36918. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  36919. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36921. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  36922. if !m.op.Is(OpUpdateOne) {
  36923. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36924. }
  36925. if m.id == nil || m.oldValue == nil {
  36926. return v, errors.New("OldWxid requires an ID field in the mutation")
  36927. }
  36928. oldValue, err := m.oldValue(ctx)
  36929. if err != nil {
  36930. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36931. }
  36932. return oldValue.Wxid, nil
  36933. }
  36934. // ResetWxid resets all changes to the "wxid" field.
  36935. func (m *WpChatroomMemberMutation) ResetWxid() {
  36936. m.wxid = nil
  36937. }
  36938. // SetNickname sets the "nickname" field.
  36939. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  36940. m.nickname = &s
  36941. }
  36942. // Nickname returns the value of the "nickname" field in the mutation.
  36943. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  36944. v := m.nickname
  36945. if v == nil {
  36946. return
  36947. }
  36948. return *v, true
  36949. }
  36950. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  36951. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36952. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36953. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  36954. if !m.op.Is(OpUpdateOne) {
  36955. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36956. }
  36957. if m.id == nil || m.oldValue == nil {
  36958. return v, errors.New("OldNickname requires an ID field in the mutation")
  36959. }
  36960. oldValue, err := m.oldValue(ctx)
  36961. if err != nil {
  36962. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36963. }
  36964. return oldValue.Nickname, nil
  36965. }
  36966. // ResetNickname resets all changes to the "nickname" field.
  36967. func (m *WpChatroomMemberMutation) ResetNickname() {
  36968. m.nickname = nil
  36969. }
  36970. // SetAvatar sets the "avatar" field.
  36971. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  36972. m.avatar = &s
  36973. }
  36974. // Avatar returns the value of the "avatar" field in the mutation.
  36975. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  36976. v := m.avatar
  36977. if v == nil {
  36978. return
  36979. }
  36980. return *v, true
  36981. }
  36982. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  36983. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36985. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36986. if !m.op.Is(OpUpdateOne) {
  36987. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36988. }
  36989. if m.id == nil || m.oldValue == nil {
  36990. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36991. }
  36992. oldValue, err := m.oldValue(ctx)
  36993. if err != nil {
  36994. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36995. }
  36996. return oldValue.Avatar, nil
  36997. }
  36998. // ResetAvatar resets all changes to the "avatar" field.
  36999. func (m *WpChatroomMemberMutation) ResetAvatar() {
  37000. m.avatar = nil
  37001. }
  37002. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  37003. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  37004. m.predicates = append(m.predicates, ps...)
  37005. }
  37006. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  37007. // users can use type-assertion to append predicates that do not depend on any generated package.
  37008. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  37009. p := make([]predicate.WpChatroomMember, len(ps))
  37010. for i := range ps {
  37011. p[i] = ps[i]
  37012. }
  37013. m.Where(p...)
  37014. }
  37015. // Op returns the operation name.
  37016. func (m *WpChatroomMemberMutation) Op() Op {
  37017. return m.op
  37018. }
  37019. // SetOp allows setting the mutation operation.
  37020. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  37021. m.op = op
  37022. }
  37023. // Type returns the node type of this mutation (WpChatroomMember).
  37024. func (m *WpChatroomMemberMutation) Type() string {
  37025. return m.typ
  37026. }
  37027. // Fields returns all fields that were changed during this mutation. Note that in
  37028. // order to get all numeric fields that were incremented/decremented, call
  37029. // AddedFields().
  37030. func (m *WpChatroomMemberMutation) Fields() []string {
  37031. fields := make([]string, 0, 7)
  37032. if m.created_at != nil {
  37033. fields = append(fields, wpchatroommember.FieldCreatedAt)
  37034. }
  37035. if m.updated_at != nil {
  37036. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  37037. }
  37038. if m.status != nil {
  37039. fields = append(fields, wpchatroommember.FieldStatus)
  37040. }
  37041. if m.wx_wxid != nil {
  37042. fields = append(fields, wpchatroommember.FieldWxWxid)
  37043. }
  37044. if m.wxid != nil {
  37045. fields = append(fields, wpchatroommember.FieldWxid)
  37046. }
  37047. if m.nickname != nil {
  37048. fields = append(fields, wpchatroommember.FieldNickname)
  37049. }
  37050. if m.avatar != nil {
  37051. fields = append(fields, wpchatroommember.FieldAvatar)
  37052. }
  37053. return fields
  37054. }
  37055. // Field returns the value of a field with the given name. The second boolean
  37056. // return value indicates that this field was not set, or was not defined in the
  37057. // schema.
  37058. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  37059. switch name {
  37060. case wpchatroommember.FieldCreatedAt:
  37061. return m.CreatedAt()
  37062. case wpchatroommember.FieldUpdatedAt:
  37063. return m.UpdatedAt()
  37064. case wpchatroommember.FieldStatus:
  37065. return m.Status()
  37066. case wpchatroommember.FieldWxWxid:
  37067. return m.WxWxid()
  37068. case wpchatroommember.FieldWxid:
  37069. return m.Wxid()
  37070. case wpchatroommember.FieldNickname:
  37071. return m.Nickname()
  37072. case wpchatroommember.FieldAvatar:
  37073. return m.Avatar()
  37074. }
  37075. return nil, false
  37076. }
  37077. // OldField returns the old value of the field from the database. An error is
  37078. // returned if the mutation operation is not UpdateOne, or the query to the
  37079. // database failed.
  37080. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37081. switch name {
  37082. case wpchatroommember.FieldCreatedAt:
  37083. return m.OldCreatedAt(ctx)
  37084. case wpchatroommember.FieldUpdatedAt:
  37085. return m.OldUpdatedAt(ctx)
  37086. case wpchatroommember.FieldStatus:
  37087. return m.OldStatus(ctx)
  37088. case wpchatroommember.FieldWxWxid:
  37089. return m.OldWxWxid(ctx)
  37090. case wpchatroommember.FieldWxid:
  37091. return m.OldWxid(ctx)
  37092. case wpchatroommember.FieldNickname:
  37093. return m.OldNickname(ctx)
  37094. case wpchatroommember.FieldAvatar:
  37095. return m.OldAvatar(ctx)
  37096. }
  37097. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  37098. }
  37099. // SetField sets the value of a field with the given name. It returns an error if
  37100. // the field is not defined in the schema, or if the type mismatched the field
  37101. // type.
  37102. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  37103. switch name {
  37104. case wpchatroommember.FieldCreatedAt:
  37105. v, ok := value.(time.Time)
  37106. if !ok {
  37107. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37108. }
  37109. m.SetCreatedAt(v)
  37110. return nil
  37111. case wpchatroommember.FieldUpdatedAt:
  37112. v, ok := value.(time.Time)
  37113. if !ok {
  37114. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37115. }
  37116. m.SetUpdatedAt(v)
  37117. return nil
  37118. case wpchatroommember.FieldStatus:
  37119. v, ok := value.(uint8)
  37120. if !ok {
  37121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37122. }
  37123. m.SetStatus(v)
  37124. return nil
  37125. case wpchatroommember.FieldWxWxid:
  37126. v, ok := value.(string)
  37127. if !ok {
  37128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37129. }
  37130. m.SetWxWxid(v)
  37131. return nil
  37132. case wpchatroommember.FieldWxid:
  37133. v, ok := value.(string)
  37134. if !ok {
  37135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37136. }
  37137. m.SetWxid(v)
  37138. return nil
  37139. case wpchatroommember.FieldNickname:
  37140. v, ok := value.(string)
  37141. if !ok {
  37142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37143. }
  37144. m.SetNickname(v)
  37145. return nil
  37146. case wpchatroommember.FieldAvatar:
  37147. v, ok := value.(string)
  37148. if !ok {
  37149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37150. }
  37151. m.SetAvatar(v)
  37152. return nil
  37153. }
  37154. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37155. }
  37156. // AddedFields returns all numeric fields that were incremented/decremented during
  37157. // this mutation.
  37158. func (m *WpChatroomMemberMutation) AddedFields() []string {
  37159. var fields []string
  37160. if m.addstatus != nil {
  37161. fields = append(fields, wpchatroommember.FieldStatus)
  37162. }
  37163. return fields
  37164. }
  37165. // AddedField returns the numeric value that was incremented/decremented on a field
  37166. // with the given name. The second boolean return value indicates that this field
  37167. // was not set, or was not defined in the schema.
  37168. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  37169. switch name {
  37170. case wpchatroommember.FieldStatus:
  37171. return m.AddedStatus()
  37172. }
  37173. return nil, false
  37174. }
  37175. // AddField adds the value to the field with the given name. It returns an error if
  37176. // the field is not defined in the schema, or if the type mismatched the field
  37177. // type.
  37178. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  37179. switch name {
  37180. case wpchatroommember.FieldStatus:
  37181. v, ok := value.(int8)
  37182. if !ok {
  37183. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37184. }
  37185. m.AddStatus(v)
  37186. return nil
  37187. }
  37188. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  37189. }
  37190. // ClearedFields returns all nullable fields that were cleared during this
  37191. // mutation.
  37192. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  37193. var fields []string
  37194. if m.FieldCleared(wpchatroommember.FieldStatus) {
  37195. fields = append(fields, wpchatroommember.FieldStatus)
  37196. }
  37197. return fields
  37198. }
  37199. // FieldCleared returns a boolean indicating if a field with the given name was
  37200. // cleared in this mutation.
  37201. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  37202. _, ok := m.clearedFields[name]
  37203. return ok
  37204. }
  37205. // ClearField clears the value of the field with the given name. It returns an
  37206. // error if the field is not defined in the schema.
  37207. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  37208. switch name {
  37209. case wpchatroommember.FieldStatus:
  37210. m.ClearStatus()
  37211. return nil
  37212. }
  37213. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  37214. }
  37215. // ResetField resets all changes in the mutation for the field with the given name.
  37216. // It returns an error if the field is not defined in the schema.
  37217. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  37218. switch name {
  37219. case wpchatroommember.FieldCreatedAt:
  37220. m.ResetCreatedAt()
  37221. return nil
  37222. case wpchatroommember.FieldUpdatedAt:
  37223. m.ResetUpdatedAt()
  37224. return nil
  37225. case wpchatroommember.FieldStatus:
  37226. m.ResetStatus()
  37227. return nil
  37228. case wpchatroommember.FieldWxWxid:
  37229. m.ResetWxWxid()
  37230. return nil
  37231. case wpchatroommember.FieldWxid:
  37232. m.ResetWxid()
  37233. return nil
  37234. case wpchatroommember.FieldNickname:
  37235. m.ResetNickname()
  37236. return nil
  37237. case wpchatroommember.FieldAvatar:
  37238. m.ResetAvatar()
  37239. return nil
  37240. }
  37241. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37242. }
  37243. // AddedEdges returns all edge names that were set/added in this mutation.
  37244. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  37245. edges := make([]string, 0, 0)
  37246. return edges
  37247. }
  37248. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37249. // name in this mutation.
  37250. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  37251. return nil
  37252. }
  37253. // RemovedEdges returns all edge names that were removed in this mutation.
  37254. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  37255. edges := make([]string, 0, 0)
  37256. return edges
  37257. }
  37258. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37259. // the given name in this mutation.
  37260. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  37261. return nil
  37262. }
  37263. // ClearedEdges returns all edge names that were cleared in this mutation.
  37264. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  37265. edges := make([]string, 0, 0)
  37266. return edges
  37267. }
  37268. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37269. // was cleared in this mutation.
  37270. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  37271. return false
  37272. }
  37273. // ClearEdge clears the value of the edge with the given name. It returns an error
  37274. // if that edge is not defined in the schema.
  37275. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  37276. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  37277. }
  37278. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37279. // It returns an error if the edge is not defined in the schema.
  37280. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  37281. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  37282. }
  37283. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  37284. type WxMutation struct {
  37285. config
  37286. op Op
  37287. typ string
  37288. id *uint64
  37289. created_at *time.Time
  37290. updated_at *time.Time
  37291. status *uint8
  37292. addstatus *int8
  37293. deleted_at *time.Time
  37294. port *string
  37295. process_id *string
  37296. callback *string
  37297. wxid *string
  37298. account *string
  37299. nickname *string
  37300. tel *string
  37301. head_big *string
  37302. organization_id *uint64
  37303. addorganization_id *int64
  37304. api_base *string
  37305. api_key *string
  37306. allow_list *[]string
  37307. appendallow_list []string
  37308. group_allow_list *[]string
  37309. appendgroup_allow_list []string
  37310. block_list *[]string
  37311. appendblock_list []string
  37312. group_block_list *[]string
  37313. appendgroup_block_list []string
  37314. clearedFields map[string]struct{}
  37315. server *uint64
  37316. clearedserver bool
  37317. agent *uint64
  37318. clearedagent bool
  37319. done bool
  37320. oldValue func(context.Context) (*Wx, error)
  37321. predicates []predicate.Wx
  37322. }
  37323. var _ ent.Mutation = (*WxMutation)(nil)
  37324. // wxOption allows management of the mutation configuration using functional options.
  37325. type wxOption func(*WxMutation)
  37326. // newWxMutation creates new mutation for the Wx entity.
  37327. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  37328. m := &WxMutation{
  37329. config: c,
  37330. op: op,
  37331. typ: TypeWx,
  37332. clearedFields: make(map[string]struct{}),
  37333. }
  37334. for _, opt := range opts {
  37335. opt(m)
  37336. }
  37337. return m
  37338. }
  37339. // withWxID sets the ID field of the mutation.
  37340. func withWxID(id uint64) wxOption {
  37341. return func(m *WxMutation) {
  37342. var (
  37343. err error
  37344. once sync.Once
  37345. value *Wx
  37346. )
  37347. m.oldValue = func(ctx context.Context) (*Wx, error) {
  37348. once.Do(func() {
  37349. if m.done {
  37350. err = errors.New("querying old values post mutation is not allowed")
  37351. } else {
  37352. value, err = m.Client().Wx.Get(ctx, id)
  37353. }
  37354. })
  37355. return value, err
  37356. }
  37357. m.id = &id
  37358. }
  37359. }
  37360. // withWx sets the old Wx of the mutation.
  37361. func withWx(node *Wx) wxOption {
  37362. return func(m *WxMutation) {
  37363. m.oldValue = func(context.Context) (*Wx, error) {
  37364. return node, nil
  37365. }
  37366. m.id = &node.ID
  37367. }
  37368. }
  37369. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37370. // executed in a transaction (ent.Tx), a transactional client is returned.
  37371. func (m WxMutation) Client() *Client {
  37372. client := &Client{config: m.config}
  37373. client.init()
  37374. return client
  37375. }
  37376. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37377. // it returns an error otherwise.
  37378. func (m WxMutation) Tx() (*Tx, error) {
  37379. if _, ok := m.driver.(*txDriver); !ok {
  37380. return nil, errors.New("ent: mutation is not running in a transaction")
  37381. }
  37382. tx := &Tx{config: m.config}
  37383. tx.init()
  37384. return tx, nil
  37385. }
  37386. // SetID sets the value of the id field. Note that this
  37387. // operation is only accepted on creation of Wx entities.
  37388. func (m *WxMutation) SetID(id uint64) {
  37389. m.id = &id
  37390. }
  37391. // ID returns the ID value in the mutation. Note that the ID is only available
  37392. // if it was provided to the builder or after it was returned from the database.
  37393. func (m *WxMutation) ID() (id uint64, exists bool) {
  37394. if m.id == nil {
  37395. return
  37396. }
  37397. return *m.id, true
  37398. }
  37399. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37400. // That means, if the mutation is applied within a transaction with an isolation level such
  37401. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37402. // or updated by the mutation.
  37403. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  37404. switch {
  37405. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37406. id, exists := m.ID()
  37407. if exists {
  37408. return []uint64{id}, nil
  37409. }
  37410. fallthrough
  37411. case m.op.Is(OpUpdate | OpDelete):
  37412. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  37413. default:
  37414. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37415. }
  37416. }
  37417. // SetCreatedAt sets the "created_at" field.
  37418. func (m *WxMutation) SetCreatedAt(t time.Time) {
  37419. m.created_at = &t
  37420. }
  37421. // CreatedAt returns the value of the "created_at" field in the mutation.
  37422. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  37423. v := m.created_at
  37424. if v == nil {
  37425. return
  37426. }
  37427. return *v, true
  37428. }
  37429. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  37430. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37432. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37433. if !m.op.Is(OpUpdateOne) {
  37434. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37435. }
  37436. if m.id == nil || m.oldValue == nil {
  37437. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37438. }
  37439. oldValue, err := m.oldValue(ctx)
  37440. if err != nil {
  37441. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37442. }
  37443. return oldValue.CreatedAt, nil
  37444. }
  37445. // ResetCreatedAt resets all changes to the "created_at" field.
  37446. func (m *WxMutation) ResetCreatedAt() {
  37447. m.created_at = nil
  37448. }
  37449. // SetUpdatedAt sets the "updated_at" field.
  37450. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  37451. m.updated_at = &t
  37452. }
  37453. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37454. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  37455. v := m.updated_at
  37456. if v == nil {
  37457. return
  37458. }
  37459. return *v, true
  37460. }
  37461. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  37462. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37464. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37465. if !m.op.Is(OpUpdateOne) {
  37466. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37467. }
  37468. if m.id == nil || m.oldValue == nil {
  37469. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37470. }
  37471. oldValue, err := m.oldValue(ctx)
  37472. if err != nil {
  37473. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37474. }
  37475. return oldValue.UpdatedAt, nil
  37476. }
  37477. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37478. func (m *WxMutation) ResetUpdatedAt() {
  37479. m.updated_at = nil
  37480. }
  37481. // SetStatus sets the "status" field.
  37482. func (m *WxMutation) SetStatus(u uint8) {
  37483. m.status = &u
  37484. m.addstatus = nil
  37485. }
  37486. // Status returns the value of the "status" field in the mutation.
  37487. func (m *WxMutation) Status() (r uint8, exists bool) {
  37488. v := m.status
  37489. if v == nil {
  37490. return
  37491. }
  37492. return *v, true
  37493. }
  37494. // OldStatus returns the old "status" field's value of the Wx entity.
  37495. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37496. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37497. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37498. if !m.op.Is(OpUpdateOne) {
  37499. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37500. }
  37501. if m.id == nil || m.oldValue == nil {
  37502. return v, errors.New("OldStatus requires an ID field in the mutation")
  37503. }
  37504. oldValue, err := m.oldValue(ctx)
  37505. if err != nil {
  37506. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37507. }
  37508. return oldValue.Status, nil
  37509. }
  37510. // AddStatus adds u to the "status" field.
  37511. func (m *WxMutation) AddStatus(u int8) {
  37512. if m.addstatus != nil {
  37513. *m.addstatus += u
  37514. } else {
  37515. m.addstatus = &u
  37516. }
  37517. }
  37518. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37519. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  37520. v := m.addstatus
  37521. if v == nil {
  37522. return
  37523. }
  37524. return *v, true
  37525. }
  37526. // ClearStatus clears the value of the "status" field.
  37527. func (m *WxMutation) ClearStatus() {
  37528. m.status = nil
  37529. m.addstatus = nil
  37530. m.clearedFields[wx.FieldStatus] = struct{}{}
  37531. }
  37532. // StatusCleared returns if the "status" field was cleared in this mutation.
  37533. func (m *WxMutation) StatusCleared() bool {
  37534. _, ok := m.clearedFields[wx.FieldStatus]
  37535. return ok
  37536. }
  37537. // ResetStatus resets all changes to the "status" field.
  37538. func (m *WxMutation) ResetStatus() {
  37539. m.status = nil
  37540. m.addstatus = nil
  37541. delete(m.clearedFields, wx.FieldStatus)
  37542. }
  37543. // SetDeletedAt sets the "deleted_at" field.
  37544. func (m *WxMutation) SetDeletedAt(t time.Time) {
  37545. m.deleted_at = &t
  37546. }
  37547. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37548. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  37549. v := m.deleted_at
  37550. if v == nil {
  37551. return
  37552. }
  37553. return *v, true
  37554. }
  37555. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  37556. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37557. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37558. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37559. if !m.op.Is(OpUpdateOne) {
  37560. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37561. }
  37562. if m.id == nil || m.oldValue == nil {
  37563. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37564. }
  37565. oldValue, err := m.oldValue(ctx)
  37566. if err != nil {
  37567. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37568. }
  37569. return oldValue.DeletedAt, nil
  37570. }
  37571. // ClearDeletedAt clears the value of the "deleted_at" field.
  37572. func (m *WxMutation) ClearDeletedAt() {
  37573. m.deleted_at = nil
  37574. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  37575. }
  37576. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37577. func (m *WxMutation) DeletedAtCleared() bool {
  37578. _, ok := m.clearedFields[wx.FieldDeletedAt]
  37579. return ok
  37580. }
  37581. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37582. func (m *WxMutation) ResetDeletedAt() {
  37583. m.deleted_at = nil
  37584. delete(m.clearedFields, wx.FieldDeletedAt)
  37585. }
  37586. // SetServerID sets the "server_id" field.
  37587. func (m *WxMutation) SetServerID(u uint64) {
  37588. m.server = &u
  37589. }
  37590. // ServerID returns the value of the "server_id" field in the mutation.
  37591. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  37592. v := m.server
  37593. if v == nil {
  37594. return
  37595. }
  37596. return *v, true
  37597. }
  37598. // OldServerID returns the old "server_id" field's value of the Wx entity.
  37599. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37601. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  37602. if !m.op.Is(OpUpdateOne) {
  37603. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  37604. }
  37605. if m.id == nil || m.oldValue == nil {
  37606. return v, errors.New("OldServerID requires an ID field in the mutation")
  37607. }
  37608. oldValue, err := m.oldValue(ctx)
  37609. if err != nil {
  37610. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  37611. }
  37612. return oldValue.ServerID, nil
  37613. }
  37614. // ClearServerID clears the value of the "server_id" field.
  37615. func (m *WxMutation) ClearServerID() {
  37616. m.server = nil
  37617. m.clearedFields[wx.FieldServerID] = struct{}{}
  37618. }
  37619. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  37620. func (m *WxMutation) ServerIDCleared() bool {
  37621. _, ok := m.clearedFields[wx.FieldServerID]
  37622. return ok
  37623. }
  37624. // ResetServerID resets all changes to the "server_id" field.
  37625. func (m *WxMutation) ResetServerID() {
  37626. m.server = nil
  37627. delete(m.clearedFields, wx.FieldServerID)
  37628. }
  37629. // SetPort sets the "port" field.
  37630. func (m *WxMutation) SetPort(s string) {
  37631. m.port = &s
  37632. }
  37633. // Port returns the value of the "port" field in the mutation.
  37634. func (m *WxMutation) Port() (r string, exists bool) {
  37635. v := m.port
  37636. if v == nil {
  37637. return
  37638. }
  37639. return *v, true
  37640. }
  37641. // OldPort returns the old "port" field's value of the Wx entity.
  37642. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37644. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  37645. if !m.op.Is(OpUpdateOne) {
  37646. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  37647. }
  37648. if m.id == nil || m.oldValue == nil {
  37649. return v, errors.New("OldPort requires an ID field in the mutation")
  37650. }
  37651. oldValue, err := m.oldValue(ctx)
  37652. if err != nil {
  37653. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  37654. }
  37655. return oldValue.Port, nil
  37656. }
  37657. // ResetPort resets all changes to the "port" field.
  37658. func (m *WxMutation) ResetPort() {
  37659. m.port = nil
  37660. }
  37661. // SetProcessID sets the "process_id" field.
  37662. func (m *WxMutation) SetProcessID(s string) {
  37663. m.process_id = &s
  37664. }
  37665. // ProcessID returns the value of the "process_id" field in the mutation.
  37666. func (m *WxMutation) ProcessID() (r string, exists bool) {
  37667. v := m.process_id
  37668. if v == nil {
  37669. return
  37670. }
  37671. return *v, true
  37672. }
  37673. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  37674. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37676. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  37677. if !m.op.Is(OpUpdateOne) {
  37678. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  37679. }
  37680. if m.id == nil || m.oldValue == nil {
  37681. return v, errors.New("OldProcessID requires an ID field in the mutation")
  37682. }
  37683. oldValue, err := m.oldValue(ctx)
  37684. if err != nil {
  37685. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  37686. }
  37687. return oldValue.ProcessID, nil
  37688. }
  37689. // ResetProcessID resets all changes to the "process_id" field.
  37690. func (m *WxMutation) ResetProcessID() {
  37691. m.process_id = nil
  37692. }
  37693. // SetCallback sets the "callback" field.
  37694. func (m *WxMutation) SetCallback(s string) {
  37695. m.callback = &s
  37696. }
  37697. // Callback returns the value of the "callback" field in the mutation.
  37698. func (m *WxMutation) Callback() (r string, exists bool) {
  37699. v := m.callback
  37700. if v == nil {
  37701. return
  37702. }
  37703. return *v, true
  37704. }
  37705. // OldCallback returns the old "callback" field's value of the Wx entity.
  37706. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37708. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  37709. if !m.op.Is(OpUpdateOne) {
  37710. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37711. }
  37712. if m.id == nil || m.oldValue == nil {
  37713. return v, errors.New("OldCallback requires an ID field in the mutation")
  37714. }
  37715. oldValue, err := m.oldValue(ctx)
  37716. if err != nil {
  37717. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37718. }
  37719. return oldValue.Callback, nil
  37720. }
  37721. // ResetCallback resets all changes to the "callback" field.
  37722. func (m *WxMutation) ResetCallback() {
  37723. m.callback = nil
  37724. }
  37725. // SetWxid sets the "wxid" field.
  37726. func (m *WxMutation) SetWxid(s string) {
  37727. m.wxid = &s
  37728. }
  37729. // Wxid returns the value of the "wxid" field in the mutation.
  37730. func (m *WxMutation) Wxid() (r string, exists bool) {
  37731. v := m.wxid
  37732. if v == nil {
  37733. return
  37734. }
  37735. return *v, true
  37736. }
  37737. // OldWxid returns the old "wxid" field's value of the Wx entity.
  37738. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37740. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  37741. if !m.op.Is(OpUpdateOne) {
  37742. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37743. }
  37744. if m.id == nil || m.oldValue == nil {
  37745. return v, errors.New("OldWxid requires an ID field in the mutation")
  37746. }
  37747. oldValue, err := m.oldValue(ctx)
  37748. if err != nil {
  37749. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37750. }
  37751. return oldValue.Wxid, nil
  37752. }
  37753. // ResetWxid resets all changes to the "wxid" field.
  37754. func (m *WxMutation) ResetWxid() {
  37755. m.wxid = nil
  37756. }
  37757. // SetAccount sets the "account" field.
  37758. func (m *WxMutation) SetAccount(s string) {
  37759. m.account = &s
  37760. }
  37761. // Account returns the value of the "account" field in the mutation.
  37762. func (m *WxMutation) Account() (r string, exists bool) {
  37763. v := m.account
  37764. if v == nil {
  37765. return
  37766. }
  37767. return *v, true
  37768. }
  37769. // OldAccount returns the old "account" field's value of the Wx entity.
  37770. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37772. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  37773. if !m.op.Is(OpUpdateOne) {
  37774. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37775. }
  37776. if m.id == nil || m.oldValue == nil {
  37777. return v, errors.New("OldAccount requires an ID field in the mutation")
  37778. }
  37779. oldValue, err := m.oldValue(ctx)
  37780. if err != nil {
  37781. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37782. }
  37783. return oldValue.Account, nil
  37784. }
  37785. // ResetAccount resets all changes to the "account" field.
  37786. func (m *WxMutation) ResetAccount() {
  37787. m.account = nil
  37788. }
  37789. // SetNickname sets the "nickname" field.
  37790. func (m *WxMutation) SetNickname(s string) {
  37791. m.nickname = &s
  37792. }
  37793. // Nickname returns the value of the "nickname" field in the mutation.
  37794. func (m *WxMutation) Nickname() (r string, exists bool) {
  37795. v := m.nickname
  37796. if v == nil {
  37797. return
  37798. }
  37799. return *v, true
  37800. }
  37801. // OldNickname returns the old "nickname" field's value of the Wx entity.
  37802. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37803. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37804. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  37805. if !m.op.Is(OpUpdateOne) {
  37806. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37807. }
  37808. if m.id == nil || m.oldValue == nil {
  37809. return v, errors.New("OldNickname requires an ID field in the mutation")
  37810. }
  37811. oldValue, err := m.oldValue(ctx)
  37812. if err != nil {
  37813. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37814. }
  37815. return oldValue.Nickname, nil
  37816. }
  37817. // ResetNickname resets all changes to the "nickname" field.
  37818. func (m *WxMutation) ResetNickname() {
  37819. m.nickname = nil
  37820. }
  37821. // SetTel sets the "tel" field.
  37822. func (m *WxMutation) SetTel(s string) {
  37823. m.tel = &s
  37824. }
  37825. // Tel returns the value of the "tel" field in the mutation.
  37826. func (m *WxMutation) Tel() (r string, exists bool) {
  37827. v := m.tel
  37828. if v == nil {
  37829. return
  37830. }
  37831. return *v, true
  37832. }
  37833. // OldTel returns the old "tel" field's value of the Wx entity.
  37834. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37835. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37836. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  37837. if !m.op.Is(OpUpdateOne) {
  37838. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  37839. }
  37840. if m.id == nil || m.oldValue == nil {
  37841. return v, errors.New("OldTel requires an ID field in the mutation")
  37842. }
  37843. oldValue, err := m.oldValue(ctx)
  37844. if err != nil {
  37845. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  37846. }
  37847. return oldValue.Tel, nil
  37848. }
  37849. // ResetTel resets all changes to the "tel" field.
  37850. func (m *WxMutation) ResetTel() {
  37851. m.tel = nil
  37852. }
  37853. // SetHeadBig sets the "head_big" field.
  37854. func (m *WxMutation) SetHeadBig(s string) {
  37855. m.head_big = &s
  37856. }
  37857. // HeadBig returns the value of the "head_big" field in the mutation.
  37858. func (m *WxMutation) HeadBig() (r string, exists bool) {
  37859. v := m.head_big
  37860. if v == nil {
  37861. return
  37862. }
  37863. return *v, true
  37864. }
  37865. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  37866. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37867. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37868. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  37869. if !m.op.Is(OpUpdateOne) {
  37870. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  37871. }
  37872. if m.id == nil || m.oldValue == nil {
  37873. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  37874. }
  37875. oldValue, err := m.oldValue(ctx)
  37876. if err != nil {
  37877. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  37878. }
  37879. return oldValue.HeadBig, nil
  37880. }
  37881. // ResetHeadBig resets all changes to the "head_big" field.
  37882. func (m *WxMutation) ResetHeadBig() {
  37883. m.head_big = nil
  37884. }
  37885. // SetOrganizationID sets the "organization_id" field.
  37886. func (m *WxMutation) SetOrganizationID(u uint64) {
  37887. m.organization_id = &u
  37888. m.addorganization_id = nil
  37889. }
  37890. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37891. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  37892. v := m.organization_id
  37893. if v == nil {
  37894. return
  37895. }
  37896. return *v, true
  37897. }
  37898. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  37899. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37900. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37901. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37902. if !m.op.Is(OpUpdateOne) {
  37903. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37904. }
  37905. if m.id == nil || m.oldValue == nil {
  37906. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  37907. }
  37908. oldValue, err := m.oldValue(ctx)
  37909. if err != nil {
  37910. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  37911. }
  37912. return oldValue.OrganizationID, nil
  37913. }
  37914. // AddOrganizationID adds u to the "organization_id" field.
  37915. func (m *WxMutation) AddOrganizationID(u int64) {
  37916. if m.addorganization_id != nil {
  37917. *m.addorganization_id += u
  37918. } else {
  37919. m.addorganization_id = &u
  37920. }
  37921. }
  37922. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37923. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  37924. v := m.addorganization_id
  37925. if v == nil {
  37926. return
  37927. }
  37928. return *v, true
  37929. }
  37930. // ClearOrganizationID clears the value of the "organization_id" field.
  37931. func (m *WxMutation) ClearOrganizationID() {
  37932. m.organization_id = nil
  37933. m.addorganization_id = nil
  37934. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  37935. }
  37936. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37937. func (m *WxMutation) OrganizationIDCleared() bool {
  37938. _, ok := m.clearedFields[wx.FieldOrganizationID]
  37939. return ok
  37940. }
  37941. // ResetOrganizationID resets all changes to the "organization_id" field.
  37942. func (m *WxMutation) ResetOrganizationID() {
  37943. m.organization_id = nil
  37944. m.addorganization_id = nil
  37945. delete(m.clearedFields, wx.FieldOrganizationID)
  37946. }
  37947. // SetAgentID sets the "agent_id" field.
  37948. func (m *WxMutation) SetAgentID(u uint64) {
  37949. m.agent = &u
  37950. }
  37951. // AgentID returns the value of the "agent_id" field in the mutation.
  37952. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  37953. v := m.agent
  37954. if v == nil {
  37955. return
  37956. }
  37957. return *v, true
  37958. }
  37959. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  37960. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37961. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37962. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  37963. if !m.op.Is(OpUpdateOne) {
  37964. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  37965. }
  37966. if m.id == nil || m.oldValue == nil {
  37967. return v, errors.New("OldAgentID requires an ID field in the mutation")
  37968. }
  37969. oldValue, err := m.oldValue(ctx)
  37970. if err != nil {
  37971. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  37972. }
  37973. return oldValue.AgentID, nil
  37974. }
  37975. // ResetAgentID resets all changes to the "agent_id" field.
  37976. func (m *WxMutation) ResetAgentID() {
  37977. m.agent = nil
  37978. }
  37979. // SetAPIBase sets the "api_base" field.
  37980. func (m *WxMutation) SetAPIBase(s string) {
  37981. m.api_base = &s
  37982. }
  37983. // APIBase returns the value of the "api_base" field in the mutation.
  37984. func (m *WxMutation) APIBase() (r string, exists bool) {
  37985. v := m.api_base
  37986. if v == nil {
  37987. return
  37988. }
  37989. return *v, true
  37990. }
  37991. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  37992. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37993. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37994. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  37995. if !m.op.Is(OpUpdateOne) {
  37996. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  37997. }
  37998. if m.id == nil || m.oldValue == nil {
  37999. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38000. }
  38001. oldValue, err := m.oldValue(ctx)
  38002. if err != nil {
  38003. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38004. }
  38005. return oldValue.APIBase, nil
  38006. }
  38007. // ClearAPIBase clears the value of the "api_base" field.
  38008. func (m *WxMutation) ClearAPIBase() {
  38009. m.api_base = nil
  38010. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  38011. }
  38012. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38013. func (m *WxMutation) APIBaseCleared() bool {
  38014. _, ok := m.clearedFields[wx.FieldAPIBase]
  38015. return ok
  38016. }
  38017. // ResetAPIBase resets all changes to the "api_base" field.
  38018. func (m *WxMutation) ResetAPIBase() {
  38019. m.api_base = nil
  38020. delete(m.clearedFields, wx.FieldAPIBase)
  38021. }
  38022. // SetAPIKey sets the "api_key" field.
  38023. func (m *WxMutation) SetAPIKey(s string) {
  38024. m.api_key = &s
  38025. }
  38026. // APIKey returns the value of the "api_key" field in the mutation.
  38027. func (m *WxMutation) APIKey() (r string, exists bool) {
  38028. v := m.api_key
  38029. if v == nil {
  38030. return
  38031. }
  38032. return *v, true
  38033. }
  38034. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  38035. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38037. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38038. if !m.op.Is(OpUpdateOne) {
  38039. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38040. }
  38041. if m.id == nil || m.oldValue == nil {
  38042. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38043. }
  38044. oldValue, err := m.oldValue(ctx)
  38045. if err != nil {
  38046. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38047. }
  38048. return oldValue.APIKey, nil
  38049. }
  38050. // ClearAPIKey clears the value of the "api_key" field.
  38051. func (m *WxMutation) ClearAPIKey() {
  38052. m.api_key = nil
  38053. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  38054. }
  38055. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38056. func (m *WxMutation) APIKeyCleared() bool {
  38057. _, ok := m.clearedFields[wx.FieldAPIKey]
  38058. return ok
  38059. }
  38060. // ResetAPIKey resets all changes to the "api_key" field.
  38061. func (m *WxMutation) ResetAPIKey() {
  38062. m.api_key = nil
  38063. delete(m.clearedFields, wx.FieldAPIKey)
  38064. }
  38065. // SetAllowList sets the "allow_list" field.
  38066. func (m *WxMutation) SetAllowList(s []string) {
  38067. m.allow_list = &s
  38068. m.appendallow_list = nil
  38069. }
  38070. // AllowList returns the value of the "allow_list" field in the mutation.
  38071. func (m *WxMutation) AllowList() (r []string, exists bool) {
  38072. v := m.allow_list
  38073. if v == nil {
  38074. return
  38075. }
  38076. return *v, true
  38077. }
  38078. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  38079. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38081. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38082. if !m.op.Is(OpUpdateOne) {
  38083. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38084. }
  38085. if m.id == nil || m.oldValue == nil {
  38086. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38087. }
  38088. oldValue, err := m.oldValue(ctx)
  38089. if err != nil {
  38090. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38091. }
  38092. return oldValue.AllowList, nil
  38093. }
  38094. // AppendAllowList adds s to the "allow_list" field.
  38095. func (m *WxMutation) AppendAllowList(s []string) {
  38096. m.appendallow_list = append(m.appendallow_list, s...)
  38097. }
  38098. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38099. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  38100. if len(m.appendallow_list) == 0 {
  38101. return nil, false
  38102. }
  38103. return m.appendallow_list, true
  38104. }
  38105. // ResetAllowList resets all changes to the "allow_list" field.
  38106. func (m *WxMutation) ResetAllowList() {
  38107. m.allow_list = nil
  38108. m.appendallow_list = nil
  38109. }
  38110. // SetGroupAllowList sets the "group_allow_list" field.
  38111. func (m *WxMutation) SetGroupAllowList(s []string) {
  38112. m.group_allow_list = &s
  38113. m.appendgroup_allow_list = nil
  38114. }
  38115. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38116. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  38117. v := m.group_allow_list
  38118. if v == nil {
  38119. return
  38120. }
  38121. return *v, true
  38122. }
  38123. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  38124. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38125. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38126. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38127. if !m.op.Is(OpUpdateOne) {
  38128. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38129. }
  38130. if m.id == nil || m.oldValue == nil {
  38131. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38132. }
  38133. oldValue, err := m.oldValue(ctx)
  38134. if err != nil {
  38135. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38136. }
  38137. return oldValue.GroupAllowList, nil
  38138. }
  38139. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38140. func (m *WxMutation) AppendGroupAllowList(s []string) {
  38141. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38142. }
  38143. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38144. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  38145. if len(m.appendgroup_allow_list) == 0 {
  38146. return nil, false
  38147. }
  38148. return m.appendgroup_allow_list, true
  38149. }
  38150. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38151. func (m *WxMutation) ResetGroupAllowList() {
  38152. m.group_allow_list = nil
  38153. m.appendgroup_allow_list = nil
  38154. }
  38155. // SetBlockList sets the "block_list" field.
  38156. func (m *WxMutation) SetBlockList(s []string) {
  38157. m.block_list = &s
  38158. m.appendblock_list = nil
  38159. }
  38160. // BlockList returns the value of the "block_list" field in the mutation.
  38161. func (m *WxMutation) BlockList() (r []string, exists bool) {
  38162. v := m.block_list
  38163. if v == nil {
  38164. return
  38165. }
  38166. return *v, true
  38167. }
  38168. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  38169. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38171. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38172. if !m.op.Is(OpUpdateOne) {
  38173. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38174. }
  38175. if m.id == nil || m.oldValue == nil {
  38176. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38177. }
  38178. oldValue, err := m.oldValue(ctx)
  38179. if err != nil {
  38180. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38181. }
  38182. return oldValue.BlockList, nil
  38183. }
  38184. // AppendBlockList adds s to the "block_list" field.
  38185. func (m *WxMutation) AppendBlockList(s []string) {
  38186. m.appendblock_list = append(m.appendblock_list, s...)
  38187. }
  38188. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38189. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  38190. if len(m.appendblock_list) == 0 {
  38191. return nil, false
  38192. }
  38193. return m.appendblock_list, true
  38194. }
  38195. // ResetBlockList resets all changes to the "block_list" field.
  38196. func (m *WxMutation) ResetBlockList() {
  38197. m.block_list = nil
  38198. m.appendblock_list = nil
  38199. }
  38200. // SetGroupBlockList sets the "group_block_list" field.
  38201. func (m *WxMutation) SetGroupBlockList(s []string) {
  38202. m.group_block_list = &s
  38203. m.appendgroup_block_list = nil
  38204. }
  38205. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38206. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  38207. v := m.group_block_list
  38208. if v == nil {
  38209. return
  38210. }
  38211. return *v, true
  38212. }
  38213. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  38214. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38216. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38217. if !m.op.Is(OpUpdateOne) {
  38218. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38219. }
  38220. if m.id == nil || m.oldValue == nil {
  38221. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38222. }
  38223. oldValue, err := m.oldValue(ctx)
  38224. if err != nil {
  38225. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38226. }
  38227. return oldValue.GroupBlockList, nil
  38228. }
  38229. // AppendGroupBlockList adds s to the "group_block_list" field.
  38230. func (m *WxMutation) AppendGroupBlockList(s []string) {
  38231. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38232. }
  38233. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38234. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  38235. if len(m.appendgroup_block_list) == 0 {
  38236. return nil, false
  38237. }
  38238. return m.appendgroup_block_list, true
  38239. }
  38240. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38241. func (m *WxMutation) ResetGroupBlockList() {
  38242. m.group_block_list = nil
  38243. m.appendgroup_block_list = nil
  38244. }
  38245. // ClearServer clears the "server" edge to the Server entity.
  38246. func (m *WxMutation) ClearServer() {
  38247. m.clearedserver = true
  38248. m.clearedFields[wx.FieldServerID] = struct{}{}
  38249. }
  38250. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  38251. func (m *WxMutation) ServerCleared() bool {
  38252. return m.ServerIDCleared() || m.clearedserver
  38253. }
  38254. // ServerIDs returns the "server" edge IDs in the mutation.
  38255. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38256. // ServerID instead. It exists only for internal usage by the builders.
  38257. func (m *WxMutation) ServerIDs() (ids []uint64) {
  38258. if id := m.server; id != nil {
  38259. ids = append(ids, *id)
  38260. }
  38261. return
  38262. }
  38263. // ResetServer resets all changes to the "server" edge.
  38264. func (m *WxMutation) ResetServer() {
  38265. m.server = nil
  38266. m.clearedserver = false
  38267. }
  38268. // ClearAgent clears the "agent" edge to the Agent entity.
  38269. func (m *WxMutation) ClearAgent() {
  38270. m.clearedagent = true
  38271. m.clearedFields[wx.FieldAgentID] = struct{}{}
  38272. }
  38273. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38274. func (m *WxMutation) AgentCleared() bool {
  38275. return m.clearedagent
  38276. }
  38277. // AgentIDs returns the "agent" edge IDs in the mutation.
  38278. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38279. // AgentID instead. It exists only for internal usage by the builders.
  38280. func (m *WxMutation) AgentIDs() (ids []uint64) {
  38281. if id := m.agent; id != nil {
  38282. ids = append(ids, *id)
  38283. }
  38284. return
  38285. }
  38286. // ResetAgent resets all changes to the "agent" edge.
  38287. func (m *WxMutation) ResetAgent() {
  38288. m.agent = nil
  38289. m.clearedagent = false
  38290. }
  38291. // Where appends a list predicates to the WxMutation builder.
  38292. func (m *WxMutation) Where(ps ...predicate.Wx) {
  38293. m.predicates = append(m.predicates, ps...)
  38294. }
  38295. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  38296. // users can use type-assertion to append predicates that do not depend on any generated package.
  38297. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  38298. p := make([]predicate.Wx, len(ps))
  38299. for i := range ps {
  38300. p[i] = ps[i]
  38301. }
  38302. m.Where(p...)
  38303. }
  38304. // Op returns the operation name.
  38305. func (m *WxMutation) Op() Op {
  38306. return m.op
  38307. }
  38308. // SetOp allows setting the mutation operation.
  38309. func (m *WxMutation) SetOp(op Op) {
  38310. m.op = op
  38311. }
  38312. // Type returns the node type of this mutation (Wx).
  38313. func (m *WxMutation) Type() string {
  38314. return m.typ
  38315. }
  38316. // Fields returns all fields that were changed during this mutation. Note that in
  38317. // order to get all numeric fields that were incremented/decremented, call
  38318. // AddedFields().
  38319. func (m *WxMutation) Fields() []string {
  38320. fields := make([]string, 0, 21)
  38321. if m.created_at != nil {
  38322. fields = append(fields, wx.FieldCreatedAt)
  38323. }
  38324. if m.updated_at != nil {
  38325. fields = append(fields, wx.FieldUpdatedAt)
  38326. }
  38327. if m.status != nil {
  38328. fields = append(fields, wx.FieldStatus)
  38329. }
  38330. if m.deleted_at != nil {
  38331. fields = append(fields, wx.FieldDeletedAt)
  38332. }
  38333. if m.server != nil {
  38334. fields = append(fields, wx.FieldServerID)
  38335. }
  38336. if m.port != nil {
  38337. fields = append(fields, wx.FieldPort)
  38338. }
  38339. if m.process_id != nil {
  38340. fields = append(fields, wx.FieldProcessID)
  38341. }
  38342. if m.callback != nil {
  38343. fields = append(fields, wx.FieldCallback)
  38344. }
  38345. if m.wxid != nil {
  38346. fields = append(fields, wx.FieldWxid)
  38347. }
  38348. if m.account != nil {
  38349. fields = append(fields, wx.FieldAccount)
  38350. }
  38351. if m.nickname != nil {
  38352. fields = append(fields, wx.FieldNickname)
  38353. }
  38354. if m.tel != nil {
  38355. fields = append(fields, wx.FieldTel)
  38356. }
  38357. if m.head_big != nil {
  38358. fields = append(fields, wx.FieldHeadBig)
  38359. }
  38360. if m.organization_id != nil {
  38361. fields = append(fields, wx.FieldOrganizationID)
  38362. }
  38363. if m.agent != nil {
  38364. fields = append(fields, wx.FieldAgentID)
  38365. }
  38366. if m.api_base != nil {
  38367. fields = append(fields, wx.FieldAPIBase)
  38368. }
  38369. if m.api_key != nil {
  38370. fields = append(fields, wx.FieldAPIKey)
  38371. }
  38372. if m.allow_list != nil {
  38373. fields = append(fields, wx.FieldAllowList)
  38374. }
  38375. if m.group_allow_list != nil {
  38376. fields = append(fields, wx.FieldGroupAllowList)
  38377. }
  38378. if m.block_list != nil {
  38379. fields = append(fields, wx.FieldBlockList)
  38380. }
  38381. if m.group_block_list != nil {
  38382. fields = append(fields, wx.FieldGroupBlockList)
  38383. }
  38384. return fields
  38385. }
  38386. // Field returns the value of a field with the given name. The second boolean
  38387. // return value indicates that this field was not set, or was not defined in the
  38388. // schema.
  38389. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  38390. switch name {
  38391. case wx.FieldCreatedAt:
  38392. return m.CreatedAt()
  38393. case wx.FieldUpdatedAt:
  38394. return m.UpdatedAt()
  38395. case wx.FieldStatus:
  38396. return m.Status()
  38397. case wx.FieldDeletedAt:
  38398. return m.DeletedAt()
  38399. case wx.FieldServerID:
  38400. return m.ServerID()
  38401. case wx.FieldPort:
  38402. return m.Port()
  38403. case wx.FieldProcessID:
  38404. return m.ProcessID()
  38405. case wx.FieldCallback:
  38406. return m.Callback()
  38407. case wx.FieldWxid:
  38408. return m.Wxid()
  38409. case wx.FieldAccount:
  38410. return m.Account()
  38411. case wx.FieldNickname:
  38412. return m.Nickname()
  38413. case wx.FieldTel:
  38414. return m.Tel()
  38415. case wx.FieldHeadBig:
  38416. return m.HeadBig()
  38417. case wx.FieldOrganizationID:
  38418. return m.OrganizationID()
  38419. case wx.FieldAgentID:
  38420. return m.AgentID()
  38421. case wx.FieldAPIBase:
  38422. return m.APIBase()
  38423. case wx.FieldAPIKey:
  38424. return m.APIKey()
  38425. case wx.FieldAllowList:
  38426. return m.AllowList()
  38427. case wx.FieldGroupAllowList:
  38428. return m.GroupAllowList()
  38429. case wx.FieldBlockList:
  38430. return m.BlockList()
  38431. case wx.FieldGroupBlockList:
  38432. return m.GroupBlockList()
  38433. }
  38434. return nil, false
  38435. }
  38436. // OldField returns the old value of the field from the database. An error is
  38437. // returned if the mutation operation is not UpdateOne, or the query to the
  38438. // database failed.
  38439. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38440. switch name {
  38441. case wx.FieldCreatedAt:
  38442. return m.OldCreatedAt(ctx)
  38443. case wx.FieldUpdatedAt:
  38444. return m.OldUpdatedAt(ctx)
  38445. case wx.FieldStatus:
  38446. return m.OldStatus(ctx)
  38447. case wx.FieldDeletedAt:
  38448. return m.OldDeletedAt(ctx)
  38449. case wx.FieldServerID:
  38450. return m.OldServerID(ctx)
  38451. case wx.FieldPort:
  38452. return m.OldPort(ctx)
  38453. case wx.FieldProcessID:
  38454. return m.OldProcessID(ctx)
  38455. case wx.FieldCallback:
  38456. return m.OldCallback(ctx)
  38457. case wx.FieldWxid:
  38458. return m.OldWxid(ctx)
  38459. case wx.FieldAccount:
  38460. return m.OldAccount(ctx)
  38461. case wx.FieldNickname:
  38462. return m.OldNickname(ctx)
  38463. case wx.FieldTel:
  38464. return m.OldTel(ctx)
  38465. case wx.FieldHeadBig:
  38466. return m.OldHeadBig(ctx)
  38467. case wx.FieldOrganizationID:
  38468. return m.OldOrganizationID(ctx)
  38469. case wx.FieldAgentID:
  38470. return m.OldAgentID(ctx)
  38471. case wx.FieldAPIBase:
  38472. return m.OldAPIBase(ctx)
  38473. case wx.FieldAPIKey:
  38474. return m.OldAPIKey(ctx)
  38475. case wx.FieldAllowList:
  38476. return m.OldAllowList(ctx)
  38477. case wx.FieldGroupAllowList:
  38478. return m.OldGroupAllowList(ctx)
  38479. case wx.FieldBlockList:
  38480. return m.OldBlockList(ctx)
  38481. case wx.FieldGroupBlockList:
  38482. return m.OldGroupBlockList(ctx)
  38483. }
  38484. return nil, fmt.Errorf("unknown Wx field %s", name)
  38485. }
  38486. // SetField sets the value of a field with the given name. It returns an error if
  38487. // the field is not defined in the schema, or if the type mismatched the field
  38488. // type.
  38489. func (m *WxMutation) SetField(name string, value ent.Value) error {
  38490. switch name {
  38491. case wx.FieldCreatedAt:
  38492. v, ok := value.(time.Time)
  38493. if !ok {
  38494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38495. }
  38496. m.SetCreatedAt(v)
  38497. return nil
  38498. case wx.FieldUpdatedAt:
  38499. v, ok := value.(time.Time)
  38500. if !ok {
  38501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38502. }
  38503. m.SetUpdatedAt(v)
  38504. return nil
  38505. case wx.FieldStatus:
  38506. v, ok := value.(uint8)
  38507. if !ok {
  38508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38509. }
  38510. m.SetStatus(v)
  38511. return nil
  38512. case wx.FieldDeletedAt:
  38513. v, ok := value.(time.Time)
  38514. if !ok {
  38515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38516. }
  38517. m.SetDeletedAt(v)
  38518. return nil
  38519. case wx.FieldServerID:
  38520. v, ok := value.(uint64)
  38521. if !ok {
  38522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38523. }
  38524. m.SetServerID(v)
  38525. return nil
  38526. case wx.FieldPort:
  38527. v, ok := value.(string)
  38528. if !ok {
  38529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38530. }
  38531. m.SetPort(v)
  38532. return nil
  38533. case wx.FieldProcessID:
  38534. v, ok := value.(string)
  38535. if !ok {
  38536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38537. }
  38538. m.SetProcessID(v)
  38539. return nil
  38540. case wx.FieldCallback:
  38541. v, ok := value.(string)
  38542. if !ok {
  38543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38544. }
  38545. m.SetCallback(v)
  38546. return nil
  38547. case wx.FieldWxid:
  38548. v, ok := value.(string)
  38549. if !ok {
  38550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38551. }
  38552. m.SetWxid(v)
  38553. return nil
  38554. case wx.FieldAccount:
  38555. v, ok := value.(string)
  38556. if !ok {
  38557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38558. }
  38559. m.SetAccount(v)
  38560. return nil
  38561. case wx.FieldNickname:
  38562. v, ok := value.(string)
  38563. if !ok {
  38564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38565. }
  38566. m.SetNickname(v)
  38567. return nil
  38568. case wx.FieldTel:
  38569. v, ok := value.(string)
  38570. if !ok {
  38571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38572. }
  38573. m.SetTel(v)
  38574. return nil
  38575. case wx.FieldHeadBig:
  38576. v, ok := value.(string)
  38577. if !ok {
  38578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38579. }
  38580. m.SetHeadBig(v)
  38581. return nil
  38582. case wx.FieldOrganizationID:
  38583. v, ok := value.(uint64)
  38584. if !ok {
  38585. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38586. }
  38587. m.SetOrganizationID(v)
  38588. return nil
  38589. case wx.FieldAgentID:
  38590. v, ok := value.(uint64)
  38591. if !ok {
  38592. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38593. }
  38594. m.SetAgentID(v)
  38595. return nil
  38596. case wx.FieldAPIBase:
  38597. v, ok := value.(string)
  38598. if !ok {
  38599. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38600. }
  38601. m.SetAPIBase(v)
  38602. return nil
  38603. case wx.FieldAPIKey:
  38604. v, ok := value.(string)
  38605. if !ok {
  38606. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38607. }
  38608. m.SetAPIKey(v)
  38609. return nil
  38610. case wx.FieldAllowList:
  38611. v, ok := value.([]string)
  38612. if !ok {
  38613. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38614. }
  38615. m.SetAllowList(v)
  38616. return nil
  38617. case wx.FieldGroupAllowList:
  38618. v, ok := value.([]string)
  38619. if !ok {
  38620. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38621. }
  38622. m.SetGroupAllowList(v)
  38623. return nil
  38624. case wx.FieldBlockList:
  38625. v, ok := value.([]string)
  38626. if !ok {
  38627. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38628. }
  38629. m.SetBlockList(v)
  38630. return nil
  38631. case wx.FieldGroupBlockList:
  38632. v, ok := value.([]string)
  38633. if !ok {
  38634. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38635. }
  38636. m.SetGroupBlockList(v)
  38637. return nil
  38638. }
  38639. return fmt.Errorf("unknown Wx field %s", name)
  38640. }
  38641. // AddedFields returns all numeric fields that were incremented/decremented during
  38642. // this mutation.
  38643. func (m *WxMutation) AddedFields() []string {
  38644. var fields []string
  38645. if m.addstatus != nil {
  38646. fields = append(fields, wx.FieldStatus)
  38647. }
  38648. if m.addorganization_id != nil {
  38649. fields = append(fields, wx.FieldOrganizationID)
  38650. }
  38651. return fields
  38652. }
  38653. // AddedField returns the numeric value that was incremented/decremented on a field
  38654. // with the given name. The second boolean return value indicates that this field
  38655. // was not set, or was not defined in the schema.
  38656. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  38657. switch name {
  38658. case wx.FieldStatus:
  38659. return m.AddedStatus()
  38660. case wx.FieldOrganizationID:
  38661. return m.AddedOrganizationID()
  38662. }
  38663. return nil, false
  38664. }
  38665. // AddField adds the value to the field with the given name. It returns an error if
  38666. // the field is not defined in the schema, or if the type mismatched the field
  38667. // type.
  38668. func (m *WxMutation) AddField(name string, value ent.Value) error {
  38669. switch name {
  38670. case wx.FieldStatus:
  38671. v, ok := value.(int8)
  38672. if !ok {
  38673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38674. }
  38675. m.AddStatus(v)
  38676. return nil
  38677. case wx.FieldOrganizationID:
  38678. v, ok := value.(int64)
  38679. if !ok {
  38680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38681. }
  38682. m.AddOrganizationID(v)
  38683. return nil
  38684. }
  38685. return fmt.Errorf("unknown Wx numeric field %s", name)
  38686. }
  38687. // ClearedFields returns all nullable fields that were cleared during this
  38688. // mutation.
  38689. func (m *WxMutation) ClearedFields() []string {
  38690. var fields []string
  38691. if m.FieldCleared(wx.FieldStatus) {
  38692. fields = append(fields, wx.FieldStatus)
  38693. }
  38694. if m.FieldCleared(wx.FieldDeletedAt) {
  38695. fields = append(fields, wx.FieldDeletedAt)
  38696. }
  38697. if m.FieldCleared(wx.FieldServerID) {
  38698. fields = append(fields, wx.FieldServerID)
  38699. }
  38700. if m.FieldCleared(wx.FieldOrganizationID) {
  38701. fields = append(fields, wx.FieldOrganizationID)
  38702. }
  38703. if m.FieldCleared(wx.FieldAPIBase) {
  38704. fields = append(fields, wx.FieldAPIBase)
  38705. }
  38706. if m.FieldCleared(wx.FieldAPIKey) {
  38707. fields = append(fields, wx.FieldAPIKey)
  38708. }
  38709. return fields
  38710. }
  38711. // FieldCleared returns a boolean indicating if a field with the given name was
  38712. // cleared in this mutation.
  38713. func (m *WxMutation) FieldCleared(name string) bool {
  38714. _, ok := m.clearedFields[name]
  38715. return ok
  38716. }
  38717. // ClearField clears the value of the field with the given name. It returns an
  38718. // error if the field is not defined in the schema.
  38719. func (m *WxMutation) ClearField(name string) error {
  38720. switch name {
  38721. case wx.FieldStatus:
  38722. m.ClearStatus()
  38723. return nil
  38724. case wx.FieldDeletedAt:
  38725. m.ClearDeletedAt()
  38726. return nil
  38727. case wx.FieldServerID:
  38728. m.ClearServerID()
  38729. return nil
  38730. case wx.FieldOrganizationID:
  38731. m.ClearOrganizationID()
  38732. return nil
  38733. case wx.FieldAPIBase:
  38734. m.ClearAPIBase()
  38735. return nil
  38736. case wx.FieldAPIKey:
  38737. m.ClearAPIKey()
  38738. return nil
  38739. }
  38740. return fmt.Errorf("unknown Wx nullable field %s", name)
  38741. }
  38742. // ResetField resets all changes in the mutation for the field with the given name.
  38743. // It returns an error if the field is not defined in the schema.
  38744. func (m *WxMutation) ResetField(name string) error {
  38745. switch name {
  38746. case wx.FieldCreatedAt:
  38747. m.ResetCreatedAt()
  38748. return nil
  38749. case wx.FieldUpdatedAt:
  38750. m.ResetUpdatedAt()
  38751. return nil
  38752. case wx.FieldStatus:
  38753. m.ResetStatus()
  38754. return nil
  38755. case wx.FieldDeletedAt:
  38756. m.ResetDeletedAt()
  38757. return nil
  38758. case wx.FieldServerID:
  38759. m.ResetServerID()
  38760. return nil
  38761. case wx.FieldPort:
  38762. m.ResetPort()
  38763. return nil
  38764. case wx.FieldProcessID:
  38765. m.ResetProcessID()
  38766. return nil
  38767. case wx.FieldCallback:
  38768. m.ResetCallback()
  38769. return nil
  38770. case wx.FieldWxid:
  38771. m.ResetWxid()
  38772. return nil
  38773. case wx.FieldAccount:
  38774. m.ResetAccount()
  38775. return nil
  38776. case wx.FieldNickname:
  38777. m.ResetNickname()
  38778. return nil
  38779. case wx.FieldTel:
  38780. m.ResetTel()
  38781. return nil
  38782. case wx.FieldHeadBig:
  38783. m.ResetHeadBig()
  38784. return nil
  38785. case wx.FieldOrganizationID:
  38786. m.ResetOrganizationID()
  38787. return nil
  38788. case wx.FieldAgentID:
  38789. m.ResetAgentID()
  38790. return nil
  38791. case wx.FieldAPIBase:
  38792. m.ResetAPIBase()
  38793. return nil
  38794. case wx.FieldAPIKey:
  38795. m.ResetAPIKey()
  38796. return nil
  38797. case wx.FieldAllowList:
  38798. m.ResetAllowList()
  38799. return nil
  38800. case wx.FieldGroupAllowList:
  38801. m.ResetGroupAllowList()
  38802. return nil
  38803. case wx.FieldBlockList:
  38804. m.ResetBlockList()
  38805. return nil
  38806. case wx.FieldGroupBlockList:
  38807. m.ResetGroupBlockList()
  38808. return nil
  38809. }
  38810. return fmt.Errorf("unknown Wx field %s", name)
  38811. }
  38812. // AddedEdges returns all edge names that were set/added in this mutation.
  38813. func (m *WxMutation) AddedEdges() []string {
  38814. edges := make([]string, 0, 2)
  38815. if m.server != nil {
  38816. edges = append(edges, wx.EdgeServer)
  38817. }
  38818. if m.agent != nil {
  38819. edges = append(edges, wx.EdgeAgent)
  38820. }
  38821. return edges
  38822. }
  38823. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38824. // name in this mutation.
  38825. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  38826. switch name {
  38827. case wx.EdgeServer:
  38828. if id := m.server; id != nil {
  38829. return []ent.Value{*id}
  38830. }
  38831. case wx.EdgeAgent:
  38832. if id := m.agent; id != nil {
  38833. return []ent.Value{*id}
  38834. }
  38835. }
  38836. return nil
  38837. }
  38838. // RemovedEdges returns all edge names that were removed in this mutation.
  38839. func (m *WxMutation) RemovedEdges() []string {
  38840. edges := make([]string, 0, 2)
  38841. return edges
  38842. }
  38843. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38844. // the given name in this mutation.
  38845. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  38846. return nil
  38847. }
  38848. // ClearedEdges returns all edge names that were cleared in this mutation.
  38849. func (m *WxMutation) ClearedEdges() []string {
  38850. edges := make([]string, 0, 2)
  38851. if m.clearedserver {
  38852. edges = append(edges, wx.EdgeServer)
  38853. }
  38854. if m.clearedagent {
  38855. edges = append(edges, wx.EdgeAgent)
  38856. }
  38857. return edges
  38858. }
  38859. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38860. // was cleared in this mutation.
  38861. func (m *WxMutation) EdgeCleared(name string) bool {
  38862. switch name {
  38863. case wx.EdgeServer:
  38864. return m.clearedserver
  38865. case wx.EdgeAgent:
  38866. return m.clearedagent
  38867. }
  38868. return false
  38869. }
  38870. // ClearEdge clears the value of the edge with the given name. It returns an error
  38871. // if that edge is not defined in the schema.
  38872. func (m *WxMutation) ClearEdge(name string) error {
  38873. switch name {
  38874. case wx.EdgeServer:
  38875. m.ClearServer()
  38876. return nil
  38877. case wx.EdgeAgent:
  38878. m.ClearAgent()
  38879. return nil
  38880. }
  38881. return fmt.Errorf("unknown Wx unique edge %s", name)
  38882. }
  38883. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38884. // It returns an error if the edge is not defined in the schema.
  38885. func (m *WxMutation) ResetEdge(name string) error {
  38886. switch name {
  38887. case wx.EdgeServer:
  38888. m.ResetServer()
  38889. return nil
  38890. case wx.EdgeAgent:
  38891. m.ResetAgent()
  38892. return nil
  38893. }
  38894. return fmt.Errorf("unknown Wx edge %s", name)
  38895. }
  38896. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  38897. type WxCardMutation struct {
  38898. config
  38899. op Op
  38900. typ string
  38901. id *uint64
  38902. created_at *time.Time
  38903. updated_at *time.Time
  38904. deleted_at *time.Time
  38905. user_id *uint64
  38906. adduser_id *int64
  38907. wx_user_id *uint64
  38908. addwx_user_id *int64
  38909. avatar *string
  38910. logo *string
  38911. name *string
  38912. company *string
  38913. address *string
  38914. phone *string
  38915. official_account *string
  38916. wechat_account *string
  38917. email *string
  38918. api_base *string
  38919. api_key *string
  38920. ai_info *string
  38921. intro *string
  38922. clearedFields map[string]struct{}
  38923. done bool
  38924. oldValue func(context.Context) (*WxCard, error)
  38925. predicates []predicate.WxCard
  38926. }
  38927. var _ ent.Mutation = (*WxCardMutation)(nil)
  38928. // wxcardOption allows management of the mutation configuration using functional options.
  38929. type wxcardOption func(*WxCardMutation)
  38930. // newWxCardMutation creates new mutation for the WxCard entity.
  38931. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  38932. m := &WxCardMutation{
  38933. config: c,
  38934. op: op,
  38935. typ: TypeWxCard,
  38936. clearedFields: make(map[string]struct{}),
  38937. }
  38938. for _, opt := range opts {
  38939. opt(m)
  38940. }
  38941. return m
  38942. }
  38943. // withWxCardID sets the ID field of the mutation.
  38944. func withWxCardID(id uint64) wxcardOption {
  38945. return func(m *WxCardMutation) {
  38946. var (
  38947. err error
  38948. once sync.Once
  38949. value *WxCard
  38950. )
  38951. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  38952. once.Do(func() {
  38953. if m.done {
  38954. err = errors.New("querying old values post mutation is not allowed")
  38955. } else {
  38956. value, err = m.Client().WxCard.Get(ctx, id)
  38957. }
  38958. })
  38959. return value, err
  38960. }
  38961. m.id = &id
  38962. }
  38963. }
  38964. // withWxCard sets the old WxCard of the mutation.
  38965. func withWxCard(node *WxCard) wxcardOption {
  38966. return func(m *WxCardMutation) {
  38967. m.oldValue = func(context.Context) (*WxCard, error) {
  38968. return node, nil
  38969. }
  38970. m.id = &node.ID
  38971. }
  38972. }
  38973. // Client returns a new `ent.Client` from the mutation. If the mutation was
  38974. // executed in a transaction (ent.Tx), a transactional client is returned.
  38975. func (m WxCardMutation) Client() *Client {
  38976. client := &Client{config: m.config}
  38977. client.init()
  38978. return client
  38979. }
  38980. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  38981. // it returns an error otherwise.
  38982. func (m WxCardMutation) Tx() (*Tx, error) {
  38983. if _, ok := m.driver.(*txDriver); !ok {
  38984. return nil, errors.New("ent: mutation is not running in a transaction")
  38985. }
  38986. tx := &Tx{config: m.config}
  38987. tx.init()
  38988. return tx, nil
  38989. }
  38990. // SetID sets the value of the id field. Note that this
  38991. // operation is only accepted on creation of WxCard entities.
  38992. func (m *WxCardMutation) SetID(id uint64) {
  38993. m.id = &id
  38994. }
  38995. // ID returns the ID value in the mutation. Note that the ID is only available
  38996. // if it was provided to the builder or after it was returned from the database.
  38997. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  38998. if m.id == nil {
  38999. return
  39000. }
  39001. return *m.id, true
  39002. }
  39003. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39004. // That means, if the mutation is applied within a transaction with an isolation level such
  39005. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39006. // or updated by the mutation.
  39007. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  39008. switch {
  39009. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39010. id, exists := m.ID()
  39011. if exists {
  39012. return []uint64{id}, nil
  39013. }
  39014. fallthrough
  39015. case m.op.Is(OpUpdate | OpDelete):
  39016. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  39017. default:
  39018. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39019. }
  39020. }
  39021. // SetCreatedAt sets the "created_at" field.
  39022. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  39023. m.created_at = &t
  39024. }
  39025. // CreatedAt returns the value of the "created_at" field in the mutation.
  39026. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  39027. v := m.created_at
  39028. if v == nil {
  39029. return
  39030. }
  39031. return *v, true
  39032. }
  39033. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  39034. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39035. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39036. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39037. if !m.op.Is(OpUpdateOne) {
  39038. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39039. }
  39040. if m.id == nil || m.oldValue == nil {
  39041. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39042. }
  39043. oldValue, err := m.oldValue(ctx)
  39044. if err != nil {
  39045. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39046. }
  39047. return oldValue.CreatedAt, nil
  39048. }
  39049. // ResetCreatedAt resets all changes to the "created_at" field.
  39050. func (m *WxCardMutation) ResetCreatedAt() {
  39051. m.created_at = nil
  39052. }
  39053. // SetUpdatedAt sets the "updated_at" field.
  39054. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  39055. m.updated_at = &t
  39056. }
  39057. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39058. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  39059. v := m.updated_at
  39060. if v == nil {
  39061. return
  39062. }
  39063. return *v, true
  39064. }
  39065. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  39066. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39067. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39068. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39069. if !m.op.Is(OpUpdateOne) {
  39070. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39071. }
  39072. if m.id == nil || m.oldValue == nil {
  39073. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39074. }
  39075. oldValue, err := m.oldValue(ctx)
  39076. if err != nil {
  39077. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39078. }
  39079. return oldValue.UpdatedAt, nil
  39080. }
  39081. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39082. func (m *WxCardMutation) ResetUpdatedAt() {
  39083. m.updated_at = nil
  39084. }
  39085. // SetDeletedAt sets the "deleted_at" field.
  39086. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  39087. m.deleted_at = &t
  39088. }
  39089. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39090. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  39091. v := m.deleted_at
  39092. if v == nil {
  39093. return
  39094. }
  39095. return *v, true
  39096. }
  39097. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  39098. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39100. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39101. if !m.op.Is(OpUpdateOne) {
  39102. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39103. }
  39104. if m.id == nil || m.oldValue == nil {
  39105. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39106. }
  39107. oldValue, err := m.oldValue(ctx)
  39108. if err != nil {
  39109. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39110. }
  39111. return oldValue.DeletedAt, nil
  39112. }
  39113. // ClearDeletedAt clears the value of the "deleted_at" field.
  39114. func (m *WxCardMutation) ClearDeletedAt() {
  39115. m.deleted_at = nil
  39116. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  39117. }
  39118. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39119. func (m *WxCardMutation) DeletedAtCleared() bool {
  39120. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  39121. return ok
  39122. }
  39123. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39124. func (m *WxCardMutation) ResetDeletedAt() {
  39125. m.deleted_at = nil
  39126. delete(m.clearedFields, wxcard.FieldDeletedAt)
  39127. }
  39128. // SetUserID sets the "user_id" field.
  39129. func (m *WxCardMutation) SetUserID(u uint64) {
  39130. m.user_id = &u
  39131. m.adduser_id = nil
  39132. }
  39133. // UserID returns the value of the "user_id" field in the mutation.
  39134. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  39135. v := m.user_id
  39136. if v == nil {
  39137. return
  39138. }
  39139. return *v, true
  39140. }
  39141. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  39142. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39143. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39144. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39145. if !m.op.Is(OpUpdateOne) {
  39146. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39147. }
  39148. if m.id == nil || m.oldValue == nil {
  39149. return v, errors.New("OldUserID requires an ID field in the mutation")
  39150. }
  39151. oldValue, err := m.oldValue(ctx)
  39152. if err != nil {
  39153. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39154. }
  39155. return oldValue.UserID, nil
  39156. }
  39157. // AddUserID adds u to the "user_id" field.
  39158. func (m *WxCardMutation) AddUserID(u int64) {
  39159. if m.adduser_id != nil {
  39160. *m.adduser_id += u
  39161. } else {
  39162. m.adduser_id = &u
  39163. }
  39164. }
  39165. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39166. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  39167. v := m.adduser_id
  39168. if v == nil {
  39169. return
  39170. }
  39171. return *v, true
  39172. }
  39173. // ClearUserID clears the value of the "user_id" field.
  39174. func (m *WxCardMutation) ClearUserID() {
  39175. m.user_id = nil
  39176. m.adduser_id = nil
  39177. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  39178. }
  39179. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39180. func (m *WxCardMutation) UserIDCleared() bool {
  39181. _, ok := m.clearedFields[wxcard.FieldUserID]
  39182. return ok
  39183. }
  39184. // ResetUserID resets all changes to the "user_id" field.
  39185. func (m *WxCardMutation) ResetUserID() {
  39186. m.user_id = nil
  39187. m.adduser_id = nil
  39188. delete(m.clearedFields, wxcard.FieldUserID)
  39189. }
  39190. // SetWxUserID sets the "wx_user_id" field.
  39191. func (m *WxCardMutation) SetWxUserID(u uint64) {
  39192. m.wx_user_id = &u
  39193. m.addwx_user_id = nil
  39194. }
  39195. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  39196. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  39197. v := m.wx_user_id
  39198. if v == nil {
  39199. return
  39200. }
  39201. return *v, true
  39202. }
  39203. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  39204. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39206. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  39207. if !m.op.Is(OpUpdateOne) {
  39208. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  39209. }
  39210. if m.id == nil || m.oldValue == nil {
  39211. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  39212. }
  39213. oldValue, err := m.oldValue(ctx)
  39214. if err != nil {
  39215. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  39216. }
  39217. return oldValue.WxUserID, nil
  39218. }
  39219. // AddWxUserID adds u to the "wx_user_id" field.
  39220. func (m *WxCardMutation) AddWxUserID(u int64) {
  39221. if m.addwx_user_id != nil {
  39222. *m.addwx_user_id += u
  39223. } else {
  39224. m.addwx_user_id = &u
  39225. }
  39226. }
  39227. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  39228. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  39229. v := m.addwx_user_id
  39230. if v == nil {
  39231. return
  39232. }
  39233. return *v, true
  39234. }
  39235. // ClearWxUserID clears the value of the "wx_user_id" field.
  39236. func (m *WxCardMutation) ClearWxUserID() {
  39237. m.wx_user_id = nil
  39238. m.addwx_user_id = nil
  39239. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  39240. }
  39241. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  39242. func (m *WxCardMutation) WxUserIDCleared() bool {
  39243. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  39244. return ok
  39245. }
  39246. // ResetWxUserID resets all changes to the "wx_user_id" field.
  39247. func (m *WxCardMutation) ResetWxUserID() {
  39248. m.wx_user_id = nil
  39249. m.addwx_user_id = nil
  39250. delete(m.clearedFields, wxcard.FieldWxUserID)
  39251. }
  39252. // SetAvatar sets the "avatar" field.
  39253. func (m *WxCardMutation) SetAvatar(s string) {
  39254. m.avatar = &s
  39255. }
  39256. // Avatar returns the value of the "avatar" field in the mutation.
  39257. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  39258. v := m.avatar
  39259. if v == nil {
  39260. return
  39261. }
  39262. return *v, true
  39263. }
  39264. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  39265. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39267. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39268. if !m.op.Is(OpUpdateOne) {
  39269. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39270. }
  39271. if m.id == nil || m.oldValue == nil {
  39272. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39273. }
  39274. oldValue, err := m.oldValue(ctx)
  39275. if err != nil {
  39276. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39277. }
  39278. return oldValue.Avatar, nil
  39279. }
  39280. // ResetAvatar resets all changes to the "avatar" field.
  39281. func (m *WxCardMutation) ResetAvatar() {
  39282. m.avatar = nil
  39283. }
  39284. // SetLogo sets the "logo" field.
  39285. func (m *WxCardMutation) SetLogo(s string) {
  39286. m.logo = &s
  39287. }
  39288. // Logo returns the value of the "logo" field in the mutation.
  39289. func (m *WxCardMutation) Logo() (r string, exists bool) {
  39290. v := m.logo
  39291. if v == nil {
  39292. return
  39293. }
  39294. return *v, true
  39295. }
  39296. // OldLogo returns the old "logo" field's value of the WxCard entity.
  39297. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39298. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39299. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  39300. if !m.op.Is(OpUpdateOne) {
  39301. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  39302. }
  39303. if m.id == nil || m.oldValue == nil {
  39304. return v, errors.New("OldLogo requires an ID field in the mutation")
  39305. }
  39306. oldValue, err := m.oldValue(ctx)
  39307. if err != nil {
  39308. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  39309. }
  39310. return oldValue.Logo, nil
  39311. }
  39312. // ResetLogo resets all changes to the "logo" field.
  39313. func (m *WxCardMutation) ResetLogo() {
  39314. m.logo = nil
  39315. }
  39316. // SetName sets the "name" field.
  39317. func (m *WxCardMutation) SetName(s string) {
  39318. m.name = &s
  39319. }
  39320. // Name returns the value of the "name" field in the mutation.
  39321. func (m *WxCardMutation) Name() (r string, exists bool) {
  39322. v := m.name
  39323. if v == nil {
  39324. return
  39325. }
  39326. return *v, true
  39327. }
  39328. // OldName returns the old "name" field's value of the WxCard entity.
  39329. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39330. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39331. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  39332. if !m.op.Is(OpUpdateOne) {
  39333. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39334. }
  39335. if m.id == nil || m.oldValue == nil {
  39336. return v, errors.New("OldName requires an ID field in the mutation")
  39337. }
  39338. oldValue, err := m.oldValue(ctx)
  39339. if err != nil {
  39340. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39341. }
  39342. return oldValue.Name, nil
  39343. }
  39344. // ResetName resets all changes to the "name" field.
  39345. func (m *WxCardMutation) ResetName() {
  39346. m.name = nil
  39347. }
  39348. // SetCompany sets the "company" field.
  39349. func (m *WxCardMutation) SetCompany(s string) {
  39350. m.company = &s
  39351. }
  39352. // Company returns the value of the "company" field in the mutation.
  39353. func (m *WxCardMutation) Company() (r string, exists bool) {
  39354. v := m.company
  39355. if v == nil {
  39356. return
  39357. }
  39358. return *v, true
  39359. }
  39360. // OldCompany returns the old "company" field's value of the WxCard entity.
  39361. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39363. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  39364. if !m.op.Is(OpUpdateOne) {
  39365. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39366. }
  39367. if m.id == nil || m.oldValue == nil {
  39368. return v, errors.New("OldCompany requires an ID field in the mutation")
  39369. }
  39370. oldValue, err := m.oldValue(ctx)
  39371. if err != nil {
  39372. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39373. }
  39374. return oldValue.Company, nil
  39375. }
  39376. // ResetCompany resets all changes to the "company" field.
  39377. func (m *WxCardMutation) ResetCompany() {
  39378. m.company = nil
  39379. }
  39380. // SetAddress sets the "address" field.
  39381. func (m *WxCardMutation) SetAddress(s string) {
  39382. m.address = &s
  39383. }
  39384. // Address returns the value of the "address" field in the mutation.
  39385. func (m *WxCardMutation) Address() (r string, exists bool) {
  39386. v := m.address
  39387. if v == nil {
  39388. return
  39389. }
  39390. return *v, true
  39391. }
  39392. // OldAddress returns the old "address" field's value of the WxCard entity.
  39393. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39394. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39395. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  39396. if !m.op.Is(OpUpdateOne) {
  39397. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  39398. }
  39399. if m.id == nil || m.oldValue == nil {
  39400. return v, errors.New("OldAddress requires an ID field in the mutation")
  39401. }
  39402. oldValue, err := m.oldValue(ctx)
  39403. if err != nil {
  39404. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  39405. }
  39406. return oldValue.Address, nil
  39407. }
  39408. // ResetAddress resets all changes to the "address" field.
  39409. func (m *WxCardMutation) ResetAddress() {
  39410. m.address = nil
  39411. }
  39412. // SetPhone sets the "phone" field.
  39413. func (m *WxCardMutation) SetPhone(s string) {
  39414. m.phone = &s
  39415. }
  39416. // Phone returns the value of the "phone" field in the mutation.
  39417. func (m *WxCardMutation) Phone() (r string, exists bool) {
  39418. v := m.phone
  39419. if v == nil {
  39420. return
  39421. }
  39422. return *v, true
  39423. }
  39424. // OldPhone returns the old "phone" field's value of the WxCard entity.
  39425. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39426. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39427. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  39428. if !m.op.Is(OpUpdateOne) {
  39429. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39430. }
  39431. if m.id == nil || m.oldValue == nil {
  39432. return v, errors.New("OldPhone requires an ID field in the mutation")
  39433. }
  39434. oldValue, err := m.oldValue(ctx)
  39435. if err != nil {
  39436. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39437. }
  39438. return oldValue.Phone, nil
  39439. }
  39440. // ResetPhone resets all changes to the "phone" field.
  39441. func (m *WxCardMutation) ResetPhone() {
  39442. m.phone = nil
  39443. }
  39444. // SetOfficialAccount sets the "official_account" field.
  39445. func (m *WxCardMutation) SetOfficialAccount(s string) {
  39446. m.official_account = &s
  39447. }
  39448. // OfficialAccount returns the value of the "official_account" field in the mutation.
  39449. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  39450. v := m.official_account
  39451. if v == nil {
  39452. return
  39453. }
  39454. return *v, true
  39455. }
  39456. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  39457. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39458. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39459. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  39460. if !m.op.Is(OpUpdateOne) {
  39461. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  39462. }
  39463. if m.id == nil || m.oldValue == nil {
  39464. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  39465. }
  39466. oldValue, err := m.oldValue(ctx)
  39467. if err != nil {
  39468. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  39469. }
  39470. return oldValue.OfficialAccount, nil
  39471. }
  39472. // ResetOfficialAccount resets all changes to the "official_account" field.
  39473. func (m *WxCardMutation) ResetOfficialAccount() {
  39474. m.official_account = nil
  39475. }
  39476. // SetWechatAccount sets the "wechat_account" field.
  39477. func (m *WxCardMutation) SetWechatAccount(s string) {
  39478. m.wechat_account = &s
  39479. }
  39480. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  39481. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  39482. v := m.wechat_account
  39483. if v == nil {
  39484. return
  39485. }
  39486. return *v, true
  39487. }
  39488. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  39489. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39491. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  39492. if !m.op.Is(OpUpdateOne) {
  39493. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  39494. }
  39495. if m.id == nil || m.oldValue == nil {
  39496. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  39497. }
  39498. oldValue, err := m.oldValue(ctx)
  39499. if err != nil {
  39500. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  39501. }
  39502. return oldValue.WechatAccount, nil
  39503. }
  39504. // ResetWechatAccount resets all changes to the "wechat_account" field.
  39505. func (m *WxCardMutation) ResetWechatAccount() {
  39506. m.wechat_account = nil
  39507. }
  39508. // SetEmail sets the "email" field.
  39509. func (m *WxCardMutation) SetEmail(s string) {
  39510. m.email = &s
  39511. }
  39512. // Email returns the value of the "email" field in the mutation.
  39513. func (m *WxCardMutation) Email() (r string, exists bool) {
  39514. v := m.email
  39515. if v == nil {
  39516. return
  39517. }
  39518. return *v, true
  39519. }
  39520. // OldEmail returns the old "email" field's value of the WxCard entity.
  39521. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39523. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  39524. if !m.op.Is(OpUpdateOne) {
  39525. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  39526. }
  39527. if m.id == nil || m.oldValue == nil {
  39528. return v, errors.New("OldEmail requires an ID field in the mutation")
  39529. }
  39530. oldValue, err := m.oldValue(ctx)
  39531. if err != nil {
  39532. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  39533. }
  39534. return oldValue.Email, nil
  39535. }
  39536. // ClearEmail clears the value of the "email" field.
  39537. func (m *WxCardMutation) ClearEmail() {
  39538. m.email = nil
  39539. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  39540. }
  39541. // EmailCleared returns if the "email" field was cleared in this mutation.
  39542. func (m *WxCardMutation) EmailCleared() bool {
  39543. _, ok := m.clearedFields[wxcard.FieldEmail]
  39544. return ok
  39545. }
  39546. // ResetEmail resets all changes to the "email" field.
  39547. func (m *WxCardMutation) ResetEmail() {
  39548. m.email = nil
  39549. delete(m.clearedFields, wxcard.FieldEmail)
  39550. }
  39551. // SetAPIBase sets the "api_base" field.
  39552. func (m *WxCardMutation) SetAPIBase(s string) {
  39553. m.api_base = &s
  39554. }
  39555. // APIBase returns the value of the "api_base" field in the mutation.
  39556. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  39557. v := m.api_base
  39558. if v == nil {
  39559. return
  39560. }
  39561. return *v, true
  39562. }
  39563. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  39564. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39565. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39566. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39567. if !m.op.Is(OpUpdateOne) {
  39568. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39569. }
  39570. if m.id == nil || m.oldValue == nil {
  39571. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39572. }
  39573. oldValue, err := m.oldValue(ctx)
  39574. if err != nil {
  39575. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39576. }
  39577. return oldValue.APIBase, nil
  39578. }
  39579. // ClearAPIBase clears the value of the "api_base" field.
  39580. func (m *WxCardMutation) ClearAPIBase() {
  39581. m.api_base = nil
  39582. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  39583. }
  39584. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39585. func (m *WxCardMutation) APIBaseCleared() bool {
  39586. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  39587. return ok
  39588. }
  39589. // ResetAPIBase resets all changes to the "api_base" field.
  39590. func (m *WxCardMutation) ResetAPIBase() {
  39591. m.api_base = nil
  39592. delete(m.clearedFields, wxcard.FieldAPIBase)
  39593. }
  39594. // SetAPIKey sets the "api_key" field.
  39595. func (m *WxCardMutation) SetAPIKey(s string) {
  39596. m.api_key = &s
  39597. }
  39598. // APIKey returns the value of the "api_key" field in the mutation.
  39599. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  39600. v := m.api_key
  39601. if v == nil {
  39602. return
  39603. }
  39604. return *v, true
  39605. }
  39606. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  39607. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39609. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39610. if !m.op.Is(OpUpdateOne) {
  39611. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39612. }
  39613. if m.id == nil || m.oldValue == nil {
  39614. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39615. }
  39616. oldValue, err := m.oldValue(ctx)
  39617. if err != nil {
  39618. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39619. }
  39620. return oldValue.APIKey, nil
  39621. }
  39622. // ClearAPIKey clears the value of the "api_key" field.
  39623. func (m *WxCardMutation) ClearAPIKey() {
  39624. m.api_key = nil
  39625. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  39626. }
  39627. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39628. func (m *WxCardMutation) APIKeyCleared() bool {
  39629. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  39630. return ok
  39631. }
  39632. // ResetAPIKey resets all changes to the "api_key" field.
  39633. func (m *WxCardMutation) ResetAPIKey() {
  39634. m.api_key = nil
  39635. delete(m.clearedFields, wxcard.FieldAPIKey)
  39636. }
  39637. // SetAiInfo sets the "ai_info" field.
  39638. func (m *WxCardMutation) SetAiInfo(s string) {
  39639. m.ai_info = &s
  39640. }
  39641. // AiInfo returns the value of the "ai_info" field in the mutation.
  39642. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  39643. v := m.ai_info
  39644. if v == nil {
  39645. return
  39646. }
  39647. return *v, true
  39648. }
  39649. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  39650. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39652. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  39653. if !m.op.Is(OpUpdateOne) {
  39654. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  39655. }
  39656. if m.id == nil || m.oldValue == nil {
  39657. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  39658. }
  39659. oldValue, err := m.oldValue(ctx)
  39660. if err != nil {
  39661. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  39662. }
  39663. return oldValue.AiInfo, nil
  39664. }
  39665. // ClearAiInfo clears the value of the "ai_info" field.
  39666. func (m *WxCardMutation) ClearAiInfo() {
  39667. m.ai_info = nil
  39668. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  39669. }
  39670. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  39671. func (m *WxCardMutation) AiInfoCleared() bool {
  39672. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  39673. return ok
  39674. }
  39675. // ResetAiInfo resets all changes to the "ai_info" field.
  39676. func (m *WxCardMutation) ResetAiInfo() {
  39677. m.ai_info = nil
  39678. delete(m.clearedFields, wxcard.FieldAiInfo)
  39679. }
  39680. // SetIntro sets the "intro" field.
  39681. func (m *WxCardMutation) SetIntro(s string) {
  39682. m.intro = &s
  39683. }
  39684. // Intro returns the value of the "intro" field in the mutation.
  39685. func (m *WxCardMutation) Intro() (r string, exists bool) {
  39686. v := m.intro
  39687. if v == nil {
  39688. return
  39689. }
  39690. return *v, true
  39691. }
  39692. // OldIntro returns the old "intro" field's value of the WxCard entity.
  39693. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39694. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39695. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  39696. if !m.op.Is(OpUpdateOne) {
  39697. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  39698. }
  39699. if m.id == nil || m.oldValue == nil {
  39700. return v, errors.New("OldIntro requires an ID field in the mutation")
  39701. }
  39702. oldValue, err := m.oldValue(ctx)
  39703. if err != nil {
  39704. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  39705. }
  39706. return oldValue.Intro, nil
  39707. }
  39708. // ClearIntro clears the value of the "intro" field.
  39709. func (m *WxCardMutation) ClearIntro() {
  39710. m.intro = nil
  39711. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  39712. }
  39713. // IntroCleared returns if the "intro" field was cleared in this mutation.
  39714. func (m *WxCardMutation) IntroCleared() bool {
  39715. _, ok := m.clearedFields[wxcard.FieldIntro]
  39716. return ok
  39717. }
  39718. // ResetIntro resets all changes to the "intro" field.
  39719. func (m *WxCardMutation) ResetIntro() {
  39720. m.intro = nil
  39721. delete(m.clearedFields, wxcard.FieldIntro)
  39722. }
  39723. // Where appends a list predicates to the WxCardMutation builder.
  39724. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  39725. m.predicates = append(m.predicates, ps...)
  39726. }
  39727. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  39728. // users can use type-assertion to append predicates that do not depend on any generated package.
  39729. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  39730. p := make([]predicate.WxCard, len(ps))
  39731. for i := range ps {
  39732. p[i] = ps[i]
  39733. }
  39734. m.Where(p...)
  39735. }
  39736. // Op returns the operation name.
  39737. func (m *WxCardMutation) Op() Op {
  39738. return m.op
  39739. }
  39740. // SetOp allows setting the mutation operation.
  39741. func (m *WxCardMutation) SetOp(op Op) {
  39742. m.op = op
  39743. }
  39744. // Type returns the node type of this mutation (WxCard).
  39745. func (m *WxCardMutation) Type() string {
  39746. return m.typ
  39747. }
  39748. // Fields returns all fields that were changed during this mutation. Note that in
  39749. // order to get all numeric fields that were incremented/decremented, call
  39750. // AddedFields().
  39751. func (m *WxCardMutation) Fields() []string {
  39752. fields := make([]string, 0, 18)
  39753. if m.created_at != nil {
  39754. fields = append(fields, wxcard.FieldCreatedAt)
  39755. }
  39756. if m.updated_at != nil {
  39757. fields = append(fields, wxcard.FieldUpdatedAt)
  39758. }
  39759. if m.deleted_at != nil {
  39760. fields = append(fields, wxcard.FieldDeletedAt)
  39761. }
  39762. if m.user_id != nil {
  39763. fields = append(fields, wxcard.FieldUserID)
  39764. }
  39765. if m.wx_user_id != nil {
  39766. fields = append(fields, wxcard.FieldWxUserID)
  39767. }
  39768. if m.avatar != nil {
  39769. fields = append(fields, wxcard.FieldAvatar)
  39770. }
  39771. if m.logo != nil {
  39772. fields = append(fields, wxcard.FieldLogo)
  39773. }
  39774. if m.name != nil {
  39775. fields = append(fields, wxcard.FieldName)
  39776. }
  39777. if m.company != nil {
  39778. fields = append(fields, wxcard.FieldCompany)
  39779. }
  39780. if m.address != nil {
  39781. fields = append(fields, wxcard.FieldAddress)
  39782. }
  39783. if m.phone != nil {
  39784. fields = append(fields, wxcard.FieldPhone)
  39785. }
  39786. if m.official_account != nil {
  39787. fields = append(fields, wxcard.FieldOfficialAccount)
  39788. }
  39789. if m.wechat_account != nil {
  39790. fields = append(fields, wxcard.FieldWechatAccount)
  39791. }
  39792. if m.email != nil {
  39793. fields = append(fields, wxcard.FieldEmail)
  39794. }
  39795. if m.api_base != nil {
  39796. fields = append(fields, wxcard.FieldAPIBase)
  39797. }
  39798. if m.api_key != nil {
  39799. fields = append(fields, wxcard.FieldAPIKey)
  39800. }
  39801. if m.ai_info != nil {
  39802. fields = append(fields, wxcard.FieldAiInfo)
  39803. }
  39804. if m.intro != nil {
  39805. fields = append(fields, wxcard.FieldIntro)
  39806. }
  39807. return fields
  39808. }
  39809. // Field returns the value of a field with the given name. The second boolean
  39810. // return value indicates that this field was not set, or was not defined in the
  39811. // schema.
  39812. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  39813. switch name {
  39814. case wxcard.FieldCreatedAt:
  39815. return m.CreatedAt()
  39816. case wxcard.FieldUpdatedAt:
  39817. return m.UpdatedAt()
  39818. case wxcard.FieldDeletedAt:
  39819. return m.DeletedAt()
  39820. case wxcard.FieldUserID:
  39821. return m.UserID()
  39822. case wxcard.FieldWxUserID:
  39823. return m.WxUserID()
  39824. case wxcard.FieldAvatar:
  39825. return m.Avatar()
  39826. case wxcard.FieldLogo:
  39827. return m.Logo()
  39828. case wxcard.FieldName:
  39829. return m.Name()
  39830. case wxcard.FieldCompany:
  39831. return m.Company()
  39832. case wxcard.FieldAddress:
  39833. return m.Address()
  39834. case wxcard.FieldPhone:
  39835. return m.Phone()
  39836. case wxcard.FieldOfficialAccount:
  39837. return m.OfficialAccount()
  39838. case wxcard.FieldWechatAccount:
  39839. return m.WechatAccount()
  39840. case wxcard.FieldEmail:
  39841. return m.Email()
  39842. case wxcard.FieldAPIBase:
  39843. return m.APIBase()
  39844. case wxcard.FieldAPIKey:
  39845. return m.APIKey()
  39846. case wxcard.FieldAiInfo:
  39847. return m.AiInfo()
  39848. case wxcard.FieldIntro:
  39849. return m.Intro()
  39850. }
  39851. return nil, false
  39852. }
  39853. // OldField returns the old value of the field from the database. An error is
  39854. // returned if the mutation operation is not UpdateOne, or the query to the
  39855. // database failed.
  39856. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39857. switch name {
  39858. case wxcard.FieldCreatedAt:
  39859. return m.OldCreatedAt(ctx)
  39860. case wxcard.FieldUpdatedAt:
  39861. return m.OldUpdatedAt(ctx)
  39862. case wxcard.FieldDeletedAt:
  39863. return m.OldDeletedAt(ctx)
  39864. case wxcard.FieldUserID:
  39865. return m.OldUserID(ctx)
  39866. case wxcard.FieldWxUserID:
  39867. return m.OldWxUserID(ctx)
  39868. case wxcard.FieldAvatar:
  39869. return m.OldAvatar(ctx)
  39870. case wxcard.FieldLogo:
  39871. return m.OldLogo(ctx)
  39872. case wxcard.FieldName:
  39873. return m.OldName(ctx)
  39874. case wxcard.FieldCompany:
  39875. return m.OldCompany(ctx)
  39876. case wxcard.FieldAddress:
  39877. return m.OldAddress(ctx)
  39878. case wxcard.FieldPhone:
  39879. return m.OldPhone(ctx)
  39880. case wxcard.FieldOfficialAccount:
  39881. return m.OldOfficialAccount(ctx)
  39882. case wxcard.FieldWechatAccount:
  39883. return m.OldWechatAccount(ctx)
  39884. case wxcard.FieldEmail:
  39885. return m.OldEmail(ctx)
  39886. case wxcard.FieldAPIBase:
  39887. return m.OldAPIBase(ctx)
  39888. case wxcard.FieldAPIKey:
  39889. return m.OldAPIKey(ctx)
  39890. case wxcard.FieldAiInfo:
  39891. return m.OldAiInfo(ctx)
  39892. case wxcard.FieldIntro:
  39893. return m.OldIntro(ctx)
  39894. }
  39895. return nil, fmt.Errorf("unknown WxCard field %s", name)
  39896. }
  39897. // SetField sets the value of a field with the given name. It returns an error if
  39898. // the field is not defined in the schema, or if the type mismatched the field
  39899. // type.
  39900. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  39901. switch name {
  39902. case wxcard.FieldCreatedAt:
  39903. v, ok := value.(time.Time)
  39904. if !ok {
  39905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39906. }
  39907. m.SetCreatedAt(v)
  39908. return nil
  39909. case wxcard.FieldUpdatedAt:
  39910. v, ok := value.(time.Time)
  39911. if !ok {
  39912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39913. }
  39914. m.SetUpdatedAt(v)
  39915. return nil
  39916. case wxcard.FieldDeletedAt:
  39917. v, ok := value.(time.Time)
  39918. if !ok {
  39919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39920. }
  39921. m.SetDeletedAt(v)
  39922. return nil
  39923. case wxcard.FieldUserID:
  39924. v, ok := value.(uint64)
  39925. if !ok {
  39926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39927. }
  39928. m.SetUserID(v)
  39929. return nil
  39930. case wxcard.FieldWxUserID:
  39931. v, ok := value.(uint64)
  39932. if !ok {
  39933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39934. }
  39935. m.SetWxUserID(v)
  39936. return nil
  39937. case wxcard.FieldAvatar:
  39938. v, ok := value.(string)
  39939. if !ok {
  39940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39941. }
  39942. m.SetAvatar(v)
  39943. return nil
  39944. case wxcard.FieldLogo:
  39945. v, ok := value.(string)
  39946. if !ok {
  39947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39948. }
  39949. m.SetLogo(v)
  39950. return nil
  39951. case wxcard.FieldName:
  39952. v, ok := value.(string)
  39953. if !ok {
  39954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39955. }
  39956. m.SetName(v)
  39957. return nil
  39958. case wxcard.FieldCompany:
  39959. v, ok := value.(string)
  39960. if !ok {
  39961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39962. }
  39963. m.SetCompany(v)
  39964. return nil
  39965. case wxcard.FieldAddress:
  39966. v, ok := value.(string)
  39967. if !ok {
  39968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39969. }
  39970. m.SetAddress(v)
  39971. return nil
  39972. case wxcard.FieldPhone:
  39973. v, ok := value.(string)
  39974. if !ok {
  39975. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39976. }
  39977. m.SetPhone(v)
  39978. return nil
  39979. case wxcard.FieldOfficialAccount:
  39980. v, ok := value.(string)
  39981. if !ok {
  39982. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39983. }
  39984. m.SetOfficialAccount(v)
  39985. return nil
  39986. case wxcard.FieldWechatAccount:
  39987. v, ok := value.(string)
  39988. if !ok {
  39989. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39990. }
  39991. m.SetWechatAccount(v)
  39992. return nil
  39993. case wxcard.FieldEmail:
  39994. v, ok := value.(string)
  39995. if !ok {
  39996. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39997. }
  39998. m.SetEmail(v)
  39999. return nil
  40000. case wxcard.FieldAPIBase:
  40001. v, ok := value.(string)
  40002. if !ok {
  40003. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40004. }
  40005. m.SetAPIBase(v)
  40006. return nil
  40007. case wxcard.FieldAPIKey:
  40008. v, ok := value.(string)
  40009. if !ok {
  40010. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40011. }
  40012. m.SetAPIKey(v)
  40013. return nil
  40014. case wxcard.FieldAiInfo:
  40015. v, ok := value.(string)
  40016. if !ok {
  40017. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40018. }
  40019. m.SetAiInfo(v)
  40020. return nil
  40021. case wxcard.FieldIntro:
  40022. v, ok := value.(string)
  40023. if !ok {
  40024. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40025. }
  40026. m.SetIntro(v)
  40027. return nil
  40028. }
  40029. return fmt.Errorf("unknown WxCard field %s", name)
  40030. }
  40031. // AddedFields returns all numeric fields that were incremented/decremented during
  40032. // this mutation.
  40033. func (m *WxCardMutation) AddedFields() []string {
  40034. var fields []string
  40035. if m.adduser_id != nil {
  40036. fields = append(fields, wxcard.FieldUserID)
  40037. }
  40038. if m.addwx_user_id != nil {
  40039. fields = append(fields, wxcard.FieldWxUserID)
  40040. }
  40041. return fields
  40042. }
  40043. // AddedField returns the numeric value that was incremented/decremented on a field
  40044. // with the given name. The second boolean return value indicates that this field
  40045. // was not set, or was not defined in the schema.
  40046. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  40047. switch name {
  40048. case wxcard.FieldUserID:
  40049. return m.AddedUserID()
  40050. case wxcard.FieldWxUserID:
  40051. return m.AddedWxUserID()
  40052. }
  40053. return nil, false
  40054. }
  40055. // AddField adds the value to the field with the given name. It returns an error if
  40056. // the field is not defined in the schema, or if the type mismatched the field
  40057. // type.
  40058. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  40059. switch name {
  40060. case wxcard.FieldUserID:
  40061. v, ok := value.(int64)
  40062. if !ok {
  40063. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40064. }
  40065. m.AddUserID(v)
  40066. return nil
  40067. case wxcard.FieldWxUserID:
  40068. v, ok := value.(int64)
  40069. if !ok {
  40070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40071. }
  40072. m.AddWxUserID(v)
  40073. return nil
  40074. }
  40075. return fmt.Errorf("unknown WxCard numeric field %s", name)
  40076. }
  40077. // ClearedFields returns all nullable fields that were cleared during this
  40078. // mutation.
  40079. func (m *WxCardMutation) ClearedFields() []string {
  40080. var fields []string
  40081. if m.FieldCleared(wxcard.FieldDeletedAt) {
  40082. fields = append(fields, wxcard.FieldDeletedAt)
  40083. }
  40084. if m.FieldCleared(wxcard.FieldUserID) {
  40085. fields = append(fields, wxcard.FieldUserID)
  40086. }
  40087. if m.FieldCleared(wxcard.FieldWxUserID) {
  40088. fields = append(fields, wxcard.FieldWxUserID)
  40089. }
  40090. if m.FieldCleared(wxcard.FieldEmail) {
  40091. fields = append(fields, wxcard.FieldEmail)
  40092. }
  40093. if m.FieldCleared(wxcard.FieldAPIBase) {
  40094. fields = append(fields, wxcard.FieldAPIBase)
  40095. }
  40096. if m.FieldCleared(wxcard.FieldAPIKey) {
  40097. fields = append(fields, wxcard.FieldAPIKey)
  40098. }
  40099. if m.FieldCleared(wxcard.FieldAiInfo) {
  40100. fields = append(fields, wxcard.FieldAiInfo)
  40101. }
  40102. if m.FieldCleared(wxcard.FieldIntro) {
  40103. fields = append(fields, wxcard.FieldIntro)
  40104. }
  40105. return fields
  40106. }
  40107. // FieldCleared returns a boolean indicating if a field with the given name was
  40108. // cleared in this mutation.
  40109. func (m *WxCardMutation) FieldCleared(name string) bool {
  40110. _, ok := m.clearedFields[name]
  40111. return ok
  40112. }
  40113. // ClearField clears the value of the field with the given name. It returns an
  40114. // error if the field is not defined in the schema.
  40115. func (m *WxCardMutation) ClearField(name string) error {
  40116. switch name {
  40117. case wxcard.FieldDeletedAt:
  40118. m.ClearDeletedAt()
  40119. return nil
  40120. case wxcard.FieldUserID:
  40121. m.ClearUserID()
  40122. return nil
  40123. case wxcard.FieldWxUserID:
  40124. m.ClearWxUserID()
  40125. return nil
  40126. case wxcard.FieldEmail:
  40127. m.ClearEmail()
  40128. return nil
  40129. case wxcard.FieldAPIBase:
  40130. m.ClearAPIBase()
  40131. return nil
  40132. case wxcard.FieldAPIKey:
  40133. m.ClearAPIKey()
  40134. return nil
  40135. case wxcard.FieldAiInfo:
  40136. m.ClearAiInfo()
  40137. return nil
  40138. case wxcard.FieldIntro:
  40139. m.ClearIntro()
  40140. return nil
  40141. }
  40142. return fmt.Errorf("unknown WxCard nullable field %s", name)
  40143. }
  40144. // ResetField resets all changes in the mutation for the field with the given name.
  40145. // It returns an error if the field is not defined in the schema.
  40146. func (m *WxCardMutation) ResetField(name string) error {
  40147. switch name {
  40148. case wxcard.FieldCreatedAt:
  40149. m.ResetCreatedAt()
  40150. return nil
  40151. case wxcard.FieldUpdatedAt:
  40152. m.ResetUpdatedAt()
  40153. return nil
  40154. case wxcard.FieldDeletedAt:
  40155. m.ResetDeletedAt()
  40156. return nil
  40157. case wxcard.FieldUserID:
  40158. m.ResetUserID()
  40159. return nil
  40160. case wxcard.FieldWxUserID:
  40161. m.ResetWxUserID()
  40162. return nil
  40163. case wxcard.FieldAvatar:
  40164. m.ResetAvatar()
  40165. return nil
  40166. case wxcard.FieldLogo:
  40167. m.ResetLogo()
  40168. return nil
  40169. case wxcard.FieldName:
  40170. m.ResetName()
  40171. return nil
  40172. case wxcard.FieldCompany:
  40173. m.ResetCompany()
  40174. return nil
  40175. case wxcard.FieldAddress:
  40176. m.ResetAddress()
  40177. return nil
  40178. case wxcard.FieldPhone:
  40179. m.ResetPhone()
  40180. return nil
  40181. case wxcard.FieldOfficialAccount:
  40182. m.ResetOfficialAccount()
  40183. return nil
  40184. case wxcard.FieldWechatAccount:
  40185. m.ResetWechatAccount()
  40186. return nil
  40187. case wxcard.FieldEmail:
  40188. m.ResetEmail()
  40189. return nil
  40190. case wxcard.FieldAPIBase:
  40191. m.ResetAPIBase()
  40192. return nil
  40193. case wxcard.FieldAPIKey:
  40194. m.ResetAPIKey()
  40195. return nil
  40196. case wxcard.FieldAiInfo:
  40197. m.ResetAiInfo()
  40198. return nil
  40199. case wxcard.FieldIntro:
  40200. m.ResetIntro()
  40201. return nil
  40202. }
  40203. return fmt.Errorf("unknown WxCard field %s", name)
  40204. }
  40205. // AddedEdges returns all edge names that were set/added in this mutation.
  40206. func (m *WxCardMutation) AddedEdges() []string {
  40207. edges := make([]string, 0, 0)
  40208. return edges
  40209. }
  40210. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40211. // name in this mutation.
  40212. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  40213. return nil
  40214. }
  40215. // RemovedEdges returns all edge names that were removed in this mutation.
  40216. func (m *WxCardMutation) RemovedEdges() []string {
  40217. edges := make([]string, 0, 0)
  40218. return edges
  40219. }
  40220. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40221. // the given name in this mutation.
  40222. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  40223. return nil
  40224. }
  40225. // ClearedEdges returns all edge names that were cleared in this mutation.
  40226. func (m *WxCardMutation) ClearedEdges() []string {
  40227. edges := make([]string, 0, 0)
  40228. return edges
  40229. }
  40230. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40231. // was cleared in this mutation.
  40232. func (m *WxCardMutation) EdgeCleared(name string) bool {
  40233. return false
  40234. }
  40235. // ClearEdge clears the value of the edge with the given name. It returns an error
  40236. // if that edge is not defined in the schema.
  40237. func (m *WxCardMutation) ClearEdge(name string) error {
  40238. return fmt.Errorf("unknown WxCard unique edge %s", name)
  40239. }
  40240. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40241. // It returns an error if the edge is not defined in the schema.
  40242. func (m *WxCardMutation) ResetEdge(name string) error {
  40243. return fmt.Errorf("unknown WxCard edge %s", name)
  40244. }
  40245. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  40246. type WxCardUserMutation struct {
  40247. config
  40248. op Op
  40249. typ string
  40250. id *uint64
  40251. created_at *time.Time
  40252. updated_at *time.Time
  40253. deleted_at *time.Time
  40254. wxid *string
  40255. account *string
  40256. avatar *string
  40257. nickname *string
  40258. remark *string
  40259. phone *string
  40260. open_id *string
  40261. union_id *string
  40262. session_key *string
  40263. is_vip *int
  40264. addis_vip *int
  40265. clearedFields map[string]struct{}
  40266. done bool
  40267. oldValue func(context.Context) (*WxCardUser, error)
  40268. predicates []predicate.WxCardUser
  40269. }
  40270. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  40271. // wxcarduserOption allows management of the mutation configuration using functional options.
  40272. type wxcarduserOption func(*WxCardUserMutation)
  40273. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  40274. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  40275. m := &WxCardUserMutation{
  40276. config: c,
  40277. op: op,
  40278. typ: TypeWxCardUser,
  40279. clearedFields: make(map[string]struct{}),
  40280. }
  40281. for _, opt := range opts {
  40282. opt(m)
  40283. }
  40284. return m
  40285. }
  40286. // withWxCardUserID sets the ID field of the mutation.
  40287. func withWxCardUserID(id uint64) wxcarduserOption {
  40288. return func(m *WxCardUserMutation) {
  40289. var (
  40290. err error
  40291. once sync.Once
  40292. value *WxCardUser
  40293. )
  40294. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  40295. once.Do(func() {
  40296. if m.done {
  40297. err = errors.New("querying old values post mutation is not allowed")
  40298. } else {
  40299. value, err = m.Client().WxCardUser.Get(ctx, id)
  40300. }
  40301. })
  40302. return value, err
  40303. }
  40304. m.id = &id
  40305. }
  40306. }
  40307. // withWxCardUser sets the old WxCardUser of the mutation.
  40308. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  40309. return func(m *WxCardUserMutation) {
  40310. m.oldValue = func(context.Context) (*WxCardUser, error) {
  40311. return node, nil
  40312. }
  40313. m.id = &node.ID
  40314. }
  40315. }
  40316. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40317. // executed in a transaction (ent.Tx), a transactional client is returned.
  40318. func (m WxCardUserMutation) Client() *Client {
  40319. client := &Client{config: m.config}
  40320. client.init()
  40321. return client
  40322. }
  40323. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40324. // it returns an error otherwise.
  40325. func (m WxCardUserMutation) Tx() (*Tx, error) {
  40326. if _, ok := m.driver.(*txDriver); !ok {
  40327. return nil, errors.New("ent: mutation is not running in a transaction")
  40328. }
  40329. tx := &Tx{config: m.config}
  40330. tx.init()
  40331. return tx, nil
  40332. }
  40333. // SetID sets the value of the id field. Note that this
  40334. // operation is only accepted on creation of WxCardUser entities.
  40335. func (m *WxCardUserMutation) SetID(id uint64) {
  40336. m.id = &id
  40337. }
  40338. // ID returns the ID value in the mutation. Note that the ID is only available
  40339. // if it was provided to the builder or after it was returned from the database.
  40340. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  40341. if m.id == nil {
  40342. return
  40343. }
  40344. return *m.id, true
  40345. }
  40346. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40347. // That means, if the mutation is applied within a transaction with an isolation level such
  40348. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40349. // or updated by the mutation.
  40350. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  40351. switch {
  40352. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40353. id, exists := m.ID()
  40354. if exists {
  40355. return []uint64{id}, nil
  40356. }
  40357. fallthrough
  40358. case m.op.Is(OpUpdate | OpDelete):
  40359. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  40360. default:
  40361. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40362. }
  40363. }
  40364. // SetCreatedAt sets the "created_at" field.
  40365. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  40366. m.created_at = &t
  40367. }
  40368. // CreatedAt returns the value of the "created_at" field in the mutation.
  40369. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  40370. v := m.created_at
  40371. if v == nil {
  40372. return
  40373. }
  40374. return *v, true
  40375. }
  40376. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  40377. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40379. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40380. if !m.op.Is(OpUpdateOne) {
  40381. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40382. }
  40383. if m.id == nil || m.oldValue == nil {
  40384. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40385. }
  40386. oldValue, err := m.oldValue(ctx)
  40387. if err != nil {
  40388. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40389. }
  40390. return oldValue.CreatedAt, nil
  40391. }
  40392. // ResetCreatedAt resets all changes to the "created_at" field.
  40393. func (m *WxCardUserMutation) ResetCreatedAt() {
  40394. m.created_at = nil
  40395. }
  40396. // SetUpdatedAt sets the "updated_at" field.
  40397. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  40398. m.updated_at = &t
  40399. }
  40400. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40401. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  40402. v := m.updated_at
  40403. if v == nil {
  40404. return
  40405. }
  40406. return *v, true
  40407. }
  40408. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  40409. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40411. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40412. if !m.op.Is(OpUpdateOne) {
  40413. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40414. }
  40415. if m.id == nil || m.oldValue == nil {
  40416. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40417. }
  40418. oldValue, err := m.oldValue(ctx)
  40419. if err != nil {
  40420. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40421. }
  40422. return oldValue.UpdatedAt, nil
  40423. }
  40424. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40425. func (m *WxCardUserMutation) ResetUpdatedAt() {
  40426. m.updated_at = nil
  40427. }
  40428. // SetDeletedAt sets the "deleted_at" field.
  40429. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  40430. m.deleted_at = &t
  40431. }
  40432. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40433. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  40434. v := m.deleted_at
  40435. if v == nil {
  40436. return
  40437. }
  40438. return *v, true
  40439. }
  40440. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  40441. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40443. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40444. if !m.op.Is(OpUpdateOne) {
  40445. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40446. }
  40447. if m.id == nil || m.oldValue == nil {
  40448. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40449. }
  40450. oldValue, err := m.oldValue(ctx)
  40451. if err != nil {
  40452. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40453. }
  40454. return oldValue.DeletedAt, nil
  40455. }
  40456. // ClearDeletedAt clears the value of the "deleted_at" field.
  40457. func (m *WxCardUserMutation) ClearDeletedAt() {
  40458. m.deleted_at = nil
  40459. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  40460. }
  40461. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40462. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  40463. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  40464. return ok
  40465. }
  40466. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40467. func (m *WxCardUserMutation) ResetDeletedAt() {
  40468. m.deleted_at = nil
  40469. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  40470. }
  40471. // SetWxid sets the "wxid" field.
  40472. func (m *WxCardUserMutation) SetWxid(s string) {
  40473. m.wxid = &s
  40474. }
  40475. // Wxid returns the value of the "wxid" field in the mutation.
  40476. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  40477. v := m.wxid
  40478. if v == nil {
  40479. return
  40480. }
  40481. return *v, true
  40482. }
  40483. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  40484. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40486. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  40487. if !m.op.Is(OpUpdateOne) {
  40488. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40489. }
  40490. if m.id == nil || m.oldValue == nil {
  40491. return v, errors.New("OldWxid requires an ID field in the mutation")
  40492. }
  40493. oldValue, err := m.oldValue(ctx)
  40494. if err != nil {
  40495. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40496. }
  40497. return oldValue.Wxid, nil
  40498. }
  40499. // ResetWxid resets all changes to the "wxid" field.
  40500. func (m *WxCardUserMutation) ResetWxid() {
  40501. m.wxid = nil
  40502. }
  40503. // SetAccount sets the "account" field.
  40504. func (m *WxCardUserMutation) SetAccount(s string) {
  40505. m.account = &s
  40506. }
  40507. // Account returns the value of the "account" field in the mutation.
  40508. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  40509. v := m.account
  40510. if v == nil {
  40511. return
  40512. }
  40513. return *v, true
  40514. }
  40515. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  40516. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40518. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  40519. if !m.op.Is(OpUpdateOne) {
  40520. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40521. }
  40522. if m.id == nil || m.oldValue == nil {
  40523. return v, errors.New("OldAccount requires an ID field in the mutation")
  40524. }
  40525. oldValue, err := m.oldValue(ctx)
  40526. if err != nil {
  40527. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40528. }
  40529. return oldValue.Account, nil
  40530. }
  40531. // ResetAccount resets all changes to the "account" field.
  40532. func (m *WxCardUserMutation) ResetAccount() {
  40533. m.account = nil
  40534. }
  40535. // SetAvatar sets the "avatar" field.
  40536. func (m *WxCardUserMutation) SetAvatar(s string) {
  40537. m.avatar = &s
  40538. }
  40539. // Avatar returns the value of the "avatar" field in the mutation.
  40540. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  40541. v := m.avatar
  40542. if v == nil {
  40543. return
  40544. }
  40545. return *v, true
  40546. }
  40547. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  40548. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40550. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40551. if !m.op.Is(OpUpdateOne) {
  40552. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40553. }
  40554. if m.id == nil || m.oldValue == nil {
  40555. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40556. }
  40557. oldValue, err := m.oldValue(ctx)
  40558. if err != nil {
  40559. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40560. }
  40561. return oldValue.Avatar, nil
  40562. }
  40563. // ResetAvatar resets all changes to the "avatar" field.
  40564. func (m *WxCardUserMutation) ResetAvatar() {
  40565. m.avatar = nil
  40566. }
  40567. // SetNickname sets the "nickname" field.
  40568. func (m *WxCardUserMutation) SetNickname(s string) {
  40569. m.nickname = &s
  40570. }
  40571. // Nickname returns the value of the "nickname" field in the mutation.
  40572. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  40573. v := m.nickname
  40574. if v == nil {
  40575. return
  40576. }
  40577. return *v, true
  40578. }
  40579. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  40580. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40581. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40582. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  40583. if !m.op.Is(OpUpdateOne) {
  40584. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40585. }
  40586. if m.id == nil || m.oldValue == nil {
  40587. return v, errors.New("OldNickname requires an ID field in the mutation")
  40588. }
  40589. oldValue, err := m.oldValue(ctx)
  40590. if err != nil {
  40591. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40592. }
  40593. return oldValue.Nickname, nil
  40594. }
  40595. // ResetNickname resets all changes to the "nickname" field.
  40596. func (m *WxCardUserMutation) ResetNickname() {
  40597. m.nickname = nil
  40598. }
  40599. // SetRemark sets the "remark" field.
  40600. func (m *WxCardUserMutation) SetRemark(s string) {
  40601. m.remark = &s
  40602. }
  40603. // Remark returns the value of the "remark" field in the mutation.
  40604. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  40605. v := m.remark
  40606. if v == nil {
  40607. return
  40608. }
  40609. return *v, true
  40610. }
  40611. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  40612. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40613. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40614. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  40615. if !m.op.Is(OpUpdateOne) {
  40616. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  40617. }
  40618. if m.id == nil || m.oldValue == nil {
  40619. return v, errors.New("OldRemark requires an ID field in the mutation")
  40620. }
  40621. oldValue, err := m.oldValue(ctx)
  40622. if err != nil {
  40623. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  40624. }
  40625. return oldValue.Remark, nil
  40626. }
  40627. // ResetRemark resets all changes to the "remark" field.
  40628. func (m *WxCardUserMutation) ResetRemark() {
  40629. m.remark = nil
  40630. }
  40631. // SetPhone sets the "phone" field.
  40632. func (m *WxCardUserMutation) SetPhone(s string) {
  40633. m.phone = &s
  40634. }
  40635. // Phone returns the value of the "phone" field in the mutation.
  40636. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  40637. v := m.phone
  40638. if v == nil {
  40639. return
  40640. }
  40641. return *v, true
  40642. }
  40643. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  40644. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40645. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40646. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  40647. if !m.op.Is(OpUpdateOne) {
  40648. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40649. }
  40650. if m.id == nil || m.oldValue == nil {
  40651. return v, errors.New("OldPhone requires an ID field in the mutation")
  40652. }
  40653. oldValue, err := m.oldValue(ctx)
  40654. if err != nil {
  40655. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40656. }
  40657. return oldValue.Phone, nil
  40658. }
  40659. // ResetPhone resets all changes to the "phone" field.
  40660. func (m *WxCardUserMutation) ResetPhone() {
  40661. m.phone = nil
  40662. }
  40663. // SetOpenID sets the "open_id" field.
  40664. func (m *WxCardUserMutation) SetOpenID(s string) {
  40665. m.open_id = &s
  40666. }
  40667. // OpenID returns the value of the "open_id" field in the mutation.
  40668. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  40669. v := m.open_id
  40670. if v == nil {
  40671. return
  40672. }
  40673. return *v, true
  40674. }
  40675. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  40676. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40677. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40678. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  40679. if !m.op.Is(OpUpdateOne) {
  40680. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  40681. }
  40682. if m.id == nil || m.oldValue == nil {
  40683. return v, errors.New("OldOpenID requires an ID field in the mutation")
  40684. }
  40685. oldValue, err := m.oldValue(ctx)
  40686. if err != nil {
  40687. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  40688. }
  40689. return oldValue.OpenID, nil
  40690. }
  40691. // ResetOpenID resets all changes to the "open_id" field.
  40692. func (m *WxCardUserMutation) ResetOpenID() {
  40693. m.open_id = nil
  40694. }
  40695. // SetUnionID sets the "union_id" field.
  40696. func (m *WxCardUserMutation) SetUnionID(s string) {
  40697. m.union_id = &s
  40698. }
  40699. // UnionID returns the value of the "union_id" field in the mutation.
  40700. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  40701. v := m.union_id
  40702. if v == nil {
  40703. return
  40704. }
  40705. return *v, true
  40706. }
  40707. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  40708. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40709. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40710. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  40711. if !m.op.Is(OpUpdateOne) {
  40712. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  40713. }
  40714. if m.id == nil || m.oldValue == nil {
  40715. return v, errors.New("OldUnionID requires an ID field in the mutation")
  40716. }
  40717. oldValue, err := m.oldValue(ctx)
  40718. if err != nil {
  40719. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  40720. }
  40721. return oldValue.UnionID, nil
  40722. }
  40723. // ResetUnionID resets all changes to the "union_id" field.
  40724. func (m *WxCardUserMutation) ResetUnionID() {
  40725. m.union_id = nil
  40726. }
  40727. // SetSessionKey sets the "session_key" field.
  40728. func (m *WxCardUserMutation) SetSessionKey(s string) {
  40729. m.session_key = &s
  40730. }
  40731. // SessionKey returns the value of the "session_key" field in the mutation.
  40732. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  40733. v := m.session_key
  40734. if v == nil {
  40735. return
  40736. }
  40737. return *v, true
  40738. }
  40739. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  40740. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40742. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  40743. if !m.op.Is(OpUpdateOne) {
  40744. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  40745. }
  40746. if m.id == nil || m.oldValue == nil {
  40747. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  40748. }
  40749. oldValue, err := m.oldValue(ctx)
  40750. if err != nil {
  40751. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  40752. }
  40753. return oldValue.SessionKey, nil
  40754. }
  40755. // ResetSessionKey resets all changes to the "session_key" field.
  40756. func (m *WxCardUserMutation) ResetSessionKey() {
  40757. m.session_key = nil
  40758. }
  40759. // SetIsVip sets the "is_vip" field.
  40760. func (m *WxCardUserMutation) SetIsVip(i int) {
  40761. m.is_vip = &i
  40762. m.addis_vip = nil
  40763. }
  40764. // IsVip returns the value of the "is_vip" field in the mutation.
  40765. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  40766. v := m.is_vip
  40767. if v == nil {
  40768. return
  40769. }
  40770. return *v, true
  40771. }
  40772. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  40773. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40774. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40775. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  40776. if !m.op.Is(OpUpdateOne) {
  40777. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  40778. }
  40779. if m.id == nil || m.oldValue == nil {
  40780. return v, errors.New("OldIsVip requires an ID field in the mutation")
  40781. }
  40782. oldValue, err := m.oldValue(ctx)
  40783. if err != nil {
  40784. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  40785. }
  40786. return oldValue.IsVip, nil
  40787. }
  40788. // AddIsVip adds i to the "is_vip" field.
  40789. func (m *WxCardUserMutation) AddIsVip(i int) {
  40790. if m.addis_vip != nil {
  40791. *m.addis_vip += i
  40792. } else {
  40793. m.addis_vip = &i
  40794. }
  40795. }
  40796. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  40797. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  40798. v := m.addis_vip
  40799. if v == nil {
  40800. return
  40801. }
  40802. return *v, true
  40803. }
  40804. // ResetIsVip resets all changes to the "is_vip" field.
  40805. func (m *WxCardUserMutation) ResetIsVip() {
  40806. m.is_vip = nil
  40807. m.addis_vip = nil
  40808. }
  40809. // Where appends a list predicates to the WxCardUserMutation builder.
  40810. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  40811. m.predicates = append(m.predicates, ps...)
  40812. }
  40813. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  40814. // users can use type-assertion to append predicates that do not depend on any generated package.
  40815. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  40816. p := make([]predicate.WxCardUser, len(ps))
  40817. for i := range ps {
  40818. p[i] = ps[i]
  40819. }
  40820. m.Where(p...)
  40821. }
  40822. // Op returns the operation name.
  40823. func (m *WxCardUserMutation) Op() Op {
  40824. return m.op
  40825. }
  40826. // SetOp allows setting the mutation operation.
  40827. func (m *WxCardUserMutation) SetOp(op Op) {
  40828. m.op = op
  40829. }
  40830. // Type returns the node type of this mutation (WxCardUser).
  40831. func (m *WxCardUserMutation) Type() string {
  40832. return m.typ
  40833. }
  40834. // Fields returns all fields that were changed during this mutation. Note that in
  40835. // order to get all numeric fields that were incremented/decremented, call
  40836. // AddedFields().
  40837. func (m *WxCardUserMutation) Fields() []string {
  40838. fields := make([]string, 0, 13)
  40839. if m.created_at != nil {
  40840. fields = append(fields, wxcarduser.FieldCreatedAt)
  40841. }
  40842. if m.updated_at != nil {
  40843. fields = append(fields, wxcarduser.FieldUpdatedAt)
  40844. }
  40845. if m.deleted_at != nil {
  40846. fields = append(fields, wxcarduser.FieldDeletedAt)
  40847. }
  40848. if m.wxid != nil {
  40849. fields = append(fields, wxcarduser.FieldWxid)
  40850. }
  40851. if m.account != nil {
  40852. fields = append(fields, wxcarduser.FieldAccount)
  40853. }
  40854. if m.avatar != nil {
  40855. fields = append(fields, wxcarduser.FieldAvatar)
  40856. }
  40857. if m.nickname != nil {
  40858. fields = append(fields, wxcarduser.FieldNickname)
  40859. }
  40860. if m.remark != nil {
  40861. fields = append(fields, wxcarduser.FieldRemark)
  40862. }
  40863. if m.phone != nil {
  40864. fields = append(fields, wxcarduser.FieldPhone)
  40865. }
  40866. if m.open_id != nil {
  40867. fields = append(fields, wxcarduser.FieldOpenID)
  40868. }
  40869. if m.union_id != nil {
  40870. fields = append(fields, wxcarduser.FieldUnionID)
  40871. }
  40872. if m.session_key != nil {
  40873. fields = append(fields, wxcarduser.FieldSessionKey)
  40874. }
  40875. if m.is_vip != nil {
  40876. fields = append(fields, wxcarduser.FieldIsVip)
  40877. }
  40878. return fields
  40879. }
  40880. // Field returns the value of a field with the given name. The second boolean
  40881. // return value indicates that this field was not set, or was not defined in the
  40882. // schema.
  40883. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  40884. switch name {
  40885. case wxcarduser.FieldCreatedAt:
  40886. return m.CreatedAt()
  40887. case wxcarduser.FieldUpdatedAt:
  40888. return m.UpdatedAt()
  40889. case wxcarduser.FieldDeletedAt:
  40890. return m.DeletedAt()
  40891. case wxcarduser.FieldWxid:
  40892. return m.Wxid()
  40893. case wxcarduser.FieldAccount:
  40894. return m.Account()
  40895. case wxcarduser.FieldAvatar:
  40896. return m.Avatar()
  40897. case wxcarduser.FieldNickname:
  40898. return m.Nickname()
  40899. case wxcarduser.FieldRemark:
  40900. return m.Remark()
  40901. case wxcarduser.FieldPhone:
  40902. return m.Phone()
  40903. case wxcarduser.FieldOpenID:
  40904. return m.OpenID()
  40905. case wxcarduser.FieldUnionID:
  40906. return m.UnionID()
  40907. case wxcarduser.FieldSessionKey:
  40908. return m.SessionKey()
  40909. case wxcarduser.FieldIsVip:
  40910. return m.IsVip()
  40911. }
  40912. return nil, false
  40913. }
  40914. // OldField returns the old value of the field from the database. An error is
  40915. // returned if the mutation operation is not UpdateOne, or the query to the
  40916. // database failed.
  40917. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40918. switch name {
  40919. case wxcarduser.FieldCreatedAt:
  40920. return m.OldCreatedAt(ctx)
  40921. case wxcarduser.FieldUpdatedAt:
  40922. return m.OldUpdatedAt(ctx)
  40923. case wxcarduser.FieldDeletedAt:
  40924. return m.OldDeletedAt(ctx)
  40925. case wxcarduser.FieldWxid:
  40926. return m.OldWxid(ctx)
  40927. case wxcarduser.FieldAccount:
  40928. return m.OldAccount(ctx)
  40929. case wxcarduser.FieldAvatar:
  40930. return m.OldAvatar(ctx)
  40931. case wxcarduser.FieldNickname:
  40932. return m.OldNickname(ctx)
  40933. case wxcarduser.FieldRemark:
  40934. return m.OldRemark(ctx)
  40935. case wxcarduser.FieldPhone:
  40936. return m.OldPhone(ctx)
  40937. case wxcarduser.FieldOpenID:
  40938. return m.OldOpenID(ctx)
  40939. case wxcarduser.FieldUnionID:
  40940. return m.OldUnionID(ctx)
  40941. case wxcarduser.FieldSessionKey:
  40942. return m.OldSessionKey(ctx)
  40943. case wxcarduser.FieldIsVip:
  40944. return m.OldIsVip(ctx)
  40945. }
  40946. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  40947. }
  40948. // SetField sets the value of a field with the given name. It returns an error if
  40949. // the field is not defined in the schema, or if the type mismatched the field
  40950. // type.
  40951. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  40952. switch name {
  40953. case wxcarduser.FieldCreatedAt:
  40954. v, ok := value.(time.Time)
  40955. if !ok {
  40956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40957. }
  40958. m.SetCreatedAt(v)
  40959. return nil
  40960. case wxcarduser.FieldUpdatedAt:
  40961. v, ok := value.(time.Time)
  40962. if !ok {
  40963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40964. }
  40965. m.SetUpdatedAt(v)
  40966. return nil
  40967. case wxcarduser.FieldDeletedAt:
  40968. v, ok := value.(time.Time)
  40969. if !ok {
  40970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40971. }
  40972. m.SetDeletedAt(v)
  40973. return nil
  40974. case wxcarduser.FieldWxid:
  40975. v, ok := value.(string)
  40976. if !ok {
  40977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40978. }
  40979. m.SetWxid(v)
  40980. return nil
  40981. case wxcarduser.FieldAccount:
  40982. v, ok := value.(string)
  40983. if !ok {
  40984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40985. }
  40986. m.SetAccount(v)
  40987. return nil
  40988. case wxcarduser.FieldAvatar:
  40989. v, ok := value.(string)
  40990. if !ok {
  40991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40992. }
  40993. m.SetAvatar(v)
  40994. return nil
  40995. case wxcarduser.FieldNickname:
  40996. v, ok := value.(string)
  40997. if !ok {
  40998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40999. }
  41000. m.SetNickname(v)
  41001. return nil
  41002. case wxcarduser.FieldRemark:
  41003. v, ok := value.(string)
  41004. if !ok {
  41005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41006. }
  41007. m.SetRemark(v)
  41008. return nil
  41009. case wxcarduser.FieldPhone:
  41010. v, ok := value.(string)
  41011. if !ok {
  41012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41013. }
  41014. m.SetPhone(v)
  41015. return nil
  41016. case wxcarduser.FieldOpenID:
  41017. v, ok := value.(string)
  41018. if !ok {
  41019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41020. }
  41021. m.SetOpenID(v)
  41022. return nil
  41023. case wxcarduser.FieldUnionID:
  41024. v, ok := value.(string)
  41025. if !ok {
  41026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41027. }
  41028. m.SetUnionID(v)
  41029. return nil
  41030. case wxcarduser.FieldSessionKey:
  41031. v, ok := value.(string)
  41032. if !ok {
  41033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41034. }
  41035. m.SetSessionKey(v)
  41036. return nil
  41037. case wxcarduser.FieldIsVip:
  41038. v, ok := value.(int)
  41039. if !ok {
  41040. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41041. }
  41042. m.SetIsVip(v)
  41043. return nil
  41044. }
  41045. return fmt.Errorf("unknown WxCardUser field %s", name)
  41046. }
  41047. // AddedFields returns all numeric fields that were incremented/decremented during
  41048. // this mutation.
  41049. func (m *WxCardUserMutation) AddedFields() []string {
  41050. var fields []string
  41051. if m.addis_vip != nil {
  41052. fields = append(fields, wxcarduser.FieldIsVip)
  41053. }
  41054. return fields
  41055. }
  41056. // AddedField returns the numeric value that was incremented/decremented on a field
  41057. // with the given name. The second boolean return value indicates that this field
  41058. // was not set, or was not defined in the schema.
  41059. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  41060. switch name {
  41061. case wxcarduser.FieldIsVip:
  41062. return m.AddedIsVip()
  41063. }
  41064. return nil, false
  41065. }
  41066. // AddField adds the value to the field with the given name. It returns an error if
  41067. // the field is not defined in the schema, or if the type mismatched the field
  41068. // type.
  41069. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  41070. switch name {
  41071. case wxcarduser.FieldIsVip:
  41072. v, ok := value.(int)
  41073. if !ok {
  41074. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41075. }
  41076. m.AddIsVip(v)
  41077. return nil
  41078. }
  41079. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  41080. }
  41081. // ClearedFields returns all nullable fields that were cleared during this
  41082. // mutation.
  41083. func (m *WxCardUserMutation) ClearedFields() []string {
  41084. var fields []string
  41085. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  41086. fields = append(fields, wxcarduser.FieldDeletedAt)
  41087. }
  41088. return fields
  41089. }
  41090. // FieldCleared returns a boolean indicating if a field with the given name was
  41091. // cleared in this mutation.
  41092. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  41093. _, ok := m.clearedFields[name]
  41094. return ok
  41095. }
  41096. // ClearField clears the value of the field with the given name. It returns an
  41097. // error if the field is not defined in the schema.
  41098. func (m *WxCardUserMutation) ClearField(name string) error {
  41099. switch name {
  41100. case wxcarduser.FieldDeletedAt:
  41101. m.ClearDeletedAt()
  41102. return nil
  41103. }
  41104. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  41105. }
  41106. // ResetField resets all changes in the mutation for the field with the given name.
  41107. // It returns an error if the field is not defined in the schema.
  41108. func (m *WxCardUserMutation) ResetField(name string) error {
  41109. switch name {
  41110. case wxcarduser.FieldCreatedAt:
  41111. m.ResetCreatedAt()
  41112. return nil
  41113. case wxcarduser.FieldUpdatedAt:
  41114. m.ResetUpdatedAt()
  41115. return nil
  41116. case wxcarduser.FieldDeletedAt:
  41117. m.ResetDeletedAt()
  41118. return nil
  41119. case wxcarduser.FieldWxid:
  41120. m.ResetWxid()
  41121. return nil
  41122. case wxcarduser.FieldAccount:
  41123. m.ResetAccount()
  41124. return nil
  41125. case wxcarduser.FieldAvatar:
  41126. m.ResetAvatar()
  41127. return nil
  41128. case wxcarduser.FieldNickname:
  41129. m.ResetNickname()
  41130. return nil
  41131. case wxcarduser.FieldRemark:
  41132. m.ResetRemark()
  41133. return nil
  41134. case wxcarduser.FieldPhone:
  41135. m.ResetPhone()
  41136. return nil
  41137. case wxcarduser.FieldOpenID:
  41138. m.ResetOpenID()
  41139. return nil
  41140. case wxcarduser.FieldUnionID:
  41141. m.ResetUnionID()
  41142. return nil
  41143. case wxcarduser.FieldSessionKey:
  41144. m.ResetSessionKey()
  41145. return nil
  41146. case wxcarduser.FieldIsVip:
  41147. m.ResetIsVip()
  41148. return nil
  41149. }
  41150. return fmt.Errorf("unknown WxCardUser field %s", name)
  41151. }
  41152. // AddedEdges returns all edge names that were set/added in this mutation.
  41153. func (m *WxCardUserMutation) AddedEdges() []string {
  41154. edges := make([]string, 0, 0)
  41155. return edges
  41156. }
  41157. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41158. // name in this mutation.
  41159. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  41160. return nil
  41161. }
  41162. // RemovedEdges returns all edge names that were removed in this mutation.
  41163. func (m *WxCardUserMutation) RemovedEdges() []string {
  41164. edges := make([]string, 0, 0)
  41165. return edges
  41166. }
  41167. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41168. // the given name in this mutation.
  41169. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  41170. return nil
  41171. }
  41172. // ClearedEdges returns all edge names that were cleared in this mutation.
  41173. func (m *WxCardUserMutation) ClearedEdges() []string {
  41174. edges := make([]string, 0, 0)
  41175. return edges
  41176. }
  41177. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41178. // was cleared in this mutation.
  41179. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  41180. return false
  41181. }
  41182. // ClearEdge clears the value of the edge with the given name. It returns an error
  41183. // if that edge is not defined in the schema.
  41184. func (m *WxCardUserMutation) ClearEdge(name string) error {
  41185. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  41186. }
  41187. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41188. // It returns an error if the edge is not defined in the schema.
  41189. func (m *WxCardUserMutation) ResetEdge(name string) error {
  41190. return fmt.Errorf("unknown WxCardUser edge %s", name)
  41191. }
  41192. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  41193. type WxCardVisitMutation struct {
  41194. config
  41195. op Op
  41196. typ string
  41197. id *uint64
  41198. created_at *time.Time
  41199. updated_at *time.Time
  41200. deleted_at *time.Time
  41201. user_id *uint64
  41202. adduser_id *int64
  41203. bot_id *uint64
  41204. addbot_id *int64
  41205. bot_type *uint8
  41206. addbot_type *int8
  41207. clearedFields map[string]struct{}
  41208. done bool
  41209. oldValue func(context.Context) (*WxCardVisit, error)
  41210. predicates []predicate.WxCardVisit
  41211. }
  41212. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  41213. // wxcardvisitOption allows management of the mutation configuration using functional options.
  41214. type wxcardvisitOption func(*WxCardVisitMutation)
  41215. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  41216. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  41217. m := &WxCardVisitMutation{
  41218. config: c,
  41219. op: op,
  41220. typ: TypeWxCardVisit,
  41221. clearedFields: make(map[string]struct{}),
  41222. }
  41223. for _, opt := range opts {
  41224. opt(m)
  41225. }
  41226. return m
  41227. }
  41228. // withWxCardVisitID sets the ID field of the mutation.
  41229. func withWxCardVisitID(id uint64) wxcardvisitOption {
  41230. return func(m *WxCardVisitMutation) {
  41231. var (
  41232. err error
  41233. once sync.Once
  41234. value *WxCardVisit
  41235. )
  41236. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  41237. once.Do(func() {
  41238. if m.done {
  41239. err = errors.New("querying old values post mutation is not allowed")
  41240. } else {
  41241. value, err = m.Client().WxCardVisit.Get(ctx, id)
  41242. }
  41243. })
  41244. return value, err
  41245. }
  41246. m.id = &id
  41247. }
  41248. }
  41249. // withWxCardVisit sets the old WxCardVisit of the mutation.
  41250. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  41251. return func(m *WxCardVisitMutation) {
  41252. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  41253. return node, nil
  41254. }
  41255. m.id = &node.ID
  41256. }
  41257. }
  41258. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41259. // executed in a transaction (ent.Tx), a transactional client is returned.
  41260. func (m WxCardVisitMutation) Client() *Client {
  41261. client := &Client{config: m.config}
  41262. client.init()
  41263. return client
  41264. }
  41265. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41266. // it returns an error otherwise.
  41267. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  41268. if _, ok := m.driver.(*txDriver); !ok {
  41269. return nil, errors.New("ent: mutation is not running in a transaction")
  41270. }
  41271. tx := &Tx{config: m.config}
  41272. tx.init()
  41273. return tx, nil
  41274. }
  41275. // SetID sets the value of the id field. Note that this
  41276. // operation is only accepted on creation of WxCardVisit entities.
  41277. func (m *WxCardVisitMutation) SetID(id uint64) {
  41278. m.id = &id
  41279. }
  41280. // ID returns the ID value in the mutation. Note that the ID is only available
  41281. // if it was provided to the builder or after it was returned from the database.
  41282. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  41283. if m.id == nil {
  41284. return
  41285. }
  41286. return *m.id, true
  41287. }
  41288. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41289. // That means, if the mutation is applied within a transaction with an isolation level such
  41290. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41291. // or updated by the mutation.
  41292. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  41293. switch {
  41294. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41295. id, exists := m.ID()
  41296. if exists {
  41297. return []uint64{id}, nil
  41298. }
  41299. fallthrough
  41300. case m.op.Is(OpUpdate | OpDelete):
  41301. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  41302. default:
  41303. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41304. }
  41305. }
  41306. // SetCreatedAt sets the "created_at" field.
  41307. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  41308. m.created_at = &t
  41309. }
  41310. // CreatedAt returns the value of the "created_at" field in the mutation.
  41311. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  41312. v := m.created_at
  41313. if v == nil {
  41314. return
  41315. }
  41316. return *v, true
  41317. }
  41318. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  41319. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41320. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41321. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41322. if !m.op.Is(OpUpdateOne) {
  41323. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41324. }
  41325. if m.id == nil || m.oldValue == nil {
  41326. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41327. }
  41328. oldValue, err := m.oldValue(ctx)
  41329. if err != nil {
  41330. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41331. }
  41332. return oldValue.CreatedAt, nil
  41333. }
  41334. // ResetCreatedAt resets all changes to the "created_at" field.
  41335. func (m *WxCardVisitMutation) ResetCreatedAt() {
  41336. m.created_at = nil
  41337. }
  41338. // SetUpdatedAt sets the "updated_at" field.
  41339. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  41340. m.updated_at = &t
  41341. }
  41342. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41343. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  41344. v := m.updated_at
  41345. if v == nil {
  41346. return
  41347. }
  41348. return *v, true
  41349. }
  41350. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  41351. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41352. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41353. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41354. if !m.op.Is(OpUpdateOne) {
  41355. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41356. }
  41357. if m.id == nil || m.oldValue == nil {
  41358. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41359. }
  41360. oldValue, err := m.oldValue(ctx)
  41361. if err != nil {
  41362. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41363. }
  41364. return oldValue.UpdatedAt, nil
  41365. }
  41366. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41367. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  41368. m.updated_at = nil
  41369. }
  41370. // SetDeletedAt sets the "deleted_at" field.
  41371. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  41372. m.deleted_at = &t
  41373. }
  41374. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41375. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  41376. v := m.deleted_at
  41377. if v == nil {
  41378. return
  41379. }
  41380. return *v, true
  41381. }
  41382. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  41383. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41384. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41385. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41386. if !m.op.Is(OpUpdateOne) {
  41387. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41388. }
  41389. if m.id == nil || m.oldValue == nil {
  41390. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41391. }
  41392. oldValue, err := m.oldValue(ctx)
  41393. if err != nil {
  41394. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41395. }
  41396. return oldValue.DeletedAt, nil
  41397. }
  41398. // ClearDeletedAt clears the value of the "deleted_at" field.
  41399. func (m *WxCardVisitMutation) ClearDeletedAt() {
  41400. m.deleted_at = nil
  41401. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  41402. }
  41403. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41404. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  41405. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  41406. return ok
  41407. }
  41408. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41409. func (m *WxCardVisitMutation) ResetDeletedAt() {
  41410. m.deleted_at = nil
  41411. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  41412. }
  41413. // SetUserID sets the "user_id" field.
  41414. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  41415. m.user_id = &u
  41416. m.adduser_id = nil
  41417. }
  41418. // UserID returns the value of the "user_id" field in the mutation.
  41419. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  41420. v := m.user_id
  41421. if v == nil {
  41422. return
  41423. }
  41424. return *v, true
  41425. }
  41426. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  41427. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41429. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41430. if !m.op.Is(OpUpdateOne) {
  41431. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41432. }
  41433. if m.id == nil || m.oldValue == nil {
  41434. return v, errors.New("OldUserID requires an ID field in the mutation")
  41435. }
  41436. oldValue, err := m.oldValue(ctx)
  41437. if err != nil {
  41438. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41439. }
  41440. return oldValue.UserID, nil
  41441. }
  41442. // AddUserID adds u to the "user_id" field.
  41443. func (m *WxCardVisitMutation) AddUserID(u int64) {
  41444. if m.adduser_id != nil {
  41445. *m.adduser_id += u
  41446. } else {
  41447. m.adduser_id = &u
  41448. }
  41449. }
  41450. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41451. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  41452. v := m.adduser_id
  41453. if v == nil {
  41454. return
  41455. }
  41456. return *v, true
  41457. }
  41458. // ClearUserID clears the value of the "user_id" field.
  41459. func (m *WxCardVisitMutation) ClearUserID() {
  41460. m.user_id = nil
  41461. m.adduser_id = nil
  41462. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  41463. }
  41464. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41465. func (m *WxCardVisitMutation) UserIDCleared() bool {
  41466. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  41467. return ok
  41468. }
  41469. // ResetUserID resets all changes to the "user_id" field.
  41470. func (m *WxCardVisitMutation) ResetUserID() {
  41471. m.user_id = nil
  41472. m.adduser_id = nil
  41473. delete(m.clearedFields, wxcardvisit.FieldUserID)
  41474. }
  41475. // SetBotID sets the "bot_id" field.
  41476. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  41477. m.bot_id = &u
  41478. m.addbot_id = nil
  41479. }
  41480. // BotID returns the value of the "bot_id" field in the mutation.
  41481. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  41482. v := m.bot_id
  41483. if v == nil {
  41484. return
  41485. }
  41486. return *v, true
  41487. }
  41488. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  41489. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41491. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  41492. if !m.op.Is(OpUpdateOne) {
  41493. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41494. }
  41495. if m.id == nil || m.oldValue == nil {
  41496. return v, errors.New("OldBotID requires an ID field in the mutation")
  41497. }
  41498. oldValue, err := m.oldValue(ctx)
  41499. if err != nil {
  41500. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41501. }
  41502. return oldValue.BotID, nil
  41503. }
  41504. // AddBotID adds u to the "bot_id" field.
  41505. func (m *WxCardVisitMutation) AddBotID(u int64) {
  41506. if m.addbot_id != nil {
  41507. *m.addbot_id += u
  41508. } else {
  41509. m.addbot_id = &u
  41510. }
  41511. }
  41512. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  41513. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  41514. v := m.addbot_id
  41515. if v == nil {
  41516. return
  41517. }
  41518. return *v, true
  41519. }
  41520. // ResetBotID resets all changes to the "bot_id" field.
  41521. func (m *WxCardVisitMutation) ResetBotID() {
  41522. m.bot_id = nil
  41523. m.addbot_id = nil
  41524. }
  41525. // SetBotType sets the "bot_type" field.
  41526. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  41527. m.bot_type = &u
  41528. m.addbot_type = nil
  41529. }
  41530. // BotType returns the value of the "bot_type" field in the mutation.
  41531. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  41532. v := m.bot_type
  41533. if v == nil {
  41534. return
  41535. }
  41536. return *v, true
  41537. }
  41538. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  41539. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41540. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41541. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  41542. if !m.op.Is(OpUpdateOne) {
  41543. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  41544. }
  41545. if m.id == nil || m.oldValue == nil {
  41546. return v, errors.New("OldBotType requires an ID field in the mutation")
  41547. }
  41548. oldValue, err := m.oldValue(ctx)
  41549. if err != nil {
  41550. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  41551. }
  41552. return oldValue.BotType, nil
  41553. }
  41554. // AddBotType adds u to the "bot_type" field.
  41555. func (m *WxCardVisitMutation) AddBotType(u int8) {
  41556. if m.addbot_type != nil {
  41557. *m.addbot_type += u
  41558. } else {
  41559. m.addbot_type = &u
  41560. }
  41561. }
  41562. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  41563. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  41564. v := m.addbot_type
  41565. if v == nil {
  41566. return
  41567. }
  41568. return *v, true
  41569. }
  41570. // ResetBotType resets all changes to the "bot_type" field.
  41571. func (m *WxCardVisitMutation) ResetBotType() {
  41572. m.bot_type = nil
  41573. m.addbot_type = nil
  41574. }
  41575. // Where appends a list predicates to the WxCardVisitMutation builder.
  41576. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  41577. m.predicates = append(m.predicates, ps...)
  41578. }
  41579. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  41580. // users can use type-assertion to append predicates that do not depend on any generated package.
  41581. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  41582. p := make([]predicate.WxCardVisit, len(ps))
  41583. for i := range ps {
  41584. p[i] = ps[i]
  41585. }
  41586. m.Where(p...)
  41587. }
  41588. // Op returns the operation name.
  41589. func (m *WxCardVisitMutation) Op() Op {
  41590. return m.op
  41591. }
  41592. // SetOp allows setting the mutation operation.
  41593. func (m *WxCardVisitMutation) SetOp(op Op) {
  41594. m.op = op
  41595. }
  41596. // Type returns the node type of this mutation (WxCardVisit).
  41597. func (m *WxCardVisitMutation) Type() string {
  41598. return m.typ
  41599. }
  41600. // Fields returns all fields that were changed during this mutation. Note that in
  41601. // order to get all numeric fields that were incremented/decremented, call
  41602. // AddedFields().
  41603. func (m *WxCardVisitMutation) Fields() []string {
  41604. fields := make([]string, 0, 6)
  41605. if m.created_at != nil {
  41606. fields = append(fields, wxcardvisit.FieldCreatedAt)
  41607. }
  41608. if m.updated_at != nil {
  41609. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  41610. }
  41611. if m.deleted_at != nil {
  41612. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41613. }
  41614. if m.user_id != nil {
  41615. fields = append(fields, wxcardvisit.FieldUserID)
  41616. }
  41617. if m.bot_id != nil {
  41618. fields = append(fields, wxcardvisit.FieldBotID)
  41619. }
  41620. if m.bot_type != nil {
  41621. fields = append(fields, wxcardvisit.FieldBotType)
  41622. }
  41623. return fields
  41624. }
  41625. // Field returns the value of a field with the given name. The second boolean
  41626. // return value indicates that this field was not set, or was not defined in the
  41627. // schema.
  41628. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  41629. switch name {
  41630. case wxcardvisit.FieldCreatedAt:
  41631. return m.CreatedAt()
  41632. case wxcardvisit.FieldUpdatedAt:
  41633. return m.UpdatedAt()
  41634. case wxcardvisit.FieldDeletedAt:
  41635. return m.DeletedAt()
  41636. case wxcardvisit.FieldUserID:
  41637. return m.UserID()
  41638. case wxcardvisit.FieldBotID:
  41639. return m.BotID()
  41640. case wxcardvisit.FieldBotType:
  41641. return m.BotType()
  41642. }
  41643. return nil, false
  41644. }
  41645. // OldField returns the old value of the field from the database. An error is
  41646. // returned if the mutation operation is not UpdateOne, or the query to the
  41647. // database failed.
  41648. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41649. switch name {
  41650. case wxcardvisit.FieldCreatedAt:
  41651. return m.OldCreatedAt(ctx)
  41652. case wxcardvisit.FieldUpdatedAt:
  41653. return m.OldUpdatedAt(ctx)
  41654. case wxcardvisit.FieldDeletedAt:
  41655. return m.OldDeletedAt(ctx)
  41656. case wxcardvisit.FieldUserID:
  41657. return m.OldUserID(ctx)
  41658. case wxcardvisit.FieldBotID:
  41659. return m.OldBotID(ctx)
  41660. case wxcardvisit.FieldBotType:
  41661. return m.OldBotType(ctx)
  41662. }
  41663. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  41664. }
  41665. // SetField sets the value of a field with the given name. It returns an error if
  41666. // the field is not defined in the schema, or if the type mismatched the field
  41667. // type.
  41668. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  41669. switch name {
  41670. case wxcardvisit.FieldCreatedAt:
  41671. v, ok := value.(time.Time)
  41672. if !ok {
  41673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41674. }
  41675. m.SetCreatedAt(v)
  41676. return nil
  41677. case wxcardvisit.FieldUpdatedAt:
  41678. v, ok := value.(time.Time)
  41679. if !ok {
  41680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41681. }
  41682. m.SetUpdatedAt(v)
  41683. return nil
  41684. case wxcardvisit.FieldDeletedAt:
  41685. v, ok := value.(time.Time)
  41686. if !ok {
  41687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41688. }
  41689. m.SetDeletedAt(v)
  41690. return nil
  41691. case wxcardvisit.FieldUserID:
  41692. v, ok := value.(uint64)
  41693. if !ok {
  41694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41695. }
  41696. m.SetUserID(v)
  41697. return nil
  41698. case wxcardvisit.FieldBotID:
  41699. v, ok := value.(uint64)
  41700. if !ok {
  41701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41702. }
  41703. m.SetBotID(v)
  41704. return nil
  41705. case wxcardvisit.FieldBotType:
  41706. v, ok := value.(uint8)
  41707. if !ok {
  41708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41709. }
  41710. m.SetBotType(v)
  41711. return nil
  41712. }
  41713. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41714. }
  41715. // AddedFields returns all numeric fields that were incremented/decremented during
  41716. // this mutation.
  41717. func (m *WxCardVisitMutation) AddedFields() []string {
  41718. var fields []string
  41719. if m.adduser_id != nil {
  41720. fields = append(fields, wxcardvisit.FieldUserID)
  41721. }
  41722. if m.addbot_id != nil {
  41723. fields = append(fields, wxcardvisit.FieldBotID)
  41724. }
  41725. if m.addbot_type != nil {
  41726. fields = append(fields, wxcardvisit.FieldBotType)
  41727. }
  41728. return fields
  41729. }
  41730. // AddedField returns the numeric value that was incremented/decremented on a field
  41731. // with the given name. The second boolean return value indicates that this field
  41732. // was not set, or was not defined in the schema.
  41733. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  41734. switch name {
  41735. case wxcardvisit.FieldUserID:
  41736. return m.AddedUserID()
  41737. case wxcardvisit.FieldBotID:
  41738. return m.AddedBotID()
  41739. case wxcardvisit.FieldBotType:
  41740. return m.AddedBotType()
  41741. }
  41742. return nil, false
  41743. }
  41744. // AddField adds the value to the field with the given name. It returns an error if
  41745. // the field is not defined in the schema, or if the type mismatched the field
  41746. // type.
  41747. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  41748. switch name {
  41749. case wxcardvisit.FieldUserID:
  41750. v, ok := value.(int64)
  41751. if !ok {
  41752. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41753. }
  41754. m.AddUserID(v)
  41755. return nil
  41756. case wxcardvisit.FieldBotID:
  41757. v, ok := value.(int64)
  41758. if !ok {
  41759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41760. }
  41761. m.AddBotID(v)
  41762. return nil
  41763. case wxcardvisit.FieldBotType:
  41764. v, ok := value.(int8)
  41765. if !ok {
  41766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41767. }
  41768. m.AddBotType(v)
  41769. return nil
  41770. }
  41771. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  41772. }
  41773. // ClearedFields returns all nullable fields that were cleared during this
  41774. // mutation.
  41775. func (m *WxCardVisitMutation) ClearedFields() []string {
  41776. var fields []string
  41777. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  41778. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41779. }
  41780. if m.FieldCleared(wxcardvisit.FieldUserID) {
  41781. fields = append(fields, wxcardvisit.FieldUserID)
  41782. }
  41783. return fields
  41784. }
  41785. // FieldCleared returns a boolean indicating if a field with the given name was
  41786. // cleared in this mutation.
  41787. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  41788. _, ok := m.clearedFields[name]
  41789. return ok
  41790. }
  41791. // ClearField clears the value of the field with the given name. It returns an
  41792. // error if the field is not defined in the schema.
  41793. func (m *WxCardVisitMutation) ClearField(name string) error {
  41794. switch name {
  41795. case wxcardvisit.FieldDeletedAt:
  41796. m.ClearDeletedAt()
  41797. return nil
  41798. case wxcardvisit.FieldUserID:
  41799. m.ClearUserID()
  41800. return nil
  41801. }
  41802. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  41803. }
  41804. // ResetField resets all changes in the mutation for the field with the given name.
  41805. // It returns an error if the field is not defined in the schema.
  41806. func (m *WxCardVisitMutation) ResetField(name string) error {
  41807. switch name {
  41808. case wxcardvisit.FieldCreatedAt:
  41809. m.ResetCreatedAt()
  41810. return nil
  41811. case wxcardvisit.FieldUpdatedAt:
  41812. m.ResetUpdatedAt()
  41813. return nil
  41814. case wxcardvisit.FieldDeletedAt:
  41815. m.ResetDeletedAt()
  41816. return nil
  41817. case wxcardvisit.FieldUserID:
  41818. m.ResetUserID()
  41819. return nil
  41820. case wxcardvisit.FieldBotID:
  41821. m.ResetBotID()
  41822. return nil
  41823. case wxcardvisit.FieldBotType:
  41824. m.ResetBotType()
  41825. return nil
  41826. }
  41827. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41828. }
  41829. // AddedEdges returns all edge names that were set/added in this mutation.
  41830. func (m *WxCardVisitMutation) AddedEdges() []string {
  41831. edges := make([]string, 0, 0)
  41832. return edges
  41833. }
  41834. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41835. // name in this mutation.
  41836. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  41837. return nil
  41838. }
  41839. // RemovedEdges returns all edge names that were removed in this mutation.
  41840. func (m *WxCardVisitMutation) RemovedEdges() []string {
  41841. edges := make([]string, 0, 0)
  41842. return edges
  41843. }
  41844. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41845. // the given name in this mutation.
  41846. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  41847. return nil
  41848. }
  41849. // ClearedEdges returns all edge names that were cleared in this mutation.
  41850. func (m *WxCardVisitMutation) ClearedEdges() []string {
  41851. edges := make([]string, 0, 0)
  41852. return edges
  41853. }
  41854. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41855. // was cleared in this mutation.
  41856. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  41857. return false
  41858. }
  41859. // ClearEdge clears the value of the edge with the given name. It returns an error
  41860. // if that edge is not defined in the schema.
  41861. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  41862. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  41863. }
  41864. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41865. // It returns an error if the edge is not defined in the schema.
  41866. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  41867. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  41868. }