mutation.go 1.3 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/workexperience"
  44. "wechat-api/ent/wpchatroom"
  45. "wechat-api/ent/wpchatroommember"
  46. "wechat-api/ent/wx"
  47. "wechat-api/ent/wxcard"
  48. "wechat-api/ent/wxcarduser"
  49. "wechat-api/ent/wxcardvisit"
  50. "entgo.io/ent"
  51. "entgo.io/ent/dialect/sql"
  52. )
  53. const (
  54. // Operation types.
  55. OpCreate = ent.OpCreate
  56. OpDelete = ent.OpDelete
  57. OpDeleteOne = ent.OpDeleteOne
  58. OpUpdate = ent.OpUpdate
  59. OpUpdateOne = ent.OpUpdateOne
  60. // Node types.
  61. TypeAgent = "Agent"
  62. TypeAgentBase = "AgentBase"
  63. TypeAliyunAvatar = "AliyunAvatar"
  64. TypeAllocAgent = "AllocAgent"
  65. TypeBatchMsg = "BatchMsg"
  66. TypeCategory = "Category"
  67. TypeChatRecords = "ChatRecords"
  68. TypeChatSession = "ChatSession"
  69. TypeContact = "Contact"
  70. TypeCreditBalance = "CreditBalance"
  71. TypeCreditUsage = "CreditUsage"
  72. TypeEmployee = "Employee"
  73. TypeEmployeeConfig = "EmployeeConfig"
  74. TypeLabel = "Label"
  75. TypeLabelRelationship = "LabelRelationship"
  76. TypeLabelTagging = "LabelTagging"
  77. TypeMessage = "Message"
  78. TypeMessageRecords = "MessageRecords"
  79. TypeMsg = "Msg"
  80. TypePayRecharge = "PayRecharge"
  81. TypeServer = "Server"
  82. TypeSopNode = "SopNode"
  83. TypeSopStage = "SopStage"
  84. TypeSopTask = "SopTask"
  85. TypeToken = "Token"
  86. TypeTutorial = "Tutorial"
  87. TypeUsageDetail = "UsageDetail"
  88. TypeUsageStatisticDay = "UsageStatisticDay"
  89. TypeUsageStatisticHour = "UsageStatisticHour"
  90. TypeUsageStatisticMonth = "UsageStatisticMonth"
  91. TypeUsageTotal = "UsageTotal"
  92. TypeWhatsapp = "Whatsapp"
  93. TypeWorkExperience = "WorkExperience"
  94. TypeWpChatroom = "WpChatroom"
  95. TypeWpChatroomMember = "WpChatroomMember"
  96. TypeWx = "Wx"
  97. TypeWxCard = "WxCard"
  98. TypeWxCardUser = "WxCardUser"
  99. TypeWxCardVisit = "WxCardVisit"
  100. )
  101. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  102. type AgentMutation struct {
  103. config
  104. op Op
  105. typ string
  106. id *uint64
  107. created_at *time.Time
  108. updated_at *time.Time
  109. deleted_at *time.Time
  110. name *string
  111. role *string
  112. status *int
  113. addstatus *int
  114. background *string
  115. examples *string
  116. organization_id *uint64
  117. addorganization_id *int64
  118. dataset_id *string
  119. collection_id *string
  120. clearedFields map[string]struct{}
  121. wx_agent map[uint64]struct{}
  122. removedwx_agent map[uint64]struct{}
  123. clearedwx_agent bool
  124. token_agent map[uint64]struct{}
  125. removedtoken_agent map[uint64]struct{}
  126. clearedtoken_agent bool
  127. wa_agent map[uint64]struct{}
  128. removedwa_agent map[uint64]struct{}
  129. clearedwa_agent bool
  130. done bool
  131. oldValue func(context.Context) (*Agent, error)
  132. predicates []predicate.Agent
  133. }
  134. var _ ent.Mutation = (*AgentMutation)(nil)
  135. // agentOption allows management of the mutation configuration using functional options.
  136. type agentOption func(*AgentMutation)
  137. // newAgentMutation creates new mutation for the Agent entity.
  138. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  139. m := &AgentMutation{
  140. config: c,
  141. op: op,
  142. typ: TypeAgent,
  143. clearedFields: make(map[string]struct{}),
  144. }
  145. for _, opt := range opts {
  146. opt(m)
  147. }
  148. return m
  149. }
  150. // withAgentID sets the ID field of the mutation.
  151. func withAgentID(id uint64) agentOption {
  152. return func(m *AgentMutation) {
  153. var (
  154. err error
  155. once sync.Once
  156. value *Agent
  157. )
  158. m.oldValue = func(ctx context.Context) (*Agent, error) {
  159. once.Do(func() {
  160. if m.done {
  161. err = errors.New("querying old values post mutation is not allowed")
  162. } else {
  163. value, err = m.Client().Agent.Get(ctx, id)
  164. }
  165. })
  166. return value, err
  167. }
  168. m.id = &id
  169. }
  170. }
  171. // withAgent sets the old Agent of the mutation.
  172. func withAgent(node *Agent) agentOption {
  173. return func(m *AgentMutation) {
  174. m.oldValue = func(context.Context) (*Agent, error) {
  175. return node, nil
  176. }
  177. m.id = &node.ID
  178. }
  179. }
  180. // Client returns a new `ent.Client` from the mutation. If the mutation was
  181. // executed in a transaction (ent.Tx), a transactional client is returned.
  182. func (m AgentMutation) Client() *Client {
  183. client := &Client{config: m.config}
  184. client.init()
  185. return client
  186. }
  187. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  188. // it returns an error otherwise.
  189. func (m AgentMutation) Tx() (*Tx, error) {
  190. if _, ok := m.driver.(*txDriver); !ok {
  191. return nil, errors.New("ent: mutation is not running in a transaction")
  192. }
  193. tx := &Tx{config: m.config}
  194. tx.init()
  195. return tx, nil
  196. }
  197. // SetID sets the value of the id field. Note that this
  198. // operation is only accepted on creation of Agent entities.
  199. func (m *AgentMutation) SetID(id uint64) {
  200. m.id = &id
  201. }
  202. // ID returns the ID value in the mutation. Note that the ID is only available
  203. // if it was provided to the builder or after it was returned from the database.
  204. func (m *AgentMutation) ID() (id uint64, exists bool) {
  205. if m.id == nil {
  206. return
  207. }
  208. return *m.id, true
  209. }
  210. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  211. // That means, if the mutation is applied within a transaction with an isolation level such
  212. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  213. // or updated by the mutation.
  214. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  215. switch {
  216. case m.op.Is(OpUpdateOne | OpDeleteOne):
  217. id, exists := m.ID()
  218. if exists {
  219. return []uint64{id}, nil
  220. }
  221. fallthrough
  222. case m.op.Is(OpUpdate | OpDelete):
  223. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  224. default:
  225. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  226. }
  227. }
  228. // SetCreatedAt sets the "created_at" field.
  229. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  230. m.created_at = &t
  231. }
  232. // CreatedAt returns the value of the "created_at" field in the mutation.
  233. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  234. v := m.created_at
  235. if v == nil {
  236. return
  237. }
  238. return *v, true
  239. }
  240. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  241. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  243. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  244. if !m.op.Is(OpUpdateOne) {
  245. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  246. }
  247. if m.id == nil || m.oldValue == nil {
  248. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  249. }
  250. oldValue, err := m.oldValue(ctx)
  251. if err != nil {
  252. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  253. }
  254. return oldValue.CreatedAt, nil
  255. }
  256. // ResetCreatedAt resets all changes to the "created_at" field.
  257. func (m *AgentMutation) ResetCreatedAt() {
  258. m.created_at = nil
  259. }
  260. // SetUpdatedAt sets the "updated_at" field.
  261. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  262. m.updated_at = &t
  263. }
  264. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  265. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  266. v := m.updated_at
  267. if v == nil {
  268. return
  269. }
  270. return *v, true
  271. }
  272. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  273. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  275. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  276. if !m.op.Is(OpUpdateOne) {
  277. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  278. }
  279. if m.id == nil || m.oldValue == nil {
  280. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  281. }
  282. oldValue, err := m.oldValue(ctx)
  283. if err != nil {
  284. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  285. }
  286. return oldValue.UpdatedAt, nil
  287. }
  288. // ResetUpdatedAt resets all changes to the "updated_at" field.
  289. func (m *AgentMutation) ResetUpdatedAt() {
  290. m.updated_at = nil
  291. }
  292. // SetDeletedAt sets the "deleted_at" field.
  293. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  294. m.deleted_at = &t
  295. }
  296. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  297. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  298. v := m.deleted_at
  299. if v == nil {
  300. return
  301. }
  302. return *v, true
  303. }
  304. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  305. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  307. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  308. if !m.op.Is(OpUpdateOne) {
  309. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  310. }
  311. if m.id == nil || m.oldValue == nil {
  312. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  313. }
  314. oldValue, err := m.oldValue(ctx)
  315. if err != nil {
  316. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  317. }
  318. return oldValue.DeletedAt, nil
  319. }
  320. // ClearDeletedAt clears the value of the "deleted_at" field.
  321. func (m *AgentMutation) ClearDeletedAt() {
  322. m.deleted_at = nil
  323. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  324. }
  325. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  326. func (m *AgentMutation) DeletedAtCleared() bool {
  327. _, ok := m.clearedFields[agent.FieldDeletedAt]
  328. return ok
  329. }
  330. // ResetDeletedAt resets all changes to the "deleted_at" field.
  331. func (m *AgentMutation) ResetDeletedAt() {
  332. m.deleted_at = nil
  333. delete(m.clearedFields, agent.FieldDeletedAt)
  334. }
  335. // SetName sets the "name" field.
  336. func (m *AgentMutation) SetName(s string) {
  337. m.name = &s
  338. }
  339. // Name returns the value of the "name" field in the mutation.
  340. func (m *AgentMutation) Name() (r string, exists bool) {
  341. v := m.name
  342. if v == nil {
  343. return
  344. }
  345. return *v, true
  346. }
  347. // OldName returns the old "name" field's value of the Agent entity.
  348. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  350. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  351. if !m.op.Is(OpUpdateOne) {
  352. return v, errors.New("OldName is only allowed on UpdateOne operations")
  353. }
  354. if m.id == nil || m.oldValue == nil {
  355. return v, errors.New("OldName requires an ID field in the mutation")
  356. }
  357. oldValue, err := m.oldValue(ctx)
  358. if err != nil {
  359. return v, fmt.Errorf("querying old value for OldName: %w", err)
  360. }
  361. return oldValue.Name, nil
  362. }
  363. // ResetName resets all changes to the "name" field.
  364. func (m *AgentMutation) ResetName() {
  365. m.name = nil
  366. }
  367. // SetRole sets the "role" field.
  368. func (m *AgentMutation) SetRole(s string) {
  369. m.role = &s
  370. }
  371. // Role returns the value of the "role" field in the mutation.
  372. func (m *AgentMutation) Role() (r string, exists bool) {
  373. v := m.role
  374. if v == nil {
  375. return
  376. }
  377. return *v, true
  378. }
  379. // OldRole returns the old "role" field's value of the Agent entity.
  380. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  382. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  383. if !m.op.Is(OpUpdateOne) {
  384. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  385. }
  386. if m.id == nil || m.oldValue == nil {
  387. return v, errors.New("OldRole requires an ID field in the mutation")
  388. }
  389. oldValue, err := m.oldValue(ctx)
  390. if err != nil {
  391. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  392. }
  393. return oldValue.Role, nil
  394. }
  395. // ResetRole resets all changes to the "role" field.
  396. func (m *AgentMutation) ResetRole() {
  397. m.role = nil
  398. }
  399. // SetStatus sets the "status" field.
  400. func (m *AgentMutation) SetStatus(i int) {
  401. m.status = &i
  402. m.addstatus = nil
  403. }
  404. // Status returns the value of the "status" field in the mutation.
  405. func (m *AgentMutation) Status() (r int, exists bool) {
  406. v := m.status
  407. if v == nil {
  408. return
  409. }
  410. return *v, true
  411. }
  412. // OldStatus returns the old "status" field's value of the Agent entity.
  413. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  415. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  416. if !m.op.Is(OpUpdateOne) {
  417. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  418. }
  419. if m.id == nil || m.oldValue == nil {
  420. return v, errors.New("OldStatus requires an ID field in the mutation")
  421. }
  422. oldValue, err := m.oldValue(ctx)
  423. if err != nil {
  424. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  425. }
  426. return oldValue.Status, nil
  427. }
  428. // AddStatus adds i to the "status" field.
  429. func (m *AgentMutation) AddStatus(i int) {
  430. if m.addstatus != nil {
  431. *m.addstatus += i
  432. } else {
  433. m.addstatus = &i
  434. }
  435. }
  436. // AddedStatus returns the value that was added to the "status" field in this mutation.
  437. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  438. v := m.addstatus
  439. if v == nil {
  440. return
  441. }
  442. return *v, true
  443. }
  444. // ClearStatus clears the value of the "status" field.
  445. func (m *AgentMutation) ClearStatus() {
  446. m.status = nil
  447. m.addstatus = nil
  448. m.clearedFields[agent.FieldStatus] = struct{}{}
  449. }
  450. // StatusCleared returns if the "status" field was cleared in this mutation.
  451. func (m *AgentMutation) StatusCleared() bool {
  452. _, ok := m.clearedFields[agent.FieldStatus]
  453. return ok
  454. }
  455. // ResetStatus resets all changes to the "status" field.
  456. func (m *AgentMutation) ResetStatus() {
  457. m.status = nil
  458. m.addstatus = nil
  459. delete(m.clearedFields, agent.FieldStatus)
  460. }
  461. // SetBackground sets the "background" field.
  462. func (m *AgentMutation) SetBackground(s string) {
  463. m.background = &s
  464. }
  465. // Background returns the value of the "background" field in the mutation.
  466. func (m *AgentMutation) Background() (r string, exists bool) {
  467. v := m.background
  468. if v == nil {
  469. return
  470. }
  471. return *v, true
  472. }
  473. // OldBackground returns the old "background" field's value of the Agent entity.
  474. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  476. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  477. if !m.op.Is(OpUpdateOne) {
  478. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  479. }
  480. if m.id == nil || m.oldValue == nil {
  481. return v, errors.New("OldBackground requires an ID field in the mutation")
  482. }
  483. oldValue, err := m.oldValue(ctx)
  484. if err != nil {
  485. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  486. }
  487. return oldValue.Background, nil
  488. }
  489. // ClearBackground clears the value of the "background" field.
  490. func (m *AgentMutation) ClearBackground() {
  491. m.background = nil
  492. m.clearedFields[agent.FieldBackground] = struct{}{}
  493. }
  494. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  495. func (m *AgentMutation) BackgroundCleared() bool {
  496. _, ok := m.clearedFields[agent.FieldBackground]
  497. return ok
  498. }
  499. // ResetBackground resets all changes to the "background" field.
  500. func (m *AgentMutation) ResetBackground() {
  501. m.background = nil
  502. delete(m.clearedFields, agent.FieldBackground)
  503. }
  504. // SetExamples sets the "examples" field.
  505. func (m *AgentMutation) SetExamples(s string) {
  506. m.examples = &s
  507. }
  508. // Examples returns the value of the "examples" field in the mutation.
  509. func (m *AgentMutation) Examples() (r string, exists bool) {
  510. v := m.examples
  511. if v == nil {
  512. return
  513. }
  514. return *v, true
  515. }
  516. // OldExamples returns the old "examples" field's value of the Agent entity.
  517. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  519. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  520. if !m.op.Is(OpUpdateOne) {
  521. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  522. }
  523. if m.id == nil || m.oldValue == nil {
  524. return v, errors.New("OldExamples requires an ID field in the mutation")
  525. }
  526. oldValue, err := m.oldValue(ctx)
  527. if err != nil {
  528. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  529. }
  530. return oldValue.Examples, nil
  531. }
  532. // ClearExamples clears the value of the "examples" field.
  533. func (m *AgentMutation) ClearExamples() {
  534. m.examples = nil
  535. m.clearedFields[agent.FieldExamples] = struct{}{}
  536. }
  537. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  538. func (m *AgentMutation) ExamplesCleared() bool {
  539. _, ok := m.clearedFields[agent.FieldExamples]
  540. return ok
  541. }
  542. // ResetExamples resets all changes to the "examples" field.
  543. func (m *AgentMutation) ResetExamples() {
  544. m.examples = nil
  545. delete(m.clearedFields, agent.FieldExamples)
  546. }
  547. // SetOrganizationID sets the "organization_id" field.
  548. func (m *AgentMutation) SetOrganizationID(u uint64) {
  549. m.organization_id = &u
  550. m.addorganization_id = nil
  551. }
  552. // OrganizationID returns the value of the "organization_id" field in the mutation.
  553. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  554. v := m.organization_id
  555. if v == nil {
  556. return
  557. }
  558. return *v, true
  559. }
  560. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  561. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  562. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  563. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  564. if !m.op.Is(OpUpdateOne) {
  565. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  566. }
  567. if m.id == nil || m.oldValue == nil {
  568. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  569. }
  570. oldValue, err := m.oldValue(ctx)
  571. if err != nil {
  572. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  573. }
  574. return oldValue.OrganizationID, nil
  575. }
  576. // AddOrganizationID adds u to the "organization_id" field.
  577. func (m *AgentMutation) AddOrganizationID(u int64) {
  578. if m.addorganization_id != nil {
  579. *m.addorganization_id += u
  580. } else {
  581. m.addorganization_id = &u
  582. }
  583. }
  584. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  585. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  586. v := m.addorganization_id
  587. if v == nil {
  588. return
  589. }
  590. return *v, true
  591. }
  592. // ResetOrganizationID resets all changes to the "organization_id" field.
  593. func (m *AgentMutation) ResetOrganizationID() {
  594. m.organization_id = nil
  595. m.addorganization_id = nil
  596. }
  597. // SetDatasetID sets the "dataset_id" field.
  598. func (m *AgentMutation) SetDatasetID(s string) {
  599. m.dataset_id = &s
  600. }
  601. // DatasetID returns the value of the "dataset_id" field in the mutation.
  602. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  603. v := m.dataset_id
  604. if v == nil {
  605. return
  606. }
  607. return *v, true
  608. }
  609. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  610. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  612. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  613. if !m.op.Is(OpUpdateOne) {
  614. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  615. }
  616. if m.id == nil || m.oldValue == nil {
  617. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  618. }
  619. oldValue, err := m.oldValue(ctx)
  620. if err != nil {
  621. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  622. }
  623. return oldValue.DatasetID, nil
  624. }
  625. // ResetDatasetID resets all changes to the "dataset_id" field.
  626. func (m *AgentMutation) ResetDatasetID() {
  627. m.dataset_id = nil
  628. }
  629. // SetCollectionID sets the "collection_id" field.
  630. func (m *AgentMutation) SetCollectionID(s string) {
  631. m.collection_id = &s
  632. }
  633. // CollectionID returns the value of the "collection_id" field in the mutation.
  634. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  635. v := m.collection_id
  636. if v == nil {
  637. return
  638. }
  639. return *v, true
  640. }
  641. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  642. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  644. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  645. if !m.op.Is(OpUpdateOne) {
  646. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  647. }
  648. if m.id == nil || m.oldValue == nil {
  649. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  650. }
  651. oldValue, err := m.oldValue(ctx)
  652. if err != nil {
  653. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  654. }
  655. return oldValue.CollectionID, nil
  656. }
  657. // ResetCollectionID resets all changes to the "collection_id" field.
  658. func (m *AgentMutation) ResetCollectionID() {
  659. m.collection_id = nil
  660. }
  661. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  662. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  663. if m.wx_agent == nil {
  664. m.wx_agent = make(map[uint64]struct{})
  665. }
  666. for i := range ids {
  667. m.wx_agent[ids[i]] = struct{}{}
  668. }
  669. }
  670. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  671. func (m *AgentMutation) ClearWxAgent() {
  672. m.clearedwx_agent = true
  673. }
  674. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  675. func (m *AgentMutation) WxAgentCleared() bool {
  676. return m.clearedwx_agent
  677. }
  678. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  679. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  680. if m.removedwx_agent == nil {
  681. m.removedwx_agent = make(map[uint64]struct{})
  682. }
  683. for i := range ids {
  684. delete(m.wx_agent, ids[i])
  685. m.removedwx_agent[ids[i]] = struct{}{}
  686. }
  687. }
  688. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  689. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  690. for id := range m.removedwx_agent {
  691. ids = append(ids, id)
  692. }
  693. return
  694. }
  695. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  696. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  697. for id := range m.wx_agent {
  698. ids = append(ids, id)
  699. }
  700. return
  701. }
  702. // ResetWxAgent resets all changes to the "wx_agent" edge.
  703. func (m *AgentMutation) ResetWxAgent() {
  704. m.wx_agent = nil
  705. m.clearedwx_agent = false
  706. m.removedwx_agent = nil
  707. }
  708. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  709. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  710. if m.token_agent == nil {
  711. m.token_agent = make(map[uint64]struct{})
  712. }
  713. for i := range ids {
  714. m.token_agent[ids[i]] = struct{}{}
  715. }
  716. }
  717. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  718. func (m *AgentMutation) ClearTokenAgent() {
  719. m.clearedtoken_agent = true
  720. }
  721. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  722. func (m *AgentMutation) TokenAgentCleared() bool {
  723. return m.clearedtoken_agent
  724. }
  725. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  726. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  727. if m.removedtoken_agent == nil {
  728. m.removedtoken_agent = make(map[uint64]struct{})
  729. }
  730. for i := range ids {
  731. delete(m.token_agent, ids[i])
  732. m.removedtoken_agent[ids[i]] = struct{}{}
  733. }
  734. }
  735. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  736. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  737. for id := range m.removedtoken_agent {
  738. ids = append(ids, id)
  739. }
  740. return
  741. }
  742. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  743. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  744. for id := range m.token_agent {
  745. ids = append(ids, id)
  746. }
  747. return
  748. }
  749. // ResetTokenAgent resets all changes to the "token_agent" edge.
  750. func (m *AgentMutation) ResetTokenAgent() {
  751. m.token_agent = nil
  752. m.clearedtoken_agent = false
  753. m.removedtoken_agent = nil
  754. }
  755. // AddWaAgentIDs adds the "wa_agent" edge to the Whatsapp entity by ids.
  756. func (m *AgentMutation) AddWaAgentIDs(ids ...uint64) {
  757. if m.wa_agent == nil {
  758. m.wa_agent = make(map[uint64]struct{})
  759. }
  760. for i := range ids {
  761. m.wa_agent[ids[i]] = struct{}{}
  762. }
  763. }
  764. // ClearWaAgent clears the "wa_agent" edge to the Whatsapp entity.
  765. func (m *AgentMutation) ClearWaAgent() {
  766. m.clearedwa_agent = true
  767. }
  768. // WaAgentCleared reports if the "wa_agent" edge to the Whatsapp entity was cleared.
  769. func (m *AgentMutation) WaAgentCleared() bool {
  770. return m.clearedwa_agent
  771. }
  772. // RemoveWaAgentIDs removes the "wa_agent" edge to the Whatsapp entity by IDs.
  773. func (m *AgentMutation) RemoveWaAgentIDs(ids ...uint64) {
  774. if m.removedwa_agent == nil {
  775. m.removedwa_agent = make(map[uint64]struct{})
  776. }
  777. for i := range ids {
  778. delete(m.wa_agent, ids[i])
  779. m.removedwa_agent[ids[i]] = struct{}{}
  780. }
  781. }
  782. // RemovedWaAgent returns the removed IDs of the "wa_agent" edge to the Whatsapp entity.
  783. func (m *AgentMutation) RemovedWaAgentIDs() (ids []uint64) {
  784. for id := range m.removedwa_agent {
  785. ids = append(ids, id)
  786. }
  787. return
  788. }
  789. // WaAgentIDs returns the "wa_agent" edge IDs in the mutation.
  790. func (m *AgentMutation) WaAgentIDs() (ids []uint64) {
  791. for id := range m.wa_agent {
  792. ids = append(ids, id)
  793. }
  794. return
  795. }
  796. // ResetWaAgent resets all changes to the "wa_agent" edge.
  797. func (m *AgentMutation) ResetWaAgent() {
  798. m.wa_agent = nil
  799. m.clearedwa_agent = false
  800. m.removedwa_agent = nil
  801. }
  802. // Where appends a list predicates to the AgentMutation builder.
  803. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  804. m.predicates = append(m.predicates, ps...)
  805. }
  806. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  807. // users can use type-assertion to append predicates that do not depend on any generated package.
  808. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  809. p := make([]predicate.Agent, len(ps))
  810. for i := range ps {
  811. p[i] = ps[i]
  812. }
  813. m.Where(p...)
  814. }
  815. // Op returns the operation name.
  816. func (m *AgentMutation) Op() Op {
  817. return m.op
  818. }
  819. // SetOp allows setting the mutation operation.
  820. func (m *AgentMutation) SetOp(op Op) {
  821. m.op = op
  822. }
  823. // Type returns the node type of this mutation (Agent).
  824. func (m *AgentMutation) Type() string {
  825. return m.typ
  826. }
  827. // Fields returns all fields that were changed during this mutation. Note that in
  828. // order to get all numeric fields that were incremented/decremented, call
  829. // AddedFields().
  830. func (m *AgentMutation) Fields() []string {
  831. fields := make([]string, 0, 11)
  832. if m.created_at != nil {
  833. fields = append(fields, agent.FieldCreatedAt)
  834. }
  835. if m.updated_at != nil {
  836. fields = append(fields, agent.FieldUpdatedAt)
  837. }
  838. if m.deleted_at != nil {
  839. fields = append(fields, agent.FieldDeletedAt)
  840. }
  841. if m.name != nil {
  842. fields = append(fields, agent.FieldName)
  843. }
  844. if m.role != nil {
  845. fields = append(fields, agent.FieldRole)
  846. }
  847. if m.status != nil {
  848. fields = append(fields, agent.FieldStatus)
  849. }
  850. if m.background != nil {
  851. fields = append(fields, agent.FieldBackground)
  852. }
  853. if m.examples != nil {
  854. fields = append(fields, agent.FieldExamples)
  855. }
  856. if m.organization_id != nil {
  857. fields = append(fields, agent.FieldOrganizationID)
  858. }
  859. if m.dataset_id != nil {
  860. fields = append(fields, agent.FieldDatasetID)
  861. }
  862. if m.collection_id != nil {
  863. fields = append(fields, agent.FieldCollectionID)
  864. }
  865. return fields
  866. }
  867. // Field returns the value of a field with the given name. The second boolean
  868. // return value indicates that this field was not set, or was not defined in the
  869. // schema.
  870. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  871. switch name {
  872. case agent.FieldCreatedAt:
  873. return m.CreatedAt()
  874. case agent.FieldUpdatedAt:
  875. return m.UpdatedAt()
  876. case agent.FieldDeletedAt:
  877. return m.DeletedAt()
  878. case agent.FieldName:
  879. return m.Name()
  880. case agent.FieldRole:
  881. return m.Role()
  882. case agent.FieldStatus:
  883. return m.Status()
  884. case agent.FieldBackground:
  885. return m.Background()
  886. case agent.FieldExamples:
  887. return m.Examples()
  888. case agent.FieldOrganizationID:
  889. return m.OrganizationID()
  890. case agent.FieldDatasetID:
  891. return m.DatasetID()
  892. case agent.FieldCollectionID:
  893. return m.CollectionID()
  894. }
  895. return nil, false
  896. }
  897. // OldField returns the old value of the field from the database. An error is
  898. // returned if the mutation operation is not UpdateOne, or the query to the
  899. // database failed.
  900. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  901. switch name {
  902. case agent.FieldCreatedAt:
  903. return m.OldCreatedAt(ctx)
  904. case agent.FieldUpdatedAt:
  905. return m.OldUpdatedAt(ctx)
  906. case agent.FieldDeletedAt:
  907. return m.OldDeletedAt(ctx)
  908. case agent.FieldName:
  909. return m.OldName(ctx)
  910. case agent.FieldRole:
  911. return m.OldRole(ctx)
  912. case agent.FieldStatus:
  913. return m.OldStatus(ctx)
  914. case agent.FieldBackground:
  915. return m.OldBackground(ctx)
  916. case agent.FieldExamples:
  917. return m.OldExamples(ctx)
  918. case agent.FieldOrganizationID:
  919. return m.OldOrganizationID(ctx)
  920. case agent.FieldDatasetID:
  921. return m.OldDatasetID(ctx)
  922. case agent.FieldCollectionID:
  923. return m.OldCollectionID(ctx)
  924. }
  925. return nil, fmt.Errorf("unknown Agent field %s", name)
  926. }
  927. // SetField sets the value of a field with the given name. It returns an error if
  928. // the field is not defined in the schema, or if the type mismatched the field
  929. // type.
  930. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  931. switch name {
  932. case agent.FieldCreatedAt:
  933. v, ok := value.(time.Time)
  934. if !ok {
  935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  936. }
  937. m.SetCreatedAt(v)
  938. return nil
  939. case agent.FieldUpdatedAt:
  940. v, ok := value.(time.Time)
  941. if !ok {
  942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  943. }
  944. m.SetUpdatedAt(v)
  945. return nil
  946. case agent.FieldDeletedAt:
  947. v, ok := value.(time.Time)
  948. if !ok {
  949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  950. }
  951. m.SetDeletedAt(v)
  952. return nil
  953. case agent.FieldName:
  954. v, ok := value.(string)
  955. if !ok {
  956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  957. }
  958. m.SetName(v)
  959. return nil
  960. case agent.FieldRole:
  961. v, ok := value.(string)
  962. if !ok {
  963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  964. }
  965. m.SetRole(v)
  966. return nil
  967. case agent.FieldStatus:
  968. v, ok := value.(int)
  969. if !ok {
  970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  971. }
  972. m.SetStatus(v)
  973. return nil
  974. case agent.FieldBackground:
  975. v, ok := value.(string)
  976. if !ok {
  977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  978. }
  979. m.SetBackground(v)
  980. return nil
  981. case agent.FieldExamples:
  982. v, ok := value.(string)
  983. if !ok {
  984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  985. }
  986. m.SetExamples(v)
  987. return nil
  988. case agent.FieldOrganizationID:
  989. v, ok := value.(uint64)
  990. if !ok {
  991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  992. }
  993. m.SetOrganizationID(v)
  994. return nil
  995. case agent.FieldDatasetID:
  996. v, ok := value.(string)
  997. if !ok {
  998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  999. }
  1000. m.SetDatasetID(v)
  1001. return nil
  1002. case agent.FieldCollectionID:
  1003. v, ok := value.(string)
  1004. if !ok {
  1005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1006. }
  1007. m.SetCollectionID(v)
  1008. return nil
  1009. }
  1010. return fmt.Errorf("unknown Agent field %s", name)
  1011. }
  1012. // AddedFields returns all numeric fields that were incremented/decremented during
  1013. // this mutation.
  1014. func (m *AgentMutation) AddedFields() []string {
  1015. var fields []string
  1016. if m.addstatus != nil {
  1017. fields = append(fields, agent.FieldStatus)
  1018. }
  1019. if m.addorganization_id != nil {
  1020. fields = append(fields, agent.FieldOrganizationID)
  1021. }
  1022. return fields
  1023. }
  1024. // AddedField returns the numeric value that was incremented/decremented on a field
  1025. // with the given name. The second boolean return value indicates that this field
  1026. // was not set, or was not defined in the schema.
  1027. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  1028. switch name {
  1029. case agent.FieldStatus:
  1030. return m.AddedStatus()
  1031. case agent.FieldOrganizationID:
  1032. return m.AddedOrganizationID()
  1033. }
  1034. return nil, false
  1035. }
  1036. // AddField adds the value to the field with the given name. It returns an error if
  1037. // the field is not defined in the schema, or if the type mismatched the field
  1038. // type.
  1039. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  1040. switch name {
  1041. case agent.FieldStatus:
  1042. v, ok := value.(int)
  1043. if !ok {
  1044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1045. }
  1046. m.AddStatus(v)
  1047. return nil
  1048. case agent.FieldOrganizationID:
  1049. v, ok := value.(int64)
  1050. if !ok {
  1051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1052. }
  1053. m.AddOrganizationID(v)
  1054. return nil
  1055. }
  1056. return fmt.Errorf("unknown Agent numeric field %s", name)
  1057. }
  1058. // ClearedFields returns all nullable fields that were cleared during this
  1059. // mutation.
  1060. func (m *AgentMutation) ClearedFields() []string {
  1061. var fields []string
  1062. if m.FieldCleared(agent.FieldDeletedAt) {
  1063. fields = append(fields, agent.FieldDeletedAt)
  1064. }
  1065. if m.FieldCleared(agent.FieldStatus) {
  1066. fields = append(fields, agent.FieldStatus)
  1067. }
  1068. if m.FieldCleared(agent.FieldBackground) {
  1069. fields = append(fields, agent.FieldBackground)
  1070. }
  1071. if m.FieldCleared(agent.FieldExamples) {
  1072. fields = append(fields, agent.FieldExamples)
  1073. }
  1074. return fields
  1075. }
  1076. // FieldCleared returns a boolean indicating if a field with the given name was
  1077. // cleared in this mutation.
  1078. func (m *AgentMutation) FieldCleared(name string) bool {
  1079. _, ok := m.clearedFields[name]
  1080. return ok
  1081. }
  1082. // ClearField clears the value of the field with the given name. It returns an
  1083. // error if the field is not defined in the schema.
  1084. func (m *AgentMutation) ClearField(name string) error {
  1085. switch name {
  1086. case agent.FieldDeletedAt:
  1087. m.ClearDeletedAt()
  1088. return nil
  1089. case agent.FieldStatus:
  1090. m.ClearStatus()
  1091. return nil
  1092. case agent.FieldBackground:
  1093. m.ClearBackground()
  1094. return nil
  1095. case agent.FieldExamples:
  1096. m.ClearExamples()
  1097. return nil
  1098. }
  1099. return fmt.Errorf("unknown Agent nullable field %s", name)
  1100. }
  1101. // ResetField resets all changes in the mutation for the field with the given name.
  1102. // It returns an error if the field is not defined in the schema.
  1103. func (m *AgentMutation) ResetField(name string) error {
  1104. switch name {
  1105. case agent.FieldCreatedAt:
  1106. m.ResetCreatedAt()
  1107. return nil
  1108. case agent.FieldUpdatedAt:
  1109. m.ResetUpdatedAt()
  1110. return nil
  1111. case agent.FieldDeletedAt:
  1112. m.ResetDeletedAt()
  1113. return nil
  1114. case agent.FieldName:
  1115. m.ResetName()
  1116. return nil
  1117. case agent.FieldRole:
  1118. m.ResetRole()
  1119. return nil
  1120. case agent.FieldStatus:
  1121. m.ResetStatus()
  1122. return nil
  1123. case agent.FieldBackground:
  1124. m.ResetBackground()
  1125. return nil
  1126. case agent.FieldExamples:
  1127. m.ResetExamples()
  1128. return nil
  1129. case agent.FieldOrganizationID:
  1130. m.ResetOrganizationID()
  1131. return nil
  1132. case agent.FieldDatasetID:
  1133. m.ResetDatasetID()
  1134. return nil
  1135. case agent.FieldCollectionID:
  1136. m.ResetCollectionID()
  1137. return nil
  1138. }
  1139. return fmt.Errorf("unknown Agent field %s", name)
  1140. }
  1141. // AddedEdges returns all edge names that were set/added in this mutation.
  1142. func (m *AgentMutation) AddedEdges() []string {
  1143. edges := make([]string, 0, 3)
  1144. if m.wx_agent != nil {
  1145. edges = append(edges, agent.EdgeWxAgent)
  1146. }
  1147. if m.token_agent != nil {
  1148. edges = append(edges, agent.EdgeTokenAgent)
  1149. }
  1150. if m.wa_agent != nil {
  1151. edges = append(edges, agent.EdgeWaAgent)
  1152. }
  1153. return edges
  1154. }
  1155. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1156. // name in this mutation.
  1157. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1158. switch name {
  1159. case agent.EdgeWxAgent:
  1160. ids := make([]ent.Value, 0, len(m.wx_agent))
  1161. for id := range m.wx_agent {
  1162. ids = append(ids, id)
  1163. }
  1164. return ids
  1165. case agent.EdgeTokenAgent:
  1166. ids := make([]ent.Value, 0, len(m.token_agent))
  1167. for id := range m.token_agent {
  1168. ids = append(ids, id)
  1169. }
  1170. return ids
  1171. case agent.EdgeWaAgent:
  1172. ids := make([]ent.Value, 0, len(m.wa_agent))
  1173. for id := range m.wa_agent {
  1174. ids = append(ids, id)
  1175. }
  1176. return ids
  1177. }
  1178. return nil
  1179. }
  1180. // RemovedEdges returns all edge names that were removed in this mutation.
  1181. func (m *AgentMutation) RemovedEdges() []string {
  1182. edges := make([]string, 0, 3)
  1183. if m.removedwx_agent != nil {
  1184. edges = append(edges, agent.EdgeWxAgent)
  1185. }
  1186. if m.removedtoken_agent != nil {
  1187. edges = append(edges, agent.EdgeTokenAgent)
  1188. }
  1189. if m.removedwa_agent != nil {
  1190. edges = append(edges, agent.EdgeWaAgent)
  1191. }
  1192. return edges
  1193. }
  1194. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1195. // the given name in this mutation.
  1196. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1197. switch name {
  1198. case agent.EdgeWxAgent:
  1199. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1200. for id := range m.removedwx_agent {
  1201. ids = append(ids, id)
  1202. }
  1203. return ids
  1204. case agent.EdgeTokenAgent:
  1205. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1206. for id := range m.removedtoken_agent {
  1207. ids = append(ids, id)
  1208. }
  1209. return ids
  1210. case agent.EdgeWaAgent:
  1211. ids := make([]ent.Value, 0, len(m.removedwa_agent))
  1212. for id := range m.removedwa_agent {
  1213. ids = append(ids, id)
  1214. }
  1215. return ids
  1216. }
  1217. return nil
  1218. }
  1219. // ClearedEdges returns all edge names that were cleared in this mutation.
  1220. func (m *AgentMutation) ClearedEdges() []string {
  1221. edges := make([]string, 0, 3)
  1222. if m.clearedwx_agent {
  1223. edges = append(edges, agent.EdgeWxAgent)
  1224. }
  1225. if m.clearedtoken_agent {
  1226. edges = append(edges, agent.EdgeTokenAgent)
  1227. }
  1228. if m.clearedwa_agent {
  1229. edges = append(edges, agent.EdgeWaAgent)
  1230. }
  1231. return edges
  1232. }
  1233. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1234. // was cleared in this mutation.
  1235. func (m *AgentMutation) EdgeCleared(name string) bool {
  1236. switch name {
  1237. case agent.EdgeWxAgent:
  1238. return m.clearedwx_agent
  1239. case agent.EdgeTokenAgent:
  1240. return m.clearedtoken_agent
  1241. case agent.EdgeWaAgent:
  1242. return m.clearedwa_agent
  1243. }
  1244. return false
  1245. }
  1246. // ClearEdge clears the value of the edge with the given name. It returns an error
  1247. // if that edge is not defined in the schema.
  1248. func (m *AgentMutation) ClearEdge(name string) error {
  1249. switch name {
  1250. }
  1251. return fmt.Errorf("unknown Agent unique edge %s", name)
  1252. }
  1253. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1254. // It returns an error if the edge is not defined in the schema.
  1255. func (m *AgentMutation) ResetEdge(name string) error {
  1256. switch name {
  1257. case agent.EdgeWxAgent:
  1258. m.ResetWxAgent()
  1259. return nil
  1260. case agent.EdgeTokenAgent:
  1261. m.ResetTokenAgent()
  1262. return nil
  1263. case agent.EdgeWaAgent:
  1264. m.ResetWaAgent()
  1265. return nil
  1266. }
  1267. return fmt.Errorf("unknown Agent edge %s", name)
  1268. }
  1269. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1270. type AgentBaseMutation struct {
  1271. config
  1272. op Op
  1273. typ string
  1274. id *string
  1275. q *string
  1276. a *string
  1277. chunk_index *uint64
  1278. addchunk_index *int64
  1279. indexes *[]string
  1280. appendindexes []string
  1281. dataset_id *string
  1282. collection_id *string
  1283. source_name *string
  1284. can_write *[]bool
  1285. appendcan_write []bool
  1286. is_owner *[]bool
  1287. appendis_owner []bool
  1288. clearedFields map[string]struct{}
  1289. wx_agent map[uint64]struct{}
  1290. removedwx_agent map[uint64]struct{}
  1291. clearedwx_agent bool
  1292. done bool
  1293. oldValue func(context.Context) (*AgentBase, error)
  1294. predicates []predicate.AgentBase
  1295. }
  1296. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1297. // agentbaseOption allows management of the mutation configuration using functional options.
  1298. type agentbaseOption func(*AgentBaseMutation)
  1299. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1300. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1301. m := &AgentBaseMutation{
  1302. config: c,
  1303. op: op,
  1304. typ: TypeAgentBase,
  1305. clearedFields: make(map[string]struct{}),
  1306. }
  1307. for _, opt := range opts {
  1308. opt(m)
  1309. }
  1310. return m
  1311. }
  1312. // withAgentBaseID sets the ID field of the mutation.
  1313. func withAgentBaseID(id string) agentbaseOption {
  1314. return func(m *AgentBaseMutation) {
  1315. var (
  1316. err error
  1317. once sync.Once
  1318. value *AgentBase
  1319. )
  1320. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1321. once.Do(func() {
  1322. if m.done {
  1323. err = errors.New("querying old values post mutation is not allowed")
  1324. } else {
  1325. value, err = m.Client().AgentBase.Get(ctx, id)
  1326. }
  1327. })
  1328. return value, err
  1329. }
  1330. m.id = &id
  1331. }
  1332. }
  1333. // withAgentBase sets the old AgentBase of the mutation.
  1334. func withAgentBase(node *AgentBase) agentbaseOption {
  1335. return func(m *AgentBaseMutation) {
  1336. m.oldValue = func(context.Context) (*AgentBase, error) {
  1337. return node, nil
  1338. }
  1339. m.id = &node.ID
  1340. }
  1341. }
  1342. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1343. // executed in a transaction (ent.Tx), a transactional client is returned.
  1344. func (m AgentBaseMutation) Client() *Client {
  1345. client := &Client{config: m.config}
  1346. client.init()
  1347. return client
  1348. }
  1349. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1350. // it returns an error otherwise.
  1351. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1352. if _, ok := m.driver.(*txDriver); !ok {
  1353. return nil, errors.New("ent: mutation is not running in a transaction")
  1354. }
  1355. tx := &Tx{config: m.config}
  1356. tx.init()
  1357. return tx, nil
  1358. }
  1359. // SetID sets the value of the id field. Note that this
  1360. // operation is only accepted on creation of AgentBase entities.
  1361. func (m *AgentBaseMutation) SetID(id string) {
  1362. m.id = &id
  1363. }
  1364. // ID returns the ID value in the mutation. Note that the ID is only available
  1365. // if it was provided to the builder or after it was returned from the database.
  1366. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1367. if m.id == nil {
  1368. return
  1369. }
  1370. return *m.id, true
  1371. }
  1372. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1373. // That means, if the mutation is applied within a transaction with an isolation level such
  1374. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1375. // or updated by the mutation.
  1376. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1377. switch {
  1378. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1379. id, exists := m.ID()
  1380. if exists {
  1381. return []string{id}, nil
  1382. }
  1383. fallthrough
  1384. case m.op.Is(OpUpdate | OpDelete):
  1385. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1386. default:
  1387. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1388. }
  1389. }
  1390. // SetQ sets the "q" field.
  1391. func (m *AgentBaseMutation) SetQ(s string) {
  1392. m.q = &s
  1393. }
  1394. // Q returns the value of the "q" field in the mutation.
  1395. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1396. v := m.q
  1397. if v == nil {
  1398. return
  1399. }
  1400. return *v, true
  1401. }
  1402. // OldQ returns the old "q" field's value of the AgentBase entity.
  1403. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1405. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1406. if !m.op.Is(OpUpdateOne) {
  1407. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1408. }
  1409. if m.id == nil || m.oldValue == nil {
  1410. return v, errors.New("OldQ requires an ID field in the mutation")
  1411. }
  1412. oldValue, err := m.oldValue(ctx)
  1413. if err != nil {
  1414. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1415. }
  1416. return oldValue.Q, nil
  1417. }
  1418. // ClearQ clears the value of the "q" field.
  1419. func (m *AgentBaseMutation) ClearQ() {
  1420. m.q = nil
  1421. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1422. }
  1423. // QCleared returns if the "q" field was cleared in this mutation.
  1424. func (m *AgentBaseMutation) QCleared() bool {
  1425. _, ok := m.clearedFields[agentbase.FieldQ]
  1426. return ok
  1427. }
  1428. // ResetQ resets all changes to the "q" field.
  1429. func (m *AgentBaseMutation) ResetQ() {
  1430. m.q = nil
  1431. delete(m.clearedFields, agentbase.FieldQ)
  1432. }
  1433. // SetA sets the "a" field.
  1434. func (m *AgentBaseMutation) SetA(s string) {
  1435. m.a = &s
  1436. }
  1437. // A returns the value of the "a" field in the mutation.
  1438. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1439. v := m.a
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // OldA returns the old "a" field's value of the AgentBase entity.
  1446. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1448. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1449. if !m.op.Is(OpUpdateOne) {
  1450. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1451. }
  1452. if m.id == nil || m.oldValue == nil {
  1453. return v, errors.New("OldA requires an ID field in the mutation")
  1454. }
  1455. oldValue, err := m.oldValue(ctx)
  1456. if err != nil {
  1457. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1458. }
  1459. return oldValue.A, nil
  1460. }
  1461. // ClearA clears the value of the "a" field.
  1462. func (m *AgentBaseMutation) ClearA() {
  1463. m.a = nil
  1464. m.clearedFields[agentbase.FieldA] = struct{}{}
  1465. }
  1466. // ACleared returns if the "a" field was cleared in this mutation.
  1467. func (m *AgentBaseMutation) ACleared() bool {
  1468. _, ok := m.clearedFields[agentbase.FieldA]
  1469. return ok
  1470. }
  1471. // ResetA resets all changes to the "a" field.
  1472. func (m *AgentBaseMutation) ResetA() {
  1473. m.a = nil
  1474. delete(m.clearedFields, agentbase.FieldA)
  1475. }
  1476. // SetChunkIndex sets the "chunk_index" field.
  1477. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1478. m.chunk_index = &u
  1479. m.addchunk_index = nil
  1480. }
  1481. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1482. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1483. v := m.chunk_index
  1484. if v == nil {
  1485. return
  1486. }
  1487. return *v, true
  1488. }
  1489. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1490. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1492. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1493. if !m.op.Is(OpUpdateOne) {
  1494. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1495. }
  1496. if m.id == nil || m.oldValue == nil {
  1497. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1498. }
  1499. oldValue, err := m.oldValue(ctx)
  1500. if err != nil {
  1501. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1502. }
  1503. return oldValue.ChunkIndex, nil
  1504. }
  1505. // AddChunkIndex adds u to the "chunk_index" field.
  1506. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1507. if m.addchunk_index != nil {
  1508. *m.addchunk_index += u
  1509. } else {
  1510. m.addchunk_index = &u
  1511. }
  1512. }
  1513. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1514. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1515. v := m.addchunk_index
  1516. if v == nil {
  1517. return
  1518. }
  1519. return *v, true
  1520. }
  1521. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1522. func (m *AgentBaseMutation) ResetChunkIndex() {
  1523. m.chunk_index = nil
  1524. m.addchunk_index = nil
  1525. }
  1526. // SetIndexes sets the "indexes" field.
  1527. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1528. m.indexes = &s
  1529. m.appendindexes = nil
  1530. }
  1531. // Indexes returns the value of the "indexes" field in the mutation.
  1532. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1533. v := m.indexes
  1534. if v == nil {
  1535. return
  1536. }
  1537. return *v, true
  1538. }
  1539. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1540. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1541. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1542. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1543. if !m.op.Is(OpUpdateOne) {
  1544. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1545. }
  1546. if m.id == nil || m.oldValue == nil {
  1547. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1548. }
  1549. oldValue, err := m.oldValue(ctx)
  1550. if err != nil {
  1551. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1552. }
  1553. return oldValue.Indexes, nil
  1554. }
  1555. // AppendIndexes adds s to the "indexes" field.
  1556. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1557. m.appendindexes = append(m.appendindexes, s...)
  1558. }
  1559. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1560. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1561. if len(m.appendindexes) == 0 {
  1562. return nil, false
  1563. }
  1564. return m.appendindexes, true
  1565. }
  1566. // ClearIndexes clears the value of the "indexes" field.
  1567. func (m *AgentBaseMutation) ClearIndexes() {
  1568. m.indexes = nil
  1569. m.appendindexes = nil
  1570. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1571. }
  1572. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1573. func (m *AgentBaseMutation) IndexesCleared() bool {
  1574. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1575. return ok
  1576. }
  1577. // ResetIndexes resets all changes to the "indexes" field.
  1578. func (m *AgentBaseMutation) ResetIndexes() {
  1579. m.indexes = nil
  1580. m.appendindexes = nil
  1581. delete(m.clearedFields, agentbase.FieldIndexes)
  1582. }
  1583. // SetDatasetID sets the "dataset_id" field.
  1584. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1585. m.dataset_id = &s
  1586. }
  1587. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1588. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1589. v := m.dataset_id
  1590. if v == nil {
  1591. return
  1592. }
  1593. return *v, true
  1594. }
  1595. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1596. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1597. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1598. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1599. if !m.op.Is(OpUpdateOne) {
  1600. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1601. }
  1602. if m.id == nil || m.oldValue == nil {
  1603. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1604. }
  1605. oldValue, err := m.oldValue(ctx)
  1606. if err != nil {
  1607. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1608. }
  1609. return oldValue.DatasetID, nil
  1610. }
  1611. // ClearDatasetID clears the value of the "dataset_id" field.
  1612. func (m *AgentBaseMutation) ClearDatasetID() {
  1613. m.dataset_id = nil
  1614. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1615. }
  1616. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1617. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1618. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1619. return ok
  1620. }
  1621. // ResetDatasetID resets all changes to the "dataset_id" field.
  1622. func (m *AgentBaseMutation) ResetDatasetID() {
  1623. m.dataset_id = nil
  1624. delete(m.clearedFields, agentbase.FieldDatasetID)
  1625. }
  1626. // SetCollectionID sets the "collection_id" field.
  1627. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1628. m.collection_id = &s
  1629. }
  1630. // CollectionID returns the value of the "collection_id" field in the mutation.
  1631. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1632. v := m.collection_id
  1633. if v == nil {
  1634. return
  1635. }
  1636. return *v, true
  1637. }
  1638. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1639. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1641. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1642. if !m.op.Is(OpUpdateOne) {
  1643. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1644. }
  1645. if m.id == nil || m.oldValue == nil {
  1646. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1647. }
  1648. oldValue, err := m.oldValue(ctx)
  1649. if err != nil {
  1650. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1651. }
  1652. return oldValue.CollectionID, nil
  1653. }
  1654. // ClearCollectionID clears the value of the "collection_id" field.
  1655. func (m *AgentBaseMutation) ClearCollectionID() {
  1656. m.collection_id = nil
  1657. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1658. }
  1659. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1660. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1661. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1662. return ok
  1663. }
  1664. // ResetCollectionID resets all changes to the "collection_id" field.
  1665. func (m *AgentBaseMutation) ResetCollectionID() {
  1666. m.collection_id = nil
  1667. delete(m.clearedFields, agentbase.FieldCollectionID)
  1668. }
  1669. // SetSourceName sets the "source_name" field.
  1670. func (m *AgentBaseMutation) SetSourceName(s string) {
  1671. m.source_name = &s
  1672. }
  1673. // SourceName returns the value of the "source_name" field in the mutation.
  1674. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1675. v := m.source_name
  1676. if v == nil {
  1677. return
  1678. }
  1679. return *v, true
  1680. }
  1681. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1682. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1683. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1684. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1685. if !m.op.Is(OpUpdateOne) {
  1686. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1687. }
  1688. if m.id == nil || m.oldValue == nil {
  1689. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1690. }
  1691. oldValue, err := m.oldValue(ctx)
  1692. if err != nil {
  1693. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1694. }
  1695. return oldValue.SourceName, nil
  1696. }
  1697. // ClearSourceName clears the value of the "source_name" field.
  1698. func (m *AgentBaseMutation) ClearSourceName() {
  1699. m.source_name = nil
  1700. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1701. }
  1702. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1703. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1704. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1705. return ok
  1706. }
  1707. // ResetSourceName resets all changes to the "source_name" field.
  1708. func (m *AgentBaseMutation) ResetSourceName() {
  1709. m.source_name = nil
  1710. delete(m.clearedFields, agentbase.FieldSourceName)
  1711. }
  1712. // SetCanWrite sets the "can_write" field.
  1713. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1714. m.can_write = &b
  1715. m.appendcan_write = nil
  1716. }
  1717. // CanWrite returns the value of the "can_write" field in the mutation.
  1718. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1719. v := m.can_write
  1720. if v == nil {
  1721. return
  1722. }
  1723. return *v, true
  1724. }
  1725. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1726. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1728. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1729. if !m.op.Is(OpUpdateOne) {
  1730. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1731. }
  1732. if m.id == nil || m.oldValue == nil {
  1733. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1734. }
  1735. oldValue, err := m.oldValue(ctx)
  1736. if err != nil {
  1737. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1738. }
  1739. return oldValue.CanWrite, nil
  1740. }
  1741. // AppendCanWrite adds b to the "can_write" field.
  1742. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1743. m.appendcan_write = append(m.appendcan_write, b...)
  1744. }
  1745. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1746. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1747. if len(m.appendcan_write) == 0 {
  1748. return nil, false
  1749. }
  1750. return m.appendcan_write, true
  1751. }
  1752. // ClearCanWrite clears the value of the "can_write" field.
  1753. func (m *AgentBaseMutation) ClearCanWrite() {
  1754. m.can_write = nil
  1755. m.appendcan_write = nil
  1756. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1757. }
  1758. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1759. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1760. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1761. return ok
  1762. }
  1763. // ResetCanWrite resets all changes to the "can_write" field.
  1764. func (m *AgentBaseMutation) ResetCanWrite() {
  1765. m.can_write = nil
  1766. m.appendcan_write = nil
  1767. delete(m.clearedFields, agentbase.FieldCanWrite)
  1768. }
  1769. // SetIsOwner sets the "is_owner" field.
  1770. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1771. m.is_owner = &b
  1772. m.appendis_owner = nil
  1773. }
  1774. // IsOwner returns the value of the "is_owner" field in the mutation.
  1775. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1776. v := m.is_owner
  1777. if v == nil {
  1778. return
  1779. }
  1780. return *v, true
  1781. }
  1782. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1783. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1784. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1785. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1786. if !m.op.Is(OpUpdateOne) {
  1787. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1788. }
  1789. if m.id == nil || m.oldValue == nil {
  1790. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1791. }
  1792. oldValue, err := m.oldValue(ctx)
  1793. if err != nil {
  1794. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1795. }
  1796. return oldValue.IsOwner, nil
  1797. }
  1798. // AppendIsOwner adds b to the "is_owner" field.
  1799. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1800. m.appendis_owner = append(m.appendis_owner, b...)
  1801. }
  1802. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1803. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1804. if len(m.appendis_owner) == 0 {
  1805. return nil, false
  1806. }
  1807. return m.appendis_owner, true
  1808. }
  1809. // ClearIsOwner clears the value of the "is_owner" field.
  1810. func (m *AgentBaseMutation) ClearIsOwner() {
  1811. m.is_owner = nil
  1812. m.appendis_owner = nil
  1813. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1814. }
  1815. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1816. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1817. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1818. return ok
  1819. }
  1820. // ResetIsOwner resets all changes to the "is_owner" field.
  1821. func (m *AgentBaseMutation) ResetIsOwner() {
  1822. m.is_owner = nil
  1823. m.appendis_owner = nil
  1824. delete(m.clearedFields, agentbase.FieldIsOwner)
  1825. }
  1826. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1827. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1828. if m.wx_agent == nil {
  1829. m.wx_agent = make(map[uint64]struct{})
  1830. }
  1831. for i := range ids {
  1832. m.wx_agent[ids[i]] = struct{}{}
  1833. }
  1834. }
  1835. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1836. func (m *AgentBaseMutation) ClearWxAgent() {
  1837. m.clearedwx_agent = true
  1838. }
  1839. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1840. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1841. return m.clearedwx_agent
  1842. }
  1843. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1844. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1845. if m.removedwx_agent == nil {
  1846. m.removedwx_agent = make(map[uint64]struct{})
  1847. }
  1848. for i := range ids {
  1849. delete(m.wx_agent, ids[i])
  1850. m.removedwx_agent[ids[i]] = struct{}{}
  1851. }
  1852. }
  1853. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1854. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1855. for id := range m.removedwx_agent {
  1856. ids = append(ids, id)
  1857. }
  1858. return
  1859. }
  1860. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1861. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1862. for id := range m.wx_agent {
  1863. ids = append(ids, id)
  1864. }
  1865. return
  1866. }
  1867. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1868. func (m *AgentBaseMutation) ResetWxAgent() {
  1869. m.wx_agent = nil
  1870. m.clearedwx_agent = false
  1871. m.removedwx_agent = nil
  1872. }
  1873. // Where appends a list predicates to the AgentBaseMutation builder.
  1874. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1875. m.predicates = append(m.predicates, ps...)
  1876. }
  1877. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1878. // users can use type-assertion to append predicates that do not depend on any generated package.
  1879. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1880. p := make([]predicate.AgentBase, len(ps))
  1881. for i := range ps {
  1882. p[i] = ps[i]
  1883. }
  1884. m.Where(p...)
  1885. }
  1886. // Op returns the operation name.
  1887. func (m *AgentBaseMutation) Op() Op {
  1888. return m.op
  1889. }
  1890. // SetOp allows setting the mutation operation.
  1891. func (m *AgentBaseMutation) SetOp(op Op) {
  1892. m.op = op
  1893. }
  1894. // Type returns the node type of this mutation (AgentBase).
  1895. func (m *AgentBaseMutation) Type() string {
  1896. return m.typ
  1897. }
  1898. // Fields returns all fields that were changed during this mutation. Note that in
  1899. // order to get all numeric fields that were incremented/decremented, call
  1900. // AddedFields().
  1901. func (m *AgentBaseMutation) Fields() []string {
  1902. fields := make([]string, 0, 9)
  1903. if m.q != nil {
  1904. fields = append(fields, agentbase.FieldQ)
  1905. }
  1906. if m.a != nil {
  1907. fields = append(fields, agentbase.FieldA)
  1908. }
  1909. if m.chunk_index != nil {
  1910. fields = append(fields, agentbase.FieldChunkIndex)
  1911. }
  1912. if m.indexes != nil {
  1913. fields = append(fields, agentbase.FieldIndexes)
  1914. }
  1915. if m.dataset_id != nil {
  1916. fields = append(fields, agentbase.FieldDatasetID)
  1917. }
  1918. if m.collection_id != nil {
  1919. fields = append(fields, agentbase.FieldCollectionID)
  1920. }
  1921. if m.source_name != nil {
  1922. fields = append(fields, agentbase.FieldSourceName)
  1923. }
  1924. if m.can_write != nil {
  1925. fields = append(fields, agentbase.FieldCanWrite)
  1926. }
  1927. if m.is_owner != nil {
  1928. fields = append(fields, agentbase.FieldIsOwner)
  1929. }
  1930. return fields
  1931. }
  1932. // Field returns the value of a field with the given name. The second boolean
  1933. // return value indicates that this field was not set, or was not defined in the
  1934. // schema.
  1935. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1936. switch name {
  1937. case agentbase.FieldQ:
  1938. return m.Q()
  1939. case agentbase.FieldA:
  1940. return m.A()
  1941. case agentbase.FieldChunkIndex:
  1942. return m.ChunkIndex()
  1943. case agentbase.FieldIndexes:
  1944. return m.Indexes()
  1945. case agentbase.FieldDatasetID:
  1946. return m.DatasetID()
  1947. case agentbase.FieldCollectionID:
  1948. return m.CollectionID()
  1949. case agentbase.FieldSourceName:
  1950. return m.SourceName()
  1951. case agentbase.FieldCanWrite:
  1952. return m.CanWrite()
  1953. case agentbase.FieldIsOwner:
  1954. return m.IsOwner()
  1955. }
  1956. return nil, false
  1957. }
  1958. // OldField returns the old value of the field from the database. An error is
  1959. // returned if the mutation operation is not UpdateOne, or the query to the
  1960. // database failed.
  1961. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1962. switch name {
  1963. case agentbase.FieldQ:
  1964. return m.OldQ(ctx)
  1965. case agentbase.FieldA:
  1966. return m.OldA(ctx)
  1967. case agentbase.FieldChunkIndex:
  1968. return m.OldChunkIndex(ctx)
  1969. case agentbase.FieldIndexes:
  1970. return m.OldIndexes(ctx)
  1971. case agentbase.FieldDatasetID:
  1972. return m.OldDatasetID(ctx)
  1973. case agentbase.FieldCollectionID:
  1974. return m.OldCollectionID(ctx)
  1975. case agentbase.FieldSourceName:
  1976. return m.OldSourceName(ctx)
  1977. case agentbase.FieldCanWrite:
  1978. return m.OldCanWrite(ctx)
  1979. case agentbase.FieldIsOwner:
  1980. return m.OldIsOwner(ctx)
  1981. }
  1982. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1983. }
  1984. // SetField sets the value of a field with the given name. It returns an error if
  1985. // the field is not defined in the schema, or if the type mismatched the field
  1986. // type.
  1987. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1988. switch name {
  1989. case agentbase.FieldQ:
  1990. v, ok := value.(string)
  1991. if !ok {
  1992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1993. }
  1994. m.SetQ(v)
  1995. return nil
  1996. case agentbase.FieldA:
  1997. v, ok := value.(string)
  1998. if !ok {
  1999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2000. }
  2001. m.SetA(v)
  2002. return nil
  2003. case agentbase.FieldChunkIndex:
  2004. v, ok := value.(uint64)
  2005. if !ok {
  2006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2007. }
  2008. m.SetChunkIndex(v)
  2009. return nil
  2010. case agentbase.FieldIndexes:
  2011. v, ok := value.([]string)
  2012. if !ok {
  2013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2014. }
  2015. m.SetIndexes(v)
  2016. return nil
  2017. case agentbase.FieldDatasetID:
  2018. v, ok := value.(string)
  2019. if !ok {
  2020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2021. }
  2022. m.SetDatasetID(v)
  2023. return nil
  2024. case agentbase.FieldCollectionID:
  2025. v, ok := value.(string)
  2026. if !ok {
  2027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2028. }
  2029. m.SetCollectionID(v)
  2030. return nil
  2031. case agentbase.FieldSourceName:
  2032. v, ok := value.(string)
  2033. if !ok {
  2034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2035. }
  2036. m.SetSourceName(v)
  2037. return nil
  2038. case agentbase.FieldCanWrite:
  2039. v, ok := value.([]bool)
  2040. if !ok {
  2041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2042. }
  2043. m.SetCanWrite(v)
  2044. return nil
  2045. case agentbase.FieldIsOwner:
  2046. v, ok := value.([]bool)
  2047. if !ok {
  2048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2049. }
  2050. m.SetIsOwner(v)
  2051. return nil
  2052. }
  2053. return fmt.Errorf("unknown AgentBase field %s", name)
  2054. }
  2055. // AddedFields returns all numeric fields that were incremented/decremented during
  2056. // this mutation.
  2057. func (m *AgentBaseMutation) AddedFields() []string {
  2058. var fields []string
  2059. if m.addchunk_index != nil {
  2060. fields = append(fields, agentbase.FieldChunkIndex)
  2061. }
  2062. return fields
  2063. }
  2064. // AddedField returns the numeric value that was incremented/decremented on a field
  2065. // with the given name. The second boolean return value indicates that this field
  2066. // was not set, or was not defined in the schema.
  2067. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  2068. switch name {
  2069. case agentbase.FieldChunkIndex:
  2070. return m.AddedChunkIndex()
  2071. }
  2072. return nil, false
  2073. }
  2074. // AddField adds the value to the field with the given name. It returns an error if
  2075. // the field is not defined in the schema, or if the type mismatched the field
  2076. // type.
  2077. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2078. switch name {
  2079. case agentbase.FieldChunkIndex:
  2080. v, ok := value.(int64)
  2081. if !ok {
  2082. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2083. }
  2084. m.AddChunkIndex(v)
  2085. return nil
  2086. }
  2087. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2088. }
  2089. // ClearedFields returns all nullable fields that were cleared during this
  2090. // mutation.
  2091. func (m *AgentBaseMutation) ClearedFields() []string {
  2092. var fields []string
  2093. if m.FieldCleared(agentbase.FieldQ) {
  2094. fields = append(fields, agentbase.FieldQ)
  2095. }
  2096. if m.FieldCleared(agentbase.FieldA) {
  2097. fields = append(fields, agentbase.FieldA)
  2098. }
  2099. if m.FieldCleared(agentbase.FieldIndexes) {
  2100. fields = append(fields, agentbase.FieldIndexes)
  2101. }
  2102. if m.FieldCleared(agentbase.FieldDatasetID) {
  2103. fields = append(fields, agentbase.FieldDatasetID)
  2104. }
  2105. if m.FieldCleared(agentbase.FieldCollectionID) {
  2106. fields = append(fields, agentbase.FieldCollectionID)
  2107. }
  2108. if m.FieldCleared(agentbase.FieldSourceName) {
  2109. fields = append(fields, agentbase.FieldSourceName)
  2110. }
  2111. if m.FieldCleared(agentbase.FieldCanWrite) {
  2112. fields = append(fields, agentbase.FieldCanWrite)
  2113. }
  2114. if m.FieldCleared(agentbase.FieldIsOwner) {
  2115. fields = append(fields, agentbase.FieldIsOwner)
  2116. }
  2117. return fields
  2118. }
  2119. // FieldCleared returns a boolean indicating if a field with the given name was
  2120. // cleared in this mutation.
  2121. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2122. _, ok := m.clearedFields[name]
  2123. return ok
  2124. }
  2125. // ClearField clears the value of the field with the given name. It returns an
  2126. // error if the field is not defined in the schema.
  2127. func (m *AgentBaseMutation) ClearField(name string) error {
  2128. switch name {
  2129. case agentbase.FieldQ:
  2130. m.ClearQ()
  2131. return nil
  2132. case agentbase.FieldA:
  2133. m.ClearA()
  2134. return nil
  2135. case agentbase.FieldIndexes:
  2136. m.ClearIndexes()
  2137. return nil
  2138. case agentbase.FieldDatasetID:
  2139. m.ClearDatasetID()
  2140. return nil
  2141. case agentbase.FieldCollectionID:
  2142. m.ClearCollectionID()
  2143. return nil
  2144. case agentbase.FieldSourceName:
  2145. m.ClearSourceName()
  2146. return nil
  2147. case agentbase.FieldCanWrite:
  2148. m.ClearCanWrite()
  2149. return nil
  2150. case agentbase.FieldIsOwner:
  2151. m.ClearIsOwner()
  2152. return nil
  2153. }
  2154. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2155. }
  2156. // ResetField resets all changes in the mutation for the field with the given name.
  2157. // It returns an error if the field is not defined in the schema.
  2158. func (m *AgentBaseMutation) ResetField(name string) error {
  2159. switch name {
  2160. case agentbase.FieldQ:
  2161. m.ResetQ()
  2162. return nil
  2163. case agentbase.FieldA:
  2164. m.ResetA()
  2165. return nil
  2166. case agentbase.FieldChunkIndex:
  2167. m.ResetChunkIndex()
  2168. return nil
  2169. case agentbase.FieldIndexes:
  2170. m.ResetIndexes()
  2171. return nil
  2172. case agentbase.FieldDatasetID:
  2173. m.ResetDatasetID()
  2174. return nil
  2175. case agentbase.FieldCollectionID:
  2176. m.ResetCollectionID()
  2177. return nil
  2178. case agentbase.FieldSourceName:
  2179. m.ResetSourceName()
  2180. return nil
  2181. case agentbase.FieldCanWrite:
  2182. m.ResetCanWrite()
  2183. return nil
  2184. case agentbase.FieldIsOwner:
  2185. m.ResetIsOwner()
  2186. return nil
  2187. }
  2188. return fmt.Errorf("unknown AgentBase field %s", name)
  2189. }
  2190. // AddedEdges returns all edge names that were set/added in this mutation.
  2191. func (m *AgentBaseMutation) AddedEdges() []string {
  2192. edges := make([]string, 0, 1)
  2193. if m.wx_agent != nil {
  2194. edges = append(edges, agentbase.EdgeWxAgent)
  2195. }
  2196. return edges
  2197. }
  2198. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2199. // name in this mutation.
  2200. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2201. switch name {
  2202. case agentbase.EdgeWxAgent:
  2203. ids := make([]ent.Value, 0, len(m.wx_agent))
  2204. for id := range m.wx_agent {
  2205. ids = append(ids, id)
  2206. }
  2207. return ids
  2208. }
  2209. return nil
  2210. }
  2211. // RemovedEdges returns all edge names that were removed in this mutation.
  2212. func (m *AgentBaseMutation) RemovedEdges() []string {
  2213. edges := make([]string, 0, 1)
  2214. if m.removedwx_agent != nil {
  2215. edges = append(edges, agentbase.EdgeWxAgent)
  2216. }
  2217. return edges
  2218. }
  2219. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2220. // the given name in this mutation.
  2221. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2222. switch name {
  2223. case agentbase.EdgeWxAgent:
  2224. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2225. for id := range m.removedwx_agent {
  2226. ids = append(ids, id)
  2227. }
  2228. return ids
  2229. }
  2230. return nil
  2231. }
  2232. // ClearedEdges returns all edge names that were cleared in this mutation.
  2233. func (m *AgentBaseMutation) ClearedEdges() []string {
  2234. edges := make([]string, 0, 1)
  2235. if m.clearedwx_agent {
  2236. edges = append(edges, agentbase.EdgeWxAgent)
  2237. }
  2238. return edges
  2239. }
  2240. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2241. // was cleared in this mutation.
  2242. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2243. switch name {
  2244. case agentbase.EdgeWxAgent:
  2245. return m.clearedwx_agent
  2246. }
  2247. return false
  2248. }
  2249. // ClearEdge clears the value of the edge with the given name. It returns an error
  2250. // if that edge is not defined in the schema.
  2251. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2252. switch name {
  2253. }
  2254. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2255. }
  2256. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2257. // It returns an error if the edge is not defined in the schema.
  2258. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2259. switch name {
  2260. case agentbase.EdgeWxAgent:
  2261. m.ResetWxAgent()
  2262. return nil
  2263. }
  2264. return fmt.Errorf("unknown AgentBase edge %s", name)
  2265. }
  2266. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2267. type AliyunAvatarMutation struct {
  2268. config
  2269. op Op
  2270. typ string
  2271. id *uint64
  2272. created_at *time.Time
  2273. updated_at *time.Time
  2274. deleted_at *time.Time
  2275. user_id *uint64
  2276. adduser_id *int64
  2277. biz_id *string
  2278. access_key_id *string
  2279. access_key_secret *string
  2280. app_id *string
  2281. tenant_id *uint64
  2282. addtenant_id *int64
  2283. response *string
  2284. token *string
  2285. session_id *string
  2286. clearedFields map[string]struct{}
  2287. done bool
  2288. oldValue func(context.Context) (*AliyunAvatar, error)
  2289. predicates []predicate.AliyunAvatar
  2290. }
  2291. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2292. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2293. type aliyunavatarOption func(*AliyunAvatarMutation)
  2294. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2295. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2296. m := &AliyunAvatarMutation{
  2297. config: c,
  2298. op: op,
  2299. typ: TypeAliyunAvatar,
  2300. clearedFields: make(map[string]struct{}),
  2301. }
  2302. for _, opt := range opts {
  2303. opt(m)
  2304. }
  2305. return m
  2306. }
  2307. // withAliyunAvatarID sets the ID field of the mutation.
  2308. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2309. return func(m *AliyunAvatarMutation) {
  2310. var (
  2311. err error
  2312. once sync.Once
  2313. value *AliyunAvatar
  2314. )
  2315. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2316. once.Do(func() {
  2317. if m.done {
  2318. err = errors.New("querying old values post mutation is not allowed")
  2319. } else {
  2320. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2321. }
  2322. })
  2323. return value, err
  2324. }
  2325. m.id = &id
  2326. }
  2327. }
  2328. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2329. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2330. return func(m *AliyunAvatarMutation) {
  2331. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2332. return node, nil
  2333. }
  2334. m.id = &node.ID
  2335. }
  2336. }
  2337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2338. // executed in a transaction (ent.Tx), a transactional client is returned.
  2339. func (m AliyunAvatarMutation) Client() *Client {
  2340. client := &Client{config: m.config}
  2341. client.init()
  2342. return client
  2343. }
  2344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2345. // it returns an error otherwise.
  2346. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2347. if _, ok := m.driver.(*txDriver); !ok {
  2348. return nil, errors.New("ent: mutation is not running in a transaction")
  2349. }
  2350. tx := &Tx{config: m.config}
  2351. tx.init()
  2352. return tx, nil
  2353. }
  2354. // SetID sets the value of the id field. Note that this
  2355. // operation is only accepted on creation of AliyunAvatar entities.
  2356. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2357. m.id = &id
  2358. }
  2359. // ID returns the ID value in the mutation. Note that the ID is only available
  2360. // if it was provided to the builder or after it was returned from the database.
  2361. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2362. if m.id == nil {
  2363. return
  2364. }
  2365. return *m.id, true
  2366. }
  2367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2368. // That means, if the mutation is applied within a transaction with an isolation level such
  2369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2370. // or updated by the mutation.
  2371. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2372. switch {
  2373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2374. id, exists := m.ID()
  2375. if exists {
  2376. return []uint64{id}, nil
  2377. }
  2378. fallthrough
  2379. case m.op.Is(OpUpdate | OpDelete):
  2380. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2381. default:
  2382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2383. }
  2384. }
  2385. // SetCreatedAt sets the "created_at" field.
  2386. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2387. m.created_at = &t
  2388. }
  2389. // CreatedAt returns the value of the "created_at" field in the mutation.
  2390. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2391. v := m.created_at
  2392. if v == nil {
  2393. return
  2394. }
  2395. return *v, true
  2396. }
  2397. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2398. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2400. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2401. if !m.op.Is(OpUpdateOne) {
  2402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2403. }
  2404. if m.id == nil || m.oldValue == nil {
  2405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2406. }
  2407. oldValue, err := m.oldValue(ctx)
  2408. if err != nil {
  2409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2410. }
  2411. return oldValue.CreatedAt, nil
  2412. }
  2413. // ResetCreatedAt resets all changes to the "created_at" field.
  2414. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2415. m.created_at = nil
  2416. }
  2417. // SetUpdatedAt sets the "updated_at" field.
  2418. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2419. m.updated_at = &t
  2420. }
  2421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2422. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2423. v := m.updated_at
  2424. if v == nil {
  2425. return
  2426. }
  2427. return *v, true
  2428. }
  2429. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2430. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2432. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2433. if !m.op.Is(OpUpdateOne) {
  2434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2435. }
  2436. if m.id == nil || m.oldValue == nil {
  2437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2438. }
  2439. oldValue, err := m.oldValue(ctx)
  2440. if err != nil {
  2441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2442. }
  2443. return oldValue.UpdatedAt, nil
  2444. }
  2445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2446. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2447. m.updated_at = nil
  2448. }
  2449. // SetDeletedAt sets the "deleted_at" field.
  2450. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2451. m.deleted_at = &t
  2452. }
  2453. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2454. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2455. v := m.deleted_at
  2456. if v == nil {
  2457. return
  2458. }
  2459. return *v, true
  2460. }
  2461. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2462. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2464. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2465. if !m.op.Is(OpUpdateOne) {
  2466. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2467. }
  2468. if m.id == nil || m.oldValue == nil {
  2469. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2470. }
  2471. oldValue, err := m.oldValue(ctx)
  2472. if err != nil {
  2473. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2474. }
  2475. return oldValue.DeletedAt, nil
  2476. }
  2477. // ClearDeletedAt clears the value of the "deleted_at" field.
  2478. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2479. m.deleted_at = nil
  2480. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2481. }
  2482. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2483. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2484. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2485. return ok
  2486. }
  2487. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2488. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2489. m.deleted_at = nil
  2490. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2491. }
  2492. // SetUserID sets the "user_id" field.
  2493. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2494. m.user_id = &u
  2495. m.adduser_id = nil
  2496. }
  2497. // UserID returns the value of the "user_id" field in the mutation.
  2498. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2499. v := m.user_id
  2500. if v == nil {
  2501. return
  2502. }
  2503. return *v, true
  2504. }
  2505. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2506. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2508. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2509. if !m.op.Is(OpUpdateOne) {
  2510. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2511. }
  2512. if m.id == nil || m.oldValue == nil {
  2513. return v, errors.New("OldUserID requires an ID field in the mutation")
  2514. }
  2515. oldValue, err := m.oldValue(ctx)
  2516. if err != nil {
  2517. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2518. }
  2519. return oldValue.UserID, nil
  2520. }
  2521. // AddUserID adds u to the "user_id" field.
  2522. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2523. if m.adduser_id != nil {
  2524. *m.adduser_id += u
  2525. } else {
  2526. m.adduser_id = &u
  2527. }
  2528. }
  2529. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2530. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2531. v := m.adduser_id
  2532. if v == nil {
  2533. return
  2534. }
  2535. return *v, true
  2536. }
  2537. // ResetUserID resets all changes to the "user_id" field.
  2538. func (m *AliyunAvatarMutation) ResetUserID() {
  2539. m.user_id = nil
  2540. m.adduser_id = nil
  2541. }
  2542. // SetBizID sets the "biz_id" field.
  2543. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2544. m.biz_id = &s
  2545. }
  2546. // BizID returns the value of the "biz_id" field in the mutation.
  2547. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2548. v := m.biz_id
  2549. if v == nil {
  2550. return
  2551. }
  2552. return *v, true
  2553. }
  2554. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2555. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2557. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2558. if !m.op.Is(OpUpdateOne) {
  2559. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2560. }
  2561. if m.id == nil || m.oldValue == nil {
  2562. return v, errors.New("OldBizID requires an ID field in the mutation")
  2563. }
  2564. oldValue, err := m.oldValue(ctx)
  2565. if err != nil {
  2566. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2567. }
  2568. return oldValue.BizID, nil
  2569. }
  2570. // ResetBizID resets all changes to the "biz_id" field.
  2571. func (m *AliyunAvatarMutation) ResetBizID() {
  2572. m.biz_id = nil
  2573. }
  2574. // SetAccessKeyID sets the "access_key_id" field.
  2575. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2576. m.access_key_id = &s
  2577. }
  2578. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2579. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2580. v := m.access_key_id
  2581. if v == nil {
  2582. return
  2583. }
  2584. return *v, true
  2585. }
  2586. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2587. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2588. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2589. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2590. if !m.op.Is(OpUpdateOne) {
  2591. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2592. }
  2593. if m.id == nil || m.oldValue == nil {
  2594. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2595. }
  2596. oldValue, err := m.oldValue(ctx)
  2597. if err != nil {
  2598. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2599. }
  2600. return oldValue.AccessKeyID, nil
  2601. }
  2602. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2603. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2604. m.access_key_id = nil
  2605. }
  2606. // SetAccessKeySecret sets the "access_key_secret" field.
  2607. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2608. m.access_key_secret = &s
  2609. }
  2610. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2611. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2612. v := m.access_key_secret
  2613. if v == nil {
  2614. return
  2615. }
  2616. return *v, true
  2617. }
  2618. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2619. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2621. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2622. if !m.op.Is(OpUpdateOne) {
  2623. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2624. }
  2625. if m.id == nil || m.oldValue == nil {
  2626. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2627. }
  2628. oldValue, err := m.oldValue(ctx)
  2629. if err != nil {
  2630. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2631. }
  2632. return oldValue.AccessKeySecret, nil
  2633. }
  2634. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2635. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2636. m.access_key_secret = nil
  2637. }
  2638. // SetAppID sets the "app_id" field.
  2639. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2640. m.app_id = &s
  2641. }
  2642. // AppID returns the value of the "app_id" field in the mutation.
  2643. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2644. v := m.app_id
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2651. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2652. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2653. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2654. if !m.op.Is(OpUpdateOne) {
  2655. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2656. }
  2657. if m.id == nil || m.oldValue == nil {
  2658. return v, errors.New("OldAppID requires an ID field in the mutation")
  2659. }
  2660. oldValue, err := m.oldValue(ctx)
  2661. if err != nil {
  2662. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2663. }
  2664. return oldValue.AppID, nil
  2665. }
  2666. // ClearAppID clears the value of the "app_id" field.
  2667. func (m *AliyunAvatarMutation) ClearAppID() {
  2668. m.app_id = nil
  2669. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2670. }
  2671. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2672. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2673. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2674. return ok
  2675. }
  2676. // ResetAppID resets all changes to the "app_id" field.
  2677. func (m *AliyunAvatarMutation) ResetAppID() {
  2678. m.app_id = nil
  2679. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2680. }
  2681. // SetTenantID sets the "tenant_id" field.
  2682. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2683. m.tenant_id = &u
  2684. m.addtenant_id = nil
  2685. }
  2686. // TenantID returns the value of the "tenant_id" field in the mutation.
  2687. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2688. v := m.tenant_id
  2689. if v == nil {
  2690. return
  2691. }
  2692. return *v, true
  2693. }
  2694. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2695. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2696. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2697. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2698. if !m.op.Is(OpUpdateOne) {
  2699. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2700. }
  2701. if m.id == nil || m.oldValue == nil {
  2702. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2703. }
  2704. oldValue, err := m.oldValue(ctx)
  2705. if err != nil {
  2706. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2707. }
  2708. return oldValue.TenantID, nil
  2709. }
  2710. // AddTenantID adds u to the "tenant_id" field.
  2711. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2712. if m.addtenant_id != nil {
  2713. *m.addtenant_id += u
  2714. } else {
  2715. m.addtenant_id = &u
  2716. }
  2717. }
  2718. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2719. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2720. v := m.addtenant_id
  2721. if v == nil {
  2722. return
  2723. }
  2724. return *v, true
  2725. }
  2726. // ResetTenantID resets all changes to the "tenant_id" field.
  2727. func (m *AliyunAvatarMutation) ResetTenantID() {
  2728. m.tenant_id = nil
  2729. m.addtenant_id = nil
  2730. }
  2731. // SetResponse sets the "response" field.
  2732. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2733. m.response = &s
  2734. }
  2735. // Response returns the value of the "response" field in the mutation.
  2736. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2737. v := m.response
  2738. if v == nil {
  2739. return
  2740. }
  2741. return *v, true
  2742. }
  2743. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2744. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2746. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2747. if !m.op.Is(OpUpdateOne) {
  2748. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2749. }
  2750. if m.id == nil || m.oldValue == nil {
  2751. return v, errors.New("OldResponse requires an ID field in the mutation")
  2752. }
  2753. oldValue, err := m.oldValue(ctx)
  2754. if err != nil {
  2755. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2756. }
  2757. return oldValue.Response, nil
  2758. }
  2759. // ResetResponse resets all changes to the "response" field.
  2760. func (m *AliyunAvatarMutation) ResetResponse() {
  2761. m.response = nil
  2762. }
  2763. // SetToken sets the "token" field.
  2764. func (m *AliyunAvatarMutation) SetToken(s string) {
  2765. m.token = &s
  2766. }
  2767. // Token returns the value of the "token" field in the mutation.
  2768. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2769. v := m.token
  2770. if v == nil {
  2771. return
  2772. }
  2773. return *v, true
  2774. }
  2775. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2776. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2778. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2779. if !m.op.Is(OpUpdateOne) {
  2780. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2781. }
  2782. if m.id == nil || m.oldValue == nil {
  2783. return v, errors.New("OldToken requires an ID field in the mutation")
  2784. }
  2785. oldValue, err := m.oldValue(ctx)
  2786. if err != nil {
  2787. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2788. }
  2789. return oldValue.Token, nil
  2790. }
  2791. // ResetToken resets all changes to the "token" field.
  2792. func (m *AliyunAvatarMutation) ResetToken() {
  2793. m.token = nil
  2794. }
  2795. // SetSessionID sets the "session_id" field.
  2796. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2797. m.session_id = &s
  2798. }
  2799. // SessionID returns the value of the "session_id" field in the mutation.
  2800. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2801. v := m.session_id
  2802. if v == nil {
  2803. return
  2804. }
  2805. return *v, true
  2806. }
  2807. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2808. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2809. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2810. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2811. if !m.op.Is(OpUpdateOne) {
  2812. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2813. }
  2814. if m.id == nil || m.oldValue == nil {
  2815. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2816. }
  2817. oldValue, err := m.oldValue(ctx)
  2818. if err != nil {
  2819. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2820. }
  2821. return oldValue.SessionID, nil
  2822. }
  2823. // ResetSessionID resets all changes to the "session_id" field.
  2824. func (m *AliyunAvatarMutation) ResetSessionID() {
  2825. m.session_id = nil
  2826. }
  2827. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2828. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2829. m.predicates = append(m.predicates, ps...)
  2830. }
  2831. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2832. // users can use type-assertion to append predicates that do not depend on any generated package.
  2833. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2834. p := make([]predicate.AliyunAvatar, len(ps))
  2835. for i := range ps {
  2836. p[i] = ps[i]
  2837. }
  2838. m.Where(p...)
  2839. }
  2840. // Op returns the operation name.
  2841. func (m *AliyunAvatarMutation) Op() Op {
  2842. return m.op
  2843. }
  2844. // SetOp allows setting the mutation operation.
  2845. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2846. m.op = op
  2847. }
  2848. // Type returns the node type of this mutation (AliyunAvatar).
  2849. func (m *AliyunAvatarMutation) Type() string {
  2850. return m.typ
  2851. }
  2852. // Fields returns all fields that were changed during this mutation. Note that in
  2853. // order to get all numeric fields that were incremented/decremented, call
  2854. // AddedFields().
  2855. func (m *AliyunAvatarMutation) Fields() []string {
  2856. fields := make([]string, 0, 12)
  2857. if m.created_at != nil {
  2858. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2859. }
  2860. if m.updated_at != nil {
  2861. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2862. }
  2863. if m.deleted_at != nil {
  2864. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2865. }
  2866. if m.user_id != nil {
  2867. fields = append(fields, aliyunavatar.FieldUserID)
  2868. }
  2869. if m.biz_id != nil {
  2870. fields = append(fields, aliyunavatar.FieldBizID)
  2871. }
  2872. if m.access_key_id != nil {
  2873. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2874. }
  2875. if m.access_key_secret != nil {
  2876. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2877. }
  2878. if m.app_id != nil {
  2879. fields = append(fields, aliyunavatar.FieldAppID)
  2880. }
  2881. if m.tenant_id != nil {
  2882. fields = append(fields, aliyunavatar.FieldTenantID)
  2883. }
  2884. if m.response != nil {
  2885. fields = append(fields, aliyunavatar.FieldResponse)
  2886. }
  2887. if m.token != nil {
  2888. fields = append(fields, aliyunavatar.FieldToken)
  2889. }
  2890. if m.session_id != nil {
  2891. fields = append(fields, aliyunavatar.FieldSessionID)
  2892. }
  2893. return fields
  2894. }
  2895. // Field returns the value of a field with the given name. The second boolean
  2896. // return value indicates that this field was not set, or was not defined in the
  2897. // schema.
  2898. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2899. switch name {
  2900. case aliyunavatar.FieldCreatedAt:
  2901. return m.CreatedAt()
  2902. case aliyunavatar.FieldUpdatedAt:
  2903. return m.UpdatedAt()
  2904. case aliyunavatar.FieldDeletedAt:
  2905. return m.DeletedAt()
  2906. case aliyunavatar.FieldUserID:
  2907. return m.UserID()
  2908. case aliyunavatar.FieldBizID:
  2909. return m.BizID()
  2910. case aliyunavatar.FieldAccessKeyID:
  2911. return m.AccessKeyID()
  2912. case aliyunavatar.FieldAccessKeySecret:
  2913. return m.AccessKeySecret()
  2914. case aliyunavatar.FieldAppID:
  2915. return m.AppID()
  2916. case aliyunavatar.FieldTenantID:
  2917. return m.TenantID()
  2918. case aliyunavatar.FieldResponse:
  2919. return m.Response()
  2920. case aliyunavatar.FieldToken:
  2921. return m.Token()
  2922. case aliyunavatar.FieldSessionID:
  2923. return m.SessionID()
  2924. }
  2925. return nil, false
  2926. }
  2927. // OldField returns the old value of the field from the database. An error is
  2928. // returned if the mutation operation is not UpdateOne, or the query to the
  2929. // database failed.
  2930. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2931. switch name {
  2932. case aliyunavatar.FieldCreatedAt:
  2933. return m.OldCreatedAt(ctx)
  2934. case aliyunavatar.FieldUpdatedAt:
  2935. return m.OldUpdatedAt(ctx)
  2936. case aliyunavatar.FieldDeletedAt:
  2937. return m.OldDeletedAt(ctx)
  2938. case aliyunavatar.FieldUserID:
  2939. return m.OldUserID(ctx)
  2940. case aliyunavatar.FieldBizID:
  2941. return m.OldBizID(ctx)
  2942. case aliyunavatar.FieldAccessKeyID:
  2943. return m.OldAccessKeyID(ctx)
  2944. case aliyunavatar.FieldAccessKeySecret:
  2945. return m.OldAccessKeySecret(ctx)
  2946. case aliyunavatar.FieldAppID:
  2947. return m.OldAppID(ctx)
  2948. case aliyunavatar.FieldTenantID:
  2949. return m.OldTenantID(ctx)
  2950. case aliyunavatar.FieldResponse:
  2951. return m.OldResponse(ctx)
  2952. case aliyunavatar.FieldToken:
  2953. return m.OldToken(ctx)
  2954. case aliyunavatar.FieldSessionID:
  2955. return m.OldSessionID(ctx)
  2956. }
  2957. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2958. }
  2959. // SetField sets the value of a field with the given name. It returns an error if
  2960. // the field is not defined in the schema, or if the type mismatched the field
  2961. // type.
  2962. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2963. switch name {
  2964. case aliyunavatar.FieldCreatedAt:
  2965. v, ok := value.(time.Time)
  2966. if !ok {
  2967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2968. }
  2969. m.SetCreatedAt(v)
  2970. return nil
  2971. case aliyunavatar.FieldUpdatedAt:
  2972. v, ok := value.(time.Time)
  2973. if !ok {
  2974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2975. }
  2976. m.SetUpdatedAt(v)
  2977. return nil
  2978. case aliyunavatar.FieldDeletedAt:
  2979. v, ok := value.(time.Time)
  2980. if !ok {
  2981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2982. }
  2983. m.SetDeletedAt(v)
  2984. return nil
  2985. case aliyunavatar.FieldUserID:
  2986. v, ok := value.(uint64)
  2987. if !ok {
  2988. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2989. }
  2990. m.SetUserID(v)
  2991. return nil
  2992. case aliyunavatar.FieldBizID:
  2993. v, ok := value.(string)
  2994. if !ok {
  2995. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2996. }
  2997. m.SetBizID(v)
  2998. return nil
  2999. case aliyunavatar.FieldAccessKeyID:
  3000. v, ok := value.(string)
  3001. if !ok {
  3002. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3003. }
  3004. m.SetAccessKeyID(v)
  3005. return nil
  3006. case aliyunavatar.FieldAccessKeySecret:
  3007. v, ok := value.(string)
  3008. if !ok {
  3009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3010. }
  3011. m.SetAccessKeySecret(v)
  3012. return nil
  3013. case aliyunavatar.FieldAppID:
  3014. v, ok := value.(string)
  3015. if !ok {
  3016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3017. }
  3018. m.SetAppID(v)
  3019. return nil
  3020. case aliyunavatar.FieldTenantID:
  3021. v, ok := value.(uint64)
  3022. if !ok {
  3023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3024. }
  3025. m.SetTenantID(v)
  3026. return nil
  3027. case aliyunavatar.FieldResponse:
  3028. v, ok := value.(string)
  3029. if !ok {
  3030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3031. }
  3032. m.SetResponse(v)
  3033. return nil
  3034. case aliyunavatar.FieldToken:
  3035. v, ok := value.(string)
  3036. if !ok {
  3037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3038. }
  3039. m.SetToken(v)
  3040. return nil
  3041. case aliyunavatar.FieldSessionID:
  3042. v, ok := value.(string)
  3043. if !ok {
  3044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3045. }
  3046. m.SetSessionID(v)
  3047. return nil
  3048. }
  3049. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3050. }
  3051. // AddedFields returns all numeric fields that were incremented/decremented during
  3052. // this mutation.
  3053. func (m *AliyunAvatarMutation) AddedFields() []string {
  3054. var fields []string
  3055. if m.adduser_id != nil {
  3056. fields = append(fields, aliyunavatar.FieldUserID)
  3057. }
  3058. if m.addtenant_id != nil {
  3059. fields = append(fields, aliyunavatar.FieldTenantID)
  3060. }
  3061. return fields
  3062. }
  3063. // AddedField returns the numeric value that was incremented/decremented on a field
  3064. // with the given name. The second boolean return value indicates that this field
  3065. // was not set, or was not defined in the schema.
  3066. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  3067. switch name {
  3068. case aliyunavatar.FieldUserID:
  3069. return m.AddedUserID()
  3070. case aliyunavatar.FieldTenantID:
  3071. return m.AddedTenantID()
  3072. }
  3073. return nil, false
  3074. }
  3075. // AddField adds the value to the field with the given name. It returns an error if
  3076. // the field is not defined in the schema, or if the type mismatched the field
  3077. // type.
  3078. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3079. switch name {
  3080. case aliyunavatar.FieldUserID:
  3081. v, ok := value.(int64)
  3082. if !ok {
  3083. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3084. }
  3085. m.AddUserID(v)
  3086. return nil
  3087. case aliyunavatar.FieldTenantID:
  3088. v, ok := value.(int64)
  3089. if !ok {
  3090. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3091. }
  3092. m.AddTenantID(v)
  3093. return nil
  3094. }
  3095. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3096. }
  3097. // ClearedFields returns all nullable fields that were cleared during this
  3098. // mutation.
  3099. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3100. var fields []string
  3101. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3102. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3103. }
  3104. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3105. fields = append(fields, aliyunavatar.FieldAppID)
  3106. }
  3107. return fields
  3108. }
  3109. // FieldCleared returns a boolean indicating if a field with the given name was
  3110. // cleared in this mutation.
  3111. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3112. _, ok := m.clearedFields[name]
  3113. return ok
  3114. }
  3115. // ClearField clears the value of the field with the given name. It returns an
  3116. // error if the field is not defined in the schema.
  3117. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3118. switch name {
  3119. case aliyunavatar.FieldDeletedAt:
  3120. m.ClearDeletedAt()
  3121. return nil
  3122. case aliyunavatar.FieldAppID:
  3123. m.ClearAppID()
  3124. return nil
  3125. }
  3126. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3127. }
  3128. // ResetField resets all changes in the mutation for the field with the given name.
  3129. // It returns an error if the field is not defined in the schema.
  3130. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3131. switch name {
  3132. case aliyunavatar.FieldCreatedAt:
  3133. m.ResetCreatedAt()
  3134. return nil
  3135. case aliyunavatar.FieldUpdatedAt:
  3136. m.ResetUpdatedAt()
  3137. return nil
  3138. case aliyunavatar.FieldDeletedAt:
  3139. m.ResetDeletedAt()
  3140. return nil
  3141. case aliyunavatar.FieldUserID:
  3142. m.ResetUserID()
  3143. return nil
  3144. case aliyunavatar.FieldBizID:
  3145. m.ResetBizID()
  3146. return nil
  3147. case aliyunavatar.FieldAccessKeyID:
  3148. m.ResetAccessKeyID()
  3149. return nil
  3150. case aliyunavatar.FieldAccessKeySecret:
  3151. m.ResetAccessKeySecret()
  3152. return nil
  3153. case aliyunavatar.FieldAppID:
  3154. m.ResetAppID()
  3155. return nil
  3156. case aliyunavatar.FieldTenantID:
  3157. m.ResetTenantID()
  3158. return nil
  3159. case aliyunavatar.FieldResponse:
  3160. m.ResetResponse()
  3161. return nil
  3162. case aliyunavatar.FieldToken:
  3163. m.ResetToken()
  3164. return nil
  3165. case aliyunavatar.FieldSessionID:
  3166. m.ResetSessionID()
  3167. return nil
  3168. }
  3169. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3170. }
  3171. // AddedEdges returns all edge names that were set/added in this mutation.
  3172. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3173. edges := make([]string, 0, 0)
  3174. return edges
  3175. }
  3176. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3177. // name in this mutation.
  3178. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3179. return nil
  3180. }
  3181. // RemovedEdges returns all edge names that were removed in this mutation.
  3182. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3183. edges := make([]string, 0, 0)
  3184. return edges
  3185. }
  3186. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3187. // the given name in this mutation.
  3188. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3189. return nil
  3190. }
  3191. // ClearedEdges returns all edge names that were cleared in this mutation.
  3192. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3193. edges := make([]string, 0, 0)
  3194. return edges
  3195. }
  3196. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3197. // was cleared in this mutation.
  3198. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3199. return false
  3200. }
  3201. // ClearEdge clears the value of the edge with the given name. It returns an error
  3202. // if that edge is not defined in the schema.
  3203. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3204. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3205. }
  3206. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3207. // It returns an error if the edge is not defined in the schema.
  3208. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3209. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3210. }
  3211. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3212. type AllocAgentMutation struct {
  3213. config
  3214. op Op
  3215. typ string
  3216. id *uint64
  3217. created_at *time.Time
  3218. updated_at *time.Time
  3219. deleted_at *time.Time
  3220. user_id *string
  3221. organization_id *uint64
  3222. addorganization_id *int64
  3223. agents *[]uint64
  3224. appendagents []uint64
  3225. status *int
  3226. addstatus *int
  3227. clearedFields map[string]struct{}
  3228. done bool
  3229. oldValue func(context.Context) (*AllocAgent, error)
  3230. predicates []predicate.AllocAgent
  3231. }
  3232. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3233. // allocagentOption allows management of the mutation configuration using functional options.
  3234. type allocagentOption func(*AllocAgentMutation)
  3235. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3236. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3237. m := &AllocAgentMutation{
  3238. config: c,
  3239. op: op,
  3240. typ: TypeAllocAgent,
  3241. clearedFields: make(map[string]struct{}),
  3242. }
  3243. for _, opt := range opts {
  3244. opt(m)
  3245. }
  3246. return m
  3247. }
  3248. // withAllocAgentID sets the ID field of the mutation.
  3249. func withAllocAgentID(id uint64) allocagentOption {
  3250. return func(m *AllocAgentMutation) {
  3251. var (
  3252. err error
  3253. once sync.Once
  3254. value *AllocAgent
  3255. )
  3256. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3257. once.Do(func() {
  3258. if m.done {
  3259. err = errors.New("querying old values post mutation is not allowed")
  3260. } else {
  3261. value, err = m.Client().AllocAgent.Get(ctx, id)
  3262. }
  3263. })
  3264. return value, err
  3265. }
  3266. m.id = &id
  3267. }
  3268. }
  3269. // withAllocAgent sets the old AllocAgent of the mutation.
  3270. func withAllocAgent(node *AllocAgent) allocagentOption {
  3271. return func(m *AllocAgentMutation) {
  3272. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3273. return node, nil
  3274. }
  3275. m.id = &node.ID
  3276. }
  3277. }
  3278. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3279. // executed in a transaction (ent.Tx), a transactional client is returned.
  3280. func (m AllocAgentMutation) Client() *Client {
  3281. client := &Client{config: m.config}
  3282. client.init()
  3283. return client
  3284. }
  3285. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3286. // it returns an error otherwise.
  3287. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3288. if _, ok := m.driver.(*txDriver); !ok {
  3289. return nil, errors.New("ent: mutation is not running in a transaction")
  3290. }
  3291. tx := &Tx{config: m.config}
  3292. tx.init()
  3293. return tx, nil
  3294. }
  3295. // SetID sets the value of the id field. Note that this
  3296. // operation is only accepted on creation of AllocAgent entities.
  3297. func (m *AllocAgentMutation) SetID(id uint64) {
  3298. m.id = &id
  3299. }
  3300. // ID returns the ID value in the mutation. Note that the ID is only available
  3301. // if it was provided to the builder or after it was returned from the database.
  3302. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3303. if m.id == nil {
  3304. return
  3305. }
  3306. return *m.id, true
  3307. }
  3308. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3309. // That means, if the mutation is applied within a transaction with an isolation level such
  3310. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3311. // or updated by the mutation.
  3312. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3313. switch {
  3314. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3315. id, exists := m.ID()
  3316. if exists {
  3317. return []uint64{id}, nil
  3318. }
  3319. fallthrough
  3320. case m.op.Is(OpUpdate | OpDelete):
  3321. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3322. default:
  3323. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3324. }
  3325. }
  3326. // SetCreatedAt sets the "created_at" field.
  3327. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3328. m.created_at = &t
  3329. }
  3330. // CreatedAt returns the value of the "created_at" field in the mutation.
  3331. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3332. v := m.created_at
  3333. if v == nil {
  3334. return
  3335. }
  3336. return *v, true
  3337. }
  3338. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3339. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3340. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3341. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3342. if !m.op.Is(OpUpdateOne) {
  3343. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3344. }
  3345. if m.id == nil || m.oldValue == nil {
  3346. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3347. }
  3348. oldValue, err := m.oldValue(ctx)
  3349. if err != nil {
  3350. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3351. }
  3352. return oldValue.CreatedAt, nil
  3353. }
  3354. // ResetCreatedAt resets all changes to the "created_at" field.
  3355. func (m *AllocAgentMutation) ResetCreatedAt() {
  3356. m.created_at = nil
  3357. }
  3358. // SetUpdatedAt sets the "updated_at" field.
  3359. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3360. m.updated_at = &t
  3361. }
  3362. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3363. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3364. v := m.updated_at
  3365. if v == nil {
  3366. return
  3367. }
  3368. return *v, true
  3369. }
  3370. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3371. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3373. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3374. if !m.op.Is(OpUpdateOne) {
  3375. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3376. }
  3377. if m.id == nil || m.oldValue == nil {
  3378. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3379. }
  3380. oldValue, err := m.oldValue(ctx)
  3381. if err != nil {
  3382. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3383. }
  3384. return oldValue.UpdatedAt, nil
  3385. }
  3386. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3387. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3388. m.updated_at = nil
  3389. }
  3390. // SetDeletedAt sets the "deleted_at" field.
  3391. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3392. m.deleted_at = &t
  3393. }
  3394. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3395. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3396. v := m.deleted_at
  3397. if v == nil {
  3398. return
  3399. }
  3400. return *v, true
  3401. }
  3402. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3403. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3405. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3406. if !m.op.Is(OpUpdateOne) {
  3407. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3408. }
  3409. if m.id == nil || m.oldValue == nil {
  3410. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3411. }
  3412. oldValue, err := m.oldValue(ctx)
  3413. if err != nil {
  3414. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3415. }
  3416. return oldValue.DeletedAt, nil
  3417. }
  3418. // ClearDeletedAt clears the value of the "deleted_at" field.
  3419. func (m *AllocAgentMutation) ClearDeletedAt() {
  3420. m.deleted_at = nil
  3421. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3422. }
  3423. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3424. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3425. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3426. return ok
  3427. }
  3428. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3429. func (m *AllocAgentMutation) ResetDeletedAt() {
  3430. m.deleted_at = nil
  3431. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3432. }
  3433. // SetUserID sets the "user_id" field.
  3434. func (m *AllocAgentMutation) SetUserID(s string) {
  3435. m.user_id = &s
  3436. }
  3437. // UserID returns the value of the "user_id" field in the mutation.
  3438. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3439. v := m.user_id
  3440. if v == nil {
  3441. return
  3442. }
  3443. return *v, true
  3444. }
  3445. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3446. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3447. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3448. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3449. if !m.op.Is(OpUpdateOne) {
  3450. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3451. }
  3452. if m.id == nil || m.oldValue == nil {
  3453. return v, errors.New("OldUserID requires an ID field in the mutation")
  3454. }
  3455. oldValue, err := m.oldValue(ctx)
  3456. if err != nil {
  3457. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3458. }
  3459. return oldValue.UserID, nil
  3460. }
  3461. // ClearUserID clears the value of the "user_id" field.
  3462. func (m *AllocAgentMutation) ClearUserID() {
  3463. m.user_id = nil
  3464. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3465. }
  3466. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3467. func (m *AllocAgentMutation) UserIDCleared() bool {
  3468. _, ok := m.clearedFields[allocagent.FieldUserID]
  3469. return ok
  3470. }
  3471. // ResetUserID resets all changes to the "user_id" field.
  3472. func (m *AllocAgentMutation) ResetUserID() {
  3473. m.user_id = nil
  3474. delete(m.clearedFields, allocagent.FieldUserID)
  3475. }
  3476. // SetOrganizationID sets the "organization_id" field.
  3477. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3478. m.organization_id = &u
  3479. m.addorganization_id = nil
  3480. }
  3481. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3482. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3483. v := m.organization_id
  3484. if v == nil {
  3485. return
  3486. }
  3487. return *v, true
  3488. }
  3489. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3490. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3491. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3492. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3493. if !m.op.Is(OpUpdateOne) {
  3494. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3495. }
  3496. if m.id == nil || m.oldValue == nil {
  3497. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3498. }
  3499. oldValue, err := m.oldValue(ctx)
  3500. if err != nil {
  3501. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3502. }
  3503. return oldValue.OrganizationID, nil
  3504. }
  3505. // AddOrganizationID adds u to the "organization_id" field.
  3506. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3507. if m.addorganization_id != nil {
  3508. *m.addorganization_id += u
  3509. } else {
  3510. m.addorganization_id = &u
  3511. }
  3512. }
  3513. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3514. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3515. v := m.addorganization_id
  3516. if v == nil {
  3517. return
  3518. }
  3519. return *v, true
  3520. }
  3521. // ClearOrganizationID clears the value of the "organization_id" field.
  3522. func (m *AllocAgentMutation) ClearOrganizationID() {
  3523. m.organization_id = nil
  3524. m.addorganization_id = nil
  3525. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3526. }
  3527. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3528. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3529. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3530. return ok
  3531. }
  3532. // ResetOrganizationID resets all changes to the "organization_id" field.
  3533. func (m *AllocAgentMutation) ResetOrganizationID() {
  3534. m.organization_id = nil
  3535. m.addorganization_id = nil
  3536. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3537. }
  3538. // SetAgents sets the "agents" field.
  3539. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3540. m.agents = &u
  3541. m.appendagents = nil
  3542. }
  3543. // Agents returns the value of the "agents" field in the mutation.
  3544. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3545. v := m.agents
  3546. if v == nil {
  3547. return
  3548. }
  3549. return *v, true
  3550. }
  3551. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3552. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3554. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3555. if !m.op.Is(OpUpdateOne) {
  3556. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3557. }
  3558. if m.id == nil || m.oldValue == nil {
  3559. return v, errors.New("OldAgents requires an ID field in the mutation")
  3560. }
  3561. oldValue, err := m.oldValue(ctx)
  3562. if err != nil {
  3563. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3564. }
  3565. return oldValue.Agents, nil
  3566. }
  3567. // AppendAgents adds u to the "agents" field.
  3568. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3569. m.appendagents = append(m.appendagents, u...)
  3570. }
  3571. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3572. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3573. if len(m.appendagents) == 0 {
  3574. return nil, false
  3575. }
  3576. return m.appendagents, true
  3577. }
  3578. // ResetAgents resets all changes to the "agents" field.
  3579. func (m *AllocAgentMutation) ResetAgents() {
  3580. m.agents = nil
  3581. m.appendagents = nil
  3582. }
  3583. // SetStatus sets the "status" field.
  3584. func (m *AllocAgentMutation) SetStatus(i int) {
  3585. m.status = &i
  3586. m.addstatus = nil
  3587. }
  3588. // Status returns the value of the "status" field in the mutation.
  3589. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3590. v := m.status
  3591. if v == nil {
  3592. return
  3593. }
  3594. return *v, true
  3595. }
  3596. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3597. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3598. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3599. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3600. if !m.op.Is(OpUpdateOne) {
  3601. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3602. }
  3603. if m.id == nil || m.oldValue == nil {
  3604. return v, errors.New("OldStatus requires an ID field in the mutation")
  3605. }
  3606. oldValue, err := m.oldValue(ctx)
  3607. if err != nil {
  3608. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3609. }
  3610. return oldValue.Status, nil
  3611. }
  3612. // AddStatus adds i to the "status" field.
  3613. func (m *AllocAgentMutation) AddStatus(i int) {
  3614. if m.addstatus != nil {
  3615. *m.addstatus += i
  3616. } else {
  3617. m.addstatus = &i
  3618. }
  3619. }
  3620. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3621. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3622. v := m.addstatus
  3623. if v == nil {
  3624. return
  3625. }
  3626. return *v, true
  3627. }
  3628. // ClearStatus clears the value of the "status" field.
  3629. func (m *AllocAgentMutation) ClearStatus() {
  3630. m.status = nil
  3631. m.addstatus = nil
  3632. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3633. }
  3634. // StatusCleared returns if the "status" field was cleared in this mutation.
  3635. func (m *AllocAgentMutation) StatusCleared() bool {
  3636. _, ok := m.clearedFields[allocagent.FieldStatus]
  3637. return ok
  3638. }
  3639. // ResetStatus resets all changes to the "status" field.
  3640. func (m *AllocAgentMutation) ResetStatus() {
  3641. m.status = nil
  3642. m.addstatus = nil
  3643. delete(m.clearedFields, allocagent.FieldStatus)
  3644. }
  3645. // Where appends a list predicates to the AllocAgentMutation builder.
  3646. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3647. m.predicates = append(m.predicates, ps...)
  3648. }
  3649. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3650. // users can use type-assertion to append predicates that do not depend on any generated package.
  3651. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3652. p := make([]predicate.AllocAgent, len(ps))
  3653. for i := range ps {
  3654. p[i] = ps[i]
  3655. }
  3656. m.Where(p...)
  3657. }
  3658. // Op returns the operation name.
  3659. func (m *AllocAgentMutation) Op() Op {
  3660. return m.op
  3661. }
  3662. // SetOp allows setting the mutation operation.
  3663. func (m *AllocAgentMutation) SetOp(op Op) {
  3664. m.op = op
  3665. }
  3666. // Type returns the node type of this mutation (AllocAgent).
  3667. func (m *AllocAgentMutation) Type() string {
  3668. return m.typ
  3669. }
  3670. // Fields returns all fields that were changed during this mutation. Note that in
  3671. // order to get all numeric fields that were incremented/decremented, call
  3672. // AddedFields().
  3673. func (m *AllocAgentMutation) Fields() []string {
  3674. fields := make([]string, 0, 7)
  3675. if m.created_at != nil {
  3676. fields = append(fields, allocagent.FieldCreatedAt)
  3677. }
  3678. if m.updated_at != nil {
  3679. fields = append(fields, allocagent.FieldUpdatedAt)
  3680. }
  3681. if m.deleted_at != nil {
  3682. fields = append(fields, allocagent.FieldDeletedAt)
  3683. }
  3684. if m.user_id != nil {
  3685. fields = append(fields, allocagent.FieldUserID)
  3686. }
  3687. if m.organization_id != nil {
  3688. fields = append(fields, allocagent.FieldOrganizationID)
  3689. }
  3690. if m.agents != nil {
  3691. fields = append(fields, allocagent.FieldAgents)
  3692. }
  3693. if m.status != nil {
  3694. fields = append(fields, allocagent.FieldStatus)
  3695. }
  3696. return fields
  3697. }
  3698. // Field returns the value of a field with the given name. The second boolean
  3699. // return value indicates that this field was not set, or was not defined in the
  3700. // schema.
  3701. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3702. switch name {
  3703. case allocagent.FieldCreatedAt:
  3704. return m.CreatedAt()
  3705. case allocagent.FieldUpdatedAt:
  3706. return m.UpdatedAt()
  3707. case allocagent.FieldDeletedAt:
  3708. return m.DeletedAt()
  3709. case allocagent.FieldUserID:
  3710. return m.UserID()
  3711. case allocagent.FieldOrganizationID:
  3712. return m.OrganizationID()
  3713. case allocagent.FieldAgents:
  3714. return m.Agents()
  3715. case allocagent.FieldStatus:
  3716. return m.Status()
  3717. }
  3718. return nil, false
  3719. }
  3720. // OldField returns the old value of the field from the database. An error is
  3721. // returned if the mutation operation is not UpdateOne, or the query to the
  3722. // database failed.
  3723. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3724. switch name {
  3725. case allocagent.FieldCreatedAt:
  3726. return m.OldCreatedAt(ctx)
  3727. case allocagent.FieldUpdatedAt:
  3728. return m.OldUpdatedAt(ctx)
  3729. case allocagent.FieldDeletedAt:
  3730. return m.OldDeletedAt(ctx)
  3731. case allocagent.FieldUserID:
  3732. return m.OldUserID(ctx)
  3733. case allocagent.FieldOrganizationID:
  3734. return m.OldOrganizationID(ctx)
  3735. case allocagent.FieldAgents:
  3736. return m.OldAgents(ctx)
  3737. case allocagent.FieldStatus:
  3738. return m.OldStatus(ctx)
  3739. }
  3740. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3741. }
  3742. // SetField sets the value of a field with the given name. It returns an error if
  3743. // the field is not defined in the schema, or if the type mismatched the field
  3744. // type.
  3745. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3746. switch name {
  3747. case allocagent.FieldCreatedAt:
  3748. v, ok := value.(time.Time)
  3749. if !ok {
  3750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3751. }
  3752. m.SetCreatedAt(v)
  3753. return nil
  3754. case allocagent.FieldUpdatedAt:
  3755. v, ok := value.(time.Time)
  3756. if !ok {
  3757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3758. }
  3759. m.SetUpdatedAt(v)
  3760. return nil
  3761. case allocagent.FieldDeletedAt:
  3762. v, ok := value.(time.Time)
  3763. if !ok {
  3764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3765. }
  3766. m.SetDeletedAt(v)
  3767. return nil
  3768. case allocagent.FieldUserID:
  3769. v, ok := value.(string)
  3770. if !ok {
  3771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3772. }
  3773. m.SetUserID(v)
  3774. return nil
  3775. case allocagent.FieldOrganizationID:
  3776. v, ok := value.(uint64)
  3777. if !ok {
  3778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3779. }
  3780. m.SetOrganizationID(v)
  3781. return nil
  3782. case allocagent.FieldAgents:
  3783. v, ok := value.([]uint64)
  3784. if !ok {
  3785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3786. }
  3787. m.SetAgents(v)
  3788. return nil
  3789. case allocagent.FieldStatus:
  3790. v, ok := value.(int)
  3791. if !ok {
  3792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3793. }
  3794. m.SetStatus(v)
  3795. return nil
  3796. }
  3797. return fmt.Errorf("unknown AllocAgent field %s", name)
  3798. }
  3799. // AddedFields returns all numeric fields that were incremented/decremented during
  3800. // this mutation.
  3801. func (m *AllocAgentMutation) AddedFields() []string {
  3802. var fields []string
  3803. if m.addorganization_id != nil {
  3804. fields = append(fields, allocagent.FieldOrganizationID)
  3805. }
  3806. if m.addstatus != nil {
  3807. fields = append(fields, allocagent.FieldStatus)
  3808. }
  3809. return fields
  3810. }
  3811. // AddedField returns the numeric value that was incremented/decremented on a field
  3812. // with the given name. The second boolean return value indicates that this field
  3813. // was not set, or was not defined in the schema.
  3814. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3815. switch name {
  3816. case allocagent.FieldOrganizationID:
  3817. return m.AddedOrganizationID()
  3818. case allocagent.FieldStatus:
  3819. return m.AddedStatus()
  3820. }
  3821. return nil, false
  3822. }
  3823. // AddField adds the value to the field with the given name. It returns an error if
  3824. // the field is not defined in the schema, or if the type mismatched the field
  3825. // type.
  3826. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3827. switch name {
  3828. case allocagent.FieldOrganizationID:
  3829. v, ok := value.(int64)
  3830. if !ok {
  3831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3832. }
  3833. m.AddOrganizationID(v)
  3834. return nil
  3835. case allocagent.FieldStatus:
  3836. v, ok := value.(int)
  3837. if !ok {
  3838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3839. }
  3840. m.AddStatus(v)
  3841. return nil
  3842. }
  3843. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3844. }
  3845. // ClearedFields returns all nullable fields that were cleared during this
  3846. // mutation.
  3847. func (m *AllocAgentMutation) ClearedFields() []string {
  3848. var fields []string
  3849. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3850. fields = append(fields, allocagent.FieldDeletedAt)
  3851. }
  3852. if m.FieldCleared(allocagent.FieldUserID) {
  3853. fields = append(fields, allocagent.FieldUserID)
  3854. }
  3855. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3856. fields = append(fields, allocagent.FieldOrganizationID)
  3857. }
  3858. if m.FieldCleared(allocagent.FieldStatus) {
  3859. fields = append(fields, allocagent.FieldStatus)
  3860. }
  3861. return fields
  3862. }
  3863. // FieldCleared returns a boolean indicating if a field with the given name was
  3864. // cleared in this mutation.
  3865. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3866. _, ok := m.clearedFields[name]
  3867. return ok
  3868. }
  3869. // ClearField clears the value of the field with the given name. It returns an
  3870. // error if the field is not defined in the schema.
  3871. func (m *AllocAgentMutation) ClearField(name string) error {
  3872. switch name {
  3873. case allocagent.FieldDeletedAt:
  3874. m.ClearDeletedAt()
  3875. return nil
  3876. case allocagent.FieldUserID:
  3877. m.ClearUserID()
  3878. return nil
  3879. case allocagent.FieldOrganizationID:
  3880. m.ClearOrganizationID()
  3881. return nil
  3882. case allocagent.FieldStatus:
  3883. m.ClearStatus()
  3884. return nil
  3885. }
  3886. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3887. }
  3888. // ResetField resets all changes in the mutation for the field with the given name.
  3889. // It returns an error if the field is not defined in the schema.
  3890. func (m *AllocAgentMutation) ResetField(name string) error {
  3891. switch name {
  3892. case allocagent.FieldCreatedAt:
  3893. m.ResetCreatedAt()
  3894. return nil
  3895. case allocagent.FieldUpdatedAt:
  3896. m.ResetUpdatedAt()
  3897. return nil
  3898. case allocagent.FieldDeletedAt:
  3899. m.ResetDeletedAt()
  3900. return nil
  3901. case allocagent.FieldUserID:
  3902. m.ResetUserID()
  3903. return nil
  3904. case allocagent.FieldOrganizationID:
  3905. m.ResetOrganizationID()
  3906. return nil
  3907. case allocagent.FieldAgents:
  3908. m.ResetAgents()
  3909. return nil
  3910. case allocagent.FieldStatus:
  3911. m.ResetStatus()
  3912. return nil
  3913. }
  3914. return fmt.Errorf("unknown AllocAgent field %s", name)
  3915. }
  3916. // AddedEdges returns all edge names that were set/added in this mutation.
  3917. func (m *AllocAgentMutation) AddedEdges() []string {
  3918. edges := make([]string, 0, 0)
  3919. return edges
  3920. }
  3921. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3922. // name in this mutation.
  3923. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3924. return nil
  3925. }
  3926. // RemovedEdges returns all edge names that were removed in this mutation.
  3927. func (m *AllocAgentMutation) RemovedEdges() []string {
  3928. edges := make([]string, 0, 0)
  3929. return edges
  3930. }
  3931. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3932. // the given name in this mutation.
  3933. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3934. return nil
  3935. }
  3936. // ClearedEdges returns all edge names that were cleared in this mutation.
  3937. func (m *AllocAgentMutation) ClearedEdges() []string {
  3938. edges := make([]string, 0, 0)
  3939. return edges
  3940. }
  3941. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3942. // was cleared in this mutation.
  3943. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3944. return false
  3945. }
  3946. // ClearEdge clears the value of the edge with the given name. It returns an error
  3947. // if that edge is not defined in the schema.
  3948. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3949. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3950. }
  3951. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3952. // It returns an error if the edge is not defined in the schema.
  3953. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3954. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3955. }
  3956. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3957. type BatchMsgMutation struct {
  3958. config
  3959. op Op
  3960. typ string
  3961. id *uint64
  3962. created_at *time.Time
  3963. updated_at *time.Time
  3964. deleted_at *time.Time
  3965. status *uint8
  3966. addstatus *int8
  3967. batch_no *string
  3968. task_name *string
  3969. fromwxid *string
  3970. msg *string
  3971. tag *string
  3972. tagids *string
  3973. total *int32
  3974. addtotal *int32
  3975. success *int32
  3976. addsuccess *int32
  3977. fail *int32
  3978. addfail *int32
  3979. start_time *time.Time
  3980. stop_time *time.Time
  3981. send_time *time.Time
  3982. _type *int32
  3983. add_type *int32
  3984. organization_id *uint64
  3985. addorganization_id *int64
  3986. clearedFields map[string]struct{}
  3987. done bool
  3988. oldValue func(context.Context) (*BatchMsg, error)
  3989. predicates []predicate.BatchMsg
  3990. }
  3991. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3992. // batchmsgOption allows management of the mutation configuration using functional options.
  3993. type batchmsgOption func(*BatchMsgMutation)
  3994. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3995. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3996. m := &BatchMsgMutation{
  3997. config: c,
  3998. op: op,
  3999. typ: TypeBatchMsg,
  4000. clearedFields: make(map[string]struct{}),
  4001. }
  4002. for _, opt := range opts {
  4003. opt(m)
  4004. }
  4005. return m
  4006. }
  4007. // withBatchMsgID sets the ID field of the mutation.
  4008. func withBatchMsgID(id uint64) batchmsgOption {
  4009. return func(m *BatchMsgMutation) {
  4010. var (
  4011. err error
  4012. once sync.Once
  4013. value *BatchMsg
  4014. )
  4015. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  4016. once.Do(func() {
  4017. if m.done {
  4018. err = errors.New("querying old values post mutation is not allowed")
  4019. } else {
  4020. value, err = m.Client().BatchMsg.Get(ctx, id)
  4021. }
  4022. })
  4023. return value, err
  4024. }
  4025. m.id = &id
  4026. }
  4027. }
  4028. // withBatchMsg sets the old BatchMsg of the mutation.
  4029. func withBatchMsg(node *BatchMsg) batchmsgOption {
  4030. return func(m *BatchMsgMutation) {
  4031. m.oldValue = func(context.Context) (*BatchMsg, error) {
  4032. return node, nil
  4033. }
  4034. m.id = &node.ID
  4035. }
  4036. }
  4037. // Client returns a new `ent.Client` from the mutation. If the mutation was
  4038. // executed in a transaction (ent.Tx), a transactional client is returned.
  4039. func (m BatchMsgMutation) Client() *Client {
  4040. client := &Client{config: m.config}
  4041. client.init()
  4042. return client
  4043. }
  4044. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  4045. // it returns an error otherwise.
  4046. func (m BatchMsgMutation) Tx() (*Tx, error) {
  4047. if _, ok := m.driver.(*txDriver); !ok {
  4048. return nil, errors.New("ent: mutation is not running in a transaction")
  4049. }
  4050. tx := &Tx{config: m.config}
  4051. tx.init()
  4052. return tx, nil
  4053. }
  4054. // SetID sets the value of the id field. Note that this
  4055. // operation is only accepted on creation of BatchMsg entities.
  4056. func (m *BatchMsgMutation) SetID(id uint64) {
  4057. m.id = &id
  4058. }
  4059. // ID returns the ID value in the mutation. Note that the ID is only available
  4060. // if it was provided to the builder or after it was returned from the database.
  4061. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  4062. if m.id == nil {
  4063. return
  4064. }
  4065. return *m.id, true
  4066. }
  4067. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  4068. // That means, if the mutation is applied within a transaction with an isolation level such
  4069. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  4070. // or updated by the mutation.
  4071. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  4072. switch {
  4073. case m.op.Is(OpUpdateOne | OpDeleteOne):
  4074. id, exists := m.ID()
  4075. if exists {
  4076. return []uint64{id}, nil
  4077. }
  4078. fallthrough
  4079. case m.op.Is(OpUpdate | OpDelete):
  4080. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4081. default:
  4082. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4083. }
  4084. }
  4085. // SetCreatedAt sets the "created_at" field.
  4086. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4087. m.created_at = &t
  4088. }
  4089. // CreatedAt returns the value of the "created_at" field in the mutation.
  4090. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4091. v := m.created_at
  4092. if v == nil {
  4093. return
  4094. }
  4095. return *v, true
  4096. }
  4097. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4098. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4099. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4100. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4101. if !m.op.Is(OpUpdateOne) {
  4102. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4103. }
  4104. if m.id == nil || m.oldValue == nil {
  4105. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4106. }
  4107. oldValue, err := m.oldValue(ctx)
  4108. if err != nil {
  4109. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4110. }
  4111. return oldValue.CreatedAt, nil
  4112. }
  4113. // ResetCreatedAt resets all changes to the "created_at" field.
  4114. func (m *BatchMsgMutation) ResetCreatedAt() {
  4115. m.created_at = nil
  4116. }
  4117. // SetUpdatedAt sets the "updated_at" field.
  4118. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4119. m.updated_at = &t
  4120. }
  4121. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4122. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4123. v := m.updated_at
  4124. if v == nil {
  4125. return
  4126. }
  4127. return *v, true
  4128. }
  4129. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4130. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4132. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4133. if !m.op.Is(OpUpdateOne) {
  4134. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4135. }
  4136. if m.id == nil || m.oldValue == nil {
  4137. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4138. }
  4139. oldValue, err := m.oldValue(ctx)
  4140. if err != nil {
  4141. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4142. }
  4143. return oldValue.UpdatedAt, nil
  4144. }
  4145. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4146. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4147. m.updated_at = nil
  4148. }
  4149. // SetDeletedAt sets the "deleted_at" field.
  4150. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4151. m.deleted_at = &t
  4152. }
  4153. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4154. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4155. v := m.deleted_at
  4156. if v == nil {
  4157. return
  4158. }
  4159. return *v, true
  4160. }
  4161. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4162. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4164. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4165. if !m.op.Is(OpUpdateOne) {
  4166. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4167. }
  4168. if m.id == nil || m.oldValue == nil {
  4169. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4170. }
  4171. oldValue, err := m.oldValue(ctx)
  4172. if err != nil {
  4173. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4174. }
  4175. return oldValue.DeletedAt, nil
  4176. }
  4177. // ClearDeletedAt clears the value of the "deleted_at" field.
  4178. func (m *BatchMsgMutation) ClearDeletedAt() {
  4179. m.deleted_at = nil
  4180. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4181. }
  4182. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4183. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4184. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4185. return ok
  4186. }
  4187. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4188. func (m *BatchMsgMutation) ResetDeletedAt() {
  4189. m.deleted_at = nil
  4190. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4191. }
  4192. // SetStatus sets the "status" field.
  4193. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4194. m.status = &u
  4195. m.addstatus = nil
  4196. }
  4197. // Status returns the value of the "status" field in the mutation.
  4198. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4199. v := m.status
  4200. if v == nil {
  4201. return
  4202. }
  4203. return *v, true
  4204. }
  4205. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4206. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4207. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4208. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4209. if !m.op.Is(OpUpdateOne) {
  4210. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4211. }
  4212. if m.id == nil || m.oldValue == nil {
  4213. return v, errors.New("OldStatus requires an ID field in the mutation")
  4214. }
  4215. oldValue, err := m.oldValue(ctx)
  4216. if err != nil {
  4217. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4218. }
  4219. return oldValue.Status, nil
  4220. }
  4221. // AddStatus adds u to the "status" field.
  4222. func (m *BatchMsgMutation) AddStatus(u int8) {
  4223. if m.addstatus != nil {
  4224. *m.addstatus += u
  4225. } else {
  4226. m.addstatus = &u
  4227. }
  4228. }
  4229. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4230. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4231. v := m.addstatus
  4232. if v == nil {
  4233. return
  4234. }
  4235. return *v, true
  4236. }
  4237. // ClearStatus clears the value of the "status" field.
  4238. func (m *BatchMsgMutation) ClearStatus() {
  4239. m.status = nil
  4240. m.addstatus = nil
  4241. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4242. }
  4243. // StatusCleared returns if the "status" field was cleared in this mutation.
  4244. func (m *BatchMsgMutation) StatusCleared() bool {
  4245. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4246. return ok
  4247. }
  4248. // ResetStatus resets all changes to the "status" field.
  4249. func (m *BatchMsgMutation) ResetStatus() {
  4250. m.status = nil
  4251. m.addstatus = nil
  4252. delete(m.clearedFields, batchmsg.FieldStatus)
  4253. }
  4254. // SetBatchNo sets the "batch_no" field.
  4255. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4256. m.batch_no = &s
  4257. }
  4258. // BatchNo returns the value of the "batch_no" field in the mutation.
  4259. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4260. v := m.batch_no
  4261. if v == nil {
  4262. return
  4263. }
  4264. return *v, true
  4265. }
  4266. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4267. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4268. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4269. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4270. if !m.op.Is(OpUpdateOne) {
  4271. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4272. }
  4273. if m.id == nil || m.oldValue == nil {
  4274. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4275. }
  4276. oldValue, err := m.oldValue(ctx)
  4277. if err != nil {
  4278. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4279. }
  4280. return oldValue.BatchNo, nil
  4281. }
  4282. // ClearBatchNo clears the value of the "batch_no" field.
  4283. func (m *BatchMsgMutation) ClearBatchNo() {
  4284. m.batch_no = nil
  4285. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4286. }
  4287. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4288. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4289. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4290. return ok
  4291. }
  4292. // ResetBatchNo resets all changes to the "batch_no" field.
  4293. func (m *BatchMsgMutation) ResetBatchNo() {
  4294. m.batch_no = nil
  4295. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4296. }
  4297. // SetTaskName sets the "task_name" field.
  4298. func (m *BatchMsgMutation) SetTaskName(s string) {
  4299. m.task_name = &s
  4300. }
  4301. // TaskName returns the value of the "task_name" field in the mutation.
  4302. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4303. v := m.task_name
  4304. if v == nil {
  4305. return
  4306. }
  4307. return *v, true
  4308. }
  4309. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4310. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4311. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4312. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4313. if !m.op.Is(OpUpdateOne) {
  4314. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4315. }
  4316. if m.id == nil || m.oldValue == nil {
  4317. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4318. }
  4319. oldValue, err := m.oldValue(ctx)
  4320. if err != nil {
  4321. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4322. }
  4323. return oldValue.TaskName, nil
  4324. }
  4325. // ClearTaskName clears the value of the "task_name" field.
  4326. func (m *BatchMsgMutation) ClearTaskName() {
  4327. m.task_name = nil
  4328. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4329. }
  4330. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4331. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4332. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4333. return ok
  4334. }
  4335. // ResetTaskName resets all changes to the "task_name" field.
  4336. func (m *BatchMsgMutation) ResetTaskName() {
  4337. m.task_name = nil
  4338. delete(m.clearedFields, batchmsg.FieldTaskName)
  4339. }
  4340. // SetFromwxid sets the "fromwxid" field.
  4341. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4342. m.fromwxid = &s
  4343. }
  4344. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4345. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4346. v := m.fromwxid
  4347. if v == nil {
  4348. return
  4349. }
  4350. return *v, true
  4351. }
  4352. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4353. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4354. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4355. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4356. if !m.op.Is(OpUpdateOne) {
  4357. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4358. }
  4359. if m.id == nil || m.oldValue == nil {
  4360. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4361. }
  4362. oldValue, err := m.oldValue(ctx)
  4363. if err != nil {
  4364. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4365. }
  4366. return oldValue.Fromwxid, nil
  4367. }
  4368. // ClearFromwxid clears the value of the "fromwxid" field.
  4369. func (m *BatchMsgMutation) ClearFromwxid() {
  4370. m.fromwxid = nil
  4371. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4372. }
  4373. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4374. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4375. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4376. return ok
  4377. }
  4378. // ResetFromwxid resets all changes to the "fromwxid" field.
  4379. func (m *BatchMsgMutation) ResetFromwxid() {
  4380. m.fromwxid = nil
  4381. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4382. }
  4383. // SetMsg sets the "msg" field.
  4384. func (m *BatchMsgMutation) SetMsg(s string) {
  4385. m.msg = &s
  4386. }
  4387. // Msg returns the value of the "msg" field in the mutation.
  4388. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4389. v := m.msg
  4390. if v == nil {
  4391. return
  4392. }
  4393. return *v, true
  4394. }
  4395. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4396. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4398. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4399. if !m.op.Is(OpUpdateOne) {
  4400. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4401. }
  4402. if m.id == nil || m.oldValue == nil {
  4403. return v, errors.New("OldMsg requires an ID field in the mutation")
  4404. }
  4405. oldValue, err := m.oldValue(ctx)
  4406. if err != nil {
  4407. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4408. }
  4409. return oldValue.Msg, nil
  4410. }
  4411. // ClearMsg clears the value of the "msg" field.
  4412. func (m *BatchMsgMutation) ClearMsg() {
  4413. m.msg = nil
  4414. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4415. }
  4416. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4417. func (m *BatchMsgMutation) MsgCleared() bool {
  4418. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4419. return ok
  4420. }
  4421. // ResetMsg resets all changes to the "msg" field.
  4422. func (m *BatchMsgMutation) ResetMsg() {
  4423. m.msg = nil
  4424. delete(m.clearedFields, batchmsg.FieldMsg)
  4425. }
  4426. // SetTag sets the "tag" field.
  4427. func (m *BatchMsgMutation) SetTag(s string) {
  4428. m.tag = &s
  4429. }
  4430. // Tag returns the value of the "tag" field in the mutation.
  4431. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4432. v := m.tag
  4433. if v == nil {
  4434. return
  4435. }
  4436. return *v, true
  4437. }
  4438. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4439. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4440. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4441. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4442. if !m.op.Is(OpUpdateOne) {
  4443. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4444. }
  4445. if m.id == nil || m.oldValue == nil {
  4446. return v, errors.New("OldTag requires an ID field in the mutation")
  4447. }
  4448. oldValue, err := m.oldValue(ctx)
  4449. if err != nil {
  4450. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4451. }
  4452. return oldValue.Tag, nil
  4453. }
  4454. // ClearTag clears the value of the "tag" field.
  4455. func (m *BatchMsgMutation) ClearTag() {
  4456. m.tag = nil
  4457. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4458. }
  4459. // TagCleared returns if the "tag" field was cleared in this mutation.
  4460. func (m *BatchMsgMutation) TagCleared() bool {
  4461. _, ok := m.clearedFields[batchmsg.FieldTag]
  4462. return ok
  4463. }
  4464. // ResetTag resets all changes to the "tag" field.
  4465. func (m *BatchMsgMutation) ResetTag() {
  4466. m.tag = nil
  4467. delete(m.clearedFields, batchmsg.FieldTag)
  4468. }
  4469. // SetTagids sets the "tagids" field.
  4470. func (m *BatchMsgMutation) SetTagids(s string) {
  4471. m.tagids = &s
  4472. }
  4473. // Tagids returns the value of the "tagids" field in the mutation.
  4474. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4475. v := m.tagids
  4476. if v == nil {
  4477. return
  4478. }
  4479. return *v, true
  4480. }
  4481. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4482. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4483. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4484. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4485. if !m.op.Is(OpUpdateOne) {
  4486. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4487. }
  4488. if m.id == nil || m.oldValue == nil {
  4489. return v, errors.New("OldTagids requires an ID field in the mutation")
  4490. }
  4491. oldValue, err := m.oldValue(ctx)
  4492. if err != nil {
  4493. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4494. }
  4495. return oldValue.Tagids, nil
  4496. }
  4497. // ClearTagids clears the value of the "tagids" field.
  4498. func (m *BatchMsgMutation) ClearTagids() {
  4499. m.tagids = nil
  4500. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4501. }
  4502. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4503. func (m *BatchMsgMutation) TagidsCleared() bool {
  4504. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4505. return ok
  4506. }
  4507. // ResetTagids resets all changes to the "tagids" field.
  4508. func (m *BatchMsgMutation) ResetTagids() {
  4509. m.tagids = nil
  4510. delete(m.clearedFields, batchmsg.FieldTagids)
  4511. }
  4512. // SetTotal sets the "total" field.
  4513. func (m *BatchMsgMutation) SetTotal(i int32) {
  4514. m.total = &i
  4515. m.addtotal = nil
  4516. }
  4517. // Total returns the value of the "total" field in the mutation.
  4518. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4519. v := m.total
  4520. if v == nil {
  4521. return
  4522. }
  4523. return *v, true
  4524. }
  4525. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4526. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4528. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4529. if !m.op.Is(OpUpdateOne) {
  4530. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4531. }
  4532. if m.id == nil || m.oldValue == nil {
  4533. return v, errors.New("OldTotal requires an ID field in the mutation")
  4534. }
  4535. oldValue, err := m.oldValue(ctx)
  4536. if err != nil {
  4537. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4538. }
  4539. return oldValue.Total, nil
  4540. }
  4541. // AddTotal adds i to the "total" field.
  4542. func (m *BatchMsgMutation) AddTotal(i int32) {
  4543. if m.addtotal != nil {
  4544. *m.addtotal += i
  4545. } else {
  4546. m.addtotal = &i
  4547. }
  4548. }
  4549. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4550. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4551. v := m.addtotal
  4552. if v == nil {
  4553. return
  4554. }
  4555. return *v, true
  4556. }
  4557. // ClearTotal clears the value of the "total" field.
  4558. func (m *BatchMsgMutation) ClearTotal() {
  4559. m.total = nil
  4560. m.addtotal = nil
  4561. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4562. }
  4563. // TotalCleared returns if the "total" field was cleared in this mutation.
  4564. func (m *BatchMsgMutation) TotalCleared() bool {
  4565. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4566. return ok
  4567. }
  4568. // ResetTotal resets all changes to the "total" field.
  4569. func (m *BatchMsgMutation) ResetTotal() {
  4570. m.total = nil
  4571. m.addtotal = nil
  4572. delete(m.clearedFields, batchmsg.FieldTotal)
  4573. }
  4574. // SetSuccess sets the "success" field.
  4575. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4576. m.success = &i
  4577. m.addsuccess = nil
  4578. }
  4579. // Success returns the value of the "success" field in the mutation.
  4580. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4581. v := m.success
  4582. if v == nil {
  4583. return
  4584. }
  4585. return *v, true
  4586. }
  4587. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4588. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4590. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4591. if !m.op.Is(OpUpdateOne) {
  4592. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4593. }
  4594. if m.id == nil || m.oldValue == nil {
  4595. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4596. }
  4597. oldValue, err := m.oldValue(ctx)
  4598. if err != nil {
  4599. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4600. }
  4601. return oldValue.Success, nil
  4602. }
  4603. // AddSuccess adds i to the "success" field.
  4604. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4605. if m.addsuccess != nil {
  4606. *m.addsuccess += i
  4607. } else {
  4608. m.addsuccess = &i
  4609. }
  4610. }
  4611. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4612. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4613. v := m.addsuccess
  4614. if v == nil {
  4615. return
  4616. }
  4617. return *v, true
  4618. }
  4619. // ClearSuccess clears the value of the "success" field.
  4620. func (m *BatchMsgMutation) ClearSuccess() {
  4621. m.success = nil
  4622. m.addsuccess = nil
  4623. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4624. }
  4625. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4626. func (m *BatchMsgMutation) SuccessCleared() bool {
  4627. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4628. return ok
  4629. }
  4630. // ResetSuccess resets all changes to the "success" field.
  4631. func (m *BatchMsgMutation) ResetSuccess() {
  4632. m.success = nil
  4633. m.addsuccess = nil
  4634. delete(m.clearedFields, batchmsg.FieldSuccess)
  4635. }
  4636. // SetFail sets the "fail" field.
  4637. func (m *BatchMsgMutation) SetFail(i int32) {
  4638. m.fail = &i
  4639. m.addfail = nil
  4640. }
  4641. // Fail returns the value of the "fail" field in the mutation.
  4642. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4643. v := m.fail
  4644. if v == nil {
  4645. return
  4646. }
  4647. return *v, true
  4648. }
  4649. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4650. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4652. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4653. if !m.op.Is(OpUpdateOne) {
  4654. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4655. }
  4656. if m.id == nil || m.oldValue == nil {
  4657. return v, errors.New("OldFail requires an ID field in the mutation")
  4658. }
  4659. oldValue, err := m.oldValue(ctx)
  4660. if err != nil {
  4661. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4662. }
  4663. return oldValue.Fail, nil
  4664. }
  4665. // AddFail adds i to the "fail" field.
  4666. func (m *BatchMsgMutation) AddFail(i int32) {
  4667. if m.addfail != nil {
  4668. *m.addfail += i
  4669. } else {
  4670. m.addfail = &i
  4671. }
  4672. }
  4673. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4674. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4675. v := m.addfail
  4676. if v == nil {
  4677. return
  4678. }
  4679. return *v, true
  4680. }
  4681. // ClearFail clears the value of the "fail" field.
  4682. func (m *BatchMsgMutation) ClearFail() {
  4683. m.fail = nil
  4684. m.addfail = nil
  4685. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4686. }
  4687. // FailCleared returns if the "fail" field was cleared in this mutation.
  4688. func (m *BatchMsgMutation) FailCleared() bool {
  4689. _, ok := m.clearedFields[batchmsg.FieldFail]
  4690. return ok
  4691. }
  4692. // ResetFail resets all changes to the "fail" field.
  4693. func (m *BatchMsgMutation) ResetFail() {
  4694. m.fail = nil
  4695. m.addfail = nil
  4696. delete(m.clearedFields, batchmsg.FieldFail)
  4697. }
  4698. // SetStartTime sets the "start_time" field.
  4699. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4700. m.start_time = &t
  4701. }
  4702. // StartTime returns the value of the "start_time" field in the mutation.
  4703. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4704. v := m.start_time
  4705. if v == nil {
  4706. return
  4707. }
  4708. return *v, true
  4709. }
  4710. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4711. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4712. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4713. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4714. if !m.op.Is(OpUpdateOne) {
  4715. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4716. }
  4717. if m.id == nil || m.oldValue == nil {
  4718. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4719. }
  4720. oldValue, err := m.oldValue(ctx)
  4721. if err != nil {
  4722. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4723. }
  4724. return oldValue.StartTime, nil
  4725. }
  4726. // ClearStartTime clears the value of the "start_time" field.
  4727. func (m *BatchMsgMutation) ClearStartTime() {
  4728. m.start_time = nil
  4729. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4730. }
  4731. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4732. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4733. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4734. return ok
  4735. }
  4736. // ResetStartTime resets all changes to the "start_time" field.
  4737. func (m *BatchMsgMutation) ResetStartTime() {
  4738. m.start_time = nil
  4739. delete(m.clearedFields, batchmsg.FieldStartTime)
  4740. }
  4741. // SetStopTime sets the "stop_time" field.
  4742. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4743. m.stop_time = &t
  4744. }
  4745. // StopTime returns the value of the "stop_time" field in the mutation.
  4746. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4747. v := m.stop_time
  4748. if v == nil {
  4749. return
  4750. }
  4751. return *v, true
  4752. }
  4753. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4754. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4755. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4756. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4757. if !m.op.Is(OpUpdateOne) {
  4758. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4759. }
  4760. if m.id == nil || m.oldValue == nil {
  4761. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4762. }
  4763. oldValue, err := m.oldValue(ctx)
  4764. if err != nil {
  4765. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4766. }
  4767. return oldValue.StopTime, nil
  4768. }
  4769. // ClearStopTime clears the value of the "stop_time" field.
  4770. func (m *BatchMsgMutation) ClearStopTime() {
  4771. m.stop_time = nil
  4772. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4773. }
  4774. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4775. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4776. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4777. return ok
  4778. }
  4779. // ResetStopTime resets all changes to the "stop_time" field.
  4780. func (m *BatchMsgMutation) ResetStopTime() {
  4781. m.stop_time = nil
  4782. delete(m.clearedFields, batchmsg.FieldStopTime)
  4783. }
  4784. // SetSendTime sets the "send_time" field.
  4785. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4786. m.send_time = &t
  4787. }
  4788. // SendTime returns the value of the "send_time" field in the mutation.
  4789. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4790. v := m.send_time
  4791. if v == nil {
  4792. return
  4793. }
  4794. return *v, true
  4795. }
  4796. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4797. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4799. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4800. if !m.op.Is(OpUpdateOne) {
  4801. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4802. }
  4803. if m.id == nil || m.oldValue == nil {
  4804. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4805. }
  4806. oldValue, err := m.oldValue(ctx)
  4807. if err != nil {
  4808. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4809. }
  4810. return oldValue.SendTime, nil
  4811. }
  4812. // ClearSendTime clears the value of the "send_time" field.
  4813. func (m *BatchMsgMutation) ClearSendTime() {
  4814. m.send_time = nil
  4815. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4816. }
  4817. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4818. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4819. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4820. return ok
  4821. }
  4822. // ResetSendTime resets all changes to the "send_time" field.
  4823. func (m *BatchMsgMutation) ResetSendTime() {
  4824. m.send_time = nil
  4825. delete(m.clearedFields, batchmsg.FieldSendTime)
  4826. }
  4827. // SetType sets the "type" field.
  4828. func (m *BatchMsgMutation) SetType(i int32) {
  4829. m._type = &i
  4830. m.add_type = nil
  4831. }
  4832. // GetType returns the value of the "type" field in the mutation.
  4833. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4834. v := m._type
  4835. if v == nil {
  4836. return
  4837. }
  4838. return *v, true
  4839. }
  4840. // OldType returns the old "type" field's value of the BatchMsg entity.
  4841. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4843. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4844. if !m.op.Is(OpUpdateOne) {
  4845. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4846. }
  4847. if m.id == nil || m.oldValue == nil {
  4848. return v, errors.New("OldType requires an ID field in the mutation")
  4849. }
  4850. oldValue, err := m.oldValue(ctx)
  4851. if err != nil {
  4852. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4853. }
  4854. return oldValue.Type, nil
  4855. }
  4856. // AddType adds i to the "type" field.
  4857. func (m *BatchMsgMutation) AddType(i int32) {
  4858. if m.add_type != nil {
  4859. *m.add_type += i
  4860. } else {
  4861. m.add_type = &i
  4862. }
  4863. }
  4864. // AddedType returns the value that was added to the "type" field in this mutation.
  4865. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4866. v := m.add_type
  4867. if v == nil {
  4868. return
  4869. }
  4870. return *v, true
  4871. }
  4872. // ClearType clears the value of the "type" field.
  4873. func (m *BatchMsgMutation) ClearType() {
  4874. m._type = nil
  4875. m.add_type = nil
  4876. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4877. }
  4878. // TypeCleared returns if the "type" field was cleared in this mutation.
  4879. func (m *BatchMsgMutation) TypeCleared() bool {
  4880. _, ok := m.clearedFields[batchmsg.FieldType]
  4881. return ok
  4882. }
  4883. // ResetType resets all changes to the "type" field.
  4884. func (m *BatchMsgMutation) ResetType() {
  4885. m._type = nil
  4886. m.add_type = nil
  4887. delete(m.clearedFields, batchmsg.FieldType)
  4888. }
  4889. // SetOrganizationID sets the "organization_id" field.
  4890. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4891. m.organization_id = &u
  4892. m.addorganization_id = nil
  4893. }
  4894. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4895. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4896. v := m.organization_id
  4897. if v == nil {
  4898. return
  4899. }
  4900. return *v, true
  4901. }
  4902. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4903. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4905. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4906. if !m.op.Is(OpUpdateOne) {
  4907. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4908. }
  4909. if m.id == nil || m.oldValue == nil {
  4910. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4911. }
  4912. oldValue, err := m.oldValue(ctx)
  4913. if err != nil {
  4914. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4915. }
  4916. return oldValue.OrganizationID, nil
  4917. }
  4918. // AddOrganizationID adds u to the "organization_id" field.
  4919. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4920. if m.addorganization_id != nil {
  4921. *m.addorganization_id += u
  4922. } else {
  4923. m.addorganization_id = &u
  4924. }
  4925. }
  4926. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4927. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4928. v := m.addorganization_id
  4929. if v == nil {
  4930. return
  4931. }
  4932. return *v, true
  4933. }
  4934. // ResetOrganizationID resets all changes to the "organization_id" field.
  4935. func (m *BatchMsgMutation) ResetOrganizationID() {
  4936. m.organization_id = nil
  4937. m.addorganization_id = nil
  4938. }
  4939. // Where appends a list predicates to the BatchMsgMutation builder.
  4940. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4941. m.predicates = append(m.predicates, ps...)
  4942. }
  4943. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4944. // users can use type-assertion to append predicates that do not depend on any generated package.
  4945. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4946. p := make([]predicate.BatchMsg, len(ps))
  4947. for i := range ps {
  4948. p[i] = ps[i]
  4949. }
  4950. m.Where(p...)
  4951. }
  4952. // Op returns the operation name.
  4953. func (m *BatchMsgMutation) Op() Op {
  4954. return m.op
  4955. }
  4956. // SetOp allows setting the mutation operation.
  4957. func (m *BatchMsgMutation) SetOp(op Op) {
  4958. m.op = op
  4959. }
  4960. // Type returns the node type of this mutation (BatchMsg).
  4961. func (m *BatchMsgMutation) Type() string {
  4962. return m.typ
  4963. }
  4964. // Fields returns all fields that were changed during this mutation. Note that in
  4965. // order to get all numeric fields that were incremented/decremented, call
  4966. // AddedFields().
  4967. func (m *BatchMsgMutation) Fields() []string {
  4968. fields := make([]string, 0, 18)
  4969. if m.created_at != nil {
  4970. fields = append(fields, batchmsg.FieldCreatedAt)
  4971. }
  4972. if m.updated_at != nil {
  4973. fields = append(fields, batchmsg.FieldUpdatedAt)
  4974. }
  4975. if m.deleted_at != nil {
  4976. fields = append(fields, batchmsg.FieldDeletedAt)
  4977. }
  4978. if m.status != nil {
  4979. fields = append(fields, batchmsg.FieldStatus)
  4980. }
  4981. if m.batch_no != nil {
  4982. fields = append(fields, batchmsg.FieldBatchNo)
  4983. }
  4984. if m.task_name != nil {
  4985. fields = append(fields, batchmsg.FieldTaskName)
  4986. }
  4987. if m.fromwxid != nil {
  4988. fields = append(fields, batchmsg.FieldFromwxid)
  4989. }
  4990. if m.msg != nil {
  4991. fields = append(fields, batchmsg.FieldMsg)
  4992. }
  4993. if m.tag != nil {
  4994. fields = append(fields, batchmsg.FieldTag)
  4995. }
  4996. if m.tagids != nil {
  4997. fields = append(fields, batchmsg.FieldTagids)
  4998. }
  4999. if m.total != nil {
  5000. fields = append(fields, batchmsg.FieldTotal)
  5001. }
  5002. if m.success != nil {
  5003. fields = append(fields, batchmsg.FieldSuccess)
  5004. }
  5005. if m.fail != nil {
  5006. fields = append(fields, batchmsg.FieldFail)
  5007. }
  5008. if m.start_time != nil {
  5009. fields = append(fields, batchmsg.FieldStartTime)
  5010. }
  5011. if m.stop_time != nil {
  5012. fields = append(fields, batchmsg.FieldStopTime)
  5013. }
  5014. if m.send_time != nil {
  5015. fields = append(fields, batchmsg.FieldSendTime)
  5016. }
  5017. if m._type != nil {
  5018. fields = append(fields, batchmsg.FieldType)
  5019. }
  5020. if m.organization_id != nil {
  5021. fields = append(fields, batchmsg.FieldOrganizationID)
  5022. }
  5023. return fields
  5024. }
  5025. // Field returns the value of a field with the given name. The second boolean
  5026. // return value indicates that this field was not set, or was not defined in the
  5027. // schema.
  5028. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  5029. switch name {
  5030. case batchmsg.FieldCreatedAt:
  5031. return m.CreatedAt()
  5032. case batchmsg.FieldUpdatedAt:
  5033. return m.UpdatedAt()
  5034. case batchmsg.FieldDeletedAt:
  5035. return m.DeletedAt()
  5036. case batchmsg.FieldStatus:
  5037. return m.Status()
  5038. case batchmsg.FieldBatchNo:
  5039. return m.BatchNo()
  5040. case batchmsg.FieldTaskName:
  5041. return m.TaskName()
  5042. case batchmsg.FieldFromwxid:
  5043. return m.Fromwxid()
  5044. case batchmsg.FieldMsg:
  5045. return m.Msg()
  5046. case batchmsg.FieldTag:
  5047. return m.Tag()
  5048. case batchmsg.FieldTagids:
  5049. return m.Tagids()
  5050. case batchmsg.FieldTotal:
  5051. return m.Total()
  5052. case batchmsg.FieldSuccess:
  5053. return m.Success()
  5054. case batchmsg.FieldFail:
  5055. return m.Fail()
  5056. case batchmsg.FieldStartTime:
  5057. return m.StartTime()
  5058. case batchmsg.FieldStopTime:
  5059. return m.StopTime()
  5060. case batchmsg.FieldSendTime:
  5061. return m.SendTime()
  5062. case batchmsg.FieldType:
  5063. return m.GetType()
  5064. case batchmsg.FieldOrganizationID:
  5065. return m.OrganizationID()
  5066. }
  5067. return nil, false
  5068. }
  5069. // OldField returns the old value of the field from the database. An error is
  5070. // returned if the mutation operation is not UpdateOne, or the query to the
  5071. // database failed.
  5072. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5073. switch name {
  5074. case batchmsg.FieldCreatedAt:
  5075. return m.OldCreatedAt(ctx)
  5076. case batchmsg.FieldUpdatedAt:
  5077. return m.OldUpdatedAt(ctx)
  5078. case batchmsg.FieldDeletedAt:
  5079. return m.OldDeletedAt(ctx)
  5080. case batchmsg.FieldStatus:
  5081. return m.OldStatus(ctx)
  5082. case batchmsg.FieldBatchNo:
  5083. return m.OldBatchNo(ctx)
  5084. case batchmsg.FieldTaskName:
  5085. return m.OldTaskName(ctx)
  5086. case batchmsg.FieldFromwxid:
  5087. return m.OldFromwxid(ctx)
  5088. case batchmsg.FieldMsg:
  5089. return m.OldMsg(ctx)
  5090. case batchmsg.FieldTag:
  5091. return m.OldTag(ctx)
  5092. case batchmsg.FieldTagids:
  5093. return m.OldTagids(ctx)
  5094. case batchmsg.FieldTotal:
  5095. return m.OldTotal(ctx)
  5096. case batchmsg.FieldSuccess:
  5097. return m.OldSuccess(ctx)
  5098. case batchmsg.FieldFail:
  5099. return m.OldFail(ctx)
  5100. case batchmsg.FieldStartTime:
  5101. return m.OldStartTime(ctx)
  5102. case batchmsg.FieldStopTime:
  5103. return m.OldStopTime(ctx)
  5104. case batchmsg.FieldSendTime:
  5105. return m.OldSendTime(ctx)
  5106. case batchmsg.FieldType:
  5107. return m.OldType(ctx)
  5108. case batchmsg.FieldOrganizationID:
  5109. return m.OldOrganizationID(ctx)
  5110. }
  5111. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5112. }
  5113. // SetField sets the value of a field with the given name. It returns an error if
  5114. // the field is not defined in the schema, or if the type mismatched the field
  5115. // type.
  5116. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5117. switch name {
  5118. case batchmsg.FieldCreatedAt:
  5119. v, ok := value.(time.Time)
  5120. if !ok {
  5121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5122. }
  5123. m.SetCreatedAt(v)
  5124. return nil
  5125. case batchmsg.FieldUpdatedAt:
  5126. v, ok := value.(time.Time)
  5127. if !ok {
  5128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5129. }
  5130. m.SetUpdatedAt(v)
  5131. return nil
  5132. case batchmsg.FieldDeletedAt:
  5133. v, ok := value.(time.Time)
  5134. if !ok {
  5135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5136. }
  5137. m.SetDeletedAt(v)
  5138. return nil
  5139. case batchmsg.FieldStatus:
  5140. v, ok := value.(uint8)
  5141. if !ok {
  5142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5143. }
  5144. m.SetStatus(v)
  5145. return nil
  5146. case batchmsg.FieldBatchNo:
  5147. v, ok := value.(string)
  5148. if !ok {
  5149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5150. }
  5151. m.SetBatchNo(v)
  5152. return nil
  5153. case batchmsg.FieldTaskName:
  5154. v, ok := value.(string)
  5155. if !ok {
  5156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5157. }
  5158. m.SetTaskName(v)
  5159. return nil
  5160. case batchmsg.FieldFromwxid:
  5161. v, ok := value.(string)
  5162. if !ok {
  5163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5164. }
  5165. m.SetFromwxid(v)
  5166. return nil
  5167. case batchmsg.FieldMsg:
  5168. v, ok := value.(string)
  5169. if !ok {
  5170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5171. }
  5172. m.SetMsg(v)
  5173. return nil
  5174. case batchmsg.FieldTag:
  5175. v, ok := value.(string)
  5176. if !ok {
  5177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5178. }
  5179. m.SetTag(v)
  5180. return nil
  5181. case batchmsg.FieldTagids:
  5182. v, ok := value.(string)
  5183. if !ok {
  5184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5185. }
  5186. m.SetTagids(v)
  5187. return nil
  5188. case batchmsg.FieldTotal:
  5189. v, ok := value.(int32)
  5190. if !ok {
  5191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5192. }
  5193. m.SetTotal(v)
  5194. return nil
  5195. case batchmsg.FieldSuccess:
  5196. v, ok := value.(int32)
  5197. if !ok {
  5198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5199. }
  5200. m.SetSuccess(v)
  5201. return nil
  5202. case batchmsg.FieldFail:
  5203. v, ok := value.(int32)
  5204. if !ok {
  5205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5206. }
  5207. m.SetFail(v)
  5208. return nil
  5209. case batchmsg.FieldStartTime:
  5210. v, ok := value.(time.Time)
  5211. if !ok {
  5212. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5213. }
  5214. m.SetStartTime(v)
  5215. return nil
  5216. case batchmsg.FieldStopTime:
  5217. v, ok := value.(time.Time)
  5218. if !ok {
  5219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5220. }
  5221. m.SetStopTime(v)
  5222. return nil
  5223. case batchmsg.FieldSendTime:
  5224. v, ok := value.(time.Time)
  5225. if !ok {
  5226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5227. }
  5228. m.SetSendTime(v)
  5229. return nil
  5230. case batchmsg.FieldType:
  5231. v, ok := value.(int32)
  5232. if !ok {
  5233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5234. }
  5235. m.SetType(v)
  5236. return nil
  5237. case batchmsg.FieldOrganizationID:
  5238. v, ok := value.(uint64)
  5239. if !ok {
  5240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5241. }
  5242. m.SetOrganizationID(v)
  5243. return nil
  5244. }
  5245. return fmt.Errorf("unknown BatchMsg field %s", name)
  5246. }
  5247. // AddedFields returns all numeric fields that were incremented/decremented during
  5248. // this mutation.
  5249. func (m *BatchMsgMutation) AddedFields() []string {
  5250. var fields []string
  5251. if m.addstatus != nil {
  5252. fields = append(fields, batchmsg.FieldStatus)
  5253. }
  5254. if m.addtotal != nil {
  5255. fields = append(fields, batchmsg.FieldTotal)
  5256. }
  5257. if m.addsuccess != nil {
  5258. fields = append(fields, batchmsg.FieldSuccess)
  5259. }
  5260. if m.addfail != nil {
  5261. fields = append(fields, batchmsg.FieldFail)
  5262. }
  5263. if m.add_type != nil {
  5264. fields = append(fields, batchmsg.FieldType)
  5265. }
  5266. if m.addorganization_id != nil {
  5267. fields = append(fields, batchmsg.FieldOrganizationID)
  5268. }
  5269. return fields
  5270. }
  5271. // AddedField returns the numeric value that was incremented/decremented on a field
  5272. // with the given name. The second boolean return value indicates that this field
  5273. // was not set, or was not defined in the schema.
  5274. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5275. switch name {
  5276. case batchmsg.FieldStatus:
  5277. return m.AddedStatus()
  5278. case batchmsg.FieldTotal:
  5279. return m.AddedTotal()
  5280. case batchmsg.FieldSuccess:
  5281. return m.AddedSuccess()
  5282. case batchmsg.FieldFail:
  5283. return m.AddedFail()
  5284. case batchmsg.FieldType:
  5285. return m.AddedType()
  5286. case batchmsg.FieldOrganizationID:
  5287. return m.AddedOrganizationID()
  5288. }
  5289. return nil, false
  5290. }
  5291. // AddField adds the value to the field with the given name. It returns an error if
  5292. // the field is not defined in the schema, or if the type mismatched the field
  5293. // type.
  5294. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5295. switch name {
  5296. case batchmsg.FieldStatus:
  5297. v, ok := value.(int8)
  5298. if !ok {
  5299. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5300. }
  5301. m.AddStatus(v)
  5302. return nil
  5303. case batchmsg.FieldTotal:
  5304. v, ok := value.(int32)
  5305. if !ok {
  5306. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5307. }
  5308. m.AddTotal(v)
  5309. return nil
  5310. case batchmsg.FieldSuccess:
  5311. v, ok := value.(int32)
  5312. if !ok {
  5313. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5314. }
  5315. m.AddSuccess(v)
  5316. return nil
  5317. case batchmsg.FieldFail:
  5318. v, ok := value.(int32)
  5319. if !ok {
  5320. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5321. }
  5322. m.AddFail(v)
  5323. return nil
  5324. case batchmsg.FieldType:
  5325. v, ok := value.(int32)
  5326. if !ok {
  5327. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5328. }
  5329. m.AddType(v)
  5330. return nil
  5331. case batchmsg.FieldOrganizationID:
  5332. v, ok := value.(int64)
  5333. if !ok {
  5334. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5335. }
  5336. m.AddOrganizationID(v)
  5337. return nil
  5338. }
  5339. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5340. }
  5341. // ClearedFields returns all nullable fields that were cleared during this
  5342. // mutation.
  5343. func (m *BatchMsgMutation) ClearedFields() []string {
  5344. var fields []string
  5345. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5346. fields = append(fields, batchmsg.FieldDeletedAt)
  5347. }
  5348. if m.FieldCleared(batchmsg.FieldStatus) {
  5349. fields = append(fields, batchmsg.FieldStatus)
  5350. }
  5351. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5352. fields = append(fields, batchmsg.FieldBatchNo)
  5353. }
  5354. if m.FieldCleared(batchmsg.FieldTaskName) {
  5355. fields = append(fields, batchmsg.FieldTaskName)
  5356. }
  5357. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5358. fields = append(fields, batchmsg.FieldFromwxid)
  5359. }
  5360. if m.FieldCleared(batchmsg.FieldMsg) {
  5361. fields = append(fields, batchmsg.FieldMsg)
  5362. }
  5363. if m.FieldCleared(batchmsg.FieldTag) {
  5364. fields = append(fields, batchmsg.FieldTag)
  5365. }
  5366. if m.FieldCleared(batchmsg.FieldTagids) {
  5367. fields = append(fields, batchmsg.FieldTagids)
  5368. }
  5369. if m.FieldCleared(batchmsg.FieldTotal) {
  5370. fields = append(fields, batchmsg.FieldTotal)
  5371. }
  5372. if m.FieldCleared(batchmsg.FieldSuccess) {
  5373. fields = append(fields, batchmsg.FieldSuccess)
  5374. }
  5375. if m.FieldCleared(batchmsg.FieldFail) {
  5376. fields = append(fields, batchmsg.FieldFail)
  5377. }
  5378. if m.FieldCleared(batchmsg.FieldStartTime) {
  5379. fields = append(fields, batchmsg.FieldStartTime)
  5380. }
  5381. if m.FieldCleared(batchmsg.FieldStopTime) {
  5382. fields = append(fields, batchmsg.FieldStopTime)
  5383. }
  5384. if m.FieldCleared(batchmsg.FieldSendTime) {
  5385. fields = append(fields, batchmsg.FieldSendTime)
  5386. }
  5387. if m.FieldCleared(batchmsg.FieldType) {
  5388. fields = append(fields, batchmsg.FieldType)
  5389. }
  5390. return fields
  5391. }
  5392. // FieldCleared returns a boolean indicating if a field with the given name was
  5393. // cleared in this mutation.
  5394. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5395. _, ok := m.clearedFields[name]
  5396. return ok
  5397. }
  5398. // ClearField clears the value of the field with the given name. It returns an
  5399. // error if the field is not defined in the schema.
  5400. func (m *BatchMsgMutation) ClearField(name string) error {
  5401. switch name {
  5402. case batchmsg.FieldDeletedAt:
  5403. m.ClearDeletedAt()
  5404. return nil
  5405. case batchmsg.FieldStatus:
  5406. m.ClearStatus()
  5407. return nil
  5408. case batchmsg.FieldBatchNo:
  5409. m.ClearBatchNo()
  5410. return nil
  5411. case batchmsg.FieldTaskName:
  5412. m.ClearTaskName()
  5413. return nil
  5414. case batchmsg.FieldFromwxid:
  5415. m.ClearFromwxid()
  5416. return nil
  5417. case batchmsg.FieldMsg:
  5418. m.ClearMsg()
  5419. return nil
  5420. case batchmsg.FieldTag:
  5421. m.ClearTag()
  5422. return nil
  5423. case batchmsg.FieldTagids:
  5424. m.ClearTagids()
  5425. return nil
  5426. case batchmsg.FieldTotal:
  5427. m.ClearTotal()
  5428. return nil
  5429. case batchmsg.FieldSuccess:
  5430. m.ClearSuccess()
  5431. return nil
  5432. case batchmsg.FieldFail:
  5433. m.ClearFail()
  5434. return nil
  5435. case batchmsg.FieldStartTime:
  5436. m.ClearStartTime()
  5437. return nil
  5438. case batchmsg.FieldStopTime:
  5439. m.ClearStopTime()
  5440. return nil
  5441. case batchmsg.FieldSendTime:
  5442. m.ClearSendTime()
  5443. return nil
  5444. case batchmsg.FieldType:
  5445. m.ClearType()
  5446. return nil
  5447. }
  5448. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5449. }
  5450. // ResetField resets all changes in the mutation for the field with the given name.
  5451. // It returns an error if the field is not defined in the schema.
  5452. func (m *BatchMsgMutation) ResetField(name string) error {
  5453. switch name {
  5454. case batchmsg.FieldCreatedAt:
  5455. m.ResetCreatedAt()
  5456. return nil
  5457. case batchmsg.FieldUpdatedAt:
  5458. m.ResetUpdatedAt()
  5459. return nil
  5460. case batchmsg.FieldDeletedAt:
  5461. m.ResetDeletedAt()
  5462. return nil
  5463. case batchmsg.FieldStatus:
  5464. m.ResetStatus()
  5465. return nil
  5466. case batchmsg.FieldBatchNo:
  5467. m.ResetBatchNo()
  5468. return nil
  5469. case batchmsg.FieldTaskName:
  5470. m.ResetTaskName()
  5471. return nil
  5472. case batchmsg.FieldFromwxid:
  5473. m.ResetFromwxid()
  5474. return nil
  5475. case batchmsg.FieldMsg:
  5476. m.ResetMsg()
  5477. return nil
  5478. case batchmsg.FieldTag:
  5479. m.ResetTag()
  5480. return nil
  5481. case batchmsg.FieldTagids:
  5482. m.ResetTagids()
  5483. return nil
  5484. case batchmsg.FieldTotal:
  5485. m.ResetTotal()
  5486. return nil
  5487. case batchmsg.FieldSuccess:
  5488. m.ResetSuccess()
  5489. return nil
  5490. case batchmsg.FieldFail:
  5491. m.ResetFail()
  5492. return nil
  5493. case batchmsg.FieldStartTime:
  5494. m.ResetStartTime()
  5495. return nil
  5496. case batchmsg.FieldStopTime:
  5497. m.ResetStopTime()
  5498. return nil
  5499. case batchmsg.FieldSendTime:
  5500. m.ResetSendTime()
  5501. return nil
  5502. case batchmsg.FieldType:
  5503. m.ResetType()
  5504. return nil
  5505. case batchmsg.FieldOrganizationID:
  5506. m.ResetOrganizationID()
  5507. return nil
  5508. }
  5509. return fmt.Errorf("unknown BatchMsg field %s", name)
  5510. }
  5511. // AddedEdges returns all edge names that were set/added in this mutation.
  5512. func (m *BatchMsgMutation) AddedEdges() []string {
  5513. edges := make([]string, 0, 0)
  5514. return edges
  5515. }
  5516. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5517. // name in this mutation.
  5518. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5519. return nil
  5520. }
  5521. // RemovedEdges returns all edge names that were removed in this mutation.
  5522. func (m *BatchMsgMutation) RemovedEdges() []string {
  5523. edges := make([]string, 0, 0)
  5524. return edges
  5525. }
  5526. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5527. // the given name in this mutation.
  5528. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5529. return nil
  5530. }
  5531. // ClearedEdges returns all edge names that were cleared in this mutation.
  5532. func (m *BatchMsgMutation) ClearedEdges() []string {
  5533. edges := make([]string, 0, 0)
  5534. return edges
  5535. }
  5536. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5537. // was cleared in this mutation.
  5538. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5539. return false
  5540. }
  5541. // ClearEdge clears the value of the edge with the given name. It returns an error
  5542. // if that edge is not defined in the schema.
  5543. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5544. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5545. }
  5546. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5547. // It returns an error if the edge is not defined in the schema.
  5548. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5549. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5550. }
  5551. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5552. type CategoryMutation struct {
  5553. config
  5554. op Op
  5555. typ string
  5556. id *uint64
  5557. created_at *time.Time
  5558. updated_at *time.Time
  5559. deleted_at *time.Time
  5560. name *string
  5561. organization_id *uint64
  5562. addorganization_id *int64
  5563. clearedFields map[string]struct{}
  5564. done bool
  5565. oldValue func(context.Context) (*Category, error)
  5566. predicates []predicate.Category
  5567. }
  5568. var _ ent.Mutation = (*CategoryMutation)(nil)
  5569. // categoryOption allows management of the mutation configuration using functional options.
  5570. type categoryOption func(*CategoryMutation)
  5571. // newCategoryMutation creates new mutation for the Category entity.
  5572. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5573. m := &CategoryMutation{
  5574. config: c,
  5575. op: op,
  5576. typ: TypeCategory,
  5577. clearedFields: make(map[string]struct{}),
  5578. }
  5579. for _, opt := range opts {
  5580. opt(m)
  5581. }
  5582. return m
  5583. }
  5584. // withCategoryID sets the ID field of the mutation.
  5585. func withCategoryID(id uint64) categoryOption {
  5586. return func(m *CategoryMutation) {
  5587. var (
  5588. err error
  5589. once sync.Once
  5590. value *Category
  5591. )
  5592. m.oldValue = func(ctx context.Context) (*Category, error) {
  5593. once.Do(func() {
  5594. if m.done {
  5595. err = errors.New("querying old values post mutation is not allowed")
  5596. } else {
  5597. value, err = m.Client().Category.Get(ctx, id)
  5598. }
  5599. })
  5600. return value, err
  5601. }
  5602. m.id = &id
  5603. }
  5604. }
  5605. // withCategory sets the old Category of the mutation.
  5606. func withCategory(node *Category) categoryOption {
  5607. return func(m *CategoryMutation) {
  5608. m.oldValue = func(context.Context) (*Category, error) {
  5609. return node, nil
  5610. }
  5611. m.id = &node.ID
  5612. }
  5613. }
  5614. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5615. // executed in a transaction (ent.Tx), a transactional client is returned.
  5616. func (m CategoryMutation) Client() *Client {
  5617. client := &Client{config: m.config}
  5618. client.init()
  5619. return client
  5620. }
  5621. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5622. // it returns an error otherwise.
  5623. func (m CategoryMutation) Tx() (*Tx, error) {
  5624. if _, ok := m.driver.(*txDriver); !ok {
  5625. return nil, errors.New("ent: mutation is not running in a transaction")
  5626. }
  5627. tx := &Tx{config: m.config}
  5628. tx.init()
  5629. return tx, nil
  5630. }
  5631. // SetID sets the value of the id field. Note that this
  5632. // operation is only accepted on creation of Category entities.
  5633. func (m *CategoryMutation) SetID(id uint64) {
  5634. m.id = &id
  5635. }
  5636. // ID returns the ID value in the mutation. Note that the ID is only available
  5637. // if it was provided to the builder or after it was returned from the database.
  5638. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5639. if m.id == nil {
  5640. return
  5641. }
  5642. return *m.id, true
  5643. }
  5644. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5645. // That means, if the mutation is applied within a transaction with an isolation level such
  5646. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5647. // or updated by the mutation.
  5648. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5649. switch {
  5650. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5651. id, exists := m.ID()
  5652. if exists {
  5653. return []uint64{id}, nil
  5654. }
  5655. fallthrough
  5656. case m.op.Is(OpUpdate | OpDelete):
  5657. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5658. default:
  5659. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5660. }
  5661. }
  5662. // SetCreatedAt sets the "created_at" field.
  5663. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5664. m.created_at = &t
  5665. }
  5666. // CreatedAt returns the value of the "created_at" field in the mutation.
  5667. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5668. v := m.created_at
  5669. if v == nil {
  5670. return
  5671. }
  5672. return *v, true
  5673. }
  5674. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5675. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5676. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5677. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5678. if !m.op.Is(OpUpdateOne) {
  5679. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5680. }
  5681. if m.id == nil || m.oldValue == nil {
  5682. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5683. }
  5684. oldValue, err := m.oldValue(ctx)
  5685. if err != nil {
  5686. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5687. }
  5688. return oldValue.CreatedAt, nil
  5689. }
  5690. // ResetCreatedAt resets all changes to the "created_at" field.
  5691. func (m *CategoryMutation) ResetCreatedAt() {
  5692. m.created_at = nil
  5693. }
  5694. // SetUpdatedAt sets the "updated_at" field.
  5695. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5696. m.updated_at = &t
  5697. }
  5698. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5699. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5700. v := m.updated_at
  5701. if v == nil {
  5702. return
  5703. }
  5704. return *v, true
  5705. }
  5706. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5707. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5709. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5710. if !m.op.Is(OpUpdateOne) {
  5711. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5712. }
  5713. if m.id == nil || m.oldValue == nil {
  5714. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5715. }
  5716. oldValue, err := m.oldValue(ctx)
  5717. if err != nil {
  5718. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5719. }
  5720. return oldValue.UpdatedAt, nil
  5721. }
  5722. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5723. func (m *CategoryMutation) ResetUpdatedAt() {
  5724. m.updated_at = nil
  5725. }
  5726. // SetDeletedAt sets the "deleted_at" field.
  5727. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5728. m.deleted_at = &t
  5729. }
  5730. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5731. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5732. v := m.deleted_at
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5739. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5741. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5747. }
  5748. oldValue, err := m.oldValue(ctx)
  5749. if err != nil {
  5750. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5751. }
  5752. return oldValue.DeletedAt, nil
  5753. }
  5754. // ClearDeletedAt clears the value of the "deleted_at" field.
  5755. func (m *CategoryMutation) ClearDeletedAt() {
  5756. m.deleted_at = nil
  5757. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5758. }
  5759. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5760. func (m *CategoryMutation) DeletedAtCleared() bool {
  5761. _, ok := m.clearedFields[category.FieldDeletedAt]
  5762. return ok
  5763. }
  5764. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5765. func (m *CategoryMutation) ResetDeletedAt() {
  5766. m.deleted_at = nil
  5767. delete(m.clearedFields, category.FieldDeletedAt)
  5768. }
  5769. // SetName sets the "name" field.
  5770. func (m *CategoryMutation) SetName(s string) {
  5771. m.name = &s
  5772. }
  5773. // Name returns the value of the "name" field in the mutation.
  5774. func (m *CategoryMutation) Name() (r string, exists bool) {
  5775. v := m.name
  5776. if v == nil {
  5777. return
  5778. }
  5779. return *v, true
  5780. }
  5781. // OldName returns the old "name" field's value of the Category entity.
  5782. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5784. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5785. if !m.op.Is(OpUpdateOne) {
  5786. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5787. }
  5788. if m.id == nil || m.oldValue == nil {
  5789. return v, errors.New("OldName requires an ID field in the mutation")
  5790. }
  5791. oldValue, err := m.oldValue(ctx)
  5792. if err != nil {
  5793. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5794. }
  5795. return oldValue.Name, nil
  5796. }
  5797. // ResetName resets all changes to the "name" field.
  5798. func (m *CategoryMutation) ResetName() {
  5799. m.name = nil
  5800. }
  5801. // SetOrganizationID sets the "organization_id" field.
  5802. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5803. m.organization_id = &u
  5804. m.addorganization_id = nil
  5805. }
  5806. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5807. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5808. v := m.organization_id
  5809. if v == nil {
  5810. return
  5811. }
  5812. return *v, true
  5813. }
  5814. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5815. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5817. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5818. if !m.op.Is(OpUpdateOne) {
  5819. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5820. }
  5821. if m.id == nil || m.oldValue == nil {
  5822. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5823. }
  5824. oldValue, err := m.oldValue(ctx)
  5825. if err != nil {
  5826. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5827. }
  5828. return oldValue.OrganizationID, nil
  5829. }
  5830. // AddOrganizationID adds u to the "organization_id" field.
  5831. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5832. if m.addorganization_id != nil {
  5833. *m.addorganization_id += u
  5834. } else {
  5835. m.addorganization_id = &u
  5836. }
  5837. }
  5838. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5839. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5840. v := m.addorganization_id
  5841. if v == nil {
  5842. return
  5843. }
  5844. return *v, true
  5845. }
  5846. // ResetOrganizationID resets all changes to the "organization_id" field.
  5847. func (m *CategoryMutation) ResetOrganizationID() {
  5848. m.organization_id = nil
  5849. m.addorganization_id = nil
  5850. }
  5851. // Where appends a list predicates to the CategoryMutation builder.
  5852. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5853. m.predicates = append(m.predicates, ps...)
  5854. }
  5855. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5856. // users can use type-assertion to append predicates that do not depend on any generated package.
  5857. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5858. p := make([]predicate.Category, len(ps))
  5859. for i := range ps {
  5860. p[i] = ps[i]
  5861. }
  5862. m.Where(p...)
  5863. }
  5864. // Op returns the operation name.
  5865. func (m *CategoryMutation) Op() Op {
  5866. return m.op
  5867. }
  5868. // SetOp allows setting the mutation operation.
  5869. func (m *CategoryMutation) SetOp(op Op) {
  5870. m.op = op
  5871. }
  5872. // Type returns the node type of this mutation (Category).
  5873. func (m *CategoryMutation) Type() string {
  5874. return m.typ
  5875. }
  5876. // Fields returns all fields that were changed during this mutation. Note that in
  5877. // order to get all numeric fields that were incremented/decremented, call
  5878. // AddedFields().
  5879. func (m *CategoryMutation) Fields() []string {
  5880. fields := make([]string, 0, 5)
  5881. if m.created_at != nil {
  5882. fields = append(fields, category.FieldCreatedAt)
  5883. }
  5884. if m.updated_at != nil {
  5885. fields = append(fields, category.FieldUpdatedAt)
  5886. }
  5887. if m.deleted_at != nil {
  5888. fields = append(fields, category.FieldDeletedAt)
  5889. }
  5890. if m.name != nil {
  5891. fields = append(fields, category.FieldName)
  5892. }
  5893. if m.organization_id != nil {
  5894. fields = append(fields, category.FieldOrganizationID)
  5895. }
  5896. return fields
  5897. }
  5898. // Field returns the value of a field with the given name. The second boolean
  5899. // return value indicates that this field was not set, or was not defined in the
  5900. // schema.
  5901. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5902. switch name {
  5903. case category.FieldCreatedAt:
  5904. return m.CreatedAt()
  5905. case category.FieldUpdatedAt:
  5906. return m.UpdatedAt()
  5907. case category.FieldDeletedAt:
  5908. return m.DeletedAt()
  5909. case category.FieldName:
  5910. return m.Name()
  5911. case category.FieldOrganizationID:
  5912. return m.OrganizationID()
  5913. }
  5914. return nil, false
  5915. }
  5916. // OldField returns the old value of the field from the database. An error is
  5917. // returned if the mutation operation is not UpdateOne, or the query to the
  5918. // database failed.
  5919. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5920. switch name {
  5921. case category.FieldCreatedAt:
  5922. return m.OldCreatedAt(ctx)
  5923. case category.FieldUpdatedAt:
  5924. return m.OldUpdatedAt(ctx)
  5925. case category.FieldDeletedAt:
  5926. return m.OldDeletedAt(ctx)
  5927. case category.FieldName:
  5928. return m.OldName(ctx)
  5929. case category.FieldOrganizationID:
  5930. return m.OldOrganizationID(ctx)
  5931. }
  5932. return nil, fmt.Errorf("unknown Category field %s", name)
  5933. }
  5934. // SetField sets the value of a field with the given name. It returns an error if
  5935. // the field is not defined in the schema, or if the type mismatched the field
  5936. // type.
  5937. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5938. switch name {
  5939. case category.FieldCreatedAt:
  5940. v, ok := value.(time.Time)
  5941. if !ok {
  5942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5943. }
  5944. m.SetCreatedAt(v)
  5945. return nil
  5946. case category.FieldUpdatedAt:
  5947. v, ok := value.(time.Time)
  5948. if !ok {
  5949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5950. }
  5951. m.SetUpdatedAt(v)
  5952. return nil
  5953. case category.FieldDeletedAt:
  5954. v, ok := value.(time.Time)
  5955. if !ok {
  5956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5957. }
  5958. m.SetDeletedAt(v)
  5959. return nil
  5960. case category.FieldName:
  5961. v, ok := value.(string)
  5962. if !ok {
  5963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5964. }
  5965. m.SetName(v)
  5966. return nil
  5967. case category.FieldOrganizationID:
  5968. v, ok := value.(uint64)
  5969. if !ok {
  5970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5971. }
  5972. m.SetOrganizationID(v)
  5973. return nil
  5974. }
  5975. return fmt.Errorf("unknown Category field %s", name)
  5976. }
  5977. // AddedFields returns all numeric fields that were incremented/decremented during
  5978. // this mutation.
  5979. func (m *CategoryMutation) AddedFields() []string {
  5980. var fields []string
  5981. if m.addorganization_id != nil {
  5982. fields = append(fields, category.FieldOrganizationID)
  5983. }
  5984. return fields
  5985. }
  5986. // AddedField returns the numeric value that was incremented/decremented on a field
  5987. // with the given name. The second boolean return value indicates that this field
  5988. // was not set, or was not defined in the schema.
  5989. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5990. switch name {
  5991. case category.FieldOrganizationID:
  5992. return m.AddedOrganizationID()
  5993. }
  5994. return nil, false
  5995. }
  5996. // AddField adds the value to the field with the given name. It returns an error if
  5997. // the field is not defined in the schema, or if the type mismatched the field
  5998. // type.
  5999. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  6000. switch name {
  6001. case category.FieldOrganizationID:
  6002. v, ok := value.(int64)
  6003. if !ok {
  6004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6005. }
  6006. m.AddOrganizationID(v)
  6007. return nil
  6008. }
  6009. return fmt.Errorf("unknown Category numeric field %s", name)
  6010. }
  6011. // ClearedFields returns all nullable fields that were cleared during this
  6012. // mutation.
  6013. func (m *CategoryMutation) ClearedFields() []string {
  6014. var fields []string
  6015. if m.FieldCleared(category.FieldDeletedAt) {
  6016. fields = append(fields, category.FieldDeletedAt)
  6017. }
  6018. return fields
  6019. }
  6020. // FieldCleared returns a boolean indicating if a field with the given name was
  6021. // cleared in this mutation.
  6022. func (m *CategoryMutation) FieldCleared(name string) bool {
  6023. _, ok := m.clearedFields[name]
  6024. return ok
  6025. }
  6026. // ClearField clears the value of the field with the given name. It returns an
  6027. // error if the field is not defined in the schema.
  6028. func (m *CategoryMutation) ClearField(name string) error {
  6029. switch name {
  6030. case category.FieldDeletedAt:
  6031. m.ClearDeletedAt()
  6032. return nil
  6033. }
  6034. return fmt.Errorf("unknown Category nullable field %s", name)
  6035. }
  6036. // ResetField resets all changes in the mutation for the field with the given name.
  6037. // It returns an error if the field is not defined in the schema.
  6038. func (m *CategoryMutation) ResetField(name string) error {
  6039. switch name {
  6040. case category.FieldCreatedAt:
  6041. m.ResetCreatedAt()
  6042. return nil
  6043. case category.FieldUpdatedAt:
  6044. m.ResetUpdatedAt()
  6045. return nil
  6046. case category.FieldDeletedAt:
  6047. m.ResetDeletedAt()
  6048. return nil
  6049. case category.FieldName:
  6050. m.ResetName()
  6051. return nil
  6052. case category.FieldOrganizationID:
  6053. m.ResetOrganizationID()
  6054. return nil
  6055. }
  6056. return fmt.Errorf("unknown Category field %s", name)
  6057. }
  6058. // AddedEdges returns all edge names that were set/added in this mutation.
  6059. func (m *CategoryMutation) AddedEdges() []string {
  6060. edges := make([]string, 0, 0)
  6061. return edges
  6062. }
  6063. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6064. // name in this mutation.
  6065. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  6066. return nil
  6067. }
  6068. // RemovedEdges returns all edge names that were removed in this mutation.
  6069. func (m *CategoryMutation) RemovedEdges() []string {
  6070. edges := make([]string, 0, 0)
  6071. return edges
  6072. }
  6073. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6074. // the given name in this mutation.
  6075. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6076. return nil
  6077. }
  6078. // ClearedEdges returns all edge names that were cleared in this mutation.
  6079. func (m *CategoryMutation) ClearedEdges() []string {
  6080. edges := make([]string, 0, 0)
  6081. return edges
  6082. }
  6083. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6084. // was cleared in this mutation.
  6085. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6086. return false
  6087. }
  6088. // ClearEdge clears the value of the edge with the given name. It returns an error
  6089. // if that edge is not defined in the schema.
  6090. func (m *CategoryMutation) ClearEdge(name string) error {
  6091. return fmt.Errorf("unknown Category unique edge %s", name)
  6092. }
  6093. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6094. // It returns an error if the edge is not defined in the schema.
  6095. func (m *CategoryMutation) ResetEdge(name string) error {
  6096. return fmt.Errorf("unknown Category edge %s", name)
  6097. }
  6098. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6099. type ChatRecordsMutation struct {
  6100. config
  6101. op Op
  6102. typ string
  6103. id *uint64
  6104. created_at *time.Time
  6105. updated_at *time.Time
  6106. deleted_at *time.Time
  6107. content *string
  6108. content_type *uint8
  6109. addcontent_type *int8
  6110. session_id *uint64
  6111. addsession_id *int64
  6112. user_id *uint64
  6113. adduser_id *int64
  6114. bot_id *uint64
  6115. addbot_id *int64
  6116. bot_type *uint8
  6117. addbot_type *int8
  6118. clearedFields map[string]struct{}
  6119. done bool
  6120. oldValue func(context.Context) (*ChatRecords, error)
  6121. predicates []predicate.ChatRecords
  6122. }
  6123. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6124. // chatrecordsOption allows management of the mutation configuration using functional options.
  6125. type chatrecordsOption func(*ChatRecordsMutation)
  6126. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6127. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6128. m := &ChatRecordsMutation{
  6129. config: c,
  6130. op: op,
  6131. typ: TypeChatRecords,
  6132. clearedFields: make(map[string]struct{}),
  6133. }
  6134. for _, opt := range opts {
  6135. opt(m)
  6136. }
  6137. return m
  6138. }
  6139. // withChatRecordsID sets the ID field of the mutation.
  6140. func withChatRecordsID(id uint64) chatrecordsOption {
  6141. return func(m *ChatRecordsMutation) {
  6142. var (
  6143. err error
  6144. once sync.Once
  6145. value *ChatRecords
  6146. )
  6147. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6148. once.Do(func() {
  6149. if m.done {
  6150. err = errors.New("querying old values post mutation is not allowed")
  6151. } else {
  6152. value, err = m.Client().ChatRecords.Get(ctx, id)
  6153. }
  6154. })
  6155. return value, err
  6156. }
  6157. m.id = &id
  6158. }
  6159. }
  6160. // withChatRecords sets the old ChatRecords of the mutation.
  6161. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6162. return func(m *ChatRecordsMutation) {
  6163. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6164. return node, nil
  6165. }
  6166. m.id = &node.ID
  6167. }
  6168. }
  6169. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6170. // executed in a transaction (ent.Tx), a transactional client is returned.
  6171. func (m ChatRecordsMutation) Client() *Client {
  6172. client := &Client{config: m.config}
  6173. client.init()
  6174. return client
  6175. }
  6176. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6177. // it returns an error otherwise.
  6178. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6179. if _, ok := m.driver.(*txDriver); !ok {
  6180. return nil, errors.New("ent: mutation is not running in a transaction")
  6181. }
  6182. tx := &Tx{config: m.config}
  6183. tx.init()
  6184. return tx, nil
  6185. }
  6186. // SetID sets the value of the id field. Note that this
  6187. // operation is only accepted on creation of ChatRecords entities.
  6188. func (m *ChatRecordsMutation) SetID(id uint64) {
  6189. m.id = &id
  6190. }
  6191. // ID returns the ID value in the mutation. Note that the ID is only available
  6192. // if it was provided to the builder or after it was returned from the database.
  6193. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6194. if m.id == nil {
  6195. return
  6196. }
  6197. return *m.id, true
  6198. }
  6199. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6200. // That means, if the mutation is applied within a transaction with an isolation level such
  6201. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6202. // or updated by the mutation.
  6203. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6204. switch {
  6205. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6206. id, exists := m.ID()
  6207. if exists {
  6208. return []uint64{id}, nil
  6209. }
  6210. fallthrough
  6211. case m.op.Is(OpUpdate | OpDelete):
  6212. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6213. default:
  6214. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6215. }
  6216. }
  6217. // SetCreatedAt sets the "created_at" field.
  6218. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6219. m.created_at = &t
  6220. }
  6221. // CreatedAt returns the value of the "created_at" field in the mutation.
  6222. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6223. v := m.created_at
  6224. if v == nil {
  6225. return
  6226. }
  6227. return *v, true
  6228. }
  6229. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6230. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6231. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6232. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6233. if !m.op.Is(OpUpdateOne) {
  6234. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6235. }
  6236. if m.id == nil || m.oldValue == nil {
  6237. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6238. }
  6239. oldValue, err := m.oldValue(ctx)
  6240. if err != nil {
  6241. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6242. }
  6243. return oldValue.CreatedAt, nil
  6244. }
  6245. // ResetCreatedAt resets all changes to the "created_at" field.
  6246. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6247. m.created_at = nil
  6248. }
  6249. // SetUpdatedAt sets the "updated_at" field.
  6250. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6251. m.updated_at = &t
  6252. }
  6253. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6254. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6255. v := m.updated_at
  6256. if v == nil {
  6257. return
  6258. }
  6259. return *v, true
  6260. }
  6261. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6262. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6263. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6264. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6265. if !m.op.Is(OpUpdateOne) {
  6266. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6267. }
  6268. if m.id == nil || m.oldValue == nil {
  6269. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6270. }
  6271. oldValue, err := m.oldValue(ctx)
  6272. if err != nil {
  6273. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6274. }
  6275. return oldValue.UpdatedAt, nil
  6276. }
  6277. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6278. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6279. m.updated_at = nil
  6280. }
  6281. // SetDeletedAt sets the "deleted_at" field.
  6282. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6283. m.deleted_at = &t
  6284. }
  6285. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6286. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6287. v := m.deleted_at
  6288. if v == nil {
  6289. return
  6290. }
  6291. return *v, true
  6292. }
  6293. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6294. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6296. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6297. if !m.op.Is(OpUpdateOne) {
  6298. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6299. }
  6300. if m.id == nil || m.oldValue == nil {
  6301. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6302. }
  6303. oldValue, err := m.oldValue(ctx)
  6304. if err != nil {
  6305. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6306. }
  6307. return oldValue.DeletedAt, nil
  6308. }
  6309. // ClearDeletedAt clears the value of the "deleted_at" field.
  6310. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6311. m.deleted_at = nil
  6312. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6313. }
  6314. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6315. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6316. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6317. return ok
  6318. }
  6319. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6320. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6321. m.deleted_at = nil
  6322. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6323. }
  6324. // SetContent sets the "content" field.
  6325. func (m *ChatRecordsMutation) SetContent(s string) {
  6326. m.content = &s
  6327. }
  6328. // Content returns the value of the "content" field in the mutation.
  6329. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6330. v := m.content
  6331. if v == nil {
  6332. return
  6333. }
  6334. return *v, true
  6335. }
  6336. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6337. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6339. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6340. if !m.op.Is(OpUpdateOne) {
  6341. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6342. }
  6343. if m.id == nil || m.oldValue == nil {
  6344. return v, errors.New("OldContent requires an ID field in the mutation")
  6345. }
  6346. oldValue, err := m.oldValue(ctx)
  6347. if err != nil {
  6348. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6349. }
  6350. return oldValue.Content, nil
  6351. }
  6352. // ResetContent resets all changes to the "content" field.
  6353. func (m *ChatRecordsMutation) ResetContent() {
  6354. m.content = nil
  6355. }
  6356. // SetContentType sets the "content_type" field.
  6357. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6358. m.content_type = &u
  6359. m.addcontent_type = nil
  6360. }
  6361. // ContentType returns the value of the "content_type" field in the mutation.
  6362. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6363. v := m.content_type
  6364. if v == nil {
  6365. return
  6366. }
  6367. return *v, true
  6368. }
  6369. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6370. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6372. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6373. if !m.op.Is(OpUpdateOne) {
  6374. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6375. }
  6376. if m.id == nil || m.oldValue == nil {
  6377. return v, errors.New("OldContentType requires an ID field in the mutation")
  6378. }
  6379. oldValue, err := m.oldValue(ctx)
  6380. if err != nil {
  6381. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6382. }
  6383. return oldValue.ContentType, nil
  6384. }
  6385. // AddContentType adds u to the "content_type" field.
  6386. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6387. if m.addcontent_type != nil {
  6388. *m.addcontent_type += u
  6389. } else {
  6390. m.addcontent_type = &u
  6391. }
  6392. }
  6393. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6394. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6395. v := m.addcontent_type
  6396. if v == nil {
  6397. return
  6398. }
  6399. return *v, true
  6400. }
  6401. // ResetContentType resets all changes to the "content_type" field.
  6402. func (m *ChatRecordsMutation) ResetContentType() {
  6403. m.content_type = nil
  6404. m.addcontent_type = nil
  6405. }
  6406. // SetSessionID sets the "session_id" field.
  6407. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6408. m.session_id = &u
  6409. m.addsession_id = nil
  6410. }
  6411. // SessionID returns the value of the "session_id" field in the mutation.
  6412. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6413. v := m.session_id
  6414. if v == nil {
  6415. return
  6416. }
  6417. return *v, true
  6418. }
  6419. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6420. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6421. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6422. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6423. if !m.op.Is(OpUpdateOne) {
  6424. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6425. }
  6426. if m.id == nil || m.oldValue == nil {
  6427. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6428. }
  6429. oldValue, err := m.oldValue(ctx)
  6430. if err != nil {
  6431. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6432. }
  6433. return oldValue.SessionID, nil
  6434. }
  6435. // AddSessionID adds u to the "session_id" field.
  6436. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6437. if m.addsession_id != nil {
  6438. *m.addsession_id += u
  6439. } else {
  6440. m.addsession_id = &u
  6441. }
  6442. }
  6443. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6444. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6445. v := m.addsession_id
  6446. if v == nil {
  6447. return
  6448. }
  6449. return *v, true
  6450. }
  6451. // ResetSessionID resets all changes to the "session_id" field.
  6452. func (m *ChatRecordsMutation) ResetSessionID() {
  6453. m.session_id = nil
  6454. m.addsession_id = nil
  6455. }
  6456. // SetUserID sets the "user_id" field.
  6457. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6458. m.user_id = &u
  6459. m.adduser_id = nil
  6460. }
  6461. // UserID returns the value of the "user_id" field in the mutation.
  6462. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6463. v := m.user_id
  6464. if v == nil {
  6465. return
  6466. }
  6467. return *v, true
  6468. }
  6469. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6470. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6471. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6472. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6473. if !m.op.Is(OpUpdateOne) {
  6474. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6475. }
  6476. if m.id == nil || m.oldValue == nil {
  6477. return v, errors.New("OldUserID requires an ID field in the mutation")
  6478. }
  6479. oldValue, err := m.oldValue(ctx)
  6480. if err != nil {
  6481. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6482. }
  6483. return oldValue.UserID, nil
  6484. }
  6485. // AddUserID adds u to the "user_id" field.
  6486. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6487. if m.adduser_id != nil {
  6488. *m.adduser_id += u
  6489. } else {
  6490. m.adduser_id = &u
  6491. }
  6492. }
  6493. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6494. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6495. v := m.adduser_id
  6496. if v == nil {
  6497. return
  6498. }
  6499. return *v, true
  6500. }
  6501. // ResetUserID resets all changes to the "user_id" field.
  6502. func (m *ChatRecordsMutation) ResetUserID() {
  6503. m.user_id = nil
  6504. m.adduser_id = nil
  6505. }
  6506. // SetBotID sets the "bot_id" field.
  6507. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6508. m.bot_id = &u
  6509. m.addbot_id = nil
  6510. }
  6511. // BotID returns the value of the "bot_id" field in the mutation.
  6512. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6513. v := m.bot_id
  6514. if v == nil {
  6515. return
  6516. }
  6517. return *v, true
  6518. }
  6519. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6520. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6522. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6523. if !m.op.Is(OpUpdateOne) {
  6524. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6525. }
  6526. if m.id == nil || m.oldValue == nil {
  6527. return v, errors.New("OldBotID requires an ID field in the mutation")
  6528. }
  6529. oldValue, err := m.oldValue(ctx)
  6530. if err != nil {
  6531. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6532. }
  6533. return oldValue.BotID, nil
  6534. }
  6535. // AddBotID adds u to the "bot_id" field.
  6536. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6537. if m.addbot_id != nil {
  6538. *m.addbot_id += u
  6539. } else {
  6540. m.addbot_id = &u
  6541. }
  6542. }
  6543. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6544. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6545. v := m.addbot_id
  6546. if v == nil {
  6547. return
  6548. }
  6549. return *v, true
  6550. }
  6551. // ResetBotID resets all changes to the "bot_id" field.
  6552. func (m *ChatRecordsMutation) ResetBotID() {
  6553. m.bot_id = nil
  6554. m.addbot_id = nil
  6555. }
  6556. // SetBotType sets the "bot_type" field.
  6557. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6558. m.bot_type = &u
  6559. m.addbot_type = nil
  6560. }
  6561. // BotType returns the value of the "bot_type" field in the mutation.
  6562. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6563. v := m.bot_type
  6564. if v == nil {
  6565. return
  6566. }
  6567. return *v, true
  6568. }
  6569. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6570. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6571. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6572. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6573. if !m.op.Is(OpUpdateOne) {
  6574. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6575. }
  6576. if m.id == nil || m.oldValue == nil {
  6577. return v, errors.New("OldBotType requires an ID field in the mutation")
  6578. }
  6579. oldValue, err := m.oldValue(ctx)
  6580. if err != nil {
  6581. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6582. }
  6583. return oldValue.BotType, nil
  6584. }
  6585. // AddBotType adds u to the "bot_type" field.
  6586. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6587. if m.addbot_type != nil {
  6588. *m.addbot_type += u
  6589. } else {
  6590. m.addbot_type = &u
  6591. }
  6592. }
  6593. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6594. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6595. v := m.addbot_type
  6596. if v == nil {
  6597. return
  6598. }
  6599. return *v, true
  6600. }
  6601. // ResetBotType resets all changes to the "bot_type" field.
  6602. func (m *ChatRecordsMutation) ResetBotType() {
  6603. m.bot_type = nil
  6604. m.addbot_type = nil
  6605. }
  6606. // Where appends a list predicates to the ChatRecordsMutation builder.
  6607. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6608. m.predicates = append(m.predicates, ps...)
  6609. }
  6610. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6611. // users can use type-assertion to append predicates that do not depend on any generated package.
  6612. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6613. p := make([]predicate.ChatRecords, len(ps))
  6614. for i := range ps {
  6615. p[i] = ps[i]
  6616. }
  6617. m.Where(p...)
  6618. }
  6619. // Op returns the operation name.
  6620. func (m *ChatRecordsMutation) Op() Op {
  6621. return m.op
  6622. }
  6623. // SetOp allows setting the mutation operation.
  6624. func (m *ChatRecordsMutation) SetOp(op Op) {
  6625. m.op = op
  6626. }
  6627. // Type returns the node type of this mutation (ChatRecords).
  6628. func (m *ChatRecordsMutation) Type() string {
  6629. return m.typ
  6630. }
  6631. // Fields returns all fields that were changed during this mutation. Note that in
  6632. // order to get all numeric fields that were incremented/decremented, call
  6633. // AddedFields().
  6634. func (m *ChatRecordsMutation) Fields() []string {
  6635. fields := make([]string, 0, 9)
  6636. if m.created_at != nil {
  6637. fields = append(fields, chatrecords.FieldCreatedAt)
  6638. }
  6639. if m.updated_at != nil {
  6640. fields = append(fields, chatrecords.FieldUpdatedAt)
  6641. }
  6642. if m.deleted_at != nil {
  6643. fields = append(fields, chatrecords.FieldDeletedAt)
  6644. }
  6645. if m.content != nil {
  6646. fields = append(fields, chatrecords.FieldContent)
  6647. }
  6648. if m.content_type != nil {
  6649. fields = append(fields, chatrecords.FieldContentType)
  6650. }
  6651. if m.session_id != nil {
  6652. fields = append(fields, chatrecords.FieldSessionID)
  6653. }
  6654. if m.user_id != nil {
  6655. fields = append(fields, chatrecords.FieldUserID)
  6656. }
  6657. if m.bot_id != nil {
  6658. fields = append(fields, chatrecords.FieldBotID)
  6659. }
  6660. if m.bot_type != nil {
  6661. fields = append(fields, chatrecords.FieldBotType)
  6662. }
  6663. return fields
  6664. }
  6665. // Field returns the value of a field with the given name. The second boolean
  6666. // return value indicates that this field was not set, or was not defined in the
  6667. // schema.
  6668. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6669. switch name {
  6670. case chatrecords.FieldCreatedAt:
  6671. return m.CreatedAt()
  6672. case chatrecords.FieldUpdatedAt:
  6673. return m.UpdatedAt()
  6674. case chatrecords.FieldDeletedAt:
  6675. return m.DeletedAt()
  6676. case chatrecords.FieldContent:
  6677. return m.Content()
  6678. case chatrecords.FieldContentType:
  6679. return m.ContentType()
  6680. case chatrecords.FieldSessionID:
  6681. return m.SessionID()
  6682. case chatrecords.FieldUserID:
  6683. return m.UserID()
  6684. case chatrecords.FieldBotID:
  6685. return m.BotID()
  6686. case chatrecords.FieldBotType:
  6687. return m.BotType()
  6688. }
  6689. return nil, false
  6690. }
  6691. // OldField returns the old value of the field from the database. An error is
  6692. // returned if the mutation operation is not UpdateOne, or the query to the
  6693. // database failed.
  6694. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6695. switch name {
  6696. case chatrecords.FieldCreatedAt:
  6697. return m.OldCreatedAt(ctx)
  6698. case chatrecords.FieldUpdatedAt:
  6699. return m.OldUpdatedAt(ctx)
  6700. case chatrecords.FieldDeletedAt:
  6701. return m.OldDeletedAt(ctx)
  6702. case chatrecords.FieldContent:
  6703. return m.OldContent(ctx)
  6704. case chatrecords.FieldContentType:
  6705. return m.OldContentType(ctx)
  6706. case chatrecords.FieldSessionID:
  6707. return m.OldSessionID(ctx)
  6708. case chatrecords.FieldUserID:
  6709. return m.OldUserID(ctx)
  6710. case chatrecords.FieldBotID:
  6711. return m.OldBotID(ctx)
  6712. case chatrecords.FieldBotType:
  6713. return m.OldBotType(ctx)
  6714. }
  6715. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6716. }
  6717. // SetField sets the value of a field with the given name. It returns an error if
  6718. // the field is not defined in the schema, or if the type mismatched the field
  6719. // type.
  6720. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6721. switch name {
  6722. case chatrecords.FieldCreatedAt:
  6723. v, ok := value.(time.Time)
  6724. if !ok {
  6725. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6726. }
  6727. m.SetCreatedAt(v)
  6728. return nil
  6729. case chatrecords.FieldUpdatedAt:
  6730. v, ok := value.(time.Time)
  6731. if !ok {
  6732. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6733. }
  6734. m.SetUpdatedAt(v)
  6735. return nil
  6736. case chatrecords.FieldDeletedAt:
  6737. v, ok := value.(time.Time)
  6738. if !ok {
  6739. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6740. }
  6741. m.SetDeletedAt(v)
  6742. return nil
  6743. case chatrecords.FieldContent:
  6744. v, ok := value.(string)
  6745. if !ok {
  6746. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6747. }
  6748. m.SetContent(v)
  6749. return nil
  6750. case chatrecords.FieldContentType:
  6751. v, ok := value.(uint8)
  6752. if !ok {
  6753. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6754. }
  6755. m.SetContentType(v)
  6756. return nil
  6757. case chatrecords.FieldSessionID:
  6758. v, ok := value.(uint64)
  6759. if !ok {
  6760. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6761. }
  6762. m.SetSessionID(v)
  6763. return nil
  6764. case chatrecords.FieldUserID:
  6765. v, ok := value.(uint64)
  6766. if !ok {
  6767. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6768. }
  6769. m.SetUserID(v)
  6770. return nil
  6771. case chatrecords.FieldBotID:
  6772. v, ok := value.(uint64)
  6773. if !ok {
  6774. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6775. }
  6776. m.SetBotID(v)
  6777. return nil
  6778. case chatrecords.FieldBotType:
  6779. v, ok := value.(uint8)
  6780. if !ok {
  6781. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6782. }
  6783. m.SetBotType(v)
  6784. return nil
  6785. }
  6786. return fmt.Errorf("unknown ChatRecords field %s", name)
  6787. }
  6788. // AddedFields returns all numeric fields that were incremented/decremented during
  6789. // this mutation.
  6790. func (m *ChatRecordsMutation) AddedFields() []string {
  6791. var fields []string
  6792. if m.addcontent_type != nil {
  6793. fields = append(fields, chatrecords.FieldContentType)
  6794. }
  6795. if m.addsession_id != nil {
  6796. fields = append(fields, chatrecords.FieldSessionID)
  6797. }
  6798. if m.adduser_id != nil {
  6799. fields = append(fields, chatrecords.FieldUserID)
  6800. }
  6801. if m.addbot_id != nil {
  6802. fields = append(fields, chatrecords.FieldBotID)
  6803. }
  6804. if m.addbot_type != nil {
  6805. fields = append(fields, chatrecords.FieldBotType)
  6806. }
  6807. return fields
  6808. }
  6809. // AddedField returns the numeric value that was incremented/decremented on a field
  6810. // with the given name. The second boolean return value indicates that this field
  6811. // was not set, or was not defined in the schema.
  6812. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6813. switch name {
  6814. case chatrecords.FieldContentType:
  6815. return m.AddedContentType()
  6816. case chatrecords.FieldSessionID:
  6817. return m.AddedSessionID()
  6818. case chatrecords.FieldUserID:
  6819. return m.AddedUserID()
  6820. case chatrecords.FieldBotID:
  6821. return m.AddedBotID()
  6822. case chatrecords.FieldBotType:
  6823. return m.AddedBotType()
  6824. }
  6825. return nil, false
  6826. }
  6827. // AddField adds the value to the field with the given name. It returns an error if
  6828. // the field is not defined in the schema, or if the type mismatched the field
  6829. // type.
  6830. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6831. switch name {
  6832. case chatrecords.FieldContentType:
  6833. v, ok := value.(int8)
  6834. if !ok {
  6835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6836. }
  6837. m.AddContentType(v)
  6838. return nil
  6839. case chatrecords.FieldSessionID:
  6840. v, ok := value.(int64)
  6841. if !ok {
  6842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6843. }
  6844. m.AddSessionID(v)
  6845. return nil
  6846. case chatrecords.FieldUserID:
  6847. v, ok := value.(int64)
  6848. if !ok {
  6849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6850. }
  6851. m.AddUserID(v)
  6852. return nil
  6853. case chatrecords.FieldBotID:
  6854. v, ok := value.(int64)
  6855. if !ok {
  6856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6857. }
  6858. m.AddBotID(v)
  6859. return nil
  6860. case chatrecords.FieldBotType:
  6861. v, ok := value.(int8)
  6862. if !ok {
  6863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6864. }
  6865. m.AddBotType(v)
  6866. return nil
  6867. }
  6868. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6869. }
  6870. // ClearedFields returns all nullable fields that were cleared during this
  6871. // mutation.
  6872. func (m *ChatRecordsMutation) ClearedFields() []string {
  6873. var fields []string
  6874. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6875. fields = append(fields, chatrecords.FieldDeletedAt)
  6876. }
  6877. return fields
  6878. }
  6879. // FieldCleared returns a boolean indicating if a field with the given name was
  6880. // cleared in this mutation.
  6881. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6882. _, ok := m.clearedFields[name]
  6883. return ok
  6884. }
  6885. // ClearField clears the value of the field with the given name. It returns an
  6886. // error if the field is not defined in the schema.
  6887. func (m *ChatRecordsMutation) ClearField(name string) error {
  6888. switch name {
  6889. case chatrecords.FieldDeletedAt:
  6890. m.ClearDeletedAt()
  6891. return nil
  6892. }
  6893. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6894. }
  6895. // ResetField resets all changes in the mutation for the field with the given name.
  6896. // It returns an error if the field is not defined in the schema.
  6897. func (m *ChatRecordsMutation) ResetField(name string) error {
  6898. switch name {
  6899. case chatrecords.FieldCreatedAt:
  6900. m.ResetCreatedAt()
  6901. return nil
  6902. case chatrecords.FieldUpdatedAt:
  6903. m.ResetUpdatedAt()
  6904. return nil
  6905. case chatrecords.FieldDeletedAt:
  6906. m.ResetDeletedAt()
  6907. return nil
  6908. case chatrecords.FieldContent:
  6909. m.ResetContent()
  6910. return nil
  6911. case chatrecords.FieldContentType:
  6912. m.ResetContentType()
  6913. return nil
  6914. case chatrecords.FieldSessionID:
  6915. m.ResetSessionID()
  6916. return nil
  6917. case chatrecords.FieldUserID:
  6918. m.ResetUserID()
  6919. return nil
  6920. case chatrecords.FieldBotID:
  6921. m.ResetBotID()
  6922. return nil
  6923. case chatrecords.FieldBotType:
  6924. m.ResetBotType()
  6925. return nil
  6926. }
  6927. return fmt.Errorf("unknown ChatRecords field %s", name)
  6928. }
  6929. // AddedEdges returns all edge names that were set/added in this mutation.
  6930. func (m *ChatRecordsMutation) AddedEdges() []string {
  6931. edges := make([]string, 0, 0)
  6932. return edges
  6933. }
  6934. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6935. // name in this mutation.
  6936. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6937. return nil
  6938. }
  6939. // RemovedEdges returns all edge names that were removed in this mutation.
  6940. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6941. edges := make([]string, 0, 0)
  6942. return edges
  6943. }
  6944. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6945. // the given name in this mutation.
  6946. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6947. return nil
  6948. }
  6949. // ClearedEdges returns all edge names that were cleared in this mutation.
  6950. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6951. edges := make([]string, 0, 0)
  6952. return edges
  6953. }
  6954. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6955. // was cleared in this mutation.
  6956. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6957. return false
  6958. }
  6959. // ClearEdge clears the value of the edge with the given name. It returns an error
  6960. // if that edge is not defined in the schema.
  6961. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6962. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6963. }
  6964. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6965. // It returns an error if the edge is not defined in the schema.
  6966. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6967. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6968. }
  6969. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6970. type ChatSessionMutation struct {
  6971. config
  6972. op Op
  6973. typ string
  6974. id *uint64
  6975. created_at *time.Time
  6976. updated_at *time.Time
  6977. deleted_at *time.Time
  6978. name *string
  6979. user_id *uint64
  6980. adduser_id *int64
  6981. bot_id *uint64
  6982. addbot_id *int64
  6983. bot_type *uint8
  6984. addbot_type *int8
  6985. clearedFields map[string]struct{}
  6986. done bool
  6987. oldValue func(context.Context) (*ChatSession, error)
  6988. predicates []predicate.ChatSession
  6989. }
  6990. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6991. // chatsessionOption allows management of the mutation configuration using functional options.
  6992. type chatsessionOption func(*ChatSessionMutation)
  6993. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6994. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6995. m := &ChatSessionMutation{
  6996. config: c,
  6997. op: op,
  6998. typ: TypeChatSession,
  6999. clearedFields: make(map[string]struct{}),
  7000. }
  7001. for _, opt := range opts {
  7002. opt(m)
  7003. }
  7004. return m
  7005. }
  7006. // withChatSessionID sets the ID field of the mutation.
  7007. func withChatSessionID(id uint64) chatsessionOption {
  7008. return func(m *ChatSessionMutation) {
  7009. var (
  7010. err error
  7011. once sync.Once
  7012. value *ChatSession
  7013. )
  7014. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  7015. once.Do(func() {
  7016. if m.done {
  7017. err = errors.New("querying old values post mutation is not allowed")
  7018. } else {
  7019. value, err = m.Client().ChatSession.Get(ctx, id)
  7020. }
  7021. })
  7022. return value, err
  7023. }
  7024. m.id = &id
  7025. }
  7026. }
  7027. // withChatSession sets the old ChatSession of the mutation.
  7028. func withChatSession(node *ChatSession) chatsessionOption {
  7029. return func(m *ChatSessionMutation) {
  7030. m.oldValue = func(context.Context) (*ChatSession, error) {
  7031. return node, nil
  7032. }
  7033. m.id = &node.ID
  7034. }
  7035. }
  7036. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7037. // executed in a transaction (ent.Tx), a transactional client is returned.
  7038. func (m ChatSessionMutation) Client() *Client {
  7039. client := &Client{config: m.config}
  7040. client.init()
  7041. return client
  7042. }
  7043. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7044. // it returns an error otherwise.
  7045. func (m ChatSessionMutation) Tx() (*Tx, error) {
  7046. if _, ok := m.driver.(*txDriver); !ok {
  7047. return nil, errors.New("ent: mutation is not running in a transaction")
  7048. }
  7049. tx := &Tx{config: m.config}
  7050. tx.init()
  7051. return tx, nil
  7052. }
  7053. // SetID sets the value of the id field. Note that this
  7054. // operation is only accepted on creation of ChatSession entities.
  7055. func (m *ChatSessionMutation) SetID(id uint64) {
  7056. m.id = &id
  7057. }
  7058. // ID returns the ID value in the mutation. Note that the ID is only available
  7059. // if it was provided to the builder or after it was returned from the database.
  7060. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  7061. if m.id == nil {
  7062. return
  7063. }
  7064. return *m.id, true
  7065. }
  7066. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7067. // That means, if the mutation is applied within a transaction with an isolation level such
  7068. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7069. // or updated by the mutation.
  7070. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  7071. switch {
  7072. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7073. id, exists := m.ID()
  7074. if exists {
  7075. return []uint64{id}, nil
  7076. }
  7077. fallthrough
  7078. case m.op.Is(OpUpdate | OpDelete):
  7079. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7080. default:
  7081. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7082. }
  7083. }
  7084. // SetCreatedAt sets the "created_at" field.
  7085. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7086. m.created_at = &t
  7087. }
  7088. // CreatedAt returns the value of the "created_at" field in the mutation.
  7089. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7090. v := m.created_at
  7091. if v == nil {
  7092. return
  7093. }
  7094. return *v, true
  7095. }
  7096. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7097. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7098. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7099. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7100. if !m.op.Is(OpUpdateOne) {
  7101. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7102. }
  7103. if m.id == nil || m.oldValue == nil {
  7104. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7105. }
  7106. oldValue, err := m.oldValue(ctx)
  7107. if err != nil {
  7108. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7109. }
  7110. return oldValue.CreatedAt, nil
  7111. }
  7112. // ResetCreatedAt resets all changes to the "created_at" field.
  7113. func (m *ChatSessionMutation) ResetCreatedAt() {
  7114. m.created_at = nil
  7115. }
  7116. // SetUpdatedAt sets the "updated_at" field.
  7117. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7118. m.updated_at = &t
  7119. }
  7120. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7121. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7122. v := m.updated_at
  7123. if v == nil {
  7124. return
  7125. }
  7126. return *v, true
  7127. }
  7128. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7129. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7131. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7132. if !m.op.Is(OpUpdateOne) {
  7133. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7134. }
  7135. if m.id == nil || m.oldValue == nil {
  7136. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7137. }
  7138. oldValue, err := m.oldValue(ctx)
  7139. if err != nil {
  7140. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7141. }
  7142. return oldValue.UpdatedAt, nil
  7143. }
  7144. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7145. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7146. m.updated_at = nil
  7147. }
  7148. // SetDeletedAt sets the "deleted_at" field.
  7149. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7150. m.deleted_at = &t
  7151. }
  7152. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7153. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7154. v := m.deleted_at
  7155. if v == nil {
  7156. return
  7157. }
  7158. return *v, true
  7159. }
  7160. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7161. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7163. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7164. if !m.op.Is(OpUpdateOne) {
  7165. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7166. }
  7167. if m.id == nil || m.oldValue == nil {
  7168. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7169. }
  7170. oldValue, err := m.oldValue(ctx)
  7171. if err != nil {
  7172. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7173. }
  7174. return oldValue.DeletedAt, nil
  7175. }
  7176. // ClearDeletedAt clears the value of the "deleted_at" field.
  7177. func (m *ChatSessionMutation) ClearDeletedAt() {
  7178. m.deleted_at = nil
  7179. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7180. }
  7181. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7182. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7183. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7184. return ok
  7185. }
  7186. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7187. func (m *ChatSessionMutation) ResetDeletedAt() {
  7188. m.deleted_at = nil
  7189. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7190. }
  7191. // SetName sets the "name" field.
  7192. func (m *ChatSessionMutation) SetName(s string) {
  7193. m.name = &s
  7194. }
  7195. // Name returns the value of the "name" field in the mutation.
  7196. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7197. v := m.name
  7198. if v == nil {
  7199. return
  7200. }
  7201. return *v, true
  7202. }
  7203. // OldName returns the old "name" field's value of the ChatSession entity.
  7204. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7206. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7207. if !m.op.Is(OpUpdateOne) {
  7208. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7209. }
  7210. if m.id == nil || m.oldValue == nil {
  7211. return v, errors.New("OldName requires an ID field in the mutation")
  7212. }
  7213. oldValue, err := m.oldValue(ctx)
  7214. if err != nil {
  7215. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7216. }
  7217. return oldValue.Name, nil
  7218. }
  7219. // ResetName resets all changes to the "name" field.
  7220. func (m *ChatSessionMutation) ResetName() {
  7221. m.name = nil
  7222. }
  7223. // SetUserID sets the "user_id" field.
  7224. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7225. m.user_id = &u
  7226. m.adduser_id = nil
  7227. }
  7228. // UserID returns the value of the "user_id" field in the mutation.
  7229. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7230. v := m.user_id
  7231. if v == nil {
  7232. return
  7233. }
  7234. return *v, true
  7235. }
  7236. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7237. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7239. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7240. if !m.op.Is(OpUpdateOne) {
  7241. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7242. }
  7243. if m.id == nil || m.oldValue == nil {
  7244. return v, errors.New("OldUserID requires an ID field in the mutation")
  7245. }
  7246. oldValue, err := m.oldValue(ctx)
  7247. if err != nil {
  7248. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7249. }
  7250. return oldValue.UserID, nil
  7251. }
  7252. // AddUserID adds u to the "user_id" field.
  7253. func (m *ChatSessionMutation) AddUserID(u int64) {
  7254. if m.adduser_id != nil {
  7255. *m.adduser_id += u
  7256. } else {
  7257. m.adduser_id = &u
  7258. }
  7259. }
  7260. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7261. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7262. v := m.adduser_id
  7263. if v == nil {
  7264. return
  7265. }
  7266. return *v, true
  7267. }
  7268. // ResetUserID resets all changes to the "user_id" field.
  7269. func (m *ChatSessionMutation) ResetUserID() {
  7270. m.user_id = nil
  7271. m.adduser_id = nil
  7272. }
  7273. // SetBotID sets the "bot_id" field.
  7274. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7275. m.bot_id = &u
  7276. m.addbot_id = nil
  7277. }
  7278. // BotID returns the value of the "bot_id" field in the mutation.
  7279. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7280. v := m.bot_id
  7281. if v == nil {
  7282. return
  7283. }
  7284. return *v, true
  7285. }
  7286. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7287. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7288. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7289. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7290. if !m.op.Is(OpUpdateOne) {
  7291. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7292. }
  7293. if m.id == nil || m.oldValue == nil {
  7294. return v, errors.New("OldBotID requires an ID field in the mutation")
  7295. }
  7296. oldValue, err := m.oldValue(ctx)
  7297. if err != nil {
  7298. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7299. }
  7300. return oldValue.BotID, nil
  7301. }
  7302. // AddBotID adds u to the "bot_id" field.
  7303. func (m *ChatSessionMutation) AddBotID(u int64) {
  7304. if m.addbot_id != nil {
  7305. *m.addbot_id += u
  7306. } else {
  7307. m.addbot_id = &u
  7308. }
  7309. }
  7310. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7311. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7312. v := m.addbot_id
  7313. if v == nil {
  7314. return
  7315. }
  7316. return *v, true
  7317. }
  7318. // ResetBotID resets all changes to the "bot_id" field.
  7319. func (m *ChatSessionMutation) ResetBotID() {
  7320. m.bot_id = nil
  7321. m.addbot_id = nil
  7322. }
  7323. // SetBotType sets the "bot_type" field.
  7324. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7325. m.bot_type = &u
  7326. m.addbot_type = nil
  7327. }
  7328. // BotType returns the value of the "bot_type" field in the mutation.
  7329. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7330. v := m.bot_type
  7331. if v == nil {
  7332. return
  7333. }
  7334. return *v, true
  7335. }
  7336. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7337. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7338. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7339. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7340. if !m.op.Is(OpUpdateOne) {
  7341. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7342. }
  7343. if m.id == nil || m.oldValue == nil {
  7344. return v, errors.New("OldBotType requires an ID field in the mutation")
  7345. }
  7346. oldValue, err := m.oldValue(ctx)
  7347. if err != nil {
  7348. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7349. }
  7350. return oldValue.BotType, nil
  7351. }
  7352. // AddBotType adds u to the "bot_type" field.
  7353. func (m *ChatSessionMutation) AddBotType(u int8) {
  7354. if m.addbot_type != nil {
  7355. *m.addbot_type += u
  7356. } else {
  7357. m.addbot_type = &u
  7358. }
  7359. }
  7360. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7361. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7362. v := m.addbot_type
  7363. if v == nil {
  7364. return
  7365. }
  7366. return *v, true
  7367. }
  7368. // ResetBotType resets all changes to the "bot_type" field.
  7369. func (m *ChatSessionMutation) ResetBotType() {
  7370. m.bot_type = nil
  7371. m.addbot_type = nil
  7372. }
  7373. // Where appends a list predicates to the ChatSessionMutation builder.
  7374. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7375. m.predicates = append(m.predicates, ps...)
  7376. }
  7377. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7378. // users can use type-assertion to append predicates that do not depend on any generated package.
  7379. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7380. p := make([]predicate.ChatSession, len(ps))
  7381. for i := range ps {
  7382. p[i] = ps[i]
  7383. }
  7384. m.Where(p...)
  7385. }
  7386. // Op returns the operation name.
  7387. func (m *ChatSessionMutation) Op() Op {
  7388. return m.op
  7389. }
  7390. // SetOp allows setting the mutation operation.
  7391. func (m *ChatSessionMutation) SetOp(op Op) {
  7392. m.op = op
  7393. }
  7394. // Type returns the node type of this mutation (ChatSession).
  7395. func (m *ChatSessionMutation) Type() string {
  7396. return m.typ
  7397. }
  7398. // Fields returns all fields that were changed during this mutation. Note that in
  7399. // order to get all numeric fields that were incremented/decremented, call
  7400. // AddedFields().
  7401. func (m *ChatSessionMutation) Fields() []string {
  7402. fields := make([]string, 0, 7)
  7403. if m.created_at != nil {
  7404. fields = append(fields, chatsession.FieldCreatedAt)
  7405. }
  7406. if m.updated_at != nil {
  7407. fields = append(fields, chatsession.FieldUpdatedAt)
  7408. }
  7409. if m.deleted_at != nil {
  7410. fields = append(fields, chatsession.FieldDeletedAt)
  7411. }
  7412. if m.name != nil {
  7413. fields = append(fields, chatsession.FieldName)
  7414. }
  7415. if m.user_id != nil {
  7416. fields = append(fields, chatsession.FieldUserID)
  7417. }
  7418. if m.bot_id != nil {
  7419. fields = append(fields, chatsession.FieldBotID)
  7420. }
  7421. if m.bot_type != nil {
  7422. fields = append(fields, chatsession.FieldBotType)
  7423. }
  7424. return fields
  7425. }
  7426. // Field returns the value of a field with the given name. The second boolean
  7427. // return value indicates that this field was not set, or was not defined in the
  7428. // schema.
  7429. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7430. switch name {
  7431. case chatsession.FieldCreatedAt:
  7432. return m.CreatedAt()
  7433. case chatsession.FieldUpdatedAt:
  7434. return m.UpdatedAt()
  7435. case chatsession.FieldDeletedAt:
  7436. return m.DeletedAt()
  7437. case chatsession.FieldName:
  7438. return m.Name()
  7439. case chatsession.FieldUserID:
  7440. return m.UserID()
  7441. case chatsession.FieldBotID:
  7442. return m.BotID()
  7443. case chatsession.FieldBotType:
  7444. return m.BotType()
  7445. }
  7446. return nil, false
  7447. }
  7448. // OldField returns the old value of the field from the database. An error is
  7449. // returned if the mutation operation is not UpdateOne, or the query to the
  7450. // database failed.
  7451. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7452. switch name {
  7453. case chatsession.FieldCreatedAt:
  7454. return m.OldCreatedAt(ctx)
  7455. case chatsession.FieldUpdatedAt:
  7456. return m.OldUpdatedAt(ctx)
  7457. case chatsession.FieldDeletedAt:
  7458. return m.OldDeletedAt(ctx)
  7459. case chatsession.FieldName:
  7460. return m.OldName(ctx)
  7461. case chatsession.FieldUserID:
  7462. return m.OldUserID(ctx)
  7463. case chatsession.FieldBotID:
  7464. return m.OldBotID(ctx)
  7465. case chatsession.FieldBotType:
  7466. return m.OldBotType(ctx)
  7467. }
  7468. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7469. }
  7470. // SetField sets the value of a field with the given name. It returns an error if
  7471. // the field is not defined in the schema, or if the type mismatched the field
  7472. // type.
  7473. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7474. switch name {
  7475. case chatsession.FieldCreatedAt:
  7476. v, ok := value.(time.Time)
  7477. if !ok {
  7478. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7479. }
  7480. m.SetCreatedAt(v)
  7481. return nil
  7482. case chatsession.FieldUpdatedAt:
  7483. v, ok := value.(time.Time)
  7484. if !ok {
  7485. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7486. }
  7487. m.SetUpdatedAt(v)
  7488. return nil
  7489. case chatsession.FieldDeletedAt:
  7490. v, ok := value.(time.Time)
  7491. if !ok {
  7492. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7493. }
  7494. m.SetDeletedAt(v)
  7495. return nil
  7496. case chatsession.FieldName:
  7497. v, ok := value.(string)
  7498. if !ok {
  7499. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7500. }
  7501. m.SetName(v)
  7502. return nil
  7503. case chatsession.FieldUserID:
  7504. v, ok := value.(uint64)
  7505. if !ok {
  7506. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7507. }
  7508. m.SetUserID(v)
  7509. return nil
  7510. case chatsession.FieldBotID:
  7511. v, ok := value.(uint64)
  7512. if !ok {
  7513. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7514. }
  7515. m.SetBotID(v)
  7516. return nil
  7517. case chatsession.FieldBotType:
  7518. v, ok := value.(uint8)
  7519. if !ok {
  7520. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7521. }
  7522. m.SetBotType(v)
  7523. return nil
  7524. }
  7525. return fmt.Errorf("unknown ChatSession field %s", name)
  7526. }
  7527. // AddedFields returns all numeric fields that were incremented/decremented during
  7528. // this mutation.
  7529. func (m *ChatSessionMutation) AddedFields() []string {
  7530. var fields []string
  7531. if m.adduser_id != nil {
  7532. fields = append(fields, chatsession.FieldUserID)
  7533. }
  7534. if m.addbot_id != nil {
  7535. fields = append(fields, chatsession.FieldBotID)
  7536. }
  7537. if m.addbot_type != nil {
  7538. fields = append(fields, chatsession.FieldBotType)
  7539. }
  7540. return fields
  7541. }
  7542. // AddedField returns the numeric value that was incremented/decremented on a field
  7543. // with the given name. The second boolean return value indicates that this field
  7544. // was not set, or was not defined in the schema.
  7545. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7546. switch name {
  7547. case chatsession.FieldUserID:
  7548. return m.AddedUserID()
  7549. case chatsession.FieldBotID:
  7550. return m.AddedBotID()
  7551. case chatsession.FieldBotType:
  7552. return m.AddedBotType()
  7553. }
  7554. return nil, false
  7555. }
  7556. // AddField adds the value to the field with the given name. It returns an error if
  7557. // the field is not defined in the schema, or if the type mismatched the field
  7558. // type.
  7559. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7560. switch name {
  7561. case chatsession.FieldUserID:
  7562. v, ok := value.(int64)
  7563. if !ok {
  7564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7565. }
  7566. m.AddUserID(v)
  7567. return nil
  7568. case chatsession.FieldBotID:
  7569. v, ok := value.(int64)
  7570. if !ok {
  7571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7572. }
  7573. m.AddBotID(v)
  7574. return nil
  7575. case chatsession.FieldBotType:
  7576. v, ok := value.(int8)
  7577. if !ok {
  7578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7579. }
  7580. m.AddBotType(v)
  7581. return nil
  7582. }
  7583. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7584. }
  7585. // ClearedFields returns all nullable fields that were cleared during this
  7586. // mutation.
  7587. func (m *ChatSessionMutation) ClearedFields() []string {
  7588. var fields []string
  7589. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7590. fields = append(fields, chatsession.FieldDeletedAt)
  7591. }
  7592. return fields
  7593. }
  7594. // FieldCleared returns a boolean indicating if a field with the given name was
  7595. // cleared in this mutation.
  7596. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7597. _, ok := m.clearedFields[name]
  7598. return ok
  7599. }
  7600. // ClearField clears the value of the field with the given name. It returns an
  7601. // error if the field is not defined in the schema.
  7602. func (m *ChatSessionMutation) ClearField(name string) error {
  7603. switch name {
  7604. case chatsession.FieldDeletedAt:
  7605. m.ClearDeletedAt()
  7606. return nil
  7607. }
  7608. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7609. }
  7610. // ResetField resets all changes in the mutation for the field with the given name.
  7611. // It returns an error if the field is not defined in the schema.
  7612. func (m *ChatSessionMutation) ResetField(name string) error {
  7613. switch name {
  7614. case chatsession.FieldCreatedAt:
  7615. m.ResetCreatedAt()
  7616. return nil
  7617. case chatsession.FieldUpdatedAt:
  7618. m.ResetUpdatedAt()
  7619. return nil
  7620. case chatsession.FieldDeletedAt:
  7621. m.ResetDeletedAt()
  7622. return nil
  7623. case chatsession.FieldName:
  7624. m.ResetName()
  7625. return nil
  7626. case chatsession.FieldUserID:
  7627. m.ResetUserID()
  7628. return nil
  7629. case chatsession.FieldBotID:
  7630. m.ResetBotID()
  7631. return nil
  7632. case chatsession.FieldBotType:
  7633. m.ResetBotType()
  7634. return nil
  7635. }
  7636. return fmt.Errorf("unknown ChatSession field %s", name)
  7637. }
  7638. // AddedEdges returns all edge names that were set/added in this mutation.
  7639. func (m *ChatSessionMutation) AddedEdges() []string {
  7640. edges := make([]string, 0, 0)
  7641. return edges
  7642. }
  7643. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7644. // name in this mutation.
  7645. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7646. return nil
  7647. }
  7648. // RemovedEdges returns all edge names that were removed in this mutation.
  7649. func (m *ChatSessionMutation) RemovedEdges() []string {
  7650. edges := make([]string, 0, 0)
  7651. return edges
  7652. }
  7653. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7654. // the given name in this mutation.
  7655. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7656. return nil
  7657. }
  7658. // ClearedEdges returns all edge names that were cleared in this mutation.
  7659. func (m *ChatSessionMutation) ClearedEdges() []string {
  7660. edges := make([]string, 0, 0)
  7661. return edges
  7662. }
  7663. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7664. // was cleared in this mutation.
  7665. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7666. return false
  7667. }
  7668. // ClearEdge clears the value of the edge with the given name. It returns an error
  7669. // if that edge is not defined in the schema.
  7670. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7671. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7672. }
  7673. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7674. // It returns an error if the edge is not defined in the schema.
  7675. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7676. return fmt.Errorf("unknown ChatSession edge %s", name)
  7677. }
  7678. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7679. type ContactMutation struct {
  7680. config
  7681. op Op
  7682. typ string
  7683. id *uint64
  7684. created_at *time.Time
  7685. updated_at *time.Time
  7686. status *uint8
  7687. addstatus *int8
  7688. deleted_at *time.Time
  7689. wx_wxid *string
  7690. _type *int
  7691. add_type *int
  7692. wxid *string
  7693. account *string
  7694. nickname *string
  7695. markname *string
  7696. headimg *string
  7697. sex *int
  7698. addsex *int
  7699. starrole *string
  7700. dontseeit *int
  7701. adddontseeit *int
  7702. dontseeme *int
  7703. adddontseeme *int
  7704. lag *string
  7705. gid *string
  7706. gname *string
  7707. v3 *string
  7708. organization_id *uint64
  7709. addorganization_id *int64
  7710. clearedFields map[string]struct{}
  7711. contact_relationships map[uint64]struct{}
  7712. removedcontact_relationships map[uint64]struct{}
  7713. clearedcontact_relationships bool
  7714. contact_messages map[uint64]struct{}
  7715. removedcontact_messages map[uint64]struct{}
  7716. clearedcontact_messages bool
  7717. done bool
  7718. oldValue func(context.Context) (*Contact, error)
  7719. predicates []predicate.Contact
  7720. }
  7721. var _ ent.Mutation = (*ContactMutation)(nil)
  7722. // contactOption allows management of the mutation configuration using functional options.
  7723. type contactOption func(*ContactMutation)
  7724. // newContactMutation creates new mutation for the Contact entity.
  7725. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7726. m := &ContactMutation{
  7727. config: c,
  7728. op: op,
  7729. typ: TypeContact,
  7730. clearedFields: make(map[string]struct{}),
  7731. }
  7732. for _, opt := range opts {
  7733. opt(m)
  7734. }
  7735. return m
  7736. }
  7737. // withContactID sets the ID field of the mutation.
  7738. func withContactID(id uint64) contactOption {
  7739. return func(m *ContactMutation) {
  7740. var (
  7741. err error
  7742. once sync.Once
  7743. value *Contact
  7744. )
  7745. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7746. once.Do(func() {
  7747. if m.done {
  7748. err = errors.New("querying old values post mutation is not allowed")
  7749. } else {
  7750. value, err = m.Client().Contact.Get(ctx, id)
  7751. }
  7752. })
  7753. return value, err
  7754. }
  7755. m.id = &id
  7756. }
  7757. }
  7758. // withContact sets the old Contact of the mutation.
  7759. func withContact(node *Contact) contactOption {
  7760. return func(m *ContactMutation) {
  7761. m.oldValue = func(context.Context) (*Contact, error) {
  7762. return node, nil
  7763. }
  7764. m.id = &node.ID
  7765. }
  7766. }
  7767. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7768. // executed in a transaction (ent.Tx), a transactional client is returned.
  7769. func (m ContactMutation) Client() *Client {
  7770. client := &Client{config: m.config}
  7771. client.init()
  7772. return client
  7773. }
  7774. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7775. // it returns an error otherwise.
  7776. func (m ContactMutation) Tx() (*Tx, error) {
  7777. if _, ok := m.driver.(*txDriver); !ok {
  7778. return nil, errors.New("ent: mutation is not running in a transaction")
  7779. }
  7780. tx := &Tx{config: m.config}
  7781. tx.init()
  7782. return tx, nil
  7783. }
  7784. // SetID sets the value of the id field. Note that this
  7785. // operation is only accepted on creation of Contact entities.
  7786. func (m *ContactMutation) SetID(id uint64) {
  7787. m.id = &id
  7788. }
  7789. // ID returns the ID value in the mutation. Note that the ID is only available
  7790. // if it was provided to the builder or after it was returned from the database.
  7791. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7792. if m.id == nil {
  7793. return
  7794. }
  7795. return *m.id, true
  7796. }
  7797. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7798. // That means, if the mutation is applied within a transaction with an isolation level such
  7799. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7800. // or updated by the mutation.
  7801. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7802. switch {
  7803. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7804. id, exists := m.ID()
  7805. if exists {
  7806. return []uint64{id}, nil
  7807. }
  7808. fallthrough
  7809. case m.op.Is(OpUpdate | OpDelete):
  7810. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7811. default:
  7812. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7813. }
  7814. }
  7815. // SetCreatedAt sets the "created_at" field.
  7816. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7817. m.created_at = &t
  7818. }
  7819. // CreatedAt returns the value of the "created_at" field in the mutation.
  7820. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7821. v := m.created_at
  7822. if v == nil {
  7823. return
  7824. }
  7825. return *v, true
  7826. }
  7827. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7828. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7830. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7831. if !m.op.Is(OpUpdateOne) {
  7832. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7833. }
  7834. if m.id == nil || m.oldValue == nil {
  7835. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7836. }
  7837. oldValue, err := m.oldValue(ctx)
  7838. if err != nil {
  7839. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7840. }
  7841. return oldValue.CreatedAt, nil
  7842. }
  7843. // ResetCreatedAt resets all changes to the "created_at" field.
  7844. func (m *ContactMutation) ResetCreatedAt() {
  7845. m.created_at = nil
  7846. }
  7847. // SetUpdatedAt sets the "updated_at" field.
  7848. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7849. m.updated_at = &t
  7850. }
  7851. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7852. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7853. v := m.updated_at
  7854. if v == nil {
  7855. return
  7856. }
  7857. return *v, true
  7858. }
  7859. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7860. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7862. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7863. if !m.op.Is(OpUpdateOne) {
  7864. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7865. }
  7866. if m.id == nil || m.oldValue == nil {
  7867. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7868. }
  7869. oldValue, err := m.oldValue(ctx)
  7870. if err != nil {
  7871. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7872. }
  7873. return oldValue.UpdatedAt, nil
  7874. }
  7875. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7876. func (m *ContactMutation) ResetUpdatedAt() {
  7877. m.updated_at = nil
  7878. }
  7879. // SetStatus sets the "status" field.
  7880. func (m *ContactMutation) SetStatus(u uint8) {
  7881. m.status = &u
  7882. m.addstatus = nil
  7883. }
  7884. // Status returns the value of the "status" field in the mutation.
  7885. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7886. v := m.status
  7887. if v == nil {
  7888. return
  7889. }
  7890. return *v, true
  7891. }
  7892. // OldStatus returns the old "status" field's value of the Contact entity.
  7893. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7894. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7895. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7896. if !m.op.Is(OpUpdateOne) {
  7897. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7898. }
  7899. if m.id == nil || m.oldValue == nil {
  7900. return v, errors.New("OldStatus requires an ID field in the mutation")
  7901. }
  7902. oldValue, err := m.oldValue(ctx)
  7903. if err != nil {
  7904. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7905. }
  7906. return oldValue.Status, nil
  7907. }
  7908. // AddStatus adds u to the "status" field.
  7909. func (m *ContactMutation) AddStatus(u int8) {
  7910. if m.addstatus != nil {
  7911. *m.addstatus += u
  7912. } else {
  7913. m.addstatus = &u
  7914. }
  7915. }
  7916. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7917. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7918. v := m.addstatus
  7919. if v == nil {
  7920. return
  7921. }
  7922. return *v, true
  7923. }
  7924. // ClearStatus clears the value of the "status" field.
  7925. func (m *ContactMutation) ClearStatus() {
  7926. m.status = nil
  7927. m.addstatus = nil
  7928. m.clearedFields[contact.FieldStatus] = struct{}{}
  7929. }
  7930. // StatusCleared returns if the "status" field was cleared in this mutation.
  7931. func (m *ContactMutation) StatusCleared() bool {
  7932. _, ok := m.clearedFields[contact.FieldStatus]
  7933. return ok
  7934. }
  7935. // ResetStatus resets all changes to the "status" field.
  7936. func (m *ContactMutation) ResetStatus() {
  7937. m.status = nil
  7938. m.addstatus = nil
  7939. delete(m.clearedFields, contact.FieldStatus)
  7940. }
  7941. // SetDeletedAt sets the "deleted_at" field.
  7942. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7943. m.deleted_at = &t
  7944. }
  7945. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7946. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7947. v := m.deleted_at
  7948. if v == nil {
  7949. return
  7950. }
  7951. return *v, true
  7952. }
  7953. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7954. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7956. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7957. if !m.op.Is(OpUpdateOne) {
  7958. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7959. }
  7960. if m.id == nil || m.oldValue == nil {
  7961. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7962. }
  7963. oldValue, err := m.oldValue(ctx)
  7964. if err != nil {
  7965. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7966. }
  7967. return oldValue.DeletedAt, nil
  7968. }
  7969. // ClearDeletedAt clears the value of the "deleted_at" field.
  7970. func (m *ContactMutation) ClearDeletedAt() {
  7971. m.deleted_at = nil
  7972. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7973. }
  7974. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7975. func (m *ContactMutation) DeletedAtCleared() bool {
  7976. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7977. return ok
  7978. }
  7979. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7980. func (m *ContactMutation) ResetDeletedAt() {
  7981. m.deleted_at = nil
  7982. delete(m.clearedFields, contact.FieldDeletedAt)
  7983. }
  7984. // SetWxWxid sets the "wx_wxid" field.
  7985. func (m *ContactMutation) SetWxWxid(s string) {
  7986. m.wx_wxid = &s
  7987. }
  7988. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7989. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7990. v := m.wx_wxid
  7991. if v == nil {
  7992. return
  7993. }
  7994. return *v, true
  7995. }
  7996. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7997. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7999. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  8000. if !m.op.Is(OpUpdateOne) {
  8001. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  8002. }
  8003. if m.id == nil || m.oldValue == nil {
  8004. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  8005. }
  8006. oldValue, err := m.oldValue(ctx)
  8007. if err != nil {
  8008. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  8009. }
  8010. return oldValue.WxWxid, nil
  8011. }
  8012. // ResetWxWxid resets all changes to the "wx_wxid" field.
  8013. func (m *ContactMutation) ResetWxWxid() {
  8014. m.wx_wxid = nil
  8015. }
  8016. // SetType sets the "type" field.
  8017. func (m *ContactMutation) SetType(i int) {
  8018. m._type = &i
  8019. m.add_type = nil
  8020. }
  8021. // GetType returns the value of the "type" field in the mutation.
  8022. func (m *ContactMutation) GetType() (r int, exists bool) {
  8023. v := m._type
  8024. if v == nil {
  8025. return
  8026. }
  8027. return *v, true
  8028. }
  8029. // OldType returns the old "type" field's value of the Contact entity.
  8030. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8031. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8032. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  8033. if !m.op.Is(OpUpdateOne) {
  8034. return v, errors.New("OldType is only allowed on UpdateOne operations")
  8035. }
  8036. if m.id == nil || m.oldValue == nil {
  8037. return v, errors.New("OldType requires an ID field in the mutation")
  8038. }
  8039. oldValue, err := m.oldValue(ctx)
  8040. if err != nil {
  8041. return v, fmt.Errorf("querying old value for OldType: %w", err)
  8042. }
  8043. return oldValue.Type, nil
  8044. }
  8045. // AddType adds i to the "type" field.
  8046. func (m *ContactMutation) AddType(i int) {
  8047. if m.add_type != nil {
  8048. *m.add_type += i
  8049. } else {
  8050. m.add_type = &i
  8051. }
  8052. }
  8053. // AddedType returns the value that was added to the "type" field in this mutation.
  8054. func (m *ContactMutation) AddedType() (r int, exists bool) {
  8055. v := m.add_type
  8056. if v == nil {
  8057. return
  8058. }
  8059. return *v, true
  8060. }
  8061. // ClearType clears the value of the "type" field.
  8062. func (m *ContactMutation) ClearType() {
  8063. m._type = nil
  8064. m.add_type = nil
  8065. m.clearedFields[contact.FieldType] = struct{}{}
  8066. }
  8067. // TypeCleared returns if the "type" field was cleared in this mutation.
  8068. func (m *ContactMutation) TypeCleared() bool {
  8069. _, ok := m.clearedFields[contact.FieldType]
  8070. return ok
  8071. }
  8072. // ResetType resets all changes to the "type" field.
  8073. func (m *ContactMutation) ResetType() {
  8074. m._type = nil
  8075. m.add_type = nil
  8076. delete(m.clearedFields, contact.FieldType)
  8077. }
  8078. // SetWxid sets the "wxid" field.
  8079. func (m *ContactMutation) SetWxid(s string) {
  8080. m.wxid = &s
  8081. }
  8082. // Wxid returns the value of the "wxid" field in the mutation.
  8083. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8084. v := m.wxid
  8085. if v == nil {
  8086. return
  8087. }
  8088. return *v, true
  8089. }
  8090. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8091. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8092. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8093. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8094. if !m.op.Is(OpUpdateOne) {
  8095. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8096. }
  8097. if m.id == nil || m.oldValue == nil {
  8098. return v, errors.New("OldWxid requires an ID field in the mutation")
  8099. }
  8100. oldValue, err := m.oldValue(ctx)
  8101. if err != nil {
  8102. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8103. }
  8104. return oldValue.Wxid, nil
  8105. }
  8106. // ResetWxid resets all changes to the "wxid" field.
  8107. func (m *ContactMutation) ResetWxid() {
  8108. m.wxid = nil
  8109. }
  8110. // SetAccount sets the "account" field.
  8111. func (m *ContactMutation) SetAccount(s string) {
  8112. m.account = &s
  8113. }
  8114. // Account returns the value of the "account" field in the mutation.
  8115. func (m *ContactMutation) Account() (r string, exists bool) {
  8116. v := m.account
  8117. if v == nil {
  8118. return
  8119. }
  8120. return *v, true
  8121. }
  8122. // OldAccount returns the old "account" field's value of the Contact entity.
  8123. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8125. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8126. if !m.op.Is(OpUpdateOne) {
  8127. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8128. }
  8129. if m.id == nil || m.oldValue == nil {
  8130. return v, errors.New("OldAccount requires an ID field in the mutation")
  8131. }
  8132. oldValue, err := m.oldValue(ctx)
  8133. if err != nil {
  8134. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8135. }
  8136. return oldValue.Account, nil
  8137. }
  8138. // ResetAccount resets all changes to the "account" field.
  8139. func (m *ContactMutation) ResetAccount() {
  8140. m.account = nil
  8141. }
  8142. // SetNickname sets the "nickname" field.
  8143. func (m *ContactMutation) SetNickname(s string) {
  8144. m.nickname = &s
  8145. }
  8146. // Nickname returns the value of the "nickname" field in the mutation.
  8147. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8148. v := m.nickname
  8149. if v == nil {
  8150. return
  8151. }
  8152. return *v, true
  8153. }
  8154. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8155. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8156. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8157. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8158. if !m.op.Is(OpUpdateOne) {
  8159. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8160. }
  8161. if m.id == nil || m.oldValue == nil {
  8162. return v, errors.New("OldNickname requires an ID field in the mutation")
  8163. }
  8164. oldValue, err := m.oldValue(ctx)
  8165. if err != nil {
  8166. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8167. }
  8168. return oldValue.Nickname, nil
  8169. }
  8170. // ResetNickname resets all changes to the "nickname" field.
  8171. func (m *ContactMutation) ResetNickname() {
  8172. m.nickname = nil
  8173. }
  8174. // SetMarkname sets the "markname" field.
  8175. func (m *ContactMutation) SetMarkname(s string) {
  8176. m.markname = &s
  8177. }
  8178. // Markname returns the value of the "markname" field in the mutation.
  8179. func (m *ContactMutation) Markname() (r string, exists bool) {
  8180. v := m.markname
  8181. if v == nil {
  8182. return
  8183. }
  8184. return *v, true
  8185. }
  8186. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8187. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8189. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8190. if !m.op.Is(OpUpdateOne) {
  8191. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8192. }
  8193. if m.id == nil || m.oldValue == nil {
  8194. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8195. }
  8196. oldValue, err := m.oldValue(ctx)
  8197. if err != nil {
  8198. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8199. }
  8200. return oldValue.Markname, nil
  8201. }
  8202. // ResetMarkname resets all changes to the "markname" field.
  8203. func (m *ContactMutation) ResetMarkname() {
  8204. m.markname = nil
  8205. }
  8206. // SetHeadimg sets the "headimg" field.
  8207. func (m *ContactMutation) SetHeadimg(s string) {
  8208. m.headimg = &s
  8209. }
  8210. // Headimg returns the value of the "headimg" field in the mutation.
  8211. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8212. v := m.headimg
  8213. if v == nil {
  8214. return
  8215. }
  8216. return *v, true
  8217. }
  8218. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8219. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8221. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8222. if !m.op.Is(OpUpdateOne) {
  8223. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8224. }
  8225. if m.id == nil || m.oldValue == nil {
  8226. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8227. }
  8228. oldValue, err := m.oldValue(ctx)
  8229. if err != nil {
  8230. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8231. }
  8232. return oldValue.Headimg, nil
  8233. }
  8234. // ResetHeadimg resets all changes to the "headimg" field.
  8235. func (m *ContactMutation) ResetHeadimg() {
  8236. m.headimg = nil
  8237. }
  8238. // SetSex sets the "sex" field.
  8239. func (m *ContactMutation) SetSex(i int) {
  8240. m.sex = &i
  8241. m.addsex = nil
  8242. }
  8243. // Sex returns the value of the "sex" field in the mutation.
  8244. func (m *ContactMutation) Sex() (r int, exists bool) {
  8245. v := m.sex
  8246. if v == nil {
  8247. return
  8248. }
  8249. return *v, true
  8250. }
  8251. // OldSex returns the old "sex" field's value of the Contact entity.
  8252. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8254. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8255. if !m.op.Is(OpUpdateOne) {
  8256. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8257. }
  8258. if m.id == nil || m.oldValue == nil {
  8259. return v, errors.New("OldSex requires an ID field in the mutation")
  8260. }
  8261. oldValue, err := m.oldValue(ctx)
  8262. if err != nil {
  8263. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8264. }
  8265. return oldValue.Sex, nil
  8266. }
  8267. // AddSex adds i to the "sex" field.
  8268. func (m *ContactMutation) AddSex(i int) {
  8269. if m.addsex != nil {
  8270. *m.addsex += i
  8271. } else {
  8272. m.addsex = &i
  8273. }
  8274. }
  8275. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8276. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8277. v := m.addsex
  8278. if v == nil {
  8279. return
  8280. }
  8281. return *v, true
  8282. }
  8283. // ResetSex resets all changes to the "sex" field.
  8284. func (m *ContactMutation) ResetSex() {
  8285. m.sex = nil
  8286. m.addsex = nil
  8287. }
  8288. // SetStarrole sets the "starrole" field.
  8289. func (m *ContactMutation) SetStarrole(s string) {
  8290. m.starrole = &s
  8291. }
  8292. // Starrole returns the value of the "starrole" field in the mutation.
  8293. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8294. v := m.starrole
  8295. if v == nil {
  8296. return
  8297. }
  8298. return *v, true
  8299. }
  8300. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8301. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8303. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8304. if !m.op.Is(OpUpdateOne) {
  8305. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8306. }
  8307. if m.id == nil || m.oldValue == nil {
  8308. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8309. }
  8310. oldValue, err := m.oldValue(ctx)
  8311. if err != nil {
  8312. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8313. }
  8314. return oldValue.Starrole, nil
  8315. }
  8316. // ResetStarrole resets all changes to the "starrole" field.
  8317. func (m *ContactMutation) ResetStarrole() {
  8318. m.starrole = nil
  8319. }
  8320. // SetDontseeit sets the "dontseeit" field.
  8321. func (m *ContactMutation) SetDontseeit(i int) {
  8322. m.dontseeit = &i
  8323. m.adddontseeit = nil
  8324. }
  8325. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8326. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8327. v := m.dontseeit
  8328. if v == nil {
  8329. return
  8330. }
  8331. return *v, true
  8332. }
  8333. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8334. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8336. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8337. if !m.op.Is(OpUpdateOne) {
  8338. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8339. }
  8340. if m.id == nil || m.oldValue == nil {
  8341. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8342. }
  8343. oldValue, err := m.oldValue(ctx)
  8344. if err != nil {
  8345. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8346. }
  8347. return oldValue.Dontseeit, nil
  8348. }
  8349. // AddDontseeit adds i to the "dontseeit" field.
  8350. func (m *ContactMutation) AddDontseeit(i int) {
  8351. if m.adddontseeit != nil {
  8352. *m.adddontseeit += i
  8353. } else {
  8354. m.adddontseeit = &i
  8355. }
  8356. }
  8357. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8358. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8359. v := m.adddontseeit
  8360. if v == nil {
  8361. return
  8362. }
  8363. return *v, true
  8364. }
  8365. // ResetDontseeit resets all changes to the "dontseeit" field.
  8366. func (m *ContactMutation) ResetDontseeit() {
  8367. m.dontseeit = nil
  8368. m.adddontseeit = nil
  8369. }
  8370. // SetDontseeme sets the "dontseeme" field.
  8371. func (m *ContactMutation) SetDontseeme(i int) {
  8372. m.dontseeme = &i
  8373. m.adddontseeme = nil
  8374. }
  8375. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8376. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8377. v := m.dontseeme
  8378. if v == nil {
  8379. return
  8380. }
  8381. return *v, true
  8382. }
  8383. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8384. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8386. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8387. if !m.op.Is(OpUpdateOne) {
  8388. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8389. }
  8390. if m.id == nil || m.oldValue == nil {
  8391. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8392. }
  8393. oldValue, err := m.oldValue(ctx)
  8394. if err != nil {
  8395. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8396. }
  8397. return oldValue.Dontseeme, nil
  8398. }
  8399. // AddDontseeme adds i to the "dontseeme" field.
  8400. func (m *ContactMutation) AddDontseeme(i int) {
  8401. if m.adddontseeme != nil {
  8402. *m.adddontseeme += i
  8403. } else {
  8404. m.adddontseeme = &i
  8405. }
  8406. }
  8407. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8408. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8409. v := m.adddontseeme
  8410. if v == nil {
  8411. return
  8412. }
  8413. return *v, true
  8414. }
  8415. // ResetDontseeme resets all changes to the "dontseeme" field.
  8416. func (m *ContactMutation) ResetDontseeme() {
  8417. m.dontseeme = nil
  8418. m.adddontseeme = nil
  8419. }
  8420. // SetLag sets the "lag" field.
  8421. func (m *ContactMutation) SetLag(s string) {
  8422. m.lag = &s
  8423. }
  8424. // Lag returns the value of the "lag" field in the mutation.
  8425. func (m *ContactMutation) Lag() (r string, exists bool) {
  8426. v := m.lag
  8427. if v == nil {
  8428. return
  8429. }
  8430. return *v, true
  8431. }
  8432. // OldLag returns the old "lag" field's value of the Contact entity.
  8433. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8435. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8436. if !m.op.Is(OpUpdateOne) {
  8437. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8438. }
  8439. if m.id == nil || m.oldValue == nil {
  8440. return v, errors.New("OldLag requires an ID field in the mutation")
  8441. }
  8442. oldValue, err := m.oldValue(ctx)
  8443. if err != nil {
  8444. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8445. }
  8446. return oldValue.Lag, nil
  8447. }
  8448. // ResetLag resets all changes to the "lag" field.
  8449. func (m *ContactMutation) ResetLag() {
  8450. m.lag = nil
  8451. }
  8452. // SetGid sets the "gid" field.
  8453. func (m *ContactMutation) SetGid(s string) {
  8454. m.gid = &s
  8455. }
  8456. // Gid returns the value of the "gid" field in the mutation.
  8457. func (m *ContactMutation) Gid() (r string, exists bool) {
  8458. v := m.gid
  8459. if v == nil {
  8460. return
  8461. }
  8462. return *v, true
  8463. }
  8464. // OldGid returns the old "gid" field's value of the Contact entity.
  8465. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8467. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8468. if !m.op.Is(OpUpdateOne) {
  8469. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8470. }
  8471. if m.id == nil || m.oldValue == nil {
  8472. return v, errors.New("OldGid requires an ID field in the mutation")
  8473. }
  8474. oldValue, err := m.oldValue(ctx)
  8475. if err != nil {
  8476. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8477. }
  8478. return oldValue.Gid, nil
  8479. }
  8480. // ResetGid resets all changes to the "gid" field.
  8481. func (m *ContactMutation) ResetGid() {
  8482. m.gid = nil
  8483. }
  8484. // SetGname sets the "gname" field.
  8485. func (m *ContactMutation) SetGname(s string) {
  8486. m.gname = &s
  8487. }
  8488. // Gname returns the value of the "gname" field in the mutation.
  8489. func (m *ContactMutation) Gname() (r string, exists bool) {
  8490. v := m.gname
  8491. if v == nil {
  8492. return
  8493. }
  8494. return *v, true
  8495. }
  8496. // OldGname returns the old "gname" field's value of the Contact entity.
  8497. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8498. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8499. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8500. if !m.op.Is(OpUpdateOne) {
  8501. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8502. }
  8503. if m.id == nil || m.oldValue == nil {
  8504. return v, errors.New("OldGname requires an ID field in the mutation")
  8505. }
  8506. oldValue, err := m.oldValue(ctx)
  8507. if err != nil {
  8508. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8509. }
  8510. return oldValue.Gname, nil
  8511. }
  8512. // ResetGname resets all changes to the "gname" field.
  8513. func (m *ContactMutation) ResetGname() {
  8514. m.gname = nil
  8515. }
  8516. // SetV3 sets the "v3" field.
  8517. func (m *ContactMutation) SetV3(s string) {
  8518. m.v3 = &s
  8519. }
  8520. // V3 returns the value of the "v3" field in the mutation.
  8521. func (m *ContactMutation) V3() (r string, exists bool) {
  8522. v := m.v3
  8523. if v == nil {
  8524. return
  8525. }
  8526. return *v, true
  8527. }
  8528. // OldV3 returns the old "v3" field's value of the Contact entity.
  8529. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8531. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8532. if !m.op.Is(OpUpdateOne) {
  8533. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8534. }
  8535. if m.id == nil || m.oldValue == nil {
  8536. return v, errors.New("OldV3 requires an ID field in the mutation")
  8537. }
  8538. oldValue, err := m.oldValue(ctx)
  8539. if err != nil {
  8540. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8541. }
  8542. return oldValue.V3, nil
  8543. }
  8544. // ResetV3 resets all changes to the "v3" field.
  8545. func (m *ContactMutation) ResetV3() {
  8546. m.v3 = nil
  8547. }
  8548. // SetOrganizationID sets the "organization_id" field.
  8549. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8550. m.organization_id = &u
  8551. m.addorganization_id = nil
  8552. }
  8553. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8554. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8555. v := m.organization_id
  8556. if v == nil {
  8557. return
  8558. }
  8559. return *v, true
  8560. }
  8561. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8562. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8564. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8565. if !m.op.Is(OpUpdateOne) {
  8566. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8567. }
  8568. if m.id == nil || m.oldValue == nil {
  8569. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8570. }
  8571. oldValue, err := m.oldValue(ctx)
  8572. if err != nil {
  8573. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8574. }
  8575. return oldValue.OrganizationID, nil
  8576. }
  8577. // AddOrganizationID adds u to the "organization_id" field.
  8578. func (m *ContactMutation) AddOrganizationID(u int64) {
  8579. if m.addorganization_id != nil {
  8580. *m.addorganization_id += u
  8581. } else {
  8582. m.addorganization_id = &u
  8583. }
  8584. }
  8585. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8586. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8587. v := m.addorganization_id
  8588. if v == nil {
  8589. return
  8590. }
  8591. return *v, true
  8592. }
  8593. // ClearOrganizationID clears the value of the "organization_id" field.
  8594. func (m *ContactMutation) ClearOrganizationID() {
  8595. m.organization_id = nil
  8596. m.addorganization_id = nil
  8597. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8598. }
  8599. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8600. func (m *ContactMutation) OrganizationIDCleared() bool {
  8601. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8602. return ok
  8603. }
  8604. // ResetOrganizationID resets all changes to the "organization_id" field.
  8605. func (m *ContactMutation) ResetOrganizationID() {
  8606. m.organization_id = nil
  8607. m.addorganization_id = nil
  8608. delete(m.clearedFields, contact.FieldOrganizationID)
  8609. }
  8610. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8611. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8612. if m.contact_relationships == nil {
  8613. m.contact_relationships = make(map[uint64]struct{})
  8614. }
  8615. for i := range ids {
  8616. m.contact_relationships[ids[i]] = struct{}{}
  8617. }
  8618. }
  8619. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8620. func (m *ContactMutation) ClearContactRelationships() {
  8621. m.clearedcontact_relationships = true
  8622. }
  8623. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8624. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8625. return m.clearedcontact_relationships
  8626. }
  8627. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8628. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8629. if m.removedcontact_relationships == nil {
  8630. m.removedcontact_relationships = make(map[uint64]struct{})
  8631. }
  8632. for i := range ids {
  8633. delete(m.contact_relationships, ids[i])
  8634. m.removedcontact_relationships[ids[i]] = struct{}{}
  8635. }
  8636. }
  8637. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8638. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8639. for id := range m.removedcontact_relationships {
  8640. ids = append(ids, id)
  8641. }
  8642. return
  8643. }
  8644. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8645. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8646. for id := range m.contact_relationships {
  8647. ids = append(ids, id)
  8648. }
  8649. return
  8650. }
  8651. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8652. func (m *ContactMutation) ResetContactRelationships() {
  8653. m.contact_relationships = nil
  8654. m.clearedcontact_relationships = false
  8655. m.removedcontact_relationships = nil
  8656. }
  8657. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8658. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8659. if m.contact_messages == nil {
  8660. m.contact_messages = make(map[uint64]struct{})
  8661. }
  8662. for i := range ids {
  8663. m.contact_messages[ids[i]] = struct{}{}
  8664. }
  8665. }
  8666. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8667. func (m *ContactMutation) ClearContactMessages() {
  8668. m.clearedcontact_messages = true
  8669. }
  8670. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8671. func (m *ContactMutation) ContactMessagesCleared() bool {
  8672. return m.clearedcontact_messages
  8673. }
  8674. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8675. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8676. if m.removedcontact_messages == nil {
  8677. m.removedcontact_messages = make(map[uint64]struct{})
  8678. }
  8679. for i := range ids {
  8680. delete(m.contact_messages, ids[i])
  8681. m.removedcontact_messages[ids[i]] = struct{}{}
  8682. }
  8683. }
  8684. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8685. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8686. for id := range m.removedcontact_messages {
  8687. ids = append(ids, id)
  8688. }
  8689. return
  8690. }
  8691. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8692. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8693. for id := range m.contact_messages {
  8694. ids = append(ids, id)
  8695. }
  8696. return
  8697. }
  8698. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8699. func (m *ContactMutation) ResetContactMessages() {
  8700. m.contact_messages = nil
  8701. m.clearedcontact_messages = false
  8702. m.removedcontact_messages = nil
  8703. }
  8704. // Where appends a list predicates to the ContactMutation builder.
  8705. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8706. m.predicates = append(m.predicates, ps...)
  8707. }
  8708. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8709. // users can use type-assertion to append predicates that do not depend on any generated package.
  8710. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8711. p := make([]predicate.Contact, len(ps))
  8712. for i := range ps {
  8713. p[i] = ps[i]
  8714. }
  8715. m.Where(p...)
  8716. }
  8717. // Op returns the operation name.
  8718. func (m *ContactMutation) Op() Op {
  8719. return m.op
  8720. }
  8721. // SetOp allows setting the mutation operation.
  8722. func (m *ContactMutation) SetOp(op Op) {
  8723. m.op = op
  8724. }
  8725. // Type returns the node type of this mutation (Contact).
  8726. func (m *ContactMutation) Type() string {
  8727. return m.typ
  8728. }
  8729. // Fields returns all fields that were changed during this mutation. Note that in
  8730. // order to get all numeric fields that were incremented/decremented, call
  8731. // AddedFields().
  8732. func (m *ContactMutation) Fields() []string {
  8733. fields := make([]string, 0, 20)
  8734. if m.created_at != nil {
  8735. fields = append(fields, contact.FieldCreatedAt)
  8736. }
  8737. if m.updated_at != nil {
  8738. fields = append(fields, contact.FieldUpdatedAt)
  8739. }
  8740. if m.status != nil {
  8741. fields = append(fields, contact.FieldStatus)
  8742. }
  8743. if m.deleted_at != nil {
  8744. fields = append(fields, contact.FieldDeletedAt)
  8745. }
  8746. if m.wx_wxid != nil {
  8747. fields = append(fields, contact.FieldWxWxid)
  8748. }
  8749. if m._type != nil {
  8750. fields = append(fields, contact.FieldType)
  8751. }
  8752. if m.wxid != nil {
  8753. fields = append(fields, contact.FieldWxid)
  8754. }
  8755. if m.account != nil {
  8756. fields = append(fields, contact.FieldAccount)
  8757. }
  8758. if m.nickname != nil {
  8759. fields = append(fields, contact.FieldNickname)
  8760. }
  8761. if m.markname != nil {
  8762. fields = append(fields, contact.FieldMarkname)
  8763. }
  8764. if m.headimg != nil {
  8765. fields = append(fields, contact.FieldHeadimg)
  8766. }
  8767. if m.sex != nil {
  8768. fields = append(fields, contact.FieldSex)
  8769. }
  8770. if m.starrole != nil {
  8771. fields = append(fields, contact.FieldStarrole)
  8772. }
  8773. if m.dontseeit != nil {
  8774. fields = append(fields, contact.FieldDontseeit)
  8775. }
  8776. if m.dontseeme != nil {
  8777. fields = append(fields, contact.FieldDontseeme)
  8778. }
  8779. if m.lag != nil {
  8780. fields = append(fields, contact.FieldLag)
  8781. }
  8782. if m.gid != nil {
  8783. fields = append(fields, contact.FieldGid)
  8784. }
  8785. if m.gname != nil {
  8786. fields = append(fields, contact.FieldGname)
  8787. }
  8788. if m.v3 != nil {
  8789. fields = append(fields, contact.FieldV3)
  8790. }
  8791. if m.organization_id != nil {
  8792. fields = append(fields, contact.FieldOrganizationID)
  8793. }
  8794. return fields
  8795. }
  8796. // Field returns the value of a field with the given name. The second boolean
  8797. // return value indicates that this field was not set, or was not defined in the
  8798. // schema.
  8799. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8800. switch name {
  8801. case contact.FieldCreatedAt:
  8802. return m.CreatedAt()
  8803. case contact.FieldUpdatedAt:
  8804. return m.UpdatedAt()
  8805. case contact.FieldStatus:
  8806. return m.Status()
  8807. case contact.FieldDeletedAt:
  8808. return m.DeletedAt()
  8809. case contact.FieldWxWxid:
  8810. return m.WxWxid()
  8811. case contact.FieldType:
  8812. return m.GetType()
  8813. case contact.FieldWxid:
  8814. return m.Wxid()
  8815. case contact.FieldAccount:
  8816. return m.Account()
  8817. case contact.FieldNickname:
  8818. return m.Nickname()
  8819. case contact.FieldMarkname:
  8820. return m.Markname()
  8821. case contact.FieldHeadimg:
  8822. return m.Headimg()
  8823. case contact.FieldSex:
  8824. return m.Sex()
  8825. case contact.FieldStarrole:
  8826. return m.Starrole()
  8827. case contact.FieldDontseeit:
  8828. return m.Dontseeit()
  8829. case contact.FieldDontseeme:
  8830. return m.Dontseeme()
  8831. case contact.FieldLag:
  8832. return m.Lag()
  8833. case contact.FieldGid:
  8834. return m.Gid()
  8835. case contact.FieldGname:
  8836. return m.Gname()
  8837. case contact.FieldV3:
  8838. return m.V3()
  8839. case contact.FieldOrganizationID:
  8840. return m.OrganizationID()
  8841. }
  8842. return nil, false
  8843. }
  8844. // OldField returns the old value of the field from the database. An error is
  8845. // returned if the mutation operation is not UpdateOne, or the query to the
  8846. // database failed.
  8847. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8848. switch name {
  8849. case contact.FieldCreatedAt:
  8850. return m.OldCreatedAt(ctx)
  8851. case contact.FieldUpdatedAt:
  8852. return m.OldUpdatedAt(ctx)
  8853. case contact.FieldStatus:
  8854. return m.OldStatus(ctx)
  8855. case contact.FieldDeletedAt:
  8856. return m.OldDeletedAt(ctx)
  8857. case contact.FieldWxWxid:
  8858. return m.OldWxWxid(ctx)
  8859. case contact.FieldType:
  8860. return m.OldType(ctx)
  8861. case contact.FieldWxid:
  8862. return m.OldWxid(ctx)
  8863. case contact.FieldAccount:
  8864. return m.OldAccount(ctx)
  8865. case contact.FieldNickname:
  8866. return m.OldNickname(ctx)
  8867. case contact.FieldMarkname:
  8868. return m.OldMarkname(ctx)
  8869. case contact.FieldHeadimg:
  8870. return m.OldHeadimg(ctx)
  8871. case contact.FieldSex:
  8872. return m.OldSex(ctx)
  8873. case contact.FieldStarrole:
  8874. return m.OldStarrole(ctx)
  8875. case contact.FieldDontseeit:
  8876. return m.OldDontseeit(ctx)
  8877. case contact.FieldDontseeme:
  8878. return m.OldDontseeme(ctx)
  8879. case contact.FieldLag:
  8880. return m.OldLag(ctx)
  8881. case contact.FieldGid:
  8882. return m.OldGid(ctx)
  8883. case contact.FieldGname:
  8884. return m.OldGname(ctx)
  8885. case contact.FieldV3:
  8886. return m.OldV3(ctx)
  8887. case contact.FieldOrganizationID:
  8888. return m.OldOrganizationID(ctx)
  8889. }
  8890. return nil, fmt.Errorf("unknown Contact field %s", name)
  8891. }
  8892. // SetField sets the value of a field with the given name. It returns an error if
  8893. // the field is not defined in the schema, or if the type mismatched the field
  8894. // type.
  8895. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8896. switch name {
  8897. case contact.FieldCreatedAt:
  8898. v, ok := value.(time.Time)
  8899. if !ok {
  8900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8901. }
  8902. m.SetCreatedAt(v)
  8903. return nil
  8904. case contact.FieldUpdatedAt:
  8905. v, ok := value.(time.Time)
  8906. if !ok {
  8907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8908. }
  8909. m.SetUpdatedAt(v)
  8910. return nil
  8911. case contact.FieldStatus:
  8912. v, ok := value.(uint8)
  8913. if !ok {
  8914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8915. }
  8916. m.SetStatus(v)
  8917. return nil
  8918. case contact.FieldDeletedAt:
  8919. v, ok := value.(time.Time)
  8920. if !ok {
  8921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8922. }
  8923. m.SetDeletedAt(v)
  8924. return nil
  8925. case contact.FieldWxWxid:
  8926. v, ok := value.(string)
  8927. if !ok {
  8928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8929. }
  8930. m.SetWxWxid(v)
  8931. return nil
  8932. case contact.FieldType:
  8933. v, ok := value.(int)
  8934. if !ok {
  8935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8936. }
  8937. m.SetType(v)
  8938. return nil
  8939. case contact.FieldWxid:
  8940. v, ok := value.(string)
  8941. if !ok {
  8942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8943. }
  8944. m.SetWxid(v)
  8945. return nil
  8946. case contact.FieldAccount:
  8947. v, ok := value.(string)
  8948. if !ok {
  8949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8950. }
  8951. m.SetAccount(v)
  8952. return nil
  8953. case contact.FieldNickname:
  8954. v, ok := value.(string)
  8955. if !ok {
  8956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8957. }
  8958. m.SetNickname(v)
  8959. return nil
  8960. case contact.FieldMarkname:
  8961. v, ok := value.(string)
  8962. if !ok {
  8963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8964. }
  8965. m.SetMarkname(v)
  8966. return nil
  8967. case contact.FieldHeadimg:
  8968. v, ok := value.(string)
  8969. if !ok {
  8970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8971. }
  8972. m.SetHeadimg(v)
  8973. return nil
  8974. case contact.FieldSex:
  8975. v, ok := value.(int)
  8976. if !ok {
  8977. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8978. }
  8979. m.SetSex(v)
  8980. return nil
  8981. case contact.FieldStarrole:
  8982. v, ok := value.(string)
  8983. if !ok {
  8984. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8985. }
  8986. m.SetStarrole(v)
  8987. return nil
  8988. case contact.FieldDontseeit:
  8989. v, ok := value.(int)
  8990. if !ok {
  8991. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8992. }
  8993. m.SetDontseeit(v)
  8994. return nil
  8995. case contact.FieldDontseeme:
  8996. v, ok := value.(int)
  8997. if !ok {
  8998. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8999. }
  9000. m.SetDontseeme(v)
  9001. return nil
  9002. case contact.FieldLag:
  9003. v, ok := value.(string)
  9004. if !ok {
  9005. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9006. }
  9007. m.SetLag(v)
  9008. return nil
  9009. case contact.FieldGid:
  9010. v, ok := value.(string)
  9011. if !ok {
  9012. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9013. }
  9014. m.SetGid(v)
  9015. return nil
  9016. case contact.FieldGname:
  9017. v, ok := value.(string)
  9018. if !ok {
  9019. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9020. }
  9021. m.SetGname(v)
  9022. return nil
  9023. case contact.FieldV3:
  9024. v, ok := value.(string)
  9025. if !ok {
  9026. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9027. }
  9028. m.SetV3(v)
  9029. return nil
  9030. case contact.FieldOrganizationID:
  9031. v, ok := value.(uint64)
  9032. if !ok {
  9033. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9034. }
  9035. m.SetOrganizationID(v)
  9036. return nil
  9037. }
  9038. return fmt.Errorf("unknown Contact field %s", name)
  9039. }
  9040. // AddedFields returns all numeric fields that were incremented/decremented during
  9041. // this mutation.
  9042. func (m *ContactMutation) AddedFields() []string {
  9043. var fields []string
  9044. if m.addstatus != nil {
  9045. fields = append(fields, contact.FieldStatus)
  9046. }
  9047. if m.add_type != nil {
  9048. fields = append(fields, contact.FieldType)
  9049. }
  9050. if m.addsex != nil {
  9051. fields = append(fields, contact.FieldSex)
  9052. }
  9053. if m.adddontseeit != nil {
  9054. fields = append(fields, contact.FieldDontseeit)
  9055. }
  9056. if m.adddontseeme != nil {
  9057. fields = append(fields, contact.FieldDontseeme)
  9058. }
  9059. if m.addorganization_id != nil {
  9060. fields = append(fields, contact.FieldOrganizationID)
  9061. }
  9062. return fields
  9063. }
  9064. // AddedField returns the numeric value that was incremented/decremented on a field
  9065. // with the given name. The second boolean return value indicates that this field
  9066. // was not set, or was not defined in the schema.
  9067. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  9068. switch name {
  9069. case contact.FieldStatus:
  9070. return m.AddedStatus()
  9071. case contact.FieldType:
  9072. return m.AddedType()
  9073. case contact.FieldSex:
  9074. return m.AddedSex()
  9075. case contact.FieldDontseeit:
  9076. return m.AddedDontseeit()
  9077. case contact.FieldDontseeme:
  9078. return m.AddedDontseeme()
  9079. case contact.FieldOrganizationID:
  9080. return m.AddedOrganizationID()
  9081. }
  9082. return nil, false
  9083. }
  9084. // AddField adds the value to the field with the given name. It returns an error if
  9085. // the field is not defined in the schema, or if the type mismatched the field
  9086. // type.
  9087. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9088. switch name {
  9089. case contact.FieldStatus:
  9090. v, ok := value.(int8)
  9091. if !ok {
  9092. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9093. }
  9094. m.AddStatus(v)
  9095. return nil
  9096. case contact.FieldType:
  9097. v, ok := value.(int)
  9098. if !ok {
  9099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9100. }
  9101. m.AddType(v)
  9102. return nil
  9103. case contact.FieldSex:
  9104. v, ok := value.(int)
  9105. if !ok {
  9106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9107. }
  9108. m.AddSex(v)
  9109. return nil
  9110. case contact.FieldDontseeit:
  9111. v, ok := value.(int)
  9112. if !ok {
  9113. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9114. }
  9115. m.AddDontseeit(v)
  9116. return nil
  9117. case contact.FieldDontseeme:
  9118. v, ok := value.(int)
  9119. if !ok {
  9120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9121. }
  9122. m.AddDontseeme(v)
  9123. return nil
  9124. case contact.FieldOrganizationID:
  9125. v, ok := value.(int64)
  9126. if !ok {
  9127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9128. }
  9129. m.AddOrganizationID(v)
  9130. return nil
  9131. }
  9132. return fmt.Errorf("unknown Contact numeric field %s", name)
  9133. }
  9134. // ClearedFields returns all nullable fields that were cleared during this
  9135. // mutation.
  9136. func (m *ContactMutation) ClearedFields() []string {
  9137. var fields []string
  9138. if m.FieldCleared(contact.FieldStatus) {
  9139. fields = append(fields, contact.FieldStatus)
  9140. }
  9141. if m.FieldCleared(contact.FieldDeletedAt) {
  9142. fields = append(fields, contact.FieldDeletedAt)
  9143. }
  9144. if m.FieldCleared(contact.FieldType) {
  9145. fields = append(fields, contact.FieldType)
  9146. }
  9147. if m.FieldCleared(contact.FieldOrganizationID) {
  9148. fields = append(fields, contact.FieldOrganizationID)
  9149. }
  9150. return fields
  9151. }
  9152. // FieldCleared returns a boolean indicating if a field with the given name was
  9153. // cleared in this mutation.
  9154. func (m *ContactMutation) FieldCleared(name string) bool {
  9155. _, ok := m.clearedFields[name]
  9156. return ok
  9157. }
  9158. // ClearField clears the value of the field with the given name. It returns an
  9159. // error if the field is not defined in the schema.
  9160. func (m *ContactMutation) ClearField(name string) error {
  9161. switch name {
  9162. case contact.FieldStatus:
  9163. m.ClearStatus()
  9164. return nil
  9165. case contact.FieldDeletedAt:
  9166. m.ClearDeletedAt()
  9167. return nil
  9168. case contact.FieldType:
  9169. m.ClearType()
  9170. return nil
  9171. case contact.FieldOrganizationID:
  9172. m.ClearOrganizationID()
  9173. return nil
  9174. }
  9175. return fmt.Errorf("unknown Contact nullable field %s", name)
  9176. }
  9177. // ResetField resets all changes in the mutation for the field with the given name.
  9178. // It returns an error if the field is not defined in the schema.
  9179. func (m *ContactMutation) ResetField(name string) error {
  9180. switch name {
  9181. case contact.FieldCreatedAt:
  9182. m.ResetCreatedAt()
  9183. return nil
  9184. case contact.FieldUpdatedAt:
  9185. m.ResetUpdatedAt()
  9186. return nil
  9187. case contact.FieldStatus:
  9188. m.ResetStatus()
  9189. return nil
  9190. case contact.FieldDeletedAt:
  9191. m.ResetDeletedAt()
  9192. return nil
  9193. case contact.FieldWxWxid:
  9194. m.ResetWxWxid()
  9195. return nil
  9196. case contact.FieldType:
  9197. m.ResetType()
  9198. return nil
  9199. case contact.FieldWxid:
  9200. m.ResetWxid()
  9201. return nil
  9202. case contact.FieldAccount:
  9203. m.ResetAccount()
  9204. return nil
  9205. case contact.FieldNickname:
  9206. m.ResetNickname()
  9207. return nil
  9208. case contact.FieldMarkname:
  9209. m.ResetMarkname()
  9210. return nil
  9211. case contact.FieldHeadimg:
  9212. m.ResetHeadimg()
  9213. return nil
  9214. case contact.FieldSex:
  9215. m.ResetSex()
  9216. return nil
  9217. case contact.FieldStarrole:
  9218. m.ResetStarrole()
  9219. return nil
  9220. case contact.FieldDontseeit:
  9221. m.ResetDontseeit()
  9222. return nil
  9223. case contact.FieldDontseeme:
  9224. m.ResetDontseeme()
  9225. return nil
  9226. case contact.FieldLag:
  9227. m.ResetLag()
  9228. return nil
  9229. case contact.FieldGid:
  9230. m.ResetGid()
  9231. return nil
  9232. case contact.FieldGname:
  9233. m.ResetGname()
  9234. return nil
  9235. case contact.FieldV3:
  9236. m.ResetV3()
  9237. return nil
  9238. case contact.FieldOrganizationID:
  9239. m.ResetOrganizationID()
  9240. return nil
  9241. }
  9242. return fmt.Errorf("unknown Contact field %s", name)
  9243. }
  9244. // AddedEdges returns all edge names that were set/added in this mutation.
  9245. func (m *ContactMutation) AddedEdges() []string {
  9246. edges := make([]string, 0, 2)
  9247. if m.contact_relationships != nil {
  9248. edges = append(edges, contact.EdgeContactRelationships)
  9249. }
  9250. if m.contact_messages != nil {
  9251. edges = append(edges, contact.EdgeContactMessages)
  9252. }
  9253. return edges
  9254. }
  9255. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9256. // name in this mutation.
  9257. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9258. switch name {
  9259. case contact.EdgeContactRelationships:
  9260. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9261. for id := range m.contact_relationships {
  9262. ids = append(ids, id)
  9263. }
  9264. return ids
  9265. case contact.EdgeContactMessages:
  9266. ids := make([]ent.Value, 0, len(m.contact_messages))
  9267. for id := range m.contact_messages {
  9268. ids = append(ids, id)
  9269. }
  9270. return ids
  9271. }
  9272. return nil
  9273. }
  9274. // RemovedEdges returns all edge names that were removed in this mutation.
  9275. func (m *ContactMutation) RemovedEdges() []string {
  9276. edges := make([]string, 0, 2)
  9277. if m.removedcontact_relationships != nil {
  9278. edges = append(edges, contact.EdgeContactRelationships)
  9279. }
  9280. if m.removedcontact_messages != nil {
  9281. edges = append(edges, contact.EdgeContactMessages)
  9282. }
  9283. return edges
  9284. }
  9285. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9286. // the given name in this mutation.
  9287. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9288. switch name {
  9289. case contact.EdgeContactRelationships:
  9290. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9291. for id := range m.removedcontact_relationships {
  9292. ids = append(ids, id)
  9293. }
  9294. return ids
  9295. case contact.EdgeContactMessages:
  9296. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9297. for id := range m.removedcontact_messages {
  9298. ids = append(ids, id)
  9299. }
  9300. return ids
  9301. }
  9302. return nil
  9303. }
  9304. // ClearedEdges returns all edge names that were cleared in this mutation.
  9305. func (m *ContactMutation) ClearedEdges() []string {
  9306. edges := make([]string, 0, 2)
  9307. if m.clearedcontact_relationships {
  9308. edges = append(edges, contact.EdgeContactRelationships)
  9309. }
  9310. if m.clearedcontact_messages {
  9311. edges = append(edges, contact.EdgeContactMessages)
  9312. }
  9313. return edges
  9314. }
  9315. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9316. // was cleared in this mutation.
  9317. func (m *ContactMutation) EdgeCleared(name string) bool {
  9318. switch name {
  9319. case contact.EdgeContactRelationships:
  9320. return m.clearedcontact_relationships
  9321. case contact.EdgeContactMessages:
  9322. return m.clearedcontact_messages
  9323. }
  9324. return false
  9325. }
  9326. // ClearEdge clears the value of the edge with the given name. It returns an error
  9327. // if that edge is not defined in the schema.
  9328. func (m *ContactMutation) ClearEdge(name string) error {
  9329. switch name {
  9330. }
  9331. return fmt.Errorf("unknown Contact unique edge %s", name)
  9332. }
  9333. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9334. // It returns an error if the edge is not defined in the schema.
  9335. func (m *ContactMutation) ResetEdge(name string) error {
  9336. switch name {
  9337. case contact.EdgeContactRelationships:
  9338. m.ResetContactRelationships()
  9339. return nil
  9340. case contact.EdgeContactMessages:
  9341. m.ResetContactMessages()
  9342. return nil
  9343. }
  9344. return fmt.Errorf("unknown Contact edge %s", name)
  9345. }
  9346. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9347. type CreditBalanceMutation struct {
  9348. config
  9349. op Op
  9350. typ string
  9351. id *uint64
  9352. created_at *time.Time
  9353. updated_at *time.Time
  9354. deleted_at *time.Time
  9355. user_id *string
  9356. balance *float32
  9357. addbalance *float32
  9358. status *int
  9359. addstatus *int
  9360. organization_id *uint64
  9361. addorganization_id *int64
  9362. clearedFields map[string]struct{}
  9363. done bool
  9364. oldValue func(context.Context) (*CreditBalance, error)
  9365. predicates []predicate.CreditBalance
  9366. }
  9367. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9368. // creditbalanceOption allows management of the mutation configuration using functional options.
  9369. type creditbalanceOption func(*CreditBalanceMutation)
  9370. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9371. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9372. m := &CreditBalanceMutation{
  9373. config: c,
  9374. op: op,
  9375. typ: TypeCreditBalance,
  9376. clearedFields: make(map[string]struct{}),
  9377. }
  9378. for _, opt := range opts {
  9379. opt(m)
  9380. }
  9381. return m
  9382. }
  9383. // withCreditBalanceID sets the ID field of the mutation.
  9384. func withCreditBalanceID(id uint64) creditbalanceOption {
  9385. return func(m *CreditBalanceMutation) {
  9386. var (
  9387. err error
  9388. once sync.Once
  9389. value *CreditBalance
  9390. )
  9391. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9392. once.Do(func() {
  9393. if m.done {
  9394. err = errors.New("querying old values post mutation is not allowed")
  9395. } else {
  9396. value, err = m.Client().CreditBalance.Get(ctx, id)
  9397. }
  9398. })
  9399. return value, err
  9400. }
  9401. m.id = &id
  9402. }
  9403. }
  9404. // withCreditBalance sets the old CreditBalance of the mutation.
  9405. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9406. return func(m *CreditBalanceMutation) {
  9407. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9408. return node, nil
  9409. }
  9410. m.id = &node.ID
  9411. }
  9412. }
  9413. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9414. // executed in a transaction (ent.Tx), a transactional client is returned.
  9415. func (m CreditBalanceMutation) Client() *Client {
  9416. client := &Client{config: m.config}
  9417. client.init()
  9418. return client
  9419. }
  9420. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9421. // it returns an error otherwise.
  9422. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9423. if _, ok := m.driver.(*txDriver); !ok {
  9424. return nil, errors.New("ent: mutation is not running in a transaction")
  9425. }
  9426. tx := &Tx{config: m.config}
  9427. tx.init()
  9428. return tx, nil
  9429. }
  9430. // SetID sets the value of the id field. Note that this
  9431. // operation is only accepted on creation of CreditBalance entities.
  9432. func (m *CreditBalanceMutation) SetID(id uint64) {
  9433. m.id = &id
  9434. }
  9435. // ID returns the ID value in the mutation. Note that the ID is only available
  9436. // if it was provided to the builder or after it was returned from the database.
  9437. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9438. if m.id == nil {
  9439. return
  9440. }
  9441. return *m.id, true
  9442. }
  9443. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9444. // That means, if the mutation is applied within a transaction with an isolation level such
  9445. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9446. // or updated by the mutation.
  9447. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9448. switch {
  9449. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9450. id, exists := m.ID()
  9451. if exists {
  9452. return []uint64{id}, nil
  9453. }
  9454. fallthrough
  9455. case m.op.Is(OpUpdate | OpDelete):
  9456. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9457. default:
  9458. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9459. }
  9460. }
  9461. // SetCreatedAt sets the "created_at" field.
  9462. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9463. m.created_at = &t
  9464. }
  9465. // CreatedAt returns the value of the "created_at" field in the mutation.
  9466. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9467. v := m.created_at
  9468. if v == nil {
  9469. return
  9470. }
  9471. return *v, true
  9472. }
  9473. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9474. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9475. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9476. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9477. if !m.op.Is(OpUpdateOne) {
  9478. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9479. }
  9480. if m.id == nil || m.oldValue == nil {
  9481. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9482. }
  9483. oldValue, err := m.oldValue(ctx)
  9484. if err != nil {
  9485. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9486. }
  9487. return oldValue.CreatedAt, nil
  9488. }
  9489. // ResetCreatedAt resets all changes to the "created_at" field.
  9490. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9491. m.created_at = nil
  9492. }
  9493. // SetUpdatedAt sets the "updated_at" field.
  9494. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9495. m.updated_at = &t
  9496. }
  9497. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9498. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9499. v := m.updated_at
  9500. if v == nil {
  9501. return
  9502. }
  9503. return *v, true
  9504. }
  9505. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9506. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9507. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9508. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9509. if !m.op.Is(OpUpdateOne) {
  9510. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9511. }
  9512. if m.id == nil || m.oldValue == nil {
  9513. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9514. }
  9515. oldValue, err := m.oldValue(ctx)
  9516. if err != nil {
  9517. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9518. }
  9519. return oldValue.UpdatedAt, nil
  9520. }
  9521. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9522. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9523. m.updated_at = nil
  9524. }
  9525. // SetDeletedAt sets the "deleted_at" field.
  9526. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9527. m.deleted_at = &t
  9528. }
  9529. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9530. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9531. v := m.deleted_at
  9532. if v == nil {
  9533. return
  9534. }
  9535. return *v, true
  9536. }
  9537. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9538. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9540. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9541. if !m.op.Is(OpUpdateOne) {
  9542. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9543. }
  9544. if m.id == nil || m.oldValue == nil {
  9545. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9546. }
  9547. oldValue, err := m.oldValue(ctx)
  9548. if err != nil {
  9549. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9550. }
  9551. return oldValue.DeletedAt, nil
  9552. }
  9553. // ClearDeletedAt clears the value of the "deleted_at" field.
  9554. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9555. m.deleted_at = nil
  9556. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9557. }
  9558. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9559. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9560. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9561. return ok
  9562. }
  9563. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9564. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9565. m.deleted_at = nil
  9566. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9567. }
  9568. // SetUserID sets the "user_id" field.
  9569. func (m *CreditBalanceMutation) SetUserID(s string) {
  9570. m.user_id = &s
  9571. }
  9572. // UserID returns the value of the "user_id" field in the mutation.
  9573. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9574. v := m.user_id
  9575. if v == nil {
  9576. return
  9577. }
  9578. return *v, true
  9579. }
  9580. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9581. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9582. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9583. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9584. if !m.op.Is(OpUpdateOne) {
  9585. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9586. }
  9587. if m.id == nil || m.oldValue == nil {
  9588. return v, errors.New("OldUserID requires an ID field in the mutation")
  9589. }
  9590. oldValue, err := m.oldValue(ctx)
  9591. if err != nil {
  9592. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9593. }
  9594. return oldValue.UserID, nil
  9595. }
  9596. // ResetUserID resets all changes to the "user_id" field.
  9597. func (m *CreditBalanceMutation) ResetUserID() {
  9598. m.user_id = nil
  9599. }
  9600. // SetBalance sets the "balance" field.
  9601. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9602. m.balance = &f
  9603. m.addbalance = nil
  9604. }
  9605. // Balance returns the value of the "balance" field in the mutation.
  9606. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9607. v := m.balance
  9608. if v == nil {
  9609. return
  9610. }
  9611. return *v, true
  9612. }
  9613. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9614. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9615. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9616. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9617. if !m.op.Is(OpUpdateOne) {
  9618. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9619. }
  9620. if m.id == nil || m.oldValue == nil {
  9621. return v, errors.New("OldBalance requires an ID field in the mutation")
  9622. }
  9623. oldValue, err := m.oldValue(ctx)
  9624. if err != nil {
  9625. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9626. }
  9627. return oldValue.Balance, nil
  9628. }
  9629. // AddBalance adds f to the "balance" field.
  9630. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9631. if m.addbalance != nil {
  9632. *m.addbalance += f
  9633. } else {
  9634. m.addbalance = &f
  9635. }
  9636. }
  9637. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9638. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9639. v := m.addbalance
  9640. if v == nil {
  9641. return
  9642. }
  9643. return *v, true
  9644. }
  9645. // ResetBalance resets all changes to the "balance" field.
  9646. func (m *CreditBalanceMutation) ResetBalance() {
  9647. m.balance = nil
  9648. m.addbalance = nil
  9649. }
  9650. // SetStatus sets the "status" field.
  9651. func (m *CreditBalanceMutation) SetStatus(i int) {
  9652. m.status = &i
  9653. m.addstatus = nil
  9654. }
  9655. // Status returns the value of the "status" field in the mutation.
  9656. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9657. v := m.status
  9658. if v == nil {
  9659. return
  9660. }
  9661. return *v, true
  9662. }
  9663. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9664. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9666. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9667. if !m.op.Is(OpUpdateOne) {
  9668. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9669. }
  9670. if m.id == nil || m.oldValue == nil {
  9671. return v, errors.New("OldStatus requires an ID field in the mutation")
  9672. }
  9673. oldValue, err := m.oldValue(ctx)
  9674. if err != nil {
  9675. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9676. }
  9677. return oldValue.Status, nil
  9678. }
  9679. // AddStatus adds i to the "status" field.
  9680. func (m *CreditBalanceMutation) AddStatus(i int) {
  9681. if m.addstatus != nil {
  9682. *m.addstatus += i
  9683. } else {
  9684. m.addstatus = &i
  9685. }
  9686. }
  9687. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9688. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9689. v := m.addstatus
  9690. if v == nil {
  9691. return
  9692. }
  9693. return *v, true
  9694. }
  9695. // ClearStatus clears the value of the "status" field.
  9696. func (m *CreditBalanceMutation) ClearStatus() {
  9697. m.status = nil
  9698. m.addstatus = nil
  9699. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9700. }
  9701. // StatusCleared returns if the "status" field was cleared in this mutation.
  9702. func (m *CreditBalanceMutation) StatusCleared() bool {
  9703. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9704. return ok
  9705. }
  9706. // ResetStatus resets all changes to the "status" field.
  9707. func (m *CreditBalanceMutation) ResetStatus() {
  9708. m.status = nil
  9709. m.addstatus = nil
  9710. delete(m.clearedFields, creditbalance.FieldStatus)
  9711. }
  9712. // SetOrganizationID sets the "organization_id" field.
  9713. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9714. m.organization_id = &u
  9715. m.addorganization_id = nil
  9716. }
  9717. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9718. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9719. v := m.organization_id
  9720. if v == nil {
  9721. return
  9722. }
  9723. return *v, true
  9724. }
  9725. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9726. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9727. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9728. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9729. if !m.op.Is(OpUpdateOne) {
  9730. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9731. }
  9732. if m.id == nil || m.oldValue == nil {
  9733. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9734. }
  9735. oldValue, err := m.oldValue(ctx)
  9736. if err != nil {
  9737. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9738. }
  9739. return oldValue.OrganizationID, nil
  9740. }
  9741. // AddOrganizationID adds u to the "organization_id" field.
  9742. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9743. if m.addorganization_id != nil {
  9744. *m.addorganization_id += u
  9745. } else {
  9746. m.addorganization_id = &u
  9747. }
  9748. }
  9749. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9750. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9751. v := m.addorganization_id
  9752. if v == nil {
  9753. return
  9754. }
  9755. return *v, true
  9756. }
  9757. // ClearOrganizationID clears the value of the "organization_id" field.
  9758. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9759. m.organization_id = nil
  9760. m.addorganization_id = nil
  9761. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9762. }
  9763. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9764. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9765. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9766. return ok
  9767. }
  9768. // ResetOrganizationID resets all changes to the "organization_id" field.
  9769. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9770. m.organization_id = nil
  9771. m.addorganization_id = nil
  9772. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9773. }
  9774. // Where appends a list predicates to the CreditBalanceMutation builder.
  9775. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9776. m.predicates = append(m.predicates, ps...)
  9777. }
  9778. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9779. // users can use type-assertion to append predicates that do not depend on any generated package.
  9780. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9781. p := make([]predicate.CreditBalance, len(ps))
  9782. for i := range ps {
  9783. p[i] = ps[i]
  9784. }
  9785. m.Where(p...)
  9786. }
  9787. // Op returns the operation name.
  9788. func (m *CreditBalanceMutation) Op() Op {
  9789. return m.op
  9790. }
  9791. // SetOp allows setting the mutation operation.
  9792. func (m *CreditBalanceMutation) SetOp(op Op) {
  9793. m.op = op
  9794. }
  9795. // Type returns the node type of this mutation (CreditBalance).
  9796. func (m *CreditBalanceMutation) Type() string {
  9797. return m.typ
  9798. }
  9799. // Fields returns all fields that were changed during this mutation. Note that in
  9800. // order to get all numeric fields that were incremented/decremented, call
  9801. // AddedFields().
  9802. func (m *CreditBalanceMutation) Fields() []string {
  9803. fields := make([]string, 0, 7)
  9804. if m.created_at != nil {
  9805. fields = append(fields, creditbalance.FieldCreatedAt)
  9806. }
  9807. if m.updated_at != nil {
  9808. fields = append(fields, creditbalance.FieldUpdatedAt)
  9809. }
  9810. if m.deleted_at != nil {
  9811. fields = append(fields, creditbalance.FieldDeletedAt)
  9812. }
  9813. if m.user_id != nil {
  9814. fields = append(fields, creditbalance.FieldUserID)
  9815. }
  9816. if m.balance != nil {
  9817. fields = append(fields, creditbalance.FieldBalance)
  9818. }
  9819. if m.status != nil {
  9820. fields = append(fields, creditbalance.FieldStatus)
  9821. }
  9822. if m.organization_id != nil {
  9823. fields = append(fields, creditbalance.FieldOrganizationID)
  9824. }
  9825. return fields
  9826. }
  9827. // Field returns the value of a field with the given name. The second boolean
  9828. // return value indicates that this field was not set, or was not defined in the
  9829. // schema.
  9830. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9831. switch name {
  9832. case creditbalance.FieldCreatedAt:
  9833. return m.CreatedAt()
  9834. case creditbalance.FieldUpdatedAt:
  9835. return m.UpdatedAt()
  9836. case creditbalance.FieldDeletedAt:
  9837. return m.DeletedAt()
  9838. case creditbalance.FieldUserID:
  9839. return m.UserID()
  9840. case creditbalance.FieldBalance:
  9841. return m.Balance()
  9842. case creditbalance.FieldStatus:
  9843. return m.Status()
  9844. case creditbalance.FieldOrganizationID:
  9845. return m.OrganizationID()
  9846. }
  9847. return nil, false
  9848. }
  9849. // OldField returns the old value of the field from the database. An error is
  9850. // returned if the mutation operation is not UpdateOne, or the query to the
  9851. // database failed.
  9852. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9853. switch name {
  9854. case creditbalance.FieldCreatedAt:
  9855. return m.OldCreatedAt(ctx)
  9856. case creditbalance.FieldUpdatedAt:
  9857. return m.OldUpdatedAt(ctx)
  9858. case creditbalance.FieldDeletedAt:
  9859. return m.OldDeletedAt(ctx)
  9860. case creditbalance.FieldUserID:
  9861. return m.OldUserID(ctx)
  9862. case creditbalance.FieldBalance:
  9863. return m.OldBalance(ctx)
  9864. case creditbalance.FieldStatus:
  9865. return m.OldStatus(ctx)
  9866. case creditbalance.FieldOrganizationID:
  9867. return m.OldOrganizationID(ctx)
  9868. }
  9869. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9870. }
  9871. // SetField sets the value of a field with the given name. It returns an error if
  9872. // the field is not defined in the schema, or if the type mismatched the field
  9873. // type.
  9874. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9875. switch name {
  9876. case creditbalance.FieldCreatedAt:
  9877. v, ok := value.(time.Time)
  9878. if !ok {
  9879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9880. }
  9881. m.SetCreatedAt(v)
  9882. return nil
  9883. case creditbalance.FieldUpdatedAt:
  9884. v, ok := value.(time.Time)
  9885. if !ok {
  9886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9887. }
  9888. m.SetUpdatedAt(v)
  9889. return nil
  9890. case creditbalance.FieldDeletedAt:
  9891. v, ok := value.(time.Time)
  9892. if !ok {
  9893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9894. }
  9895. m.SetDeletedAt(v)
  9896. return nil
  9897. case creditbalance.FieldUserID:
  9898. v, ok := value.(string)
  9899. if !ok {
  9900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9901. }
  9902. m.SetUserID(v)
  9903. return nil
  9904. case creditbalance.FieldBalance:
  9905. v, ok := value.(float32)
  9906. if !ok {
  9907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9908. }
  9909. m.SetBalance(v)
  9910. return nil
  9911. case creditbalance.FieldStatus:
  9912. v, ok := value.(int)
  9913. if !ok {
  9914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9915. }
  9916. m.SetStatus(v)
  9917. return nil
  9918. case creditbalance.FieldOrganizationID:
  9919. v, ok := value.(uint64)
  9920. if !ok {
  9921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9922. }
  9923. m.SetOrganizationID(v)
  9924. return nil
  9925. }
  9926. return fmt.Errorf("unknown CreditBalance field %s", name)
  9927. }
  9928. // AddedFields returns all numeric fields that were incremented/decremented during
  9929. // this mutation.
  9930. func (m *CreditBalanceMutation) AddedFields() []string {
  9931. var fields []string
  9932. if m.addbalance != nil {
  9933. fields = append(fields, creditbalance.FieldBalance)
  9934. }
  9935. if m.addstatus != nil {
  9936. fields = append(fields, creditbalance.FieldStatus)
  9937. }
  9938. if m.addorganization_id != nil {
  9939. fields = append(fields, creditbalance.FieldOrganizationID)
  9940. }
  9941. return fields
  9942. }
  9943. // AddedField returns the numeric value that was incremented/decremented on a field
  9944. // with the given name. The second boolean return value indicates that this field
  9945. // was not set, or was not defined in the schema.
  9946. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9947. switch name {
  9948. case creditbalance.FieldBalance:
  9949. return m.AddedBalance()
  9950. case creditbalance.FieldStatus:
  9951. return m.AddedStatus()
  9952. case creditbalance.FieldOrganizationID:
  9953. return m.AddedOrganizationID()
  9954. }
  9955. return nil, false
  9956. }
  9957. // AddField adds the value to the field with the given name. It returns an error if
  9958. // the field is not defined in the schema, or if the type mismatched the field
  9959. // type.
  9960. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9961. switch name {
  9962. case creditbalance.FieldBalance:
  9963. v, ok := value.(float32)
  9964. if !ok {
  9965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9966. }
  9967. m.AddBalance(v)
  9968. return nil
  9969. case creditbalance.FieldStatus:
  9970. v, ok := value.(int)
  9971. if !ok {
  9972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9973. }
  9974. m.AddStatus(v)
  9975. return nil
  9976. case creditbalance.FieldOrganizationID:
  9977. v, ok := value.(int64)
  9978. if !ok {
  9979. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9980. }
  9981. m.AddOrganizationID(v)
  9982. return nil
  9983. }
  9984. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9985. }
  9986. // ClearedFields returns all nullable fields that were cleared during this
  9987. // mutation.
  9988. func (m *CreditBalanceMutation) ClearedFields() []string {
  9989. var fields []string
  9990. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9991. fields = append(fields, creditbalance.FieldDeletedAt)
  9992. }
  9993. if m.FieldCleared(creditbalance.FieldStatus) {
  9994. fields = append(fields, creditbalance.FieldStatus)
  9995. }
  9996. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  9997. fields = append(fields, creditbalance.FieldOrganizationID)
  9998. }
  9999. return fields
  10000. }
  10001. // FieldCleared returns a boolean indicating if a field with the given name was
  10002. // cleared in this mutation.
  10003. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  10004. _, ok := m.clearedFields[name]
  10005. return ok
  10006. }
  10007. // ClearField clears the value of the field with the given name. It returns an
  10008. // error if the field is not defined in the schema.
  10009. func (m *CreditBalanceMutation) ClearField(name string) error {
  10010. switch name {
  10011. case creditbalance.FieldDeletedAt:
  10012. m.ClearDeletedAt()
  10013. return nil
  10014. case creditbalance.FieldStatus:
  10015. m.ClearStatus()
  10016. return nil
  10017. case creditbalance.FieldOrganizationID:
  10018. m.ClearOrganizationID()
  10019. return nil
  10020. }
  10021. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  10022. }
  10023. // ResetField resets all changes in the mutation for the field with the given name.
  10024. // It returns an error if the field is not defined in the schema.
  10025. func (m *CreditBalanceMutation) ResetField(name string) error {
  10026. switch name {
  10027. case creditbalance.FieldCreatedAt:
  10028. m.ResetCreatedAt()
  10029. return nil
  10030. case creditbalance.FieldUpdatedAt:
  10031. m.ResetUpdatedAt()
  10032. return nil
  10033. case creditbalance.FieldDeletedAt:
  10034. m.ResetDeletedAt()
  10035. return nil
  10036. case creditbalance.FieldUserID:
  10037. m.ResetUserID()
  10038. return nil
  10039. case creditbalance.FieldBalance:
  10040. m.ResetBalance()
  10041. return nil
  10042. case creditbalance.FieldStatus:
  10043. m.ResetStatus()
  10044. return nil
  10045. case creditbalance.FieldOrganizationID:
  10046. m.ResetOrganizationID()
  10047. return nil
  10048. }
  10049. return fmt.Errorf("unknown CreditBalance field %s", name)
  10050. }
  10051. // AddedEdges returns all edge names that were set/added in this mutation.
  10052. func (m *CreditBalanceMutation) AddedEdges() []string {
  10053. edges := make([]string, 0, 0)
  10054. return edges
  10055. }
  10056. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  10057. // name in this mutation.
  10058. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  10059. return nil
  10060. }
  10061. // RemovedEdges returns all edge names that were removed in this mutation.
  10062. func (m *CreditBalanceMutation) RemovedEdges() []string {
  10063. edges := make([]string, 0, 0)
  10064. return edges
  10065. }
  10066. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  10067. // the given name in this mutation.
  10068. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  10069. return nil
  10070. }
  10071. // ClearedEdges returns all edge names that were cleared in this mutation.
  10072. func (m *CreditBalanceMutation) ClearedEdges() []string {
  10073. edges := make([]string, 0, 0)
  10074. return edges
  10075. }
  10076. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10077. // was cleared in this mutation.
  10078. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10079. return false
  10080. }
  10081. // ClearEdge clears the value of the edge with the given name. It returns an error
  10082. // if that edge is not defined in the schema.
  10083. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10084. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10085. }
  10086. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10087. // It returns an error if the edge is not defined in the schema.
  10088. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10089. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10090. }
  10091. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10092. type CreditUsageMutation struct {
  10093. config
  10094. op Op
  10095. typ string
  10096. id *uint64
  10097. created_at *time.Time
  10098. updated_at *time.Time
  10099. deleted_at *time.Time
  10100. user_id *string
  10101. number *float32
  10102. addnumber *float32
  10103. status *int
  10104. addstatus *int
  10105. ntype *int
  10106. addntype *int
  10107. table *string
  10108. organization_id *uint64
  10109. addorganization_id *int64
  10110. nid *uint64
  10111. addnid *int64
  10112. reason *string
  10113. operator *string
  10114. clearedFields map[string]struct{}
  10115. done bool
  10116. oldValue func(context.Context) (*CreditUsage, error)
  10117. predicates []predicate.CreditUsage
  10118. }
  10119. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10120. // creditusageOption allows management of the mutation configuration using functional options.
  10121. type creditusageOption func(*CreditUsageMutation)
  10122. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10123. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10124. m := &CreditUsageMutation{
  10125. config: c,
  10126. op: op,
  10127. typ: TypeCreditUsage,
  10128. clearedFields: make(map[string]struct{}),
  10129. }
  10130. for _, opt := range opts {
  10131. opt(m)
  10132. }
  10133. return m
  10134. }
  10135. // withCreditUsageID sets the ID field of the mutation.
  10136. func withCreditUsageID(id uint64) creditusageOption {
  10137. return func(m *CreditUsageMutation) {
  10138. var (
  10139. err error
  10140. once sync.Once
  10141. value *CreditUsage
  10142. )
  10143. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10144. once.Do(func() {
  10145. if m.done {
  10146. err = errors.New("querying old values post mutation is not allowed")
  10147. } else {
  10148. value, err = m.Client().CreditUsage.Get(ctx, id)
  10149. }
  10150. })
  10151. return value, err
  10152. }
  10153. m.id = &id
  10154. }
  10155. }
  10156. // withCreditUsage sets the old CreditUsage of the mutation.
  10157. func withCreditUsage(node *CreditUsage) creditusageOption {
  10158. return func(m *CreditUsageMutation) {
  10159. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10160. return node, nil
  10161. }
  10162. m.id = &node.ID
  10163. }
  10164. }
  10165. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10166. // executed in a transaction (ent.Tx), a transactional client is returned.
  10167. func (m CreditUsageMutation) Client() *Client {
  10168. client := &Client{config: m.config}
  10169. client.init()
  10170. return client
  10171. }
  10172. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10173. // it returns an error otherwise.
  10174. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10175. if _, ok := m.driver.(*txDriver); !ok {
  10176. return nil, errors.New("ent: mutation is not running in a transaction")
  10177. }
  10178. tx := &Tx{config: m.config}
  10179. tx.init()
  10180. return tx, nil
  10181. }
  10182. // SetID sets the value of the id field. Note that this
  10183. // operation is only accepted on creation of CreditUsage entities.
  10184. func (m *CreditUsageMutation) SetID(id uint64) {
  10185. m.id = &id
  10186. }
  10187. // ID returns the ID value in the mutation. Note that the ID is only available
  10188. // if it was provided to the builder or after it was returned from the database.
  10189. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10190. if m.id == nil {
  10191. return
  10192. }
  10193. return *m.id, true
  10194. }
  10195. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10196. // That means, if the mutation is applied within a transaction with an isolation level such
  10197. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10198. // or updated by the mutation.
  10199. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10200. switch {
  10201. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10202. id, exists := m.ID()
  10203. if exists {
  10204. return []uint64{id}, nil
  10205. }
  10206. fallthrough
  10207. case m.op.Is(OpUpdate | OpDelete):
  10208. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10209. default:
  10210. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10211. }
  10212. }
  10213. // SetCreatedAt sets the "created_at" field.
  10214. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10215. m.created_at = &t
  10216. }
  10217. // CreatedAt returns the value of the "created_at" field in the mutation.
  10218. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10219. v := m.created_at
  10220. if v == nil {
  10221. return
  10222. }
  10223. return *v, true
  10224. }
  10225. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10226. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10228. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10229. if !m.op.Is(OpUpdateOne) {
  10230. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10231. }
  10232. if m.id == nil || m.oldValue == nil {
  10233. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10234. }
  10235. oldValue, err := m.oldValue(ctx)
  10236. if err != nil {
  10237. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10238. }
  10239. return oldValue.CreatedAt, nil
  10240. }
  10241. // ResetCreatedAt resets all changes to the "created_at" field.
  10242. func (m *CreditUsageMutation) ResetCreatedAt() {
  10243. m.created_at = nil
  10244. }
  10245. // SetUpdatedAt sets the "updated_at" field.
  10246. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10247. m.updated_at = &t
  10248. }
  10249. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10250. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10251. v := m.updated_at
  10252. if v == nil {
  10253. return
  10254. }
  10255. return *v, true
  10256. }
  10257. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10258. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10260. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10261. if !m.op.Is(OpUpdateOne) {
  10262. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10263. }
  10264. if m.id == nil || m.oldValue == nil {
  10265. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10266. }
  10267. oldValue, err := m.oldValue(ctx)
  10268. if err != nil {
  10269. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10270. }
  10271. return oldValue.UpdatedAt, nil
  10272. }
  10273. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10274. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10275. m.updated_at = nil
  10276. }
  10277. // SetDeletedAt sets the "deleted_at" field.
  10278. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10279. m.deleted_at = &t
  10280. }
  10281. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10282. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10283. v := m.deleted_at
  10284. if v == nil {
  10285. return
  10286. }
  10287. return *v, true
  10288. }
  10289. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10290. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10291. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10292. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10293. if !m.op.Is(OpUpdateOne) {
  10294. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10295. }
  10296. if m.id == nil || m.oldValue == nil {
  10297. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10298. }
  10299. oldValue, err := m.oldValue(ctx)
  10300. if err != nil {
  10301. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10302. }
  10303. return oldValue.DeletedAt, nil
  10304. }
  10305. // ClearDeletedAt clears the value of the "deleted_at" field.
  10306. func (m *CreditUsageMutation) ClearDeletedAt() {
  10307. m.deleted_at = nil
  10308. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10309. }
  10310. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10311. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10312. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10313. return ok
  10314. }
  10315. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10316. func (m *CreditUsageMutation) ResetDeletedAt() {
  10317. m.deleted_at = nil
  10318. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10319. }
  10320. // SetUserID sets the "user_id" field.
  10321. func (m *CreditUsageMutation) SetUserID(s string) {
  10322. m.user_id = &s
  10323. }
  10324. // UserID returns the value of the "user_id" field in the mutation.
  10325. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10326. v := m.user_id
  10327. if v == nil {
  10328. return
  10329. }
  10330. return *v, true
  10331. }
  10332. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10333. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10335. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10336. if !m.op.Is(OpUpdateOne) {
  10337. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10338. }
  10339. if m.id == nil || m.oldValue == nil {
  10340. return v, errors.New("OldUserID requires an ID field in the mutation")
  10341. }
  10342. oldValue, err := m.oldValue(ctx)
  10343. if err != nil {
  10344. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10345. }
  10346. return oldValue.UserID, nil
  10347. }
  10348. // ResetUserID resets all changes to the "user_id" field.
  10349. func (m *CreditUsageMutation) ResetUserID() {
  10350. m.user_id = nil
  10351. }
  10352. // SetNumber sets the "number" field.
  10353. func (m *CreditUsageMutation) SetNumber(f float32) {
  10354. m.number = &f
  10355. m.addnumber = nil
  10356. }
  10357. // Number returns the value of the "number" field in the mutation.
  10358. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10359. v := m.number
  10360. if v == nil {
  10361. return
  10362. }
  10363. return *v, true
  10364. }
  10365. // OldNumber returns the old "number" field's value of the CreditUsage entity.
  10366. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10367. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10368. func (m *CreditUsageMutation) OldNumber(ctx context.Context) (v float32, err error) {
  10369. if !m.op.Is(OpUpdateOne) {
  10370. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10371. }
  10372. if m.id == nil || m.oldValue == nil {
  10373. return v, errors.New("OldNumber requires an ID field in the mutation")
  10374. }
  10375. oldValue, err := m.oldValue(ctx)
  10376. if err != nil {
  10377. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  10378. }
  10379. return oldValue.Number, nil
  10380. }
  10381. // AddNumber adds f to the "number" field.
  10382. func (m *CreditUsageMutation) AddNumber(f float32) {
  10383. if m.addnumber != nil {
  10384. *m.addnumber += f
  10385. } else {
  10386. m.addnumber = &f
  10387. }
  10388. }
  10389. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10390. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10391. v := m.addnumber
  10392. if v == nil {
  10393. return
  10394. }
  10395. return *v, true
  10396. }
  10397. // ResetNumber resets all changes to the "number" field.
  10398. func (m *CreditUsageMutation) ResetNumber() {
  10399. m.number = nil
  10400. m.addnumber = nil
  10401. }
  10402. // SetStatus sets the "status" field.
  10403. func (m *CreditUsageMutation) SetStatus(i int) {
  10404. m.status = &i
  10405. m.addstatus = nil
  10406. }
  10407. // Status returns the value of the "status" field in the mutation.
  10408. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10409. v := m.status
  10410. if v == nil {
  10411. return
  10412. }
  10413. return *v, true
  10414. }
  10415. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10416. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10417. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10418. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10419. if !m.op.Is(OpUpdateOne) {
  10420. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10421. }
  10422. if m.id == nil || m.oldValue == nil {
  10423. return v, errors.New("OldStatus requires an ID field in the mutation")
  10424. }
  10425. oldValue, err := m.oldValue(ctx)
  10426. if err != nil {
  10427. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10428. }
  10429. return oldValue.Status, nil
  10430. }
  10431. // AddStatus adds i to the "status" field.
  10432. func (m *CreditUsageMutation) AddStatus(i int) {
  10433. if m.addstatus != nil {
  10434. *m.addstatus += i
  10435. } else {
  10436. m.addstatus = &i
  10437. }
  10438. }
  10439. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10440. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10441. v := m.addstatus
  10442. if v == nil {
  10443. return
  10444. }
  10445. return *v, true
  10446. }
  10447. // ClearStatus clears the value of the "status" field.
  10448. func (m *CreditUsageMutation) ClearStatus() {
  10449. m.status = nil
  10450. m.addstatus = nil
  10451. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10452. }
  10453. // StatusCleared returns if the "status" field was cleared in this mutation.
  10454. func (m *CreditUsageMutation) StatusCleared() bool {
  10455. _, ok := m.clearedFields[creditusage.FieldStatus]
  10456. return ok
  10457. }
  10458. // ResetStatus resets all changes to the "status" field.
  10459. func (m *CreditUsageMutation) ResetStatus() {
  10460. m.status = nil
  10461. m.addstatus = nil
  10462. delete(m.clearedFields, creditusage.FieldStatus)
  10463. }
  10464. // SetNtype sets the "ntype" field.
  10465. func (m *CreditUsageMutation) SetNtype(i int) {
  10466. m.ntype = &i
  10467. m.addntype = nil
  10468. }
  10469. // Ntype returns the value of the "ntype" field in the mutation.
  10470. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10471. v := m.ntype
  10472. if v == nil {
  10473. return
  10474. }
  10475. return *v, true
  10476. }
  10477. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10478. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10479. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10480. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10481. if !m.op.Is(OpUpdateOne) {
  10482. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10483. }
  10484. if m.id == nil || m.oldValue == nil {
  10485. return v, errors.New("OldNtype requires an ID field in the mutation")
  10486. }
  10487. oldValue, err := m.oldValue(ctx)
  10488. if err != nil {
  10489. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10490. }
  10491. return oldValue.Ntype, nil
  10492. }
  10493. // AddNtype adds i to the "ntype" field.
  10494. func (m *CreditUsageMutation) AddNtype(i int) {
  10495. if m.addntype != nil {
  10496. *m.addntype += i
  10497. } else {
  10498. m.addntype = &i
  10499. }
  10500. }
  10501. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10502. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10503. v := m.addntype
  10504. if v == nil {
  10505. return
  10506. }
  10507. return *v, true
  10508. }
  10509. // ResetNtype resets all changes to the "ntype" field.
  10510. func (m *CreditUsageMutation) ResetNtype() {
  10511. m.ntype = nil
  10512. m.addntype = nil
  10513. }
  10514. // SetTable sets the "table" field.
  10515. func (m *CreditUsageMutation) SetTable(s string) {
  10516. m.table = &s
  10517. }
  10518. // Table returns the value of the "table" field in the mutation.
  10519. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10520. v := m.table
  10521. if v == nil {
  10522. return
  10523. }
  10524. return *v, true
  10525. }
  10526. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10527. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10528. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10529. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10530. if !m.op.Is(OpUpdateOne) {
  10531. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10532. }
  10533. if m.id == nil || m.oldValue == nil {
  10534. return v, errors.New("OldTable requires an ID field in the mutation")
  10535. }
  10536. oldValue, err := m.oldValue(ctx)
  10537. if err != nil {
  10538. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10539. }
  10540. return oldValue.Table, nil
  10541. }
  10542. // ResetTable resets all changes to the "table" field.
  10543. func (m *CreditUsageMutation) ResetTable() {
  10544. m.table = nil
  10545. }
  10546. // SetOrganizationID sets the "organization_id" field.
  10547. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10548. m.organization_id = &u
  10549. m.addorganization_id = nil
  10550. }
  10551. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10552. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10553. v := m.organization_id
  10554. if v == nil {
  10555. return
  10556. }
  10557. return *v, true
  10558. }
  10559. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10560. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10561. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10562. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10563. if !m.op.Is(OpUpdateOne) {
  10564. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10565. }
  10566. if m.id == nil || m.oldValue == nil {
  10567. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10568. }
  10569. oldValue, err := m.oldValue(ctx)
  10570. if err != nil {
  10571. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10572. }
  10573. return oldValue.OrganizationID, nil
  10574. }
  10575. // AddOrganizationID adds u to the "organization_id" field.
  10576. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10577. if m.addorganization_id != nil {
  10578. *m.addorganization_id += u
  10579. } else {
  10580. m.addorganization_id = &u
  10581. }
  10582. }
  10583. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10584. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10585. v := m.addorganization_id
  10586. if v == nil {
  10587. return
  10588. }
  10589. return *v, true
  10590. }
  10591. // ClearOrganizationID clears the value of the "organization_id" field.
  10592. func (m *CreditUsageMutation) ClearOrganizationID() {
  10593. m.organization_id = nil
  10594. m.addorganization_id = nil
  10595. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10596. }
  10597. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10598. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10599. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10600. return ok
  10601. }
  10602. // ResetOrganizationID resets all changes to the "organization_id" field.
  10603. func (m *CreditUsageMutation) ResetOrganizationID() {
  10604. m.organization_id = nil
  10605. m.addorganization_id = nil
  10606. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10607. }
  10608. // SetNid sets the "nid" field.
  10609. func (m *CreditUsageMutation) SetNid(u uint64) {
  10610. m.nid = &u
  10611. m.addnid = nil
  10612. }
  10613. // Nid returns the value of the "nid" field in the mutation.
  10614. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10615. v := m.nid
  10616. if v == nil {
  10617. return
  10618. }
  10619. return *v, true
  10620. }
  10621. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10622. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10624. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10625. if !m.op.Is(OpUpdateOne) {
  10626. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10627. }
  10628. if m.id == nil || m.oldValue == nil {
  10629. return v, errors.New("OldNid requires an ID field in the mutation")
  10630. }
  10631. oldValue, err := m.oldValue(ctx)
  10632. if err != nil {
  10633. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10634. }
  10635. return oldValue.Nid, nil
  10636. }
  10637. // AddNid adds u to the "nid" field.
  10638. func (m *CreditUsageMutation) AddNid(u int64) {
  10639. if m.addnid != nil {
  10640. *m.addnid += u
  10641. } else {
  10642. m.addnid = &u
  10643. }
  10644. }
  10645. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10646. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10647. v := m.addnid
  10648. if v == nil {
  10649. return
  10650. }
  10651. return *v, true
  10652. }
  10653. // ResetNid resets all changes to the "nid" field.
  10654. func (m *CreditUsageMutation) ResetNid() {
  10655. m.nid = nil
  10656. m.addnid = nil
  10657. }
  10658. // SetReason sets the "reason" field.
  10659. func (m *CreditUsageMutation) SetReason(s string) {
  10660. m.reason = &s
  10661. }
  10662. // Reason returns the value of the "reason" field in the mutation.
  10663. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10664. v := m.reason
  10665. if v == nil {
  10666. return
  10667. }
  10668. return *v, true
  10669. }
  10670. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10671. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10673. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10674. if !m.op.Is(OpUpdateOne) {
  10675. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10676. }
  10677. if m.id == nil || m.oldValue == nil {
  10678. return v, errors.New("OldReason requires an ID field in the mutation")
  10679. }
  10680. oldValue, err := m.oldValue(ctx)
  10681. if err != nil {
  10682. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10683. }
  10684. return oldValue.Reason, nil
  10685. }
  10686. // ResetReason resets all changes to the "reason" field.
  10687. func (m *CreditUsageMutation) ResetReason() {
  10688. m.reason = nil
  10689. }
  10690. // SetOperator sets the "operator" field.
  10691. func (m *CreditUsageMutation) SetOperator(s string) {
  10692. m.operator = &s
  10693. }
  10694. // Operator returns the value of the "operator" field in the mutation.
  10695. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10696. v := m.operator
  10697. if v == nil {
  10698. return
  10699. }
  10700. return *v, true
  10701. }
  10702. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10703. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10705. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10706. if !m.op.Is(OpUpdateOne) {
  10707. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10708. }
  10709. if m.id == nil || m.oldValue == nil {
  10710. return v, errors.New("OldOperator requires an ID field in the mutation")
  10711. }
  10712. oldValue, err := m.oldValue(ctx)
  10713. if err != nil {
  10714. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10715. }
  10716. return oldValue.Operator, nil
  10717. }
  10718. // ResetOperator resets all changes to the "operator" field.
  10719. func (m *CreditUsageMutation) ResetOperator() {
  10720. m.operator = nil
  10721. }
  10722. // Where appends a list predicates to the CreditUsageMutation builder.
  10723. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10724. m.predicates = append(m.predicates, ps...)
  10725. }
  10726. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10727. // users can use type-assertion to append predicates that do not depend on any generated package.
  10728. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10729. p := make([]predicate.CreditUsage, len(ps))
  10730. for i := range ps {
  10731. p[i] = ps[i]
  10732. }
  10733. m.Where(p...)
  10734. }
  10735. // Op returns the operation name.
  10736. func (m *CreditUsageMutation) Op() Op {
  10737. return m.op
  10738. }
  10739. // SetOp allows setting the mutation operation.
  10740. func (m *CreditUsageMutation) SetOp(op Op) {
  10741. m.op = op
  10742. }
  10743. // Type returns the node type of this mutation (CreditUsage).
  10744. func (m *CreditUsageMutation) Type() string {
  10745. return m.typ
  10746. }
  10747. // Fields returns all fields that were changed during this mutation. Note that in
  10748. // order to get all numeric fields that were incremented/decremented, call
  10749. // AddedFields().
  10750. func (m *CreditUsageMutation) Fields() []string {
  10751. fields := make([]string, 0, 12)
  10752. if m.created_at != nil {
  10753. fields = append(fields, creditusage.FieldCreatedAt)
  10754. }
  10755. if m.updated_at != nil {
  10756. fields = append(fields, creditusage.FieldUpdatedAt)
  10757. }
  10758. if m.deleted_at != nil {
  10759. fields = append(fields, creditusage.FieldDeletedAt)
  10760. }
  10761. if m.user_id != nil {
  10762. fields = append(fields, creditusage.FieldUserID)
  10763. }
  10764. if m.number != nil {
  10765. fields = append(fields, creditusage.FieldNumber)
  10766. }
  10767. if m.status != nil {
  10768. fields = append(fields, creditusage.FieldStatus)
  10769. }
  10770. if m.ntype != nil {
  10771. fields = append(fields, creditusage.FieldNtype)
  10772. }
  10773. if m.table != nil {
  10774. fields = append(fields, creditusage.FieldTable)
  10775. }
  10776. if m.organization_id != nil {
  10777. fields = append(fields, creditusage.FieldOrganizationID)
  10778. }
  10779. if m.nid != nil {
  10780. fields = append(fields, creditusage.FieldNid)
  10781. }
  10782. if m.reason != nil {
  10783. fields = append(fields, creditusage.FieldReason)
  10784. }
  10785. if m.operator != nil {
  10786. fields = append(fields, creditusage.FieldOperator)
  10787. }
  10788. return fields
  10789. }
  10790. // Field returns the value of a field with the given name. The second boolean
  10791. // return value indicates that this field was not set, or was not defined in the
  10792. // schema.
  10793. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10794. switch name {
  10795. case creditusage.FieldCreatedAt:
  10796. return m.CreatedAt()
  10797. case creditusage.FieldUpdatedAt:
  10798. return m.UpdatedAt()
  10799. case creditusage.FieldDeletedAt:
  10800. return m.DeletedAt()
  10801. case creditusage.FieldUserID:
  10802. return m.UserID()
  10803. case creditusage.FieldNumber:
  10804. return m.Number()
  10805. case creditusage.FieldStatus:
  10806. return m.Status()
  10807. case creditusage.FieldNtype:
  10808. return m.Ntype()
  10809. case creditusage.FieldTable:
  10810. return m.Table()
  10811. case creditusage.FieldOrganizationID:
  10812. return m.OrganizationID()
  10813. case creditusage.FieldNid:
  10814. return m.Nid()
  10815. case creditusage.FieldReason:
  10816. return m.Reason()
  10817. case creditusage.FieldOperator:
  10818. return m.Operator()
  10819. }
  10820. return nil, false
  10821. }
  10822. // OldField returns the old value of the field from the database. An error is
  10823. // returned if the mutation operation is not UpdateOne, or the query to the
  10824. // database failed.
  10825. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10826. switch name {
  10827. case creditusage.FieldCreatedAt:
  10828. return m.OldCreatedAt(ctx)
  10829. case creditusage.FieldUpdatedAt:
  10830. return m.OldUpdatedAt(ctx)
  10831. case creditusage.FieldDeletedAt:
  10832. return m.OldDeletedAt(ctx)
  10833. case creditusage.FieldUserID:
  10834. return m.OldUserID(ctx)
  10835. case creditusage.FieldNumber:
  10836. return m.OldNumber(ctx)
  10837. case creditusage.FieldStatus:
  10838. return m.OldStatus(ctx)
  10839. case creditusage.FieldNtype:
  10840. return m.OldNtype(ctx)
  10841. case creditusage.FieldTable:
  10842. return m.OldTable(ctx)
  10843. case creditusage.FieldOrganizationID:
  10844. return m.OldOrganizationID(ctx)
  10845. case creditusage.FieldNid:
  10846. return m.OldNid(ctx)
  10847. case creditusage.FieldReason:
  10848. return m.OldReason(ctx)
  10849. case creditusage.FieldOperator:
  10850. return m.OldOperator(ctx)
  10851. }
  10852. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10853. }
  10854. // SetField sets the value of a field with the given name. It returns an error if
  10855. // the field is not defined in the schema, or if the type mismatched the field
  10856. // type.
  10857. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10858. switch name {
  10859. case creditusage.FieldCreatedAt:
  10860. v, ok := value.(time.Time)
  10861. if !ok {
  10862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10863. }
  10864. m.SetCreatedAt(v)
  10865. return nil
  10866. case creditusage.FieldUpdatedAt:
  10867. v, ok := value.(time.Time)
  10868. if !ok {
  10869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10870. }
  10871. m.SetUpdatedAt(v)
  10872. return nil
  10873. case creditusage.FieldDeletedAt:
  10874. v, ok := value.(time.Time)
  10875. if !ok {
  10876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10877. }
  10878. m.SetDeletedAt(v)
  10879. return nil
  10880. case creditusage.FieldUserID:
  10881. v, ok := value.(string)
  10882. if !ok {
  10883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10884. }
  10885. m.SetUserID(v)
  10886. return nil
  10887. case creditusage.FieldNumber:
  10888. v, ok := value.(float32)
  10889. if !ok {
  10890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10891. }
  10892. m.SetNumber(v)
  10893. return nil
  10894. case creditusage.FieldStatus:
  10895. v, ok := value.(int)
  10896. if !ok {
  10897. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10898. }
  10899. m.SetStatus(v)
  10900. return nil
  10901. case creditusage.FieldNtype:
  10902. v, ok := value.(int)
  10903. if !ok {
  10904. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10905. }
  10906. m.SetNtype(v)
  10907. return nil
  10908. case creditusage.FieldTable:
  10909. v, ok := value.(string)
  10910. if !ok {
  10911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10912. }
  10913. m.SetTable(v)
  10914. return nil
  10915. case creditusage.FieldOrganizationID:
  10916. v, ok := value.(uint64)
  10917. if !ok {
  10918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10919. }
  10920. m.SetOrganizationID(v)
  10921. return nil
  10922. case creditusage.FieldNid:
  10923. v, ok := value.(uint64)
  10924. if !ok {
  10925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10926. }
  10927. m.SetNid(v)
  10928. return nil
  10929. case creditusage.FieldReason:
  10930. v, ok := value.(string)
  10931. if !ok {
  10932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10933. }
  10934. m.SetReason(v)
  10935. return nil
  10936. case creditusage.FieldOperator:
  10937. v, ok := value.(string)
  10938. if !ok {
  10939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10940. }
  10941. m.SetOperator(v)
  10942. return nil
  10943. }
  10944. return fmt.Errorf("unknown CreditUsage field %s", name)
  10945. }
  10946. // AddedFields returns all numeric fields that were incremented/decremented during
  10947. // this mutation.
  10948. func (m *CreditUsageMutation) AddedFields() []string {
  10949. var fields []string
  10950. if m.addnumber != nil {
  10951. fields = append(fields, creditusage.FieldNumber)
  10952. }
  10953. if m.addstatus != nil {
  10954. fields = append(fields, creditusage.FieldStatus)
  10955. }
  10956. if m.addntype != nil {
  10957. fields = append(fields, creditusage.FieldNtype)
  10958. }
  10959. if m.addorganization_id != nil {
  10960. fields = append(fields, creditusage.FieldOrganizationID)
  10961. }
  10962. if m.addnid != nil {
  10963. fields = append(fields, creditusage.FieldNid)
  10964. }
  10965. return fields
  10966. }
  10967. // AddedField returns the numeric value that was incremented/decremented on a field
  10968. // with the given name. The second boolean return value indicates that this field
  10969. // was not set, or was not defined in the schema.
  10970. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10971. switch name {
  10972. case creditusage.FieldNumber:
  10973. return m.AddedNumber()
  10974. case creditusage.FieldStatus:
  10975. return m.AddedStatus()
  10976. case creditusage.FieldNtype:
  10977. return m.AddedNtype()
  10978. case creditusage.FieldOrganizationID:
  10979. return m.AddedOrganizationID()
  10980. case creditusage.FieldNid:
  10981. return m.AddedNid()
  10982. }
  10983. return nil, false
  10984. }
  10985. // AddField adds the value to the field with the given name. It returns an error if
  10986. // the field is not defined in the schema, or if the type mismatched the field
  10987. // type.
  10988. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10989. switch name {
  10990. case creditusage.FieldNumber:
  10991. v, ok := value.(float32)
  10992. if !ok {
  10993. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10994. }
  10995. m.AddNumber(v)
  10996. return nil
  10997. case creditusage.FieldStatus:
  10998. v, ok := value.(int)
  10999. if !ok {
  11000. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11001. }
  11002. m.AddStatus(v)
  11003. return nil
  11004. case creditusage.FieldNtype:
  11005. v, ok := value.(int)
  11006. if !ok {
  11007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11008. }
  11009. m.AddNtype(v)
  11010. return nil
  11011. case creditusage.FieldOrganizationID:
  11012. v, ok := value.(int64)
  11013. if !ok {
  11014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11015. }
  11016. m.AddOrganizationID(v)
  11017. return nil
  11018. case creditusage.FieldNid:
  11019. v, ok := value.(int64)
  11020. if !ok {
  11021. return fmt.Errorf("unexpected type %T for field %s", value, name)
  11022. }
  11023. m.AddNid(v)
  11024. return nil
  11025. }
  11026. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  11027. }
  11028. // ClearedFields returns all nullable fields that were cleared during this
  11029. // mutation.
  11030. func (m *CreditUsageMutation) ClearedFields() []string {
  11031. var fields []string
  11032. if m.FieldCleared(creditusage.FieldDeletedAt) {
  11033. fields = append(fields, creditusage.FieldDeletedAt)
  11034. }
  11035. if m.FieldCleared(creditusage.FieldStatus) {
  11036. fields = append(fields, creditusage.FieldStatus)
  11037. }
  11038. if m.FieldCleared(creditusage.FieldOrganizationID) {
  11039. fields = append(fields, creditusage.FieldOrganizationID)
  11040. }
  11041. return fields
  11042. }
  11043. // FieldCleared returns a boolean indicating if a field with the given name was
  11044. // cleared in this mutation.
  11045. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  11046. _, ok := m.clearedFields[name]
  11047. return ok
  11048. }
  11049. // ClearField clears the value of the field with the given name. It returns an
  11050. // error if the field is not defined in the schema.
  11051. func (m *CreditUsageMutation) ClearField(name string) error {
  11052. switch name {
  11053. case creditusage.FieldDeletedAt:
  11054. m.ClearDeletedAt()
  11055. return nil
  11056. case creditusage.FieldStatus:
  11057. m.ClearStatus()
  11058. return nil
  11059. case creditusage.FieldOrganizationID:
  11060. m.ClearOrganizationID()
  11061. return nil
  11062. }
  11063. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  11064. }
  11065. // ResetField resets all changes in the mutation for the field with the given name.
  11066. // It returns an error if the field is not defined in the schema.
  11067. func (m *CreditUsageMutation) ResetField(name string) error {
  11068. switch name {
  11069. case creditusage.FieldCreatedAt:
  11070. m.ResetCreatedAt()
  11071. return nil
  11072. case creditusage.FieldUpdatedAt:
  11073. m.ResetUpdatedAt()
  11074. return nil
  11075. case creditusage.FieldDeletedAt:
  11076. m.ResetDeletedAt()
  11077. return nil
  11078. case creditusage.FieldUserID:
  11079. m.ResetUserID()
  11080. return nil
  11081. case creditusage.FieldNumber:
  11082. m.ResetNumber()
  11083. return nil
  11084. case creditusage.FieldStatus:
  11085. m.ResetStatus()
  11086. return nil
  11087. case creditusage.FieldNtype:
  11088. m.ResetNtype()
  11089. return nil
  11090. case creditusage.FieldTable:
  11091. m.ResetTable()
  11092. return nil
  11093. case creditusage.FieldOrganizationID:
  11094. m.ResetOrganizationID()
  11095. return nil
  11096. case creditusage.FieldNid:
  11097. m.ResetNid()
  11098. return nil
  11099. case creditusage.FieldReason:
  11100. m.ResetReason()
  11101. return nil
  11102. case creditusage.FieldOperator:
  11103. m.ResetOperator()
  11104. return nil
  11105. }
  11106. return fmt.Errorf("unknown CreditUsage field %s", name)
  11107. }
  11108. // AddedEdges returns all edge names that were set/added in this mutation.
  11109. func (m *CreditUsageMutation) AddedEdges() []string {
  11110. edges := make([]string, 0, 0)
  11111. return edges
  11112. }
  11113. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11114. // name in this mutation.
  11115. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11116. return nil
  11117. }
  11118. // RemovedEdges returns all edge names that were removed in this mutation.
  11119. func (m *CreditUsageMutation) RemovedEdges() []string {
  11120. edges := make([]string, 0, 0)
  11121. return edges
  11122. }
  11123. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11124. // the given name in this mutation.
  11125. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11126. return nil
  11127. }
  11128. // ClearedEdges returns all edge names that were cleared in this mutation.
  11129. func (m *CreditUsageMutation) ClearedEdges() []string {
  11130. edges := make([]string, 0, 0)
  11131. return edges
  11132. }
  11133. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11134. // was cleared in this mutation.
  11135. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11136. return false
  11137. }
  11138. // ClearEdge clears the value of the edge with the given name. It returns an error
  11139. // if that edge is not defined in the schema.
  11140. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11141. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11142. }
  11143. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11144. // It returns an error if the edge is not defined in the schema.
  11145. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11146. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11147. }
  11148. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11149. type EmployeeMutation struct {
  11150. config
  11151. op Op
  11152. typ string
  11153. id *uint64
  11154. created_at *time.Time
  11155. updated_at *time.Time
  11156. deleted_at *time.Time
  11157. title *string
  11158. avatar *string
  11159. tags *string
  11160. hire_count *int
  11161. addhire_count *int
  11162. service_count *int
  11163. addservice_count *int
  11164. achievement_count *int
  11165. addachievement_count *int
  11166. intro *string
  11167. estimate *string
  11168. skill *string
  11169. ability_type *string
  11170. scene *string
  11171. switch_in *string
  11172. video_url *string
  11173. organization_id *uint64
  11174. addorganization_id *int64
  11175. category_id *uint64
  11176. addcategory_id *int64
  11177. api_base *string
  11178. api_key *string
  11179. ai_info *string
  11180. is_vip *int
  11181. addis_vip *int
  11182. chat_url *string
  11183. clearedFields map[string]struct{}
  11184. em_work_experiences map[uint64]struct{}
  11185. removedem_work_experiences map[uint64]struct{}
  11186. clearedem_work_experiences bool
  11187. em_tutorial map[uint64]struct{}
  11188. removedem_tutorial map[uint64]struct{}
  11189. clearedem_tutorial bool
  11190. done bool
  11191. oldValue func(context.Context) (*Employee, error)
  11192. predicates []predicate.Employee
  11193. }
  11194. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11195. // employeeOption allows management of the mutation configuration using functional options.
  11196. type employeeOption func(*EmployeeMutation)
  11197. // newEmployeeMutation creates new mutation for the Employee entity.
  11198. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11199. m := &EmployeeMutation{
  11200. config: c,
  11201. op: op,
  11202. typ: TypeEmployee,
  11203. clearedFields: make(map[string]struct{}),
  11204. }
  11205. for _, opt := range opts {
  11206. opt(m)
  11207. }
  11208. return m
  11209. }
  11210. // withEmployeeID sets the ID field of the mutation.
  11211. func withEmployeeID(id uint64) employeeOption {
  11212. return func(m *EmployeeMutation) {
  11213. var (
  11214. err error
  11215. once sync.Once
  11216. value *Employee
  11217. )
  11218. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11219. once.Do(func() {
  11220. if m.done {
  11221. err = errors.New("querying old values post mutation is not allowed")
  11222. } else {
  11223. value, err = m.Client().Employee.Get(ctx, id)
  11224. }
  11225. })
  11226. return value, err
  11227. }
  11228. m.id = &id
  11229. }
  11230. }
  11231. // withEmployee sets the old Employee of the mutation.
  11232. func withEmployee(node *Employee) employeeOption {
  11233. return func(m *EmployeeMutation) {
  11234. m.oldValue = func(context.Context) (*Employee, error) {
  11235. return node, nil
  11236. }
  11237. m.id = &node.ID
  11238. }
  11239. }
  11240. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11241. // executed in a transaction (ent.Tx), a transactional client is returned.
  11242. func (m EmployeeMutation) Client() *Client {
  11243. client := &Client{config: m.config}
  11244. client.init()
  11245. return client
  11246. }
  11247. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11248. // it returns an error otherwise.
  11249. func (m EmployeeMutation) Tx() (*Tx, error) {
  11250. if _, ok := m.driver.(*txDriver); !ok {
  11251. return nil, errors.New("ent: mutation is not running in a transaction")
  11252. }
  11253. tx := &Tx{config: m.config}
  11254. tx.init()
  11255. return tx, nil
  11256. }
  11257. // SetID sets the value of the id field. Note that this
  11258. // operation is only accepted on creation of Employee entities.
  11259. func (m *EmployeeMutation) SetID(id uint64) {
  11260. m.id = &id
  11261. }
  11262. // ID returns the ID value in the mutation. Note that the ID is only available
  11263. // if it was provided to the builder or after it was returned from the database.
  11264. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11265. if m.id == nil {
  11266. return
  11267. }
  11268. return *m.id, true
  11269. }
  11270. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11271. // That means, if the mutation is applied within a transaction with an isolation level such
  11272. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11273. // or updated by the mutation.
  11274. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11275. switch {
  11276. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11277. id, exists := m.ID()
  11278. if exists {
  11279. return []uint64{id}, nil
  11280. }
  11281. fallthrough
  11282. case m.op.Is(OpUpdate | OpDelete):
  11283. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11284. default:
  11285. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11286. }
  11287. }
  11288. // SetCreatedAt sets the "created_at" field.
  11289. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11290. m.created_at = &t
  11291. }
  11292. // CreatedAt returns the value of the "created_at" field in the mutation.
  11293. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11294. v := m.created_at
  11295. if v == nil {
  11296. return
  11297. }
  11298. return *v, true
  11299. }
  11300. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11301. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11303. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11304. if !m.op.Is(OpUpdateOne) {
  11305. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11306. }
  11307. if m.id == nil || m.oldValue == nil {
  11308. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11309. }
  11310. oldValue, err := m.oldValue(ctx)
  11311. if err != nil {
  11312. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11313. }
  11314. return oldValue.CreatedAt, nil
  11315. }
  11316. // ResetCreatedAt resets all changes to the "created_at" field.
  11317. func (m *EmployeeMutation) ResetCreatedAt() {
  11318. m.created_at = nil
  11319. }
  11320. // SetUpdatedAt sets the "updated_at" field.
  11321. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11322. m.updated_at = &t
  11323. }
  11324. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11325. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11326. v := m.updated_at
  11327. if v == nil {
  11328. return
  11329. }
  11330. return *v, true
  11331. }
  11332. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11333. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11335. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11336. if !m.op.Is(OpUpdateOne) {
  11337. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11338. }
  11339. if m.id == nil || m.oldValue == nil {
  11340. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11341. }
  11342. oldValue, err := m.oldValue(ctx)
  11343. if err != nil {
  11344. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11345. }
  11346. return oldValue.UpdatedAt, nil
  11347. }
  11348. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11349. func (m *EmployeeMutation) ResetUpdatedAt() {
  11350. m.updated_at = nil
  11351. }
  11352. // SetDeletedAt sets the "deleted_at" field.
  11353. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11354. m.deleted_at = &t
  11355. }
  11356. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11357. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11358. v := m.deleted_at
  11359. if v == nil {
  11360. return
  11361. }
  11362. return *v, true
  11363. }
  11364. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11365. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11367. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11368. if !m.op.Is(OpUpdateOne) {
  11369. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11370. }
  11371. if m.id == nil || m.oldValue == nil {
  11372. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11373. }
  11374. oldValue, err := m.oldValue(ctx)
  11375. if err != nil {
  11376. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11377. }
  11378. return oldValue.DeletedAt, nil
  11379. }
  11380. // ClearDeletedAt clears the value of the "deleted_at" field.
  11381. func (m *EmployeeMutation) ClearDeletedAt() {
  11382. m.deleted_at = nil
  11383. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11384. }
  11385. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11386. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11387. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11388. return ok
  11389. }
  11390. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11391. func (m *EmployeeMutation) ResetDeletedAt() {
  11392. m.deleted_at = nil
  11393. delete(m.clearedFields, employee.FieldDeletedAt)
  11394. }
  11395. // SetTitle sets the "title" field.
  11396. func (m *EmployeeMutation) SetTitle(s string) {
  11397. m.title = &s
  11398. }
  11399. // Title returns the value of the "title" field in the mutation.
  11400. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11401. v := m.title
  11402. if v == nil {
  11403. return
  11404. }
  11405. return *v, true
  11406. }
  11407. // OldTitle returns the old "title" field's value of the Employee entity.
  11408. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11410. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11411. if !m.op.Is(OpUpdateOne) {
  11412. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11413. }
  11414. if m.id == nil || m.oldValue == nil {
  11415. return v, errors.New("OldTitle requires an ID field in the mutation")
  11416. }
  11417. oldValue, err := m.oldValue(ctx)
  11418. if err != nil {
  11419. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11420. }
  11421. return oldValue.Title, nil
  11422. }
  11423. // ResetTitle resets all changes to the "title" field.
  11424. func (m *EmployeeMutation) ResetTitle() {
  11425. m.title = nil
  11426. }
  11427. // SetAvatar sets the "avatar" field.
  11428. func (m *EmployeeMutation) SetAvatar(s string) {
  11429. m.avatar = &s
  11430. }
  11431. // Avatar returns the value of the "avatar" field in the mutation.
  11432. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11433. v := m.avatar
  11434. if v == nil {
  11435. return
  11436. }
  11437. return *v, true
  11438. }
  11439. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11440. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11442. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11443. if !m.op.Is(OpUpdateOne) {
  11444. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11445. }
  11446. if m.id == nil || m.oldValue == nil {
  11447. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11448. }
  11449. oldValue, err := m.oldValue(ctx)
  11450. if err != nil {
  11451. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11452. }
  11453. return oldValue.Avatar, nil
  11454. }
  11455. // ResetAvatar resets all changes to the "avatar" field.
  11456. func (m *EmployeeMutation) ResetAvatar() {
  11457. m.avatar = nil
  11458. }
  11459. // SetTags sets the "tags" field.
  11460. func (m *EmployeeMutation) SetTags(s string) {
  11461. m.tags = &s
  11462. }
  11463. // Tags returns the value of the "tags" field in the mutation.
  11464. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11465. v := m.tags
  11466. if v == nil {
  11467. return
  11468. }
  11469. return *v, true
  11470. }
  11471. // OldTags returns the old "tags" field's value of the Employee entity.
  11472. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11473. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11474. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11475. if !m.op.Is(OpUpdateOne) {
  11476. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11477. }
  11478. if m.id == nil || m.oldValue == nil {
  11479. return v, errors.New("OldTags requires an ID field in the mutation")
  11480. }
  11481. oldValue, err := m.oldValue(ctx)
  11482. if err != nil {
  11483. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11484. }
  11485. return oldValue.Tags, nil
  11486. }
  11487. // ResetTags resets all changes to the "tags" field.
  11488. func (m *EmployeeMutation) ResetTags() {
  11489. m.tags = nil
  11490. }
  11491. // SetHireCount sets the "hire_count" field.
  11492. func (m *EmployeeMutation) SetHireCount(i int) {
  11493. m.hire_count = &i
  11494. m.addhire_count = nil
  11495. }
  11496. // HireCount returns the value of the "hire_count" field in the mutation.
  11497. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11498. v := m.hire_count
  11499. if v == nil {
  11500. return
  11501. }
  11502. return *v, true
  11503. }
  11504. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11505. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11507. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11508. if !m.op.Is(OpUpdateOne) {
  11509. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11510. }
  11511. if m.id == nil || m.oldValue == nil {
  11512. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11513. }
  11514. oldValue, err := m.oldValue(ctx)
  11515. if err != nil {
  11516. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11517. }
  11518. return oldValue.HireCount, nil
  11519. }
  11520. // AddHireCount adds i to the "hire_count" field.
  11521. func (m *EmployeeMutation) AddHireCount(i int) {
  11522. if m.addhire_count != nil {
  11523. *m.addhire_count += i
  11524. } else {
  11525. m.addhire_count = &i
  11526. }
  11527. }
  11528. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11529. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11530. v := m.addhire_count
  11531. if v == nil {
  11532. return
  11533. }
  11534. return *v, true
  11535. }
  11536. // ResetHireCount resets all changes to the "hire_count" field.
  11537. func (m *EmployeeMutation) ResetHireCount() {
  11538. m.hire_count = nil
  11539. m.addhire_count = nil
  11540. }
  11541. // SetServiceCount sets the "service_count" field.
  11542. func (m *EmployeeMutation) SetServiceCount(i int) {
  11543. m.service_count = &i
  11544. m.addservice_count = nil
  11545. }
  11546. // ServiceCount returns the value of the "service_count" field in the mutation.
  11547. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11548. v := m.service_count
  11549. if v == nil {
  11550. return
  11551. }
  11552. return *v, true
  11553. }
  11554. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11555. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11556. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11557. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11558. if !m.op.Is(OpUpdateOne) {
  11559. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11560. }
  11561. if m.id == nil || m.oldValue == nil {
  11562. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11563. }
  11564. oldValue, err := m.oldValue(ctx)
  11565. if err != nil {
  11566. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11567. }
  11568. return oldValue.ServiceCount, nil
  11569. }
  11570. // AddServiceCount adds i to the "service_count" field.
  11571. func (m *EmployeeMutation) AddServiceCount(i int) {
  11572. if m.addservice_count != nil {
  11573. *m.addservice_count += i
  11574. } else {
  11575. m.addservice_count = &i
  11576. }
  11577. }
  11578. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11579. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11580. v := m.addservice_count
  11581. if v == nil {
  11582. return
  11583. }
  11584. return *v, true
  11585. }
  11586. // ResetServiceCount resets all changes to the "service_count" field.
  11587. func (m *EmployeeMutation) ResetServiceCount() {
  11588. m.service_count = nil
  11589. m.addservice_count = nil
  11590. }
  11591. // SetAchievementCount sets the "achievement_count" field.
  11592. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11593. m.achievement_count = &i
  11594. m.addachievement_count = nil
  11595. }
  11596. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11597. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11598. v := m.achievement_count
  11599. if v == nil {
  11600. return
  11601. }
  11602. return *v, true
  11603. }
  11604. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11605. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11607. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11608. if !m.op.Is(OpUpdateOne) {
  11609. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11610. }
  11611. if m.id == nil || m.oldValue == nil {
  11612. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11613. }
  11614. oldValue, err := m.oldValue(ctx)
  11615. if err != nil {
  11616. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11617. }
  11618. return oldValue.AchievementCount, nil
  11619. }
  11620. // AddAchievementCount adds i to the "achievement_count" field.
  11621. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11622. if m.addachievement_count != nil {
  11623. *m.addachievement_count += i
  11624. } else {
  11625. m.addachievement_count = &i
  11626. }
  11627. }
  11628. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11629. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11630. v := m.addachievement_count
  11631. if v == nil {
  11632. return
  11633. }
  11634. return *v, true
  11635. }
  11636. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11637. func (m *EmployeeMutation) ResetAchievementCount() {
  11638. m.achievement_count = nil
  11639. m.addachievement_count = nil
  11640. }
  11641. // SetIntro sets the "intro" field.
  11642. func (m *EmployeeMutation) SetIntro(s string) {
  11643. m.intro = &s
  11644. }
  11645. // Intro returns the value of the "intro" field in the mutation.
  11646. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11647. v := m.intro
  11648. if v == nil {
  11649. return
  11650. }
  11651. return *v, true
  11652. }
  11653. // OldIntro returns the old "intro" field's value of the Employee entity.
  11654. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11656. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11657. if !m.op.Is(OpUpdateOne) {
  11658. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11659. }
  11660. if m.id == nil || m.oldValue == nil {
  11661. return v, errors.New("OldIntro requires an ID field in the mutation")
  11662. }
  11663. oldValue, err := m.oldValue(ctx)
  11664. if err != nil {
  11665. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11666. }
  11667. return oldValue.Intro, nil
  11668. }
  11669. // ResetIntro resets all changes to the "intro" field.
  11670. func (m *EmployeeMutation) ResetIntro() {
  11671. m.intro = nil
  11672. }
  11673. // SetEstimate sets the "estimate" field.
  11674. func (m *EmployeeMutation) SetEstimate(s string) {
  11675. m.estimate = &s
  11676. }
  11677. // Estimate returns the value of the "estimate" field in the mutation.
  11678. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11679. v := m.estimate
  11680. if v == nil {
  11681. return
  11682. }
  11683. return *v, true
  11684. }
  11685. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11686. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11688. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11689. if !m.op.Is(OpUpdateOne) {
  11690. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11691. }
  11692. if m.id == nil || m.oldValue == nil {
  11693. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11694. }
  11695. oldValue, err := m.oldValue(ctx)
  11696. if err != nil {
  11697. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11698. }
  11699. return oldValue.Estimate, nil
  11700. }
  11701. // ResetEstimate resets all changes to the "estimate" field.
  11702. func (m *EmployeeMutation) ResetEstimate() {
  11703. m.estimate = nil
  11704. }
  11705. // SetSkill sets the "skill" field.
  11706. func (m *EmployeeMutation) SetSkill(s string) {
  11707. m.skill = &s
  11708. }
  11709. // Skill returns the value of the "skill" field in the mutation.
  11710. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11711. v := m.skill
  11712. if v == nil {
  11713. return
  11714. }
  11715. return *v, true
  11716. }
  11717. // OldSkill returns the old "skill" field's value of the Employee entity.
  11718. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11720. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11721. if !m.op.Is(OpUpdateOne) {
  11722. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11723. }
  11724. if m.id == nil || m.oldValue == nil {
  11725. return v, errors.New("OldSkill requires an ID field in the mutation")
  11726. }
  11727. oldValue, err := m.oldValue(ctx)
  11728. if err != nil {
  11729. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11730. }
  11731. return oldValue.Skill, nil
  11732. }
  11733. // ResetSkill resets all changes to the "skill" field.
  11734. func (m *EmployeeMutation) ResetSkill() {
  11735. m.skill = nil
  11736. }
  11737. // SetAbilityType sets the "ability_type" field.
  11738. func (m *EmployeeMutation) SetAbilityType(s string) {
  11739. m.ability_type = &s
  11740. }
  11741. // AbilityType returns the value of the "ability_type" field in the mutation.
  11742. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11743. v := m.ability_type
  11744. if v == nil {
  11745. return
  11746. }
  11747. return *v, true
  11748. }
  11749. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11750. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11751. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11752. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11753. if !m.op.Is(OpUpdateOne) {
  11754. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11755. }
  11756. if m.id == nil || m.oldValue == nil {
  11757. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11758. }
  11759. oldValue, err := m.oldValue(ctx)
  11760. if err != nil {
  11761. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11762. }
  11763. return oldValue.AbilityType, nil
  11764. }
  11765. // ResetAbilityType resets all changes to the "ability_type" field.
  11766. func (m *EmployeeMutation) ResetAbilityType() {
  11767. m.ability_type = nil
  11768. }
  11769. // SetScene sets the "scene" field.
  11770. func (m *EmployeeMutation) SetScene(s string) {
  11771. m.scene = &s
  11772. }
  11773. // Scene returns the value of the "scene" field in the mutation.
  11774. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11775. v := m.scene
  11776. if v == nil {
  11777. return
  11778. }
  11779. return *v, true
  11780. }
  11781. // OldScene returns the old "scene" field's value of the Employee entity.
  11782. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11784. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11785. if !m.op.Is(OpUpdateOne) {
  11786. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11787. }
  11788. if m.id == nil || m.oldValue == nil {
  11789. return v, errors.New("OldScene requires an ID field in the mutation")
  11790. }
  11791. oldValue, err := m.oldValue(ctx)
  11792. if err != nil {
  11793. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11794. }
  11795. return oldValue.Scene, nil
  11796. }
  11797. // ResetScene resets all changes to the "scene" field.
  11798. func (m *EmployeeMutation) ResetScene() {
  11799. m.scene = nil
  11800. }
  11801. // SetSwitchIn sets the "switch_in" field.
  11802. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11803. m.switch_in = &s
  11804. }
  11805. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11806. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11807. v := m.switch_in
  11808. if v == nil {
  11809. return
  11810. }
  11811. return *v, true
  11812. }
  11813. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11814. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11815. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11816. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11817. if !m.op.Is(OpUpdateOne) {
  11818. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11819. }
  11820. if m.id == nil || m.oldValue == nil {
  11821. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11822. }
  11823. oldValue, err := m.oldValue(ctx)
  11824. if err != nil {
  11825. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11826. }
  11827. return oldValue.SwitchIn, nil
  11828. }
  11829. // ResetSwitchIn resets all changes to the "switch_in" field.
  11830. func (m *EmployeeMutation) ResetSwitchIn() {
  11831. m.switch_in = nil
  11832. }
  11833. // SetVideoURL sets the "video_url" field.
  11834. func (m *EmployeeMutation) SetVideoURL(s string) {
  11835. m.video_url = &s
  11836. }
  11837. // VideoURL returns the value of the "video_url" field in the mutation.
  11838. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11839. v := m.video_url
  11840. if v == nil {
  11841. return
  11842. }
  11843. return *v, true
  11844. }
  11845. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11846. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11848. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11849. if !m.op.Is(OpUpdateOne) {
  11850. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11851. }
  11852. if m.id == nil || m.oldValue == nil {
  11853. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11854. }
  11855. oldValue, err := m.oldValue(ctx)
  11856. if err != nil {
  11857. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11858. }
  11859. return oldValue.VideoURL, nil
  11860. }
  11861. // ResetVideoURL resets all changes to the "video_url" field.
  11862. func (m *EmployeeMutation) ResetVideoURL() {
  11863. m.video_url = nil
  11864. }
  11865. // SetOrganizationID sets the "organization_id" field.
  11866. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11867. m.organization_id = &u
  11868. m.addorganization_id = nil
  11869. }
  11870. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11871. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11872. v := m.organization_id
  11873. if v == nil {
  11874. return
  11875. }
  11876. return *v, true
  11877. }
  11878. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11879. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11881. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11882. if !m.op.Is(OpUpdateOne) {
  11883. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11884. }
  11885. if m.id == nil || m.oldValue == nil {
  11886. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11887. }
  11888. oldValue, err := m.oldValue(ctx)
  11889. if err != nil {
  11890. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11891. }
  11892. return oldValue.OrganizationID, nil
  11893. }
  11894. // AddOrganizationID adds u to the "organization_id" field.
  11895. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11896. if m.addorganization_id != nil {
  11897. *m.addorganization_id += u
  11898. } else {
  11899. m.addorganization_id = &u
  11900. }
  11901. }
  11902. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11903. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11904. v := m.addorganization_id
  11905. if v == nil {
  11906. return
  11907. }
  11908. return *v, true
  11909. }
  11910. // ResetOrganizationID resets all changes to the "organization_id" field.
  11911. func (m *EmployeeMutation) ResetOrganizationID() {
  11912. m.organization_id = nil
  11913. m.addorganization_id = nil
  11914. }
  11915. // SetCategoryID sets the "category_id" field.
  11916. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11917. m.category_id = &u
  11918. m.addcategory_id = nil
  11919. }
  11920. // CategoryID returns the value of the "category_id" field in the mutation.
  11921. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11922. v := m.category_id
  11923. if v == nil {
  11924. return
  11925. }
  11926. return *v, true
  11927. }
  11928. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11929. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11931. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11932. if !m.op.Is(OpUpdateOne) {
  11933. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11934. }
  11935. if m.id == nil || m.oldValue == nil {
  11936. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11937. }
  11938. oldValue, err := m.oldValue(ctx)
  11939. if err != nil {
  11940. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11941. }
  11942. return oldValue.CategoryID, nil
  11943. }
  11944. // AddCategoryID adds u to the "category_id" field.
  11945. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11946. if m.addcategory_id != nil {
  11947. *m.addcategory_id += u
  11948. } else {
  11949. m.addcategory_id = &u
  11950. }
  11951. }
  11952. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11953. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11954. v := m.addcategory_id
  11955. if v == nil {
  11956. return
  11957. }
  11958. return *v, true
  11959. }
  11960. // ResetCategoryID resets all changes to the "category_id" field.
  11961. func (m *EmployeeMutation) ResetCategoryID() {
  11962. m.category_id = nil
  11963. m.addcategory_id = nil
  11964. }
  11965. // SetAPIBase sets the "api_base" field.
  11966. func (m *EmployeeMutation) SetAPIBase(s string) {
  11967. m.api_base = &s
  11968. }
  11969. // APIBase returns the value of the "api_base" field in the mutation.
  11970. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11971. v := m.api_base
  11972. if v == nil {
  11973. return
  11974. }
  11975. return *v, true
  11976. }
  11977. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11978. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11979. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11980. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11981. if !m.op.Is(OpUpdateOne) {
  11982. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11983. }
  11984. if m.id == nil || m.oldValue == nil {
  11985. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11986. }
  11987. oldValue, err := m.oldValue(ctx)
  11988. if err != nil {
  11989. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11990. }
  11991. return oldValue.APIBase, nil
  11992. }
  11993. // ResetAPIBase resets all changes to the "api_base" field.
  11994. func (m *EmployeeMutation) ResetAPIBase() {
  11995. m.api_base = nil
  11996. }
  11997. // SetAPIKey sets the "api_key" field.
  11998. func (m *EmployeeMutation) SetAPIKey(s string) {
  11999. m.api_key = &s
  12000. }
  12001. // APIKey returns the value of the "api_key" field in the mutation.
  12002. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  12003. v := m.api_key
  12004. if v == nil {
  12005. return
  12006. }
  12007. return *v, true
  12008. }
  12009. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  12010. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12011. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12012. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  12013. if !m.op.Is(OpUpdateOne) {
  12014. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  12015. }
  12016. if m.id == nil || m.oldValue == nil {
  12017. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  12018. }
  12019. oldValue, err := m.oldValue(ctx)
  12020. if err != nil {
  12021. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  12022. }
  12023. return oldValue.APIKey, nil
  12024. }
  12025. // ResetAPIKey resets all changes to the "api_key" field.
  12026. func (m *EmployeeMutation) ResetAPIKey() {
  12027. m.api_key = nil
  12028. }
  12029. // SetAiInfo sets the "ai_info" field.
  12030. func (m *EmployeeMutation) SetAiInfo(s string) {
  12031. m.ai_info = &s
  12032. }
  12033. // AiInfo returns the value of the "ai_info" field in the mutation.
  12034. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  12035. v := m.ai_info
  12036. if v == nil {
  12037. return
  12038. }
  12039. return *v, true
  12040. }
  12041. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  12042. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12044. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  12045. if !m.op.Is(OpUpdateOne) {
  12046. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  12047. }
  12048. if m.id == nil || m.oldValue == nil {
  12049. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  12050. }
  12051. oldValue, err := m.oldValue(ctx)
  12052. if err != nil {
  12053. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  12054. }
  12055. return oldValue.AiInfo, nil
  12056. }
  12057. // ClearAiInfo clears the value of the "ai_info" field.
  12058. func (m *EmployeeMutation) ClearAiInfo() {
  12059. m.ai_info = nil
  12060. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  12061. }
  12062. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  12063. func (m *EmployeeMutation) AiInfoCleared() bool {
  12064. _, ok := m.clearedFields[employee.FieldAiInfo]
  12065. return ok
  12066. }
  12067. // ResetAiInfo resets all changes to the "ai_info" field.
  12068. func (m *EmployeeMutation) ResetAiInfo() {
  12069. m.ai_info = nil
  12070. delete(m.clearedFields, employee.FieldAiInfo)
  12071. }
  12072. // SetIsVip sets the "is_vip" field.
  12073. func (m *EmployeeMutation) SetIsVip(i int) {
  12074. m.is_vip = &i
  12075. m.addis_vip = nil
  12076. }
  12077. // IsVip returns the value of the "is_vip" field in the mutation.
  12078. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12079. v := m.is_vip
  12080. if v == nil {
  12081. return
  12082. }
  12083. return *v, true
  12084. }
  12085. // OldIsVip returns the old "is_vip" field's value of the Employee entity.
  12086. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12088. func (m *EmployeeMutation) OldIsVip(ctx context.Context) (v int, err error) {
  12089. if !m.op.Is(OpUpdateOne) {
  12090. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12091. }
  12092. if m.id == nil || m.oldValue == nil {
  12093. return v, errors.New("OldIsVip requires an ID field in the mutation")
  12094. }
  12095. oldValue, err := m.oldValue(ctx)
  12096. if err != nil {
  12097. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  12098. }
  12099. return oldValue.IsVip, nil
  12100. }
  12101. // AddIsVip adds i to the "is_vip" field.
  12102. func (m *EmployeeMutation) AddIsVip(i int) {
  12103. if m.addis_vip != nil {
  12104. *m.addis_vip += i
  12105. } else {
  12106. m.addis_vip = &i
  12107. }
  12108. }
  12109. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12110. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12111. v := m.addis_vip
  12112. if v == nil {
  12113. return
  12114. }
  12115. return *v, true
  12116. }
  12117. // ResetIsVip resets all changes to the "is_vip" field.
  12118. func (m *EmployeeMutation) ResetIsVip() {
  12119. m.is_vip = nil
  12120. m.addis_vip = nil
  12121. }
  12122. // SetChatURL sets the "chat_url" field.
  12123. func (m *EmployeeMutation) SetChatURL(s string) {
  12124. m.chat_url = &s
  12125. }
  12126. // ChatURL returns the value of the "chat_url" field in the mutation.
  12127. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12128. v := m.chat_url
  12129. if v == nil {
  12130. return
  12131. }
  12132. return *v, true
  12133. }
  12134. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12135. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12136. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12137. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12138. if !m.op.Is(OpUpdateOne) {
  12139. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12140. }
  12141. if m.id == nil || m.oldValue == nil {
  12142. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12143. }
  12144. oldValue, err := m.oldValue(ctx)
  12145. if err != nil {
  12146. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12147. }
  12148. return oldValue.ChatURL, nil
  12149. }
  12150. // ResetChatURL resets all changes to the "chat_url" field.
  12151. func (m *EmployeeMutation) ResetChatURL() {
  12152. m.chat_url = nil
  12153. }
  12154. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12155. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12156. if m.em_work_experiences == nil {
  12157. m.em_work_experiences = make(map[uint64]struct{})
  12158. }
  12159. for i := range ids {
  12160. m.em_work_experiences[ids[i]] = struct{}{}
  12161. }
  12162. }
  12163. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12164. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12165. m.clearedem_work_experiences = true
  12166. }
  12167. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12168. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12169. return m.clearedem_work_experiences
  12170. }
  12171. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12172. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12173. if m.removedem_work_experiences == nil {
  12174. m.removedem_work_experiences = make(map[uint64]struct{})
  12175. }
  12176. for i := range ids {
  12177. delete(m.em_work_experiences, ids[i])
  12178. m.removedem_work_experiences[ids[i]] = struct{}{}
  12179. }
  12180. }
  12181. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12182. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12183. for id := range m.removedem_work_experiences {
  12184. ids = append(ids, id)
  12185. }
  12186. return
  12187. }
  12188. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12189. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12190. for id := range m.em_work_experiences {
  12191. ids = append(ids, id)
  12192. }
  12193. return
  12194. }
  12195. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12196. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12197. m.em_work_experiences = nil
  12198. m.clearedem_work_experiences = false
  12199. m.removedem_work_experiences = nil
  12200. }
  12201. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12202. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12203. if m.em_tutorial == nil {
  12204. m.em_tutorial = make(map[uint64]struct{})
  12205. }
  12206. for i := range ids {
  12207. m.em_tutorial[ids[i]] = struct{}{}
  12208. }
  12209. }
  12210. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12211. func (m *EmployeeMutation) ClearEmTutorial() {
  12212. m.clearedem_tutorial = true
  12213. }
  12214. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12215. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12216. return m.clearedem_tutorial
  12217. }
  12218. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12219. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12220. if m.removedem_tutorial == nil {
  12221. m.removedem_tutorial = make(map[uint64]struct{})
  12222. }
  12223. for i := range ids {
  12224. delete(m.em_tutorial, ids[i])
  12225. m.removedem_tutorial[ids[i]] = struct{}{}
  12226. }
  12227. }
  12228. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12229. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12230. for id := range m.removedem_tutorial {
  12231. ids = append(ids, id)
  12232. }
  12233. return
  12234. }
  12235. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12236. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12237. for id := range m.em_tutorial {
  12238. ids = append(ids, id)
  12239. }
  12240. return
  12241. }
  12242. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12243. func (m *EmployeeMutation) ResetEmTutorial() {
  12244. m.em_tutorial = nil
  12245. m.clearedem_tutorial = false
  12246. m.removedem_tutorial = nil
  12247. }
  12248. // Where appends a list predicates to the EmployeeMutation builder.
  12249. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12250. m.predicates = append(m.predicates, ps...)
  12251. }
  12252. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12253. // users can use type-assertion to append predicates that do not depend on any generated package.
  12254. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12255. p := make([]predicate.Employee, len(ps))
  12256. for i := range ps {
  12257. p[i] = ps[i]
  12258. }
  12259. m.Where(p...)
  12260. }
  12261. // Op returns the operation name.
  12262. func (m *EmployeeMutation) Op() Op {
  12263. return m.op
  12264. }
  12265. // SetOp allows setting the mutation operation.
  12266. func (m *EmployeeMutation) SetOp(op Op) {
  12267. m.op = op
  12268. }
  12269. // Type returns the node type of this mutation (Employee).
  12270. func (m *EmployeeMutation) Type() string {
  12271. return m.typ
  12272. }
  12273. // Fields returns all fields that were changed during this mutation. Note that in
  12274. // order to get all numeric fields that were incremented/decremented, call
  12275. // AddedFields().
  12276. func (m *EmployeeMutation) Fields() []string {
  12277. fields := make([]string, 0, 23)
  12278. if m.created_at != nil {
  12279. fields = append(fields, employee.FieldCreatedAt)
  12280. }
  12281. if m.updated_at != nil {
  12282. fields = append(fields, employee.FieldUpdatedAt)
  12283. }
  12284. if m.deleted_at != nil {
  12285. fields = append(fields, employee.FieldDeletedAt)
  12286. }
  12287. if m.title != nil {
  12288. fields = append(fields, employee.FieldTitle)
  12289. }
  12290. if m.avatar != nil {
  12291. fields = append(fields, employee.FieldAvatar)
  12292. }
  12293. if m.tags != nil {
  12294. fields = append(fields, employee.FieldTags)
  12295. }
  12296. if m.hire_count != nil {
  12297. fields = append(fields, employee.FieldHireCount)
  12298. }
  12299. if m.service_count != nil {
  12300. fields = append(fields, employee.FieldServiceCount)
  12301. }
  12302. if m.achievement_count != nil {
  12303. fields = append(fields, employee.FieldAchievementCount)
  12304. }
  12305. if m.intro != nil {
  12306. fields = append(fields, employee.FieldIntro)
  12307. }
  12308. if m.estimate != nil {
  12309. fields = append(fields, employee.FieldEstimate)
  12310. }
  12311. if m.skill != nil {
  12312. fields = append(fields, employee.FieldSkill)
  12313. }
  12314. if m.ability_type != nil {
  12315. fields = append(fields, employee.FieldAbilityType)
  12316. }
  12317. if m.scene != nil {
  12318. fields = append(fields, employee.FieldScene)
  12319. }
  12320. if m.switch_in != nil {
  12321. fields = append(fields, employee.FieldSwitchIn)
  12322. }
  12323. if m.video_url != nil {
  12324. fields = append(fields, employee.FieldVideoURL)
  12325. }
  12326. if m.organization_id != nil {
  12327. fields = append(fields, employee.FieldOrganizationID)
  12328. }
  12329. if m.category_id != nil {
  12330. fields = append(fields, employee.FieldCategoryID)
  12331. }
  12332. if m.api_base != nil {
  12333. fields = append(fields, employee.FieldAPIBase)
  12334. }
  12335. if m.api_key != nil {
  12336. fields = append(fields, employee.FieldAPIKey)
  12337. }
  12338. if m.ai_info != nil {
  12339. fields = append(fields, employee.FieldAiInfo)
  12340. }
  12341. if m.is_vip != nil {
  12342. fields = append(fields, employee.FieldIsVip)
  12343. }
  12344. if m.chat_url != nil {
  12345. fields = append(fields, employee.FieldChatURL)
  12346. }
  12347. return fields
  12348. }
  12349. // Field returns the value of a field with the given name. The second boolean
  12350. // return value indicates that this field was not set, or was not defined in the
  12351. // schema.
  12352. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12353. switch name {
  12354. case employee.FieldCreatedAt:
  12355. return m.CreatedAt()
  12356. case employee.FieldUpdatedAt:
  12357. return m.UpdatedAt()
  12358. case employee.FieldDeletedAt:
  12359. return m.DeletedAt()
  12360. case employee.FieldTitle:
  12361. return m.Title()
  12362. case employee.FieldAvatar:
  12363. return m.Avatar()
  12364. case employee.FieldTags:
  12365. return m.Tags()
  12366. case employee.FieldHireCount:
  12367. return m.HireCount()
  12368. case employee.FieldServiceCount:
  12369. return m.ServiceCount()
  12370. case employee.FieldAchievementCount:
  12371. return m.AchievementCount()
  12372. case employee.FieldIntro:
  12373. return m.Intro()
  12374. case employee.FieldEstimate:
  12375. return m.Estimate()
  12376. case employee.FieldSkill:
  12377. return m.Skill()
  12378. case employee.FieldAbilityType:
  12379. return m.AbilityType()
  12380. case employee.FieldScene:
  12381. return m.Scene()
  12382. case employee.FieldSwitchIn:
  12383. return m.SwitchIn()
  12384. case employee.FieldVideoURL:
  12385. return m.VideoURL()
  12386. case employee.FieldOrganizationID:
  12387. return m.OrganizationID()
  12388. case employee.FieldCategoryID:
  12389. return m.CategoryID()
  12390. case employee.FieldAPIBase:
  12391. return m.APIBase()
  12392. case employee.FieldAPIKey:
  12393. return m.APIKey()
  12394. case employee.FieldAiInfo:
  12395. return m.AiInfo()
  12396. case employee.FieldIsVip:
  12397. return m.IsVip()
  12398. case employee.FieldChatURL:
  12399. return m.ChatURL()
  12400. }
  12401. return nil, false
  12402. }
  12403. // OldField returns the old value of the field from the database. An error is
  12404. // returned if the mutation operation is not UpdateOne, or the query to the
  12405. // database failed.
  12406. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12407. switch name {
  12408. case employee.FieldCreatedAt:
  12409. return m.OldCreatedAt(ctx)
  12410. case employee.FieldUpdatedAt:
  12411. return m.OldUpdatedAt(ctx)
  12412. case employee.FieldDeletedAt:
  12413. return m.OldDeletedAt(ctx)
  12414. case employee.FieldTitle:
  12415. return m.OldTitle(ctx)
  12416. case employee.FieldAvatar:
  12417. return m.OldAvatar(ctx)
  12418. case employee.FieldTags:
  12419. return m.OldTags(ctx)
  12420. case employee.FieldHireCount:
  12421. return m.OldHireCount(ctx)
  12422. case employee.FieldServiceCount:
  12423. return m.OldServiceCount(ctx)
  12424. case employee.FieldAchievementCount:
  12425. return m.OldAchievementCount(ctx)
  12426. case employee.FieldIntro:
  12427. return m.OldIntro(ctx)
  12428. case employee.FieldEstimate:
  12429. return m.OldEstimate(ctx)
  12430. case employee.FieldSkill:
  12431. return m.OldSkill(ctx)
  12432. case employee.FieldAbilityType:
  12433. return m.OldAbilityType(ctx)
  12434. case employee.FieldScene:
  12435. return m.OldScene(ctx)
  12436. case employee.FieldSwitchIn:
  12437. return m.OldSwitchIn(ctx)
  12438. case employee.FieldVideoURL:
  12439. return m.OldVideoURL(ctx)
  12440. case employee.FieldOrganizationID:
  12441. return m.OldOrganizationID(ctx)
  12442. case employee.FieldCategoryID:
  12443. return m.OldCategoryID(ctx)
  12444. case employee.FieldAPIBase:
  12445. return m.OldAPIBase(ctx)
  12446. case employee.FieldAPIKey:
  12447. return m.OldAPIKey(ctx)
  12448. case employee.FieldAiInfo:
  12449. return m.OldAiInfo(ctx)
  12450. case employee.FieldIsVip:
  12451. return m.OldIsVip(ctx)
  12452. case employee.FieldChatURL:
  12453. return m.OldChatURL(ctx)
  12454. }
  12455. return nil, fmt.Errorf("unknown Employee field %s", name)
  12456. }
  12457. // SetField sets the value of a field with the given name. It returns an error if
  12458. // the field is not defined in the schema, or if the type mismatched the field
  12459. // type.
  12460. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12461. switch name {
  12462. case employee.FieldCreatedAt:
  12463. v, ok := value.(time.Time)
  12464. if !ok {
  12465. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12466. }
  12467. m.SetCreatedAt(v)
  12468. return nil
  12469. case employee.FieldUpdatedAt:
  12470. v, ok := value.(time.Time)
  12471. if !ok {
  12472. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12473. }
  12474. m.SetUpdatedAt(v)
  12475. return nil
  12476. case employee.FieldDeletedAt:
  12477. v, ok := value.(time.Time)
  12478. if !ok {
  12479. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12480. }
  12481. m.SetDeletedAt(v)
  12482. return nil
  12483. case employee.FieldTitle:
  12484. v, ok := value.(string)
  12485. if !ok {
  12486. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12487. }
  12488. m.SetTitle(v)
  12489. return nil
  12490. case employee.FieldAvatar:
  12491. v, ok := value.(string)
  12492. if !ok {
  12493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12494. }
  12495. m.SetAvatar(v)
  12496. return nil
  12497. case employee.FieldTags:
  12498. v, ok := value.(string)
  12499. if !ok {
  12500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12501. }
  12502. m.SetTags(v)
  12503. return nil
  12504. case employee.FieldHireCount:
  12505. v, ok := value.(int)
  12506. if !ok {
  12507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12508. }
  12509. m.SetHireCount(v)
  12510. return nil
  12511. case employee.FieldServiceCount:
  12512. v, ok := value.(int)
  12513. if !ok {
  12514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12515. }
  12516. m.SetServiceCount(v)
  12517. return nil
  12518. case employee.FieldAchievementCount:
  12519. v, ok := value.(int)
  12520. if !ok {
  12521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12522. }
  12523. m.SetAchievementCount(v)
  12524. return nil
  12525. case employee.FieldIntro:
  12526. v, ok := value.(string)
  12527. if !ok {
  12528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12529. }
  12530. m.SetIntro(v)
  12531. return nil
  12532. case employee.FieldEstimate:
  12533. v, ok := value.(string)
  12534. if !ok {
  12535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12536. }
  12537. m.SetEstimate(v)
  12538. return nil
  12539. case employee.FieldSkill:
  12540. v, ok := value.(string)
  12541. if !ok {
  12542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12543. }
  12544. m.SetSkill(v)
  12545. return nil
  12546. case employee.FieldAbilityType:
  12547. v, ok := value.(string)
  12548. if !ok {
  12549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12550. }
  12551. m.SetAbilityType(v)
  12552. return nil
  12553. case employee.FieldScene:
  12554. v, ok := value.(string)
  12555. if !ok {
  12556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12557. }
  12558. m.SetScene(v)
  12559. return nil
  12560. case employee.FieldSwitchIn:
  12561. v, ok := value.(string)
  12562. if !ok {
  12563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12564. }
  12565. m.SetSwitchIn(v)
  12566. return nil
  12567. case employee.FieldVideoURL:
  12568. v, ok := value.(string)
  12569. if !ok {
  12570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12571. }
  12572. m.SetVideoURL(v)
  12573. return nil
  12574. case employee.FieldOrganizationID:
  12575. v, ok := value.(uint64)
  12576. if !ok {
  12577. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12578. }
  12579. m.SetOrganizationID(v)
  12580. return nil
  12581. case employee.FieldCategoryID:
  12582. v, ok := value.(uint64)
  12583. if !ok {
  12584. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12585. }
  12586. m.SetCategoryID(v)
  12587. return nil
  12588. case employee.FieldAPIBase:
  12589. v, ok := value.(string)
  12590. if !ok {
  12591. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12592. }
  12593. m.SetAPIBase(v)
  12594. return nil
  12595. case employee.FieldAPIKey:
  12596. v, ok := value.(string)
  12597. if !ok {
  12598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12599. }
  12600. m.SetAPIKey(v)
  12601. return nil
  12602. case employee.FieldAiInfo:
  12603. v, ok := value.(string)
  12604. if !ok {
  12605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12606. }
  12607. m.SetAiInfo(v)
  12608. return nil
  12609. case employee.FieldIsVip:
  12610. v, ok := value.(int)
  12611. if !ok {
  12612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12613. }
  12614. m.SetIsVip(v)
  12615. return nil
  12616. case employee.FieldChatURL:
  12617. v, ok := value.(string)
  12618. if !ok {
  12619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12620. }
  12621. m.SetChatURL(v)
  12622. return nil
  12623. }
  12624. return fmt.Errorf("unknown Employee field %s", name)
  12625. }
  12626. // AddedFields returns all numeric fields that were incremented/decremented during
  12627. // this mutation.
  12628. func (m *EmployeeMutation) AddedFields() []string {
  12629. var fields []string
  12630. if m.addhire_count != nil {
  12631. fields = append(fields, employee.FieldHireCount)
  12632. }
  12633. if m.addservice_count != nil {
  12634. fields = append(fields, employee.FieldServiceCount)
  12635. }
  12636. if m.addachievement_count != nil {
  12637. fields = append(fields, employee.FieldAchievementCount)
  12638. }
  12639. if m.addorganization_id != nil {
  12640. fields = append(fields, employee.FieldOrganizationID)
  12641. }
  12642. if m.addcategory_id != nil {
  12643. fields = append(fields, employee.FieldCategoryID)
  12644. }
  12645. if m.addis_vip != nil {
  12646. fields = append(fields, employee.FieldIsVip)
  12647. }
  12648. return fields
  12649. }
  12650. // AddedField returns the numeric value that was incremented/decremented on a field
  12651. // with the given name. The second boolean return value indicates that this field
  12652. // was not set, or was not defined in the schema.
  12653. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12654. switch name {
  12655. case employee.FieldHireCount:
  12656. return m.AddedHireCount()
  12657. case employee.FieldServiceCount:
  12658. return m.AddedServiceCount()
  12659. case employee.FieldAchievementCount:
  12660. return m.AddedAchievementCount()
  12661. case employee.FieldOrganizationID:
  12662. return m.AddedOrganizationID()
  12663. case employee.FieldCategoryID:
  12664. return m.AddedCategoryID()
  12665. case employee.FieldIsVip:
  12666. return m.AddedIsVip()
  12667. }
  12668. return nil, false
  12669. }
  12670. // AddField adds the value to the field with the given name. It returns an error if
  12671. // the field is not defined in the schema, or if the type mismatched the field
  12672. // type.
  12673. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12674. switch name {
  12675. case employee.FieldHireCount:
  12676. v, ok := value.(int)
  12677. if !ok {
  12678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12679. }
  12680. m.AddHireCount(v)
  12681. return nil
  12682. case employee.FieldServiceCount:
  12683. v, ok := value.(int)
  12684. if !ok {
  12685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12686. }
  12687. m.AddServiceCount(v)
  12688. return nil
  12689. case employee.FieldAchievementCount:
  12690. v, ok := value.(int)
  12691. if !ok {
  12692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12693. }
  12694. m.AddAchievementCount(v)
  12695. return nil
  12696. case employee.FieldOrganizationID:
  12697. v, ok := value.(int64)
  12698. if !ok {
  12699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12700. }
  12701. m.AddOrganizationID(v)
  12702. return nil
  12703. case employee.FieldCategoryID:
  12704. v, ok := value.(int64)
  12705. if !ok {
  12706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12707. }
  12708. m.AddCategoryID(v)
  12709. return nil
  12710. case employee.FieldIsVip:
  12711. v, ok := value.(int)
  12712. if !ok {
  12713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12714. }
  12715. m.AddIsVip(v)
  12716. return nil
  12717. }
  12718. return fmt.Errorf("unknown Employee numeric field %s", name)
  12719. }
  12720. // ClearedFields returns all nullable fields that were cleared during this
  12721. // mutation.
  12722. func (m *EmployeeMutation) ClearedFields() []string {
  12723. var fields []string
  12724. if m.FieldCleared(employee.FieldDeletedAt) {
  12725. fields = append(fields, employee.FieldDeletedAt)
  12726. }
  12727. if m.FieldCleared(employee.FieldAiInfo) {
  12728. fields = append(fields, employee.FieldAiInfo)
  12729. }
  12730. return fields
  12731. }
  12732. // FieldCleared returns a boolean indicating if a field with the given name was
  12733. // cleared in this mutation.
  12734. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12735. _, ok := m.clearedFields[name]
  12736. return ok
  12737. }
  12738. // ClearField clears the value of the field with the given name. It returns an
  12739. // error if the field is not defined in the schema.
  12740. func (m *EmployeeMutation) ClearField(name string) error {
  12741. switch name {
  12742. case employee.FieldDeletedAt:
  12743. m.ClearDeletedAt()
  12744. return nil
  12745. case employee.FieldAiInfo:
  12746. m.ClearAiInfo()
  12747. return nil
  12748. }
  12749. return fmt.Errorf("unknown Employee nullable field %s", name)
  12750. }
  12751. // ResetField resets all changes in the mutation for the field with the given name.
  12752. // It returns an error if the field is not defined in the schema.
  12753. func (m *EmployeeMutation) ResetField(name string) error {
  12754. switch name {
  12755. case employee.FieldCreatedAt:
  12756. m.ResetCreatedAt()
  12757. return nil
  12758. case employee.FieldUpdatedAt:
  12759. m.ResetUpdatedAt()
  12760. return nil
  12761. case employee.FieldDeletedAt:
  12762. m.ResetDeletedAt()
  12763. return nil
  12764. case employee.FieldTitle:
  12765. m.ResetTitle()
  12766. return nil
  12767. case employee.FieldAvatar:
  12768. m.ResetAvatar()
  12769. return nil
  12770. case employee.FieldTags:
  12771. m.ResetTags()
  12772. return nil
  12773. case employee.FieldHireCount:
  12774. m.ResetHireCount()
  12775. return nil
  12776. case employee.FieldServiceCount:
  12777. m.ResetServiceCount()
  12778. return nil
  12779. case employee.FieldAchievementCount:
  12780. m.ResetAchievementCount()
  12781. return nil
  12782. case employee.FieldIntro:
  12783. m.ResetIntro()
  12784. return nil
  12785. case employee.FieldEstimate:
  12786. m.ResetEstimate()
  12787. return nil
  12788. case employee.FieldSkill:
  12789. m.ResetSkill()
  12790. return nil
  12791. case employee.FieldAbilityType:
  12792. m.ResetAbilityType()
  12793. return nil
  12794. case employee.FieldScene:
  12795. m.ResetScene()
  12796. return nil
  12797. case employee.FieldSwitchIn:
  12798. m.ResetSwitchIn()
  12799. return nil
  12800. case employee.FieldVideoURL:
  12801. m.ResetVideoURL()
  12802. return nil
  12803. case employee.FieldOrganizationID:
  12804. m.ResetOrganizationID()
  12805. return nil
  12806. case employee.FieldCategoryID:
  12807. m.ResetCategoryID()
  12808. return nil
  12809. case employee.FieldAPIBase:
  12810. m.ResetAPIBase()
  12811. return nil
  12812. case employee.FieldAPIKey:
  12813. m.ResetAPIKey()
  12814. return nil
  12815. case employee.FieldAiInfo:
  12816. m.ResetAiInfo()
  12817. return nil
  12818. case employee.FieldIsVip:
  12819. m.ResetIsVip()
  12820. return nil
  12821. case employee.FieldChatURL:
  12822. m.ResetChatURL()
  12823. return nil
  12824. }
  12825. return fmt.Errorf("unknown Employee field %s", name)
  12826. }
  12827. // AddedEdges returns all edge names that were set/added in this mutation.
  12828. func (m *EmployeeMutation) AddedEdges() []string {
  12829. edges := make([]string, 0, 2)
  12830. if m.em_work_experiences != nil {
  12831. edges = append(edges, employee.EdgeEmWorkExperiences)
  12832. }
  12833. if m.em_tutorial != nil {
  12834. edges = append(edges, employee.EdgeEmTutorial)
  12835. }
  12836. return edges
  12837. }
  12838. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12839. // name in this mutation.
  12840. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12841. switch name {
  12842. case employee.EdgeEmWorkExperiences:
  12843. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12844. for id := range m.em_work_experiences {
  12845. ids = append(ids, id)
  12846. }
  12847. return ids
  12848. case employee.EdgeEmTutorial:
  12849. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12850. for id := range m.em_tutorial {
  12851. ids = append(ids, id)
  12852. }
  12853. return ids
  12854. }
  12855. return nil
  12856. }
  12857. // RemovedEdges returns all edge names that were removed in this mutation.
  12858. func (m *EmployeeMutation) RemovedEdges() []string {
  12859. edges := make([]string, 0, 2)
  12860. if m.removedem_work_experiences != nil {
  12861. edges = append(edges, employee.EdgeEmWorkExperiences)
  12862. }
  12863. if m.removedem_tutorial != nil {
  12864. edges = append(edges, employee.EdgeEmTutorial)
  12865. }
  12866. return edges
  12867. }
  12868. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12869. // the given name in this mutation.
  12870. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12871. switch name {
  12872. case employee.EdgeEmWorkExperiences:
  12873. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12874. for id := range m.removedem_work_experiences {
  12875. ids = append(ids, id)
  12876. }
  12877. return ids
  12878. case employee.EdgeEmTutorial:
  12879. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12880. for id := range m.removedem_tutorial {
  12881. ids = append(ids, id)
  12882. }
  12883. return ids
  12884. }
  12885. return nil
  12886. }
  12887. // ClearedEdges returns all edge names that were cleared in this mutation.
  12888. func (m *EmployeeMutation) ClearedEdges() []string {
  12889. edges := make([]string, 0, 2)
  12890. if m.clearedem_work_experiences {
  12891. edges = append(edges, employee.EdgeEmWorkExperiences)
  12892. }
  12893. if m.clearedem_tutorial {
  12894. edges = append(edges, employee.EdgeEmTutorial)
  12895. }
  12896. return edges
  12897. }
  12898. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12899. // was cleared in this mutation.
  12900. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12901. switch name {
  12902. case employee.EdgeEmWorkExperiences:
  12903. return m.clearedem_work_experiences
  12904. case employee.EdgeEmTutorial:
  12905. return m.clearedem_tutorial
  12906. }
  12907. return false
  12908. }
  12909. // ClearEdge clears the value of the edge with the given name. It returns an error
  12910. // if that edge is not defined in the schema.
  12911. func (m *EmployeeMutation) ClearEdge(name string) error {
  12912. switch name {
  12913. }
  12914. return fmt.Errorf("unknown Employee unique edge %s", name)
  12915. }
  12916. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12917. // It returns an error if the edge is not defined in the schema.
  12918. func (m *EmployeeMutation) ResetEdge(name string) error {
  12919. switch name {
  12920. case employee.EdgeEmWorkExperiences:
  12921. m.ResetEmWorkExperiences()
  12922. return nil
  12923. case employee.EdgeEmTutorial:
  12924. m.ResetEmTutorial()
  12925. return nil
  12926. }
  12927. return fmt.Errorf("unknown Employee edge %s", name)
  12928. }
  12929. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12930. type EmployeeConfigMutation struct {
  12931. config
  12932. op Op
  12933. typ string
  12934. id *uint64
  12935. created_at *time.Time
  12936. updated_at *time.Time
  12937. deleted_at *time.Time
  12938. stype *string
  12939. title *string
  12940. photo *string
  12941. organization_id *uint64
  12942. addorganization_id *int64
  12943. clearedFields map[string]struct{}
  12944. done bool
  12945. oldValue func(context.Context) (*EmployeeConfig, error)
  12946. predicates []predicate.EmployeeConfig
  12947. }
  12948. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12949. // employeeconfigOption allows management of the mutation configuration using functional options.
  12950. type employeeconfigOption func(*EmployeeConfigMutation)
  12951. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12952. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12953. m := &EmployeeConfigMutation{
  12954. config: c,
  12955. op: op,
  12956. typ: TypeEmployeeConfig,
  12957. clearedFields: make(map[string]struct{}),
  12958. }
  12959. for _, opt := range opts {
  12960. opt(m)
  12961. }
  12962. return m
  12963. }
  12964. // withEmployeeConfigID sets the ID field of the mutation.
  12965. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12966. return func(m *EmployeeConfigMutation) {
  12967. var (
  12968. err error
  12969. once sync.Once
  12970. value *EmployeeConfig
  12971. )
  12972. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12973. once.Do(func() {
  12974. if m.done {
  12975. err = errors.New("querying old values post mutation is not allowed")
  12976. } else {
  12977. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12978. }
  12979. })
  12980. return value, err
  12981. }
  12982. m.id = &id
  12983. }
  12984. }
  12985. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12986. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12987. return func(m *EmployeeConfigMutation) {
  12988. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12989. return node, nil
  12990. }
  12991. m.id = &node.ID
  12992. }
  12993. }
  12994. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12995. // executed in a transaction (ent.Tx), a transactional client is returned.
  12996. func (m EmployeeConfigMutation) Client() *Client {
  12997. client := &Client{config: m.config}
  12998. client.init()
  12999. return client
  13000. }
  13001. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13002. // it returns an error otherwise.
  13003. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  13004. if _, ok := m.driver.(*txDriver); !ok {
  13005. return nil, errors.New("ent: mutation is not running in a transaction")
  13006. }
  13007. tx := &Tx{config: m.config}
  13008. tx.init()
  13009. return tx, nil
  13010. }
  13011. // SetID sets the value of the id field. Note that this
  13012. // operation is only accepted on creation of EmployeeConfig entities.
  13013. func (m *EmployeeConfigMutation) SetID(id uint64) {
  13014. m.id = &id
  13015. }
  13016. // ID returns the ID value in the mutation. Note that the ID is only available
  13017. // if it was provided to the builder or after it was returned from the database.
  13018. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  13019. if m.id == nil {
  13020. return
  13021. }
  13022. return *m.id, true
  13023. }
  13024. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13025. // That means, if the mutation is applied within a transaction with an isolation level such
  13026. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13027. // or updated by the mutation.
  13028. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  13029. switch {
  13030. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13031. id, exists := m.ID()
  13032. if exists {
  13033. return []uint64{id}, nil
  13034. }
  13035. fallthrough
  13036. case m.op.Is(OpUpdate | OpDelete):
  13037. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  13038. default:
  13039. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13040. }
  13041. }
  13042. // SetCreatedAt sets the "created_at" field.
  13043. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  13044. m.created_at = &t
  13045. }
  13046. // CreatedAt returns the value of the "created_at" field in the mutation.
  13047. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  13048. v := m.created_at
  13049. if v == nil {
  13050. return
  13051. }
  13052. return *v, true
  13053. }
  13054. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  13055. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13056. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13057. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13058. if !m.op.Is(OpUpdateOne) {
  13059. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13060. }
  13061. if m.id == nil || m.oldValue == nil {
  13062. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13063. }
  13064. oldValue, err := m.oldValue(ctx)
  13065. if err != nil {
  13066. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13067. }
  13068. return oldValue.CreatedAt, nil
  13069. }
  13070. // ResetCreatedAt resets all changes to the "created_at" field.
  13071. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  13072. m.created_at = nil
  13073. }
  13074. // SetUpdatedAt sets the "updated_at" field.
  13075. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13076. m.updated_at = &t
  13077. }
  13078. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13079. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13080. v := m.updated_at
  13081. if v == nil {
  13082. return
  13083. }
  13084. return *v, true
  13085. }
  13086. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13087. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13088. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13089. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13090. if !m.op.Is(OpUpdateOne) {
  13091. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13092. }
  13093. if m.id == nil || m.oldValue == nil {
  13094. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13095. }
  13096. oldValue, err := m.oldValue(ctx)
  13097. if err != nil {
  13098. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13099. }
  13100. return oldValue.UpdatedAt, nil
  13101. }
  13102. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13103. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13104. m.updated_at = nil
  13105. }
  13106. // SetDeletedAt sets the "deleted_at" field.
  13107. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13108. m.deleted_at = &t
  13109. }
  13110. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13111. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13112. v := m.deleted_at
  13113. if v == nil {
  13114. return
  13115. }
  13116. return *v, true
  13117. }
  13118. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13119. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13120. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13121. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13122. if !m.op.Is(OpUpdateOne) {
  13123. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13124. }
  13125. if m.id == nil || m.oldValue == nil {
  13126. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13127. }
  13128. oldValue, err := m.oldValue(ctx)
  13129. if err != nil {
  13130. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13131. }
  13132. return oldValue.DeletedAt, nil
  13133. }
  13134. // ClearDeletedAt clears the value of the "deleted_at" field.
  13135. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13136. m.deleted_at = nil
  13137. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13138. }
  13139. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13140. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13141. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13142. return ok
  13143. }
  13144. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13145. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13146. m.deleted_at = nil
  13147. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13148. }
  13149. // SetStype sets the "stype" field.
  13150. func (m *EmployeeConfigMutation) SetStype(s string) {
  13151. m.stype = &s
  13152. }
  13153. // Stype returns the value of the "stype" field in the mutation.
  13154. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13155. v := m.stype
  13156. if v == nil {
  13157. return
  13158. }
  13159. return *v, true
  13160. }
  13161. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13162. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13163. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13164. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13165. if !m.op.Is(OpUpdateOne) {
  13166. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13167. }
  13168. if m.id == nil || m.oldValue == nil {
  13169. return v, errors.New("OldStype requires an ID field in the mutation")
  13170. }
  13171. oldValue, err := m.oldValue(ctx)
  13172. if err != nil {
  13173. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13174. }
  13175. return oldValue.Stype, nil
  13176. }
  13177. // ResetStype resets all changes to the "stype" field.
  13178. func (m *EmployeeConfigMutation) ResetStype() {
  13179. m.stype = nil
  13180. }
  13181. // SetTitle sets the "title" field.
  13182. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13183. m.title = &s
  13184. }
  13185. // Title returns the value of the "title" field in the mutation.
  13186. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13187. v := m.title
  13188. if v == nil {
  13189. return
  13190. }
  13191. return *v, true
  13192. }
  13193. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13194. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13196. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13197. if !m.op.Is(OpUpdateOne) {
  13198. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13199. }
  13200. if m.id == nil || m.oldValue == nil {
  13201. return v, errors.New("OldTitle requires an ID field in the mutation")
  13202. }
  13203. oldValue, err := m.oldValue(ctx)
  13204. if err != nil {
  13205. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13206. }
  13207. return oldValue.Title, nil
  13208. }
  13209. // ResetTitle resets all changes to the "title" field.
  13210. func (m *EmployeeConfigMutation) ResetTitle() {
  13211. m.title = nil
  13212. }
  13213. // SetPhoto sets the "photo" field.
  13214. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13215. m.photo = &s
  13216. }
  13217. // Photo returns the value of the "photo" field in the mutation.
  13218. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13219. v := m.photo
  13220. if v == nil {
  13221. return
  13222. }
  13223. return *v, true
  13224. }
  13225. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13226. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13227. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13228. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13229. if !m.op.Is(OpUpdateOne) {
  13230. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13231. }
  13232. if m.id == nil || m.oldValue == nil {
  13233. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13234. }
  13235. oldValue, err := m.oldValue(ctx)
  13236. if err != nil {
  13237. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13238. }
  13239. return oldValue.Photo, nil
  13240. }
  13241. // ResetPhoto resets all changes to the "photo" field.
  13242. func (m *EmployeeConfigMutation) ResetPhoto() {
  13243. m.photo = nil
  13244. }
  13245. // SetOrganizationID sets the "organization_id" field.
  13246. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13247. m.organization_id = &u
  13248. m.addorganization_id = nil
  13249. }
  13250. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13251. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13252. v := m.organization_id
  13253. if v == nil {
  13254. return
  13255. }
  13256. return *v, true
  13257. }
  13258. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13259. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13261. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13262. if !m.op.Is(OpUpdateOne) {
  13263. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13264. }
  13265. if m.id == nil || m.oldValue == nil {
  13266. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13267. }
  13268. oldValue, err := m.oldValue(ctx)
  13269. if err != nil {
  13270. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13271. }
  13272. return oldValue.OrganizationID, nil
  13273. }
  13274. // AddOrganizationID adds u to the "organization_id" field.
  13275. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13276. if m.addorganization_id != nil {
  13277. *m.addorganization_id += u
  13278. } else {
  13279. m.addorganization_id = &u
  13280. }
  13281. }
  13282. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13283. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13284. v := m.addorganization_id
  13285. if v == nil {
  13286. return
  13287. }
  13288. return *v, true
  13289. }
  13290. // ClearOrganizationID clears the value of the "organization_id" field.
  13291. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13292. m.organization_id = nil
  13293. m.addorganization_id = nil
  13294. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13295. }
  13296. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13297. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13298. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13299. return ok
  13300. }
  13301. // ResetOrganizationID resets all changes to the "organization_id" field.
  13302. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13303. m.organization_id = nil
  13304. m.addorganization_id = nil
  13305. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13306. }
  13307. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13308. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13309. m.predicates = append(m.predicates, ps...)
  13310. }
  13311. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13312. // users can use type-assertion to append predicates that do not depend on any generated package.
  13313. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13314. p := make([]predicate.EmployeeConfig, len(ps))
  13315. for i := range ps {
  13316. p[i] = ps[i]
  13317. }
  13318. m.Where(p...)
  13319. }
  13320. // Op returns the operation name.
  13321. func (m *EmployeeConfigMutation) Op() Op {
  13322. return m.op
  13323. }
  13324. // SetOp allows setting the mutation operation.
  13325. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13326. m.op = op
  13327. }
  13328. // Type returns the node type of this mutation (EmployeeConfig).
  13329. func (m *EmployeeConfigMutation) Type() string {
  13330. return m.typ
  13331. }
  13332. // Fields returns all fields that were changed during this mutation. Note that in
  13333. // order to get all numeric fields that were incremented/decremented, call
  13334. // AddedFields().
  13335. func (m *EmployeeConfigMutation) Fields() []string {
  13336. fields := make([]string, 0, 7)
  13337. if m.created_at != nil {
  13338. fields = append(fields, employeeconfig.FieldCreatedAt)
  13339. }
  13340. if m.updated_at != nil {
  13341. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13342. }
  13343. if m.deleted_at != nil {
  13344. fields = append(fields, employeeconfig.FieldDeletedAt)
  13345. }
  13346. if m.stype != nil {
  13347. fields = append(fields, employeeconfig.FieldStype)
  13348. }
  13349. if m.title != nil {
  13350. fields = append(fields, employeeconfig.FieldTitle)
  13351. }
  13352. if m.photo != nil {
  13353. fields = append(fields, employeeconfig.FieldPhoto)
  13354. }
  13355. if m.organization_id != nil {
  13356. fields = append(fields, employeeconfig.FieldOrganizationID)
  13357. }
  13358. return fields
  13359. }
  13360. // Field returns the value of a field with the given name. The second boolean
  13361. // return value indicates that this field was not set, or was not defined in the
  13362. // schema.
  13363. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13364. switch name {
  13365. case employeeconfig.FieldCreatedAt:
  13366. return m.CreatedAt()
  13367. case employeeconfig.FieldUpdatedAt:
  13368. return m.UpdatedAt()
  13369. case employeeconfig.FieldDeletedAt:
  13370. return m.DeletedAt()
  13371. case employeeconfig.FieldStype:
  13372. return m.Stype()
  13373. case employeeconfig.FieldTitle:
  13374. return m.Title()
  13375. case employeeconfig.FieldPhoto:
  13376. return m.Photo()
  13377. case employeeconfig.FieldOrganizationID:
  13378. return m.OrganizationID()
  13379. }
  13380. return nil, false
  13381. }
  13382. // OldField returns the old value of the field from the database. An error is
  13383. // returned if the mutation operation is not UpdateOne, or the query to the
  13384. // database failed.
  13385. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13386. switch name {
  13387. case employeeconfig.FieldCreatedAt:
  13388. return m.OldCreatedAt(ctx)
  13389. case employeeconfig.FieldUpdatedAt:
  13390. return m.OldUpdatedAt(ctx)
  13391. case employeeconfig.FieldDeletedAt:
  13392. return m.OldDeletedAt(ctx)
  13393. case employeeconfig.FieldStype:
  13394. return m.OldStype(ctx)
  13395. case employeeconfig.FieldTitle:
  13396. return m.OldTitle(ctx)
  13397. case employeeconfig.FieldPhoto:
  13398. return m.OldPhoto(ctx)
  13399. case employeeconfig.FieldOrganizationID:
  13400. return m.OldOrganizationID(ctx)
  13401. }
  13402. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13403. }
  13404. // SetField sets the value of a field with the given name. It returns an error if
  13405. // the field is not defined in the schema, or if the type mismatched the field
  13406. // type.
  13407. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13408. switch name {
  13409. case employeeconfig.FieldCreatedAt:
  13410. v, ok := value.(time.Time)
  13411. if !ok {
  13412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13413. }
  13414. m.SetCreatedAt(v)
  13415. return nil
  13416. case employeeconfig.FieldUpdatedAt:
  13417. v, ok := value.(time.Time)
  13418. if !ok {
  13419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13420. }
  13421. m.SetUpdatedAt(v)
  13422. return nil
  13423. case employeeconfig.FieldDeletedAt:
  13424. v, ok := value.(time.Time)
  13425. if !ok {
  13426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13427. }
  13428. m.SetDeletedAt(v)
  13429. return nil
  13430. case employeeconfig.FieldStype:
  13431. v, ok := value.(string)
  13432. if !ok {
  13433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13434. }
  13435. m.SetStype(v)
  13436. return nil
  13437. case employeeconfig.FieldTitle:
  13438. v, ok := value.(string)
  13439. if !ok {
  13440. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13441. }
  13442. m.SetTitle(v)
  13443. return nil
  13444. case employeeconfig.FieldPhoto:
  13445. v, ok := value.(string)
  13446. if !ok {
  13447. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13448. }
  13449. m.SetPhoto(v)
  13450. return nil
  13451. case employeeconfig.FieldOrganizationID:
  13452. v, ok := value.(uint64)
  13453. if !ok {
  13454. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13455. }
  13456. m.SetOrganizationID(v)
  13457. return nil
  13458. }
  13459. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13460. }
  13461. // AddedFields returns all numeric fields that were incremented/decremented during
  13462. // this mutation.
  13463. func (m *EmployeeConfigMutation) AddedFields() []string {
  13464. var fields []string
  13465. if m.addorganization_id != nil {
  13466. fields = append(fields, employeeconfig.FieldOrganizationID)
  13467. }
  13468. return fields
  13469. }
  13470. // AddedField returns the numeric value that was incremented/decremented on a field
  13471. // with the given name. The second boolean return value indicates that this field
  13472. // was not set, or was not defined in the schema.
  13473. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13474. switch name {
  13475. case employeeconfig.FieldOrganizationID:
  13476. return m.AddedOrganizationID()
  13477. }
  13478. return nil, false
  13479. }
  13480. // AddField adds the value to the field with the given name. It returns an error if
  13481. // the field is not defined in the schema, or if the type mismatched the field
  13482. // type.
  13483. func (m *EmployeeConfigMutation) AddField(name string, value ent.Value) error {
  13484. switch name {
  13485. case employeeconfig.FieldOrganizationID:
  13486. v, ok := value.(int64)
  13487. if !ok {
  13488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13489. }
  13490. m.AddOrganizationID(v)
  13491. return nil
  13492. }
  13493. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13494. }
  13495. // ClearedFields returns all nullable fields that were cleared during this
  13496. // mutation.
  13497. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13498. var fields []string
  13499. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13500. fields = append(fields, employeeconfig.FieldDeletedAt)
  13501. }
  13502. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13503. fields = append(fields, employeeconfig.FieldOrganizationID)
  13504. }
  13505. return fields
  13506. }
  13507. // FieldCleared returns a boolean indicating if a field with the given name was
  13508. // cleared in this mutation.
  13509. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13510. _, ok := m.clearedFields[name]
  13511. return ok
  13512. }
  13513. // ClearField clears the value of the field with the given name. It returns an
  13514. // error if the field is not defined in the schema.
  13515. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13516. switch name {
  13517. case employeeconfig.FieldDeletedAt:
  13518. m.ClearDeletedAt()
  13519. return nil
  13520. case employeeconfig.FieldOrganizationID:
  13521. m.ClearOrganizationID()
  13522. return nil
  13523. }
  13524. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13525. }
  13526. // ResetField resets all changes in the mutation for the field with the given name.
  13527. // It returns an error if the field is not defined in the schema.
  13528. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13529. switch name {
  13530. case employeeconfig.FieldCreatedAt:
  13531. m.ResetCreatedAt()
  13532. return nil
  13533. case employeeconfig.FieldUpdatedAt:
  13534. m.ResetUpdatedAt()
  13535. return nil
  13536. case employeeconfig.FieldDeletedAt:
  13537. m.ResetDeletedAt()
  13538. return nil
  13539. case employeeconfig.FieldStype:
  13540. m.ResetStype()
  13541. return nil
  13542. case employeeconfig.FieldTitle:
  13543. m.ResetTitle()
  13544. return nil
  13545. case employeeconfig.FieldPhoto:
  13546. m.ResetPhoto()
  13547. return nil
  13548. case employeeconfig.FieldOrganizationID:
  13549. m.ResetOrganizationID()
  13550. return nil
  13551. }
  13552. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13553. }
  13554. // AddedEdges returns all edge names that were set/added in this mutation.
  13555. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13556. edges := make([]string, 0, 0)
  13557. return edges
  13558. }
  13559. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13560. // name in this mutation.
  13561. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13562. return nil
  13563. }
  13564. // RemovedEdges returns all edge names that were removed in this mutation.
  13565. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13566. edges := make([]string, 0, 0)
  13567. return edges
  13568. }
  13569. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13570. // the given name in this mutation.
  13571. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13572. return nil
  13573. }
  13574. // ClearedEdges returns all edge names that were cleared in this mutation.
  13575. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13576. edges := make([]string, 0, 0)
  13577. return edges
  13578. }
  13579. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13580. // was cleared in this mutation.
  13581. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13582. return false
  13583. }
  13584. // ClearEdge clears the value of the edge with the given name. It returns an error
  13585. // if that edge is not defined in the schema.
  13586. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13587. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13588. }
  13589. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13590. // It returns an error if the edge is not defined in the schema.
  13591. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13592. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13593. }
  13594. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13595. type LabelMutation struct {
  13596. config
  13597. op Op
  13598. typ string
  13599. id *uint64
  13600. created_at *time.Time
  13601. updated_at *time.Time
  13602. status *uint8
  13603. addstatus *int8
  13604. _type *int
  13605. add_type *int
  13606. name *string
  13607. from *int
  13608. addfrom *int
  13609. mode *int
  13610. addmode *int
  13611. conditions *string
  13612. organization_id *uint64
  13613. addorganization_id *int64
  13614. clearedFields map[string]struct{}
  13615. label_relationships map[uint64]struct{}
  13616. removedlabel_relationships map[uint64]struct{}
  13617. clearedlabel_relationships bool
  13618. done bool
  13619. oldValue func(context.Context) (*Label, error)
  13620. predicates []predicate.Label
  13621. }
  13622. var _ ent.Mutation = (*LabelMutation)(nil)
  13623. // labelOption allows management of the mutation configuration using functional options.
  13624. type labelOption func(*LabelMutation)
  13625. // newLabelMutation creates new mutation for the Label entity.
  13626. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13627. m := &LabelMutation{
  13628. config: c,
  13629. op: op,
  13630. typ: TypeLabel,
  13631. clearedFields: make(map[string]struct{}),
  13632. }
  13633. for _, opt := range opts {
  13634. opt(m)
  13635. }
  13636. return m
  13637. }
  13638. // withLabelID sets the ID field of the mutation.
  13639. func withLabelID(id uint64) labelOption {
  13640. return func(m *LabelMutation) {
  13641. var (
  13642. err error
  13643. once sync.Once
  13644. value *Label
  13645. )
  13646. m.oldValue = func(ctx context.Context) (*Label, error) {
  13647. once.Do(func() {
  13648. if m.done {
  13649. err = errors.New("querying old values post mutation is not allowed")
  13650. } else {
  13651. value, err = m.Client().Label.Get(ctx, id)
  13652. }
  13653. })
  13654. return value, err
  13655. }
  13656. m.id = &id
  13657. }
  13658. }
  13659. // withLabel sets the old Label of the mutation.
  13660. func withLabel(node *Label) labelOption {
  13661. return func(m *LabelMutation) {
  13662. m.oldValue = func(context.Context) (*Label, error) {
  13663. return node, nil
  13664. }
  13665. m.id = &node.ID
  13666. }
  13667. }
  13668. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13669. // executed in a transaction (ent.Tx), a transactional client is returned.
  13670. func (m LabelMutation) Client() *Client {
  13671. client := &Client{config: m.config}
  13672. client.init()
  13673. return client
  13674. }
  13675. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13676. // it returns an error otherwise.
  13677. func (m LabelMutation) Tx() (*Tx, error) {
  13678. if _, ok := m.driver.(*txDriver); !ok {
  13679. return nil, errors.New("ent: mutation is not running in a transaction")
  13680. }
  13681. tx := &Tx{config: m.config}
  13682. tx.init()
  13683. return tx, nil
  13684. }
  13685. // SetID sets the value of the id field. Note that this
  13686. // operation is only accepted on creation of Label entities.
  13687. func (m *LabelMutation) SetID(id uint64) {
  13688. m.id = &id
  13689. }
  13690. // ID returns the ID value in the mutation. Note that the ID is only available
  13691. // if it was provided to the builder or after it was returned from the database.
  13692. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13693. if m.id == nil {
  13694. return
  13695. }
  13696. return *m.id, true
  13697. }
  13698. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13699. // That means, if the mutation is applied within a transaction with an isolation level such
  13700. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13701. // or updated by the mutation.
  13702. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13703. switch {
  13704. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13705. id, exists := m.ID()
  13706. if exists {
  13707. return []uint64{id}, nil
  13708. }
  13709. fallthrough
  13710. case m.op.Is(OpUpdate | OpDelete):
  13711. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13712. default:
  13713. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13714. }
  13715. }
  13716. // SetCreatedAt sets the "created_at" field.
  13717. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13718. m.created_at = &t
  13719. }
  13720. // CreatedAt returns the value of the "created_at" field in the mutation.
  13721. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13722. v := m.created_at
  13723. if v == nil {
  13724. return
  13725. }
  13726. return *v, true
  13727. }
  13728. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13729. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13731. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13732. if !m.op.Is(OpUpdateOne) {
  13733. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13734. }
  13735. if m.id == nil || m.oldValue == nil {
  13736. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13737. }
  13738. oldValue, err := m.oldValue(ctx)
  13739. if err != nil {
  13740. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13741. }
  13742. return oldValue.CreatedAt, nil
  13743. }
  13744. // ResetCreatedAt resets all changes to the "created_at" field.
  13745. func (m *LabelMutation) ResetCreatedAt() {
  13746. m.created_at = nil
  13747. }
  13748. // SetUpdatedAt sets the "updated_at" field.
  13749. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13750. m.updated_at = &t
  13751. }
  13752. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13753. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13754. v := m.updated_at
  13755. if v == nil {
  13756. return
  13757. }
  13758. return *v, true
  13759. }
  13760. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13761. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13762. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13763. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13764. if !m.op.Is(OpUpdateOne) {
  13765. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13766. }
  13767. if m.id == nil || m.oldValue == nil {
  13768. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13769. }
  13770. oldValue, err := m.oldValue(ctx)
  13771. if err != nil {
  13772. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13773. }
  13774. return oldValue.UpdatedAt, nil
  13775. }
  13776. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13777. func (m *LabelMutation) ResetUpdatedAt() {
  13778. m.updated_at = nil
  13779. }
  13780. // SetStatus sets the "status" field.
  13781. func (m *LabelMutation) SetStatus(u uint8) {
  13782. m.status = &u
  13783. m.addstatus = nil
  13784. }
  13785. // Status returns the value of the "status" field in the mutation.
  13786. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13787. v := m.status
  13788. if v == nil {
  13789. return
  13790. }
  13791. return *v, true
  13792. }
  13793. // OldStatus returns the old "status" field's value of the Label entity.
  13794. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13795. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13796. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13797. if !m.op.Is(OpUpdateOne) {
  13798. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13799. }
  13800. if m.id == nil || m.oldValue == nil {
  13801. return v, errors.New("OldStatus requires an ID field in the mutation")
  13802. }
  13803. oldValue, err := m.oldValue(ctx)
  13804. if err != nil {
  13805. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13806. }
  13807. return oldValue.Status, nil
  13808. }
  13809. // AddStatus adds u to the "status" field.
  13810. func (m *LabelMutation) AddStatus(u int8) {
  13811. if m.addstatus != nil {
  13812. *m.addstatus += u
  13813. } else {
  13814. m.addstatus = &u
  13815. }
  13816. }
  13817. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13818. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13819. v := m.addstatus
  13820. if v == nil {
  13821. return
  13822. }
  13823. return *v, true
  13824. }
  13825. // ClearStatus clears the value of the "status" field.
  13826. func (m *LabelMutation) ClearStatus() {
  13827. m.status = nil
  13828. m.addstatus = nil
  13829. m.clearedFields[label.FieldStatus] = struct{}{}
  13830. }
  13831. // StatusCleared returns if the "status" field was cleared in this mutation.
  13832. func (m *LabelMutation) StatusCleared() bool {
  13833. _, ok := m.clearedFields[label.FieldStatus]
  13834. return ok
  13835. }
  13836. // ResetStatus resets all changes to the "status" field.
  13837. func (m *LabelMutation) ResetStatus() {
  13838. m.status = nil
  13839. m.addstatus = nil
  13840. delete(m.clearedFields, label.FieldStatus)
  13841. }
  13842. // SetType sets the "type" field.
  13843. func (m *LabelMutation) SetType(i int) {
  13844. m._type = &i
  13845. m.add_type = nil
  13846. }
  13847. // GetType returns the value of the "type" field in the mutation.
  13848. func (m *LabelMutation) GetType() (r int, exists bool) {
  13849. v := m._type
  13850. if v == nil {
  13851. return
  13852. }
  13853. return *v, true
  13854. }
  13855. // OldType returns the old "type" field's value of the Label entity.
  13856. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13858. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13859. if !m.op.Is(OpUpdateOne) {
  13860. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13861. }
  13862. if m.id == nil || m.oldValue == nil {
  13863. return v, errors.New("OldType requires an ID field in the mutation")
  13864. }
  13865. oldValue, err := m.oldValue(ctx)
  13866. if err != nil {
  13867. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13868. }
  13869. return oldValue.Type, nil
  13870. }
  13871. // AddType adds i to the "type" field.
  13872. func (m *LabelMutation) AddType(i int) {
  13873. if m.add_type != nil {
  13874. *m.add_type += i
  13875. } else {
  13876. m.add_type = &i
  13877. }
  13878. }
  13879. // AddedType returns the value that was added to the "type" field in this mutation.
  13880. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13881. v := m.add_type
  13882. if v == nil {
  13883. return
  13884. }
  13885. return *v, true
  13886. }
  13887. // ResetType resets all changes to the "type" field.
  13888. func (m *LabelMutation) ResetType() {
  13889. m._type = nil
  13890. m.add_type = nil
  13891. }
  13892. // SetName sets the "name" field.
  13893. func (m *LabelMutation) SetName(s string) {
  13894. m.name = &s
  13895. }
  13896. // Name returns the value of the "name" field in the mutation.
  13897. func (m *LabelMutation) Name() (r string, exists bool) {
  13898. v := m.name
  13899. if v == nil {
  13900. return
  13901. }
  13902. return *v, true
  13903. }
  13904. // OldName returns the old "name" field's value of the Label entity.
  13905. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13907. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13908. if !m.op.Is(OpUpdateOne) {
  13909. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13910. }
  13911. if m.id == nil || m.oldValue == nil {
  13912. return v, errors.New("OldName requires an ID field in the mutation")
  13913. }
  13914. oldValue, err := m.oldValue(ctx)
  13915. if err != nil {
  13916. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13917. }
  13918. return oldValue.Name, nil
  13919. }
  13920. // ResetName resets all changes to the "name" field.
  13921. func (m *LabelMutation) ResetName() {
  13922. m.name = nil
  13923. }
  13924. // SetFrom sets the "from" field.
  13925. func (m *LabelMutation) SetFrom(i int) {
  13926. m.from = &i
  13927. m.addfrom = nil
  13928. }
  13929. // From returns the value of the "from" field in the mutation.
  13930. func (m *LabelMutation) From() (r int, exists bool) {
  13931. v := m.from
  13932. if v == nil {
  13933. return
  13934. }
  13935. return *v, true
  13936. }
  13937. // OldFrom returns the old "from" field's value of the Label entity.
  13938. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13940. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13941. if !m.op.Is(OpUpdateOne) {
  13942. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13943. }
  13944. if m.id == nil || m.oldValue == nil {
  13945. return v, errors.New("OldFrom requires an ID field in the mutation")
  13946. }
  13947. oldValue, err := m.oldValue(ctx)
  13948. if err != nil {
  13949. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13950. }
  13951. return oldValue.From, nil
  13952. }
  13953. // AddFrom adds i to the "from" field.
  13954. func (m *LabelMutation) AddFrom(i int) {
  13955. if m.addfrom != nil {
  13956. *m.addfrom += i
  13957. } else {
  13958. m.addfrom = &i
  13959. }
  13960. }
  13961. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13962. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13963. v := m.addfrom
  13964. if v == nil {
  13965. return
  13966. }
  13967. return *v, true
  13968. }
  13969. // ResetFrom resets all changes to the "from" field.
  13970. func (m *LabelMutation) ResetFrom() {
  13971. m.from = nil
  13972. m.addfrom = nil
  13973. }
  13974. // SetMode sets the "mode" field.
  13975. func (m *LabelMutation) SetMode(i int) {
  13976. m.mode = &i
  13977. m.addmode = nil
  13978. }
  13979. // Mode returns the value of the "mode" field in the mutation.
  13980. func (m *LabelMutation) Mode() (r int, exists bool) {
  13981. v := m.mode
  13982. if v == nil {
  13983. return
  13984. }
  13985. return *v, true
  13986. }
  13987. // OldMode returns the old "mode" field's value of the Label entity.
  13988. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13989. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13990. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13991. if !m.op.Is(OpUpdateOne) {
  13992. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13993. }
  13994. if m.id == nil || m.oldValue == nil {
  13995. return v, errors.New("OldMode requires an ID field in the mutation")
  13996. }
  13997. oldValue, err := m.oldValue(ctx)
  13998. if err != nil {
  13999. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  14000. }
  14001. return oldValue.Mode, nil
  14002. }
  14003. // AddMode adds i to the "mode" field.
  14004. func (m *LabelMutation) AddMode(i int) {
  14005. if m.addmode != nil {
  14006. *m.addmode += i
  14007. } else {
  14008. m.addmode = &i
  14009. }
  14010. }
  14011. // AddedMode returns the value that was added to the "mode" field in this mutation.
  14012. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  14013. v := m.addmode
  14014. if v == nil {
  14015. return
  14016. }
  14017. return *v, true
  14018. }
  14019. // ResetMode resets all changes to the "mode" field.
  14020. func (m *LabelMutation) ResetMode() {
  14021. m.mode = nil
  14022. m.addmode = nil
  14023. }
  14024. // SetConditions sets the "conditions" field.
  14025. func (m *LabelMutation) SetConditions(s string) {
  14026. m.conditions = &s
  14027. }
  14028. // Conditions returns the value of the "conditions" field in the mutation.
  14029. func (m *LabelMutation) Conditions() (r string, exists bool) {
  14030. v := m.conditions
  14031. if v == nil {
  14032. return
  14033. }
  14034. return *v, true
  14035. }
  14036. // OldConditions returns the old "conditions" field's value of the Label entity.
  14037. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14038. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14039. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  14040. if !m.op.Is(OpUpdateOne) {
  14041. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  14042. }
  14043. if m.id == nil || m.oldValue == nil {
  14044. return v, errors.New("OldConditions requires an ID field in the mutation")
  14045. }
  14046. oldValue, err := m.oldValue(ctx)
  14047. if err != nil {
  14048. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  14049. }
  14050. return oldValue.Conditions, nil
  14051. }
  14052. // ClearConditions clears the value of the "conditions" field.
  14053. func (m *LabelMutation) ClearConditions() {
  14054. m.conditions = nil
  14055. m.clearedFields[label.FieldConditions] = struct{}{}
  14056. }
  14057. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  14058. func (m *LabelMutation) ConditionsCleared() bool {
  14059. _, ok := m.clearedFields[label.FieldConditions]
  14060. return ok
  14061. }
  14062. // ResetConditions resets all changes to the "conditions" field.
  14063. func (m *LabelMutation) ResetConditions() {
  14064. m.conditions = nil
  14065. delete(m.clearedFields, label.FieldConditions)
  14066. }
  14067. // SetOrganizationID sets the "organization_id" field.
  14068. func (m *LabelMutation) SetOrganizationID(u uint64) {
  14069. m.organization_id = &u
  14070. m.addorganization_id = nil
  14071. }
  14072. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14073. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  14074. v := m.organization_id
  14075. if v == nil {
  14076. return
  14077. }
  14078. return *v, true
  14079. }
  14080. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14081. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14083. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14084. if !m.op.Is(OpUpdateOne) {
  14085. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14086. }
  14087. if m.id == nil || m.oldValue == nil {
  14088. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14089. }
  14090. oldValue, err := m.oldValue(ctx)
  14091. if err != nil {
  14092. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14093. }
  14094. return oldValue.OrganizationID, nil
  14095. }
  14096. // AddOrganizationID adds u to the "organization_id" field.
  14097. func (m *LabelMutation) AddOrganizationID(u int64) {
  14098. if m.addorganization_id != nil {
  14099. *m.addorganization_id += u
  14100. } else {
  14101. m.addorganization_id = &u
  14102. }
  14103. }
  14104. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14105. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14106. v := m.addorganization_id
  14107. if v == nil {
  14108. return
  14109. }
  14110. return *v, true
  14111. }
  14112. // ClearOrganizationID clears the value of the "organization_id" field.
  14113. func (m *LabelMutation) ClearOrganizationID() {
  14114. m.organization_id = nil
  14115. m.addorganization_id = nil
  14116. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14117. }
  14118. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14119. func (m *LabelMutation) OrganizationIDCleared() bool {
  14120. _, ok := m.clearedFields[label.FieldOrganizationID]
  14121. return ok
  14122. }
  14123. // ResetOrganizationID resets all changes to the "organization_id" field.
  14124. func (m *LabelMutation) ResetOrganizationID() {
  14125. m.organization_id = nil
  14126. m.addorganization_id = nil
  14127. delete(m.clearedFields, label.FieldOrganizationID)
  14128. }
  14129. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14130. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14131. if m.label_relationships == nil {
  14132. m.label_relationships = make(map[uint64]struct{})
  14133. }
  14134. for i := range ids {
  14135. m.label_relationships[ids[i]] = struct{}{}
  14136. }
  14137. }
  14138. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14139. func (m *LabelMutation) ClearLabelRelationships() {
  14140. m.clearedlabel_relationships = true
  14141. }
  14142. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14143. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14144. return m.clearedlabel_relationships
  14145. }
  14146. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14147. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14148. if m.removedlabel_relationships == nil {
  14149. m.removedlabel_relationships = make(map[uint64]struct{})
  14150. }
  14151. for i := range ids {
  14152. delete(m.label_relationships, ids[i])
  14153. m.removedlabel_relationships[ids[i]] = struct{}{}
  14154. }
  14155. }
  14156. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14157. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14158. for id := range m.removedlabel_relationships {
  14159. ids = append(ids, id)
  14160. }
  14161. return
  14162. }
  14163. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14164. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14165. for id := range m.label_relationships {
  14166. ids = append(ids, id)
  14167. }
  14168. return
  14169. }
  14170. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14171. func (m *LabelMutation) ResetLabelRelationships() {
  14172. m.label_relationships = nil
  14173. m.clearedlabel_relationships = false
  14174. m.removedlabel_relationships = nil
  14175. }
  14176. // Where appends a list predicates to the LabelMutation builder.
  14177. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14178. m.predicates = append(m.predicates, ps...)
  14179. }
  14180. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14181. // users can use type-assertion to append predicates that do not depend on any generated package.
  14182. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14183. p := make([]predicate.Label, len(ps))
  14184. for i := range ps {
  14185. p[i] = ps[i]
  14186. }
  14187. m.Where(p...)
  14188. }
  14189. // Op returns the operation name.
  14190. func (m *LabelMutation) Op() Op {
  14191. return m.op
  14192. }
  14193. // SetOp allows setting the mutation operation.
  14194. func (m *LabelMutation) SetOp(op Op) {
  14195. m.op = op
  14196. }
  14197. // Type returns the node type of this mutation (Label).
  14198. func (m *LabelMutation) Type() string {
  14199. return m.typ
  14200. }
  14201. // Fields returns all fields that were changed during this mutation. Note that in
  14202. // order to get all numeric fields that were incremented/decremented, call
  14203. // AddedFields().
  14204. func (m *LabelMutation) Fields() []string {
  14205. fields := make([]string, 0, 9)
  14206. if m.created_at != nil {
  14207. fields = append(fields, label.FieldCreatedAt)
  14208. }
  14209. if m.updated_at != nil {
  14210. fields = append(fields, label.FieldUpdatedAt)
  14211. }
  14212. if m.status != nil {
  14213. fields = append(fields, label.FieldStatus)
  14214. }
  14215. if m._type != nil {
  14216. fields = append(fields, label.FieldType)
  14217. }
  14218. if m.name != nil {
  14219. fields = append(fields, label.FieldName)
  14220. }
  14221. if m.from != nil {
  14222. fields = append(fields, label.FieldFrom)
  14223. }
  14224. if m.mode != nil {
  14225. fields = append(fields, label.FieldMode)
  14226. }
  14227. if m.conditions != nil {
  14228. fields = append(fields, label.FieldConditions)
  14229. }
  14230. if m.organization_id != nil {
  14231. fields = append(fields, label.FieldOrganizationID)
  14232. }
  14233. return fields
  14234. }
  14235. // Field returns the value of a field with the given name. The second boolean
  14236. // return value indicates that this field was not set, or was not defined in the
  14237. // schema.
  14238. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14239. switch name {
  14240. case label.FieldCreatedAt:
  14241. return m.CreatedAt()
  14242. case label.FieldUpdatedAt:
  14243. return m.UpdatedAt()
  14244. case label.FieldStatus:
  14245. return m.Status()
  14246. case label.FieldType:
  14247. return m.GetType()
  14248. case label.FieldName:
  14249. return m.Name()
  14250. case label.FieldFrom:
  14251. return m.From()
  14252. case label.FieldMode:
  14253. return m.Mode()
  14254. case label.FieldConditions:
  14255. return m.Conditions()
  14256. case label.FieldOrganizationID:
  14257. return m.OrganizationID()
  14258. }
  14259. return nil, false
  14260. }
  14261. // OldField returns the old value of the field from the database. An error is
  14262. // returned if the mutation operation is not UpdateOne, or the query to the
  14263. // database failed.
  14264. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14265. switch name {
  14266. case label.FieldCreatedAt:
  14267. return m.OldCreatedAt(ctx)
  14268. case label.FieldUpdatedAt:
  14269. return m.OldUpdatedAt(ctx)
  14270. case label.FieldStatus:
  14271. return m.OldStatus(ctx)
  14272. case label.FieldType:
  14273. return m.OldType(ctx)
  14274. case label.FieldName:
  14275. return m.OldName(ctx)
  14276. case label.FieldFrom:
  14277. return m.OldFrom(ctx)
  14278. case label.FieldMode:
  14279. return m.OldMode(ctx)
  14280. case label.FieldConditions:
  14281. return m.OldConditions(ctx)
  14282. case label.FieldOrganizationID:
  14283. return m.OldOrganizationID(ctx)
  14284. }
  14285. return nil, fmt.Errorf("unknown Label field %s", name)
  14286. }
  14287. // SetField sets the value of a field with the given name. It returns an error if
  14288. // the field is not defined in the schema, or if the type mismatched the field
  14289. // type.
  14290. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14291. switch name {
  14292. case label.FieldCreatedAt:
  14293. v, ok := value.(time.Time)
  14294. if !ok {
  14295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14296. }
  14297. m.SetCreatedAt(v)
  14298. return nil
  14299. case label.FieldUpdatedAt:
  14300. v, ok := value.(time.Time)
  14301. if !ok {
  14302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14303. }
  14304. m.SetUpdatedAt(v)
  14305. return nil
  14306. case label.FieldStatus:
  14307. v, ok := value.(uint8)
  14308. if !ok {
  14309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14310. }
  14311. m.SetStatus(v)
  14312. return nil
  14313. case label.FieldType:
  14314. v, ok := value.(int)
  14315. if !ok {
  14316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14317. }
  14318. m.SetType(v)
  14319. return nil
  14320. case label.FieldName:
  14321. v, ok := value.(string)
  14322. if !ok {
  14323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14324. }
  14325. m.SetName(v)
  14326. return nil
  14327. case label.FieldFrom:
  14328. v, ok := value.(int)
  14329. if !ok {
  14330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14331. }
  14332. m.SetFrom(v)
  14333. return nil
  14334. case label.FieldMode:
  14335. v, ok := value.(int)
  14336. if !ok {
  14337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14338. }
  14339. m.SetMode(v)
  14340. return nil
  14341. case label.FieldConditions:
  14342. v, ok := value.(string)
  14343. if !ok {
  14344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14345. }
  14346. m.SetConditions(v)
  14347. return nil
  14348. case label.FieldOrganizationID:
  14349. v, ok := value.(uint64)
  14350. if !ok {
  14351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14352. }
  14353. m.SetOrganizationID(v)
  14354. return nil
  14355. }
  14356. return fmt.Errorf("unknown Label field %s", name)
  14357. }
  14358. // AddedFields returns all numeric fields that were incremented/decremented during
  14359. // this mutation.
  14360. func (m *LabelMutation) AddedFields() []string {
  14361. var fields []string
  14362. if m.addstatus != nil {
  14363. fields = append(fields, label.FieldStatus)
  14364. }
  14365. if m.add_type != nil {
  14366. fields = append(fields, label.FieldType)
  14367. }
  14368. if m.addfrom != nil {
  14369. fields = append(fields, label.FieldFrom)
  14370. }
  14371. if m.addmode != nil {
  14372. fields = append(fields, label.FieldMode)
  14373. }
  14374. if m.addorganization_id != nil {
  14375. fields = append(fields, label.FieldOrganizationID)
  14376. }
  14377. return fields
  14378. }
  14379. // AddedField returns the numeric value that was incremented/decremented on a field
  14380. // with the given name. The second boolean return value indicates that this field
  14381. // was not set, or was not defined in the schema.
  14382. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14383. switch name {
  14384. case label.FieldStatus:
  14385. return m.AddedStatus()
  14386. case label.FieldType:
  14387. return m.AddedType()
  14388. case label.FieldFrom:
  14389. return m.AddedFrom()
  14390. case label.FieldMode:
  14391. return m.AddedMode()
  14392. case label.FieldOrganizationID:
  14393. return m.AddedOrganizationID()
  14394. }
  14395. return nil, false
  14396. }
  14397. // AddField adds the value to the field with the given name. It returns an error if
  14398. // the field is not defined in the schema, or if the type mismatched the field
  14399. // type.
  14400. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14401. switch name {
  14402. case label.FieldStatus:
  14403. v, ok := value.(int8)
  14404. if !ok {
  14405. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14406. }
  14407. m.AddStatus(v)
  14408. return nil
  14409. case label.FieldType:
  14410. v, ok := value.(int)
  14411. if !ok {
  14412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14413. }
  14414. m.AddType(v)
  14415. return nil
  14416. case label.FieldFrom:
  14417. v, ok := value.(int)
  14418. if !ok {
  14419. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14420. }
  14421. m.AddFrom(v)
  14422. return nil
  14423. case label.FieldMode:
  14424. v, ok := value.(int)
  14425. if !ok {
  14426. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14427. }
  14428. m.AddMode(v)
  14429. return nil
  14430. case label.FieldOrganizationID:
  14431. v, ok := value.(int64)
  14432. if !ok {
  14433. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14434. }
  14435. m.AddOrganizationID(v)
  14436. return nil
  14437. }
  14438. return fmt.Errorf("unknown Label numeric field %s", name)
  14439. }
  14440. // ClearedFields returns all nullable fields that were cleared during this
  14441. // mutation.
  14442. func (m *LabelMutation) ClearedFields() []string {
  14443. var fields []string
  14444. if m.FieldCleared(label.FieldStatus) {
  14445. fields = append(fields, label.FieldStatus)
  14446. }
  14447. if m.FieldCleared(label.FieldConditions) {
  14448. fields = append(fields, label.FieldConditions)
  14449. }
  14450. if m.FieldCleared(label.FieldOrganizationID) {
  14451. fields = append(fields, label.FieldOrganizationID)
  14452. }
  14453. return fields
  14454. }
  14455. // FieldCleared returns a boolean indicating if a field with the given name was
  14456. // cleared in this mutation.
  14457. func (m *LabelMutation) FieldCleared(name string) bool {
  14458. _, ok := m.clearedFields[name]
  14459. return ok
  14460. }
  14461. // ClearField clears the value of the field with the given name. It returns an
  14462. // error if the field is not defined in the schema.
  14463. func (m *LabelMutation) ClearField(name string) error {
  14464. switch name {
  14465. case label.FieldStatus:
  14466. m.ClearStatus()
  14467. return nil
  14468. case label.FieldConditions:
  14469. m.ClearConditions()
  14470. return nil
  14471. case label.FieldOrganizationID:
  14472. m.ClearOrganizationID()
  14473. return nil
  14474. }
  14475. return fmt.Errorf("unknown Label nullable field %s", name)
  14476. }
  14477. // ResetField resets all changes in the mutation for the field with the given name.
  14478. // It returns an error if the field is not defined in the schema.
  14479. func (m *LabelMutation) ResetField(name string) error {
  14480. switch name {
  14481. case label.FieldCreatedAt:
  14482. m.ResetCreatedAt()
  14483. return nil
  14484. case label.FieldUpdatedAt:
  14485. m.ResetUpdatedAt()
  14486. return nil
  14487. case label.FieldStatus:
  14488. m.ResetStatus()
  14489. return nil
  14490. case label.FieldType:
  14491. m.ResetType()
  14492. return nil
  14493. case label.FieldName:
  14494. m.ResetName()
  14495. return nil
  14496. case label.FieldFrom:
  14497. m.ResetFrom()
  14498. return nil
  14499. case label.FieldMode:
  14500. m.ResetMode()
  14501. return nil
  14502. case label.FieldConditions:
  14503. m.ResetConditions()
  14504. return nil
  14505. case label.FieldOrganizationID:
  14506. m.ResetOrganizationID()
  14507. return nil
  14508. }
  14509. return fmt.Errorf("unknown Label field %s", name)
  14510. }
  14511. // AddedEdges returns all edge names that were set/added in this mutation.
  14512. func (m *LabelMutation) AddedEdges() []string {
  14513. edges := make([]string, 0, 1)
  14514. if m.label_relationships != nil {
  14515. edges = append(edges, label.EdgeLabelRelationships)
  14516. }
  14517. return edges
  14518. }
  14519. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14520. // name in this mutation.
  14521. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14522. switch name {
  14523. case label.EdgeLabelRelationships:
  14524. ids := make([]ent.Value, 0, len(m.label_relationships))
  14525. for id := range m.label_relationships {
  14526. ids = append(ids, id)
  14527. }
  14528. return ids
  14529. }
  14530. return nil
  14531. }
  14532. // RemovedEdges returns all edge names that were removed in this mutation.
  14533. func (m *LabelMutation) RemovedEdges() []string {
  14534. edges := make([]string, 0, 1)
  14535. if m.removedlabel_relationships != nil {
  14536. edges = append(edges, label.EdgeLabelRelationships)
  14537. }
  14538. return edges
  14539. }
  14540. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14541. // the given name in this mutation.
  14542. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14543. switch name {
  14544. case label.EdgeLabelRelationships:
  14545. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14546. for id := range m.removedlabel_relationships {
  14547. ids = append(ids, id)
  14548. }
  14549. return ids
  14550. }
  14551. return nil
  14552. }
  14553. // ClearedEdges returns all edge names that were cleared in this mutation.
  14554. func (m *LabelMutation) ClearedEdges() []string {
  14555. edges := make([]string, 0, 1)
  14556. if m.clearedlabel_relationships {
  14557. edges = append(edges, label.EdgeLabelRelationships)
  14558. }
  14559. return edges
  14560. }
  14561. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14562. // was cleared in this mutation.
  14563. func (m *LabelMutation) EdgeCleared(name string) bool {
  14564. switch name {
  14565. case label.EdgeLabelRelationships:
  14566. return m.clearedlabel_relationships
  14567. }
  14568. return false
  14569. }
  14570. // ClearEdge clears the value of the edge with the given name. It returns an error
  14571. // if that edge is not defined in the schema.
  14572. func (m *LabelMutation) ClearEdge(name string) error {
  14573. switch name {
  14574. }
  14575. return fmt.Errorf("unknown Label unique edge %s", name)
  14576. }
  14577. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14578. // It returns an error if the edge is not defined in the schema.
  14579. func (m *LabelMutation) ResetEdge(name string) error {
  14580. switch name {
  14581. case label.EdgeLabelRelationships:
  14582. m.ResetLabelRelationships()
  14583. return nil
  14584. }
  14585. return fmt.Errorf("unknown Label edge %s", name)
  14586. }
  14587. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14588. type LabelRelationshipMutation struct {
  14589. config
  14590. op Op
  14591. typ string
  14592. id *uint64
  14593. created_at *time.Time
  14594. updated_at *time.Time
  14595. status *uint8
  14596. addstatus *int8
  14597. organization_id *uint64
  14598. addorganization_id *int64
  14599. clearedFields map[string]struct{}
  14600. contacts *uint64
  14601. clearedcontacts bool
  14602. labels *uint64
  14603. clearedlabels bool
  14604. done bool
  14605. oldValue func(context.Context) (*LabelRelationship, error)
  14606. predicates []predicate.LabelRelationship
  14607. }
  14608. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14609. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14610. type labelrelationshipOption func(*LabelRelationshipMutation)
  14611. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14612. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14613. m := &LabelRelationshipMutation{
  14614. config: c,
  14615. op: op,
  14616. typ: TypeLabelRelationship,
  14617. clearedFields: make(map[string]struct{}),
  14618. }
  14619. for _, opt := range opts {
  14620. opt(m)
  14621. }
  14622. return m
  14623. }
  14624. // withLabelRelationshipID sets the ID field of the mutation.
  14625. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14626. return func(m *LabelRelationshipMutation) {
  14627. var (
  14628. err error
  14629. once sync.Once
  14630. value *LabelRelationship
  14631. )
  14632. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14633. once.Do(func() {
  14634. if m.done {
  14635. err = errors.New("querying old values post mutation is not allowed")
  14636. } else {
  14637. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14638. }
  14639. })
  14640. return value, err
  14641. }
  14642. m.id = &id
  14643. }
  14644. }
  14645. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14646. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14647. return func(m *LabelRelationshipMutation) {
  14648. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14649. return node, nil
  14650. }
  14651. m.id = &node.ID
  14652. }
  14653. }
  14654. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14655. // executed in a transaction (ent.Tx), a transactional client is returned.
  14656. func (m LabelRelationshipMutation) Client() *Client {
  14657. client := &Client{config: m.config}
  14658. client.init()
  14659. return client
  14660. }
  14661. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14662. // it returns an error otherwise.
  14663. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14664. if _, ok := m.driver.(*txDriver); !ok {
  14665. return nil, errors.New("ent: mutation is not running in a transaction")
  14666. }
  14667. tx := &Tx{config: m.config}
  14668. tx.init()
  14669. return tx, nil
  14670. }
  14671. // SetID sets the value of the id field. Note that this
  14672. // operation is only accepted on creation of LabelRelationship entities.
  14673. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14674. m.id = &id
  14675. }
  14676. // ID returns the ID value in the mutation. Note that the ID is only available
  14677. // if it was provided to the builder or after it was returned from the database.
  14678. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14679. if m.id == nil {
  14680. return
  14681. }
  14682. return *m.id, true
  14683. }
  14684. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14685. // That means, if the mutation is applied within a transaction with an isolation level such
  14686. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14687. // or updated by the mutation.
  14688. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14689. switch {
  14690. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14691. id, exists := m.ID()
  14692. if exists {
  14693. return []uint64{id}, nil
  14694. }
  14695. fallthrough
  14696. case m.op.Is(OpUpdate | OpDelete):
  14697. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14698. default:
  14699. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14700. }
  14701. }
  14702. // SetCreatedAt sets the "created_at" field.
  14703. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14704. m.created_at = &t
  14705. }
  14706. // CreatedAt returns the value of the "created_at" field in the mutation.
  14707. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14708. v := m.created_at
  14709. if v == nil {
  14710. return
  14711. }
  14712. return *v, true
  14713. }
  14714. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14715. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14717. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14718. if !m.op.Is(OpUpdateOne) {
  14719. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14720. }
  14721. if m.id == nil || m.oldValue == nil {
  14722. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14723. }
  14724. oldValue, err := m.oldValue(ctx)
  14725. if err != nil {
  14726. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14727. }
  14728. return oldValue.CreatedAt, nil
  14729. }
  14730. // ResetCreatedAt resets all changes to the "created_at" field.
  14731. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14732. m.created_at = nil
  14733. }
  14734. // SetUpdatedAt sets the "updated_at" field.
  14735. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14736. m.updated_at = &t
  14737. }
  14738. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14739. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14740. v := m.updated_at
  14741. if v == nil {
  14742. return
  14743. }
  14744. return *v, true
  14745. }
  14746. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14747. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14748. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14749. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14750. if !m.op.Is(OpUpdateOne) {
  14751. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14752. }
  14753. if m.id == nil || m.oldValue == nil {
  14754. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14755. }
  14756. oldValue, err := m.oldValue(ctx)
  14757. if err != nil {
  14758. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14759. }
  14760. return oldValue.UpdatedAt, nil
  14761. }
  14762. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14763. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14764. m.updated_at = nil
  14765. }
  14766. // SetStatus sets the "status" field.
  14767. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14768. m.status = &u
  14769. m.addstatus = nil
  14770. }
  14771. // Status returns the value of the "status" field in the mutation.
  14772. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14773. v := m.status
  14774. if v == nil {
  14775. return
  14776. }
  14777. return *v, true
  14778. }
  14779. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14780. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14782. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14783. if !m.op.Is(OpUpdateOne) {
  14784. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14785. }
  14786. if m.id == nil || m.oldValue == nil {
  14787. return v, errors.New("OldStatus requires an ID field in the mutation")
  14788. }
  14789. oldValue, err := m.oldValue(ctx)
  14790. if err != nil {
  14791. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14792. }
  14793. return oldValue.Status, nil
  14794. }
  14795. // AddStatus adds u to the "status" field.
  14796. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14797. if m.addstatus != nil {
  14798. *m.addstatus += u
  14799. } else {
  14800. m.addstatus = &u
  14801. }
  14802. }
  14803. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14804. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14805. v := m.addstatus
  14806. if v == nil {
  14807. return
  14808. }
  14809. return *v, true
  14810. }
  14811. // ClearStatus clears the value of the "status" field.
  14812. func (m *LabelRelationshipMutation) ClearStatus() {
  14813. m.status = nil
  14814. m.addstatus = nil
  14815. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14816. }
  14817. // StatusCleared returns if the "status" field was cleared in this mutation.
  14818. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14819. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14820. return ok
  14821. }
  14822. // ResetStatus resets all changes to the "status" field.
  14823. func (m *LabelRelationshipMutation) ResetStatus() {
  14824. m.status = nil
  14825. m.addstatus = nil
  14826. delete(m.clearedFields, labelrelationship.FieldStatus)
  14827. }
  14828. // SetLabelID sets the "label_id" field.
  14829. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14830. m.labels = &u
  14831. }
  14832. // LabelID returns the value of the "label_id" field in the mutation.
  14833. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14834. v := m.labels
  14835. if v == nil {
  14836. return
  14837. }
  14838. return *v, true
  14839. }
  14840. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14841. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14843. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14844. if !m.op.Is(OpUpdateOne) {
  14845. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14846. }
  14847. if m.id == nil || m.oldValue == nil {
  14848. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14849. }
  14850. oldValue, err := m.oldValue(ctx)
  14851. if err != nil {
  14852. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14853. }
  14854. return oldValue.LabelID, nil
  14855. }
  14856. // ResetLabelID resets all changes to the "label_id" field.
  14857. func (m *LabelRelationshipMutation) ResetLabelID() {
  14858. m.labels = nil
  14859. }
  14860. // SetContactID sets the "contact_id" field.
  14861. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14862. m.contacts = &u
  14863. }
  14864. // ContactID returns the value of the "contact_id" field in the mutation.
  14865. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14866. v := m.contacts
  14867. if v == nil {
  14868. return
  14869. }
  14870. return *v, true
  14871. }
  14872. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14873. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14875. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14876. if !m.op.Is(OpUpdateOne) {
  14877. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14878. }
  14879. if m.id == nil || m.oldValue == nil {
  14880. return v, errors.New("OldContactID requires an ID field in the mutation")
  14881. }
  14882. oldValue, err := m.oldValue(ctx)
  14883. if err != nil {
  14884. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14885. }
  14886. return oldValue.ContactID, nil
  14887. }
  14888. // ResetContactID resets all changes to the "contact_id" field.
  14889. func (m *LabelRelationshipMutation) ResetContactID() {
  14890. m.contacts = nil
  14891. }
  14892. // SetOrganizationID sets the "organization_id" field.
  14893. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14894. m.organization_id = &u
  14895. m.addorganization_id = nil
  14896. }
  14897. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14898. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14899. v := m.organization_id
  14900. if v == nil {
  14901. return
  14902. }
  14903. return *v, true
  14904. }
  14905. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14906. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14907. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14908. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14909. if !m.op.Is(OpUpdateOne) {
  14910. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14911. }
  14912. if m.id == nil || m.oldValue == nil {
  14913. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14914. }
  14915. oldValue, err := m.oldValue(ctx)
  14916. if err != nil {
  14917. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14918. }
  14919. return oldValue.OrganizationID, nil
  14920. }
  14921. // AddOrganizationID adds u to the "organization_id" field.
  14922. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14923. if m.addorganization_id != nil {
  14924. *m.addorganization_id += u
  14925. } else {
  14926. m.addorganization_id = &u
  14927. }
  14928. }
  14929. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14930. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14931. v := m.addorganization_id
  14932. if v == nil {
  14933. return
  14934. }
  14935. return *v, true
  14936. }
  14937. // ClearOrganizationID clears the value of the "organization_id" field.
  14938. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14939. m.organization_id = nil
  14940. m.addorganization_id = nil
  14941. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14942. }
  14943. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14944. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14945. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14946. return ok
  14947. }
  14948. // ResetOrganizationID resets all changes to the "organization_id" field.
  14949. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14950. m.organization_id = nil
  14951. m.addorganization_id = nil
  14952. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14953. }
  14954. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14955. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14956. m.contacts = &id
  14957. }
  14958. // ClearContacts clears the "contacts" edge to the Contact entity.
  14959. func (m *LabelRelationshipMutation) ClearContacts() {
  14960. m.clearedcontacts = true
  14961. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14962. }
  14963. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14964. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14965. return m.clearedcontacts
  14966. }
  14967. // ContactsID returns the "contacts" edge ID in the mutation.
  14968. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14969. if m.contacts != nil {
  14970. return *m.contacts, true
  14971. }
  14972. return
  14973. }
  14974. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14975. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14976. // ContactsID instead. It exists only for internal usage by the builders.
  14977. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14978. if id := m.contacts; id != nil {
  14979. ids = append(ids, *id)
  14980. }
  14981. return
  14982. }
  14983. // ResetContacts resets all changes to the "contacts" edge.
  14984. func (m *LabelRelationshipMutation) ResetContacts() {
  14985. m.contacts = nil
  14986. m.clearedcontacts = false
  14987. }
  14988. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14989. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14990. m.labels = &id
  14991. }
  14992. // ClearLabels clears the "labels" edge to the Label entity.
  14993. func (m *LabelRelationshipMutation) ClearLabels() {
  14994. m.clearedlabels = true
  14995. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14996. }
  14997. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14998. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14999. return m.clearedlabels
  15000. }
  15001. // LabelsID returns the "labels" edge ID in the mutation.
  15002. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  15003. if m.labels != nil {
  15004. return *m.labels, true
  15005. }
  15006. return
  15007. }
  15008. // LabelsIDs returns the "labels" edge IDs in the mutation.
  15009. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  15010. // LabelsID instead. It exists only for internal usage by the builders.
  15011. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  15012. if id := m.labels; id != nil {
  15013. ids = append(ids, *id)
  15014. }
  15015. return
  15016. }
  15017. // ResetLabels resets all changes to the "labels" edge.
  15018. func (m *LabelRelationshipMutation) ResetLabels() {
  15019. m.labels = nil
  15020. m.clearedlabels = false
  15021. }
  15022. // Where appends a list predicates to the LabelRelationshipMutation builder.
  15023. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  15024. m.predicates = append(m.predicates, ps...)
  15025. }
  15026. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  15027. // users can use type-assertion to append predicates that do not depend on any generated package.
  15028. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  15029. p := make([]predicate.LabelRelationship, len(ps))
  15030. for i := range ps {
  15031. p[i] = ps[i]
  15032. }
  15033. m.Where(p...)
  15034. }
  15035. // Op returns the operation name.
  15036. func (m *LabelRelationshipMutation) Op() Op {
  15037. return m.op
  15038. }
  15039. // SetOp allows setting the mutation operation.
  15040. func (m *LabelRelationshipMutation) SetOp(op Op) {
  15041. m.op = op
  15042. }
  15043. // Type returns the node type of this mutation (LabelRelationship).
  15044. func (m *LabelRelationshipMutation) Type() string {
  15045. return m.typ
  15046. }
  15047. // Fields returns all fields that were changed during this mutation. Note that in
  15048. // order to get all numeric fields that were incremented/decremented, call
  15049. // AddedFields().
  15050. func (m *LabelRelationshipMutation) Fields() []string {
  15051. fields := make([]string, 0, 6)
  15052. if m.created_at != nil {
  15053. fields = append(fields, labelrelationship.FieldCreatedAt)
  15054. }
  15055. if m.updated_at != nil {
  15056. fields = append(fields, labelrelationship.FieldUpdatedAt)
  15057. }
  15058. if m.status != nil {
  15059. fields = append(fields, labelrelationship.FieldStatus)
  15060. }
  15061. if m.labels != nil {
  15062. fields = append(fields, labelrelationship.FieldLabelID)
  15063. }
  15064. if m.contacts != nil {
  15065. fields = append(fields, labelrelationship.FieldContactID)
  15066. }
  15067. if m.organization_id != nil {
  15068. fields = append(fields, labelrelationship.FieldOrganizationID)
  15069. }
  15070. return fields
  15071. }
  15072. // Field returns the value of a field with the given name. The second boolean
  15073. // return value indicates that this field was not set, or was not defined in the
  15074. // schema.
  15075. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15076. switch name {
  15077. case labelrelationship.FieldCreatedAt:
  15078. return m.CreatedAt()
  15079. case labelrelationship.FieldUpdatedAt:
  15080. return m.UpdatedAt()
  15081. case labelrelationship.FieldStatus:
  15082. return m.Status()
  15083. case labelrelationship.FieldLabelID:
  15084. return m.LabelID()
  15085. case labelrelationship.FieldContactID:
  15086. return m.ContactID()
  15087. case labelrelationship.FieldOrganizationID:
  15088. return m.OrganizationID()
  15089. }
  15090. return nil, false
  15091. }
  15092. // OldField returns the old value of the field from the database. An error is
  15093. // returned if the mutation operation is not UpdateOne, or the query to the
  15094. // database failed.
  15095. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15096. switch name {
  15097. case labelrelationship.FieldCreatedAt:
  15098. return m.OldCreatedAt(ctx)
  15099. case labelrelationship.FieldUpdatedAt:
  15100. return m.OldUpdatedAt(ctx)
  15101. case labelrelationship.FieldStatus:
  15102. return m.OldStatus(ctx)
  15103. case labelrelationship.FieldLabelID:
  15104. return m.OldLabelID(ctx)
  15105. case labelrelationship.FieldContactID:
  15106. return m.OldContactID(ctx)
  15107. case labelrelationship.FieldOrganizationID:
  15108. return m.OldOrganizationID(ctx)
  15109. }
  15110. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15111. }
  15112. // SetField sets the value of a field with the given name. It returns an error if
  15113. // the field is not defined in the schema, or if the type mismatched the field
  15114. // type.
  15115. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15116. switch name {
  15117. case labelrelationship.FieldCreatedAt:
  15118. v, ok := value.(time.Time)
  15119. if !ok {
  15120. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15121. }
  15122. m.SetCreatedAt(v)
  15123. return nil
  15124. case labelrelationship.FieldUpdatedAt:
  15125. v, ok := value.(time.Time)
  15126. if !ok {
  15127. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15128. }
  15129. m.SetUpdatedAt(v)
  15130. return nil
  15131. case labelrelationship.FieldStatus:
  15132. v, ok := value.(uint8)
  15133. if !ok {
  15134. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15135. }
  15136. m.SetStatus(v)
  15137. return nil
  15138. case labelrelationship.FieldLabelID:
  15139. v, ok := value.(uint64)
  15140. if !ok {
  15141. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15142. }
  15143. m.SetLabelID(v)
  15144. return nil
  15145. case labelrelationship.FieldContactID:
  15146. v, ok := value.(uint64)
  15147. if !ok {
  15148. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15149. }
  15150. m.SetContactID(v)
  15151. return nil
  15152. case labelrelationship.FieldOrganizationID:
  15153. v, ok := value.(uint64)
  15154. if !ok {
  15155. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15156. }
  15157. m.SetOrganizationID(v)
  15158. return nil
  15159. }
  15160. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15161. }
  15162. // AddedFields returns all numeric fields that were incremented/decremented during
  15163. // this mutation.
  15164. func (m *LabelRelationshipMutation) AddedFields() []string {
  15165. var fields []string
  15166. if m.addstatus != nil {
  15167. fields = append(fields, labelrelationship.FieldStatus)
  15168. }
  15169. if m.addorganization_id != nil {
  15170. fields = append(fields, labelrelationship.FieldOrganizationID)
  15171. }
  15172. return fields
  15173. }
  15174. // AddedField returns the numeric value that was incremented/decremented on a field
  15175. // with the given name. The second boolean return value indicates that this field
  15176. // was not set, or was not defined in the schema.
  15177. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15178. switch name {
  15179. case labelrelationship.FieldStatus:
  15180. return m.AddedStatus()
  15181. case labelrelationship.FieldOrganizationID:
  15182. return m.AddedOrganizationID()
  15183. }
  15184. return nil, false
  15185. }
  15186. // AddField adds the value to the field with the given name. It returns an error if
  15187. // the field is not defined in the schema, or if the type mismatched the field
  15188. // type.
  15189. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15190. switch name {
  15191. case labelrelationship.FieldStatus:
  15192. v, ok := value.(int8)
  15193. if !ok {
  15194. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15195. }
  15196. m.AddStatus(v)
  15197. return nil
  15198. case labelrelationship.FieldOrganizationID:
  15199. v, ok := value.(int64)
  15200. if !ok {
  15201. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15202. }
  15203. m.AddOrganizationID(v)
  15204. return nil
  15205. }
  15206. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15207. }
  15208. // ClearedFields returns all nullable fields that were cleared during this
  15209. // mutation.
  15210. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15211. var fields []string
  15212. if m.FieldCleared(labelrelationship.FieldStatus) {
  15213. fields = append(fields, labelrelationship.FieldStatus)
  15214. }
  15215. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15216. fields = append(fields, labelrelationship.FieldOrganizationID)
  15217. }
  15218. return fields
  15219. }
  15220. // FieldCleared returns a boolean indicating if a field with the given name was
  15221. // cleared in this mutation.
  15222. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15223. _, ok := m.clearedFields[name]
  15224. return ok
  15225. }
  15226. // ClearField clears the value of the field with the given name. It returns an
  15227. // error if the field is not defined in the schema.
  15228. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15229. switch name {
  15230. case labelrelationship.FieldStatus:
  15231. m.ClearStatus()
  15232. return nil
  15233. case labelrelationship.FieldOrganizationID:
  15234. m.ClearOrganizationID()
  15235. return nil
  15236. }
  15237. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15238. }
  15239. // ResetField resets all changes in the mutation for the field with the given name.
  15240. // It returns an error if the field is not defined in the schema.
  15241. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15242. switch name {
  15243. case labelrelationship.FieldCreatedAt:
  15244. m.ResetCreatedAt()
  15245. return nil
  15246. case labelrelationship.FieldUpdatedAt:
  15247. m.ResetUpdatedAt()
  15248. return nil
  15249. case labelrelationship.FieldStatus:
  15250. m.ResetStatus()
  15251. return nil
  15252. case labelrelationship.FieldLabelID:
  15253. m.ResetLabelID()
  15254. return nil
  15255. case labelrelationship.FieldContactID:
  15256. m.ResetContactID()
  15257. return nil
  15258. case labelrelationship.FieldOrganizationID:
  15259. m.ResetOrganizationID()
  15260. return nil
  15261. }
  15262. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15263. }
  15264. // AddedEdges returns all edge names that were set/added in this mutation.
  15265. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15266. edges := make([]string, 0, 2)
  15267. if m.contacts != nil {
  15268. edges = append(edges, labelrelationship.EdgeContacts)
  15269. }
  15270. if m.labels != nil {
  15271. edges = append(edges, labelrelationship.EdgeLabels)
  15272. }
  15273. return edges
  15274. }
  15275. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15276. // name in this mutation.
  15277. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15278. switch name {
  15279. case labelrelationship.EdgeContacts:
  15280. if id := m.contacts; id != nil {
  15281. return []ent.Value{*id}
  15282. }
  15283. case labelrelationship.EdgeLabels:
  15284. if id := m.labels; id != nil {
  15285. return []ent.Value{*id}
  15286. }
  15287. }
  15288. return nil
  15289. }
  15290. // RemovedEdges returns all edge names that were removed in this mutation.
  15291. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15292. edges := make([]string, 0, 2)
  15293. return edges
  15294. }
  15295. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15296. // the given name in this mutation.
  15297. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15298. return nil
  15299. }
  15300. // ClearedEdges returns all edge names that were cleared in this mutation.
  15301. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15302. edges := make([]string, 0, 2)
  15303. if m.clearedcontacts {
  15304. edges = append(edges, labelrelationship.EdgeContacts)
  15305. }
  15306. if m.clearedlabels {
  15307. edges = append(edges, labelrelationship.EdgeLabels)
  15308. }
  15309. return edges
  15310. }
  15311. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15312. // was cleared in this mutation.
  15313. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15314. switch name {
  15315. case labelrelationship.EdgeContacts:
  15316. return m.clearedcontacts
  15317. case labelrelationship.EdgeLabels:
  15318. return m.clearedlabels
  15319. }
  15320. return false
  15321. }
  15322. // ClearEdge clears the value of the edge with the given name. It returns an error
  15323. // if that edge is not defined in the schema.
  15324. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15325. switch name {
  15326. case labelrelationship.EdgeContacts:
  15327. m.ClearContacts()
  15328. return nil
  15329. case labelrelationship.EdgeLabels:
  15330. m.ClearLabels()
  15331. return nil
  15332. }
  15333. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15334. }
  15335. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15336. // It returns an error if the edge is not defined in the schema.
  15337. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15338. switch name {
  15339. case labelrelationship.EdgeContacts:
  15340. m.ResetContacts()
  15341. return nil
  15342. case labelrelationship.EdgeLabels:
  15343. m.ResetLabels()
  15344. return nil
  15345. }
  15346. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15347. }
  15348. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15349. type LabelTaggingMutation struct {
  15350. config
  15351. op Op
  15352. typ string
  15353. id *uint64
  15354. created_at *time.Time
  15355. updated_at *time.Time
  15356. status *uint8
  15357. addstatus *int8
  15358. deleted_at *time.Time
  15359. organization_id *uint64
  15360. addorganization_id *int64
  15361. _type *int
  15362. add_type *int
  15363. conditions *string
  15364. action_label_add *[]uint64
  15365. appendaction_label_add []uint64
  15366. action_label_del *[]uint64
  15367. appendaction_label_del []uint64
  15368. clearedFields map[string]struct{}
  15369. done bool
  15370. oldValue func(context.Context) (*LabelTagging, error)
  15371. predicates []predicate.LabelTagging
  15372. }
  15373. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15374. // labeltaggingOption allows management of the mutation configuration using functional options.
  15375. type labeltaggingOption func(*LabelTaggingMutation)
  15376. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15377. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15378. m := &LabelTaggingMutation{
  15379. config: c,
  15380. op: op,
  15381. typ: TypeLabelTagging,
  15382. clearedFields: make(map[string]struct{}),
  15383. }
  15384. for _, opt := range opts {
  15385. opt(m)
  15386. }
  15387. return m
  15388. }
  15389. // withLabelTaggingID sets the ID field of the mutation.
  15390. func withLabelTaggingID(id uint64) labeltaggingOption {
  15391. return func(m *LabelTaggingMutation) {
  15392. var (
  15393. err error
  15394. once sync.Once
  15395. value *LabelTagging
  15396. )
  15397. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15398. once.Do(func() {
  15399. if m.done {
  15400. err = errors.New("querying old values post mutation is not allowed")
  15401. } else {
  15402. value, err = m.Client().LabelTagging.Get(ctx, id)
  15403. }
  15404. })
  15405. return value, err
  15406. }
  15407. m.id = &id
  15408. }
  15409. }
  15410. // withLabelTagging sets the old LabelTagging of the mutation.
  15411. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15412. return func(m *LabelTaggingMutation) {
  15413. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15414. return node, nil
  15415. }
  15416. m.id = &node.ID
  15417. }
  15418. }
  15419. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15420. // executed in a transaction (ent.Tx), a transactional client is returned.
  15421. func (m LabelTaggingMutation) Client() *Client {
  15422. client := &Client{config: m.config}
  15423. client.init()
  15424. return client
  15425. }
  15426. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15427. // it returns an error otherwise.
  15428. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15429. if _, ok := m.driver.(*txDriver); !ok {
  15430. return nil, errors.New("ent: mutation is not running in a transaction")
  15431. }
  15432. tx := &Tx{config: m.config}
  15433. tx.init()
  15434. return tx, nil
  15435. }
  15436. // SetID sets the value of the id field. Note that this
  15437. // operation is only accepted on creation of LabelTagging entities.
  15438. func (m *LabelTaggingMutation) SetID(id uint64) {
  15439. m.id = &id
  15440. }
  15441. // ID returns the ID value in the mutation. Note that the ID is only available
  15442. // if it was provided to the builder or after it was returned from the database.
  15443. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15444. if m.id == nil {
  15445. return
  15446. }
  15447. return *m.id, true
  15448. }
  15449. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15450. // That means, if the mutation is applied within a transaction with an isolation level such
  15451. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15452. // or updated by the mutation.
  15453. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15454. switch {
  15455. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15456. id, exists := m.ID()
  15457. if exists {
  15458. return []uint64{id}, nil
  15459. }
  15460. fallthrough
  15461. case m.op.Is(OpUpdate | OpDelete):
  15462. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15463. default:
  15464. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15465. }
  15466. }
  15467. // SetCreatedAt sets the "created_at" field.
  15468. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15469. m.created_at = &t
  15470. }
  15471. // CreatedAt returns the value of the "created_at" field in the mutation.
  15472. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15473. v := m.created_at
  15474. if v == nil {
  15475. return
  15476. }
  15477. return *v, true
  15478. }
  15479. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15480. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15482. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15483. if !m.op.Is(OpUpdateOne) {
  15484. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15485. }
  15486. if m.id == nil || m.oldValue == nil {
  15487. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15488. }
  15489. oldValue, err := m.oldValue(ctx)
  15490. if err != nil {
  15491. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15492. }
  15493. return oldValue.CreatedAt, nil
  15494. }
  15495. // ResetCreatedAt resets all changes to the "created_at" field.
  15496. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15497. m.created_at = nil
  15498. }
  15499. // SetUpdatedAt sets the "updated_at" field.
  15500. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15501. m.updated_at = &t
  15502. }
  15503. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15504. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15505. v := m.updated_at
  15506. if v == nil {
  15507. return
  15508. }
  15509. return *v, true
  15510. }
  15511. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15512. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15514. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15515. if !m.op.Is(OpUpdateOne) {
  15516. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15517. }
  15518. if m.id == nil || m.oldValue == nil {
  15519. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15520. }
  15521. oldValue, err := m.oldValue(ctx)
  15522. if err != nil {
  15523. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15524. }
  15525. return oldValue.UpdatedAt, nil
  15526. }
  15527. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15528. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15529. m.updated_at = nil
  15530. }
  15531. // SetStatus sets the "status" field.
  15532. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15533. m.status = &u
  15534. m.addstatus = nil
  15535. }
  15536. // Status returns the value of the "status" field in the mutation.
  15537. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15538. v := m.status
  15539. if v == nil {
  15540. return
  15541. }
  15542. return *v, true
  15543. }
  15544. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15545. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15546. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15547. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15548. if !m.op.Is(OpUpdateOne) {
  15549. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15550. }
  15551. if m.id == nil || m.oldValue == nil {
  15552. return v, errors.New("OldStatus requires an ID field in the mutation")
  15553. }
  15554. oldValue, err := m.oldValue(ctx)
  15555. if err != nil {
  15556. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15557. }
  15558. return oldValue.Status, nil
  15559. }
  15560. // AddStatus adds u to the "status" field.
  15561. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15562. if m.addstatus != nil {
  15563. *m.addstatus += u
  15564. } else {
  15565. m.addstatus = &u
  15566. }
  15567. }
  15568. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15569. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15570. v := m.addstatus
  15571. if v == nil {
  15572. return
  15573. }
  15574. return *v, true
  15575. }
  15576. // ClearStatus clears the value of the "status" field.
  15577. func (m *LabelTaggingMutation) ClearStatus() {
  15578. m.status = nil
  15579. m.addstatus = nil
  15580. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15581. }
  15582. // StatusCleared returns if the "status" field was cleared in this mutation.
  15583. func (m *LabelTaggingMutation) StatusCleared() bool {
  15584. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15585. return ok
  15586. }
  15587. // ResetStatus resets all changes to the "status" field.
  15588. func (m *LabelTaggingMutation) ResetStatus() {
  15589. m.status = nil
  15590. m.addstatus = nil
  15591. delete(m.clearedFields, labeltagging.FieldStatus)
  15592. }
  15593. // SetDeletedAt sets the "deleted_at" field.
  15594. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15595. m.deleted_at = &t
  15596. }
  15597. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15598. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15599. v := m.deleted_at
  15600. if v == nil {
  15601. return
  15602. }
  15603. return *v, true
  15604. }
  15605. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15606. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15608. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15609. if !m.op.Is(OpUpdateOne) {
  15610. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15611. }
  15612. if m.id == nil || m.oldValue == nil {
  15613. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15614. }
  15615. oldValue, err := m.oldValue(ctx)
  15616. if err != nil {
  15617. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15618. }
  15619. return oldValue.DeletedAt, nil
  15620. }
  15621. // ClearDeletedAt clears the value of the "deleted_at" field.
  15622. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15623. m.deleted_at = nil
  15624. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15625. }
  15626. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15627. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15628. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15629. return ok
  15630. }
  15631. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15632. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15633. m.deleted_at = nil
  15634. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15635. }
  15636. // SetOrganizationID sets the "organization_id" field.
  15637. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15638. m.organization_id = &u
  15639. m.addorganization_id = nil
  15640. }
  15641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15642. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15643. v := m.organization_id
  15644. if v == nil {
  15645. return
  15646. }
  15647. return *v, true
  15648. }
  15649. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15650. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15652. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15653. if !m.op.Is(OpUpdateOne) {
  15654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15655. }
  15656. if m.id == nil || m.oldValue == nil {
  15657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15658. }
  15659. oldValue, err := m.oldValue(ctx)
  15660. if err != nil {
  15661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15662. }
  15663. return oldValue.OrganizationID, nil
  15664. }
  15665. // AddOrganizationID adds u to the "organization_id" field.
  15666. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15667. if m.addorganization_id != nil {
  15668. *m.addorganization_id += u
  15669. } else {
  15670. m.addorganization_id = &u
  15671. }
  15672. }
  15673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15674. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15675. v := m.addorganization_id
  15676. if v == nil {
  15677. return
  15678. }
  15679. return *v, true
  15680. }
  15681. // ResetOrganizationID resets all changes to the "organization_id" field.
  15682. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15683. m.organization_id = nil
  15684. m.addorganization_id = nil
  15685. }
  15686. // SetType sets the "type" field.
  15687. func (m *LabelTaggingMutation) SetType(i int) {
  15688. m._type = &i
  15689. m.add_type = nil
  15690. }
  15691. // GetType returns the value of the "type" field in the mutation.
  15692. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15693. v := m._type
  15694. if v == nil {
  15695. return
  15696. }
  15697. return *v, true
  15698. }
  15699. // OldType returns the old "type" field's value of the LabelTagging entity.
  15700. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15702. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15703. if !m.op.Is(OpUpdateOne) {
  15704. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15705. }
  15706. if m.id == nil || m.oldValue == nil {
  15707. return v, errors.New("OldType requires an ID field in the mutation")
  15708. }
  15709. oldValue, err := m.oldValue(ctx)
  15710. if err != nil {
  15711. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15712. }
  15713. return oldValue.Type, nil
  15714. }
  15715. // AddType adds i to the "type" field.
  15716. func (m *LabelTaggingMutation) AddType(i int) {
  15717. if m.add_type != nil {
  15718. *m.add_type += i
  15719. } else {
  15720. m.add_type = &i
  15721. }
  15722. }
  15723. // AddedType returns the value that was added to the "type" field in this mutation.
  15724. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15725. v := m.add_type
  15726. if v == nil {
  15727. return
  15728. }
  15729. return *v, true
  15730. }
  15731. // ResetType resets all changes to the "type" field.
  15732. func (m *LabelTaggingMutation) ResetType() {
  15733. m._type = nil
  15734. m.add_type = nil
  15735. }
  15736. // SetConditions sets the "conditions" field.
  15737. func (m *LabelTaggingMutation) SetConditions(s string) {
  15738. m.conditions = &s
  15739. }
  15740. // Conditions returns the value of the "conditions" field in the mutation.
  15741. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15742. v := m.conditions
  15743. if v == nil {
  15744. return
  15745. }
  15746. return *v, true
  15747. }
  15748. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15749. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15750. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15751. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15752. if !m.op.Is(OpUpdateOne) {
  15753. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15754. }
  15755. if m.id == nil || m.oldValue == nil {
  15756. return v, errors.New("OldConditions requires an ID field in the mutation")
  15757. }
  15758. oldValue, err := m.oldValue(ctx)
  15759. if err != nil {
  15760. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15761. }
  15762. return oldValue.Conditions, nil
  15763. }
  15764. // ResetConditions resets all changes to the "conditions" field.
  15765. func (m *LabelTaggingMutation) ResetConditions() {
  15766. m.conditions = nil
  15767. }
  15768. // SetActionLabelAdd sets the "action_label_add" field.
  15769. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15770. m.action_label_add = &u
  15771. m.appendaction_label_add = nil
  15772. }
  15773. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15774. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15775. v := m.action_label_add
  15776. if v == nil {
  15777. return
  15778. }
  15779. return *v, true
  15780. }
  15781. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15782. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15783. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15784. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15785. if !m.op.Is(OpUpdateOne) {
  15786. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15787. }
  15788. if m.id == nil || m.oldValue == nil {
  15789. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15790. }
  15791. oldValue, err := m.oldValue(ctx)
  15792. if err != nil {
  15793. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15794. }
  15795. return oldValue.ActionLabelAdd, nil
  15796. }
  15797. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15798. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15799. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15800. }
  15801. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15802. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15803. if len(m.appendaction_label_add) == 0 {
  15804. return nil, false
  15805. }
  15806. return m.appendaction_label_add, true
  15807. }
  15808. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15809. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15810. m.action_label_add = nil
  15811. m.appendaction_label_add = nil
  15812. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15813. }
  15814. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15815. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15816. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15817. return ok
  15818. }
  15819. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15820. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15821. m.action_label_add = nil
  15822. m.appendaction_label_add = nil
  15823. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15824. }
  15825. // SetActionLabelDel sets the "action_label_del" field.
  15826. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15827. m.action_label_del = &u
  15828. m.appendaction_label_del = nil
  15829. }
  15830. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15831. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15832. v := m.action_label_del
  15833. if v == nil {
  15834. return
  15835. }
  15836. return *v, true
  15837. }
  15838. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15839. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15841. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15842. if !m.op.Is(OpUpdateOne) {
  15843. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15844. }
  15845. if m.id == nil || m.oldValue == nil {
  15846. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15847. }
  15848. oldValue, err := m.oldValue(ctx)
  15849. if err != nil {
  15850. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15851. }
  15852. return oldValue.ActionLabelDel, nil
  15853. }
  15854. // AppendActionLabelDel adds u to the "action_label_del" field.
  15855. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15856. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15857. }
  15858. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15859. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15860. if len(m.appendaction_label_del) == 0 {
  15861. return nil, false
  15862. }
  15863. return m.appendaction_label_del, true
  15864. }
  15865. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15866. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15867. m.action_label_del = nil
  15868. m.appendaction_label_del = nil
  15869. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15870. }
  15871. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15872. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15873. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15874. return ok
  15875. }
  15876. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15877. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15878. m.action_label_del = nil
  15879. m.appendaction_label_del = nil
  15880. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15881. }
  15882. // Where appends a list predicates to the LabelTaggingMutation builder.
  15883. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15884. m.predicates = append(m.predicates, ps...)
  15885. }
  15886. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15887. // users can use type-assertion to append predicates that do not depend on any generated package.
  15888. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15889. p := make([]predicate.LabelTagging, len(ps))
  15890. for i := range ps {
  15891. p[i] = ps[i]
  15892. }
  15893. m.Where(p...)
  15894. }
  15895. // Op returns the operation name.
  15896. func (m *LabelTaggingMutation) Op() Op {
  15897. return m.op
  15898. }
  15899. // SetOp allows setting the mutation operation.
  15900. func (m *LabelTaggingMutation) SetOp(op Op) {
  15901. m.op = op
  15902. }
  15903. // Type returns the node type of this mutation (LabelTagging).
  15904. func (m *LabelTaggingMutation) Type() string {
  15905. return m.typ
  15906. }
  15907. // Fields returns all fields that were changed during this mutation. Note that in
  15908. // order to get all numeric fields that were incremented/decremented, call
  15909. // AddedFields().
  15910. func (m *LabelTaggingMutation) Fields() []string {
  15911. fields := make([]string, 0, 9)
  15912. if m.created_at != nil {
  15913. fields = append(fields, labeltagging.FieldCreatedAt)
  15914. }
  15915. if m.updated_at != nil {
  15916. fields = append(fields, labeltagging.FieldUpdatedAt)
  15917. }
  15918. if m.status != nil {
  15919. fields = append(fields, labeltagging.FieldStatus)
  15920. }
  15921. if m.deleted_at != nil {
  15922. fields = append(fields, labeltagging.FieldDeletedAt)
  15923. }
  15924. if m.organization_id != nil {
  15925. fields = append(fields, labeltagging.FieldOrganizationID)
  15926. }
  15927. if m._type != nil {
  15928. fields = append(fields, labeltagging.FieldType)
  15929. }
  15930. if m.conditions != nil {
  15931. fields = append(fields, labeltagging.FieldConditions)
  15932. }
  15933. if m.action_label_add != nil {
  15934. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15935. }
  15936. if m.action_label_del != nil {
  15937. fields = append(fields, labeltagging.FieldActionLabelDel)
  15938. }
  15939. return fields
  15940. }
  15941. // Field returns the value of a field with the given name. The second boolean
  15942. // return value indicates that this field was not set, or was not defined in the
  15943. // schema.
  15944. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15945. switch name {
  15946. case labeltagging.FieldCreatedAt:
  15947. return m.CreatedAt()
  15948. case labeltagging.FieldUpdatedAt:
  15949. return m.UpdatedAt()
  15950. case labeltagging.FieldStatus:
  15951. return m.Status()
  15952. case labeltagging.FieldDeletedAt:
  15953. return m.DeletedAt()
  15954. case labeltagging.FieldOrganizationID:
  15955. return m.OrganizationID()
  15956. case labeltagging.FieldType:
  15957. return m.GetType()
  15958. case labeltagging.FieldConditions:
  15959. return m.Conditions()
  15960. case labeltagging.FieldActionLabelAdd:
  15961. return m.ActionLabelAdd()
  15962. case labeltagging.FieldActionLabelDel:
  15963. return m.ActionLabelDel()
  15964. }
  15965. return nil, false
  15966. }
  15967. // OldField returns the old value of the field from the database. An error is
  15968. // returned if the mutation operation is not UpdateOne, or the query to the
  15969. // database failed.
  15970. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15971. switch name {
  15972. case labeltagging.FieldCreatedAt:
  15973. return m.OldCreatedAt(ctx)
  15974. case labeltagging.FieldUpdatedAt:
  15975. return m.OldUpdatedAt(ctx)
  15976. case labeltagging.FieldStatus:
  15977. return m.OldStatus(ctx)
  15978. case labeltagging.FieldDeletedAt:
  15979. return m.OldDeletedAt(ctx)
  15980. case labeltagging.FieldOrganizationID:
  15981. return m.OldOrganizationID(ctx)
  15982. case labeltagging.FieldType:
  15983. return m.OldType(ctx)
  15984. case labeltagging.FieldConditions:
  15985. return m.OldConditions(ctx)
  15986. case labeltagging.FieldActionLabelAdd:
  15987. return m.OldActionLabelAdd(ctx)
  15988. case labeltagging.FieldActionLabelDel:
  15989. return m.OldActionLabelDel(ctx)
  15990. }
  15991. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15992. }
  15993. // SetField sets the value of a field with the given name. It returns an error if
  15994. // the field is not defined in the schema, or if the type mismatched the field
  15995. // type.
  15996. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15997. switch name {
  15998. case labeltagging.FieldCreatedAt:
  15999. v, ok := value.(time.Time)
  16000. if !ok {
  16001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16002. }
  16003. m.SetCreatedAt(v)
  16004. return nil
  16005. case labeltagging.FieldUpdatedAt:
  16006. v, ok := value.(time.Time)
  16007. if !ok {
  16008. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16009. }
  16010. m.SetUpdatedAt(v)
  16011. return nil
  16012. case labeltagging.FieldStatus:
  16013. v, ok := value.(uint8)
  16014. if !ok {
  16015. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16016. }
  16017. m.SetStatus(v)
  16018. return nil
  16019. case labeltagging.FieldDeletedAt:
  16020. v, ok := value.(time.Time)
  16021. if !ok {
  16022. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16023. }
  16024. m.SetDeletedAt(v)
  16025. return nil
  16026. case labeltagging.FieldOrganizationID:
  16027. v, ok := value.(uint64)
  16028. if !ok {
  16029. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16030. }
  16031. m.SetOrganizationID(v)
  16032. return nil
  16033. case labeltagging.FieldType:
  16034. v, ok := value.(int)
  16035. if !ok {
  16036. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16037. }
  16038. m.SetType(v)
  16039. return nil
  16040. case labeltagging.FieldConditions:
  16041. v, ok := value.(string)
  16042. if !ok {
  16043. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16044. }
  16045. m.SetConditions(v)
  16046. return nil
  16047. case labeltagging.FieldActionLabelAdd:
  16048. v, ok := value.([]uint64)
  16049. if !ok {
  16050. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16051. }
  16052. m.SetActionLabelAdd(v)
  16053. return nil
  16054. case labeltagging.FieldActionLabelDel:
  16055. v, ok := value.([]uint64)
  16056. if !ok {
  16057. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16058. }
  16059. m.SetActionLabelDel(v)
  16060. return nil
  16061. }
  16062. return fmt.Errorf("unknown LabelTagging field %s", name)
  16063. }
  16064. // AddedFields returns all numeric fields that were incremented/decremented during
  16065. // this mutation.
  16066. func (m *LabelTaggingMutation) AddedFields() []string {
  16067. var fields []string
  16068. if m.addstatus != nil {
  16069. fields = append(fields, labeltagging.FieldStatus)
  16070. }
  16071. if m.addorganization_id != nil {
  16072. fields = append(fields, labeltagging.FieldOrganizationID)
  16073. }
  16074. if m.add_type != nil {
  16075. fields = append(fields, labeltagging.FieldType)
  16076. }
  16077. return fields
  16078. }
  16079. // AddedField returns the numeric value that was incremented/decremented on a field
  16080. // with the given name. The second boolean return value indicates that this field
  16081. // was not set, or was not defined in the schema.
  16082. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16083. switch name {
  16084. case labeltagging.FieldStatus:
  16085. return m.AddedStatus()
  16086. case labeltagging.FieldOrganizationID:
  16087. return m.AddedOrganizationID()
  16088. case labeltagging.FieldType:
  16089. return m.AddedType()
  16090. }
  16091. return nil, false
  16092. }
  16093. // AddField adds the value to the field with the given name. It returns an error if
  16094. // the field is not defined in the schema, or if the type mismatched the field
  16095. // type.
  16096. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16097. switch name {
  16098. case labeltagging.FieldStatus:
  16099. v, ok := value.(int8)
  16100. if !ok {
  16101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16102. }
  16103. m.AddStatus(v)
  16104. return nil
  16105. case labeltagging.FieldOrganizationID:
  16106. v, ok := value.(int64)
  16107. if !ok {
  16108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16109. }
  16110. m.AddOrganizationID(v)
  16111. return nil
  16112. case labeltagging.FieldType:
  16113. v, ok := value.(int)
  16114. if !ok {
  16115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16116. }
  16117. m.AddType(v)
  16118. return nil
  16119. }
  16120. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16121. }
  16122. // ClearedFields returns all nullable fields that were cleared during this
  16123. // mutation.
  16124. func (m *LabelTaggingMutation) ClearedFields() []string {
  16125. var fields []string
  16126. if m.FieldCleared(labeltagging.FieldStatus) {
  16127. fields = append(fields, labeltagging.FieldStatus)
  16128. }
  16129. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16130. fields = append(fields, labeltagging.FieldDeletedAt)
  16131. }
  16132. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16133. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16134. }
  16135. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16136. fields = append(fields, labeltagging.FieldActionLabelDel)
  16137. }
  16138. return fields
  16139. }
  16140. // FieldCleared returns a boolean indicating if a field with the given name was
  16141. // cleared in this mutation.
  16142. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16143. _, ok := m.clearedFields[name]
  16144. return ok
  16145. }
  16146. // ClearField clears the value of the field with the given name. It returns an
  16147. // error if the field is not defined in the schema.
  16148. func (m *LabelTaggingMutation) ClearField(name string) error {
  16149. switch name {
  16150. case labeltagging.FieldStatus:
  16151. m.ClearStatus()
  16152. return nil
  16153. case labeltagging.FieldDeletedAt:
  16154. m.ClearDeletedAt()
  16155. return nil
  16156. case labeltagging.FieldActionLabelAdd:
  16157. m.ClearActionLabelAdd()
  16158. return nil
  16159. case labeltagging.FieldActionLabelDel:
  16160. m.ClearActionLabelDel()
  16161. return nil
  16162. }
  16163. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16164. }
  16165. // ResetField resets all changes in the mutation for the field with the given name.
  16166. // It returns an error if the field is not defined in the schema.
  16167. func (m *LabelTaggingMutation) ResetField(name string) error {
  16168. switch name {
  16169. case labeltagging.FieldCreatedAt:
  16170. m.ResetCreatedAt()
  16171. return nil
  16172. case labeltagging.FieldUpdatedAt:
  16173. m.ResetUpdatedAt()
  16174. return nil
  16175. case labeltagging.FieldStatus:
  16176. m.ResetStatus()
  16177. return nil
  16178. case labeltagging.FieldDeletedAt:
  16179. m.ResetDeletedAt()
  16180. return nil
  16181. case labeltagging.FieldOrganizationID:
  16182. m.ResetOrganizationID()
  16183. return nil
  16184. case labeltagging.FieldType:
  16185. m.ResetType()
  16186. return nil
  16187. case labeltagging.FieldConditions:
  16188. m.ResetConditions()
  16189. return nil
  16190. case labeltagging.FieldActionLabelAdd:
  16191. m.ResetActionLabelAdd()
  16192. return nil
  16193. case labeltagging.FieldActionLabelDel:
  16194. m.ResetActionLabelDel()
  16195. return nil
  16196. }
  16197. return fmt.Errorf("unknown LabelTagging field %s", name)
  16198. }
  16199. // AddedEdges returns all edge names that were set/added in this mutation.
  16200. func (m *LabelTaggingMutation) AddedEdges() []string {
  16201. edges := make([]string, 0, 0)
  16202. return edges
  16203. }
  16204. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16205. // name in this mutation.
  16206. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16207. return nil
  16208. }
  16209. // RemovedEdges returns all edge names that were removed in this mutation.
  16210. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16211. edges := make([]string, 0, 0)
  16212. return edges
  16213. }
  16214. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16215. // the given name in this mutation.
  16216. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16217. return nil
  16218. }
  16219. // ClearedEdges returns all edge names that were cleared in this mutation.
  16220. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16221. edges := make([]string, 0, 0)
  16222. return edges
  16223. }
  16224. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16225. // was cleared in this mutation.
  16226. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16227. return false
  16228. }
  16229. // ClearEdge clears the value of the edge with the given name. It returns an error
  16230. // if that edge is not defined in the schema.
  16231. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16232. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16233. }
  16234. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16235. // It returns an error if the edge is not defined in the schema.
  16236. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16237. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16238. }
  16239. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16240. type MessageMutation struct {
  16241. config
  16242. op Op
  16243. typ string
  16244. id *int
  16245. wx_wxid *string
  16246. wxid *string
  16247. content *string
  16248. clearedFields map[string]struct{}
  16249. done bool
  16250. oldValue func(context.Context) (*Message, error)
  16251. predicates []predicate.Message
  16252. }
  16253. var _ ent.Mutation = (*MessageMutation)(nil)
  16254. // messageOption allows management of the mutation configuration using functional options.
  16255. type messageOption func(*MessageMutation)
  16256. // newMessageMutation creates new mutation for the Message entity.
  16257. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16258. m := &MessageMutation{
  16259. config: c,
  16260. op: op,
  16261. typ: TypeMessage,
  16262. clearedFields: make(map[string]struct{}),
  16263. }
  16264. for _, opt := range opts {
  16265. opt(m)
  16266. }
  16267. return m
  16268. }
  16269. // withMessageID sets the ID field of the mutation.
  16270. func withMessageID(id int) messageOption {
  16271. return func(m *MessageMutation) {
  16272. var (
  16273. err error
  16274. once sync.Once
  16275. value *Message
  16276. )
  16277. m.oldValue = func(ctx context.Context) (*Message, error) {
  16278. once.Do(func() {
  16279. if m.done {
  16280. err = errors.New("querying old values post mutation is not allowed")
  16281. } else {
  16282. value, err = m.Client().Message.Get(ctx, id)
  16283. }
  16284. })
  16285. return value, err
  16286. }
  16287. m.id = &id
  16288. }
  16289. }
  16290. // withMessage sets the old Message of the mutation.
  16291. func withMessage(node *Message) messageOption {
  16292. return func(m *MessageMutation) {
  16293. m.oldValue = func(context.Context) (*Message, error) {
  16294. return node, nil
  16295. }
  16296. m.id = &node.ID
  16297. }
  16298. }
  16299. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16300. // executed in a transaction (ent.Tx), a transactional client is returned.
  16301. func (m MessageMutation) Client() *Client {
  16302. client := &Client{config: m.config}
  16303. client.init()
  16304. return client
  16305. }
  16306. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16307. // it returns an error otherwise.
  16308. func (m MessageMutation) Tx() (*Tx, error) {
  16309. if _, ok := m.driver.(*txDriver); !ok {
  16310. return nil, errors.New("ent: mutation is not running in a transaction")
  16311. }
  16312. tx := &Tx{config: m.config}
  16313. tx.init()
  16314. return tx, nil
  16315. }
  16316. // ID returns the ID value in the mutation. Note that the ID is only available
  16317. // if it was provided to the builder or after it was returned from the database.
  16318. func (m *MessageMutation) ID() (id int, exists bool) {
  16319. if m.id == nil {
  16320. return
  16321. }
  16322. return *m.id, true
  16323. }
  16324. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16325. // That means, if the mutation is applied within a transaction with an isolation level such
  16326. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16327. // or updated by the mutation.
  16328. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16329. switch {
  16330. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16331. id, exists := m.ID()
  16332. if exists {
  16333. return []int{id}, nil
  16334. }
  16335. fallthrough
  16336. case m.op.Is(OpUpdate | OpDelete):
  16337. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16338. default:
  16339. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16340. }
  16341. }
  16342. // SetWxWxid sets the "wx_wxid" field.
  16343. func (m *MessageMutation) SetWxWxid(s string) {
  16344. m.wx_wxid = &s
  16345. }
  16346. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16347. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16348. v := m.wx_wxid
  16349. if v == nil {
  16350. return
  16351. }
  16352. return *v, true
  16353. }
  16354. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16355. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16357. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16358. if !m.op.Is(OpUpdateOne) {
  16359. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16360. }
  16361. if m.id == nil || m.oldValue == nil {
  16362. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16363. }
  16364. oldValue, err := m.oldValue(ctx)
  16365. if err != nil {
  16366. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16367. }
  16368. return oldValue.WxWxid, nil
  16369. }
  16370. // ClearWxWxid clears the value of the "wx_wxid" field.
  16371. func (m *MessageMutation) ClearWxWxid() {
  16372. m.wx_wxid = nil
  16373. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16374. }
  16375. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16376. func (m *MessageMutation) WxWxidCleared() bool {
  16377. _, ok := m.clearedFields[message.FieldWxWxid]
  16378. return ok
  16379. }
  16380. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16381. func (m *MessageMutation) ResetWxWxid() {
  16382. m.wx_wxid = nil
  16383. delete(m.clearedFields, message.FieldWxWxid)
  16384. }
  16385. // SetWxid sets the "wxid" field.
  16386. func (m *MessageMutation) SetWxid(s string) {
  16387. m.wxid = &s
  16388. }
  16389. // Wxid returns the value of the "wxid" field in the mutation.
  16390. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16391. v := m.wxid
  16392. if v == nil {
  16393. return
  16394. }
  16395. return *v, true
  16396. }
  16397. // OldWxid returns the old "wxid" field's value of the Message entity.
  16398. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16400. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16401. if !m.op.Is(OpUpdateOne) {
  16402. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16403. }
  16404. if m.id == nil || m.oldValue == nil {
  16405. return v, errors.New("OldWxid requires an ID field in the mutation")
  16406. }
  16407. oldValue, err := m.oldValue(ctx)
  16408. if err != nil {
  16409. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16410. }
  16411. return oldValue.Wxid, nil
  16412. }
  16413. // ResetWxid resets all changes to the "wxid" field.
  16414. func (m *MessageMutation) ResetWxid() {
  16415. m.wxid = nil
  16416. }
  16417. // SetContent sets the "content" field.
  16418. func (m *MessageMutation) SetContent(s string) {
  16419. m.content = &s
  16420. }
  16421. // Content returns the value of the "content" field in the mutation.
  16422. func (m *MessageMutation) Content() (r string, exists bool) {
  16423. v := m.content
  16424. if v == nil {
  16425. return
  16426. }
  16427. return *v, true
  16428. }
  16429. // OldContent returns the old "content" field's value of the Message entity.
  16430. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16432. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16433. if !m.op.Is(OpUpdateOne) {
  16434. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16435. }
  16436. if m.id == nil || m.oldValue == nil {
  16437. return v, errors.New("OldContent requires an ID field in the mutation")
  16438. }
  16439. oldValue, err := m.oldValue(ctx)
  16440. if err != nil {
  16441. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16442. }
  16443. return oldValue.Content, nil
  16444. }
  16445. // ResetContent resets all changes to the "content" field.
  16446. func (m *MessageMutation) ResetContent() {
  16447. m.content = nil
  16448. }
  16449. // Where appends a list predicates to the MessageMutation builder.
  16450. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16451. m.predicates = append(m.predicates, ps...)
  16452. }
  16453. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16454. // users can use type-assertion to append predicates that do not depend on any generated package.
  16455. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16456. p := make([]predicate.Message, len(ps))
  16457. for i := range ps {
  16458. p[i] = ps[i]
  16459. }
  16460. m.Where(p...)
  16461. }
  16462. // Op returns the operation name.
  16463. func (m *MessageMutation) Op() Op {
  16464. return m.op
  16465. }
  16466. // SetOp allows setting the mutation operation.
  16467. func (m *MessageMutation) SetOp(op Op) {
  16468. m.op = op
  16469. }
  16470. // Type returns the node type of this mutation (Message).
  16471. func (m *MessageMutation) Type() string {
  16472. return m.typ
  16473. }
  16474. // Fields returns all fields that were changed during this mutation. Note that in
  16475. // order to get all numeric fields that were incremented/decremented, call
  16476. // AddedFields().
  16477. func (m *MessageMutation) Fields() []string {
  16478. fields := make([]string, 0, 3)
  16479. if m.wx_wxid != nil {
  16480. fields = append(fields, message.FieldWxWxid)
  16481. }
  16482. if m.wxid != nil {
  16483. fields = append(fields, message.FieldWxid)
  16484. }
  16485. if m.content != nil {
  16486. fields = append(fields, message.FieldContent)
  16487. }
  16488. return fields
  16489. }
  16490. // Field returns the value of a field with the given name. The second boolean
  16491. // return value indicates that this field was not set, or was not defined in the
  16492. // schema.
  16493. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16494. switch name {
  16495. case message.FieldWxWxid:
  16496. return m.WxWxid()
  16497. case message.FieldWxid:
  16498. return m.Wxid()
  16499. case message.FieldContent:
  16500. return m.Content()
  16501. }
  16502. return nil, false
  16503. }
  16504. // OldField returns the old value of the field from the database. An error is
  16505. // returned if the mutation operation is not UpdateOne, or the query to the
  16506. // database failed.
  16507. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16508. switch name {
  16509. case message.FieldWxWxid:
  16510. return m.OldWxWxid(ctx)
  16511. case message.FieldWxid:
  16512. return m.OldWxid(ctx)
  16513. case message.FieldContent:
  16514. return m.OldContent(ctx)
  16515. }
  16516. return nil, fmt.Errorf("unknown Message field %s", name)
  16517. }
  16518. // SetField sets the value of a field with the given name. It returns an error if
  16519. // the field is not defined in the schema, or if the type mismatched the field
  16520. // type.
  16521. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16522. switch name {
  16523. case message.FieldWxWxid:
  16524. v, ok := value.(string)
  16525. if !ok {
  16526. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16527. }
  16528. m.SetWxWxid(v)
  16529. return nil
  16530. case message.FieldWxid:
  16531. v, ok := value.(string)
  16532. if !ok {
  16533. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16534. }
  16535. m.SetWxid(v)
  16536. return nil
  16537. case message.FieldContent:
  16538. v, ok := value.(string)
  16539. if !ok {
  16540. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16541. }
  16542. m.SetContent(v)
  16543. return nil
  16544. }
  16545. return fmt.Errorf("unknown Message field %s", name)
  16546. }
  16547. // AddedFields returns all numeric fields that were incremented/decremented during
  16548. // this mutation.
  16549. func (m *MessageMutation) AddedFields() []string {
  16550. return nil
  16551. }
  16552. // AddedField returns the numeric value that was incremented/decremented on a field
  16553. // with the given name. The second boolean return value indicates that this field
  16554. // was not set, or was not defined in the schema.
  16555. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16556. return nil, false
  16557. }
  16558. // AddField adds the value to the field with the given name. It returns an error if
  16559. // the field is not defined in the schema, or if the type mismatched the field
  16560. // type.
  16561. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16562. switch name {
  16563. }
  16564. return fmt.Errorf("unknown Message numeric field %s", name)
  16565. }
  16566. // ClearedFields returns all nullable fields that were cleared during this
  16567. // mutation.
  16568. func (m *MessageMutation) ClearedFields() []string {
  16569. var fields []string
  16570. if m.FieldCleared(message.FieldWxWxid) {
  16571. fields = append(fields, message.FieldWxWxid)
  16572. }
  16573. return fields
  16574. }
  16575. // FieldCleared returns a boolean indicating if a field with the given name was
  16576. // cleared in this mutation.
  16577. func (m *MessageMutation) FieldCleared(name string) bool {
  16578. _, ok := m.clearedFields[name]
  16579. return ok
  16580. }
  16581. // ClearField clears the value of the field with the given name. It returns an
  16582. // error if the field is not defined in the schema.
  16583. func (m *MessageMutation) ClearField(name string) error {
  16584. switch name {
  16585. case message.FieldWxWxid:
  16586. m.ClearWxWxid()
  16587. return nil
  16588. }
  16589. return fmt.Errorf("unknown Message nullable field %s", name)
  16590. }
  16591. // ResetField resets all changes in the mutation for the field with the given name.
  16592. // It returns an error if the field is not defined in the schema.
  16593. func (m *MessageMutation) ResetField(name string) error {
  16594. switch name {
  16595. case message.FieldWxWxid:
  16596. m.ResetWxWxid()
  16597. return nil
  16598. case message.FieldWxid:
  16599. m.ResetWxid()
  16600. return nil
  16601. case message.FieldContent:
  16602. m.ResetContent()
  16603. return nil
  16604. }
  16605. return fmt.Errorf("unknown Message field %s", name)
  16606. }
  16607. // AddedEdges returns all edge names that were set/added in this mutation.
  16608. func (m *MessageMutation) AddedEdges() []string {
  16609. edges := make([]string, 0, 0)
  16610. return edges
  16611. }
  16612. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16613. // name in this mutation.
  16614. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16615. return nil
  16616. }
  16617. // RemovedEdges returns all edge names that were removed in this mutation.
  16618. func (m *MessageMutation) RemovedEdges() []string {
  16619. edges := make([]string, 0, 0)
  16620. return edges
  16621. }
  16622. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16623. // the given name in this mutation.
  16624. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16625. return nil
  16626. }
  16627. // ClearedEdges returns all edge names that were cleared in this mutation.
  16628. func (m *MessageMutation) ClearedEdges() []string {
  16629. edges := make([]string, 0, 0)
  16630. return edges
  16631. }
  16632. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16633. // was cleared in this mutation.
  16634. func (m *MessageMutation) EdgeCleared(name string) bool {
  16635. return false
  16636. }
  16637. // ClearEdge clears the value of the edge with the given name. It returns an error
  16638. // if that edge is not defined in the schema.
  16639. func (m *MessageMutation) ClearEdge(name string) error {
  16640. return fmt.Errorf("unknown Message unique edge %s", name)
  16641. }
  16642. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16643. // It returns an error if the edge is not defined in the schema.
  16644. func (m *MessageMutation) ResetEdge(name string) error {
  16645. return fmt.Errorf("unknown Message edge %s", name)
  16646. }
  16647. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16648. type MessageRecordsMutation struct {
  16649. config
  16650. op Op
  16651. typ string
  16652. id *uint64
  16653. created_at *time.Time
  16654. updated_at *time.Time
  16655. status *uint8
  16656. addstatus *int8
  16657. bot_wxid *string
  16658. contact_type *int
  16659. addcontact_type *int
  16660. contact_wxid *string
  16661. content_type *int
  16662. addcontent_type *int
  16663. content *string
  16664. meta *custom_types.Meta
  16665. error_detail *string
  16666. send_time *time.Time
  16667. source_type *int
  16668. addsource_type *int
  16669. organization_id *uint64
  16670. addorganization_id *int64
  16671. clearedFields map[string]struct{}
  16672. sop_stage *uint64
  16673. clearedsop_stage bool
  16674. sop_node *uint64
  16675. clearedsop_node bool
  16676. message_contact *uint64
  16677. clearedmessage_contact bool
  16678. done bool
  16679. oldValue func(context.Context) (*MessageRecords, error)
  16680. predicates []predicate.MessageRecords
  16681. }
  16682. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16683. // messagerecordsOption allows management of the mutation configuration using functional options.
  16684. type messagerecordsOption func(*MessageRecordsMutation)
  16685. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16686. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16687. m := &MessageRecordsMutation{
  16688. config: c,
  16689. op: op,
  16690. typ: TypeMessageRecords,
  16691. clearedFields: make(map[string]struct{}),
  16692. }
  16693. for _, opt := range opts {
  16694. opt(m)
  16695. }
  16696. return m
  16697. }
  16698. // withMessageRecordsID sets the ID field of the mutation.
  16699. func withMessageRecordsID(id uint64) messagerecordsOption {
  16700. return func(m *MessageRecordsMutation) {
  16701. var (
  16702. err error
  16703. once sync.Once
  16704. value *MessageRecords
  16705. )
  16706. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16707. once.Do(func() {
  16708. if m.done {
  16709. err = errors.New("querying old values post mutation is not allowed")
  16710. } else {
  16711. value, err = m.Client().MessageRecords.Get(ctx, id)
  16712. }
  16713. })
  16714. return value, err
  16715. }
  16716. m.id = &id
  16717. }
  16718. }
  16719. // withMessageRecords sets the old MessageRecords of the mutation.
  16720. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16721. return func(m *MessageRecordsMutation) {
  16722. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16723. return node, nil
  16724. }
  16725. m.id = &node.ID
  16726. }
  16727. }
  16728. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16729. // executed in a transaction (ent.Tx), a transactional client is returned.
  16730. func (m MessageRecordsMutation) Client() *Client {
  16731. client := &Client{config: m.config}
  16732. client.init()
  16733. return client
  16734. }
  16735. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16736. // it returns an error otherwise.
  16737. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16738. if _, ok := m.driver.(*txDriver); !ok {
  16739. return nil, errors.New("ent: mutation is not running in a transaction")
  16740. }
  16741. tx := &Tx{config: m.config}
  16742. tx.init()
  16743. return tx, nil
  16744. }
  16745. // SetID sets the value of the id field. Note that this
  16746. // operation is only accepted on creation of MessageRecords entities.
  16747. func (m *MessageRecordsMutation) SetID(id uint64) {
  16748. m.id = &id
  16749. }
  16750. // ID returns the ID value in the mutation. Note that the ID is only available
  16751. // if it was provided to the builder or after it was returned from the database.
  16752. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16753. if m.id == nil {
  16754. return
  16755. }
  16756. return *m.id, true
  16757. }
  16758. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16759. // That means, if the mutation is applied within a transaction with an isolation level such
  16760. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16761. // or updated by the mutation.
  16762. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16763. switch {
  16764. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16765. id, exists := m.ID()
  16766. if exists {
  16767. return []uint64{id}, nil
  16768. }
  16769. fallthrough
  16770. case m.op.Is(OpUpdate | OpDelete):
  16771. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16772. default:
  16773. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16774. }
  16775. }
  16776. // SetCreatedAt sets the "created_at" field.
  16777. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16778. m.created_at = &t
  16779. }
  16780. // CreatedAt returns the value of the "created_at" field in the mutation.
  16781. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16782. v := m.created_at
  16783. if v == nil {
  16784. return
  16785. }
  16786. return *v, true
  16787. }
  16788. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16789. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16791. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16792. if !m.op.Is(OpUpdateOne) {
  16793. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16794. }
  16795. if m.id == nil || m.oldValue == nil {
  16796. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16797. }
  16798. oldValue, err := m.oldValue(ctx)
  16799. if err != nil {
  16800. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16801. }
  16802. return oldValue.CreatedAt, nil
  16803. }
  16804. // ResetCreatedAt resets all changes to the "created_at" field.
  16805. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16806. m.created_at = nil
  16807. }
  16808. // SetUpdatedAt sets the "updated_at" field.
  16809. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16810. m.updated_at = &t
  16811. }
  16812. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16813. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16814. v := m.updated_at
  16815. if v == nil {
  16816. return
  16817. }
  16818. return *v, true
  16819. }
  16820. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16821. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16823. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16824. if !m.op.Is(OpUpdateOne) {
  16825. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16826. }
  16827. if m.id == nil || m.oldValue == nil {
  16828. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16829. }
  16830. oldValue, err := m.oldValue(ctx)
  16831. if err != nil {
  16832. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16833. }
  16834. return oldValue.UpdatedAt, nil
  16835. }
  16836. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16837. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16838. m.updated_at = nil
  16839. }
  16840. // SetStatus sets the "status" field.
  16841. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16842. m.status = &u
  16843. m.addstatus = nil
  16844. }
  16845. // Status returns the value of the "status" field in the mutation.
  16846. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16847. v := m.status
  16848. if v == nil {
  16849. return
  16850. }
  16851. return *v, true
  16852. }
  16853. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16854. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16856. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16857. if !m.op.Is(OpUpdateOne) {
  16858. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16859. }
  16860. if m.id == nil || m.oldValue == nil {
  16861. return v, errors.New("OldStatus requires an ID field in the mutation")
  16862. }
  16863. oldValue, err := m.oldValue(ctx)
  16864. if err != nil {
  16865. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16866. }
  16867. return oldValue.Status, nil
  16868. }
  16869. // AddStatus adds u to the "status" field.
  16870. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16871. if m.addstatus != nil {
  16872. *m.addstatus += u
  16873. } else {
  16874. m.addstatus = &u
  16875. }
  16876. }
  16877. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16878. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16879. v := m.addstatus
  16880. if v == nil {
  16881. return
  16882. }
  16883. return *v, true
  16884. }
  16885. // ClearStatus clears the value of the "status" field.
  16886. func (m *MessageRecordsMutation) ClearStatus() {
  16887. m.status = nil
  16888. m.addstatus = nil
  16889. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16890. }
  16891. // StatusCleared returns if the "status" field was cleared in this mutation.
  16892. func (m *MessageRecordsMutation) StatusCleared() bool {
  16893. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16894. return ok
  16895. }
  16896. // ResetStatus resets all changes to the "status" field.
  16897. func (m *MessageRecordsMutation) ResetStatus() {
  16898. m.status = nil
  16899. m.addstatus = nil
  16900. delete(m.clearedFields, messagerecords.FieldStatus)
  16901. }
  16902. // SetBotWxid sets the "bot_wxid" field.
  16903. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16904. m.bot_wxid = &s
  16905. }
  16906. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16907. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16908. v := m.bot_wxid
  16909. if v == nil {
  16910. return
  16911. }
  16912. return *v, true
  16913. }
  16914. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16915. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16916. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16917. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16918. if !m.op.Is(OpUpdateOne) {
  16919. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16920. }
  16921. if m.id == nil || m.oldValue == nil {
  16922. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16923. }
  16924. oldValue, err := m.oldValue(ctx)
  16925. if err != nil {
  16926. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16927. }
  16928. return oldValue.BotWxid, nil
  16929. }
  16930. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16931. func (m *MessageRecordsMutation) ResetBotWxid() {
  16932. m.bot_wxid = nil
  16933. }
  16934. // SetContactID sets the "contact_id" field.
  16935. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16936. m.message_contact = &u
  16937. }
  16938. // ContactID returns the value of the "contact_id" field in the mutation.
  16939. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16940. v := m.message_contact
  16941. if v == nil {
  16942. return
  16943. }
  16944. return *v, true
  16945. }
  16946. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16947. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16948. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16949. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16950. if !m.op.Is(OpUpdateOne) {
  16951. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16952. }
  16953. if m.id == nil || m.oldValue == nil {
  16954. return v, errors.New("OldContactID requires an ID field in the mutation")
  16955. }
  16956. oldValue, err := m.oldValue(ctx)
  16957. if err != nil {
  16958. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16959. }
  16960. return oldValue.ContactID, nil
  16961. }
  16962. // ClearContactID clears the value of the "contact_id" field.
  16963. func (m *MessageRecordsMutation) ClearContactID() {
  16964. m.message_contact = nil
  16965. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16966. }
  16967. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16968. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16969. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16970. return ok
  16971. }
  16972. // ResetContactID resets all changes to the "contact_id" field.
  16973. func (m *MessageRecordsMutation) ResetContactID() {
  16974. m.message_contact = nil
  16975. delete(m.clearedFields, messagerecords.FieldContactID)
  16976. }
  16977. // SetContactType sets the "contact_type" field.
  16978. func (m *MessageRecordsMutation) SetContactType(i int) {
  16979. m.contact_type = &i
  16980. m.addcontact_type = nil
  16981. }
  16982. // ContactType returns the value of the "contact_type" field in the mutation.
  16983. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16984. v := m.contact_type
  16985. if v == nil {
  16986. return
  16987. }
  16988. return *v, true
  16989. }
  16990. // OldContactType returns the old "contact_type" field's value of the MessageRecords entity.
  16991. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16993. func (m *MessageRecordsMutation) OldContactType(ctx context.Context) (v int, err error) {
  16994. if !m.op.Is(OpUpdateOne) {
  16995. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16996. }
  16997. if m.id == nil || m.oldValue == nil {
  16998. return v, errors.New("OldContactType requires an ID field in the mutation")
  16999. }
  17000. oldValue, err := m.oldValue(ctx)
  17001. if err != nil {
  17002. return v, fmt.Errorf("querying old value for OldContactType: %w", err)
  17003. }
  17004. return oldValue.ContactType, nil
  17005. }
  17006. // AddContactType adds i to the "contact_type" field.
  17007. func (m *MessageRecordsMutation) AddContactType(i int) {
  17008. if m.addcontact_type != nil {
  17009. *m.addcontact_type += i
  17010. } else {
  17011. m.addcontact_type = &i
  17012. }
  17013. }
  17014. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  17015. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  17016. v := m.addcontact_type
  17017. if v == nil {
  17018. return
  17019. }
  17020. return *v, true
  17021. }
  17022. // ResetContactType resets all changes to the "contact_type" field.
  17023. func (m *MessageRecordsMutation) ResetContactType() {
  17024. m.contact_type = nil
  17025. m.addcontact_type = nil
  17026. }
  17027. // SetContactWxid sets the "contact_wxid" field.
  17028. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  17029. m.contact_wxid = &s
  17030. }
  17031. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  17032. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  17033. v := m.contact_wxid
  17034. if v == nil {
  17035. return
  17036. }
  17037. return *v, true
  17038. }
  17039. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  17040. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17041. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17042. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  17043. if !m.op.Is(OpUpdateOne) {
  17044. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  17045. }
  17046. if m.id == nil || m.oldValue == nil {
  17047. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  17048. }
  17049. oldValue, err := m.oldValue(ctx)
  17050. if err != nil {
  17051. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  17052. }
  17053. return oldValue.ContactWxid, nil
  17054. }
  17055. // ResetContactWxid resets all changes to the "contact_wxid" field.
  17056. func (m *MessageRecordsMutation) ResetContactWxid() {
  17057. m.contact_wxid = nil
  17058. }
  17059. // SetContentType sets the "content_type" field.
  17060. func (m *MessageRecordsMutation) SetContentType(i int) {
  17061. m.content_type = &i
  17062. m.addcontent_type = nil
  17063. }
  17064. // ContentType returns the value of the "content_type" field in the mutation.
  17065. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  17066. v := m.content_type
  17067. if v == nil {
  17068. return
  17069. }
  17070. return *v, true
  17071. }
  17072. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  17073. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17074. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17075. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17076. if !m.op.Is(OpUpdateOne) {
  17077. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17078. }
  17079. if m.id == nil || m.oldValue == nil {
  17080. return v, errors.New("OldContentType requires an ID field in the mutation")
  17081. }
  17082. oldValue, err := m.oldValue(ctx)
  17083. if err != nil {
  17084. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17085. }
  17086. return oldValue.ContentType, nil
  17087. }
  17088. // AddContentType adds i to the "content_type" field.
  17089. func (m *MessageRecordsMutation) AddContentType(i int) {
  17090. if m.addcontent_type != nil {
  17091. *m.addcontent_type += i
  17092. } else {
  17093. m.addcontent_type = &i
  17094. }
  17095. }
  17096. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17097. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17098. v := m.addcontent_type
  17099. if v == nil {
  17100. return
  17101. }
  17102. return *v, true
  17103. }
  17104. // ResetContentType resets all changes to the "content_type" field.
  17105. func (m *MessageRecordsMutation) ResetContentType() {
  17106. m.content_type = nil
  17107. m.addcontent_type = nil
  17108. }
  17109. // SetContent sets the "content" field.
  17110. func (m *MessageRecordsMutation) SetContent(s string) {
  17111. m.content = &s
  17112. }
  17113. // Content returns the value of the "content" field in the mutation.
  17114. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17115. v := m.content
  17116. if v == nil {
  17117. return
  17118. }
  17119. return *v, true
  17120. }
  17121. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17122. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17123. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17124. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17125. if !m.op.Is(OpUpdateOne) {
  17126. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17127. }
  17128. if m.id == nil || m.oldValue == nil {
  17129. return v, errors.New("OldContent requires an ID field in the mutation")
  17130. }
  17131. oldValue, err := m.oldValue(ctx)
  17132. if err != nil {
  17133. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17134. }
  17135. return oldValue.Content, nil
  17136. }
  17137. // ResetContent resets all changes to the "content" field.
  17138. func (m *MessageRecordsMutation) ResetContent() {
  17139. m.content = nil
  17140. }
  17141. // SetMeta sets the "meta" field.
  17142. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17143. m.meta = &ct
  17144. }
  17145. // Meta returns the value of the "meta" field in the mutation.
  17146. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17147. v := m.meta
  17148. if v == nil {
  17149. return
  17150. }
  17151. return *v, true
  17152. }
  17153. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17154. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17156. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17157. if !m.op.Is(OpUpdateOne) {
  17158. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17159. }
  17160. if m.id == nil || m.oldValue == nil {
  17161. return v, errors.New("OldMeta requires an ID field in the mutation")
  17162. }
  17163. oldValue, err := m.oldValue(ctx)
  17164. if err != nil {
  17165. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17166. }
  17167. return oldValue.Meta, nil
  17168. }
  17169. // ClearMeta clears the value of the "meta" field.
  17170. func (m *MessageRecordsMutation) ClearMeta() {
  17171. m.meta = nil
  17172. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17173. }
  17174. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17175. func (m *MessageRecordsMutation) MetaCleared() bool {
  17176. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17177. return ok
  17178. }
  17179. // ResetMeta resets all changes to the "meta" field.
  17180. func (m *MessageRecordsMutation) ResetMeta() {
  17181. m.meta = nil
  17182. delete(m.clearedFields, messagerecords.FieldMeta)
  17183. }
  17184. // SetErrorDetail sets the "error_detail" field.
  17185. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17186. m.error_detail = &s
  17187. }
  17188. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17189. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17190. v := m.error_detail
  17191. if v == nil {
  17192. return
  17193. }
  17194. return *v, true
  17195. }
  17196. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17197. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17198. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17199. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17200. if !m.op.Is(OpUpdateOne) {
  17201. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17202. }
  17203. if m.id == nil || m.oldValue == nil {
  17204. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17205. }
  17206. oldValue, err := m.oldValue(ctx)
  17207. if err != nil {
  17208. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17209. }
  17210. return oldValue.ErrorDetail, nil
  17211. }
  17212. // ResetErrorDetail resets all changes to the "error_detail" field.
  17213. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17214. m.error_detail = nil
  17215. }
  17216. // SetSendTime sets the "send_time" field.
  17217. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17218. m.send_time = &t
  17219. }
  17220. // SendTime returns the value of the "send_time" field in the mutation.
  17221. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17222. v := m.send_time
  17223. if v == nil {
  17224. return
  17225. }
  17226. return *v, true
  17227. }
  17228. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17229. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17230. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17231. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17232. if !m.op.Is(OpUpdateOne) {
  17233. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17234. }
  17235. if m.id == nil || m.oldValue == nil {
  17236. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17237. }
  17238. oldValue, err := m.oldValue(ctx)
  17239. if err != nil {
  17240. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17241. }
  17242. return oldValue.SendTime, nil
  17243. }
  17244. // ClearSendTime clears the value of the "send_time" field.
  17245. func (m *MessageRecordsMutation) ClearSendTime() {
  17246. m.send_time = nil
  17247. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17248. }
  17249. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17250. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17251. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17252. return ok
  17253. }
  17254. // ResetSendTime resets all changes to the "send_time" field.
  17255. func (m *MessageRecordsMutation) ResetSendTime() {
  17256. m.send_time = nil
  17257. delete(m.clearedFields, messagerecords.FieldSendTime)
  17258. }
  17259. // SetSourceType sets the "source_type" field.
  17260. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17261. m.source_type = &i
  17262. m.addsource_type = nil
  17263. }
  17264. // SourceType returns the value of the "source_type" field in the mutation.
  17265. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17266. v := m.source_type
  17267. if v == nil {
  17268. return
  17269. }
  17270. return *v, true
  17271. }
  17272. // OldSourceType returns the old "source_type" field's value of the MessageRecords entity.
  17273. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17275. func (m *MessageRecordsMutation) OldSourceType(ctx context.Context) (v int, err error) {
  17276. if !m.op.Is(OpUpdateOne) {
  17277. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17278. }
  17279. if m.id == nil || m.oldValue == nil {
  17280. return v, errors.New("OldSourceType requires an ID field in the mutation")
  17281. }
  17282. oldValue, err := m.oldValue(ctx)
  17283. if err != nil {
  17284. return v, fmt.Errorf("querying old value for OldSourceType: %w", err)
  17285. }
  17286. return oldValue.SourceType, nil
  17287. }
  17288. // AddSourceType adds i to the "source_type" field.
  17289. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17290. if m.addsource_type != nil {
  17291. *m.addsource_type += i
  17292. } else {
  17293. m.addsource_type = &i
  17294. }
  17295. }
  17296. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17297. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17298. v := m.addsource_type
  17299. if v == nil {
  17300. return
  17301. }
  17302. return *v, true
  17303. }
  17304. // ResetSourceType resets all changes to the "source_type" field.
  17305. func (m *MessageRecordsMutation) ResetSourceType() {
  17306. m.source_type = nil
  17307. m.addsource_type = nil
  17308. }
  17309. // SetSourceID sets the "source_id" field.
  17310. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17311. m.sop_stage = &u
  17312. }
  17313. // SourceID returns the value of the "source_id" field in the mutation.
  17314. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17315. v := m.sop_stage
  17316. if v == nil {
  17317. return
  17318. }
  17319. return *v, true
  17320. }
  17321. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17322. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17324. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17325. if !m.op.Is(OpUpdateOne) {
  17326. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17327. }
  17328. if m.id == nil || m.oldValue == nil {
  17329. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17330. }
  17331. oldValue, err := m.oldValue(ctx)
  17332. if err != nil {
  17333. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17334. }
  17335. return oldValue.SourceID, nil
  17336. }
  17337. // ClearSourceID clears the value of the "source_id" field.
  17338. func (m *MessageRecordsMutation) ClearSourceID() {
  17339. m.sop_stage = nil
  17340. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17341. }
  17342. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17343. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17344. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17345. return ok
  17346. }
  17347. // ResetSourceID resets all changes to the "source_id" field.
  17348. func (m *MessageRecordsMutation) ResetSourceID() {
  17349. m.sop_stage = nil
  17350. delete(m.clearedFields, messagerecords.FieldSourceID)
  17351. }
  17352. // SetSubSourceID sets the "sub_source_id" field.
  17353. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17354. m.sop_node = &u
  17355. }
  17356. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17357. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17358. v := m.sop_node
  17359. if v == nil {
  17360. return
  17361. }
  17362. return *v, true
  17363. }
  17364. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17365. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17367. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17368. if !m.op.Is(OpUpdateOne) {
  17369. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17370. }
  17371. if m.id == nil || m.oldValue == nil {
  17372. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17373. }
  17374. oldValue, err := m.oldValue(ctx)
  17375. if err != nil {
  17376. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17377. }
  17378. return oldValue.SubSourceID, nil
  17379. }
  17380. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17381. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17382. m.sop_node = nil
  17383. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17384. }
  17385. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17386. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17387. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17388. return ok
  17389. }
  17390. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17391. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17392. m.sop_node = nil
  17393. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17394. }
  17395. // SetOrganizationID sets the "organization_id" field.
  17396. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17397. m.organization_id = &u
  17398. m.addorganization_id = nil
  17399. }
  17400. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17401. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17402. v := m.organization_id
  17403. if v == nil {
  17404. return
  17405. }
  17406. return *v, true
  17407. }
  17408. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17409. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17411. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17412. if !m.op.Is(OpUpdateOne) {
  17413. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17414. }
  17415. if m.id == nil || m.oldValue == nil {
  17416. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17417. }
  17418. oldValue, err := m.oldValue(ctx)
  17419. if err != nil {
  17420. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17421. }
  17422. return oldValue.OrganizationID, nil
  17423. }
  17424. // AddOrganizationID adds u to the "organization_id" field.
  17425. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17426. if m.addorganization_id != nil {
  17427. *m.addorganization_id += u
  17428. } else {
  17429. m.addorganization_id = &u
  17430. }
  17431. }
  17432. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17433. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17434. v := m.addorganization_id
  17435. if v == nil {
  17436. return
  17437. }
  17438. return *v, true
  17439. }
  17440. // ClearOrganizationID clears the value of the "organization_id" field.
  17441. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17442. m.organization_id = nil
  17443. m.addorganization_id = nil
  17444. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17445. }
  17446. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17447. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17448. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17449. return ok
  17450. }
  17451. // ResetOrganizationID resets all changes to the "organization_id" field.
  17452. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17453. m.organization_id = nil
  17454. m.addorganization_id = nil
  17455. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17456. }
  17457. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17458. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17459. m.sop_stage = &id
  17460. }
  17461. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17462. func (m *MessageRecordsMutation) ClearSopStage() {
  17463. m.clearedsop_stage = true
  17464. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17465. }
  17466. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17467. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17468. return m.SourceIDCleared() || m.clearedsop_stage
  17469. }
  17470. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17471. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17472. if m.sop_stage != nil {
  17473. return *m.sop_stage, true
  17474. }
  17475. return
  17476. }
  17477. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17478. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17479. // SopStageID instead. It exists only for internal usage by the builders.
  17480. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17481. if id := m.sop_stage; id != nil {
  17482. ids = append(ids, *id)
  17483. }
  17484. return
  17485. }
  17486. // ResetSopStage resets all changes to the "sop_stage" edge.
  17487. func (m *MessageRecordsMutation) ResetSopStage() {
  17488. m.sop_stage = nil
  17489. m.clearedsop_stage = false
  17490. }
  17491. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17492. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17493. m.sop_node = &id
  17494. }
  17495. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17496. func (m *MessageRecordsMutation) ClearSopNode() {
  17497. m.clearedsop_node = true
  17498. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17499. }
  17500. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17501. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17502. return m.SubSourceIDCleared() || m.clearedsop_node
  17503. }
  17504. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17505. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17506. if m.sop_node != nil {
  17507. return *m.sop_node, true
  17508. }
  17509. return
  17510. }
  17511. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17512. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17513. // SopNodeID instead. It exists only for internal usage by the builders.
  17514. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17515. if id := m.sop_node; id != nil {
  17516. ids = append(ids, *id)
  17517. }
  17518. return
  17519. }
  17520. // ResetSopNode resets all changes to the "sop_node" edge.
  17521. func (m *MessageRecordsMutation) ResetSopNode() {
  17522. m.sop_node = nil
  17523. m.clearedsop_node = false
  17524. }
  17525. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17526. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17527. m.message_contact = &id
  17528. }
  17529. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17530. func (m *MessageRecordsMutation) ClearMessageContact() {
  17531. m.clearedmessage_contact = true
  17532. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17533. }
  17534. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17535. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17536. return m.ContactIDCleared() || m.clearedmessage_contact
  17537. }
  17538. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17539. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17540. if m.message_contact != nil {
  17541. return *m.message_contact, true
  17542. }
  17543. return
  17544. }
  17545. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17546. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17547. // MessageContactID instead. It exists only for internal usage by the builders.
  17548. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17549. if id := m.message_contact; id != nil {
  17550. ids = append(ids, *id)
  17551. }
  17552. return
  17553. }
  17554. // ResetMessageContact resets all changes to the "message_contact" edge.
  17555. func (m *MessageRecordsMutation) ResetMessageContact() {
  17556. m.message_contact = nil
  17557. m.clearedmessage_contact = false
  17558. }
  17559. // Where appends a list predicates to the MessageRecordsMutation builder.
  17560. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17561. m.predicates = append(m.predicates, ps...)
  17562. }
  17563. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17564. // users can use type-assertion to append predicates that do not depend on any generated package.
  17565. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17566. p := make([]predicate.MessageRecords, len(ps))
  17567. for i := range ps {
  17568. p[i] = ps[i]
  17569. }
  17570. m.Where(p...)
  17571. }
  17572. // Op returns the operation name.
  17573. func (m *MessageRecordsMutation) Op() Op {
  17574. return m.op
  17575. }
  17576. // SetOp allows setting the mutation operation.
  17577. func (m *MessageRecordsMutation) SetOp(op Op) {
  17578. m.op = op
  17579. }
  17580. // Type returns the node type of this mutation (MessageRecords).
  17581. func (m *MessageRecordsMutation) Type() string {
  17582. return m.typ
  17583. }
  17584. // Fields returns all fields that were changed during this mutation. Note that in
  17585. // order to get all numeric fields that were incremented/decremented, call
  17586. // AddedFields().
  17587. func (m *MessageRecordsMutation) Fields() []string {
  17588. fields := make([]string, 0, 16)
  17589. if m.created_at != nil {
  17590. fields = append(fields, messagerecords.FieldCreatedAt)
  17591. }
  17592. if m.updated_at != nil {
  17593. fields = append(fields, messagerecords.FieldUpdatedAt)
  17594. }
  17595. if m.status != nil {
  17596. fields = append(fields, messagerecords.FieldStatus)
  17597. }
  17598. if m.bot_wxid != nil {
  17599. fields = append(fields, messagerecords.FieldBotWxid)
  17600. }
  17601. if m.message_contact != nil {
  17602. fields = append(fields, messagerecords.FieldContactID)
  17603. }
  17604. if m.contact_type != nil {
  17605. fields = append(fields, messagerecords.FieldContactType)
  17606. }
  17607. if m.contact_wxid != nil {
  17608. fields = append(fields, messagerecords.FieldContactWxid)
  17609. }
  17610. if m.content_type != nil {
  17611. fields = append(fields, messagerecords.FieldContentType)
  17612. }
  17613. if m.content != nil {
  17614. fields = append(fields, messagerecords.FieldContent)
  17615. }
  17616. if m.meta != nil {
  17617. fields = append(fields, messagerecords.FieldMeta)
  17618. }
  17619. if m.error_detail != nil {
  17620. fields = append(fields, messagerecords.FieldErrorDetail)
  17621. }
  17622. if m.send_time != nil {
  17623. fields = append(fields, messagerecords.FieldSendTime)
  17624. }
  17625. if m.source_type != nil {
  17626. fields = append(fields, messagerecords.FieldSourceType)
  17627. }
  17628. if m.sop_stage != nil {
  17629. fields = append(fields, messagerecords.FieldSourceID)
  17630. }
  17631. if m.sop_node != nil {
  17632. fields = append(fields, messagerecords.FieldSubSourceID)
  17633. }
  17634. if m.organization_id != nil {
  17635. fields = append(fields, messagerecords.FieldOrganizationID)
  17636. }
  17637. return fields
  17638. }
  17639. // Field returns the value of a field with the given name. The second boolean
  17640. // return value indicates that this field was not set, or was not defined in the
  17641. // schema.
  17642. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17643. switch name {
  17644. case messagerecords.FieldCreatedAt:
  17645. return m.CreatedAt()
  17646. case messagerecords.FieldUpdatedAt:
  17647. return m.UpdatedAt()
  17648. case messagerecords.FieldStatus:
  17649. return m.Status()
  17650. case messagerecords.FieldBotWxid:
  17651. return m.BotWxid()
  17652. case messagerecords.FieldContactID:
  17653. return m.ContactID()
  17654. case messagerecords.FieldContactType:
  17655. return m.ContactType()
  17656. case messagerecords.FieldContactWxid:
  17657. return m.ContactWxid()
  17658. case messagerecords.FieldContentType:
  17659. return m.ContentType()
  17660. case messagerecords.FieldContent:
  17661. return m.Content()
  17662. case messagerecords.FieldMeta:
  17663. return m.Meta()
  17664. case messagerecords.FieldErrorDetail:
  17665. return m.ErrorDetail()
  17666. case messagerecords.FieldSendTime:
  17667. return m.SendTime()
  17668. case messagerecords.FieldSourceType:
  17669. return m.SourceType()
  17670. case messagerecords.FieldSourceID:
  17671. return m.SourceID()
  17672. case messagerecords.FieldSubSourceID:
  17673. return m.SubSourceID()
  17674. case messagerecords.FieldOrganizationID:
  17675. return m.OrganizationID()
  17676. }
  17677. return nil, false
  17678. }
  17679. // OldField returns the old value of the field from the database. An error is
  17680. // returned if the mutation operation is not UpdateOne, or the query to the
  17681. // database failed.
  17682. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17683. switch name {
  17684. case messagerecords.FieldCreatedAt:
  17685. return m.OldCreatedAt(ctx)
  17686. case messagerecords.FieldUpdatedAt:
  17687. return m.OldUpdatedAt(ctx)
  17688. case messagerecords.FieldStatus:
  17689. return m.OldStatus(ctx)
  17690. case messagerecords.FieldBotWxid:
  17691. return m.OldBotWxid(ctx)
  17692. case messagerecords.FieldContactID:
  17693. return m.OldContactID(ctx)
  17694. case messagerecords.FieldContactType:
  17695. return m.OldContactType(ctx)
  17696. case messagerecords.FieldContactWxid:
  17697. return m.OldContactWxid(ctx)
  17698. case messagerecords.FieldContentType:
  17699. return m.OldContentType(ctx)
  17700. case messagerecords.FieldContent:
  17701. return m.OldContent(ctx)
  17702. case messagerecords.FieldMeta:
  17703. return m.OldMeta(ctx)
  17704. case messagerecords.FieldErrorDetail:
  17705. return m.OldErrorDetail(ctx)
  17706. case messagerecords.FieldSendTime:
  17707. return m.OldSendTime(ctx)
  17708. case messagerecords.FieldSourceType:
  17709. return m.OldSourceType(ctx)
  17710. case messagerecords.FieldSourceID:
  17711. return m.OldSourceID(ctx)
  17712. case messagerecords.FieldSubSourceID:
  17713. return m.OldSubSourceID(ctx)
  17714. case messagerecords.FieldOrganizationID:
  17715. return m.OldOrganizationID(ctx)
  17716. }
  17717. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17718. }
  17719. // SetField sets the value of a field with the given name. It returns an error if
  17720. // the field is not defined in the schema, or if the type mismatched the field
  17721. // type.
  17722. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17723. switch name {
  17724. case messagerecords.FieldCreatedAt:
  17725. v, ok := value.(time.Time)
  17726. if !ok {
  17727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17728. }
  17729. m.SetCreatedAt(v)
  17730. return nil
  17731. case messagerecords.FieldUpdatedAt:
  17732. v, ok := value.(time.Time)
  17733. if !ok {
  17734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17735. }
  17736. m.SetUpdatedAt(v)
  17737. return nil
  17738. case messagerecords.FieldStatus:
  17739. v, ok := value.(uint8)
  17740. if !ok {
  17741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17742. }
  17743. m.SetStatus(v)
  17744. return nil
  17745. case messagerecords.FieldBotWxid:
  17746. v, ok := value.(string)
  17747. if !ok {
  17748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17749. }
  17750. m.SetBotWxid(v)
  17751. return nil
  17752. case messagerecords.FieldContactID:
  17753. v, ok := value.(uint64)
  17754. if !ok {
  17755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17756. }
  17757. m.SetContactID(v)
  17758. return nil
  17759. case messagerecords.FieldContactType:
  17760. v, ok := value.(int)
  17761. if !ok {
  17762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17763. }
  17764. m.SetContactType(v)
  17765. return nil
  17766. case messagerecords.FieldContactWxid:
  17767. v, ok := value.(string)
  17768. if !ok {
  17769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17770. }
  17771. m.SetContactWxid(v)
  17772. return nil
  17773. case messagerecords.FieldContentType:
  17774. v, ok := value.(int)
  17775. if !ok {
  17776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17777. }
  17778. m.SetContentType(v)
  17779. return nil
  17780. case messagerecords.FieldContent:
  17781. v, ok := value.(string)
  17782. if !ok {
  17783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17784. }
  17785. m.SetContent(v)
  17786. return nil
  17787. case messagerecords.FieldMeta:
  17788. v, ok := value.(custom_types.Meta)
  17789. if !ok {
  17790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17791. }
  17792. m.SetMeta(v)
  17793. return nil
  17794. case messagerecords.FieldErrorDetail:
  17795. v, ok := value.(string)
  17796. if !ok {
  17797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17798. }
  17799. m.SetErrorDetail(v)
  17800. return nil
  17801. case messagerecords.FieldSendTime:
  17802. v, ok := value.(time.Time)
  17803. if !ok {
  17804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17805. }
  17806. m.SetSendTime(v)
  17807. return nil
  17808. case messagerecords.FieldSourceType:
  17809. v, ok := value.(int)
  17810. if !ok {
  17811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17812. }
  17813. m.SetSourceType(v)
  17814. return nil
  17815. case messagerecords.FieldSourceID:
  17816. v, ok := value.(uint64)
  17817. if !ok {
  17818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17819. }
  17820. m.SetSourceID(v)
  17821. return nil
  17822. case messagerecords.FieldSubSourceID:
  17823. v, ok := value.(uint64)
  17824. if !ok {
  17825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17826. }
  17827. m.SetSubSourceID(v)
  17828. return nil
  17829. case messagerecords.FieldOrganizationID:
  17830. v, ok := value.(uint64)
  17831. if !ok {
  17832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17833. }
  17834. m.SetOrganizationID(v)
  17835. return nil
  17836. }
  17837. return fmt.Errorf("unknown MessageRecords field %s", name)
  17838. }
  17839. // AddedFields returns all numeric fields that were incremented/decremented during
  17840. // this mutation.
  17841. func (m *MessageRecordsMutation) AddedFields() []string {
  17842. var fields []string
  17843. if m.addstatus != nil {
  17844. fields = append(fields, messagerecords.FieldStatus)
  17845. }
  17846. if m.addcontact_type != nil {
  17847. fields = append(fields, messagerecords.FieldContactType)
  17848. }
  17849. if m.addcontent_type != nil {
  17850. fields = append(fields, messagerecords.FieldContentType)
  17851. }
  17852. if m.addsource_type != nil {
  17853. fields = append(fields, messagerecords.FieldSourceType)
  17854. }
  17855. if m.addorganization_id != nil {
  17856. fields = append(fields, messagerecords.FieldOrganizationID)
  17857. }
  17858. return fields
  17859. }
  17860. // AddedField returns the numeric value that was incremented/decremented on a field
  17861. // with the given name. The second boolean return value indicates that this field
  17862. // was not set, or was not defined in the schema.
  17863. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17864. switch name {
  17865. case messagerecords.FieldStatus:
  17866. return m.AddedStatus()
  17867. case messagerecords.FieldContactType:
  17868. return m.AddedContactType()
  17869. case messagerecords.FieldContentType:
  17870. return m.AddedContentType()
  17871. case messagerecords.FieldSourceType:
  17872. return m.AddedSourceType()
  17873. case messagerecords.FieldOrganizationID:
  17874. return m.AddedOrganizationID()
  17875. }
  17876. return nil, false
  17877. }
  17878. // AddField adds the value to the field with the given name. It returns an error if
  17879. // the field is not defined in the schema, or if the type mismatched the field
  17880. // type.
  17881. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17882. switch name {
  17883. case messagerecords.FieldStatus:
  17884. v, ok := value.(int8)
  17885. if !ok {
  17886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17887. }
  17888. m.AddStatus(v)
  17889. return nil
  17890. case messagerecords.FieldContactType:
  17891. v, ok := value.(int)
  17892. if !ok {
  17893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17894. }
  17895. m.AddContactType(v)
  17896. return nil
  17897. case messagerecords.FieldContentType:
  17898. v, ok := value.(int)
  17899. if !ok {
  17900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17901. }
  17902. m.AddContentType(v)
  17903. return nil
  17904. case messagerecords.FieldSourceType:
  17905. v, ok := value.(int)
  17906. if !ok {
  17907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17908. }
  17909. m.AddSourceType(v)
  17910. return nil
  17911. case messagerecords.FieldOrganizationID:
  17912. v, ok := value.(int64)
  17913. if !ok {
  17914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17915. }
  17916. m.AddOrganizationID(v)
  17917. return nil
  17918. }
  17919. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17920. }
  17921. // ClearedFields returns all nullable fields that were cleared during this
  17922. // mutation.
  17923. func (m *MessageRecordsMutation) ClearedFields() []string {
  17924. var fields []string
  17925. if m.FieldCleared(messagerecords.FieldStatus) {
  17926. fields = append(fields, messagerecords.FieldStatus)
  17927. }
  17928. if m.FieldCleared(messagerecords.FieldContactID) {
  17929. fields = append(fields, messagerecords.FieldContactID)
  17930. }
  17931. if m.FieldCleared(messagerecords.FieldMeta) {
  17932. fields = append(fields, messagerecords.FieldMeta)
  17933. }
  17934. if m.FieldCleared(messagerecords.FieldSendTime) {
  17935. fields = append(fields, messagerecords.FieldSendTime)
  17936. }
  17937. if m.FieldCleared(messagerecords.FieldSourceID) {
  17938. fields = append(fields, messagerecords.FieldSourceID)
  17939. }
  17940. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17941. fields = append(fields, messagerecords.FieldSubSourceID)
  17942. }
  17943. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17944. fields = append(fields, messagerecords.FieldOrganizationID)
  17945. }
  17946. return fields
  17947. }
  17948. // FieldCleared returns a boolean indicating if a field with the given name was
  17949. // cleared in this mutation.
  17950. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17951. _, ok := m.clearedFields[name]
  17952. return ok
  17953. }
  17954. // ClearField clears the value of the field with the given name. It returns an
  17955. // error if the field is not defined in the schema.
  17956. func (m *MessageRecordsMutation) ClearField(name string) error {
  17957. switch name {
  17958. case messagerecords.FieldStatus:
  17959. m.ClearStatus()
  17960. return nil
  17961. case messagerecords.FieldContactID:
  17962. m.ClearContactID()
  17963. return nil
  17964. case messagerecords.FieldMeta:
  17965. m.ClearMeta()
  17966. return nil
  17967. case messagerecords.FieldSendTime:
  17968. m.ClearSendTime()
  17969. return nil
  17970. case messagerecords.FieldSourceID:
  17971. m.ClearSourceID()
  17972. return nil
  17973. case messagerecords.FieldSubSourceID:
  17974. m.ClearSubSourceID()
  17975. return nil
  17976. case messagerecords.FieldOrganizationID:
  17977. m.ClearOrganizationID()
  17978. return nil
  17979. }
  17980. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17981. }
  17982. // ResetField resets all changes in the mutation for the field with the given name.
  17983. // It returns an error if the field is not defined in the schema.
  17984. func (m *MessageRecordsMutation) ResetField(name string) error {
  17985. switch name {
  17986. case messagerecords.FieldCreatedAt:
  17987. m.ResetCreatedAt()
  17988. return nil
  17989. case messagerecords.FieldUpdatedAt:
  17990. m.ResetUpdatedAt()
  17991. return nil
  17992. case messagerecords.FieldStatus:
  17993. m.ResetStatus()
  17994. return nil
  17995. case messagerecords.FieldBotWxid:
  17996. m.ResetBotWxid()
  17997. return nil
  17998. case messagerecords.FieldContactID:
  17999. m.ResetContactID()
  18000. return nil
  18001. case messagerecords.FieldContactType:
  18002. m.ResetContactType()
  18003. return nil
  18004. case messagerecords.FieldContactWxid:
  18005. m.ResetContactWxid()
  18006. return nil
  18007. case messagerecords.FieldContentType:
  18008. m.ResetContentType()
  18009. return nil
  18010. case messagerecords.FieldContent:
  18011. m.ResetContent()
  18012. return nil
  18013. case messagerecords.FieldMeta:
  18014. m.ResetMeta()
  18015. return nil
  18016. case messagerecords.FieldErrorDetail:
  18017. m.ResetErrorDetail()
  18018. return nil
  18019. case messagerecords.FieldSendTime:
  18020. m.ResetSendTime()
  18021. return nil
  18022. case messagerecords.FieldSourceType:
  18023. m.ResetSourceType()
  18024. return nil
  18025. case messagerecords.FieldSourceID:
  18026. m.ResetSourceID()
  18027. return nil
  18028. case messagerecords.FieldSubSourceID:
  18029. m.ResetSubSourceID()
  18030. return nil
  18031. case messagerecords.FieldOrganizationID:
  18032. m.ResetOrganizationID()
  18033. return nil
  18034. }
  18035. return fmt.Errorf("unknown MessageRecords field %s", name)
  18036. }
  18037. // AddedEdges returns all edge names that were set/added in this mutation.
  18038. func (m *MessageRecordsMutation) AddedEdges() []string {
  18039. edges := make([]string, 0, 3)
  18040. if m.sop_stage != nil {
  18041. edges = append(edges, messagerecords.EdgeSopStage)
  18042. }
  18043. if m.sop_node != nil {
  18044. edges = append(edges, messagerecords.EdgeSopNode)
  18045. }
  18046. if m.message_contact != nil {
  18047. edges = append(edges, messagerecords.EdgeMessageContact)
  18048. }
  18049. return edges
  18050. }
  18051. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18052. // name in this mutation.
  18053. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  18054. switch name {
  18055. case messagerecords.EdgeSopStage:
  18056. if id := m.sop_stage; id != nil {
  18057. return []ent.Value{*id}
  18058. }
  18059. case messagerecords.EdgeSopNode:
  18060. if id := m.sop_node; id != nil {
  18061. return []ent.Value{*id}
  18062. }
  18063. case messagerecords.EdgeMessageContact:
  18064. if id := m.message_contact; id != nil {
  18065. return []ent.Value{*id}
  18066. }
  18067. }
  18068. return nil
  18069. }
  18070. // RemovedEdges returns all edge names that were removed in this mutation.
  18071. func (m *MessageRecordsMutation) RemovedEdges() []string {
  18072. edges := make([]string, 0, 3)
  18073. return edges
  18074. }
  18075. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18076. // the given name in this mutation.
  18077. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18078. return nil
  18079. }
  18080. // ClearedEdges returns all edge names that were cleared in this mutation.
  18081. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18082. edges := make([]string, 0, 3)
  18083. if m.clearedsop_stage {
  18084. edges = append(edges, messagerecords.EdgeSopStage)
  18085. }
  18086. if m.clearedsop_node {
  18087. edges = append(edges, messagerecords.EdgeSopNode)
  18088. }
  18089. if m.clearedmessage_contact {
  18090. edges = append(edges, messagerecords.EdgeMessageContact)
  18091. }
  18092. return edges
  18093. }
  18094. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18095. // was cleared in this mutation.
  18096. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18097. switch name {
  18098. case messagerecords.EdgeSopStage:
  18099. return m.clearedsop_stage
  18100. case messagerecords.EdgeSopNode:
  18101. return m.clearedsop_node
  18102. case messagerecords.EdgeMessageContact:
  18103. return m.clearedmessage_contact
  18104. }
  18105. return false
  18106. }
  18107. // ClearEdge clears the value of the edge with the given name. It returns an error
  18108. // if that edge is not defined in the schema.
  18109. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18110. switch name {
  18111. case messagerecords.EdgeSopStage:
  18112. m.ClearSopStage()
  18113. return nil
  18114. case messagerecords.EdgeSopNode:
  18115. m.ClearSopNode()
  18116. return nil
  18117. case messagerecords.EdgeMessageContact:
  18118. m.ClearMessageContact()
  18119. return nil
  18120. }
  18121. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18122. }
  18123. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18124. // It returns an error if the edge is not defined in the schema.
  18125. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18126. switch name {
  18127. case messagerecords.EdgeSopStage:
  18128. m.ResetSopStage()
  18129. return nil
  18130. case messagerecords.EdgeSopNode:
  18131. m.ResetSopNode()
  18132. return nil
  18133. case messagerecords.EdgeMessageContact:
  18134. m.ResetMessageContact()
  18135. return nil
  18136. }
  18137. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18138. }
  18139. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18140. type MsgMutation struct {
  18141. config
  18142. op Op
  18143. typ string
  18144. id *uint64
  18145. created_at *time.Time
  18146. updated_at *time.Time
  18147. deleted_at *time.Time
  18148. status *uint8
  18149. addstatus *int8
  18150. fromwxid *string
  18151. toid *string
  18152. msgtype *int32
  18153. addmsgtype *int32
  18154. msg *string
  18155. batch_no *string
  18156. clearedFields map[string]struct{}
  18157. done bool
  18158. oldValue func(context.Context) (*Msg, error)
  18159. predicates []predicate.Msg
  18160. }
  18161. var _ ent.Mutation = (*MsgMutation)(nil)
  18162. // msgOption allows management of the mutation configuration using functional options.
  18163. type msgOption func(*MsgMutation)
  18164. // newMsgMutation creates new mutation for the Msg entity.
  18165. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18166. m := &MsgMutation{
  18167. config: c,
  18168. op: op,
  18169. typ: TypeMsg,
  18170. clearedFields: make(map[string]struct{}),
  18171. }
  18172. for _, opt := range opts {
  18173. opt(m)
  18174. }
  18175. return m
  18176. }
  18177. // withMsgID sets the ID field of the mutation.
  18178. func withMsgID(id uint64) msgOption {
  18179. return func(m *MsgMutation) {
  18180. var (
  18181. err error
  18182. once sync.Once
  18183. value *Msg
  18184. )
  18185. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18186. once.Do(func() {
  18187. if m.done {
  18188. err = errors.New("querying old values post mutation is not allowed")
  18189. } else {
  18190. value, err = m.Client().Msg.Get(ctx, id)
  18191. }
  18192. })
  18193. return value, err
  18194. }
  18195. m.id = &id
  18196. }
  18197. }
  18198. // withMsg sets the old Msg of the mutation.
  18199. func withMsg(node *Msg) msgOption {
  18200. return func(m *MsgMutation) {
  18201. m.oldValue = func(context.Context) (*Msg, error) {
  18202. return node, nil
  18203. }
  18204. m.id = &node.ID
  18205. }
  18206. }
  18207. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18208. // executed in a transaction (ent.Tx), a transactional client is returned.
  18209. func (m MsgMutation) Client() *Client {
  18210. client := &Client{config: m.config}
  18211. client.init()
  18212. return client
  18213. }
  18214. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18215. // it returns an error otherwise.
  18216. func (m MsgMutation) Tx() (*Tx, error) {
  18217. if _, ok := m.driver.(*txDriver); !ok {
  18218. return nil, errors.New("ent: mutation is not running in a transaction")
  18219. }
  18220. tx := &Tx{config: m.config}
  18221. tx.init()
  18222. return tx, nil
  18223. }
  18224. // SetID sets the value of the id field. Note that this
  18225. // operation is only accepted on creation of Msg entities.
  18226. func (m *MsgMutation) SetID(id uint64) {
  18227. m.id = &id
  18228. }
  18229. // ID returns the ID value in the mutation. Note that the ID is only available
  18230. // if it was provided to the builder or after it was returned from the database.
  18231. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18232. if m.id == nil {
  18233. return
  18234. }
  18235. return *m.id, true
  18236. }
  18237. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18238. // That means, if the mutation is applied within a transaction with an isolation level such
  18239. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18240. // or updated by the mutation.
  18241. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18242. switch {
  18243. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18244. id, exists := m.ID()
  18245. if exists {
  18246. return []uint64{id}, nil
  18247. }
  18248. fallthrough
  18249. case m.op.Is(OpUpdate | OpDelete):
  18250. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18251. default:
  18252. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18253. }
  18254. }
  18255. // SetCreatedAt sets the "created_at" field.
  18256. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18257. m.created_at = &t
  18258. }
  18259. // CreatedAt returns the value of the "created_at" field in the mutation.
  18260. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18261. v := m.created_at
  18262. if v == nil {
  18263. return
  18264. }
  18265. return *v, true
  18266. }
  18267. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18268. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18269. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18270. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18271. if !m.op.Is(OpUpdateOne) {
  18272. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18273. }
  18274. if m.id == nil || m.oldValue == nil {
  18275. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18276. }
  18277. oldValue, err := m.oldValue(ctx)
  18278. if err != nil {
  18279. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18280. }
  18281. return oldValue.CreatedAt, nil
  18282. }
  18283. // ResetCreatedAt resets all changes to the "created_at" field.
  18284. func (m *MsgMutation) ResetCreatedAt() {
  18285. m.created_at = nil
  18286. }
  18287. // SetUpdatedAt sets the "updated_at" field.
  18288. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18289. m.updated_at = &t
  18290. }
  18291. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18292. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18293. v := m.updated_at
  18294. if v == nil {
  18295. return
  18296. }
  18297. return *v, true
  18298. }
  18299. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18300. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18302. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18303. if !m.op.Is(OpUpdateOne) {
  18304. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18305. }
  18306. if m.id == nil || m.oldValue == nil {
  18307. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18308. }
  18309. oldValue, err := m.oldValue(ctx)
  18310. if err != nil {
  18311. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18312. }
  18313. return oldValue.UpdatedAt, nil
  18314. }
  18315. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18316. func (m *MsgMutation) ResetUpdatedAt() {
  18317. m.updated_at = nil
  18318. }
  18319. // SetDeletedAt sets the "deleted_at" field.
  18320. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18321. m.deleted_at = &t
  18322. }
  18323. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18324. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18325. v := m.deleted_at
  18326. if v == nil {
  18327. return
  18328. }
  18329. return *v, true
  18330. }
  18331. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18332. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18334. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18335. if !m.op.Is(OpUpdateOne) {
  18336. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18337. }
  18338. if m.id == nil || m.oldValue == nil {
  18339. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18340. }
  18341. oldValue, err := m.oldValue(ctx)
  18342. if err != nil {
  18343. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18344. }
  18345. return oldValue.DeletedAt, nil
  18346. }
  18347. // ClearDeletedAt clears the value of the "deleted_at" field.
  18348. func (m *MsgMutation) ClearDeletedAt() {
  18349. m.deleted_at = nil
  18350. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18351. }
  18352. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18353. func (m *MsgMutation) DeletedAtCleared() bool {
  18354. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18355. return ok
  18356. }
  18357. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18358. func (m *MsgMutation) ResetDeletedAt() {
  18359. m.deleted_at = nil
  18360. delete(m.clearedFields, msg.FieldDeletedAt)
  18361. }
  18362. // SetStatus sets the "status" field.
  18363. func (m *MsgMutation) SetStatus(u uint8) {
  18364. m.status = &u
  18365. m.addstatus = nil
  18366. }
  18367. // Status returns the value of the "status" field in the mutation.
  18368. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18369. v := m.status
  18370. if v == nil {
  18371. return
  18372. }
  18373. return *v, true
  18374. }
  18375. // OldStatus returns the old "status" field's value of the Msg entity.
  18376. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18377. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18378. func (m *MsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  18379. if !m.op.Is(OpUpdateOne) {
  18380. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18381. }
  18382. if m.id == nil || m.oldValue == nil {
  18383. return v, errors.New("OldStatus requires an ID field in the mutation")
  18384. }
  18385. oldValue, err := m.oldValue(ctx)
  18386. if err != nil {
  18387. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  18388. }
  18389. return oldValue.Status, nil
  18390. }
  18391. // AddStatus adds u to the "status" field.
  18392. func (m *MsgMutation) AddStatus(u int8) {
  18393. if m.addstatus != nil {
  18394. *m.addstatus += u
  18395. } else {
  18396. m.addstatus = &u
  18397. }
  18398. }
  18399. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18400. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18401. v := m.addstatus
  18402. if v == nil {
  18403. return
  18404. }
  18405. return *v, true
  18406. }
  18407. // ClearStatus clears the value of the "status" field.
  18408. func (m *MsgMutation) ClearStatus() {
  18409. m.status = nil
  18410. m.addstatus = nil
  18411. m.clearedFields[msg.FieldStatus] = struct{}{}
  18412. }
  18413. // StatusCleared returns if the "status" field was cleared in this mutation.
  18414. func (m *MsgMutation) StatusCleared() bool {
  18415. _, ok := m.clearedFields[msg.FieldStatus]
  18416. return ok
  18417. }
  18418. // ResetStatus resets all changes to the "status" field.
  18419. func (m *MsgMutation) ResetStatus() {
  18420. m.status = nil
  18421. m.addstatus = nil
  18422. delete(m.clearedFields, msg.FieldStatus)
  18423. }
  18424. // SetFromwxid sets the "fromwxid" field.
  18425. func (m *MsgMutation) SetFromwxid(s string) {
  18426. m.fromwxid = &s
  18427. }
  18428. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18429. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18430. v := m.fromwxid
  18431. if v == nil {
  18432. return
  18433. }
  18434. return *v, true
  18435. }
  18436. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18437. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18438. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18439. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18440. if !m.op.Is(OpUpdateOne) {
  18441. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18442. }
  18443. if m.id == nil || m.oldValue == nil {
  18444. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18445. }
  18446. oldValue, err := m.oldValue(ctx)
  18447. if err != nil {
  18448. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18449. }
  18450. return oldValue.Fromwxid, nil
  18451. }
  18452. // ClearFromwxid clears the value of the "fromwxid" field.
  18453. func (m *MsgMutation) ClearFromwxid() {
  18454. m.fromwxid = nil
  18455. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18456. }
  18457. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18458. func (m *MsgMutation) FromwxidCleared() bool {
  18459. _, ok := m.clearedFields[msg.FieldFromwxid]
  18460. return ok
  18461. }
  18462. // ResetFromwxid resets all changes to the "fromwxid" field.
  18463. func (m *MsgMutation) ResetFromwxid() {
  18464. m.fromwxid = nil
  18465. delete(m.clearedFields, msg.FieldFromwxid)
  18466. }
  18467. // SetToid sets the "toid" field.
  18468. func (m *MsgMutation) SetToid(s string) {
  18469. m.toid = &s
  18470. }
  18471. // Toid returns the value of the "toid" field in the mutation.
  18472. func (m *MsgMutation) Toid() (r string, exists bool) {
  18473. v := m.toid
  18474. if v == nil {
  18475. return
  18476. }
  18477. return *v, true
  18478. }
  18479. // OldToid returns the old "toid" field's value of the Msg entity.
  18480. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18481. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18482. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18483. if !m.op.Is(OpUpdateOne) {
  18484. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18485. }
  18486. if m.id == nil || m.oldValue == nil {
  18487. return v, errors.New("OldToid requires an ID field in the mutation")
  18488. }
  18489. oldValue, err := m.oldValue(ctx)
  18490. if err != nil {
  18491. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18492. }
  18493. return oldValue.Toid, nil
  18494. }
  18495. // ClearToid clears the value of the "toid" field.
  18496. func (m *MsgMutation) ClearToid() {
  18497. m.toid = nil
  18498. m.clearedFields[msg.FieldToid] = struct{}{}
  18499. }
  18500. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18501. func (m *MsgMutation) ToidCleared() bool {
  18502. _, ok := m.clearedFields[msg.FieldToid]
  18503. return ok
  18504. }
  18505. // ResetToid resets all changes to the "toid" field.
  18506. func (m *MsgMutation) ResetToid() {
  18507. m.toid = nil
  18508. delete(m.clearedFields, msg.FieldToid)
  18509. }
  18510. // SetMsgtype sets the "msgtype" field.
  18511. func (m *MsgMutation) SetMsgtype(i int32) {
  18512. m.msgtype = &i
  18513. m.addmsgtype = nil
  18514. }
  18515. // Msgtype returns the value of the "msgtype" field in the mutation.
  18516. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18517. v := m.msgtype
  18518. if v == nil {
  18519. return
  18520. }
  18521. return *v, true
  18522. }
  18523. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18524. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18525. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18526. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18527. if !m.op.Is(OpUpdateOne) {
  18528. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18529. }
  18530. if m.id == nil || m.oldValue == nil {
  18531. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18532. }
  18533. oldValue, err := m.oldValue(ctx)
  18534. if err != nil {
  18535. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18536. }
  18537. return oldValue.Msgtype, nil
  18538. }
  18539. // AddMsgtype adds i to the "msgtype" field.
  18540. func (m *MsgMutation) AddMsgtype(i int32) {
  18541. if m.addmsgtype != nil {
  18542. *m.addmsgtype += i
  18543. } else {
  18544. m.addmsgtype = &i
  18545. }
  18546. }
  18547. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18548. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18549. v := m.addmsgtype
  18550. if v == nil {
  18551. return
  18552. }
  18553. return *v, true
  18554. }
  18555. // ClearMsgtype clears the value of the "msgtype" field.
  18556. func (m *MsgMutation) ClearMsgtype() {
  18557. m.msgtype = nil
  18558. m.addmsgtype = nil
  18559. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18560. }
  18561. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18562. func (m *MsgMutation) MsgtypeCleared() bool {
  18563. _, ok := m.clearedFields[msg.FieldMsgtype]
  18564. return ok
  18565. }
  18566. // ResetMsgtype resets all changes to the "msgtype" field.
  18567. func (m *MsgMutation) ResetMsgtype() {
  18568. m.msgtype = nil
  18569. m.addmsgtype = nil
  18570. delete(m.clearedFields, msg.FieldMsgtype)
  18571. }
  18572. // SetMsg sets the "msg" field.
  18573. func (m *MsgMutation) SetMsg(s string) {
  18574. m.msg = &s
  18575. }
  18576. // Msg returns the value of the "msg" field in the mutation.
  18577. func (m *MsgMutation) Msg() (r string, exists bool) {
  18578. v := m.msg
  18579. if v == nil {
  18580. return
  18581. }
  18582. return *v, true
  18583. }
  18584. // OldMsg returns the old "msg" field's value of the Msg entity.
  18585. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18586. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18587. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18588. if !m.op.Is(OpUpdateOne) {
  18589. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18590. }
  18591. if m.id == nil || m.oldValue == nil {
  18592. return v, errors.New("OldMsg requires an ID field in the mutation")
  18593. }
  18594. oldValue, err := m.oldValue(ctx)
  18595. if err != nil {
  18596. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18597. }
  18598. return oldValue.Msg, nil
  18599. }
  18600. // ClearMsg clears the value of the "msg" field.
  18601. func (m *MsgMutation) ClearMsg() {
  18602. m.msg = nil
  18603. m.clearedFields[msg.FieldMsg] = struct{}{}
  18604. }
  18605. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18606. func (m *MsgMutation) MsgCleared() bool {
  18607. _, ok := m.clearedFields[msg.FieldMsg]
  18608. return ok
  18609. }
  18610. // ResetMsg resets all changes to the "msg" field.
  18611. func (m *MsgMutation) ResetMsg() {
  18612. m.msg = nil
  18613. delete(m.clearedFields, msg.FieldMsg)
  18614. }
  18615. // SetBatchNo sets the "batch_no" field.
  18616. func (m *MsgMutation) SetBatchNo(s string) {
  18617. m.batch_no = &s
  18618. }
  18619. // BatchNo returns the value of the "batch_no" field in the mutation.
  18620. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18621. v := m.batch_no
  18622. if v == nil {
  18623. return
  18624. }
  18625. return *v, true
  18626. }
  18627. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18628. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18629. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18630. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18631. if !m.op.Is(OpUpdateOne) {
  18632. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18633. }
  18634. if m.id == nil || m.oldValue == nil {
  18635. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18636. }
  18637. oldValue, err := m.oldValue(ctx)
  18638. if err != nil {
  18639. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18640. }
  18641. return oldValue.BatchNo, nil
  18642. }
  18643. // ClearBatchNo clears the value of the "batch_no" field.
  18644. func (m *MsgMutation) ClearBatchNo() {
  18645. m.batch_no = nil
  18646. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18647. }
  18648. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18649. func (m *MsgMutation) BatchNoCleared() bool {
  18650. _, ok := m.clearedFields[msg.FieldBatchNo]
  18651. return ok
  18652. }
  18653. // ResetBatchNo resets all changes to the "batch_no" field.
  18654. func (m *MsgMutation) ResetBatchNo() {
  18655. m.batch_no = nil
  18656. delete(m.clearedFields, msg.FieldBatchNo)
  18657. }
  18658. // Where appends a list predicates to the MsgMutation builder.
  18659. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18660. m.predicates = append(m.predicates, ps...)
  18661. }
  18662. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18663. // users can use type-assertion to append predicates that do not depend on any generated package.
  18664. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18665. p := make([]predicate.Msg, len(ps))
  18666. for i := range ps {
  18667. p[i] = ps[i]
  18668. }
  18669. m.Where(p...)
  18670. }
  18671. // Op returns the operation name.
  18672. func (m *MsgMutation) Op() Op {
  18673. return m.op
  18674. }
  18675. // SetOp allows setting the mutation operation.
  18676. func (m *MsgMutation) SetOp(op Op) {
  18677. m.op = op
  18678. }
  18679. // Type returns the node type of this mutation (Msg).
  18680. func (m *MsgMutation) Type() string {
  18681. return m.typ
  18682. }
  18683. // Fields returns all fields that were changed during this mutation. Note that in
  18684. // order to get all numeric fields that were incremented/decremented, call
  18685. // AddedFields().
  18686. func (m *MsgMutation) Fields() []string {
  18687. fields := make([]string, 0, 9)
  18688. if m.created_at != nil {
  18689. fields = append(fields, msg.FieldCreatedAt)
  18690. }
  18691. if m.updated_at != nil {
  18692. fields = append(fields, msg.FieldUpdatedAt)
  18693. }
  18694. if m.deleted_at != nil {
  18695. fields = append(fields, msg.FieldDeletedAt)
  18696. }
  18697. if m.status != nil {
  18698. fields = append(fields, msg.FieldStatus)
  18699. }
  18700. if m.fromwxid != nil {
  18701. fields = append(fields, msg.FieldFromwxid)
  18702. }
  18703. if m.toid != nil {
  18704. fields = append(fields, msg.FieldToid)
  18705. }
  18706. if m.msgtype != nil {
  18707. fields = append(fields, msg.FieldMsgtype)
  18708. }
  18709. if m.msg != nil {
  18710. fields = append(fields, msg.FieldMsg)
  18711. }
  18712. if m.batch_no != nil {
  18713. fields = append(fields, msg.FieldBatchNo)
  18714. }
  18715. return fields
  18716. }
  18717. // Field returns the value of a field with the given name. The second boolean
  18718. // return value indicates that this field was not set, or was not defined in the
  18719. // schema.
  18720. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18721. switch name {
  18722. case msg.FieldCreatedAt:
  18723. return m.CreatedAt()
  18724. case msg.FieldUpdatedAt:
  18725. return m.UpdatedAt()
  18726. case msg.FieldDeletedAt:
  18727. return m.DeletedAt()
  18728. case msg.FieldStatus:
  18729. return m.Status()
  18730. case msg.FieldFromwxid:
  18731. return m.Fromwxid()
  18732. case msg.FieldToid:
  18733. return m.Toid()
  18734. case msg.FieldMsgtype:
  18735. return m.Msgtype()
  18736. case msg.FieldMsg:
  18737. return m.Msg()
  18738. case msg.FieldBatchNo:
  18739. return m.BatchNo()
  18740. }
  18741. return nil, false
  18742. }
  18743. // OldField returns the old value of the field from the database. An error is
  18744. // returned if the mutation operation is not UpdateOne, or the query to the
  18745. // database failed.
  18746. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18747. switch name {
  18748. case msg.FieldCreatedAt:
  18749. return m.OldCreatedAt(ctx)
  18750. case msg.FieldUpdatedAt:
  18751. return m.OldUpdatedAt(ctx)
  18752. case msg.FieldDeletedAt:
  18753. return m.OldDeletedAt(ctx)
  18754. case msg.FieldStatus:
  18755. return m.OldStatus(ctx)
  18756. case msg.FieldFromwxid:
  18757. return m.OldFromwxid(ctx)
  18758. case msg.FieldToid:
  18759. return m.OldToid(ctx)
  18760. case msg.FieldMsgtype:
  18761. return m.OldMsgtype(ctx)
  18762. case msg.FieldMsg:
  18763. return m.OldMsg(ctx)
  18764. case msg.FieldBatchNo:
  18765. return m.OldBatchNo(ctx)
  18766. }
  18767. return nil, fmt.Errorf("unknown Msg field %s", name)
  18768. }
  18769. // SetField sets the value of a field with the given name. It returns an error if
  18770. // the field is not defined in the schema, or if the type mismatched the field
  18771. // type.
  18772. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18773. switch name {
  18774. case msg.FieldCreatedAt:
  18775. v, ok := value.(time.Time)
  18776. if !ok {
  18777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18778. }
  18779. m.SetCreatedAt(v)
  18780. return nil
  18781. case msg.FieldUpdatedAt:
  18782. v, ok := value.(time.Time)
  18783. if !ok {
  18784. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18785. }
  18786. m.SetUpdatedAt(v)
  18787. return nil
  18788. case msg.FieldDeletedAt:
  18789. v, ok := value.(time.Time)
  18790. if !ok {
  18791. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18792. }
  18793. m.SetDeletedAt(v)
  18794. return nil
  18795. case msg.FieldStatus:
  18796. v, ok := value.(uint8)
  18797. if !ok {
  18798. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18799. }
  18800. m.SetStatus(v)
  18801. return nil
  18802. case msg.FieldFromwxid:
  18803. v, ok := value.(string)
  18804. if !ok {
  18805. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18806. }
  18807. m.SetFromwxid(v)
  18808. return nil
  18809. case msg.FieldToid:
  18810. v, ok := value.(string)
  18811. if !ok {
  18812. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18813. }
  18814. m.SetToid(v)
  18815. return nil
  18816. case msg.FieldMsgtype:
  18817. v, ok := value.(int32)
  18818. if !ok {
  18819. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18820. }
  18821. m.SetMsgtype(v)
  18822. return nil
  18823. case msg.FieldMsg:
  18824. v, ok := value.(string)
  18825. if !ok {
  18826. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18827. }
  18828. m.SetMsg(v)
  18829. return nil
  18830. case msg.FieldBatchNo:
  18831. v, ok := value.(string)
  18832. if !ok {
  18833. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18834. }
  18835. m.SetBatchNo(v)
  18836. return nil
  18837. }
  18838. return fmt.Errorf("unknown Msg field %s", name)
  18839. }
  18840. // AddedFields returns all numeric fields that were incremented/decremented during
  18841. // this mutation.
  18842. func (m *MsgMutation) AddedFields() []string {
  18843. var fields []string
  18844. if m.addstatus != nil {
  18845. fields = append(fields, msg.FieldStatus)
  18846. }
  18847. if m.addmsgtype != nil {
  18848. fields = append(fields, msg.FieldMsgtype)
  18849. }
  18850. return fields
  18851. }
  18852. // AddedField returns the numeric value that was incremented/decremented on a field
  18853. // with the given name. The second boolean return value indicates that this field
  18854. // was not set, or was not defined in the schema.
  18855. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18856. switch name {
  18857. case msg.FieldStatus:
  18858. return m.AddedStatus()
  18859. case msg.FieldMsgtype:
  18860. return m.AddedMsgtype()
  18861. }
  18862. return nil, false
  18863. }
  18864. // AddField adds the value to the field with the given name. It returns an error if
  18865. // the field is not defined in the schema, or if the type mismatched the field
  18866. // type.
  18867. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18868. switch name {
  18869. case msg.FieldStatus:
  18870. v, ok := value.(int8)
  18871. if !ok {
  18872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18873. }
  18874. m.AddStatus(v)
  18875. return nil
  18876. case msg.FieldMsgtype:
  18877. v, ok := value.(int32)
  18878. if !ok {
  18879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18880. }
  18881. m.AddMsgtype(v)
  18882. return nil
  18883. }
  18884. return fmt.Errorf("unknown Msg numeric field %s", name)
  18885. }
  18886. // ClearedFields returns all nullable fields that were cleared during this
  18887. // mutation.
  18888. func (m *MsgMutation) ClearedFields() []string {
  18889. var fields []string
  18890. if m.FieldCleared(msg.FieldDeletedAt) {
  18891. fields = append(fields, msg.FieldDeletedAt)
  18892. }
  18893. if m.FieldCleared(msg.FieldStatus) {
  18894. fields = append(fields, msg.FieldStatus)
  18895. }
  18896. if m.FieldCleared(msg.FieldFromwxid) {
  18897. fields = append(fields, msg.FieldFromwxid)
  18898. }
  18899. if m.FieldCleared(msg.FieldToid) {
  18900. fields = append(fields, msg.FieldToid)
  18901. }
  18902. if m.FieldCleared(msg.FieldMsgtype) {
  18903. fields = append(fields, msg.FieldMsgtype)
  18904. }
  18905. if m.FieldCleared(msg.FieldMsg) {
  18906. fields = append(fields, msg.FieldMsg)
  18907. }
  18908. if m.FieldCleared(msg.FieldBatchNo) {
  18909. fields = append(fields, msg.FieldBatchNo)
  18910. }
  18911. return fields
  18912. }
  18913. // FieldCleared returns a boolean indicating if a field with the given name was
  18914. // cleared in this mutation.
  18915. func (m *MsgMutation) FieldCleared(name string) bool {
  18916. _, ok := m.clearedFields[name]
  18917. return ok
  18918. }
  18919. // ClearField clears the value of the field with the given name. It returns an
  18920. // error if the field is not defined in the schema.
  18921. func (m *MsgMutation) ClearField(name string) error {
  18922. switch name {
  18923. case msg.FieldDeletedAt:
  18924. m.ClearDeletedAt()
  18925. return nil
  18926. case msg.FieldStatus:
  18927. m.ClearStatus()
  18928. return nil
  18929. case msg.FieldFromwxid:
  18930. m.ClearFromwxid()
  18931. return nil
  18932. case msg.FieldToid:
  18933. m.ClearToid()
  18934. return nil
  18935. case msg.FieldMsgtype:
  18936. m.ClearMsgtype()
  18937. return nil
  18938. case msg.FieldMsg:
  18939. m.ClearMsg()
  18940. return nil
  18941. case msg.FieldBatchNo:
  18942. m.ClearBatchNo()
  18943. return nil
  18944. }
  18945. return fmt.Errorf("unknown Msg nullable field %s", name)
  18946. }
  18947. // ResetField resets all changes in the mutation for the field with the given name.
  18948. // It returns an error if the field is not defined in the schema.
  18949. func (m *MsgMutation) ResetField(name string) error {
  18950. switch name {
  18951. case msg.FieldCreatedAt:
  18952. m.ResetCreatedAt()
  18953. return nil
  18954. case msg.FieldUpdatedAt:
  18955. m.ResetUpdatedAt()
  18956. return nil
  18957. case msg.FieldDeletedAt:
  18958. m.ResetDeletedAt()
  18959. return nil
  18960. case msg.FieldStatus:
  18961. m.ResetStatus()
  18962. return nil
  18963. case msg.FieldFromwxid:
  18964. m.ResetFromwxid()
  18965. return nil
  18966. case msg.FieldToid:
  18967. m.ResetToid()
  18968. return nil
  18969. case msg.FieldMsgtype:
  18970. m.ResetMsgtype()
  18971. return nil
  18972. case msg.FieldMsg:
  18973. m.ResetMsg()
  18974. return nil
  18975. case msg.FieldBatchNo:
  18976. m.ResetBatchNo()
  18977. return nil
  18978. }
  18979. return fmt.Errorf("unknown Msg field %s", name)
  18980. }
  18981. // AddedEdges returns all edge names that were set/added in this mutation.
  18982. func (m *MsgMutation) AddedEdges() []string {
  18983. edges := make([]string, 0, 0)
  18984. return edges
  18985. }
  18986. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18987. // name in this mutation.
  18988. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18989. return nil
  18990. }
  18991. // RemovedEdges returns all edge names that were removed in this mutation.
  18992. func (m *MsgMutation) RemovedEdges() []string {
  18993. edges := make([]string, 0, 0)
  18994. return edges
  18995. }
  18996. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18997. // the given name in this mutation.
  18998. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18999. return nil
  19000. }
  19001. // ClearedEdges returns all edge names that were cleared in this mutation.
  19002. func (m *MsgMutation) ClearedEdges() []string {
  19003. edges := make([]string, 0, 0)
  19004. return edges
  19005. }
  19006. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19007. // was cleared in this mutation.
  19008. func (m *MsgMutation) EdgeCleared(name string) bool {
  19009. return false
  19010. }
  19011. // ClearEdge clears the value of the edge with the given name. It returns an error
  19012. // if that edge is not defined in the schema.
  19013. func (m *MsgMutation) ClearEdge(name string) error {
  19014. return fmt.Errorf("unknown Msg unique edge %s", name)
  19015. }
  19016. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19017. // It returns an error if the edge is not defined in the schema.
  19018. func (m *MsgMutation) ResetEdge(name string) error {
  19019. return fmt.Errorf("unknown Msg edge %s", name)
  19020. }
  19021. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  19022. type PayRechargeMutation struct {
  19023. config
  19024. op Op
  19025. typ string
  19026. id *uint64
  19027. created_at *time.Time
  19028. updated_at *time.Time
  19029. deleted_at *time.Time
  19030. user_id *string
  19031. number *float32
  19032. addnumber *float32
  19033. status *int
  19034. addstatus *int
  19035. money *float32
  19036. addmoney *float32
  19037. out_trade_no *string
  19038. organization_id *uint64
  19039. addorganization_id *int64
  19040. clearedFields map[string]struct{}
  19041. done bool
  19042. oldValue func(context.Context) (*PayRecharge, error)
  19043. predicates []predicate.PayRecharge
  19044. }
  19045. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  19046. // payrechargeOption allows management of the mutation configuration using functional options.
  19047. type payrechargeOption func(*PayRechargeMutation)
  19048. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  19049. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  19050. m := &PayRechargeMutation{
  19051. config: c,
  19052. op: op,
  19053. typ: TypePayRecharge,
  19054. clearedFields: make(map[string]struct{}),
  19055. }
  19056. for _, opt := range opts {
  19057. opt(m)
  19058. }
  19059. return m
  19060. }
  19061. // withPayRechargeID sets the ID field of the mutation.
  19062. func withPayRechargeID(id uint64) payrechargeOption {
  19063. return func(m *PayRechargeMutation) {
  19064. var (
  19065. err error
  19066. once sync.Once
  19067. value *PayRecharge
  19068. )
  19069. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  19070. once.Do(func() {
  19071. if m.done {
  19072. err = errors.New("querying old values post mutation is not allowed")
  19073. } else {
  19074. value, err = m.Client().PayRecharge.Get(ctx, id)
  19075. }
  19076. })
  19077. return value, err
  19078. }
  19079. m.id = &id
  19080. }
  19081. }
  19082. // withPayRecharge sets the old PayRecharge of the mutation.
  19083. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19084. return func(m *PayRechargeMutation) {
  19085. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19086. return node, nil
  19087. }
  19088. m.id = &node.ID
  19089. }
  19090. }
  19091. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19092. // executed in a transaction (ent.Tx), a transactional client is returned.
  19093. func (m PayRechargeMutation) Client() *Client {
  19094. client := &Client{config: m.config}
  19095. client.init()
  19096. return client
  19097. }
  19098. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19099. // it returns an error otherwise.
  19100. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19101. if _, ok := m.driver.(*txDriver); !ok {
  19102. return nil, errors.New("ent: mutation is not running in a transaction")
  19103. }
  19104. tx := &Tx{config: m.config}
  19105. tx.init()
  19106. return tx, nil
  19107. }
  19108. // SetID sets the value of the id field. Note that this
  19109. // operation is only accepted on creation of PayRecharge entities.
  19110. func (m *PayRechargeMutation) SetID(id uint64) {
  19111. m.id = &id
  19112. }
  19113. // ID returns the ID value in the mutation. Note that the ID is only available
  19114. // if it was provided to the builder or after it was returned from the database.
  19115. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19116. if m.id == nil {
  19117. return
  19118. }
  19119. return *m.id, true
  19120. }
  19121. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19122. // That means, if the mutation is applied within a transaction with an isolation level such
  19123. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19124. // or updated by the mutation.
  19125. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19126. switch {
  19127. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19128. id, exists := m.ID()
  19129. if exists {
  19130. return []uint64{id}, nil
  19131. }
  19132. fallthrough
  19133. case m.op.Is(OpUpdate | OpDelete):
  19134. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19135. default:
  19136. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19137. }
  19138. }
  19139. // SetCreatedAt sets the "created_at" field.
  19140. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19141. m.created_at = &t
  19142. }
  19143. // CreatedAt returns the value of the "created_at" field in the mutation.
  19144. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19145. v := m.created_at
  19146. if v == nil {
  19147. return
  19148. }
  19149. return *v, true
  19150. }
  19151. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19152. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19153. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19154. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19155. if !m.op.Is(OpUpdateOne) {
  19156. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19157. }
  19158. if m.id == nil || m.oldValue == nil {
  19159. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19160. }
  19161. oldValue, err := m.oldValue(ctx)
  19162. if err != nil {
  19163. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19164. }
  19165. return oldValue.CreatedAt, nil
  19166. }
  19167. // ResetCreatedAt resets all changes to the "created_at" field.
  19168. func (m *PayRechargeMutation) ResetCreatedAt() {
  19169. m.created_at = nil
  19170. }
  19171. // SetUpdatedAt sets the "updated_at" field.
  19172. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19173. m.updated_at = &t
  19174. }
  19175. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19176. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19177. v := m.updated_at
  19178. if v == nil {
  19179. return
  19180. }
  19181. return *v, true
  19182. }
  19183. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19184. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19186. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19187. if !m.op.Is(OpUpdateOne) {
  19188. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19189. }
  19190. if m.id == nil || m.oldValue == nil {
  19191. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19192. }
  19193. oldValue, err := m.oldValue(ctx)
  19194. if err != nil {
  19195. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19196. }
  19197. return oldValue.UpdatedAt, nil
  19198. }
  19199. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19200. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19201. m.updated_at = nil
  19202. }
  19203. // SetDeletedAt sets the "deleted_at" field.
  19204. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19205. m.deleted_at = &t
  19206. }
  19207. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19208. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19209. v := m.deleted_at
  19210. if v == nil {
  19211. return
  19212. }
  19213. return *v, true
  19214. }
  19215. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19216. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19218. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19219. if !m.op.Is(OpUpdateOne) {
  19220. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19221. }
  19222. if m.id == nil || m.oldValue == nil {
  19223. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19224. }
  19225. oldValue, err := m.oldValue(ctx)
  19226. if err != nil {
  19227. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19228. }
  19229. return oldValue.DeletedAt, nil
  19230. }
  19231. // ClearDeletedAt clears the value of the "deleted_at" field.
  19232. func (m *PayRechargeMutation) ClearDeletedAt() {
  19233. m.deleted_at = nil
  19234. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19235. }
  19236. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19237. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19238. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19239. return ok
  19240. }
  19241. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19242. func (m *PayRechargeMutation) ResetDeletedAt() {
  19243. m.deleted_at = nil
  19244. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19245. }
  19246. // SetUserID sets the "user_id" field.
  19247. func (m *PayRechargeMutation) SetUserID(s string) {
  19248. m.user_id = &s
  19249. }
  19250. // UserID returns the value of the "user_id" field in the mutation.
  19251. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19252. v := m.user_id
  19253. if v == nil {
  19254. return
  19255. }
  19256. return *v, true
  19257. }
  19258. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19259. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19260. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19261. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19262. if !m.op.Is(OpUpdateOne) {
  19263. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19264. }
  19265. if m.id == nil || m.oldValue == nil {
  19266. return v, errors.New("OldUserID requires an ID field in the mutation")
  19267. }
  19268. oldValue, err := m.oldValue(ctx)
  19269. if err != nil {
  19270. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19271. }
  19272. return oldValue.UserID, nil
  19273. }
  19274. // ResetUserID resets all changes to the "user_id" field.
  19275. func (m *PayRechargeMutation) ResetUserID() {
  19276. m.user_id = nil
  19277. }
  19278. // SetNumber sets the "number" field.
  19279. func (m *PayRechargeMutation) SetNumber(f float32) {
  19280. m.number = &f
  19281. m.addnumber = nil
  19282. }
  19283. // Number returns the value of the "number" field in the mutation.
  19284. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19285. v := m.number
  19286. if v == nil {
  19287. return
  19288. }
  19289. return *v, true
  19290. }
  19291. // OldNumber returns the old "number" field's value of the PayRecharge entity.
  19292. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19294. func (m *PayRechargeMutation) OldNumber(ctx context.Context) (v float32, err error) {
  19295. if !m.op.Is(OpUpdateOne) {
  19296. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19297. }
  19298. if m.id == nil || m.oldValue == nil {
  19299. return v, errors.New("OldNumber requires an ID field in the mutation")
  19300. }
  19301. oldValue, err := m.oldValue(ctx)
  19302. if err != nil {
  19303. return v, fmt.Errorf("querying old value for OldNumber: %w", err)
  19304. }
  19305. return oldValue.Number, nil
  19306. }
  19307. // AddNumber adds f to the "number" field.
  19308. func (m *PayRechargeMutation) AddNumber(f float32) {
  19309. if m.addnumber != nil {
  19310. *m.addnumber += f
  19311. } else {
  19312. m.addnumber = &f
  19313. }
  19314. }
  19315. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19316. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19317. v := m.addnumber
  19318. if v == nil {
  19319. return
  19320. }
  19321. return *v, true
  19322. }
  19323. // ResetNumber resets all changes to the "number" field.
  19324. func (m *PayRechargeMutation) ResetNumber() {
  19325. m.number = nil
  19326. m.addnumber = nil
  19327. }
  19328. // SetStatus sets the "status" field.
  19329. func (m *PayRechargeMutation) SetStatus(i int) {
  19330. m.status = &i
  19331. m.addstatus = nil
  19332. }
  19333. // Status returns the value of the "status" field in the mutation.
  19334. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19335. v := m.status
  19336. if v == nil {
  19337. return
  19338. }
  19339. return *v, true
  19340. }
  19341. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19342. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19343. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19344. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19345. if !m.op.Is(OpUpdateOne) {
  19346. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19347. }
  19348. if m.id == nil || m.oldValue == nil {
  19349. return v, errors.New("OldStatus requires an ID field in the mutation")
  19350. }
  19351. oldValue, err := m.oldValue(ctx)
  19352. if err != nil {
  19353. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19354. }
  19355. return oldValue.Status, nil
  19356. }
  19357. // AddStatus adds i to the "status" field.
  19358. func (m *PayRechargeMutation) AddStatus(i int) {
  19359. if m.addstatus != nil {
  19360. *m.addstatus += i
  19361. } else {
  19362. m.addstatus = &i
  19363. }
  19364. }
  19365. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19366. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19367. v := m.addstatus
  19368. if v == nil {
  19369. return
  19370. }
  19371. return *v, true
  19372. }
  19373. // ClearStatus clears the value of the "status" field.
  19374. func (m *PayRechargeMutation) ClearStatus() {
  19375. m.status = nil
  19376. m.addstatus = nil
  19377. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19378. }
  19379. // StatusCleared returns if the "status" field was cleared in this mutation.
  19380. func (m *PayRechargeMutation) StatusCleared() bool {
  19381. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19382. return ok
  19383. }
  19384. // ResetStatus resets all changes to the "status" field.
  19385. func (m *PayRechargeMutation) ResetStatus() {
  19386. m.status = nil
  19387. m.addstatus = nil
  19388. delete(m.clearedFields, payrecharge.FieldStatus)
  19389. }
  19390. // SetMoney sets the "money" field.
  19391. func (m *PayRechargeMutation) SetMoney(f float32) {
  19392. m.money = &f
  19393. m.addmoney = nil
  19394. }
  19395. // Money returns the value of the "money" field in the mutation.
  19396. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19397. v := m.money
  19398. if v == nil {
  19399. return
  19400. }
  19401. return *v, true
  19402. }
  19403. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19404. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19406. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19407. if !m.op.Is(OpUpdateOne) {
  19408. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19409. }
  19410. if m.id == nil || m.oldValue == nil {
  19411. return v, errors.New("OldMoney requires an ID field in the mutation")
  19412. }
  19413. oldValue, err := m.oldValue(ctx)
  19414. if err != nil {
  19415. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19416. }
  19417. return oldValue.Money, nil
  19418. }
  19419. // AddMoney adds f to the "money" field.
  19420. func (m *PayRechargeMutation) AddMoney(f float32) {
  19421. if m.addmoney != nil {
  19422. *m.addmoney += f
  19423. } else {
  19424. m.addmoney = &f
  19425. }
  19426. }
  19427. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19428. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19429. v := m.addmoney
  19430. if v == nil {
  19431. return
  19432. }
  19433. return *v, true
  19434. }
  19435. // ClearMoney clears the value of the "money" field.
  19436. func (m *PayRechargeMutation) ClearMoney() {
  19437. m.money = nil
  19438. m.addmoney = nil
  19439. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19440. }
  19441. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19442. func (m *PayRechargeMutation) MoneyCleared() bool {
  19443. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19444. return ok
  19445. }
  19446. // ResetMoney resets all changes to the "money" field.
  19447. func (m *PayRechargeMutation) ResetMoney() {
  19448. m.money = nil
  19449. m.addmoney = nil
  19450. delete(m.clearedFields, payrecharge.FieldMoney)
  19451. }
  19452. // SetOutTradeNo sets the "out_trade_no" field.
  19453. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19454. m.out_trade_no = &s
  19455. }
  19456. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19457. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19458. v := m.out_trade_no
  19459. if v == nil {
  19460. return
  19461. }
  19462. return *v, true
  19463. }
  19464. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19465. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19467. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19468. if !m.op.Is(OpUpdateOne) {
  19469. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19470. }
  19471. if m.id == nil || m.oldValue == nil {
  19472. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19473. }
  19474. oldValue, err := m.oldValue(ctx)
  19475. if err != nil {
  19476. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19477. }
  19478. return oldValue.OutTradeNo, nil
  19479. }
  19480. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19481. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19482. m.out_trade_no = nil
  19483. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19484. }
  19485. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19486. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19487. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19488. return ok
  19489. }
  19490. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19491. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19492. m.out_trade_no = nil
  19493. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19494. }
  19495. // SetOrganizationID sets the "organization_id" field.
  19496. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19497. m.organization_id = &u
  19498. m.addorganization_id = nil
  19499. }
  19500. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19501. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19502. v := m.organization_id
  19503. if v == nil {
  19504. return
  19505. }
  19506. return *v, true
  19507. }
  19508. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19509. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19511. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19512. if !m.op.Is(OpUpdateOne) {
  19513. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19514. }
  19515. if m.id == nil || m.oldValue == nil {
  19516. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19517. }
  19518. oldValue, err := m.oldValue(ctx)
  19519. if err != nil {
  19520. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19521. }
  19522. return oldValue.OrganizationID, nil
  19523. }
  19524. // AddOrganizationID adds u to the "organization_id" field.
  19525. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19526. if m.addorganization_id != nil {
  19527. *m.addorganization_id += u
  19528. } else {
  19529. m.addorganization_id = &u
  19530. }
  19531. }
  19532. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19533. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19534. v := m.addorganization_id
  19535. if v == nil {
  19536. return
  19537. }
  19538. return *v, true
  19539. }
  19540. // ResetOrganizationID resets all changes to the "organization_id" field.
  19541. func (m *PayRechargeMutation) ResetOrganizationID() {
  19542. m.organization_id = nil
  19543. m.addorganization_id = nil
  19544. }
  19545. // Where appends a list predicates to the PayRechargeMutation builder.
  19546. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19547. m.predicates = append(m.predicates, ps...)
  19548. }
  19549. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19550. // users can use type-assertion to append predicates that do not depend on any generated package.
  19551. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19552. p := make([]predicate.PayRecharge, len(ps))
  19553. for i := range ps {
  19554. p[i] = ps[i]
  19555. }
  19556. m.Where(p...)
  19557. }
  19558. // Op returns the operation name.
  19559. func (m *PayRechargeMutation) Op() Op {
  19560. return m.op
  19561. }
  19562. // SetOp allows setting the mutation operation.
  19563. func (m *PayRechargeMutation) SetOp(op Op) {
  19564. m.op = op
  19565. }
  19566. // Type returns the node type of this mutation (PayRecharge).
  19567. func (m *PayRechargeMutation) Type() string {
  19568. return m.typ
  19569. }
  19570. // Fields returns all fields that were changed during this mutation. Note that in
  19571. // order to get all numeric fields that were incremented/decremented, call
  19572. // AddedFields().
  19573. func (m *PayRechargeMutation) Fields() []string {
  19574. fields := make([]string, 0, 9)
  19575. if m.created_at != nil {
  19576. fields = append(fields, payrecharge.FieldCreatedAt)
  19577. }
  19578. if m.updated_at != nil {
  19579. fields = append(fields, payrecharge.FieldUpdatedAt)
  19580. }
  19581. if m.deleted_at != nil {
  19582. fields = append(fields, payrecharge.FieldDeletedAt)
  19583. }
  19584. if m.user_id != nil {
  19585. fields = append(fields, payrecharge.FieldUserID)
  19586. }
  19587. if m.number != nil {
  19588. fields = append(fields, payrecharge.FieldNumber)
  19589. }
  19590. if m.status != nil {
  19591. fields = append(fields, payrecharge.FieldStatus)
  19592. }
  19593. if m.money != nil {
  19594. fields = append(fields, payrecharge.FieldMoney)
  19595. }
  19596. if m.out_trade_no != nil {
  19597. fields = append(fields, payrecharge.FieldOutTradeNo)
  19598. }
  19599. if m.organization_id != nil {
  19600. fields = append(fields, payrecharge.FieldOrganizationID)
  19601. }
  19602. return fields
  19603. }
  19604. // Field returns the value of a field with the given name. The second boolean
  19605. // return value indicates that this field was not set, or was not defined in the
  19606. // schema.
  19607. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19608. switch name {
  19609. case payrecharge.FieldCreatedAt:
  19610. return m.CreatedAt()
  19611. case payrecharge.FieldUpdatedAt:
  19612. return m.UpdatedAt()
  19613. case payrecharge.FieldDeletedAt:
  19614. return m.DeletedAt()
  19615. case payrecharge.FieldUserID:
  19616. return m.UserID()
  19617. case payrecharge.FieldNumber:
  19618. return m.Number()
  19619. case payrecharge.FieldStatus:
  19620. return m.Status()
  19621. case payrecharge.FieldMoney:
  19622. return m.Money()
  19623. case payrecharge.FieldOutTradeNo:
  19624. return m.OutTradeNo()
  19625. case payrecharge.FieldOrganizationID:
  19626. return m.OrganizationID()
  19627. }
  19628. return nil, false
  19629. }
  19630. // OldField returns the old value of the field from the database. An error is
  19631. // returned if the mutation operation is not UpdateOne, or the query to the
  19632. // database failed.
  19633. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19634. switch name {
  19635. case payrecharge.FieldCreatedAt:
  19636. return m.OldCreatedAt(ctx)
  19637. case payrecharge.FieldUpdatedAt:
  19638. return m.OldUpdatedAt(ctx)
  19639. case payrecharge.FieldDeletedAt:
  19640. return m.OldDeletedAt(ctx)
  19641. case payrecharge.FieldUserID:
  19642. return m.OldUserID(ctx)
  19643. case payrecharge.FieldNumber:
  19644. return m.OldNumber(ctx)
  19645. case payrecharge.FieldStatus:
  19646. return m.OldStatus(ctx)
  19647. case payrecharge.FieldMoney:
  19648. return m.OldMoney(ctx)
  19649. case payrecharge.FieldOutTradeNo:
  19650. return m.OldOutTradeNo(ctx)
  19651. case payrecharge.FieldOrganizationID:
  19652. return m.OldOrganizationID(ctx)
  19653. }
  19654. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19655. }
  19656. // SetField sets the value of a field with the given name. It returns an error if
  19657. // the field is not defined in the schema, or if the type mismatched the field
  19658. // type.
  19659. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19660. switch name {
  19661. case payrecharge.FieldCreatedAt:
  19662. v, ok := value.(time.Time)
  19663. if !ok {
  19664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19665. }
  19666. m.SetCreatedAt(v)
  19667. return nil
  19668. case payrecharge.FieldUpdatedAt:
  19669. v, ok := value.(time.Time)
  19670. if !ok {
  19671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19672. }
  19673. m.SetUpdatedAt(v)
  19674. return nil
  19675. case payrecharge.FieldDeletedAt:
  19676. v, ok := value.(time.Time)
  19677. if !ok {
  19678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19679. }
  19680. m.SetDeletedAt(v)
  19681. return nil
  19682. case payrecharge.FieldUserID:
  19683. v, ok := value.(string)
  19684. if !ok {
  19685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19686. }
  19687. m.SetUserID(v)
  19688. return nil
  19689. case payrecharge.FieldNumber:
  19690. v, ok := value.(float32)
  19691. if !ok {
  19692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19693. }
  19694. m.SetNumber(v)
  19695. return nil
  19696. case payrecharge.FieldStatus:
  19697. v, ok := value.(int)
  19698. if !ok {
  19699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19700. }
  19701. m.SetStatus(v)
  19702. return nil
  19703. case payrecharge.FieldMoney:
  19704. v, ok := value.(float32)
  19705. if !ok {
  19706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19707. }
  19708. m.SetMoney(v)
  19709. return nil
  19710. case payrecharge.FieldOutTradeNo:
  19711. v, ok := value.(string)
  19712. if !ok {
  19713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19714. }
  19715. m.SetOutTradeNo(v)
  19716. return nil
  19717. case payrecharge.FieldOrganizationID:
  19718. v, ok := value.(uint64)
  19719. if !ok {
  19720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19721. }
  19722. m.SetOrganizationID(v)
  19723. return nil
  19724. }
  19725. return fmt.Errorf("unknown PayRecharge field %s", name)
  19726. }
  19727. // AddedFields returns all numeric fields that were incremented/decremented during
  19728. // this mutation.
  19729. func (m *PayRechargeMutation) AddedFields() []string {
  19730. var fields []string
  19731. if m.addnumber != nil {
  19732. fields = append(fields, payrecharge.FieldNumber)
  19733. }
  19734. if m.addstatus != nil {
  19735. fields = append(fields, payrecharge.FieldStatus)
  19736. }
  19737. if m.addmoney != nil {
  19738. fields = append(fields, payrecharge.FieldMoney)
  19739. }
  19740. if m.addorganization_id != nil {
  19741. fields = append(fields, payrecharge.FieldOrganizationID)
  19742. }
  19743. return fields
  19744. }
  19745. // AddedField returns the numeric value that was incremented/decremented on a field
  19746. // with the given name. The second boolean return value indicates that this field
  19747. // was not set, or was not defined in the schema.
  19748. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19749. switch name {
  19750. case payrecharge.FieldNumber:
  19751. return m.AddedNumber()
  19752. case payrecharge.FieldStatus:
  19753. return m.AddedStatus()
  19754. case payrecharge.FieldMoney:
  19755. return m.AddedMoney()
  19756. case payrecharge.FieldOrganizationID:
  19757. return m.AddedOrganizationID()
  19758. }
  19759. return nil, false
  19760. }
  19761. // AddField adds the value to the field with the given name. It returns an error if
  19762. // the field is not defined in the schema, or if the type mismatched the field
  19763. // type.
  19764. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19765. switch name {
  19766. case payrecharge.FieldNumber:
  19767. v, ok := value.(float32)
  19768. if !ok {
  19769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19770. }
  19771. m.AddNumber(v)
  19772. return nil
  19773. case payrecharge.FieldStatus:
  19774. v, ok := value.(int)
  19775. if !ok {
  19776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19777. }
  19778. m.AddStatus(v)
  19779. return nil
  19780. case payrecharge.FieldMoney:
  19781. v, ok := value.(float32)
  19782. if !ok {
  19783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19784. }
  19785. m.AddMoney(v)
  19786. return nil
  19787. case payrecharge.FieldOrganizationID:
  19788. v, ok := value.(int64)
  19789. if !ok {
  19790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19791. }
  19792. m.AddOrganizationID(v)
  19793. return nil
  19794. }
  19795. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19796. }
  19797. // ClearedFields returns all nullable fields that were cleared during this
  19798. // mutation.
  19799. func (m *PayRechargeMutation) ClearedFields() []string {
  19800. var fields []string
  19801. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19802. fields = append(fields, payrecharge.FieldDeletedAt)
  19803. }
  19804. if m.FieldCleared(payrecharge.FieldStatus) {
  19805. fields = append(fields, payrecharge.FieldStatus)
  19806. }
  19807. if m.FieldCleared(payrecharge.FieldMoney) {
  19808. fields = append(fields, payrecharge.FieldMoney)
  19809. }
  19810. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19811. fields = append(fields, payrecharge.FieldOutTradeNo)
  19812. }
  19813. return fields
  19814. }
  19815. // FieldCleared returns a boolean indicating if a field with the given name was
  19816. // cleared in this mutation.
  19817. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19818. _, ok := m.clearedFields[name]
  19819. return ok
  19820. }
  19821. // ClearField clears the value of the field with the given name. It returns an
  19822. // error if the field is not defined in the schema.
  19823. func (m *PayRechargeMutation) ClearField(name string) error {
  19824. switch name {
  19825. case payrecharge.FieldDeletedAt:
  19826. m.ClearDeletedAt()
  19827. return nil
  19828. case payrecharge.FieldStatus:
  19829. m.ClearStatus()
  19830. return nil
  19831. case payrecharge.FieldMoney:
  19832. m.ClearMoney()
  19833. return nil
  19834. case payrecharge.FieldOutTradeNo:
  19835. m.ClearOutTradeNo()
  19836. return nil
  19837. }
  19838. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19839. }
  19840. // ResetField resets all changes in the mutation for the field with the given name.
  19841. // It returns an error if the field is not defined in the schema.
  19842. func (m *PayRechargeMutation) ResetField(name string) error {
  19843. switch name {
  19844. case payrecharge.FieldCreatedAt:
  19845. m.ResetCreatedAt()
  19846. return nil
  19847. case payrecharge.FieldUpdatedAt:
  19848. m.ResetUpdatedAt()
  19849. return nil
  19850. case payrecharge.FieldDeletedAt:
  19851. m.ResetDeletedAt()
  19852. return nil
  19853. case payrecharge.FieldUserID:
  19854. m.ResetUserID()
  19855. return nil
  19856. case payrecharge.FieldNumber:
  19857. m.ResetNumber()
  19858. return nil
  19859. case payrecharge.FieldStatus:
  19860. m.ResetStatus()
  19861. return nil
  19862. case payrecharge.FieldMoney:
  19863. m.ResetMoney()
  19864. return nil
  19865. case payrecharge.FieldOutTradeNo:
  19866. m.ResetOutTradeNo()
  19867. return nil
  19868. case payrecharge.FieldOrganizationID:
  19869. m.ResetOrganizationID()
  19870. return nil
  19871. }
  19872. return fmt.Errorf("unknown PayRecharge field %s", name)
  19873. }
  19874. // AddedEdges returns all edge names that were set/added in this mutation.
  19875. func (m *PayRechargeMutation) AddedEdges() []string {
  19876. edges := make([]string, 0, 0)
  19877. return edges
  19878. }
  19879. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19880. // name in this mutation.
  19881. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19882. return nil
  19883. }
  19884. // RemovedEdges returns all edge names that were removed in this mutation.
  19885. func (m *PayRechargeMutation) RemovedEdges() []string {
  19886. edges := make([]string, 0, 0)
  19887. return edges
  19888. }
  19889. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19890. // the given name in this mutation.
  19891. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19892. return nil
  19893. }
  19894. // ClearedEdges returns all edge names that were cleared in this mutation.
  19895. func (m *PayRechargeMutation) ClearedEdges() []string {
  19896. edges := make([]string, 0, 0)
  19897. return edges
  19898. }
  19899. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19900. // was cleared in this mutation.
  19901. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19902. return false
  19903. }
  19904. // ClearEdge clears the value of the edge with the given name. It returns an error
  19905. // if that edge is not defined in the schema.
  19906. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19907. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19908. }
  19909. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19910. // It returns an error if the edge is not defined in the schema.
  19911. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19912. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19913. }
  19914. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19915. type ServerMutation struct {
  19916. config
  19917. op Op
  19918. typ string
  19919. id *uint64
  19920. created_at *time.Time
  19921. updated_at *time.Time
  19922. status *uint8
  19923. addstatus *int8
  19924. deleted_at *time.Time
  19925. name *string
  19926. public_ip *string
  19927. private_ip *string
  19928. admin_port *string
  19929. clearedFields map[string]struct{}
  19930. wxs map[uint64]struct{}
  19931. removedwxs map[uint64]struct{}
  19932. clearedwxs bool
  19933. done bool
  19934. oldValue func(context.Context) (*Server, error)
  19935. predicates []predicate.Server
  19936. }
  19937. var _ ent.Mutation = (*ServerMutation)(nil)
  19938. // serverOption allows management of the mutation configuration using functional options.
  19939. type serverOption func(*ServerMutation)
  19940. // newServerMutation creates new mutation for the Server entity.
  19941. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19942. m := &ServerMutation{
  19943. config: c,
  19944. op: op,
  19945. typ: TypeServer,
  19946. clearedFields: make(map[string]struct{}),
  19947. }
  19948. for _, opt := range opts {
  19949. opt(m)
  19950. }
  19951. return m
  19952. }
  19953. // withServerID sets the ID field of the mutation.
  19954. func withServerID(id uint64) serverOption {
  19955. return func(m *ServerMutation) {
  19956. var (
  19957. err error
  19958. once sync.Once
  19959. value *Server
  19960. )
  19961. m.oldValue = func(ctx context.Context) (*Server, error) {
  19962. once.Do(func() {
  19963. if m.done {
  19964. err = errors.New("querying old values post mutation is not allowed")
  19965. } else {
  19966. value, err = m.Client().Server.Get(ctx, id)
  19967. }
  19968. })
  19969. return value, err
  19970. }
  19971. m.id = &id
  19972. }
  19973. }
  19974. // withServer sets the old Server of the mutation.
  19975. func withServer(node *Server) serverOption {
  19976. return func(m *ServerMutation) {
  19977. m.oldValue = func(context.Context) (*Server, error) {
  19978. return node, nil
  19979. }
  19980. m.id = &node.ID
  19981. }
  19982. }
  19983. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19984. // executed in a transaction (ent.Tx), a transactional client is returned.
  19985. func (m ServerMutation) Client() *Client {
  19986. client := &Client{config: m.config}
  19987. client.init()
  19988. return client
  19989. }
  19990. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19991. // it returns an error otherwise.
  19992. func (m ServerMutation) Tx() (*Tx, error) {
  19993. if _, ok := m.driver.(*txDriver); !ok {
  19994. return nil, errors.New("ent: mutation is not running in a transaction")
  19995. }
  19996. tx := &Tx{config: m.config}
  19997. tx.init()
  19998. return tx, nil
  19999. }
  20000. // SetID sets the value of the id field. Note that this
  20001. // operation is only accepted on creation of Server entities.
  20002. func (m *ServerMutation) SetID(id uint64) {
  20003. m.id = &id
  20004. }
  20005. // ID returns the ID value in the mutation. Note that the ID is only available
  20006. // if it was provided to the builder or after it was returned from the database.
  20007. func (m *ServerMutation) ID() (id uint64, exists bool) {
  20008. if m.id == nil {
  20009. return
  20010. }
  20011. return *m.id, true
  20012. }
  20013. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20014. // That means, if the mutation is applied within a transaction with an isolation level such
  20015. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20016. // or updated by the mutation.
  20017. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  20018. switch {
  20019. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20020. id, exists := m.ID()
  20021. if exists {
  20022. return []uint64{id}, nil
  20023. }
  20024. fallthrough
  20025. case m.op.Is(OpUpdate | OpDelete):
  20026. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  20027. default:
  20028. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20029. }
  20030. }
  20031. // SetCreatedAt sets the "created_at" field.
  20032. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  20033. m.created_at = &t
  20034. }
  20035. // CreatedAt returns the value of the "created_at" field in the mutation.
  20036. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  20037. v := m.created_at
  20038. if v == nil {
  20039. return
  20040. }
  20041. return *v, true
  20042. }
  20043. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  20044. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20045. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20046. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20047. if !m.op.Is(OpUpdateOne) {
  20048. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20049. }
  20050. if m.id == nil || m.oldValue == nil {
  20051. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20052. }
  20053. oldValue, err := m.oldValue(ctx)
  20054. if err != nil {
  20055. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20056. }
  20057. return oldValue.CreatedAt, nil
  20058. }
  20059. // ResetCreatedAt resets all changes to the "created_at" field.
  20060. func (m *ServerMutation) ResetCreatedAt() {
  20061. m.created_at = nil
  20062. }
  20063. // SetUpdatedAt sets the "updated_at" field.
  20064. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  20065. m.updated_at = &t
  20066. }
  20067. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20068. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  20069. v := m.updated_at
  20070. if v == nil {
  20071. return
  20072. }
  20073. return *v, true
  20074. }
  20075. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20076. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20078. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20079. if !m.op.Is(OpUpdateOne) {
  20080. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20081. }
  20082. if m.id == nil || m.oldValue == nil {
  20083. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20084. }
  20085. oldValue, err := m.oldValue(ctx)
  20086. if err != nil {
  20087. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20088. }
  20089. return oldValue.UpdatedAt, nil
  20090. }
  20091. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20092. func (m *ServerMutation) ResetUpdatedAt() {
  20093. m.updated_at = nil
  20094. }
  20095. // SetStatus sets the "status" field.
  20096. func (m *ServerMutation) SetStatus(u uint8) {
  20097. m.status = &u
  20098. m.addstatus = nil
  20099. }
  20100. // Status returns the value of the "status" field in the mutation.
  20101. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20102. v := m.status
  20103. if v == nil {
  20104. return
  20105. }
  20106. return *v, true
  20107. }
  20108. // OldStatus returns the old "status" field's value of the Server entity.
  20109. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20110. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20111. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20112. if !m.op.Is(OpUpdateOne) {
  20113. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20114. }
  20115. if m.id == nil || m.oldValue == nil {
  20116. return v, errors.New("OldStatus requires an ID field in the mutation")
  20117. }
  20118. oldValue, err := m.oldValue(ctx)
  20119. if err != nil {
  20120. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20121. }
  20122. return oldValue.Status, nil
  20123. }
  20124. // AddStatus adds u to the "status" field.
  20125. func (m *ServerMutation) AddStatus(u int8) {
  20126. if m.addstatus != nil {
  20127. *m.addstatus += u
  20128. } else {
  20129. m.addstatus = &u
  20130. }
  20131. }
  20132. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20133. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20134. v := m.addstatus
  20135. if v == nil {
  20136. return
  20137. }
  20138. return *v, true
  20139. }
  20140. // ClearStatus clears the value of the "status" field.
  20141. func (m *ServerMutation) ClearStatus() {
  20142. m.status = nil
  20143. m.addstatus = nil
  20144. m.clearedFields[server.FieldStatus] = struct{}{}
  20145. }
  20146. // StatusCleared returns if the "status" field was cleared in this mutation.
  20147. func (m *ServerMutation) StatusCleared() bool {
  20148. _, ok := m.clearedFields[server.FieldStatus]
  20149. return ok
  20150. }
  20151. // ResetStatus resets all changes to the "status" field.
  20152. func (m *ServerMutation) ResetStatus() {
  20153. m.status = nil
  20154. m.addstatus = nil
  20155. delete(m.clearedFields, server.FieldStatus)
  20156. }
  20157. // SetDeletedAt sets the "deleted_at" field.
  20158. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20159. m.deleted_at = &t
  20160. }
  20161. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20162. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20163. v := m.deleted_at
  20164. if v == nil {
  20165. return
  20166. }
  20167. return *v, true
  20168. }
  20169. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20170. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20172. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20173. if !m.op.Is(OpUpdateOne) {
  20174. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20175. }
  20176. if m.id == nil || m.oldValue == nil {
  20177. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20178. }
  20179. oldValue, err := m.oldValue(ctx)
  20180. if err != nil {
  20181. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20182. }
  20183. return oldValue.DeletedAt, nil
  20184. }
  20185. // ClearDeletedAt clears the value of the "deleted_at" field.
  20186. func (m *ServerMutation) ClearDeletedAt() {
  20187. m.deleted_at = nil
  20188. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20189. }
  20190. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20191. func (m *ServerMutation) DeletedAtCleared() bool {
  20192. _, ok := m.clearedFields[server.FieldDeletedAt]
  20193. return ok
  20194. }
  20195. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20196. func (m *ServerMutation) ResetDeletedAt() {
  20197. m.deleted_at = nil
  20198. delete(m.clearedFields, server.FieldDeletedAt)
  20199. }
  20200. // SetName sets the "name" field.
  20201. func (m *ServerMutation) SetName(s string) {
  20202. m.name = &s
  20203. }
  20204. // Name returns the value of the "name" field in the mutation.
  20205. func (m *ServerMutation) Name() (r string, exists bool) {
  20206. v := m.name
  20207. if v == nil {
  20208. return
  20209. }
  20210. return *v, true
  20211. }
  20212. // OldName returns the old "name" field's value of the Server entity.
  20213. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20214. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20215. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20216. if !m.op.Is(OpUpdateOne) {
  20217. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20218. }
  20219. if m.id == nil || m.oldValue == nil {
  20220. return v, errors.New("OldName requires an ID field in the mutation")
  20221. }
  20222. oldValue, err := m.oldValue(ctx)
  20223. if err != nil {
  20224. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20225. }
  20226. return oldValue.Name, nil
  20227. }
  20228. // ResetName resets all changes to the "name" field.
  20229. func (m *ServerMutation) ResetName() {
  20230. m.name = nil
  20231. }
  20232. // SetPublicIP sets the "public_ip" field.
  20233. func (m *ServerMutation) SetPublicIP(s string) {
  20234. m.public_ip = &s
  20235. }
  20236. // PublicIP returns the value of the "public_ip" field in the mutation.
  20237. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20238. v := m.public_ip
  20239. if v == nil {
  20240. return
  20241. }
  20242. return *v, true
  20243. }
  20244. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20245. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20246. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20247. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20248. if !m.op.Is(OpUpdateOne) {
  20249. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20250. }
  20251. if m.id == nil || m.oldValue == nil {
  20252. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20253. }
  20254. oldValue, err := m.oldValue(ctx)
  20255. if err != nil {
  20256. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20257. }
  20258. return oldValue.PublicIP, nil
  20259. }
  20260. // ResetPublicIP resets all changes to the "public_ip" field.
  20261. func (m *ServerMutation) ResetPublicIP() {
  20262. m.public_ip = nil
  20263. }
  20264. // SetPrivateIP sets the "private_ip" field.
  20265. func (m *ServerMutation) SetPrivateIP(s string) {
  20266. m.private_ip = &s
  20267. }
  20268. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20269. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20270. v := m.private_ip
  20271. if v == nil {
  20272. return
  20273. }
  20274. return *v, true
  20275. }
  20276. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20277. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20279. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20280. if !m.op.Is(OpUpdateOne) {
  20281. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20282. }
  20283. if m.id == nil || m.oldValue == nil {
  20284. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20285. }
  20286. oldValue, err := m.oldValue(ctx)
  20287. if err != nil {
  20288. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20289. }
  20290. return oldValue.PrivateIP, nil
  20291. }
  20292. // ResetPrivateIP resets all changes to the "private_ip" field.
  20293. func (m *ServerMutation) ResetPrivateIP() {
  20294. m.private_ip = nil
  20295. }
  20296. // SetAdminPort sets the "admin_port" field.
  20297. func (m *ServerMutation) SetAdminPort(s string) {
  20298. m.admin_port = &s
  20299. }
  20300. // AdminPort returns the value of the "admin_port" field in the mutation.
  20301. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20302. v := m.admin_port
  20303. if v == nil {
  20304. return
  20305. }
  20306. return *v, true
  20307. }
  20308. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20309. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20310. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20311. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20312. if !m.op.Is(OpUpdateOne) {
  20313. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20314. }
  20315. if m.id == nil || m.oldValue == nil {
  20316. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20317. }
  20318. oldValue, err := m.oldValue(ctx)
  20319. if err != nil {
  20320. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20321. }
  20322. return oldValue.AdminPort, nil
  20323. }
  20324. // ResetAdminPort resets all changes to the "admin_port" field.
  20325. func (m *ServerMutation) ResetAdminPort() {
  20326. m.admin_port = nil
  20327. }
  20328. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20329. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20330. if m.wxs == nil {
  20331. m.wxs = make(map[uint64]struct{})
  20332. }
  20333. for i := range ids {
  20334. m.wxs[ids[i]] = struct{}{}
  20335. }
  20336. }
  20337. // ClearWxs clears the "wxs" edge to the Wx entity.
  20338. func (m *ServerMutation) ClearWxs() {
  20339. m.clearedwxs = true
  20340. }
  20341. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20342. func (m *ServerMutation) WxsCleared() bool {
  20343. return m.clearedwxs
  20344. }
  20345. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20346. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20347. if m.removedwxs == nil {
  20348. m.removedwxs = make(map[uint64]struct{})
  20349. }
  20350. for i := range ids {
  20351. delete(m.wxs, ids[i])
  20352. m.removedwxs[ids[i]] = struct{}{}
  20353. }
  20354. }
  20355. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20356. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20357. for id := range m.removedwxs {
  20358. ids = append(ids, id)
  20359. }
  20360. return
  20361. }
  20362. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20363. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20364. for id := range m.wxs {
  20365. ids = append(ids, id)
  20366. }
  20367. return
  20368. }
  20369. // ResetWxs resets all changes to the "wxs" edge.
  20370. func (m *ServerMutation) ResetWxs() {
  20371. m.wxs = nil
  20372. m.clearedwxs = false
  20373. m.removedwxs = nil
  20374. }
  20375. // Where appends a list predicates to the ServerMutation builder.
  20376. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20377. m.predicates = append(m.predicates, ps...)
  20378. }
  20379. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20380. // users can use type-assertion to append predicates that do not depend on any generated package.
  20381. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20382. p := make([]predicate.Server, len(ps))
  20383. for i := range ps {
  20384. p[i] = ps[i]
  20385. }
  20386. m.Where(p...)
  20387. }
  20388. // Op returns the operation name.
  20389. func (m *ServerMutation) Op() Op {
  20390. return m.op
  20391. }
  20392. // SetOp allows setting the mutation operation.
  20393. func (m *ServerMutation) SetOp(op Op) {
  20394. m.op = op
  20395. }
  20396. // Type returns the node type of this mutation (Server).
  20397. func (m *ServerMutation) Type() string {
  20398. return m.typ
  20399. }
  20400. // Fields returns all fields that were changed during this mutation. Note that in
  20401. // order to get all numeric fields that were incremented/decremented, call
  20402. // AddedFields().
  20403. func (m *ServerMutation) Fields() []string {
  20404. fields := make([]string, 0, 8)
  20405. if m.created_at != nil {
  20406. fields = append(fields, server.FieldCreatedAt)
  20407. }
  20408. if m.updated_at != nil {
  20409. fields = append(fields, server.FieldUpdatedAt)
  20410. }
  20411. if m.status != nil {
  20412. fields = append(fields, server.FieldStatus)
  20413. }
  20414. if m.deleted_at != nil {
  20415. fields = append(fields, server.FieldDeletedAt)
  20416. }
  20417. if m.name != nil {
  20418. fields = append(fields, server.FieldName)
  20419. }
  20420. if m.public_ip != nil {
  20421. fields = append(fields, server.FieldPublicIP)
  20422. }
  20423. if m.private_ip != nil {
  20424. fields = append(fields, server.FieldPrivateIP)
  20425. }
  20426. if m.admin_port != nil {
  20427. fields = append(fields, server.FieldAdminPort)
  20428. }
  20429. return fields
  20430. }
  20431. // Field returns the value of a field with the given name. The second boolean
  20432. // return value indicates that this field was not set, or was not defined in the
  20433. // schema.
  20434. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20435. switch name {
  20436. case server.FieldCreatedAt:
  20437. return m.CreatedAt()
  20438. case server.FieldUpdatedAt:
  20439. return m.UpdatedAt()
  20440. case server.FieldStatus:
  20441. return m.Status()
  20442. case server.FieldDeletedAt:
  20443. return m.DeletedAt()
  20444. case server.FieldName:
  20445. return m.Name()
  20446. case server.FieldPublicIP:
  20447. return m.PublicIP()
  20448. case server.FieldPrivateIP:
  20449. return m.PrivateIP()
  20450. case server.FieldAdminPort:
  20451. return m.AdminPort()
  20452. }
  20453. return nil, false
  20454. }
  20455. // OldField returns the old value of the field from the database. An error is
  20456. // returned if the mutation operation is not UpdateOne, or the query to the
  20457. // database failed.
  20458. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20459. switch name {
  20460. case server.FieldCreatedAt:
  20461. return m.OldCreatedAt(ctx)
  20462. case server.FieldUpdatedAt:
  20463. return m.OldUpdatedAt(ctx)
  20464. case server.FieldStatus:
  20465. return m.OldStatus(ctx)
  20466. case server.FieldDeletedAt:
  20467. return m.OldDeletedAt(ctx)
  20468. case server.FieldName:
  20469. return m.OldName(ctx)
  20470. case server.FieldPublicIP:
  20471. return m.OldPublicIP(ctx)
  20472. case server.FieldPrivateIP:
  20473. return m.OldPrivateIP(ctx)
  20474. case server.FieldAdminPort:
  20475. return m.OldAdminPort(ctx)
  20476. }
  20477. return nil, fmt.Errorf("unknown Server field %s", name)
  20478. }
  20479. // SetField sets the value of a field with the given name. It returns an error if
  20480. // the field is not defined in the schema, or if the type mismatched the field
  20481. // type.
  20482. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20483. switch name {
  20484. case server.FieldCreatedAt:
  20485. v, ok := value.(time.Time)
  20486. if !ok {
  20487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20488. }
  20489. m.SetCreatedAt(v)
  20490. return nil
  20491. case server.FieldUpdatedAt:
  20492. v, ok := value.(time.Time)
  20493. if !ok {
  20494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20495. }
  20496. m.SetUpdatedAt(v)
  20497. return nil
  20498. case server.FieldStatus:
  20499. v, ok := value.(uint8)
  20500. if !ok {
  20501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20502. }
  20503. m.SetStatus(v)
  20504. return nil
  20505. case server.FieldDeletedAt:
  20506. v, ok := value.(time.Time)
  20507. if !ok {
  20508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20509. }
  20510. m.SetDeletedAt(v)
  20511. return nil
  20512. case server.FieldName:
  20513. v, ok := value.(string)
  20514. if !ok {
  20515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20516. }
  20517. m.SetName(v)
  20518. return nil
  20519. case server.FieldPublicIP:
  20520. v, ok := value.(string)
  20521. if !ok {
  20522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20523. }
  20524. m.SetPublicIP(v)
  20525. return nil
  20526. case server.FieldPrivateIP:
  20527. v, ok := value.(string)
  20528. if !ok {
  20529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20530. }
  20531. m.SetPrivateIP(v)
  20532. return nil
  20533. case server.FieldAdminPort:
  20534. v, ok := value.(string)
  20535. if !ok {
  20536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20537. }
  20538. m.SetAdminPort(v)
  20539. return nil
  20540. }
  20541. return fmt.Errorf("unknown Server field %s", name)
  20542. }
  20543. // AddedFields returns all numeric fields that were incremented/decremented during
  20544. // this mutation.
  20545. func (m *ServerMutation) AddedFields() []string {
  20546. var fields []string
  20547. if m.addstatus != nil {
  20548. fields = append(fields, server.FieldStatus)
  20549. }
  20550. return fields
  20551. }
  20552. // AddedField returns the numeric value that was incremented/decremented on a field
  20553. // with the given name. The second boolean return value indicates that this field
  20554. // was not set, or was not defined in the schema.
  20555. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20556. switch name {
  20557. case server.FieldStatus:
  20558. return m.AddedStatus()
  20559. }
  20560. return nil, false
  20561. }
  20562. // AddField adds the value to the field with the given name. It returns an error if
  20563. // the field is not defined in the schema, or if the type mismatched the field
  20564. // type.
  20565. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20566. switch name {
  20567. case server.FieldStatus:
  20568. v, ok := value.(int8)
  20569. if !ok {
  20570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20571. }
  20572. m.AddStatus(v)
  20573. return nil
  20574. }
  20575. return fmt.Errorf("unknown Server numeric field %s", name)
  20576. }
  20577. // ClearedFields returns all nullable fields that were cleared during this
  20578. // mutation.
  20579. func (m *ServerMutation) ClearedFields() []string {
  20580. var fields []string
  20581. if m.FieldCleared(server.FieldStatus) {
  20582. fields = append(fields, server.FieldStatus)
  20583. }
  20584. if m.FieldCleared(server.FieldDeletedAt) {
  20585. fields = append(fields, server.FieldDeletedAt)
  20586. }
  20587. return fields
  20588. }
  20589. // FieldCleared returns a boolean indicating if a field with the given name was
  20590. // cleared in this mutation.
  20591. func (m *ServerMutation) FieldCleared(name string) bool {
  20592. _, ok := m.clearedFields[name]
  20593. return ok
  20594. }
  20595. // ClearField clears the value of the field with the given name. It returns an
  20596. // error if the field is not defined in the schema.
  20597. func (m *ServerMutation) ClearField(name string) error {
  20598. switch name {
  20599. case server.FieldStatus:
  20600. m.ClearStatus()
  20601. return nil
  20602. case server.FieldDeletedAt:
  20603. m.ClearDeletedAt()
  20604. return nil
  20605. }
  20606. return fmt.Errorf("unknown Server nullable field %s", name)
  20607. }
  20608. // ResetField resets all changes in the mutation for the field with the given name.
  20609. // It returns an error if the field is not defined in the schema.
  20610. func (m *ServerMutation) ResetField(name string) error {
  20611. switch name {
  20612. case server.FieldCreatedAt:
  20613. m.ResetCreatedAt()
  20614. return nil
  20615. case server.FieldUpdatedAt:
  20616. m.ResetUpdatedAt()
  20617. return nil
  20618. case server.FieldStatus:
  20619. m.ResetStatus()
  20620. return nil
  20621. case server.FieldDeletedAt:
  20622. m.ResetDeletedAt()
  20623. return nil
  20624. case server.FieldName:
  20625. m.ResetName()
  20626. return nil
  20627. case server.FieldPublicIP:
  20628. m.ResetPublicIP()
  20629. return nil
  20630. case server.FieldPrivateIP:
  20631. m.ResetPrivateIP()
  20632. return nil
  20633. case server.FieldAdminPort:
  20634. m.ResetAdminPort()
  20635. return nil
  20636. }
  20637. return fmt.Errorf("unknown Server field %s", name)
  20638. }
  20639. // AddedEdges returns all edge names that were set/added in this mutation.
  20640. func (m *ServerMutation) AddedEdges() []string {
  20641. edges := make([]string, 0, 1)
  20642. if m.wxs != nil {
  20643. edges = append(edges, server.EdgeWxs)
  20644. }
  20645. return edges
  20646. }
  20647. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20648. // name in this mutation.
  20649. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20650. switch name {
  20651. case server.EdgeWxs:
  20652. ids := make([]ent.Value, 0, len(m.wxs))
  20653. for id := range m.wxs {
  20654. ids = append(ids, id)
  20655. }
  20656. return ids
  20657. }
  20658. return nil
  20659. }
  20660. // RemovedEdges returns all edge names that were removed in this mutation.
  20661. func (m *ServerMutation) RemovedEdges() []string {
  20662. edges := make([]string, 0, 1)
  20663. if m.removedwxs != nil {
  20664. edges = append(edges, server.EdgeWxs)
  20665. }
  20666. return edges
  20667. }
  20668. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20669. // the given name in this mutation.
  20670. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20671. switch name {
  20672. case server.EdgeWxs:
  20673. ids := make([]ent.Value, 0, len(m.removedwxs))
  20674. for id := range m.removedwxs {
  20675. ids = append(ids, id)
  20676. }
  20677. return ids
  20678. }
  20679. return nil
  20680. }
  20681. // ClearedEdges returns all edge names that were cleared in this mutation.
  20682. func (m *ServerMutation) ClearedEdges() []string {
  20683. edges := make([]string, 0, 1)
  20684. if m.clearedwxs {
  20685. edges = append(edges, server.EdgeWxs)
  20686. }
  20687. return edges
  20688. }
  20689. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20690. // was cleared in this mutation.
  20691. func (m *ServerMutation) EdgeCleared(name string) bool {
  20692. switch name {
  20693. case server.EdgeWxs:
  20694. return m.clearedwxs
  20695. }
  20696. return false
  20697. }
  20698. // ClearEdge clears the value of the edge with the given name. It returns an error
  20699. // if that edge is not defined in the schema.
  20700. func (m *ServerMutation) ClearEdge(name string) error {
  20701. switch name {
  20702. }
  20703. return fmt.Errorf("unknown Server unique edge %s", name)
  20704. }
  20705. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20706. // It returns an error if the edge is not defined in the schema.
  20707. func (m *ServerMutation) ResetEdge(name string) error {
  20708. switch name {
  20709. case server.EdgeWxs:
  20710. m.ResetWxs()
  20711. return nil
  20712. }
  20713. return fmt.Errorf("unknown Server edge %s", name)
  20714. }
  20715. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20716. type SopNodeMutation struct {
  20717. config
  20718. op Op
  20719. typ string
  20720. id *uint64
  20721. created_at *time.Time
  20722. updated_at *time.Time
  20723. status *uint8
  20724. addstatus *int8
  20725. deleted_at *time.Time
  20726. parent_id *uint64
  20727. addparent_id *int64
  20728. name *string
  20729. condition_type *int
  20730. addcondition_type *int
  20731. condition_list *[]string
  20732. appendcondition_list []string
  20733. no_reply_condition *uint64
  20734. addno_reply_condition *int64
  20735. no_reply_unit *string
  20736. action_message *[]custom_types.Action
  20737. appendaction_message []custom_types.Action
  20738. action_label_add *[]uint64
  20739. appendaction_label_add []uint64
  20740. action_label_del *[]uint64
  20741. appendaction_label_del []uint64
  20742. action_forward **custom_types.ActionForward
  20743. clearedFields map[string]struct{}
  20744. sop_stage *uint64
  20745. clearedsop_stage bool
  20746. node_messages map[uint64]struct{}
  20747. removednode_messages map[uint64]struct{}
  20748. clearednode_messages bool
  20749. done bool
  20750. oldValue func(context.Context) (*SopNode, error)
  20751. predicates []predicate.SopNode
  20752. }
  20753. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20754. // sopnodeOption allows management of the mutation configuration using functional options.
  20755. type sopnodeOption func(*SopNodeMutation)
  20756. // newSopNodeMutation creates new mutation for the SopNode entity.
  20757. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20758. m := &SopNodeMutation{
  20759. config: c,
  20760. op: op,
  20761. typ: TypeSopNode,
  20762. clearedFields: make(map[string]struct{}),
  20763. }
  20764. for _, opt := range opts {
  20765. opt(m)
  20766. }
  20767. return m
  20768. }
  20769. // withSopNodeID sets the ID field of the mutation.
  20770. func withSopNodeID(id uint64) sopnodeOption {
  20771. return func(m *SopNodeMutation) {
  20772. var (
  20773. err error
  20774. once sync.Once
  20775. value *SopNode
  20776. )
  20777. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20778. once.Do(func() {
  20779. if m.done {
  20780. err = errors.New("querying old values post mutation is not allowed")
  20781. } else {
  20782. value, err = m.Client().SopNode.Get(ctx, id)
  20783. }
  20784. })
  20785. return value, err
  20786. }
  20787. m.id = &id
  20788. }
  20789. }
  20790. // withSopNode sets the old SopNode of the mutation.
  20791. func withSopNode(node *SopNode) sopnodeOption {
  20792. return func(m *SopNodeMutation) {
  20793. m.oldValue = func(context.Context) (*SopNode, error) {
  20794. return node, nil
  20795. }
  20796. m.id = &node.ID
  20797. }
  20798. }
  20799. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20800. // executed in a transaction (ent.Tx), a transactional client is returned.
  20801. func (m SopNodeMutation) Client() *Client {
  20802. client := &Client{config: m.config}
  20803. client.init()
  20804. return client
  20805. }
  20806. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20807. // it returns an error otherwise.
  20808. func (m SopNodeMutation) Tx() (*Tx, error) {
  20809. if _, ok := m.driver.(*txDriver); !ok {
  20810. return nil, errors.New("ent: mutation is not running in a transaction")
  20811. }
  20812. tx := &Tx{config: m.config}
  20813. tx.init()
  20814. return tx, nil
  20815. }
  20816. // SetID sets the value of the id field. Note that this
  20817. // operation is only accepted on creation of SopNode entities.
  20818. func (m *SopNodeMutation) SetID(id uint64) {
  20819. m.id = &id
  20820. }
  20821. // ID returns the ID value in the mutation. Note that the ID is only available
  20822. // if it was provided to the builder or after it was returned from the database.
  20823. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20824. if m.id == nil {
  20825. return
  20826. }
  20827. return *m.id, true
  20828. }
  20829. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20830. // That means, if the mutation is applied within a transaction with an isolation level such
  20831. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20832. // or updated by the mutation.
  20833. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20834. switch {
  20835. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20836. id, exists := m.ID()
  20837. if exists {
  20838. return []uint64{id}, nil
  20839. }
  20840. fallthrough
  20841. case m.op.Is(OpUpdate | OpDelete):
  20842. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20843. default:
  20844. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20845. }
  20846. }
  20847. // SetCreatedAt sets the "created_at" field.
  20848. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20849. m.created_at = &t
  20850. }
  20851. // CreatedAt returns the value of the "created_at" field in the mutation.
  20852. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20853. v := m.created_at
  20854. if v == nil {
  20855. return
  20856. }
  20857. return *v, true
  20858. }
  20859. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20860. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20861. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20862. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20863. if !m.op.Is(OpUpdateOne) {
  20864. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20865. }
  20866. if m.id == nil || m.oldValue == nil {
  20867. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20868. }
  20869. oldValue, err := m.oldValue(ctx)
  20870. if err != nil {
  20871. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20872. }
  20873. return oldValue.CreatedAt, nil
  20874. }
  20875. // ResetCreatedAt resets all changes to the "created_at" field.
  20876. func (m *SopNodeMutation) ResetCreatedAt() {
  20877. m.created_at = nil
  20878. }
  20879. // SetUpdatedAt sets the "updated_at" field.
  20880. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20881. m.updated_at = &t
  20882. }
  20883. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20884. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20885. v := m.updated_at
  20886. if v == nil {
  20887. return
  20888. }
  20889. return *v, true
  20890. }
  20891. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20892. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20893. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20894. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20895. if !m.op.Is(OpUpdateOne) {
  20896. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20897. }
  20898. if m.id == nil || m.oldValue == nil {
  20899. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20900. }
  20901. oldValue, err := m.oldValue(ctx)
  20902. if err != nil {
  20903. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20904. }
  20905. return oldValue.UpdatedAt, nil
  20906. }
  20907. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20908. func (m *SopNodeMutation) ResetUpdatedAt() {
  20909. m.updated_at = nil
  20910. }
  20911. // SetStatus sets the "status" field.
  20912. func (m *SopNodeMutation) SetStatus(u uint8) {
  20913. m.status = &u
  20914. m.addstatus = nil
  20915. }
  20916. // Status returns the value of the "status" field in the mutation.
  20917. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20918. v := m.status
  20919. if v == nil {
  20920. return
  20921. }
  20922. return *v, true
  20923. }
  20924. // OldStatus returns the old "status" field's value of the SopNode entity.
  20925. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20926. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20927. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20928. if !m.op.Is(OpUpdateOne) {
  20929. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20930. }
  20931. if m.id == nil || m.oldValue == nil {
  20932. return v, errors.New("OldStatus requires an ID field in the mutation")
  20933. }
  20934. oldValue, err := m.oldValue(ctx)
  20935. if err != nil {
  20936. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20937. }
  20938. return oldValue.Status, nil
  20939. }
  20940. // AddStatus adds u to the "status" field.
  20941. func (m *SopNodeMutation) AddStatus(u int8) {
  20942. if m.addstatus != nil {
  20943. *m.addstatus += u
  20944. } else {
  20945. m.addstatus = &u
  20946. }
  20947. }
  20948. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20949. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20950. v := m.addstatus
  20951. if v == nil {
  20952. return
  20953. }
  20954. return *v, true
  20955. }
  20956. // ClearStatus clears the value of the "status" field.
  20957. func (m *SopNodeMutation) ClearStatus() {
  20958. m.status = nil
  20959. m.addstatus = nil
  20960. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20961. }
  20962. // StatusCleared returns if the "status" field was cleared in this mutation.
  20963. func (m *SopNodeMutation) StatusCleared() bool {
  20964. _, ok := m.clearedFields[sopnode.FieldStatus]
  20965. return ok
  20966. }
  20967. // ResetStatus resets all changes to the "status" field.
  20968. func (m *SopNodeMutation) ResetStatus() {
  20969. m.status = nil
  20970. m.addstatus = nil
  20971. delete(m.clearedFields, sopnode.FieldStatus)
  20972. }
  20973. // SetDeletedAt sets the "deleted_at" field.
  20974. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20975. m.deleted_at = &t
  20976. }
  20977. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20978. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20979. v := m.deleted_at
  20980. if v == nil {
  20981. return
  20982. }
  20983. return *v, true
  20984. }
  20985. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20986. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20987. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20988. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20989. if !m.op.Is(OpUpdateOne) {
  20990. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20991. }
  20992. if m.id == nil || m.oldValue == nil {
  20993. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20994. }
  20995. oldValue, err := m.oldValue(ctx)
  20996. if err != nil {
  20997. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20998. }
  20999. return oldValue.DeletedAt, nil
  21000. }
  21001. // ClearDeletedAt clears the value of the "deleted_at" field.
  21002. func (m *SopNodeMutation) ClearDeletedAt() {
  21003. m.deleted_at = nil
  21004. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  21005. }
  21006. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  21007. func (m *SopNodeMutation) DeletedAtCleared() bool {
  21008. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  21009. return ok
  21010. }
  21011. // ResetDeletedAt resets all changes to the "deleted_at" field.
  21012. func (m *SopNodeMutation) ResetDeletedAt() {
  21013. m.deleted_at = nil
  21014. delete(m.clearedFields, sopnode.FieldDeletedAt)
  21015. }
  21016. // SetStageID sets the "stage_id" field.
  21017. func (m *SopNodeMutation) SetStageID(u uint64) {
  21018. m.sop_stage = &u
  21019. }
  21020. // StageID returns the value of the "stage_id" field in the mutation.
  21021. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  21022. v := m.sop_stage
  21023. if v == nil {
  21024. return
  21025. }
  21026. return *v, true
  21027. }
  21028. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  21029. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21030. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21031. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  21032. if !m.op.Is(OpUpdateOne) {
  21033. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  21034. }
  21035. if m.id == nil || m.oldValue == nil {
  21036. return v, errors.New("OldStageID requires an ID field in the mutation")
  21037. }
  21038. oldValue, err := m.oldValue(ctx)
  21039. if err != nil {
  21040. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  21041. }
  21042. return oldValue.StageID, nil
  21043. }
  21044. // ResetStageID resets all changes to the "stage_id" field.
  21045. func (m *SopNodeMutation) ResetStageID() {
  21046. m.sop_stage = nil
  21047. }
  21048. // SetParentID sets the "parent_id" field.
  21049. func (m *SopNodeMutation) SetParentID(u uint64) {
  21050. m.parent_id = &u
  21051. m.addparent_id = nil
  21052. }
  21053. // ParentID returns the value of the "parent_id" field in the mutation.
  21054. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  21055. v := m.parent_id
  21056. if v == nil {
  21057. return
  21058. }
  21059. return *v, true
  21060. }
  21061. // OldParentID returns the old "parent_id" field's value of the SopNode entity.
  21062. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21063. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21064. func (m *SopNodeMutation) OldParentID(ctx context.Context) (v uint64, err error) {
  21065. if !m.op.Is(OpUpdateOne) {
  21066. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  21067. }
  21068. if m.id == nil || m.oldValue == nil {
  21069. return v, errors.New("OldParentID requires an ID field in the mutation")
  21070. }
  21071. oldValue, err := m.oldValue(ctx)
  21072. if err != nil {
  21073. return v, fmt.Errorf("querying old value for OldParentID: %w", err)
  21074. }
  21075. return oldValue.ParentID, nil
  21076. }
  21077. // AddParentID adds u to the "parent_id" field.
  21078. func (m *SopNodeMutation) AddParentID(u int64) {
  21079. if m.addparent_id != nil {
  21080. *m.addparent_id += u
  21081. } else {
  21082. m.addparent_id = &u
  21083. }
  21084. }
  21085. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21086. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21087. v := m.addparent_id
  21088. if v == nil {
  21089. return
  21090. }
  21091. return *v, true
  21092. }
  21093. // ResetParentID resets all changes to the "parent_id" field.
  21094. func (m *SopNodeMutation) ResetParentID() {
  21095. m.parent_id = nil
  21096. m.addparent_id = nil
  21097. }
  21098. // SetName sets the "name" field.
  21099. func (m *SopNodeMutation) SetName(s string) {
  21100. m.name = &s
  21101. }
  21102. // Name returns the value of the "name" field in the mutation.
  21103. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21104. v := m.name
  21105. if v == nil {
  21106. return
  21107. }
  21108. return *v, true
  21109. }
  21110. // OldName returns the old "name" field's value of the SopNode entity.
  21111. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21113. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21114. if !m.op.Is(OpUpdateOne) {
  21115. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21116. }
  21117. if m.id == nil || m.oldValue == nil {
  21118. return v, errors.New("OldName requires an ID field in the mutation")
  21119. }
  21120. oldValue, err := m.oldValue(ctx)
  21121. if err != nil {
  21122. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21123. }
  21124. return oldValue.Name, nil
  21125. }
  21126. // ResetName resets all changes to the "name" field.
  21127. func (m *SopNodeMutation) ResetName() {
  21128. m.name = nil
  21129. }
  21130. // SetConditionType sets the "condition_type" field.
  21131. func (m *SopNodeMutation) SetConditionType(i int) {
  21132. m.condition_type = &i
  21133. m.addcondition_type = nil
  21134. }
  21135. // ConditionType returns the value of the "condition_type" field in the mutation.
  21136. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21137. v := m.condition_type
  21138. if v == nil {
  21139. return
  21140. }
  21141. return *v, true
  21142. }
  21143. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21144. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21146. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21147. if !m.op.Is(OpUpdateOne) {
  21148. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21149. }
  21150. if m.id == nil || m.oldValue == nil {
  21151. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21152. }
  21153. oldValue, err := m.oldValue(ctx)
  21154. if err != nil {
  21155. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21156. }
  21157. return oldValue.ConditionType, nil
  21158. }
  21159. // AddConditionType adds i to the "condition_type" field.
  21160. func (m *SopNodeMutation) AddConditionType(i int) {
  21161. if m.addcondition_type != nil {
  21162. *m.addcondition_type += i
  21163. } else {
  21164. m.addcondition_type = &i
  21165. }
  21166. }
  21167. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21168. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21169. v := m.addcondition_type
  21170. if v == nil {
  21171. return
  21172. }
  21173. return *v, true
  21174. }
  21175. // ResetConditionType resets all changes to the "condition_type" field.
  21176. func (m *SopNodeMutation) ResetConditionType() {
  21177. m.condition_type = nil
  21178. m.addcondition_type = nil
  21179. }
  21180. // SetConditionList sets the "condition_list" field.
  21181. func (m *SopNodeMutation) SetConditionList(s []string) {
  21182. m.condition_list = &s
  21183. m.appendcondition_list = nil
  21184. }
  21185. // ConditionList returns the value of the "condition_list" field in the mutation.
  21186. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21187. v := m.condition_list
  21188. if v == nil {
  21189. return
  21190. }
  21191. return *v, true
  21192. }
  21193. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21194. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21196. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21197. if !m.op.Is(OpUpdateOne) {
  21198. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21199. }
  21200. if m.id == nil || m.oldValue == nil {
  21201. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21202. }
  21203. oldValue, err := m.oldValue(ctx)
  21204. if err != nil {
  21205. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21206. }
  21207. return oldValue.ConditionList, nil
  21208. }
  21209. // AppendConditionList adds s to the "condition_list" field.
  21210. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21211. m.appendcondition_list = append(m.appendcondition_list, s...)
  21212. }
  21213. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21214. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21215. if len(m.appendcondition_list) == 0 {
  21216. return nil, false
  21217. }
  21218. return m.appendcondition_list, true
  21219. }
  21220. // ClearConditionList clears the value of the "condition_list" field.
  21221. func (m *SopNodeMutation) ClearConditionList() {
  21222. m.condition_list = nil
  21223. m.appendcondition_list = nil
  21224. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21225. }
  21226. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21227. func (m *SopNodeMutation) ConditionListCleared() bool {
  21228. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21229. return ok
  21230. }
  21231. // ResetConditionList resets all changes to the "condition_list" field.
  21232. func (m *SopNodeMutation) ResetConditionList() {
  21233. m.condition_list = nil
  21234. m.appendcondition_list = nil
  21235. delete(m.clearedFields, sopnode.FieldConditionList)
  21236. }
  21237. // SetNoReplyCondition sets the "no_reply_condition" field.
  21238. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21239. m.no_reply_condition = &u
  21240. m.addno_reply_condition = nil
  21241. }
  21242. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21243. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21244. v := m.no_reply_condition
  21245. if v == nil {
  21246. return
  21247. }
  21248. return *v, true
  21249. }
  21250. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21251. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21252. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21253. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21254. if !m.op.Is(OpUpdateOne) {
  21255. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21256. }
  21257. if m.id == nil || m.oldValue == nil {
  21258. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21259. }
  21260. oldValue, err := m.oldValue(ctx)
  21261. if err != nil {
  21262. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21263. }
  21264. return oldValue.NoReplyCondition, nil
  21265. }
  21266. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21267. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21268. if m.addno_reply_condition != nil {
  21269. *m.addno_reply_condition += u
  21270. } else {
  21271. m.addno_reply_condition = &u
  21272. }
  21273. }
  21274. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21275. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21276. v := m.addno_reply_condition
  21277. if v == nil {
  21278. return
  21279. }
  21280. return *v, true
  21281. }
  21282. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21283. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21284. m.no_reply_condition = nil
  21285. m.addno_reply_condition = nil
  21286. }
  21287. // SetNoReplyUnit sets the "no_reply_unit" field.
  21288. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21289. m.no_reply_unit = &s
  21290. }
  21291. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21292. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21293. v := m.no_reply_unit
  21294. if v == nil {
  21295. return
  21296. }
  21297. return *v, true
  21298. }
  21299. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21300. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21301. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21302. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21303. if !m.op.Is(OpUpdateOne) {
  21304. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21305. }
  21306. if m.id == nil || m.oldValue == nil {
  21307. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21308. }
  21309. oldValue, err := m.oldValue(ctx)
  21310. if err != nil {
  21311. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21312. }
  21313. return oldValue.NoReplyUnit, nil
  21314. }
  21315. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21316. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21317. m.no_reply_unit = nil
  21318. }
  21319. // SetActionMessage sets the "action_message" field.
  21320. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21321. m.action_message = &ct
  21322. m.appendaction_message = nil
  21323. }
  21324. // ActionMessage returns the value of the "action_message" field in the mutation.
  21325. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21326. v := m.action_message
  21327. if v == nil {
  21328. return
  21329. }
  21330. return *v, true
  21331. }
  21332. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21333. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21335. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21336. if !m.op.Is(OpUpdateOne) {
  21337. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21338. }
  21339. if m.id == nil || m.oldValue == nil {
  21340. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21341. }
  21342. oldValue, err := m.oldValue(ctx)
  21343. if err != nil {
  21344. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21345. }
  21346. return oldValue.ActionMessage, nil
  21347. }
  21348. // AppendActionMessage adds ct to the "action_message" field.
  21349. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21350. m.appendaction_message = append(m.appendaction_message, ct...)
  21351. }
  21352. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21353. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21354. if len(m.appendaction_message) == 0 {
  21355. return nil, false
  21356. }
  21357. return m.appendaction_message, true
  21358. }
  21359. // ClearActionMessage clears the value of the "action_message" field.
  21360. func (m *SopNodeMutation) ClearActionMessage() {
  21361. m.action_message = nil
  21362. m.appendaction_message = nil
  21363. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21364. }
  21365. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21366. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21367. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21368. return ok
  21369. }
  21370. // ResetActionMessage resets all changes to the "action_message" field.
  21371. func (m *SopNodeMutation) ResetActionMessage() {
  21372. m.action_message = nil
  21373. m.appendaction_message = nil
  21374. delete(m.clearedFields, sopnode.FieldActionMessage)
  21375. }
  21376. // SetActionLabelAdd sets the "action_label_add" field.
  21377. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21378. m.action_label_add = &u
  21379. m.appendaction_label_add = nil
  21380. }
  21381. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21382. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21383. v := m.action_label_add
  21384. if v == nil {
  21385. return
  21386. }
  21387. return *v, true
  21388. }
  21389. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21390. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21391. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21392. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21393. if !m.op.Is(OpUpdateOne) {
  21394. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21395. }
  21396. if m.id == nil || m.oldValue == nil {
  21397. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21398. }
  21399. oldValue, err := m.oldValue(ctx)
  21400. if err != nil {
  21401. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21402. }
  21403. return oldValue.ActionLabelAdd, nil
  21404. }
  21405. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21406. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21407. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21408. }
  21409. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21410. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21411. if len(m.appendaction_label_add) == 0 {
  21412. return nil, false
  21413. }
  21414. return m.appendaction_label_add, true
  21415. }
  21416. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21417. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21418. m.action_label_add = nil
  21419. m.appendaction_label_add = nil
  21420. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21421. }
  21422. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21423. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21424. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21425. return ok
  21426. }
  21427. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21428. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21429. m.action_label_add = nil
  21430. m.appendaction_label_add = nil
  21431. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21432. }
  21433. // SetActionLabelDel sets the "action_label_del" field.
  21434. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21435. m.action_label_del = &u
  21436. m.appendaction_label_del = nil
  21437. }
  21438. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21439. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21440. v := m.action_label_del
  21441. if v == nil {
  21442. return
  21443. }
  21444. return *v, true
  21445. }
  21446. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21447. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21448. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21449. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21450. if !m.op.Is(OpUpdateOne) {
  21451. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21452. }
  21453. if m.id == nil || m.oldValue == nil {
  21454. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21455. }
  21456. oldValue, err := m.oldValue(ctx)
  21457. if err != nil {
  21458. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21459. }
  21460. return oldValue.ActionLabelDel, nil
  21461. }
  21462. // AppendActionLabelDel adds u to the "action_label_del" field.
  21463. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21464. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21465. }
  21466. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21467. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21468. if len(m.appendaction_label_del) == 0 {
  21469. return nil, false
  21470. }
  21471. return m.appendaction_label_del, true
  21472. }
  21473. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21474. func (m *SopNodeMutation) ClearActionLabelDel() {
  21475. m.action_label_del = nil
  21476. m.appendaction_label_del = nil
  21477. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21478. }
  21479. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21480. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21481. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21482. return ok
  21483. }
  21484. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21485. func (m *SopNodeMutation) ResetActionLabelDel() {
  21486. m.action_label_del = nil
  21487. m.appendaction_label_del = nil
  21488. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21489. }
  21490. // SetActionForward sets the "action_forward" field.
  21491. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21492. m.action_forward = &ctf
  21493. }
  21494. // ActionForward returns the value of the "action_forward" field in the mutation.
  21495. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21496. v := m.action_forward
  21497. if v == nil {
  21498. return
  21499. }
  21500. return *v, true
  21501. }
  21502. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21503. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21505. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21506. if !m.op.Is(OpUpdateOne) {
  21507. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21508. }
  21509. if m.id == nil || m.oldValue == nil {
  21510. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21511. }
  21512. oldValue, err := m.oldValue(ctx)
  21513. if err != nil {
  21514. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21515. }
  21516. return oldValue.ActionForward, nil
  21517. }
  21518. // ClearActionForward clears the value of the "action_forward" field.
  21519. func (m *SopNodeMutation) ClearActionForward() {
  21520. m.action_forward = nil
  21521. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21522. }
  21523. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21524. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21525. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21526. return ok
  21527. }
  21528. // ResetActionForward resets all changes to the "action_forward" field.
  21529. func (m *SopNodeMutation) ResetActionForward() {
  21530. m.action_forward = nil
  21531. delete(m.clearedFields, sopnode.FieldActionForward)
  21532. }
  21533. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21534. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21535. m.sop_stage = &id
  21536. }
  21537. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21538. func (m *SopNodeMutation) ClearSopStage() {
  21539. m.clearedsop_stage = true
  21540. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21541. }
  21542. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21543. func (m *SopNodeMutation) SopStageCleared() bool {
  21544. return m.clearedsop_stage
  21545. }
  21546. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21547. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21548. if m.sop_stage != nil {
  21549. return *m.sop_stage, true
  21550. }
  21551. return
  21552. }
  21553. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21554. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21555. // SopStageID instead. It exists only for internal usage by the builders.
  21556. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21557. if id := m.sop_stage; id != nil {
  21558. ids = append(ids, *id)
  21559. }
  21560. return
  21561. }
  21562. // ResetSopStage resets all changes to the "sop_stage" edge.
  21563. func (m *SopNodeMutation) ResetSopStage() {
  21564. m.sop_stage = nil
  21565. m.clearedsop_stage = false
  21566. }
  21567. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21568. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21569. if m.node_messages == nil {
  21570. m.node_messages = make(map[uint64]struct{})
  21571. }
  21572. for i := range ids {
  21573. m.node_messages[ids[i]] = struct{}{}
  21574. }
  21575. }
  21576. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21577. func (m *SopNodeMutation) ClearNodeMessages() {
  21578. m.clearednode_messages = true
  21579. }
  21580. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21581. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21582. return m.clearednode_messages
  21583. }
  21584. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21585. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21586. if m.removednode_messages == nil {
  21587. m.removednode_messages = make(map[uint64]struct{})
  21588. }
  21589. for i := range ids {
  21590. delete(m.node_messages, ids[i])
  21591. m.removednode_messages[ids[i]] = struct{}{}
  21592. }
  21593. }
  21594. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21595. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21596. for id := range m.removednode_messages {
  21597. ids = append(ids, id)
  21598. }
  21599. return
  21600. }
  21601. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21602. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21603. for id := range m.node_messages {
  21604. ids = append(ids, id)
  21605. }
  21606. return
  21607. }
  21608. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21609. func (m *SopNodeMutation) ResetNodeMessages() {
  21610. m.node_messages = nil
  21611. m.clearednode_messages = false
  21612. m.removednode_messages = nil
  21613. }
  21614. // Where appends a list predicates to the SopNodeMutation builder.
  21615. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21616. m.predicates = append(m.predicates, ps...)
  21617. }
  21618. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21619. // users can use type-assertion to append predicates that do not depend on any generated package.
  21620. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21621. p := make([]predicate.SopNode, len(ps))
  21622. for i := range ps {
  21623. p[i] = ps[i]
  21624. }
  21625. m.Where(p...)
  21626. }
  21627. // Op returns the operation name.
  21628. func (m *SopNodeMutation) Op() Op {
  21629. return m.op
  21630. }
  21631. // SetOp allows setting the mutation operation.
  21632. func (m *SopNodeMutation) SetOp(op Op) {
  21633. m.op = op
  21634. }
  21635. // Type returns the node type of this mutation (SopNode).
  21636. func (m *SopNodeMutation) Type() string {
  21637. return m.typ
  21638. }
  21639. // Fields returns all fields that were changed during this mutation. Note that in
  21640. // order to get all numeric fields that were incremented/decremented, call
  21641. // AddedFields().
  21642. func (m *SopNodeMutation) Fields() []string {
  21643. fields := make([]string, 0, 15)
  21644. if m.created_at != nil {
  21645. fields = append(fields, sopnode.FieldCreatedAt)
  21646. }
  21647. if m.updated_at != nil {
  21648. fields = append(fields, sopnode.FieldUpdatedAt)
  21649. }
  21650. if m.status != nil {
  21651. fields = append(fields, sopnode.FieldStatus)
  21652. }
  21653. if m.deleted_at != nil {
  21654. fields = append(fields, sopnode.FieldDeletedAt)
  21655. }
  21656. if m.sop_stage != nil {
  21657. fields = append(fields, sopnode.FieldStageID)
  21658. }
  21659. if m.parent_id != nil {
  21660. fields = append(fields, sopnode.FieldParentID)
  21661. }
  21662. if m.name != nil {
  21663. fields = append(fields, sopnode.FieldName)
  21664. }
  21665. if m.condition_type != nil {
  21666. fields = append(fields, sopnode.FieldConditionType)
  21667. }
  21668. if m.condition_list != nil {
  21669. fields = append(fields, sopnode.FieldConditionList)
  21670. }
  21671. if m.no_reply_condition != nil {
  21672. fields = append(fields, sopnode.FieldNoReplyCondition)
  21673. }
  21674. if m.no_reply_unit != nil {
  21675. fields = append(fields, sopnode.FieldNoReplyUnit)
  21676. }
  21677. if m.action_message != nil {
  21678. fields = append(fields, sopnode.FieldActionMessage)
  21679. }
  21680. if m.action_label_add != nil {
  21681. fields = append(fields, sopnode.FieldActionLabelAdd)
  21682. }
  21683. if m.action_label_del != nil {
  21684. fields = append(fields, sopnode.FieldActionLabelDel)
  21685. }
  21686. if m.action_forward != nil {
  21687. fields = append(fields, sopnode.FieldActionForward)
  21688. }
  21689. return fields
  21690. }
  21691. // Field returns the value of a field with the given name. The second boolean
  21692. // return value indicates that this field was not set, or was not defined in the
  21693. // schema.
  21694. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21695. switch name {
  21696. case sopnode.FieldCreatedAt:
  21697. return m.CreatedAt()
  21698. case sopnode.FieldUpdatedAt:
  21699. return m.UpdatedAt()
  21700. case sopnode.FieldStatus:
  21701. return m.Status()
  21702. case sopnode.FieldDeletedAt:
  21703. return m.DeletedAt()
  21704. case sopnode.FieldStageID:
  21705. return m.StageID()
  21706. case sopnode.FieldParentID:
  21707. return m.ParentID()
  21708. case sopnode.FieldName:
  21709. return m.Name()
  21710. case sopnode.FieldConditionType:
  21711. return m.ConditionType()
  21712. case sopnode.FieldConditionList:
  21713. return m.ConditionList()
  21714. case sopnode.FieldNoReplyCondition:
  21715. return m.NoReplyCondition()
  21716. case sopnode.FieldNoReplyUnit:
  21717. return m.NoReplyUnit()
  21718. case sopnode.FieldActionMessage:
  21719. return m.ActionMessage()
  21720. case sopnode.FieldActionLabelAdd:
  21721. return m.ActionLabelAdd()
  21722. case sopnode.FieldActionLabelDel:
  21723. return m.ActionLabelDel()
  21724. case sopnode.FieldActionForward:
  21725. return m.ActionForward()
  21726. }
  21727. return nil, false
  21728. }
  21729. // OldField returns the old value of the field from the database. An error is
  21730. // returned if the mutation operation is not UpdateOne, or the query to the
  21731. // database failed.
  21732. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21733. switch name {
  21734. case sopnode.FieldCreatedAt:
  21735. return m.OldCreatedAt(ctx)
  21736. case sopnode.FieldUpdatedAt:
  21737. return m.OldUpdatedAt(ctx)
  21738. case sopnode.FieldStatus:
  21739. return m.OldStatus(ctx)
  21740. case sopnode.FieldDeletedAt:
  21741. return m.OldDeletedAt(ctx)
  21742. case sopnode.FieldStageID:
  21743. return m.OldStageID(ctx)
  21744. case sopnode.FieldParentID:
  21745. return m.OldParentID(ctx)
  21746. case sopnode.FieldName:
  21747. return m.OldName(ctx)
  21748. case sopnode.FieldConditionType:
  21749. return m.OldConditionType(ctx)
  21750. case sopnode.FieldConditionList:
  21751. return m.OldConditionList(ctx)
  21752. case sopnode.FieldNoReplyCondition:
  21753. return m.OldNoReplyCondition(ctx)
  21754. case sopnode.FieldNoReplyUnit:
  21755. return m.OldNoReplyUnit(ctx)
  21756. case sopnode.FieldActionMessage:
  21757. return m.OldActionMessage(ctx)
  21758. case sopnode.FieldActionLabelAdd:
  21759. return m.OldActionLabelAdd(ctx)
  21760. case sopnode.FieldActionLabelDel:
  21761. return m.OldActionLabelDel(ctx)
  21762. case sopnode.FieldActionForward:
  21763. return m.OldActionForward(ctx)
  21764. }
  21765. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21766. }
  21767. // SetField sets the value of a field with the given name. It returns an error if
  21768. // the field is not defined in the schema, or if the type mismatched the field
  21769. // type.
  21770. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21771. switch name {
  21772. case sopnode.FieldCreatedAt:
  21773. v, ok := value.(time.Time)
  21774. if !ok {
  21775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21776. }
  21777. m.SetCreatedAt(v)
  21778. return nil
  21779. case sopnode.FieldUpdatedAt:
  21780. v, ok := value.(time.Time)
  21781. if !ok {
  21782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21783. }
  21784. m.SetUpdatedAt(v)
  21785. return nil
  21786. case sopnode.FieldStatus:
  21787. v, ok := value.(uint8)
  21788. if !ok {
  21789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21790. }
  21791. m.SetStatus(v)
  21792. return nil
  21793. case sopnode.FieldDeletedAt:
  21794. v, ok := value.(time.Time)
  21795. if !ok {
  21796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21797. }
  21798. m.SetDeletedAt(v)
  21799. return nil
  21800. case sopnode.FieldStageID:
  21801. v, ok := value.(uint64)
  21802. if !ok {
  21803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21804. }
  21805. m.SetStageID(v)
  21806. return nil
  21807. case sopnode.FieldParentID:
  21808. v, ok := value.(uint64)
  21809. if !ok {
  21810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21811. }
  21812. m.SetParentID(v)
  21813. return nil
  21814. case sopnode.FieldName:
  21815. v, ok := value.(string)
  21816. if !ok {
  21817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21818. }
  21819. m.SetName(v)
  21820. return nil
  21821. case sopnode.FieldConditionType:
  21822. v, ok := value.(int)
  21823. if !ok {
  21824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21825. }
  21826. m.SetConditionType(v)
  21827. return nil
  21828. case sopnode.FieldConditionList:
  21829. v, ok := value.([]string)
  21830. if !ok {
  21831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21832. }
  21833. m.SetConditionList(v)
  21834. return nil
  21835. case sopnode.FieldNoReplyCondition:
  21836. v, ok := value.(uint64)
  21837. if !ok {
  21838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21839. }
  21840. m.SetNoReplyCondition(v)
  21841. return nil
  21842. case sopnode.FieldNoReplyUnit:
  21843. v, ok := value.(string)
  21844. if !ok {
  21845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21846. }
  21847. m.SetNoReplyUnit(v)
  21848. return nil
  21849. case sopnode.FieldActionMessage:
  21850. v, ok := value.([]custom_types.Action)
  21851. if !ok {
  21852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21853. }
  21854. m.SetActionMessage(v)
  21855. return nil
  21856. case sopnode.FieldActionLabelAdd:
  21857. v, ok := value.([]uint64)
  21858. if !ok {
  21859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21860. }
  21861. m.SetActionLabelAdd(v)
  21862. return nil
  21863. case sopnode.FieldActionLabelDel:
  21864. v, ok := value.([]uint64)
  21865. if !ok {
  21866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21867. }
  21868. m.SetActionLabelDel(v)
  21869. return nil
  21870. case sopnode.FieldActionForward:
  21871. v, ok := value.(*custom_types.ActionForward)
  21872. if !ok {
  21873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21874. }
  21875. m.SetActionForward(v)
  21876. return nil
  21877. }
  21878. return fmt.Errorf("unknown SopNode field %s", name)
  21879. }
  21880. // AddedFields returns all numeric fields that were incremented/decremented during
  21881. // this mutation.
  21882. func (m *SopNodeMutation) AddedFields() []string {
  21883. var fields []string
  21884. if m.addstatus != nil {
  21885. fields = append(fields, sopnode.FieldStatus)
  21886. }
  21887. if m.addparent_id != nil {
  21888. fields = append(fields, sopnode.FieldParentID)
  21889. }
  21890. if m.addcondition_type != nil {
  21891. fields = append(fields, sopnode.FieldConditionType)
  21892. }
  21893. if m.addno_reply_condition != nil {
  21894. fields = append(fields, sopnode.FieldNoReplyCondition)
  21895. }
  21896. return fields
  21897. }
  21898. // AddedField returns the numeric value that was incremented/decremented on a field
  21899. // with the given name. The second boolean return value indicates that this field
  21900. // was not set, or was not defined in the schema.
  21901. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21902. switch name {
  21903. case sopnode.FieldStatus:
  21904. return m.AddedStatus()
  21905. case sopnode.FieldParentID:
  21906. return m.AddedParentID()
  21907. case sopnode.FieldConditionType:
  21908. return m.AddedConditionType()
  21909. case sopnode.FieldNoReplyCondition:
  21910. return m.AddedNoReplyCondition()
  21911. }
  21912. return nil, false
  21913. }
  21914. // AddField adds the value to the field with the given name. It returns an error if
  21915. // the field is not defined in the schema, or if the type mismatched the field
  21916. // type.
  21917. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21918. switch name {
  21919. case sopnode.FieldStatus:
  21920. v, ok := value.(int8)
  21921. if !ok {
  21922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21923. }
  21924. m.AddStatus(v)
  21925. return nil
  21926. case sopnode.FieldParentID:
  21927. v, ok := value.(int64)
  21928. if !ok {
  21929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21930. }
  21931. m.AddParentID(v)
  21932. return nil
  21933. case sopnode.FieldConditionType:
  21934. v, ok := value.(int)
  21935. if !ok {
  21936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21937. }
  21938. m.AddConditionType(v)
  21939. return nil
  21940. case sopnode.FieldNoReplyCondition:
  21941. v, ok := value.(int64)
  21942. if !ok {
  21943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21944. }
  21945. m.AddNoReplyCondition(v)
  21946. return nil
  21947. }
  21948. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21949. }
  21950. // ClearedFields returns all nullable fields that were cleared during this
  21951. // mutation.
  21952. func (m *SopNodeMutation) ClearedFields() []string {
  21953. var fields []string
  21954. if m.FieldCleared(sopnode.FieldStatus) {
  21955. fields = append(fields, sopnode.FieldStatus)
  21956. }
  21957. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21958. fields = append(fields, sopnode.FieldDeletedAt)
  21959. }
  21960. if m.FieldCleared(sopnode.FieldConditionList) {
  21961. fields = append(fields, sopnode.FieldConditionList)
  21962. }
  21963. if m.FieldCleared(sopnode.FieldActionMessage) {
  21964. fields = append(fields, sopnode.FieldActionMessage)
  21965. }
  21966. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21967. fields = append(fields, sopnode.FieldActionLabelAdd)
  21968. }
  21969. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21970. fields = append(fields, sopnode.FieldActionLabelDel)
  21971. }
  21972. if m.FieldCleared(sopnode.FieldActionForward) {
  21973. fields = append(fields, sopnode.FieldActionForward)
  21974. }
  21975. return fields
  21976. }
  21977. // FieldCleared returns a boolean indicating if a field with the given name was
  21978. // cleared in this mutation.
  21979. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21980. _, ok := m.clearedFields[name]
  21981. return ok
  21982. }
  21983. // ClearField clears the value of the field with the given name. It returns an
  21984. // error if the field is not defined in the schema.
  21985. func (m *SopNodeMutation) ClearField(name string) error {
  21986. switch name {
  21987. case sopnode.FieldStatus:
  21988. m.ClearStatus()
  21989. return nil
  21990. case sopnode.FieldDeletedAt:
  21991. m.ClearDeletedAt()
  21992. return nil
  21993. case sopnode.FieldConditionList:
  21994. m.ClearConditionList()
  21995. return nil
  21996. case sopnode.FieldActionMessage:
  21997. m.ClearActionMessage()
  21998. return nil
  21999. case sopnode.FieldActionLabelAdd:
  22000. m.ClearActionLabelAdd()
  22001. return nil
  22002. case sopnode.FieldActionLabelDel:
  22003. m.ClearActionLabelDel()
  22004. return nil
  22005. case sopnode.FieldActionForward:
  22006. m.ClearActionForward()
  22007. return nil
  22008. }
  22009. return fmt.Errorf("unknown SopNode nullable field %s", name)
  22010. }
  22011. // ResetField resets all changes in the mutation for the field with the given name.
  22012. // It returns an error if the field is not defined in the schema.
  22013. func (m *SopNodeMutation) ResetField(name string) error {
  22014. switch name {
  22015. case sopnode.FieldCreatedAt:
  22016. m.ResetCreatedAt()
  22017. return nil
  22018. case sopnode.FieldUpdatedAt:
  22019. m.ResetUpdatedAt()
  22020. return nil
  22021. case sopnode.FieldStatus:
  22022. m.ResetStatus()
  22023. return nil
  22024. case sopnode.FieldDeletedAt:
  22025. m.ResetDeletedAt()
  22026. return nil
  22027. case sopnode.FieldStageID:
  22028. m.ResetStageID()
  22029. return nil
  22030. case sopnode.FieldParentID:
  22031. m.ResetParentID()
  22032. return nil
  22033. case sopnode.FieldName:
  22034. m.ResetName()
  22035. return nil
  22036. case sopnode.FieldConditionType:
  22037. m.ResetConditionType()
  22038. return nil
  22039. case sopnode.FieldConditionList:
  22040. m.ResetConditionList()
  22041. return nil
  22042. case sopnode.FieldNoReplyCondition:
  22043. m.ResetNoReplyCondition()
  22044. return nil
  22045. case sopnode.FieldNoReplyUnit:
  22046. m.ResetNoReplyUnit()
  22047. return nil
  22048. case sopnode.FieldActionMessage:
  22049. m.ResetActionMessage()
  22050. return nil
  22051. case sopnode.FieldActionLabelAdd:
  22052. m.ResetActionLabelAdd()
  22053. return nil
  22054. case sopnode.FieldActionLabelDel:
  22055. m.ResetActionLabelDel()
  22056. return nil
  22057. case sopnode.FieldActionForward:
  22058. m.ResetActionForward()
  22059. return nil
  22060. }
  22061. return fmt.Errorf("unknown SopNode field %s", name)
  22062. }
  22063. // AddedEdges returns all edge names that were set/added in this mutation.
  22064. func (m *SopNodeMutation) AddedEdges() []string {
  22065. edges := make([]string, 0, 2)
  22066. if m.sop_stage != nil {
  22067. edges = append(edges, sopnode.EdgeSopStage)
  22068. }
  22069. if m.node_messages != nil {
  22070. edges = append(edges, sopnode.EdgeNodeMessages)
  22071. }
  22072. return edges
  22073. }
  22074. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  22075. // name in this mutation.
  22076. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22077. switch name {
  22078. case sopnode.EdgeSopStage:
  22079. if id := m.sop_stage; id != nil {
  22080. return []ent.Value{*id}
  22081. }
  22082. case sopnode.EdgeNodeMessages:
  22083. ids := make([]ent.Value, 0, len(m.node_messages))
  22084. for id := range m.node_messages {
  22085. ids = append(ids, id)
  22086. }
  22087. return ids
  22088. }
  22089. return nil
  22090. }
  22091. // RemovedEdges returns all edge names that were removed in this mutation.
  22092. func (m *SopNodeMutation) RemovedEdges() []string {
  22093. edges := make([]string, 0, 2)
  22094. if m.removednode_messages != nil {
  22095. edges = append(edges, sopnode.EdgeNodeMessages)
  22096. }
  22097. return edges
  22098. }
  22099. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22100. // the given name in this mutation.
  22101. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22102. switch name {
  22103. case sopnode.EdgeNodeMessages:
  22104. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22105. for id := range m.removednode_messages {
  22106. ids = append(ids, id)
  22107. }
  22108. return ids
  22109. }
  22110. return nil
  22111. }
  22112. // ClearedEdges returns all edge names that were cleared in this mutation.
  22113. func (m *SopNodeMutation) ClearedEdges() []string {
  22114. edges := make([]string, 0, 2)
  22115. if m.clearedsop_stage {
  22116. edges = append(edges, sopnode.EdgeSopStage)
  22117. }
  22118. if m.clearednode_messages {
  22119. edges = append(edges, sopnode.EdgeNodeMessages)
  22120. }
  22121. return edges
  22122. }
  22123. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22124. // was cleared in this mutation.
  22125. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22126. switch name {
  22127. case sopnode.EdgeSopStage:
  22128. return m.clearedsop_stage
  22129. case sopnode.EdgeNodeMessages:
  22130. return m.clearednode_messages
  22131. }
  22132. return false
  22133. }
  22134. // ClearEdge clears the value of the edge with the given name. It returns an error
  22135. // if that edge is not defined in the schema.
  22136. func (m *SopNodeMutation) ClearEdge(name string) error {
  22137. switch name {
  22138. case sopnode.EdgeSopStage:
  22139. m.ClearSopStage()
  22140. return nil
  22141. }
  22142. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22143. }
  22144. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22145. // It returns an error if the edge is not defined in the schema.
  22146. func (m *SopNodeMutation) ResetEdge(name string) error {
  22147. switch name {
  22148. case sopnode.EdgeSopStage:
  22149. m.ResetSopStage()
  22150. return nil
  22151. case sopnode.EdgeNodeMessages:
  22152. m.ResetNodeMessages()
  22153. return nil
  22154. }
  22155. return fmt.Errorf("unknown SopNode edge %s", name)
  22156. }
  22157. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22158. type SopStageMutation struct {
  22159. config
  22160. op Op
  22161. typ string
  22162. id *uint64
  22163. created_at *time.Time
  22164. updated_at *time.Time
  22165. status *uint8
  22166. addstatus *int8
  22167. deleted_at *time.Time
  22168. name *string
  22169. condition_type *int
  22170. addcondition_type *int
  22171. condition_operator *int
  22172. addcondition_operator *int
  22173. condition_list *[]custom_types.Condition
  22174. appendcondition_list []custom_types.Condition
  22175. action_message *[]custom_types.Action
  22176. appendaction_message []custom_types.Action
  22177. action_label_add *[]uint64
  22178. appendaction_label_add []uint64
  22179. action_label_del *[]uint64
  22180. appendaction_label_del []uint64
  22181. action_forward **custom_types.ActionForward
  22182. index_sort *int
  22183. addindex_sort *int
  22184. clearedFields map[string]struct{}
  22185. sop_task *uint64
  22186. clearedsop_task bool
  22187. stage_nodes map[uint64]struct{}
  22188. removedstage_nodes map[uint64]struct{}
  22189. clearedstage_nodes bool
  22190. stage_messages map[uint64]struct{}
  22191. removedstage_messages map[uint64]struct{}
  22192. clearedstage_messages bool
  22193. done bool
  22194. oldValue func(context.Context) (*SopStage, error)
  22195. predicates []predicate.SopStage
  22196. }
  22197. var _ ent.Mutation = (*SopStageMutation)(nil)
  22198. // sopstageOption allows management of the mutation configuration using functional options.
  22199. type sopstageOption func(*SopStageMutation)
  22200. // newSopStageMutation creates new mutation for the SopStage entity.
  22201. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22202. m := &SopStageMutation{
  22203. config: c,
  22204. op: op,
  22205. typ: TypeSopStage,
  22206. clearedFields: make(map[string]struct{}),
  22207. }
  22208. for _, opt := range opts {
  22209. opt(m)
  22210. }
  22211. return m
  22212. }
  22213. // withSopStageID sets the ID field of the mutation.
  22214. func withSopStageID(id uint64) sopstageOption {
  22215. return func(m *SopStageMutation) {
  22216. var (
  22217. err error
  22218. once sync.Once
  22219. value *SopStage
  22220. )
  22221. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22222. once.Do(func() {
  22223. if m.done {
  22224. err = errors.New("querying old values post mutation is not allowed")
  22225. } else {
  22226. value, err = m.Client().SopStage.Get(ctx, id)
  22227. }
  22228. })
  22229. return value, err
  22230. }
  22231. m.id = &id
  22232. }
  22233. }
  22234. // withSopStage sets the old SopStage of the mutation.
  22235. func withSopStage(node *SopStage) sopstageOption {
  22236. return func(m *SopStageMutation) {
  22237. m.oldValue = func(context.Context) (*SopStage, error) {
  22238. return node, nil
  22239. }
  22240. m.id = &node.ID
  22241. }
  22242. }
  22243. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22244. // executed in a transaction (ent.Tx), a transactional client is returned.
  22245. func (m SopStageMutation) Client() *Client {
  22246. client := &Client{config: m.config}
  22247. client.init()
  22248. return client
  22249. }
  22250. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22251. // it returns an error otherwise.
  22252. func (m SopStageMutation) Tx() (*Tx, error) {
  22253. if _, ok := m.driver.(*txDriver); !ok {
  22254. return nil, errors.New("ent: mutation is not running in a transaction")
  22255. }
  22256. tx := &Tx{config: m.config}
  22257. tx.init()
  22258. return tx, nil
  22259. }
  22260. // SetID sets the value of the id field. Note that this
  22261. // operation is only accepted on creation of SopStage entities.
  22262. func (m *SopStageMutation) SetID(id uint64) {
  22263. m.id = &id
  22264. }
  22265. // ID returns the ID value in the mutation. Note that the ID is only available
  22266. // if it was provided to the builder or after it was returned from the database.
  22267. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22268. if m.id == nil {
  22269. return
  22270. }
  22271. return *m.id, true
  22272. }
  22273. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22274. // That means, if the mutation is applied within a transaction with an isolation level such
  22275. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22276. // or updated by the mutation.
  22277. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22278. switch {
  22279. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22280. id, exists := m.ID()
  22281. if exists {
  22282. return []uint64{id}, nil
  22283. }
  22284. fallthrough
  22285. case m.op.Is(OpUpdate | OpDelete):
  22286. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22287. default:
  22288. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22289. }
  22290. }
  22291. // SetCreatedAt sets the "created_at" field.
  22292. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22293. m.created_at = &t
  22294. }
  22295. // CreatedAt returns the value of the "created_at" field in the mutation.
  22296. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22297. v := m.created_at
  22298. if v == nil {
  22299. return
  22300. }
  22301. return *v, true
  22302. }
  22303. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22304. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22305. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22306. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22307. if !m.op.Is(OpUpdateOne) {
  22308. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22309. }
  22310. if m.id == nil || m.oldValue == nil {
  22311. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22312. }
  22313. oldValue, err := m.oldValue(ctx)
  22314. if err != nil {
  22315. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22316. }
  22317. return oldValue.CreatedAt, nil
  22318. }
  22319. // ResetCreatedAt resets all changes to the "created_at" field.
  22320. func (m *SopStageMutation) ResetCreatedAt() {
  22321. m.created_at = nil
  22322. }
  22323. // SetUpdatedAt sets the "updated_at" field.
  22324. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22325. m.updated_at = &t
  22326. }
  22327. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22328. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22329. v := m.updated_at
  22330. if v == nil {
  22331. return
  22332. }
  22333. return *v, true
  22334. }
  22335. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22336. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22337. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22338. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22339. if !m.op.Is(OpUpdateOne) {
  22340. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22341. }
  22342. if m.id == nil || m.oldValue == nil {
  22343. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22344. }
  22345. oldValue, err := m.oldValue(ctx)
  22346. if err != nil {
  22347. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22348. }
  22349. return oldValue.UpdatedAt, nil
  22350. }
  22351. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22352. func (m *SopStageMutation) ResetUpdatedAt() {
  22353. m.updated_at = nil
  22354. }
  22355. // SetStatus sets the "status" field.
  22356. func (m *SopStageMutation) SetStatus(u uint8) {
  22357. m.status = &u
  22358. m.addstatus = nil
  22359. }
  22360. // Status returns the value of the "status" field in the mutation.
  22361. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22362. v := m.status
  22363. if v == nil {
  22364. return
  22365. }
  22366. return *v, true
  22367. }
  22368. // OldStatus returns the old "status" field's value of the SopStage entity.
  22369. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22371. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22372. if !m.op.Is(OpUpdateOne) {
  22373. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22374. }
  22375. if m.id == nil || m.oldValue == nil {
  22376. return v, errors.New("OldStatus requires an ID field in the mutation")
  22377. }
  22378. oldValue, err := m.oldValue(ctx)
  22379. if err != nil {
  22380. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22381. }
  22382. return oldValue.Status, nil
  22383. }
  22384. // AddStatus adds u to the "status" field.
  22385. func (m *SopStageMutation) AddStatus(u int8) {
  22386. if m.addstatus != nil {
  22387. *m.addstatus += u
  22388. } else {
  22389. m.addstatus = &u
  22390. }
  22391. }
  22392. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22393. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22394. v := m.addstatus
  22395. if v == nil {
  22396. return
  22397. }
  22398. return *v, true
  22399. }
  22400. // ClearStatus clears the value of the "status" field.
  22401. func (m *SopStageMutation) ClearStatus() {
  22402. m.status = nil
  22403. m.addstatus = nil
  22404. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22405. }
  22406. // StatusCleared returns if the "status" field was cleared in this mutation.
  22407. func (m *SopStageMutation) StatusCleared() bool {
  22408. _, ok := m.clearedFields[sopstage.FieldStatus]
  22409. return ok
  22410. }
  22411. // ResetStatus resets all changes to the "status" field.
  22412. func (m *SopStageMutation) ResetStatus() {
  22413. m.status = nil
  22414. m.addstatus = nil
  22415. delete(m.clearedFields, sopstage.FieldStatus)
  22416. }
  22417. // SetDeletedAt sets the "deleted_at" field.
  22418. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22419. m.deleted_at = &t
  22420. }
  22421. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22422. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22423. v := m.deleted_at
  22424. if v == nil {
  22425. return
  22426. }
  22427. return *v, true
  22428. }
  22429. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22430. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22432. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22433. if !m.op.Is(OpUpdateOne) {
  22434. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22435. }
  22436. if m.id == nil || m.oldValue == nil {
  22437. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22438. }
  22439. oldValue, err := m.oldValue(ctx)
  22440. if err != nil {
  22441. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22442. }
  22443. return oldValue.DeletedAt, nil
  22444. }
  22445. // ClearDeletedAt clears the value of the "deleted_at" field.
  22446. func (m *SopStageMutation) ClearDeletedAt() {
  22447. m.deleted_at = nil
  22448. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22449. }
  22450. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22451. func (m *SopStageMutation) DeletedAtCleared() bool {
  22452. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22453. return ok
  22454. }
  22455. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22456. func (m *SopStageMutation) ResetDeletedAt() {
  22457. m.deleted_at = nil
  22458. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22459. }
  22460. // SetTaskID sets the "task_id" field.
  22461. func (m *SopStageMutation) SetTaskID(u uint64) {
  22462. m.sop_task = &u
  22463. }
  22464. // TaskID returns the value of the "task_id" field in the mutation.
  22465. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22466. v := m.sop_task
  22467. if v == nil {
  22468. return
  22469. }
  22470. return *v, true
  22471. }
  22472. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22473. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22475. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22476. if !m.op.Is(OpUpdateOne) {
  22477. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22478. }
  22479. if m.id == nil || m.oldValue == nil {
  22480. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22481. }
  22482. oldValue, err := m.oldValue(ctx)
  22483. if err != nil {
  22484. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22485. }
  22486. return oldValue.TaskID, nil
  22487. }
  22488. // ResetTaskID resets all changes to the "task_id" field.
  22489. func (m *SopStageMutation) ResetTaskID() {
  22490. m.sop_task = nil
  22491. }
  22492. // SetName sets the "name" field.
  22493. func (m *SopStageMutation) SetName(s string) {
  22494. m.name = &s
  22495. }
  22496. // Name returns the value of the "name" field in the mutation.
  22497. func (m *SopStageMutation) Name() (r string, exists bool) {
  22498. v := m.name
  22499. if v == nil {
  22500. return
  22501. }
  22502. return *v, true
  22503. }
  22504. // OldName returns the old "name" field's value of the SopStage entity.
  22505. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22507. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22508. if !m.op.Is(OpUpdateOne) {
  22509. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22510. }
  22511. if m.id == nil || m.oldValue == nil {
  22512. return v, errors.New("OldName requires an ID field in the mutation")
  22513. }
  22514. oldValue, err := m.oldValue(ctx)
  22515. if err != nil {
  22516. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22517. }
  22518. return oldValue.Name, nil
  22519. }
  22520. // ResetName resets all changes to the "name" field.
  22521. func (m *SopStageMutation) ResetName() {
  22522. m.name = nil
  22523. }
  22524. // SetConditionType sets the "condition_type" field.
  22525. func (m *SopStageMutation) SetConditionType(i int) {
  22526. m.condition_type = &i
  22527. m.addcondition_type = nil
  22528. }
  22529. // ConditionType returns the value of the "condition_type" field in the mutation.
  22530. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22531. v := m.condition_type
  22532. if v == nil {
  22533. return
  22534. }
  22535. return *v, true
  22536. }
  22537. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22538. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22540. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22541. if !m.op.Is(OpUpdateOne) {
  22542. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22543. }
  22544. if m.id == nil || m.oldValue == nil {
  22545. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22546. }
  22547. oldValue, err := m.oldValue(ctx)
  22548. if err != nil {
  22549. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22550. }
  22551. return oldValue.ConditionType, nil
  22552. }
  22553. // AddConditionType adds i to the "condition_type" field.
  22554. func (m *SopStageMutation) AddConditionType(i int) {
  22555. if m.addcondition_type != nil {
  22556. *m.addcondition_type += i
  22557. } else {
  22558. m.addcondition_type = &i
  22559. }
  22560. }
  22561. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22562. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22563. v := m.addcondition_type
  22564. if v == nil {
  22565. return
  22566. }
  22567. return *v, true
  22568. }
  22569. // ResetConditionType resets all changes to the "condition_type" field.
  22570. func (m *SopStageMutation) ResetConditionType() {
  22571. m.condition_type = nil
  22572. m.addcondition_type = nil
  22573. }
  22574. // SetConditionOperator sets the "condition_operator" field.
  22575. func (m *SopStageMutation) SetConditionOperator(i int) {
  22576. m.condition_operator = &i
  22577. m.addcondition_operator = nil
  22578. }
  22579. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22580. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22581. v := m.condition_operator
  22582. if v == nil {
  22583. return
  22584. }
  22585. return *v, true
  22586. }
  22587. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22588. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22590. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22591. if !m.op.Is(OpUpdateOne) {
  22592. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22593. }
  22594. if m.id == nil || m.oldValue == nil {
  22595. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22596. }
  22597. oldValue, err := m.oldValue(ctx)
  22598. if err != nil {
  22599. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22600. }
  22601. return oldValue.ConditionOperator, nil
  22602. }
  22603. // AddConditionOperator adds i to the "condition_operator" field.
  22604. func (m *SopStageMutation) AddConditionOperator(i int) {
  22605. if m.addcondition_operator != nil {
  22606. *m.addcondition_operator += i
  22607. } else {
  22608. m.addcondition_operator = &i
  22609. }
  22610. }
  22611. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22612. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22613. v := m.addcondition_operator
  22614. if v == nil {
  22615. return
  22616. }
  22617. return *v, true
  22618. }
  22619. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22620. func (m *SopStageMutation) ResetConditionOperator() {
  22621. m.condition_operator = nil
  22622. m.addcondition_operator = nil
  22623. }
  22624. // SetConditionList sets the "condition_list" field.
  22625. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22626. m.condition_list = &ct
  22627. m.appendcondition_list = nil
  22628. }
  22629. // ConditionList returns the value of the "condition_list" field in the mutation.
  22630. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22631. v := m.condition_list
  22632. if v == nil {
  22633. return
  22634. }
  22635. return *v, true
  22636. }
  22637. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22638. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22640. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22641. if !m.op.Is(OpUpdateOne) {
  22642. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22643. }
  22644. if m.id == nil || m.oldValue == nil {
  22645. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22646. }
  22647. oldValue, err := m.oldValue(ctx)
  22648. if err != nil {
  22649. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22650. }
  22651. return oldValue.ConditionList, nil
  22652. }
  22653. // AppendConditionList adds ct to the "condition_list" field.
  22654. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22655. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22656. }
  22657. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22658. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22659. if len(m.appendcondition_list) == 0 {
  22660. return nil, false
  22661. }
  22662. return m.appendcondition_list, true
  22663. }
  22664. // ResetConditionList resets all changes to the "condition_list" field.
  22665. func (m *SopStageMutation) ResetConditionList() {
  22666. m.condition_list = nil
  22667. m.appendcondition_list = nil
  22668. }
  22669. // SetActionMessage sets the "action_message" field.
  22670. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22671. m.action_message = &ct
  22672. m.appendaction_message = nil
  22673. }
  22674. // ActionMessage returns the value of the "action_message" field in the mutation.
  22675. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22676. v := m.action_message
  22677. if v == nil {
  22678. return
  22679. }
  22680. return *v, true
  22681. }
  22682. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22683. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22685. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22686. if !m.op.Is(OpUpdateOne) {
  22687. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22688. }
  22689. if m.id == nil || m.oldValue == nil {
  22690. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22691. }
  22692. oldValue, err := m.oldValue(ctx)
  22693. if err != nil {
  22694. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22695. }
  22696. return oldValue.ActionMessage, nil
  22697. }
  22698. // AppendActionMessage adds ct to the "action_message" field.
  22699. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22700. m.appendaction_message = append(m.appendaction_message, ct...)
  22701. }
  22702. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22703. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22704. if len(m.appendaction_message) == 0 {
  22705. return nil, false
  22706. }
  22707. return m.appendaction_message, true
  22708. }
  22709. // ClearActionMessage clears the value of the "action_message" field.
  22710. func (m *SopStageMutation) ClearActionMessage() {
  22711. m.action_message = nil
  22712. m.appendaction_message = nil
  22713. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22714. }
  22715. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22716. func (m *SopStageMutation) ActionMessageCleared() bool {
  22717. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22718. return ok
  22719. }
  22720. // ResetActionMessage resets all changes to the "action_message" field.
  22721. func (m *SopStageMutation) ResetActionMessage() {
  22722. m.action_message = nil
  22723. m.appendaction_message = nil
  22724. delete(m.clearedFields, sopstage.FieldActionMessage)
  22725. }
  22726. // SetActionLabelAdd sets the "action_label_add" field.
  22727. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22728. m.action_label_add = &u
  22729. m.appendaction_label_add = nil
  22730. }
  22731. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22732. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22733. v := m.action_label_add
  22734. if v == nil {
  22735. return
  22736. }
  22737. return *v, true
  22738. }
  22739. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22740. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22741. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22742. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22743. if !m.op.Is(OpUpdateOne) {
  22744. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22745. }
  22746. if m.id == nil || m.oldValue == nil {
  22747. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22748. }
  22749. oldValue, err := m.oldValue(ctx)
  22750. if err != nil {
  22751. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22752. }
  22753. return oldValue.ActionLabelAdd, nil
  22754. }
  22755. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22756. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22757. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22758. }
  22759. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22760. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22761. if len(m.appendaction_label_add) == 0 {
  22762. return nil, false
  22763. }
  22764. return m.appendaction_label_add, true
  22765. }
  22766. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22767. func (m *SopStageMutation) ClearActionLabelAdd() {
  22768. m.action_label_add = nil
  22769. m.appendaction_label_add = nil
  22770. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22771. }
  22772. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22773. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22774. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22775. return ok
  22776. }
  22777. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22778. func (m *SopStageMutation) ResetActionLabelAdd() {
  22779. m.action_label_add = nil
  22780. m.appendaction_label_add = nil
  22781. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22782. }
  22783. // SetActionLabelDel sets the "action_label_del" field.
  22784. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22785. m.action_label_del = &u
  22786. m.appendaction_label_del = nil
  22787. }
  22788. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22789. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22790. v := m.action_label_del
  22791. if v == nil {
  22792. return
  22793. }
  22794. return *v, true
  22795. }
  22796. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22797. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22799. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22800. if !m.op.Is(OpUpdateOne) {
  22801. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22802. }
  22803. if m.id == nil || m.oldValue == nil {
  22804. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22805. }
  22806. oldValue, err := m.oldValue(ctx)
  22807. if err != nil {
  22808. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22809. }
  22810. return oldValue.ActionLabelDel, nil
  22811. }
  22812. // AppendActionLabelDel adds u to the "action_label_del" field.
  22813. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22814. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22815. }
  22816. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22817. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22818. if len(m.appendaction_label_del) == 0 {
  22819. return nil, false
  22820. }
  22821. return m.appendaction_label_del, true
  22822. }
  22823. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22824. func (m *SopStageMutation) ClearActionLabelDel() {
  22825. m.action_label_del = nil
  22826. m.appendaction_label_del = nil
  22827. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22828. }
  22829. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22830. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22831. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22832. return ok
  22833. }
  22834. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22835. func (m *SopStageMutation) ResetActionLabelDel() {
  22836. m.action_label_del = nil
  22837. m.appendaction_label_del = nil
  22838. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22839. }
  22840. // SetActionForward sets the "action_forward" field.
  22841. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22842. m.action_forward = &ctf
  22843. }
  22844. // ActionForward returns the value of the "action_forward" field in the mutation.
  22845. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22846. v := m.action_forward
  22847. if v == nil {
  22848. return
  22849. }
  22850. return *v, true
  22851. }
  22852. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22853. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22855. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22856. if !m.op.Is(OpUpdateOne) {
  22857. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22858. }
  22859. if m.id == nil || m.oldValue == nil {
  22860. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22861. }
  22862. oldValue, err := m.oldValue(ctx)
  22863. if err != nil {
  22864. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22865. }
  22866. return oldValue.ActionForward, nil
  22867. }
  22868. // ClearActionForward clears the value of the "action_forward" field.
  22869. func (m *SopStageMutation) ClearActionForward() {
  22870. m.action_forward = nil
  22871. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22872. }
  22873. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22874. func (m *SopStageMutation) ActionForwardCleared() bool {
  22875. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22876. return ok
  22877. }
  22878. // ResetActionForward resets all changes to the "action_forward" field.
  22879. func (m *SopStageMutation) ResetActionForward() {
  22880. m.action_forward = nil
  22881. delete(m.clearedFields, sopstage.FieldActionForward)
  22882. }
  22883. // SetIndexSort sets the "index_sort" field.
  22884. func (m *SopStageMutation) SetIndexSort(i int) {
  22885. m.index_sort = &i
  22886. m.addindex_sort = nil
  22887. }
  22888. // IndexSort returns the value of the "index_sort" field in the mutation.
  22889. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22890. v := m.index_sort
  22891. if v == nil {
  22892. return
  22893. }
  22894. return *v, true
  22895. }
  22896. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22897. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22898. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22899. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22900. if !m.op.Is(OpUpdateOne) {
  22901. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22902. }
  22903. if m.id == nil || m.oldValue == nil {
  22904. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22905. }
  22906. oldValue, err := m.oldValue(ctx)
  22907. if err != nil {
  22908. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22909. }
  22910. return oldValue.IndexSort, nil
  22911. }
  22912. // AddIndexSort adds i to the "index_sort" field.
  22913. func (m *SopStageMutation) AddIndexSort(i int) {
  22914. if m.addindex_sort != nil {
  22915. *m.addindex_sort += i
  22916. } else {
  22917. m.addindex_sort = &i
  22918. }
  22919. }
  22920. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22921. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22922. v := m.addindex_sort
  22923. if v == nil {
  22924. return
  22925. }
  22926. return *v, true
  22927. }
  22928. // ClearIndexSort clears the value of the "index_sort" field.
  22929. func (m *SopStageMutation) ClearIndexSort() {
  22930. m.index_sort = nil
  22931. m.addindex_sort = nil
  22932. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22933. }
  22934. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22935. func (m *SopStageMutation) IndexSortCleared() bool {
  22936. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22937. return ok
  22938. }
  22939. // ResetIndexSort resets all changes to the "index_sort" field.
  22940. func (m *SopStageMutation) ResetIndexSort() {
  22941. m.index_sort = nil
  22942. m.addindex_sort = nil
  22943. delete(m.clearedFields, sopstage.FieldIndexSort)
  22944. }
  22945. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22946. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22947. m.sop_task = &id
  22948. }
  22949. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22950. func (m *SopStageMutation) ClearSopTask() {
  22951. m.clearedsop_task = true
  22952. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22953. }
  22954. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22955. func (m *SopStageMutation) SopTaskCleared() bool {
  22956. return m.clearedsop_task
  22957. }
  22958. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22959. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22960. if m.sop_task != nil {
  22961. return *m.sop_task, true
  22962. }
  22963. return
  22964. }
  22965. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22966. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22967. // SopTaskID instead. It exists only for internal usage by the builders.
  22968. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22969. if id := m.sop_task; id != nil {
  22970. ids = append(ids, *id)
  22971. }
  22972. return
  22973. }
  22974. // ResetSopTask resets all changes to the "sop_task" edge.
  22975. func (m *SopStageMutation) ResetSopTask() {
  22976. m.sop_task = nil
  22977. m.clearedsop_task = false
  22978. }
  22979. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22980. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22981. if m.stage_nodes == nil {
  22982. m.stage_nodes = make(map[uint64]struct{})
  22983. }
  22984. for i := range ids {
  22985. m.stage_nodes[ids[i]] = struct{}{}
  22986. }
  22987. }
  22988. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22989. func (m *SopStageMutation) ClearStageNodes() {
  22990. m.clearedstage_nodes = true
  22991. }
  22992. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22993. func (m *SopStageMutation) StageNodesCleared() bool {
  22994. return m.clearedstage_nodes
  22995. }
  22996. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22997. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22998. if m.removedstage_nodes == nil {
  22999. m.removedstage_nodes = make(map[uint64]struct{})
  23000. }
  23001. for i := range ids {
  23002. delete(m.stage_nodes, ids[i])
  23003. m.removedstage_nodes[ids[i]] = struct{}{}
  23004. }
  23005. }
  23006. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  23007. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  23008. for id := range m.removedstage_nodes {
  23009. ids = append(ids, id)
  23010. }
  23011. return
  23012. }
  23013. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  23014. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  23015. for id := range m.stage_nodes {
  23016. ids = append(ids, id)
  23017. }
  23018. return
  23019. }
  23020. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  23021. func (m *SopStageMutation) ResetStageNodes() {
  23022. m.stage_nodes = nil
  23023. m.clearedstage_nodes = false
  23024. m.removedstage_nodes = nil
  23025. }
  23026. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  23027. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  23028. if m.stage_messages == nil {
  23029. m.stage_messages = make(map[uint64]struct{})
  23030. }
  23031. for i := range ids {
  23032. m.stage_messages[ids[i]] = struct{}{}
  23033. }
  23034. }
  23035. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  23036. func (m *SopStageMutation) ClearStageMessages() {
  23037. m.clearedstage_messages = true
  23038. }
  23039. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  23040. func (m *SopStageMutation) StageMessagesCleared() bool {
  23041. return m.clearedstage_messages
  23042. }
  23043. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  23044. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  23045. if m.removedstage_messages == nil {
  23046. m.removedstage_messages = make(map[uint64]struct{})
  23047. }
  23048. for i := range ids {
  23049. delete(m.stage_messages, ids[i])
  23050. m.removedstage_messages[ids[i]] = struct{}{}
  23051. }
  23052. }
  23053. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  23054. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  23055. for id := range m.removedstage_messages {
  23056. ids = append(ids, id)
  23057. }
  23058. return
  23059. }
  23060. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  23061. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  23062. for id := range m.stage_messages {
  23063. ids = append(ids, id)
  23064. }
  23065. return
  23066. }
  23067. // ResetStageMessages resets all changes to the "stage_messages" edge.
  23068. func (m *SopStageMutation) ResetStageMessages() {
  23069. m.stage_messages = nil
  23070. m.clearedstage_messages = false
  23071. m.removedstage_messages = nil
  23072. }
  23073. // Where appends a list predicates to the SopStageMutation builder.
  23074. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  23075. m.predicates = append(m.predicates, ps...)
  23076. }
  23077. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23078. // users can use type-assertion to append predicates that do not depend on any generated package.
  23079. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23080. p := make([]predicate.SopStage, len(ps))
  23081. for i := range ps {
  23082. p[i] = ps[i]
  23083. }
  23084. m.Where(p...)
  23085. }
  23086. // Op returns the operation name.
  23087. func (m *SopStageMutation) Op() Op {
  23088. return m.op
  23089. }
  23090. // SetOp allows setting the mutation operation.
  23091. func (m *SopStageMutation) SetOp(op Op) {
  23092. m.op = op
  23093. }
  23094. // Type returns the node type of this mutation (SopStage).
  23095. func (m *SopStageMutation) Type() string {
  23096. return m.typ
  23097. }
  23098. // Fields returns all fields that were changed during this mutation. Note that in
  23099. // order to get all numeric fields that were incremented/decremented, call
  23100. // AddedFields().
  23101. func (m *SopStageMutation) Fields() []string {
  23102. fields := make([]string, 0, 14)
  23103. if m.created_at != nil {
  23104. fields = append(fields, sopstage.FieldCreatedAt)
  23105. }
  23106. if m.updated_at != nil {
  23107. fields = append(fields, sopstage.FieldUpdatedAt)
  23108. }
  23109. if m.status != nil {
  23110. fields = append(fields, sopstage.FieldStatus)
  23111. }
  23112. if m.deleted_at != nil {
  23113. fields = append(fields, sopstage.FieldDeletedAt)
  23114. }
  23115. if m.sop_task != nil {
  23116. fields = append(fields, sopstage.FieldTaskID)
  23117. }
  23118. if m.name != nil {
  23119. fields = append(fields, sopstage.FieldName)
  23120. }
  23121. if m.condition_type != nil {
  23122. fields = append(fields, sopstage.FieldConditionType)
  23123. }
  23124. if m.condition_operator != nil {
  23125. fields = append(fields, sopstage.FieldConditionOperator)
  23126. }
  23127. if m.condition_list != nil {
  23128. fields = append(fields, sopstage.FieldConditionList)
  23129. }
  23130. if m.action_message != nil {
  23131. fields = append(fields, sopstage.FieldActionMessage)
  23132. }
  23133. if m.action_label_add != nil {
  23134. fields = append(fields, sopstage.FieldActionLabelAdd)
  23135. }
  23136. if m.action_label_del != nil {
  23137. fields = append(fields, sopstage.FieldActionLabelDel)
  23138. }
  23139. if m.action_forward != nil {
  23140. fields = append(fields, sopstage.FieldActionForward)
  23141. }
  23142. if m.index_sort != nil {
  23143. fields = append(fields, sopstage.FieldIndexSort)
  23144. }
  23145. return fields
  23146. }
  23147. // Field returns the value of a field with the given name. The second boolean
  23148. // return value indicates that this field was not set, or was not defined in the
  23149. // schema.
  23150. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23151. switch name {
  23152. case sopstage.FieldCreatedAt:
  23153. return m.CreatedAt()
  23154. case sopstage.FieldUpdatedAt:
  23155. return m.UpdatedAt()
  23156. case sopstage.FieldStatus:
  23157. return m.Status()
  23158. case sopstage.FieldDeletedAt:
  23159. return m.DeletedAt()
  23160. case sopstage.FieldTaskID:
  23161. return m.TaskID()
  23162. case sopstage.FieldName:
  23163. return m.Name()
  23164. case sopstage.FieldConditionType:
  23165. return m.ConditionType()
  23166. case sopstage.FieldConditionOperator:
  23167. return m.ConditionOperator()
  23168. case sopstage.FieldConditionList:
  23169. return m.ConditionList()
  23170. case sopstage.FieldActionMessage:
  23171. return m.ActionMessage()
  23172. case sopstage.FieldActionLabelAdd:
  23173. return m.ActionLabelAdd()
  23174. case sopstage.FieldActionLabelDel:
  23175. return m.ActionLabelDel()
  23176. case sopstage.FieldActionForward:
  23177. return m.ActionForward()
  23178. case sopstage.FieldIndexSort:
  23179. return m.IndexSort()
  23180. }
  23181. return nil, false
  23182. }
  23183. // OldField returns the old value of the field from the database. An error is
  23184. // returned if the mutation operation is not UpdateOne, or the query to the
  23185. // database failed.
  23186. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23187. switch name {
  23188. case sopstage.FieldCreatedAt:
  23189. return m.OldCreatedAt(ctx)
  23190. case sopstage.FieldUpdatedAt:
  23191. return m.OldUpdatedAt(ctx)
  23192. case sopstage.FieldStatus:
  23193. return m.OldStatus(ctx)
  23194. case sopstage.FieldDeletedAt:
  23195. return m.OldDeletedAt(ctx)
  23196. case sopstage.FieldTaskID:
  23197. return m.OldTaskID(ctx)
  23198. case sopstage.FieldName:
  23199. return m.OldName(ctx)
  23200. case sopstage.FieldConditionType:
  23201. return m.OldConditionType(ctx)
  23202. case sopstage.FieldConditionOperator:
  23203. return m.OldConditionOperator(ctx)
  23204. case sopstage.FieldConditionList:
  23205. return m.OldConditionList(ctx)
  23206. case sopstage.FieldActionMessage:
  23207. return m.OldActionMessage(ctx)
  23208. case sopstage.FieldActionLabelAdd:
  23209. return m.OldActionLabelAdd(ctx)
  23210. case sopstage.FieldActionLabelDel:
  23211. return m.OldActionLabelDel(ctx)
  23212. case sopstage.FieldActionForward:
  23213. return m.OldActionForward(ctx)
  23214. case sopstage.FieldIndexSort:
  23215. return m.OldIndexSort(ctx)
  23216. }
  23217. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23218. }
  23219. // SetField sets the value of a field with the given name. It returns an error if
  23220. // the field is not defined in the schema, or if the type mismatched the field
  23221. // type.
  23222. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23223. switch name {
  23224. case sopstage.FieldCreatedAt:
  23225. v, ok := value.(time.Time)
  23226. if !ok {
  23227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23228. }
  23229. m.SetCreatedAt(v)
  23230. return nil
  23231. case sopstage.FieldUpdatedAt:
  23232. v, ok := value.(time.Time)
  23233. if !ok {
  23234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23235. }
  23236. m.SetUpdatedAt(v)
  23237. return nil
  23238. case sopstage.FieldStatus:
  23239. v, ok := value.(uint8)
  23240. if !ok {
  23241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23242. }
  23243. m.SetStatus(v)
  23244. return nil
  23245. case sopstage.FieldDeletedAt:
  23246. v, ok := value.(time.Time)
  23247. if !ok {
  23248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23249. }
  23250. m.SetDeletedAt(v)
  23251. return nil
  23252. case sopstage.FieldTaskID:
  23253. v, ok := value.(uint64)
  23254. if !ok {
  23255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23256. }
  23257. m.SetTaskID(v)
  23258. return nil
  23259. case sopstage.FieldName:
  23260. v, ok := value.(string)
  23261. if !ok {
  23262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23263. }
  23264. m.SetName(v)
  23265. return nil
  23266. case sopstage.FieldConditionType:
  23267. v, ok := value.(int)
  23268. if !ok {
  23269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23270. }
  23271. m.SetConditionType(v)
  23272. return nil
  23273. case sopstage.FieldConditionOperator:
  23274. v, ok := value.(int)
  23275. if !ok {
  23276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23277. }
  23278. m.SetConditionOperator(v)
  23279. return nil
  23280. case sopstage.FieldConditionList:
  23281. v, ok := value.([]custom_types.Condition)
  23282. if !ok {
  23283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23284. }
  23285. m.SetConditionList(v)
  23286. return nil
  23287. case sopstage.FieldActionMessage:
  23288. v, ok := value.([]custom_types.Action)
  23289. if !ok {
  23290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23291. }
  23292. m.SetActionMessage(v)
  23293. return nil
  23294. case sopstage.FieldActionLabelAdd:
  23295. v, ok := value.([]uint64)
  23296. if !ok {
  23297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23298. }
  23299. m.SetActionLabelAdd(v)
  23300. return nil
  23301. case sopstage.FieldActionLabelDel:
  23302. v, ok := value.([]uint64)
  23303. if !ok {
  23304. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23305. }
  23306. m.SetActionLabelDel(v)
  23307. return nil
  23308. case sopstage.FieldActionForward:
  23309. v, ok := value.(*custom_types.ActionForward)
  23310. if !ok {
  23311. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23312. }
  23313. m.SetActionForward(v)
  23314. return nil
  23315. case sopstage.FieldIndexSort:
  23316. v, ok := value.(int)
  23317. if !ok {
  23318. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23319. }
  23320. m.SetIndexSort(v)
  23321. return nil
  23322. }
  23323. return fmt.Errorf("unknown SopStage field %s", name)
  23324. }
  23325. // AddedFields returns all numeric fields that were incremented/decremented during
  23326. // this mutation.
  23327. func (m *SopStageMutation) AddedFields() []string {
  23328. var fields []string
  23329. if m.addstatus != nil {
  23330. fields = append(fields, sopstage.FieldStatus)
  23331. }
  23332. if m.addcondition_type != nil {
  23333. fields = append(fields, sopstage.FieldConditionType)
  23334. }
  23335. if m.addcondition_operator != nil {
  23336. fields = append(fields, sopstage.FieldConditionOperator)
  23337. }
  23338. if m.addindex_sort != nil {
  23339. fields = append(fields, sopstage.FieldIndexSort)
  23340. }
  23341. return fields
  23342. }
  23343. // AddedField returns the numeric value that was incremented/decremented on a field
  23344. // with the given name. The second boolean return value indicates that this field
  23345. // was not set, or was not defined in the schema.
  23346. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23347. switch name {
  23348. case sopstage.FieldStatus:
  23349. return m.AddedStatus()
  23350. case sopstage.FieldConditionType:
  23351. return m.AddedConditionType()
  23352. case sopstage.FieldConditionOperator:
  23353. return m.AddedConditionOperator()
  23354. case sopstage.FieldIndexSort:
  23355. return m.AddedIndexSort()
  23356. }
  23357. return nil, false
  23358. }
  23359. // AddField adds the value to the field with the given name. It returns an error if
  23360. // the field is not defined in the schema, or if the type mismatched the field
  23361. // type.
  23362. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23363. switch name {
  23364. case sopstage.FieldStatus:
  23365. v, ok := value.(int8)
  23366. if !ok {
  23367. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23368. }
  23369. m.AddStatus(v)
  23370. return nil
  23371. case sopstage.FieldConditionType:
  23372. v, ok := value.(int)
  23373. if !ok {
  23374. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23375. }
  23376. m.AddConditionType(v)
  23377. return nil
  23378. case sopstage.FieldConditionOperator:
  23379. v, ok := value.(int)
  23380. if !ok {
  23381. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23382. }
  23383. m.AddConditionOperator(v)
  23384. return nil
  23385. case sopstage.FieldIndexSort:
  23386. v, ok := value.(int)
  23387. if !ok {
  23388. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23389. }
  23390. m.AddIndexSort(v)
  23391. return nil
  23392. }
  23393. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23394. }
  23395. // ClearedFields returns all nullable fields that were cleared during this
  23396. // mutation.
  23397. func (m *SopStageMutation) ClearedFields() []string {
  23398. var fields []string
  23399. if m.FieldCleared(sopstage.FieldStatus) {
  23400. fields = append(fields, sopstage.FieldStatus)
  23401. }
  23402. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23403. fields = append(fields, sopstage.FieldDeletedAt)
  23404. }
  23405. if m.FieldCleared(sopstage.FieldActionMessage) {
  23406. fields = append(fields, sopstage.FieldActionMessage)
  23407. }
  23408. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23409. fields = append(fields, sopstage.FieldActionLabelAdd)
  23410. }
  23411. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23412. fields = append(fields, sopstage.FieldActionLabelDel)
  23413. }
  23414. if m.FieldCleared(sopstage.FieldActionForward) {
  23415. fields = append(fields, sopstage.FieldActionForward)
  23416. }
  23417. if m.FieldCleared(sopstage.FieldIndexSort) {
  23418. fields = append(fields, sopstage.FieldIndexSort)
  23419. }
  23420. return fields
  23421. }
  23422. // FieldCleared returns a boolean indicating if a field with the given name was
  23423. // cleared in this mutation.
  23424. func (m *SopStageMutation) FieldCleared(name string) bool {
  23425. _, ok := m.clearedFields[name]
  23426. return ok
  23427. }
  23428. // ClearField clears the value of the field with the given name. It returns an
  23429. // error if the field is not defined in the schema.
  23430. func (m *SopStageMutation) ClearField(name string) error {
  23431. switch name {
  23432. case sopstage.FieldStatus:
  23433. m.ClearStatus()
  23434. return nil
  23435. case sopstage.FieldDeletedAt:
  23436. m.ClearDeletedAt()
  23437. return nil
  23438. case sopstage.FieldActionMessage:
  23439. m.ClearActionMessage()
  23440. return nil
  23441. case sopstage.FieldActionLabelAdd:
  23442. m.ClearActionLabelAdd()
  23443. return nil
  23444. case sopstage.FieldActionLabelDel:
  23445. m.ClearActionLabelDel()
  23446. return nil
  23447. case sopstage.FieldActionForward:
  23448. m.ClearActionForward()
  23449. return nil
  23450. case sopstage.FieldIndexSort:
  23451. m.ClearIndexSort()
  23452. return nil
  23453. }
  23454. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23455. }
  23456. // ResetField resets all changes in the mutation for the field with the given name.
  23457. // It returns an error if the field is not defined in the schema.
  23458. func (m *SopStageMutation) ResetField(name string) error {
  23459. switch name {
  23460. case sopstage.FieldCreatedAt:
  23461. m.ResetCreatedAt()
  23462. return nil
  23463. case sopstage.FieldUpdatedAt:
  23464. m.ResetUpdatedAt()
  23465. return nil
  23466. case sopstage.FieldStatus:
  23467. m.ResetStatus()
  23468. return nil
  23469. case sopstage.FieldDeletedAt:
  23470. m.ResetDeletedAt()
  23471. return nil
  23472. case sopstage.FieldTaskID:
  23473. m.ResetTaskID()
  23474. return nil
  23475. case sopstage.FieldName:
  23476. m.ResetName()
  23477. return nil
  23478. case sopstage.FieldConditionType:
  23479. m.ResetConditionType()
  23480. return nil
  23481. case sopstage.FieldConditionOperator:
  23482. m.ResetConditionOperator()
  23483. return nil
  23484. case sopstage.FieldConditionList:
  23485. m.ResetConditionList()
  23486. return nil
  23487. case sopstage.FieldActionMessage:
  23488. m.ResetActionMessage()
  23489. return nil
  23490. case sopstage.FieldActionLabelAdd:
  23491. m.ResetActionLabelAdd()
  23492. return nil
  23493. case sopstage.FieldActionLabelDel:
  23494. m.ResetActionLabelDel()
  23495. return nil
  23496. case sopstage.FieldActionForward:
  23497. m.ResetActionForward()
  23498. return nil
  23499. case sopstage.FieldIndexSort:
  23500. m.ResetIndexSort()
  23501. return nil
  23502. }
  23503. return fmt.Errorf("unknown SopStage field %s", name)
  23504. }
  23505. // AddedEdges returns all edge names that were set/added in this mutation.
  23506. func (m *SopStageMutation) AddedEdges() []string {
  23507. edges := make([]string, 0, 3)
  23508. if m.sop_task != nil {
  23509. edges = append(edges, sopstage.EdgeSopTask)
  23510. }
  23511. if m.stage_nodes != nil {
  23512. edges = append(edges, sopstage.EdgeStageNodes)
  23513. }
  23514. if m.stage_messages != nil {
  23515. edges = append(edges, sopstage.EdgeStageMessages)
  23516. }
  23517. return edges
  23518. }
  23519. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23520. // name in this mutation.
  23521. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23522. switch name {
  23523. case sopstage.EdgeSopTask:
  23524. if id := m.sop_task; id != nil {
  23525. return []ent.Value{*id}
  23526. }
  23527. case sopstage.EdgeStageNodes:
  23528. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23529. for id := range m.stage_nodes {
  23530. ids = append(ids, id)
  23531. }
  23532. return ids
  23533. case sopstage.EdgeStageMessages:
  23534. ids := make([]ent.Value, 0, len(m.stage_messages))
  23535. for id := range m.stage_messages {
  23536. ids = append(ids, id)
  23537. }
  23538. return ids
  23539. }
  23540. return nil
  23541. }
  23542. // RemovedEdges returns all edge names that were removed in this mutation.
  23543. func (m *SopStageMutation) RemovedEdges() []string {
  23544. edges := make([]string, 0, 3)
  23545. if m.removedstage_nodes != nil {
  23546. edges = append(edges, sopstage.EdgeStageNodes)
  23547. }
  23548. if m.removedstage_messages != nil {
  23549. edges = append(edges, sopstage.EdgeStageMessages)
  23550. }
  23551. return edges
  23552. }
  23553. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23554. // the given name in this mutation.
  23555. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23556. switch name {
  23557. case sopstage.EdgeStageNodes:
  23558. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23559. for id := range m.removedstage_nodes {
  23560. ids = append(ids, id)
  23561. }
  23562. return ids
  23563. case sopstage.EdgeStageMessages:
  23564. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23565. for id := range m.removedstage_messages {
  23566. ids = append(ids, id)
  23567. }
  23568. return ids
  23569. }
  23570. return nil
  23571. }
  23572. // ClearedEdges returns all edge names that were cleared in this mutation.
  23573. func (m *SopStageMutation) ClearedEdges() []string {
  23574. edges := make([]string, 0, 3)
  23575. if m.clearedsop_task {
  23576. edges = append(edges, sopstage.EdgeSopTask)
  23577. }
  23578. if m.clearedstage_nodes {
  23579. edges = append(edges, sopstage.EdgeStageNodes)
  23580. }
  23581. if m.clearedstage_messages {
  23582. edges = append(edges, sopstage.EdgeStageMessages)
  23583. }
  23584. return edges
  23585. }
  23586. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23587. // was cleared in this mutation.
  23588. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23589. switch name {
  23590. case sopstage.EdgeSopTask:
  23591. return m.clearedsop_task
  23592. case sopstage.EdgeStageNodes:
  23593. return m.clearedstage_nodes
  23594. case sopstage.EdgeStageMessages:
  23595. return m.clearedstage_messages
  23596. }
  23597. return false
  23598. }
  23599. // ClearEdge clears the value of the edge with the given name. It returns an error
  23600. // if that edge is not defined in the schema.
  23601. func (m *SopStageMutation) ClearEdge(name string) error {
  23602. switch name {
  23603. case sopstage.EdgeSopTask:
  23604. m.ClearSopTask()
  23605. return nil
  23606. }
  23607. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23608. }
  23609. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23610. // It returns an error if the edge is not defined in the schema.
  23611. func (m *SopStageMutation) ResetEdge(name string) error {
  23612. switch name {
  23613. case sopstage.EdgeSopTask:
  23614. m.ResetSopTask()
  23615. return nil
  23616. case sopstage.EdgeStageNodes:
  23617. m.ResetStageNodes()
  23618. return nil
  23619. case sopstage.EdgeStageMessages:
  23620. m.ResetStageMessages()
  23621. return nil
  23622. }
  23623. return fmt.Errorf("unknown SopStage edge %s", name)
  23624. }
  23625. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23626. type SopTaskMutation struct {
  23627. config
  23628. op Op
  23629. typ string
  23630. id *uint64
  23631. created_at *time.Time
  23632. updated_at *time.Time
  23633. status *uint8
  23634. addstatus *int8
  23635. deleted_at *time.Time
  23636. name *string
  23637. bot_wxid_list *[]string
  23638. appendbot_wxid_list []string
  23639. _type *int
  23640. add_type *int
  23641. plan_start_time *time.Time
  23642. plan_end_time *time.Time
  23643. creator_id *string
  23644. organization_id *uint64
  23645. addorganization_id *int64
  23646. token *[]string
  23647. appendtoken []string
  23648. clearedFields map[string]struct{}
  23649. task_stages map[uint64]struct{}
  23650. removedtask_stages map[uint64]struct{}
  23651. clearedtask_stages bool
  23652. done bool
  23653. oldValue func(context.Context) (*SopTask, error)
  23654. predicates []predicate.SopTask
  23655. }
  23656. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23657. // soptaskOption allows management of the mutation configuration using functional options.
  23658. type soptaskOption func(*SopTaskMutation)
  23659. // newSopTaskMutation creates new mutation for the SopTask entity.
  23660. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23661. m := &SopTaskMutation{
  23662. config: c,
  23663. op: op,
  23664. typ: TypeSopTask,
  23665. clearedFields: make(map[string]struct{}),
  23666. }
  23667. for _, opt := range opts {
  23668. opt(m)
  23669. }
  23670. return m
  23671. }
  23672. // withSopTaskID sets the ID field of the mutation.
  23673. func withSopTaskID(id uint64) soptaskOption {
  23674. return func(m *SopTaskMutation) {
  23675. var (
  23676. err error
  23677. once sync.Once
  23678. value *SopTask
  23679. )
  23680. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23681. once.Do(func() {
  23682. if m.done {
  23683. err = errors.New("querying old values post mutation is not allowed")
  23684. } else {
  23685. value, err = m.Client().SopTask.Get(ctx, id)
  23686. }
  23687. })
  23688. return value, err
  23689. }
  23690. m.id = &id
  23691. }
  23692. }
  23693. // withSopTask sets the old SopTask of the mutation.
  23694. func withSopTask(node *SopTask) soptaskOption {
  23695. return func(m *SopTaskMutation) {
  23696. m.oldValue = func(context.Context) (*SopTask, error) {
  23697. return node, nil
  23698. }
  23699. m.id = &node.ID
  23700. }
  23701. }
  23702. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23703. // executed in a transaction (ent.Tx), a transactional client is returned.
  23704. func (m SopTaskMutation) Client() *Client {
  23705. client := &Client{config: m.config}
  23706. client.init()
  23707. return client
  23708. }
  23709. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23710. // it returns an error otherwise.
  23711. func (m SopTaskMutation) Tx() (*Tx, error) {
  23712. if _, ok := m.driver.(*txDriver); !ok {
  23713. return nil, errors.New("ent: mutation is not running in a transaction")
  23714. }
  23715. tx := &Tx{config: m.config}
  23716. tx.init()
  23717. return tx, nil
  23718. }
  23719. // SetID sets the value of the id field. Note that this
  23720. // operation is only accepted on creation of SopTask entities.
  23721. func (m *SopTaskMutation) SetID(id uint64) {
  23722. m.id = &id
  23723. }
  23724. // ID returns the ID value in the mutation. Note that the ID is only available
  23725. // if it was provided to the builder or after it was returned from the database.
  23726. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23727. if m.id == nil {
  23728. return
  23729. }
  23730. return *m.id, true
  23731. }
  23732. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23733. // That means, if the mutation is applied within a transaction with an isolation level such
  23734. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23735. // or updated by the mutation.
  23736. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23737. switch {
  23738. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23739. id, exists := m.ID()
  23740. if exists {
  23741. return []uint64{id}, nil
  23742. }
  23743. fallthrough
  23744. case m.op.Is(OpUpdate | OpDelete):
  23745. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23746. default:
  23747. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23748. }
  23749. }
  23750. // SetCreatedAt sets the "created_at" field.
  23751. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23752. m.created_at = &t
  23753. }
  23754. // CreatedAt returns the value of the "created_at" field in the mutation.
  23755. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23756. v := m.created_at
  23757. if v == nil {
  23758. return
  23759. }
  23760. return *v, true
  23761. }
  23762. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23763. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23765. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23766. if !m.op.Is(OpUpdateOne) {
  23767. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23768. }
  23769. if m.id == nil || m.oldValue == nil {
  23770. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23771. }
  23772. oldValue, err := m.oldValue(ctx)
  23773. if err != nil {
  23774. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23775. }
  23776. return oldValue.CreatedAt, nil
  23777. }
  23778. // ResetCreatedAt resets all changes to the "created_at" field.
  23779. func (m *SopTaskMutation) ResetCreatedAt() {
  23780. m.created_at = nil
  23781. }
  23782. // SetUpdatedAt sets the "updated_at" field.
  23783. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23784. m.updated_at = &t
  23785. }
  23786. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23787. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23788. v := m.updated_at
  23789. if v == nil {
  23790. return
  23791. }
  23792. return *v, true
  23793. }
  23794. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23795. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23797. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23798. if !m.op.Is(OpUpdateOne) {
  23799. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23800. }
  23801. if m.id == nil || m.oldValue == nil {
  23802. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23803. }
  23804. oldValue, err := m.oldValue(ctx)
  23805. if err != nil {
  23806. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23807. }
  23808. return oldValue.UpdatedAt, nil
  23809. }
  23810. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23811. func (m *SopTaskMutation) ResetUpdatedAt() {
  23812. m.updated_at = nil
  23813. }
  23814. // SetStatus sets the "status" field.
  23815. func (m *SopTaskMutation) SetStatus(u uint8) {
  23816. m.status = &u
  23817. m.addstatus = nil
  23818. }
  23819. // Status returns the value of the "status" field in the mutation.
  23820. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23821. v := m.status
  23822. if v == nil {
  23823. return
  23824. }
  23825. return *v, true
  23826. }
  23827. // OldStatus returns the old "status" field's value of the SopTask entity.
  23828. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23829. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23830. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23831. if !m.op.Is(OpUpdateOne) {
  23832. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23833. }
  23834. if m.id == nil || m.oldValue == nil {
  23835. return v, errors.New("OldStatus requires an ID field in the mutation")
  23836. }
  23837. oldValue, err := m.oldValue(ctx)
  23838. if err != nil {
  23839. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23840. }
  23841. return oldValue.Status, nil
  23842. }
  23843. // AddStatus adds u to the "status" field.
  23844. func (m *SopTaskMutation) AddStatus(u int8) {
  23845. if m.addstatus != nil {
  23846. *m.addstatus += u
  23847. } else {
  23848. m.addstatus = &u
  23849. }
  23850. }
  23851. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23852. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23853. v := m.addstatus
  23854. if v == nil {
  23855. return
  23856. }
  23857. return *v, true
  23858. }
  23859. // ClearStatus clears the value of the "status" field.
  23860. func (m *SopTaskMutation) ClearStatus() {
  23861. m.status = nil
  23862. m.addstatus = nil
  23863. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23864. }
  23865. // StatusCleared returns if the "status" field was cleared in this mutation.
  23866. func (m *SopTaskMutation) StatusCleared() bool {
  23867. _, ok := m.clearedFields[soptask.FieldStatus]
  23868. return ok
  23869. }
  23870. // ResetStatus resets all changes to the "status" field.
  23871. func (m *SopTaskMutation) ResetStatus() {
  23872. m.status = nil
  23873. m.addstatus = nil
  23874. delete(m.clearedFields, soptask.FieldStatus)
  23875. }
  23876. // SetDeletedAt sets the "deleted_at" field.
  23877. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23878. m.deleted_at = &t
  23879. }
  23880. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23881. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23882. v := m.deleted_at
  23883. if v == nil {
  23884. return
  23885. }
  23886. return *v, true
  23887. }
  23888. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23889. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23891. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23892. if !m.op.Is(OpUpdateOne) {
  23893. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23894. }
  23895. if m.id == nil || m.oldValue == nil {
  23896. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23897. }
  23898. oldValue, err := m.oldValue(ctx)
  23899. if err != nil {
  23900. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23901. }
  23902. return oldValue.DeletedAt, nil
  23903. }
  23904. // ClearDeletedAt clears the value of the "deleted_at" field.
  23905. func (m *SopTaskMutation) ClearDeletedAt() {
  23906. m.deleted_at = nil
  23907. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23908. }
  23909. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23910. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23911. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23912. return ok
  23913. }
  23914. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23915. func (m *SopTaskMutation) ResetDeletedAt() {
  23916. m.deleted_at = nil
  23917. delete(m.clearedFields, soptask.FieldDeletedAt)
  23918. }
  23919. // SetName sets the "name" field.
  23920. func (m *SopTaskMutation) SetName(s string) {
  23921. m.name = &s
  23922. }
  23923. // Name returns the value of the "name" field in the mutation.
  23924. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23925. v := m.name
  23926. if v == nil {
  23927. return
  23928. }
  23929. return *v, true
  23930. }
  23931. // OldName returns the old "name" field's value of the SopTask entity.
  23932. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23933. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23934. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23935. if !m.op.Is(OpUpdateOne) {
  23936. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23937. }
  23938. if m.id == nil || m.oldValue == nil {
  23939. return v, errors.New("OldName requires an ID field in the mutation")
  23940. }
  23941. oldValue, err := m.oldValue(ctx)
  23942. if err != nil {
  23943. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23944. }
  23945. return oldValue.Name, nil
  23946. }
  23947. // ResetName resets all changes to the "name" field.
  23948. func (m *SopTaskMutation) ResetName() {
  23949. m.name = nil
  23950. }
  23951. // SetBotWxidList sets the "bot_wxid_list" field.
  23952. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23953. m.bot_wxid_list = &s
  23954. m.appendbot_wxid_list = nil
  23955. }
  23956. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23957. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23958. v := m.bot_wxid_list
  23959. if v == nil {
  23960. return
  23961. }
  23962. return *v, true
  23963. }
  23964. // OldBotWxidList returns the old "bot_wxid_list" field's value of the SopTask entity.
  23965. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23966. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23967. func (m *SopTaskMutation) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23968. if !m.op.Is(OpUpdateOne) {
  23969. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23970. }
  23971. if m.id == nil || m.oldValue == nil {
  23972. return v, errors.New("OldBotWxidList requires an ID field in the mutation")
  23973. }
  23974. oldValue, err := m.oldValue(ctx)
  23975. if err != nil {
  23976. return v, fmt.Errorf("querying old value for OldBotWxidList: %w", err)
  23977. }
  23978. return oldValue.BotWxidList, nil
  23979. }
  23980. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23981. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23982. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23983. }
  23984. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23985. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23986. if len(m.appendbot_wxid_list) == 0 {
  23987. return nil, false
  23988. }
  23989. return m.appendbot_wxid_list, true
  23990. }
  23991. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23992. func (m *SopTaskMutation) ClearBotWxidList() {
  23993. m.bot_wxid_list = nil
  23994. m.appendbot_wxid_list = nil
  23995. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23996. }
  23997. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23998. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23999. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  24000. return ok
  24001. }
  24002. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  24003. func (m *SopTaskMutation) ResetBotWxidList() {
  24004. m.bot_wxid_list = nil
  24005. m.appendbot_wxid_list = nil
  24006. delete(m.clearedFields, soptask.FieldBotWxidList)
  24007. }
  24008. // SetType sets the "type" field.
  24009. func (m *SopTaskMutation) SetType(i int) {
  24010. m._type = &i
  24011. m.add_type = nil
  24012. }
  24013. // GetType returns the value of the "type" field in the mutation.
  24014. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  24015. v := m._type
  24016. if v == nil {
  24017. return
  24018. }
  24019. return *v, true
  24020. }
  24021. // OldType returns the old "type" field's value of the SopTask entity.
  24022. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24024. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  24025. if !m.op.Is(OpUpdateOne) {
  24026. return v, errors.New("OldType is only allowed on UpdateOne operations")
  24027. }
  24028. if m.id == nil || m.oldValue == nil {
  24029. return v, errors.New("OldType requires an ID field in the mutation")
  24030. }
  24031. oldValue, err := m.oldValue(ctx)
  24032. if err != nil {
  24033. return v, fmt.Errorf("querying old value for OldType: %w", err)
  24034. }
  24035. return oldValue.Type, nil
  24036. }
  24037. // AddType adds i to the "type" field.
  24038. func (m *SopTaskMutation) AddType(i int) {
  24039. if m.add_type != nil {
  24040. *m.add_type += i
  24041. } else {
  24042. m.add_type = &i
  24043. }
  24044. }
  24045. // AddedType returns the value that was added to the "type" field in this mutation.
  24046. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  24047. v := m.add_type
  24048. if v == nil {
  24049. return
  24050. }
  24051. return *v, true
  24052. }
  24053. // ResetType resets all changes to the "type" field.
  24054. func (m *SopTaskMutation) ResetType() {
  24055. m._type = nil
  24056. m.add_type = nil
  24057. }
  24058. // SetPlanStartTime sets the "plan_start_time" field.
  24059. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  24060. m.plan_start_time = &t
  24061. }
  24062. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  24063. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  24064. v := m.plan_start_time
  24065. if v == nil {
  24066. return
  24067. }
  24068. return *v, true
  24069. }
  24070. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  24071. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24073. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  24074. if !m.op.Is(OpUpdateOne) {
  24075. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24076. }
  24077. if m.id == nil || m.oldValue == nil {
  24078. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24079. }
  24080. oldValue, err := m.oldValue(ctx)
  24081. if err != nil {
  24082. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24083. }
  24084. return oldValue.PlanStartTime, nil
  24085. }
  24086. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24087. func (m *SopTaskMutation) ClearPlanStartTime() {
  24088. m.plan_start_time = nil
  24089. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24090. }
  24091. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24092. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24093. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24094. return ok
  24095. }
  24096. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24097. func (m *SopTaskMutation) ResetPlanStartTime() {
  24098. m.plan_start_time = nil
  24099. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24100. }
  24101. // SetPlanEndTime sets the "plan_end_time" field.
  24102. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24103. m.plan_end_time = &t
  24104. }
  24105. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24106. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24107. v := m.plan_end_time
  24108. if v == nil {
  24109. return
  24110. }
  24111. return *v, true
  24112. }
  24113. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24114. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24116. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24117. if !m.op.Is(OpUpdateOne) {
  24118. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24119. }
  24120. if m.id == nil || m.oldValue == nil {
  24121. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24122. }
  24123. oldValue, err := m.oldValue(ctx)
  24124. if err != nil {
  24125. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24126. }
  24127. return oldValue.PlanEndTime, nil
  24128. }
  24129. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24130. func (m *SopTaskMutation) ClearPlanEndTime() {
  24131. m.plan_end_time = nil
  24132. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24133. }
  24134. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24135. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24136. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24137. return ok
  24138. }
  24139. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24140. func (m *SopTaskMutation) ResetPlanEndTime() {
  24141. m.plan_end_time = nil
  24142. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24143. }
  24144. // SetCreatorID sets the "creator_id" field.
  24145. func (m *SopTaskMutation) SetCreatorID(s string) {
  24146. m.creator_id = &s
  24147. }
  24148. // CreatorID returns the value of the "creator_id" field in the mutation.
  24149. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24150. v := m.creator_id
  24151. if v == nil {
  24152. return
  24153. }
  24154. return *v, true
  24155. }
  24156. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24157. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24159. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24160. if !m.op.Is(OpUpdateOne) {
  24161. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24162. }
  24163. if m.id == nil || m.oldValue == nil {
  24164. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24165. }
  24166. oldValue, err := m.oldValue(ctx)
  24167. if err != nil {
  24168. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24169. }
  24170. return oldValue.CreatorID, nil
  24171. }
  24172. // ClearCreatorID clears the value of the "creator_id" field.
  24173. func (m *SopTaskMutation) ClearCreatorID() {
  24174. m.creator_id = nil
  24175. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24176. }
  24177. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24178. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24179. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24180. return ok
  24181. }
  24182. // ResetCreatorID resets all changes to the "creator_id" field.
  24183. func (m *SopTaskMutation) ResetCreatorID() {
  24184. m.creator_id = nil
  24185. delete(m.clearedFields, soptask.FieldCreatorID)
  24186. }
  24187. // SetOrganizationID sets the "organization_id" field.
  24188. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24189. m.organization_id = &u
  24190. m.addorganization_id = nil
  24191. }
  24192. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24193. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24194. v := m.organization_id
  24195. if v == nil {
  24196. return
  24197. }
  24198. return *v, true
  24199. }
  24200. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24201. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24203. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24204. if !m.op.Is(OpUpdateOne) {
  24205. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24206. }
  24207. if m.id == nil || m.oldValue == nil {
  24208. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24209. }
  24210. oldValue, err := m.oldValue(ctx)
  24211. if err != nil {
  24212. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24213. }
  24214. return oldValue.OrganizationID, nil
  24215. }
  24216. // AddOrganizationID adds u to the "organization_id" field.
  24217. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24218. if m.addorganization_id != nil {
  24219. *m.addorganization_id += u
  24220. } else {
  24221. m.addorganization_id = &u
  24222. }
  24223. }
  24224. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24225. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24226. v := m.addorganization_id
  24227. if v == nil {
  24228. return
  24229. }
  24230. return *v, true
  24231. }
  24232. // ClearOrganizationID clears the value of the "organization_id" field.
  24233. func (m *SopTaskMutation) ClearOrganizationID() {
  24234. m.organization_id = nil
  24235. m.addorganization_id = nil
  24236. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24237. }
  24238. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24239. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24240. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24241. return ok
  24242. }
  24243. // ResetOrganizationID resets all changes to the "organization_id" field.
  24244. func (m *SopTaskMutation) ResetOrganizationID() {
  24245. m.organization_id = nil
  24246. m.addorganization_id = nil
  24247. delete(m.clearedFields, soptask.FieldOrganizationID)
  24248. }
  24249. // SetToken sets the "token" field.
  24250. func (m *SopTaskMutation) SetToken(s []string) {
  24251. m.token = &s
  24252. m.appendtoken = nil
  24253. }
  24254. // Token returns the value of the "token" field in the mutation.
  24255. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24256. v := m.token
  24257. if v == nil {
  24258. return
  24259. }
  24260. return *v, true
  24261. }
  24262. // OldToken returns the old "token" field's value of the SopTask entity.
  24263. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24265. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24266. if !m.op.Is(OpUpdateOne) {
  24267. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24268. }
  24269. if m.id == nil || m.oldValue == nil {
  24270. return v, errors.New("OldToken requires an ID field in the mutation")
  24271. }
  24272. oldValue, err := m.oldValue(ctx)
  24273. if err != nil {
  24274. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24275. }
  24276. return oldValue.Token, nil
  24277. }
  24278. // AppendToken adds s to the "token" field.
  24279. func (m *SopTaskMutation) AppendToken(s []string) {
  24280. m.appendtoken = append(m.appendtoken, s...)
  24281. }
  24282. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24283. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24284. if len(m.appendtoken) == 0 {
  24285. return nil, false
  24286. }
  24287. return m.appendtoken, true
  24288. }
  24289. // ClearToken clears the value of the "token" field.
  24290. func (m *SopTaskMutation) ClearToken() {
  24291. m.token = nil
  24292. m.appendtoken = nil
  24293. m.clearedFields[soptask.FieldToken] = struct{}{}
  24294. }
  24295. // TokenCleared returns if the "token" field was cleared in this mutation.
  24296. func (m *SopTaskMutation) TokenCleared() bool {
  24297. _, ok := m.clearedFields[soptask.FieldToken]
  24298. return ok
  24299. }
  24300. // ResetToken resets all changes to the "token" field.
  24301. func (m *SopTaskMutation) ResetToken() {
  24302. m.token = nil
  24303. m.appendtoken = nil
  24304. delete(m.clearedFields, soptask.FieldToken)
  24305. }
  24306. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24307. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24308. if m.task_stages == nil {
  24309. m.task_stages = make(map[uint64]struct{})
  24310. }
  24311. for i := range ids {
  24312. m.task_stages[ids[i]] = struct{}{}
  24313. }
  24314. }
  24315. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24316. func (m *SopTaskMutation) ClearTaskStages() {
  24317. m.clearedtask_stages = true
  24318. }
  24319. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24320. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24321. return m.clearedtask_stages
  24322. }
  24323. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24324. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24325. if m.removedtask_stages == nil {
  24326. m.removedtask_stages = make(map[uint64]struct{})
  24327. }
  24328. for i := range ids {
  24329. delete(m.task_stages, ids[i])
  24330. m.removedtask_stages[ids[i]] = struct{}{}
  24331. }
  24332. }
  24333. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24334. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24335. for id := range m.removedtask_stages {
  24336. ids = append(ids, id)
  24337. }
  24338. return
  24339. }
  24340. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24341. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24342. for id := range m.task_stages {
  24343. ids = append(ids, id)
  24344. }
  24345. return
  24346. }
  24347. // ResetTaskStages resets all changes to the "task_stages" edge.
  24348. func (m *SopTaskMutation) ResetTaskStages() {
  24349. m.task_stages = nil
  24350. m.clearedtask_stages = false
  24351. m.removedtask_stages = nil
  24352. }
  24353. // Where appends a list predicates to the SopTaskMutation builder.
  24354. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24355. m.predicates = append(m.predicates, ps...)
  24356. }
  24357. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24358. // users can use type-assertion to append predicates that do not depend on any generated package.
  24359. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24360. p := make([]predicate.SopTask, len(ps))
  24361. for i := range ps {
  24362. p[i] = ps[i]
  24363. }
  24364. m.Where(p...)
  24365. }
  24366. // Op returns the operation name.
  24367. func (m *SopTaskMutation) Op() Op {
  24368. return m.op
  24369. }
  24370. // SetOp allows setting the mutation operation.
  24371. func (m *SopTaskMutation) SetOp(op Op) {
  24372. m.op = op
  24373. }
  24374. // Type returns the node type of this mutation (SopTask).
  24375. func (m *SopTaskMutation) Type() string {
  24376. return m.typ
  24377. }
  24378. // Fields returns all fields that were changed during this mutation. Note that in
  24379. // order to get all numeric fields that were incremented/decremented, call
  24380. // AddedFields().
  24381. func (m *SopTaskMutation) Fields() []string {
  24382. fields := make([]string, 0, 12)
  24383. if m.created_at != nil {
  24384. fields = append(fields, soptask.FieldCreatedAt)
  24385. }
  24386. if m.updated_at != nil {
  24387. fields = append(fields, soptask.FieldUpdatedAt)
  24388. }
  24389. if m.status != nil {
  24390. fields = append(fields, soptask.FieldStatus)
  24391. }
  24392. if m.deleted_at != nil {
  24393. fields = append(fields, soptask.FieldDeletedAt)
  24394. }
  24395. if m.name != nil {
  24396. fields = append(fields, soptask.FieldName)
  24397. }
  24398. if m.bot_wxid_list != nil {
  24399. fields = append(fields, soptask.FieldBotWxidList)
  24400. }
  24401. if m._type != nil {
  24402. fields = append(fields, soptask.FieldType)
  24403. }
  24404. if m.plan_start_time != nil {
  24405. fields = append(fields, soptask.FieldPlanStartTime)
  24406. }
  24407. if m.plan_end_time != nil {
  24408. fields = append(fields, soptask.FieldPlanEndTime)
  24409. }
  24410. if m.creator_id != nil {
  24411. fields = append(fields, soptask.FieldCreatorID)
  24412. }
  24413. if m.organization_id != nil {
  24414. fields = append(fields, soptask.FieldOrganizationID)
  24415. }
  24416. if m.token != nil {
  24417. fields = append(fields, soptask.FieldToken)
  24418. }
  24419. return fields
  24420. }
  24421. // Field returns the value of a field with the given name. The second boolean
  24422. // return value indicates that this field was not set, or was not defined in the
  24423. // schema.
  24424. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24425. switch name {
  24426. case soptask.FieldCreatedAt:
  24427. return m.CreatedAt()
  24428. case soptask.FieldUpdatedAt:
  24429. return m.UpdatedAt()
  24430. case soptask.FieldStatus:
  24431. return m.Status()
  24432. case soptask.FieldDeletedAt:
  24433. return m.DeletedAt()
  24434. case soptask.FieldName:
  24435. return m.Name()
  24436. case soptask.FieldBotWxidList:
  24437. return m.BotWxidList()
  24438. case soptask.FieldType:
  24439. return m.GetType()
  24440. case soptask.FieldPlanStartTime:
  24441. return m.PlanStartTime()
  24442. case soptask.FieldPlanEndTime:
  24443. return m.PlanEndTime()
  24444. case soptask.FieldCreatorID:
  24445. return m.CreatorID()
  24446. case soptask.FieldOrganizationID:
  24447. return m.OrganizationID()
  24448. case soptask.FieldToken:
  24449. return m.Token()
  24450. }
  24451. return nil, false
  24452. }
  24453. // OldField returns the old value of the field from the database. An error is
  24454. // returned if the mutation operation is not UpdateOne, or the query to the
  24455. // database failed.
  24456. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24457. switch name {
  24458. case soptask.FieldCreatedAt:
  24459. return m.OldCreatedAt(ctx)
  24460. case soptask.FieldUpdatedAt:
  24461. return m.OldUpdatedAt(ctx)
  24462. case soptask.FieldStatus:
  24463. return m.OldStatus(ctx)
  24464. case soptask.FieldDeletedAt:
  24465. return m.OldDeletedAt(ctx)
  24466. case soptask.FieldName:
  24467. return m.OldName(ctx)
  24468. case soptask.FieldBotWxidList:
  24469. return m.OldBotWxidList(ctx)
  24470. case soptask.FieldType:
  24471. return m.OldType(ctx)
  24472. case soptask.FieldPlanStartTime:
  24473. return m.OldPlanStartTime(ctx)
  24474. case soptask.FieldPlanEndTime:
  24475. return m.OldPlanEndTime(ctx)
  24476. case soptask.FieldCreatorID:
  24477. return m.OldCreatorID(ctx)
  24478. case soptask.FieldOrganizationID:
  24479. return m.OldOrganizationID(ctx)
  24480. case soptask.FieldToken:
  24481. return m.OldToken(ctx)
  24482. }
  24483. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24484. }
  24485. // SetField sets the value of a field with the given name. It returns an error if
  24486. // the field is not defined in the schema, or if the type mismatched the field
  24487. // type.
  24488. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24489. switch name {
  24490. case soptask.FieldCreatedAt:
  24491. v, ok := value.(time.Time)
  24492. if !ok {
  24493. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24494. }
  24495. m.SetCreatedAt(v)
  24496. return nil
  24497. case soptask.FieldUpdatedAt:
  24498. v, ok := value.(time.Time)
  24499. if !ok {
  24500. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24501. }
  24502. m.SetUpdatedAt(v)
  24503. return nil
  24504. case soptask.FieldStatus:
  24505. v, ok := value.(uint8)
  24506. if !ok {
  24507. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24508. }
  24509. m.SetStatus(v)
  24510. return nil
  24511. case soptask.FieldDeletedAt:
  24512. v, ok := value.(time.Time)
  24513. if !ok {
  24514. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24515. }
  24516. m.SetDeletedAt(v)
  24517. return nil
  24518. case soptask.FieldName:
  24519. v, ok := value.(string)
  24520. if !ok {
  24521. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24522. }
  24523. m.SetName(v)
  24524. return nil
  24525. case soptask.FieldBotWxidList:
  24526. v, ok := value.([]string)
  24527. if !ok {
  24528. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24529. }
  24530. m.SetBotWxidList(v)
  24531. return nil
  24532. case soptask.FieldType:
  24533. v, ok := value.(int)
  24534. if !ok {
  24535. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24536. }
  24537. m.SetType(v)
  24538. return nil
  24539. case soptask.FieldPlanStartTime:
  24540. v, ok := value.(time.Time)
  24541. if !ok {
  24542. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24543. }
  24544. m.SetPlanStartTime(v)
  24545. return nil
  24546. case soptask.FieldPlanEndTime:
  24547. v, ok := value.(time.Time)
  24548. if !ok {
  24549. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24550. }
  24551. m.SetPlanEndTime(v)
  24552. return nil
  24553. case soptask.FieldCreatorID:
  24554. v, ok := value.(string)
  24555. if !ok {
  24556. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24557. }
  24558. m.SetCreatorID(v)
  24559. return nil
  24560. case soptask.FieldOrganizationID:
  24561. v, ok := value.(uint64)
  24562. if !ok {
  24563. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24564. }
  24565. m.SetOrganizationID(v)
  24566. return nil
  24567. case soptask.FieldToken:
  24568. v, ok := value.([]string)
  24569. if !ok {
  24570. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24571. }
  24572. m.SetToken(v)
  24573. return nil
  24574. }
  24575. return fmt.Errorf("unknown SopTask field %s", name)
  24576. }
  24577. // AddedFields returns all numeric fields that were incremented/decremented during
  24578. // this mutation.
  24579. func (m *SopTaskMutation) AddedFields() []string {
  24580. var fields []string
  24581. if m.addstatus != nil {
  24582. fields = append(fields, soptask.FieldStatus)
  24583. }
  24584. if m.add_type != nil {
  24585. fields = append(fields, soptask.FieldType)
  24586. }
  24587. if m.addorganization_id != nil {
  24588. fields = append(fields, soptask.FieldOrganizationID)
  24589. }
  24590. return fields
  24591. }
  24592. // AddedField returns the numeric value that was incremented/decremented on a field
  24593. // with the given name. The second boolean return value indicates that this field
  24594. // was not set, or was not defined in the schema.
  24595. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24596. switch name {
  24597. case soptask.FieldStatus:
  24598. return m.AddedStatus()
  24599. case soptask.FieldType:
  24600. return m.AddedType()
  24601. case soptask.FieldOrganizationID:
  24602. return m.AddedOrganizationID()
  24603. }
  24604. return nil, false
  24605. }
  24606. // AddField adds the value to the field with the given name. It returns an error if
  24607. // the field is not defined in the schema, or if the type mismatched the field
  24608. // type.
  24609. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24610. switch name {
  24611. case soptask.FieldStatus:
  24612. v, ok := value.(int8)
  24613. if !ok {
  24614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24615. }
  24616. m.AddStatus(v)
  24617. return nil
  24618. case soptask.FieldType:
  24619. v, ok := value.(int)
  24620. if !ok {
  24621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24622. }
  24623. m.AddType(v)
  24624. return nil
  24625. case soptask.FieldOrganizationID:
  24626. v, ok := value.(int64)
  24627. if !ok {
  24628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24629. }
  24630. m.AddOrganizationID(v)
  24631. return nil
  24632. }
  24633. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24634. }
  24635. // ClearedFields returns all nullable fields that were cleared during this
  24636. // mutation.
  24637. func (m *SopTaskMutation) ClearedFields() []string {
  24638. var fields []string
  24639. if m.FieldCleared(soptask.FieldStatus) {
  24640. fields = append(fields, soptask.FieldStatus)
  24641. }
  24642. if m.FieldCleared(soptask.FieldDeletedAt) {
  24643. fields = append(fields, soptask.FieldDeletedAt)
  24644. }
  24645. if m.FieldCleared(soptask.FieldBotWxidList) {
  24646. fields = append(fields, soptask.FieldBotWxidList)
  24647. }
  24648. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24649. fields = append(fields, soptask.FieldPlanStartTime)
  24650. }
  24651. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24652. fields = append(fields, soptask.FieldPlanEndTime)
  24653. }
  24654. if m.FieldCleared(soptask.FieldCreatorID) {
  24655. fields = append(fields, soptask.FieldCreatorID)
  24656. }
  24657. if m.FieldCleared(soptask.FieldOrganizationID) {
  24658. fields = append(fields, soptask.FieldOrganizationID)
  24659. }
  24660. if m.FieldCleared(soptask.FieldToken) {
  24661. fields = append(fields, soptask.FieldToken)
  24662. }
  24663. return fields
  24664. }
  24665. // FieldCleared returns a boolean indicating if a field with the given name was
  24666. // cleared in this mutation.
  24667. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24668. _, ok := m.clearedFields[name]
  24669. return ok
  24670. }
  24671. // ClearField clears the value of the field with the given name. It returns an
  24672. // error if the field is not defined in the schema.
  24673. func (m *SopTaskMutation) ClearField(name string) error {
  24674. switch name {
  24675. case soptask.FieldStatus:
  24676. m.ClearStatus()
  24677. return nil
  24678. case soptask.FieldDeletedAt:
  24679. m.ClearDeletedAt()
  24680. return nil
  24681. case soptask.FieldBotWxidList:
  24682. m.ClearBotWxidList()
  24683. return nil
  24684. case soptask.FieldPlanStartTime:
  24685. m.ClearPlanStartTime()
  24686. return nil
  24687. case soptask.FieldPlanEndTime:
  24688. m.ClearPlanEndTime()
  24689. return nil
  24690. case soptask.FieldCreatorID:
  24691. m.ClearCreatorID()
  24692. return nil
  24693. case soptask.FieldOrganizationID:
  24694. m.ClearOrganizationID()
  24695. return nil
  24696. case soptask.FieldToken:
  24697. m.ClearToken()
  24698. return nil
  24699. }
  24700. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24701. }
  24702. // ResetField resets all changes in the mutation for the field with the given name.
  24703. // It returns an error if the field is not defined in the schema.
  24704. func (m *SopTaskMutation) ResetField(name string) error {
  24705. switch name {
  24706. case soptask.FieldCreatedAt:
  24707. m.ResetCreatedAt()
  24708. return nil
  24709. case soptask.FieldUpdatedAt:
  24710. m.ResetUpdatedAt()
  24711. return nil
  24712. case soptask.FieldStatus:
  24713. m.ResetStatus()
  24714. return nil
  24715. case soptask.FieldDeletedAt:
  24716. m.ResetDeletedAt()
  24717. return nil
  24718. case soptask.FieldName:
  24719. m.ResetName()
  24720. return nil
  24721. case soptask.FieldBotWxidList:
  24722. m.ResetBotWxidList()
  24723. return nil
  24724. case soptask.FieldType:
  24725. m.ResetType()
  24726. return nil
  24727. case soptask.FieldPlanStartTime:
  24728. m.ResetPlanStartTime()
  24729. return nil
  24730. case soptask.FieldPlanEndTime:
  24731. m.ResetPlanEndTime()
  24732. return nil
  24733. case soptask.FieldCreatorID:
  24734. m.ResetCreatorID()
  24735. return nil
  24736. case soptask.FieldOrganizationID:
  24737. m.ResetOrganizationID()
  24738. return nil
  24739. case soptask.FieldToken:
  24740. m.ResetToken()
  24741. return nil
  24742. }
  24743. return fmt.Errorf("unknown SopTask field %s", name)
  24744. }
  24745. // AddedEdges returns all edge names that were set/added in this mutation.
  24746. func (m *SopTaskMutation) AddedEdges() []string {
  24747. edges := make([]string, 0, 1)
  24748. if m.task_stages != nil {
  24749. edges = append(edges, soptask.EdgeTaskStages)
  24750. }
  24751. return edges
  24752. }
  24753. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24754. // name in this mutation.
  24755. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24756. switch name {
  24757. case soptask.EdgeTaskStages:
  24758. ids := make([]ent.Value, 0, len(m.task_stages))
  24759. for id := range m.task_stages {
  24760. ids = append(ids, id)
  24761. }
  24762. return ids
  24763. }
  24764. return nil
  24765. }
  24766. // RemovedEdges returns all edge names that were removed in this mutation.
  24767. func (m *SopTaskMutation) RemovedEdges() []string {
  24768. edges := make([]string, 0, 1)
  24769. if m.removedtask_stages != nil {
  24770. edges = append(edges, soptask.EdgeTaskStages)
  24771. }
  24772. return edges
  24773. }
  24774. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24775. // the given name in this mutation.
  24776. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24777. switch name {
  24778. case soptask.EdgeTaskStages:
  24779. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24780. for id := range m.removedtask_stages {
  24781. ids = append(ids, id)
  24782. }
  24783. return ids
  24784. }
  24785. return nil
  24786. }
  24787. // ClearedEdges returns all edge names that were cleared in this mutation.
  24788. func (m *SopTaskMutation) ClearedEdges() []string {
  24789. edges := make([]string, 0, 1)
  24790. if m.clearedtask_stages {
  24791. edges = append(edges, soptask.EdgeTaskStages)
  24792. }
  24793. return edges
  24794. }
  24795. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24796. // was cleared in this mutation.
  24797. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24798. switch name {
  24799. case soptask.EdgeTaskStages:
  24800. return m.clearedtask_stages
  24801. }
  24802. return false
  24803. }
  24804. // ClearEdge clears the value of the edge with the given name. It returns an error
  24805. // if that edge is not defined in the schema.
  24806. func (m *SopTaskMutation) ClearEdge(name string) error {
  24807. switch name {
  24808. }
  24809. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24810. }
  24811. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24812. // It returns an error if the edge is not defined in the schema.
  24813. func (m *SopTaskMutation) ResetEdge(name string) error {
  24814. switch name {
  24815. case soptask.EdgeTaskStages:
  24816. m.ResetTaskStages()
  24817. return nil
  24818. }
  24819. return fmt.Errorf("unknown SopTask edge %s", name)
  24820. }
  24821. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24822. type TokenMutation struct {
  24823. config
  24824. op Op
  24825. typ string
  24826. id *uint64
  24827. created_at *time.Time
  24828. updated_at *time.Time
  24829. deleted_at *time.Time
  24830. expire_at *time.Time
  24831. token *string
  24832. mac *string
  24833. organization_id *uint64
  24834. addorganization_id *int64
  24835. custom_agent_base *string
  24836. custom_agent_key *string
  24837. openai_base *string
  24838. openai_key *string
  24839. clearedFields map[string]struct{}
  24840. agent *uint64
  24841. clearedagent bool
  24842. done bool
  24843. oldValue func(context.Context) (*Token, error)
  24844. predicates []predicate.Token
  24845. }
  24846. var _ ent.Mutation = (*TokenMutation)(nil)
  24847. // tokenOption allows management of the mutation configuration using functional options.
  24848. type tokenOption func(*TokenMutation)
  24849. // newTokenMutation creates new mutation for the Token entity.
  24850. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24851. m := &TokenMutation{
  24852. config: c,
  24853. op: op,
  24854. typ: TypeToken,
  24855. clearedFields: make(map[string]struct{}),
  24856. }
  24857. for _, opt := range opts {
  24858. opt(m)
  24859. }
  24860. return m
  24861. }
  24862. // withTokenID sets the ID field of the mutation.
  24863. func withTokenID(id uint64) tokenOption {
  24864. return func(m *TokenMutation) {
  24865. var (
  24866. err error
  24867. once sync.Once
  24868. value *Token
  24869. )
  24870. m.oldValue = func(ctx context.Context) (*Token, error) {
  24871. once.Do(func() {
  24872. if m.done {
  24873. err = errors.New("querying old values post mutation is not allowed")
  24874. } else {
  24875. value, err = m.Client().Token.Get(ctx, id)
  24876. }
  24877. })
  24878. return value, err
  24879. }
  24880. m.id = &id
  24881. }
  24882. }
  24883. // withToken sets the old Token of the mutation.
  24884. func withToken(node *Token) tokenOption {
  24885. return func(m *TokenMutation) {
  24886. m.oldValue = func(context.Context) (*Token, error) {
  24887. return node, nil
  24888. }
  24889. m.id = &node.ID
  24890. }
  24891. }
  24892. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24893. // executed in a transaction (ent.Tx), a transactional client is returned.
  24894. func (m TokenMutation) Client() *Client {
  24895. client := &Client{config: m.config}
  24896. client.init()
  24897. return client
  24898. }
  24899. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24900. // it returns an error otherwise.
  24901. func (m TokenMutation) Tx() (*Tx, error) {
  24902. if _, ok := m.driver.(*txDriver); !ok {
  24903. return nil, errors.New("ent: mutation is not running in a transaction")
  24904. }
  24905. tx := &Tx{config: m.config}
  24906. tx.init()
  24907. return tx, nil
  24908. }
  24909. // SetID sets the value of the id field. Note that this
  24910. // operation is only accepted on creation of Token entities.
  24911. func (m *TokenMutation) SetID(id uint64) {
  24912. m.id = &id
  24913. }
  24914. // ID returns the ID value in the mutation. Note that the ID is only available
  24915. // if it was provided to the builder or after it was returned from the database.
  24916. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24917. if m.id == nil {
  24918. return
  24919. }
  24920. return *m.id, true
  24921. }
  24922. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24923. // That means, if the mutation is applied within a transaction with an isolation level such
  24924. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24925. // or updated by the mutation.
  24926. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24927. switch {
  24928. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24929. id, exists := m.ID()
  24930. if exists {
  24931. return []uint64{id}, nil
  24932. }
  24933. fallthrough
  24934. case m.op.Is(OpUpdate | OpDelete):
  24935. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24936. default:
  24937. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24938. }
  24939. }
  24940. // SetCreatedAt sets the "created_at" field.
  24941. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24942. m.created_at = &t
  24943. }
  24944. // CreatedAt returns the value of the "created_at" field in the mutation.
  24945. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24946. v := m.created_at
  24947. if v == nil {
  24948. return
  24949. }
  24950. return *v, true
  24951. }
  24952. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24953. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24955. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24956. if !m.op.Is(OpUpdateOne) {
  24957. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24958. }
  24959. if m.id == nil || m.oldValue == nil {
  24960. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24961. }
  24962. oldValue, err := m.oldValue(ctx)
  24963. if err != nil {
  24964. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24965. }
  24966. return oldValue.CreatedAt, nil
  24967. }
  24968. // ResetCreatedAt resets all changes to the "created_at" field.
  24969. func (m *TokenMutation) ResetCreatedAt() {
  24970. m.created_at = nil
  24971. }
  24972. // SetUpdatedAt sets the "updated_at" field.
  24973. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24974. m.updated_at = &t
  24975. }
  24976. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24977. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24978. v := m.updated_at
  24979. if v == nil {
  24980. return
  24981. }
  24982. return *v, true
  24983. }
  24984. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24985. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24986. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24987. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24988. if !m.op.Is(OpUpdateOne) {
  24989. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24990. }
  24991. if m.id == nil || m.oldValue == nil {
  24992. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24993. }
  24994. oldValue, err := m.oldValue(ctx)
  24995. if err != nil {
  24996. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24997. }
  24998. return oldValue.UpdatedAt, nil
  24999. }
  25000. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25001. func (m *TokenMutation) ResetUpdatedAt() {
  25002. m.updated_at = nil
  25003. }
  25004. // SetDeletedAt sets the "deleted_at" field.
  25005. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  25006. m.deleted_at = &t
  25007. }
  25008. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25009. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  25010. v := m.deleted_at
  25011. if v == nil {
  25012. return
  25013. }
  25014. return *v, true
  25015. }
  25016. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  25017. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25018. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25019. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  25020. if !m.op.Is(OpUpdateOne) {
  25021. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  25022. }
  25023. if m.id == nil || m.oldValue == nil {
  25024. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  25025. }
  25026. oldValue, err := m.oldValue(ctx)
  25027. if err != nil {
  25028. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  25029. }
  25030. return oldValue.DeletedAt, nil
  25031. }
  25032. // ClearDeletedAt clears the value of the "deleted_at" field.
  25033. func (m *TokenMutation) ClearDeletedAt() {
  25034. m.deleted_at = nil
  25035. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  25036. }
  25037. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  25038. func (m *TokenMutation) DeletedAtCleared() bool {
  25039. _, ok := m.clearedFields[token.FieldDeletedAt]
  25040. return ok
  25041. }
  25042. // ResetDeletedAt resets all changes to the "deleted_at" field.
  25043. func (m *TokenMutation) ResetDeletedAt() {
  25044. m.deleted_at = nil
  25045. delete(m.clearedFields, token.FieldDeletedAt)
  25046. }
  25047. // SetExpireAt sets the "expire_at" field.
  25048. func (m *TokenMutation) SetExpireAt(t time.Time) {
  25049. m.expire_at = &t
  25050. }
  25051. // ExpireAt returns the value of the "expire_at" field in the mutation.
  25052. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  25053. v := m.expire_at
  25054. if v == nil {
  25055. return
  25056. }
  25057. return *v, true
  25058. }
  25059. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  25060. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25061. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25062. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  25063. if !m.op.Is(OpUpdateOne) {
  25064. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  25065. }
  25066. if m.id == nil || m.oldValue == nil {
  25067. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  25068. }
  25069. oldValue, err := m.oldValue(ctx)
  25070. if err != nil {
  25071. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  25072. }
  25073. return oldValue.ExpireAt, nil
  25074. }
  25075. // ClearExpireAt clears the value of the "expire_at" field.
  25076. func (m *TokenMutation) ClearExpireAt() {
  25077. m.expire_at = nil
  25078. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25079. }
  25080. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25081. func (m *TokenMutation) ExpireAtCleared() bool {
  25082. _, ok := m.clearedFields[token.FieldExpireAt]
  25083. return ok
  25084. }
  25085. // ResetExpireAt resets all changes to the "expire_at" field.
  25086. func (m *TokenMutation) ResetExpireAt() {
  25087. m.expire_at = nil
  25088. delete(m.clearedFields, token.FieldExpireAt)
  25089. }
  25090. // SetToken sets the "token" field.
  25091. func (m *TokenMutation) SetToken(s string) {
  25092. m.token = &s
  25093. }
  25094. // Token returns the value of the "token" field in the mutation.
  25095. func (m *TokenMutation) Token() (r string, exists bool) {
  25096. v := m.token
  25097. if v == nil {
  25098. return
  25099. }
  25100. return *v, true
  25101. }
  25102. // OldToken returns the old "token" field's value of the Token entity.
  25103. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25105. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25106. if !m.op.Is(OpUpdateOne) {
  25107. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25108. }
  25109. if m.id == nil || m.oldValue == nil {
  25110. return v, errors.New("OldToken requires an ID field in the mutation")
  25111. }
  25112. oldValue, err := m.oldValue(ctx)
  25113. if err != nil {
  25114. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25115. }
  25116. return oldValue.Token, nil
  25117. }
  25118. // ClearToken clears the value of the "token" field.
  25119. func (m *TokenMutation) ClearToken() {
  25120. m.token = nil
  25121. m.clearedFields[token.FieldToken] = struct{}{}
  25122. }
  25123. // TokenCleared returns if the "token" field was cleared in this mutation.
  25124. func (m *TokenMutation) TokenCleared() bool {
  25125. _, ok := m.clearedFields[token.FieldToken]
  25126. return ok
  25127. }
  25128. // ResetToken resets all changes to the "token" field.
  25129. func (m *TokenMutation) ResetToken() {
  25130. m.token = nil
  25131. delete(m.clearedFields, token.FieldToken)
  25132. }
  25133. // SetMAC sets the "mac" field.
  25134. func (m *TokenMutation) SetMAC(s string) {
  25135. m.mac = &s
  25136. }
  25137. // MAC returns the value of the "mac" field in the mutation.
  25138. func (m *TokenMutation) MAC() (r string, exists bool) {
  25139. v := m.mac
  25140. if v == nil {
  25141. return
  25142. }
  25143. return *v, true
  25144. }
  25145. // OldMAC returns the old "mac" field's value of the Token entity.
  25146. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25147. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25148. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25149. if !m.op.Is(OpUpdateOne) {
  25150. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25151. }
  25152. if m.id == nil || m.oldValue == nil {
  25153. return v, errors.New("OldMAC requires an ID field in the mutation")
  25154. }
  25155. oldValue, err := m.oldValue(ctx)
  25156. if err != nil {
  25157. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25158. }
  25159. return oldValue.MAC, nil
  25160. }
  25161. // ClearMAC clears the value of the "mac" field.
  25162. func (m *TokenMutation) ClearMAC() {
  25163. m.mac = nil
  25164. m.clearedFields[token.FieldMAC] = struct{}{}
  25165. }
  25166. // MACCleared returns if the "mac" field was cleared in this mutation.
  25167. func (m *TokenMutation) MACCleared() bool {
  25168. _, ok := m.clearedFields[token.FieldMAC]
  25169. return ok
  25170. }
  25171. // ResetMAC resets all changes to the "mac" field.
  25172. func (m *TokenMutation) ResetMAC() {
  25173. m.mac = nil
  25174. delete(m.clearedFields, token.FieldMAC)
  25175. }
  25176. // SetOrganizationID sets the "organization_id" field.
  25177. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25178. m.organization_id = &u
  25179. m.addorganization_id = nil
  25180. }
  25181. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25182. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25183. v := m.organization_id
  25184. if v == nil {
  25185. return
  25186. }
  25187. return *v, true
  25188. }
  25189. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25190. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25191. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25192. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25193. if !m.op.Is(OpUpdateOne) {
  25194. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25195. }
  25196. if m.id == nil || m.oldValue == nil {
  25197. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25198. }
  25199. oldValue, err := m.oldValue(ctx)
  25200. if err != nil {
  25201. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25202. }
  25203. return oldValue.OrganizationID, nil
  25204. }
  25205. // AddOrganizationID adds u to the "organization_id" field.
  25206. func (m *TokenMutation) AddOrganizationID(u int64) {
  25207. if m.addorganization_id != nil {
  25208. *m.addorganization_id += u
  25209. } else {
  25210. m.addorganization_id = &u
  25211. }
  25212. }
  25213. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25214. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25215. v := m.addorganization_id
  25216. if v == nil {
  25217. return
  25218. }
  25219. return *v, true
  25220. }
  25221. // ResetOrganizationID resets all changes to the "organization_id" field.
  25222. func (m *TokenMutation) ResetOrganizationID() {
  25223. m.organization_id = nil
  25224. m.addorganization_id = nil
  25225. }
  25226. // SetAgentID sets the "agent_id" field.
  25227. func (m *TokenMutation) SetAgentID(u uint64) {
  25228. m.agent = &u
  25229. }
  25230. // AgentID returns the value of the "agent_id" field in the mutation.
  25231. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25232. v := m.agent
  25233. if v == nil {
  25234. return
  25235. }
  25236. return *v, true
  25237. }
  25238. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25239. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25240. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25241. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25242. if !m.op.Is(OpUpdateOne) {
  25243. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25244. }
  25245. if m.id == nil || m.oldValue == nil {
  25246. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25247. }
  25248. oldValue, err := m.oldValue(ctx)
  25249. if err != nil {
  25250. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25251. }
  25252. return oldValue.AgentID, nil
  25253. }
  25254. // ResetAgentID resets all changes to the "agent_id" field.
  25255. func (m *TokenMutation) ResetAgentID() {
  25256. m.agent = nil
  25257. }
  25258. // SetCustomAgentBase sets the "custom_agent_base" field.
  25259. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25260. m.custom_agent_base = &s
  25261. }
  25262. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25263. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25264. v := m.custom_agent_base
  25265. if v == nil {
  25266. return
  25267. }
  25268. return *v, true
  25269. }
  25270. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25271. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25272. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25273. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25274. if !m.op.Is(OpUpdateOne) {
  25275. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25276. }
  25277. if m.id == nil || m.oldValue == nil {
  25278. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25279. }
  25280. oldValue, err := m.oldValue(ctx)
  25281. if err != nil {
  25282. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25283. }
  25284. return oldValue.CustomAgentBase, nil
  25285. }
  25286. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25287. func (m *TokenMutation) ClearCustomAgentBase() {
  25288. m.custom_agent_base = nil
  25289. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25290. }
  25291. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25292. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25293. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25294. return ok
  25295. }
  25296. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25297. func (m *TokenMutation) ResetCustomAgentBase() {
  25298. m.custom_agent_base = nil
  25299. delete(m.clearedFields, token.FieldCustomAgentBase)
  25300. }
  25301. // SetCustomAgentKey sets the "custom_agent_key" field.
  25302. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25303. m.custom_agent_key = &s
  25304. }
  25305. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25306. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25307. v := m.custom_agent_key
  25308. if v == nil {
  25309. return
  25310. }
  25311. return *v, true
  25312. }
  25313. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25314. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25316. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25317. if !m.op.Is(OpUpdateOne) {
  25318. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25319. }
  25320. if m.id == nil || m.oldValue == nil {
  25321. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25322. }
  25323. oldValue, err := m.oldValue(ctx)
  25324. if err != nil {
  25325. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25326. }
  25327. return oldValue.CustomAgentKey, nil
  25328. }
  25329. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25330. func (m *TokenMutation) ClearCustomAgentKey() {
  25331. m.custom_agent_key = nil
  25332. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25333. }
  25334. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25335. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25336. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25337. return ok
  25338. }
  25339. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25340. func (m *TokenMutation) ResetCustomAgentKey() {
  25341. m.custom_agent_key = nil
  25342. delete(m.clearedFields, token.FieldCustomAgentKey)
  25343. }
  25344. // SetOpenaiBase sets the "openai_base" field.
  25345. func (m *TokenMutation) SetOpenaiBase(s string) {
  25346. m.openai_base = &s
  25347. }
  25348. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25349. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25350. v := m.openai_base
  25351. if v == nil {
  25352. return
  25353. }
  25354. return *v, true
  25355. }
  25356. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25357. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25359. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25360. if !m.op.Is(OpUpdateOne) {
  25361. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25362. }
  25363. if m.id == nil || m.oldValue == nil {
  25364. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25365. }
  25366. oldValue, err := m.oldValue(ctx)
  25367. if err != nil {
  25368. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25369. }
  25370. return oldValue.OpenaiBase, nil
  25371. }
  25372. // ClearOpenaiBase clears the value of the "openai_base" field.
  25373. func (m *TokenMutation) ClearOpenaiBase() {
  25374. m.openai_base = nil
  25375. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25376. }
  25377. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25378. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25379. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25380. return ok
  25381. }
  25382. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25383. func (m *TokenMutation) ResetOpenaiBase() {
  25384. m.openai_base = nil
  25385. delete(m.clearedFields, token.FieldOpenaiBase)
  25386. }
  25387. // SetOpenaiKey sets the "openai_key" field.
  25388. func (m *TokenMutation) SetOpenaiKey(s string) {
  25389. m.openai_key = &s
  25390. }
  25391. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25392. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25393. v := m.openai_key
  25394. if v == nil {
  25395. return
  25396. }
  25397. return *v, true
  25398. }
  25399. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25400. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25401. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25402. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25403. if !m.op.Is(OpUpdateOne) {
  25404. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25405. }
  25406. if m.id == nil || m.oldValue == nil {
  25407. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25408. }
  25409. oldValue, err := m.oldValue(ctx)
  25410. if err != nil {
  25411. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25412. }
  25413. return oldValue.OpenaiKey, nil
  25414. }
  25415. // ClearOpenaiKey clears the value of the "openai_key" field.
  25416. func (m *TokenMutation) ClearOpenaiKey() {
  25417. m.openai_key = nil
  25418. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25419. }
  25420. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25421. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25422. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25423. return ok
  25424. }
  25425. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25426. func (m *TokenMutation) ResetOpenaiKey() {
  25427. m.openai_key = nil
  25428. delete(m.clearedFields, token.FieldOpenaiKey)
  25429. }
  25430. // ClearAgent clears the "agent" edge to the Agent entity.
  25431. func (m *TokenMutation) ClearAgent() {
  25432. m.clearedagent = true
  25433. m.clearedFields[token.FieldAgentID] = struct{}{}
  25434. }
  25435. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25436. func (m *TokenMutation) AgentCleared() bool {
  25437. return m.clearedagent
  25438. }
  25439. // AgentIDs returns the "agent" edge IDs in the mutation.
  25440. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25441. // AgentID instead. It exists only for internal usage by the builders.
  25442. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25443. if id := m.agent; id != nil {
  25444. ids = append(ids, *id)
  25445. }
  25446. return
  25447. }
  25448. // ResetAgent resets all changes to the "agent" edge.
  25449. func (m *TokenMutation) ResetAgent() {
  25450. m.agent = nil
  25451. m.clearedagent = false
  25452. }
  25453. // Where appends a list predicates to the TokenMutation builder.
  25454. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25455. m.predicates = append(m.predicates, ps...)
  25456. }
  25457. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25458. // users can use type-assertion to append predicates that do not depend on any generated package.
  25459. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25460. p := make([]predicate.Token, len(ps))
  25461. for i := range ps {
  25462. p[i] = ps[i]
  25463. }
  25464. m.Where(p...)
  25465. }
  25466. // Op returns the operation name.
  25467. func (m *TokenMutation) Op() Op {
  25468. return m.op
  25469. }
  25470. // SetOp allows setting the mutation operation.
  25471. func (m *TokenMutation) SetOp(op Op) {
  25472. m.op = op
  25473. }
  25474. // Type returns the node type of this mutation (Token).
  25475. func (m *TokenMutation) Type() string {
  25476. return m.typ
  25477. }
  25478. // Fields returns all fields that were changed during this mutation. Note that in
  25479. // order to get all numeric fields that were incremented/decremented, call
  25480. // AddedFields().
  25481. func (m *TokenMutation) Fields() []string {
  25482. fields := make([]string, 0, 12)
  25483. if m.created_at != nil {
  25484. fields = append(fields, token.FieldCreatedAt)
  25485. }
  25486. if m.updated_at != nil {
  25487. fields = append(fields, token.FieldUpdatedAt)
  25488. }
  25489. if m.deleted_at != nil {
  25490. fields = append(fields, token.FieldDeletedAt)
  25491. }
  25492. if m.expire_at != nil {
  25493. fields = append(fields, token.FieldExpireAt)
  25494. }
  25495. if m.token != nil {
  25496. fields = append(fields, token.FieldToken)
  25497. }
  25498. if m.mac != nil {
  25499. fields = append(fields, token.FieldMAC)
  25500. }
  25501. if m.organization_id != nil {
  25502. fields = append(fields, token.FieldOrganizationID)
  25503. }
  25504. if m.agent != nil {
  25505. fields = append(fields, token.FieldAgentID)
  25506. }
  25507. if m.custom_agent_base != nil {
  25508. fields = append(fields, token.FieldCustomAgentBase)
  25509. }
  25510. if m.custom_agent_key != nil {
  25511. fields = append(fields, token.FieldCustomAgentKey)
  25512. }
  25513. if m.openai_base != nil {
  25514. fields = append(fields, token.FieldOpenaiBase)
  25515. }
  25516. if m.openai_key != nil {
  25517. fields = append(fields, token.FieldOpenaiKey)
  25518. }
  25519. return fields
  25520. }
  25521. // Field returns the value of a field with the given name. The second boolean
  25522. // return value indicates that this field was not set, or was not defined in the
  25523. // schema.
  25524. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25525. switch name {
  25526. case token.FieldCreatedAt:
  25527. return m.CreatedAt()
  25528. case token.FieldUpdatedAt:
  25529. return m.UpdatedAt()
  25530. case token.FieldDeletedAt:
  25531. return m.DeletedAt()
  25532. case token.FieldExpireAt:
  25533. return m.ExpireAt()
  25534. case token.FieldToken:
  25535. return m.Token()
  25536. case token.FieldMAC:
  25537. return m.MAC()
  25538. case token.FieldOrganizationID:
  25539. return m.OrganizationID()
  25540. case token.FieldAgentID:
  25541. return m.AgentID()
  25542. case token.FieldCustomAgentBase:
  25543. return m.CustomAgentBase()
  25544. case token.FieldCustomAgentKey:
  25545. return m.CustomAgentKey()
  25546. case token.FieldOpenaiBase:
  25547. return m.OpenaiBase()
  25548. case token.FieldOpenaiKey:
  25549. return m.OpenaiKey()
  25550. }
  25551. return nil, false
  25552. }
  25553. // OldField returns the old value of the field from the database. An error is
  25554. // returned if the mutation operation is not UpdateOne, or the query to the
  25555. // database failed.
  25556. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25557. switch name {
  25558. case token.FieldCreatedAt:
  25559. return m.OldCreatedAt(ctx)
  25560. case token.FieldUpdatedAt:
  25561. return m.OldUpdatedAt(ctx)
  25562. case token.FieldDeletedAt:
  25563. return m.OldDeletedAt(ctx)
  25564. case token.FieldExpireAt:
  25565. return m.OldExpireAt(ctx)
  25566. case token.FieldToken:
  25567. return m.OldToken(ctx)
  25568. case token.FieldMAC:
  25569. return m.OldMAC(ctx)
  25570. case token.FieldOrganizationID:
  25571. return m.OldOrganizationID(ctx)
  25572. case token.FieldAgentID:
  25573. return m.OldAgentID(ctx)
  25574. case token.FieldCustomAgentBase:
  25575. return m.OldCustomAgentBase(ctx)
  25576. case token.FieldCustomAgentKey:
  25577. return m.OldCustomAgentKey(ctx)
  25578. case token.FieldOpenaiBase:
  25579. return m.OldOpenaiBase(ctx)
  25580. case token.FieldOpenaiKey:
  25581. return m.OldOpenaiKey(ctx)
  25582. }
  25583. return nil, fmt.Errorf("unknown Token field %s", name)
  25584. }
  25585. // SetField sets the value of a field with the given name. It returns an error if
  25586. // the field is not defined in the schema, or if the type mismatched the field
  25587. // type.
  25588. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25589. switch name {
  25590. case token.FieldCreatedAt:
  25591. v, ok := value.(time.Time)
  25592. if !ok {
  25593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25594. }
  25595. m.SetCreatedAt(v)
  25596. return nil
  25597. case token.FieldUpdatedAt:
  25598. v, ok := value.(time.Time)
  25599. if !ok {
  25600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25601. }
  25602. m.SetUpdatedAt(v)
  25603. return nil
  25604. case token.FieldDeletedAt:
  25605. v, ok := value.(time.Time)
  25606. if !ok {
  25607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25608. }
  25609. m.SetDeletedAt(v)
  25610. return nil
  25611. case token.FieldExpireAt:
  25612. v, ok := value.(time.Time)
  25613. if !ok {
  25614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25615. }
  25616. m.SetExpireAt(v)
  25617. return nil
  25618. case token.FieldToken:
  25619. v, ok := value.(string)
  25620. if !ok {
  25621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25622. }
  25623. m.SetToken(v)
  25624. return nil
  25625. case token.FieldMAC:
  25626. v, ok := value.(string)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.SetMAC(v)
  25631. return nil
  25632. case token.FieldOrganizationID:
  25633. v, ok := value.(uint64)
  25634. if !ok {
  25635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25636. }
  25637. m.SetOrganizationID(v)
  25638. return nil
  25639. case token.FieldAgentID:
  25640. v, ok := value.(uint64)
  25641. if !ok {
  25642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25643. }
  25644. m.SetAgentID(v)
  25645. return nil
  25646. case token.FieldCustomAgentBase:
  25647. v, ok := value.(string)
  25648. if !ok {
  25649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25650. }
  25651. m.SetCustomAgentBase(v)
  25652. return nil
  25653. case token.FieldCustomAgentKey:
  25654. v, ok := value.(string)
  25655. if !ok {
  25656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25657. }
  25658. m.SetCustomAgentKey(v)
  25659. return nil
  25660. case token.FieldOpenaiBase:
  25661. v, ok := value.(string)
  25662. if !ok {
  25663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25664. }
  25665. m.SetOpenaiBase(v)
  25666. return nil
  25667. case token.FieldOpenaiKey:
  25668. v, ok := value.(string)
  25669. if !ok {
  25670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25671. }
  25672. m.SetOpenaiKey(v)
  25673. return nil
  25674. }
  25675. return fmt.Errorf("unknown Token field %s", name)
  25676. }
  25677. // AddedFields returns all numeric fields that were incremented/decremented during
  25678. // this mutation.
  25679. func (m *TokenMutation) AddedFields() []string {
  25680. var fields []string
  25681. if m.addorganization_id != nil {
  25682. fields = append(fields, token.FieldOrganizationID)
  25683. }
  25684. return fields
  25685. }
  25686. // AddedField returns the numeric value that was incremented/decremented on a field
  25687. // with the given name. The second boolean return value indicates that this field
  25688. // was not set, or was not defined in the schema.
  25689. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25690. switch name {
  25691. case token.FieldOrganizationID:
  25692. return m.AddedOrganizationID()
  25693. }
  25694. return nil, false
  25695. }
  25696. // AddField adds the value to the field with the given name. It returns an error if
  25697. // the field is not defined in the schema, or if the type mismatched the field
  25698. // type.
  25699. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25700. switch name {
  25701. case token.FieldOrganizationID:
  25702. v, ok := value.(int64)
  25703. if !ok {
  25704. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25705. }
  25706. m.AddOrganizationID(v)
  25707. return nil
  25708. }
  25709. return fmt.Errorf("unknown Token numeric field %s", name)
  25710. }
  25711. // ClearedFields returns all nullable fields that were cleared during this
  25712. // mutation.
  25713. func (m *TokenMutation) ClearedFields() []string {
  25714. var fields []string
  25715. if m.FieldCleared(token.FieldDeletedAt) {
  25716. fields = append(fields, token.FieldDeletedAt)
  25717. }
  25718. if m.FieldCleared(token.FieldExpireAt) {
  25719. fields = append(fields, token.FieldExpireAt)
  25720. }
  25721. if m.FieldCleared(token.FieldToken) {
  25722. fields = append(fields, token.FieldToken)
  25723. }
  25724. if m.FieldCleared(token.FieldMAC) {
  25725. fields = append(fields, token.FieldMAC)
  25726. }
  25727. if m.FieldCleared(token.FieldCustomAgentBase) {
  25728. fields = append(fields, token.FieldCustomAgentBase)
  25729. }
  25730. if m.FieldCleared(token.FieldCustomAgentKey) {
  25731. fields = append(fields, token.FieldCustomAgentKey)
  25732. }
  25733. if m.FieldCleared(token.FieldOpenaiBase) {
  25734. fields = append(fields, token.FieldOpenaiBase)
  25735. }
  25736. if m.FieldCleared(token.FieldOpenaiKey) {
  25737. fields = append(fields, token.FieldOpenaiKey)
  25738. }
  25739. return fields
  25740. }
  25741. // FieldCleared returns a boolean indicating if a field with the given name was
  25742. // cleared in this mutation.
  25743. func (m *TokenMutation) FieldCleared(name string) bool {
  25744. _, ok := m.clearedFields[name]
  25745. return ok
  25746. }
  25747. // ClearField clears the value of the field with the given name. It returns an
  25748. // error if the field is not defined in the schema.
  25749. func (m *TokenMutation) ClearField(name string) error {
  25750. switch name {
  25751. case token.FieldDeletedAt:
  25752. m.ClearDeletedAt()
  25753. return nil
  25754. case token.FieldExpireAt:
  25755. m.ClearExpireAt()
  25756. return nil
  25757. case token.FieldToken:
  25758. m.ClearToken()
  25759. return nil
  25760. case token.FieldMAC:
  25761. m.ClearMAC()
  25762. return nil
  25763. case token.FieldCustomAgentBase:
  25764. m.ClearCustomAgentBase()
  25765. return nil
  25766. case token.FieldCustomAgentKey:
  25767. m.ClearCustomAgentKey()
  25768. return nil
  25769. case token.FieldOpenaiBase:
  25770. m.ClearOpenaiBase()
  25771. return nil
  25772. case token.FieldOpenaiKey:
  25773. m.ClearOpenaiKey()
  25774. return nil
  25775. }
  25776. return fmt.Errorf("unknown Token nullable field %s", name)
  25777. }
  25778. // ResetField resets all changes in the mutation for the field with the given name.
  25779. // It returns an error if the field is not defined in the schema.
  25780. func (m *TokenMutation) ResetField(name string) error {
  25781. switch name {
  25782. case token.FieldCreatedAt:
  25783. m.ResetCreatedAt()
  25784. return nil
  25785. case token.FieldUpdatedAt:
  25786. m.ResetUpdatedAt()
  25787. return nil
  25788. case token.FieldDeletedAt:
  25789. m.ResetDeletedAt()
  25790. return nil
  25791. case token.FieldExpireAt:
  25792. m.ResetExpireAt()
  25793. return nil
  25794. case token.FieldToken:
  25795. m.ResetToken()
  25796. return nil
  25797. case token.FieldMAC:
  25798. m.ResetMAC()
  25799. return nil
  25800. case token.FieldOrganizationID:
  25801. m.ResetOrganizationID()
  25802. return nil
  25803. case token.FieldAgentID:
  25804. m.ResetAgentID()
  25805. return nil
  25806. case token.FieldCustomAgentBase:
  25807. m.ResetCustomAgentBase()
  25808. return nil
  25809. case token.FieldCustomAgentKey:
  25810. m.ResetCustomAgentKey()
  25811. return nil
  25812. case token.FieldOpenaiBase:
  25813. m.ResetOpenaiBase()
  25814. return nil
  25815. case token.FieldOpenaiKey:
  25816. m.ResetOpenaiKey()
  25817. return nil
  25818. }
  25819. return fmt.Errorf("unknown Token field %s", name)
  25820. }
  25821. // AddedEdges returns all edge names that were set/added in this mutation.
  25822. func (m *TokenMutation) AddedEdges() []string {
  25823. edges := make([]string, 0, 1)
  25824. if m.agent != nil {
  25825. edges = append(edges, token.EdgeAgent)
  25826. }
  25827. return edges
  25828. }
  25829. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25830. // name in this mutation.
  25831. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25832. switch name {
  25833. case token.EdgeAgent:
  25834. if id := m.agent; id != nil {
  25835. return []ent.Value{*id}
  25836. }
  25837. }
  25838. return nil
  25839. }
  25840. // RemovedEdges returns all edge names that were removed in this mutation.
  25841. func (m *TokenMutation) RemovedEdges() []string {
  25842. edges := make([]string, 0, 1)
  25843. return edges
  25844. }
  25845. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25846. // the given name in this mutation.
  25847. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25848. return nil
  25849. }
  25850. // ClearedEdges returns all edge names that were cleared in this mutation.
  25851. func (m *TokenMutation) ClearedEdges() []string {
  25852. edges := make([]string, 0, 1)
  25853. if m.clearedagent {
  25854. edges = append(edges, token.EdgeAgent)
  25855. }
  25856. return edges
  25857. }
  25858. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25859. // was cleared in this mutation.
  25860. func (m *TokenMutation) EdgeCleared(name string) bool {
  25861. switch name {
  25862. case token.EdgeAgent:
  25863. return m.clearedagent
  25864. }
  25865. return false
  25866. }
  25867. // ClearEdge clears the value of the edge with the given name. It returns an error
  25868. // if that edge is not defined in the schema.
  25869. func (m *TokenMutation) ClearEdge(name string) error {
  25870. switch name {
  25871. case token.EdgeAgent:
  25872. m.ClearAgent()
  25873. return nil
  25874. }
  25875. return fmt.Errorf("unknown Token unique edge %s", name)
  25876. }
  25877. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25878. // It returns an error if the edge is not defined in the schema.
  25879. func (m *TokenMutation) ResetEdge(name string) error {
  25880. switch name {
  25881. case token.EdgeAgent:
  25882. m.ResetAgent()
  25883. return nil
  25884. }
  25885. return fmt.Errorf("unknown Token edge %s", name)
  25886. }
  25887. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25888. type TutorialMutation struct {
  25889. config
  25890. op Op
  25891. typ string
  25892. id *uint64
  25893. created_at *time.Time
  25894. updated_at *time.Time
  25895. deleted_at *time.Time
  25896. index *int
  25897. addindex *int
  25898. title *string
  25899. content *string
  25900. organization_id *uint64
  25901. addorganization_id *int64
  25902. clearedFields map[string]struct{}
  25903. employee *uint64
  25904. clearedemployee bool
  25905. done bool
  25906. oldValue func(context.Context) (*Tutorial, error)
  25907. predicates []predicate.Tutorial
  25908. }
  25909. var _ ent.Mutation = (*TutorialMutation)(nil)
  25910. // tutorialOption allows management of the mutation configuration using functional options.
  25911. type tutorialOption func(*TutorialMutation)
  25912. // newTutorialMutation creates new mutation for the Tutorial entity.
  25913. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25914. m := &TutorialMutation{
  25915. config: c,
  25916. op: op,
  25917. typ: TypeTutorial,
  25918. clearedFields: make(map[string]struct{}),
  25919. }
  25920. for _, opt := range opts {
  25921. opt(m)
  25922. }
  25923. return m
  25924. }
  25925. // withTutorialID sets the ID field of the mutation.
  25926. func withTutorialID(id uint64) tutorialOption {
  25927. return func(m *TutorialMutation) {
  25928. var (
  25929. err error
  25930. once sync.Once
  25931. value *Tutorial
  25932. )
  25933. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25934. once.Do(func() {
  25935. if m.done {
  25936. err = errors.New("querying old values post mutation is not allowed")
  25937. } else {
  25938. value, err = m.Client().Tutorial.Get(ctx, id)
  25939. }
  25940. })
  25941. return value, err
  25942. }
  25943. m.id = &id
  25944. }
  25945. }
  25946. // withTutorial sets the old Tutorial of the mutation.
  25947. func withTutorial(node *Tutorial) tutorialOption {
  25948. return func(m *TutorialMutation) {
  25949. m.oldValue = func(context.Context) (*Tutorial, error) {
  25950. return node, nil
  25951. }
  25952. m.id = &node.ID
  25953. }
  25954. }
  25955. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25956. // executed in a transaction (ent.Tx), a transactional client is returned.
  25957. func (m TutorialMutation) Client() *Client {
  25958. client := &Client{config: m.config}
  25959. client.init()
  25960. return client
  25961. }
  25962. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25963. // it returns an error otherwise.
  25964. func (m TutorialMutation) Tx() (*Tx, error) {
  25965. if _, ok := m.driver.(*txDriver); !ok {
  25966. return nil, errors.New("ent: mutation is not running in a transaction")
  25967. }
  25968. tx := &Tx{config: m.config}
  25969. tx.init()
  25970. return tx, nil
  25971. }
  25972. // SetID sets the value of the id field. Note that this
  25973. // operation is only accepted on creation of Tutorial entities.
  25974. func (m *TutorialMutation) SetID(id uint64) {
  25975. m.id = &id
  25976. }
  25977. // ID returns the ID value in the mutation. Note that the ID is only available
  25978. // if it was provided to the builder or after it was returned from the database.
  25979. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25980. if m.id == nil {
  25981. return
  25982. }
  25983. return *m.id, true
  25984. }
  25985. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25986. // That means, if the mutation is applied within a transaction with an isolation level such
  25987. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25988. // or updated by the mutation.
  25989. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25990. switch {
  25991. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25992. id, exists := m.ID()
  25993. if exists {
  25994. return []uint64{id}, nil
  25995. }
  25996. fallthrough
  25997. case m.op.Is(OpUpdate | OpDelete):
  25998. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25999. default:
  26000. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26001. }
  26002. }
  26003. // SetCreatedAt sets the "created_at" field.
  26004. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  26005. m.created_at = &t
  26006. }
  26007. // CreatedAt returns the value of the "created_at" field in the mutation.
  26008. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  26009. v := m.created_at
  26010. if v == nil {
  26011. return
  26012. }
  26013. return *v, true
  26014. }
  26015. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  26016. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26017. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26018. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26019. if !m.op.Is(OpUpdateOne) {
  26020. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26021. }
  26022. if m.id == nil || m.oldValue == nil {
  26023. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26024. }
  26025. oldValue, err := m.oldValue(ctx)
  26026. if err != nil {
  26027. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26028. }
  26029. return oldValue.CreatedAt, nil
  26030. }
  26031. // ResetCreatedAt resets all changes to the "created_at" field.
  26032. func (m *TutorialMutation) ResetCreatedAt() {
  26033. m.created_at = nil
  26034. }
  26035. // SetUpdatedAt sets the "updated_at" field.
  26036. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  26037. m.updated_at = &t
  26038. }
  26039. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26040. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  26041. v := m.updated_at
  26042. if v == nil {
  26043. return
  26044. }
  26045. return *v, true
  26046. }
  26047. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  26048. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26049. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26050. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26051. if !m.op.Is(OpUpdateOne) {
  26052. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26053. }
  26054. if m.id == nil || m.oldValue == nil {
  26055. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26056. }
  26057. oldValue, err := m.oldValue(ctx)
  26058. if err != nil {
  26059. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26060. }
  26061. return oldValue.UpdatedAt, nil
  26062. }
  26063. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26064. func (m *TutorialMutation) ResetUpdatedAt() {
  26065. m.updated_at = nil
  26066. }
  26067. // SetDeletedAt sets the "deleted_at" field.
  26068. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  26069. m.deleted_at = &t
  26070. }
  26071. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  26072. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  26073. v := m.deleted_at
  26074. if v == nil {
  26075. return
  26076. }
  26077. return *v, true
  26078. }
  26079. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26080. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26081. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26082. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26083. if !m.op.Is(OpUpdateOne) {
  26084. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26085. }
  26086. if m.id == nil || m.oldValue == nil {
  26087. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26088. }
  26089. oldValue, err := m.oldValue(ctx)
  26090. if err != nil {
  26091. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26092. }
  26093. return oldValue.DeletedAt, nil
  26094. }
  26095. // ClearDeletedAt clears the value of the "deleted_at" field.
  26096. func (m *TutorialMutation) ClearDeletedAt() {
  26097. m.deleted_at = nil
  26098. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26099. }
  26100. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26101. func (m *TutorialMutation) DeletedAtCleared() bool {
  26102. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26103. return ok
  26104. }
  26105. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26106. func (m *TutorialMutation) ResetDeletedAt() {
  26107. m.deleted_at = nil
  26108. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26109. }
  26110. // SetEmployeeID sets the "employee_id" field.
  26111. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26112. m.employee = &u
  26113. }
  26114. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26115. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26116. v := m.employee
  26117. if v == nil {
  26118. return
  26119. }
  26120. return *v, true
  26121. }
  26122. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26123. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26125. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26126. if !m.op.Is(OpUpdateOne) {
  26127. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26128. }
  26129. if m.id == nil || m.oldValue == nil {
  26130. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26131. }
  26132. oldValue, err := m.oldValue(ctx)
  26133. if err != nil {
  26134. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26135. }
  26136. return oldValue.EmployeeID, nil
  26137. }
  26138. // ResetEmployeeID resets all changes to the "employee_id" field.
  26139. func (m *TutorialMutation) ResetEmployeeID() {
  26140. m.employee = nil
  26141. }
  26142. // SetIndex sets the "index" field.
  26143. func (m *TutorialMutation) SetIndex(i int) {
  26144. m.index = &i
  26145. m.addindex = nil
  26146. }
  26147. // Index returns the value of the "index" field in the mutation.
  26148. func (m *TutorialMutation) Index() (r int, exists bool) {
  26149. v := m.index
  26150. if v == nil {
  26151. return
  26152. }
  26153. return *v, true
  26154. }
  26155. // OldIndex returns the old "index" field's value of the Tutorial entity.
  26156. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26157. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26158. func (m *TutorialMutation) OldIndex(ctx context.Context) (v int, err error) {
  26159. if !m.op.Is(OpUpdateOne) {
  26160. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26161. }
  26162. if m.id == nil || m.oldValue == nil {
  26163. return v, errors.New("OldIndex requires an ID field in the mutation")
  26164. }
  26165. oldValue, err := m.oldValue(ctx)
  26166. if err != nil {
  26167. return v, fmt.Errorf("querying old value for OldIndex: %w", err)
  26168. }
  26169. return oldValue.Index, nil
  26170. }
  26171. // AddIndex adds i to the "index" field.
  26172. func (m *TutorialMutation) AddIndex(i int) {
  26173. if m.addindex != nil {
  26174. *m.addindex += i
  26175. } else {
  26176. m.addindex = &i
  26177. }
  26178. }
  26179. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26180. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26181. v := m.addindex
  26182. if v == nil {
  26183. return
  26184. }
  26185. return *v, true
  26186. }
  26187. // ResetIndex resets all changes to the "index" field.
  26188. func (m *TutorialMutation) ResetIndex() {
  26189. m.index = nil
  26190. m.addindex = nil
  26191. }
  26192. // SetTitle sets the "title" field.
  26193. func (m *TutorialMutation) SetTitle(s string) {
  26194. m.title = &s
  26195. }
  26196. // Title returns the value of the "title" field in the mutation.
  26197. func (m *TutorialMutation) Title() (r string, exists bool) {
  26198. v := m.title
  26199. if v == nil {
  26200. return
  26201. }
  26202. return *v, true
  26203. }
  26204. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26205. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26207. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26208. if !m.op.Is(OpUpdateOne) {
  26209. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26210. }
  26211. if m.id == nil || m.oldValue == nil {
  26212. return v, errors.New("OldTitle requires an ID field in the mutation")
  26213. }
  26214. oldValue, err := m.oldValue(ctx)
  26215. if err != nil {
  26216. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26217. }
  26218. return oldValue.Title, nil
  26219. }
  26220. // ResetTitle resets all changes to the "title" field.
  26221. func (m *TutorialMutation) ResetTitle() {
  26222. m.title = nil
  26223. }
  26224. // SetContent sets the "content" field.
  26225. func (m *TutorialMutation) SetContent(s string) {
  26226. m.content = &s
  26227. }
  26228. // Content returns the value of the "content" field in the mutation.
  26229. func (m *TutorialMutation) Content() (r string, exists bool) {
  26230. v := m.content
  26231. if v == nil {
  26232. return
  26233. }
  26234. return *v, true
  26235. }
  26236. // OldContent returns the old "content" field's value of the Tutorial entity.
  26237. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26238. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26239. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26240. if !m.op.Is(OpUpdateOne) {
  26241. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26242. }
  26243. if m.id == nil || m.oldValue == nil {
  26244. return v, errors.New("OldContent requires an ID field in the mutation")
  26245. }
  26246. oldValue, err := m.oldValue(ctx)
  26247. if err != nil {
  26248. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26249. }
  26250. return oldValue.Content, nil
  26251. }
  26252. // ResetContent resets all changes to the "content" field.
  26253. func (m *TutorialMutation) ResetContent() {
  26254. m.content = nil
  26255. }
  26256. // SetOrganizationID sets the "organization_id" field.
  26257. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26258. m.organization_id = &u
  26259. m.addorganization_id = nil
  26260. }
  26261. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26262. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26263. v := m.organization_id
  26264. if v == nil {
  26265. return
  26266. }
  26267. return *v, true
  26268. }
  26269. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26270. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26272. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26273. if !m.op.Is(OpUpdateOne) {
  26274. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26275. }
  26276. if m.id == nil || m.oldValue == nil {
  26277. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26278. }
  26279. oldValue, err := m.oldValue(ctx)
  26280. if err != nil {
  26281. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26282. }
  26283. return oldValue.OrganizationID, nil
  26284. }
  26285. // AddOrganizationID adds u to the "organization_id" field.
  26286. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26287. if m.addorganization_id != nil {
  26288. *m.addorganization_id += u
  26289. } else {
  26290. m.addorganization_id = &u
  26291. }
  26292. }
  26293. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26294. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26295. v := m.addorganization_id
  26296. if v == nil {
  26297. return
  26298. }
  26299. return *v, true
  26300. }
  26301. // ResetOrganizationID resets all changes to the "organization_id" field.
  26302. func (m *TutorialMutation) ResetOrganizationID() {
  26303. m.organization_id = nil
  26304. m.addorganization_id = nil
  26305. }
  26306. // ClearEmployee clears the "employee" edge to the Employee entity.
  26307. func (m *TutorialMutation) ClearEmployee() {
  26308. m.clearedemployee = true
  26309. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26310. }
  26311. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26312. func (m *TutorialMutation) EmployeeCleared() bool {
  26313. return m.clearedemployee
  26314. }
  26315. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26316. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26317. // EmployeeID instead. It exists only for internal usage by the builders.
  26318. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26319. if id := m.employee; id != nil {
  26320. ids = append(ids, *id)
  26321. }
  26322. return
  26323. }
  26324. // ResetEmployee resets all changes to the "employee" edge.
  26325. func (m *TutorialMutation) ResetEmployee() {
  26326. m.employee = nil
  26327. m.clearedemployee = false
  26328. }
  26329. // Where appends a list predicates to the TutorialMutation builder.
  26330. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26331. m.predicates = append(m.predicates, ps...)
  26332. }
  26333. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26334. // users can use type-assertion to append predicates that do not depend on any generated package.
  26335. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26336. p := make([]predicate.Tutorial, len(ps))
  26337. for i := range ps {
  26338. p[i] = ps[i]
  26339. }
  26340. m.Where(p...)
  26341. }
  26342. // Op returns the operation name.
  26343. func (m *TutorialMutation) Op() Op {
  26344. return m.op
  26345. }
  26346. // SetOp allows setting the mutation operation.
  26347. func (m *TutorialMutation) SetOp(op Op) {
  26348. m.op = op
  26349. }
  26350. // Type returns the node type of this mutation (Tutorial).
  26351. func (m *TutorialMutation) Type() string {
  26352. return m.typ
  26353. }
  26354. // Fields returns all fields that were changed during this mutation. Note that in
  26355. // order to get all numeric fields that were incremented/decremented, call
  26356. // AddedFields().
  26357. func (m *TutorialMutation) Fields() []string {
  26358. fields := make([]string, 0, 8)
  26359. if m.created_at != nil {
  26360. fields = append(fields, tutorial.FieldCreatedAt)
  26361. }
  26362. if m.updated_at != nil {
  26363. fields = append(fields, tutorial.FieldUpdatedAt)
  26364. }
  26365. if m.deleted_at != nil {
  26366. fields = append(fields, tutorial.FieldDeletedAt)
  26367. }
  26368. if m.employee != nil {
  26369. fields = append(fields, tutorial.FieldEmployeeID)
  26370. }
  26371. if m.index != nil {
  26372. fields = append(fields, tutorial.FieldIndex)
  26373. }
  26374. if m.title != nil {
  26375. fields = append(fields, tutorial.FieldTitle)
  26376. }
  26377. if m.content != nil {
  26378. fields = append(fields, tutorial.FieldContent)
  26379. }
  26380. if m.organization_id != nil {
  26381. fields = append(fields, tutorial.FieldOrganizationID)
  26382. }
  26383. return fields
  26384. }
  26385. // Field returns the value of a field with the given name. The second boolean
  26386. // return value indicates that this field was not set, or was not defined in the
  26387. // schema.
  26388. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26389. switch name {
  26390. case tutorial.FieldCreatedAt:
  26391. return m.CreatedAt()
  26392. case tutorial.FieldUpdatedAt:
  26393. return m.UpdatedAt()
  26394. case tutorial.FieldDeletedAt:
  26395. return m.DeletedAt()
  26396. case tutorial.FieldEmployeeID:
  26397. return m.EmployeeID()
  26398. case tutorial.FieldIndex:
  26399. return m.Index()
  26400. case tutorial.FieldTitle:
  26401. return m.Title()
  26402. case tutorial.FieldContent:
  26403. return m.Content()
  26404. case tutorial.FieldOrganizationID:
  26405. return m.OrganizationID()
  26406. }
  26407. return nil, false
  26408. }
  26409. // OldField returns the old value of the field from the database. An error is
  26410. // returned if the mutation operation is not UpdateOne, or the query to the
  26411. // database failed.
  26412. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26413. switch name {
  26414. case tutorial.FieldCreatedAt:
  26415. return m.OldCreatedAt(ctx)
  26416. case tutorial.FieldUpdatedAt:
  26417. return m.OldUpdatedAt(ctx)
  26418. case tutorial.FieldDeletedAt:
  26419. return m.OldDeletedAt(ctx)
  26420. case tutorial.FieldEmployeeID:
  26421. return m.OldEmployeeID(ctx)
  26422. case tutorial.FieldIndex:
  26423. return m.OldIndex(ctx)
  26424. case tutorial.FieldTitle:
  26425. return m.OldTitle(ctx)
  26426. case tutorial.FieldContent:
  26427. return m.OldContent(ctx)
  26428. case tutorial.FieldOrganizationID:
  26429. return m.OldOrganizationID(ctx)
  26430. }
  26431. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26432. }
  26433. // SetField sets the value of a field with the given name. It returns an error if
  26434. // the field is not defined in the schema, or if the type mismatched the field
  26435. // type.
  26436. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26437. switch name {
  26438. case tutorial.FieldCreatedAt:
  26439. v, ok := value.(time.Time)
  26440. if !ok {
  26441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26442. }
  26443. m.SetCreatedAt(v)
  26444. return nil
  26445. case tutorial.FieldUpdatedAt:
  26446. v, ok := value.(time.Time)
  26447. if !ok {
  26448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26449. }
  26450. m.SetUpdatedAt(v)
  26451. return nil
  26452. case tutorial.FieldDeletedAt:
  26453. v, ok := value.(time.Time)
  26454. if !ok {
  26455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26456. }
  26457. m.SetDeletedAt(v)
  26458. return nil
  26459. case tutorial.FieldEmployeeID:
  26460. v, ok := value.(uint64)
  26461. if !ok {
  26462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26463. }
  26464. m.SetEmployeeID(v)
  26465. return nil
  26466. case tutorial.FieldIndex:
  26467. v, ok := value.(int)
  26468. if !ok {
  26469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26470. }
  26471. m.SetIndex(v)
  26472. return nil
  26473. case tutorial.FieldTitle:
  26474. v, ok := value.(string)
  26475. if !ok {
  26476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26477. }
  26478. m.SetTitle(v)
  26479. return nil
  26480. case tutorial.FieldContent:
  26481. v, ok := value.(string)
  26482. if !ok {
  26483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26484. }
  26485. m.SetContent(v)
  26486. return nil
  26487. case tutorial.FieldOrganizationID:
  26488. v, ok := value.(uint64)
  26489. if !ok {
  26490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26491. }
  26492. m.SetOrganizationID(v)
  26493. return nil
  26494. }
  26495. return fmt.Errorf("unknown Tutorial field %s", name)
  26496. }
  26497. // AddedFields returns all numeric fields that were incremented/decremented during
  26498. // this mutation.
  26499. func (m *TutorialMutation) AddedFields() []string {
  26500. var fields []string
  26501. if m.addindex != nil {
  26502. fields = append(fields, tutorial.FieldIndex)
  26503. }
  26504. if m.addorganization_id != nil {
  26505. fields = append(fields, tutorial.FieldOrganizationID)
  26506. }
  26507. return fields
  26508. }
  26509. // AddedField returns the numeric value that was incremented/decremented on a field
  26510. // with the given name. The second boolean return value indicates that this field
  26511. // was not set, or was not defined in the schema.
  26512. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26513. switch name {
  26514. case tutorial.FieldIndex:
  26515. return m.AddedIndex()
  26516. case tutorial.FieldOrganizationID:
  26517. return m.AddedOrganizationID()
  26518. }
  26519. return nil, false
  26520. }
  26521. // AddField adds the value to the field with the given name. It returns an error if
  26522. // the field is not defined in the schema, or if the type mismatched the field
  26523. // type.
  26524. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26525. switch name {
  26526. case tutorial.FieldIndex:
  26527. v, ok := value.(int)
  26528. if !ok {
  26529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26530. }
  26531. m.AddIndex(v)
  26532. return nil
  26533. case tutorial.FieldOrganizationID:
  26534. v, ok := value.(int64)
  26535. if !ok {
  26536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26537. }
  26538. m.AddOrganizationID(v)
  26539. return nil
  26540. }
  26541. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26542. }
  26543. // ClearedFields returns all nullable fields that were cleared during this
  26544. // mutation.
  26545. func (m *TutorialMutation) ClearedFields() []string {
  26546. var fields []string
  26547. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26548. fields = append(fields, tutorial.FieldDeletedAt)
  26549. }
  26550. return fields
  26551. }
  26552. // FieldCleared returns a boolean indicating if a field with the given name was
  26553. // cleared in this mutation.
  26554. func (m *TutorialMutation) FieldCleared(name string) bool {
  26555. _, ok := m.clearedFields[name]
  26556. return ok
  26557. }
  26558. // ClearField clears the value of the field with the given name. It returns an
  26559. // error if the field is not defined in the schema.
  26560. func (m *TutorialMutation) ClearField(name string) error {
  26561. switch name {
  26562. case tutorial.FieldDeletedAt:
  26563. m.ClearDeletedAt()
  26564. return nil
  26565. }
  26566. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26567. }
  26568. // ResetField resets all changes in the mutation for the field with the given name.
  26569. // It returns an error if the field is not defined in the schema.
  26570. func (m *TutorialMutation) ResetField(name string) error {
  26571. switch name {
  26572. case tutorial.FieldCreatedAt:
  26573. m.ResetCreatedAt()
  26574. return nil
  26575. case tutorial.FieldUpdatedAt:
  26576. m.ResetUpdatedAt()
  26577. return nil
  26578. case tutorial.FieldDeletedAt:
  26579. m.ResetDeletedAt()
  26580. return nil
  26581. case tutorial.FieldEmployeeID:
  26582. m.ResetEmployeeID()
  26583. return nil
  26584. case tutorial.FieldIndex:
  26585. m.ResetIndex()
  26586. return nil
  26587. case tutorial.FieldTitle:
  26588. m.ResetTitle()
  26589. return nil
  26590. case tutorial.FieldContent:
  26591. m.ResetContent()
  26592. return nil
  26593. case tutorial.FieldOrganizationID:
  26594. m.ResetOrganizationID()
  26595. return nil
  26596. }
  26597. return fmt.Errorf("unknown Tutorial field %s", name)
  26598. }
  26599. // AddedEdges returns all edge names that were set/added in this mutation.
  26600. func (m *TutorialMutation) AddedEdges() []string {
  26601. edges := make([]string, 0, 1)
  26602. if m.employee != nil {
  26603. edges = append(edges, tutorial.EdgeEmployee)
  26604. }
  26605. return edges
  26606. }
  26607. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26608. // name in this mutation.
  26609. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26610. switch name {
  26611. case tutorial.EdgeEmployee:
  26612. if id := m.employee; id != nil {
  26613. return []ent.Value{*id}
  26614. }
  26615. }
  26616. return nil
  26617. }
  26618. // RemovedEdges returns all edge names that were removed in this mutation.
  26619. func (m *TutorialMutation) RemovedEdges() []string {
  26620. edges := make([]string, 0, 1)
  26621. return edges
  26622. }
  26623. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26624. // the given name in this mutation.
  26625. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26626. return nil
  26627. }
  26628. // ClearedEdges returns all edge names that were cleared in this mutation.
  26629. func (m *TutorialMutation) ClearedEdges() []string {
  26630. edges := make([]string, 0, 1)
  26631. if m.clearedemployee {
  26632. edges = append(edges, tutorial.EdgeEmployee)
  26633. }
  26634. return edges
  26635. }
  26636. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26637. // was cleared in this mutation.
  26638. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26639. switch name {
  26640. case tutorial.EdgeEmployee:
  26641. return m.clearedemployee
  26642. }
  26643. return false
  26644. }
  26645. // ClearEdge clears the value of the edge with the given name. It returns an error
  26646. // if that edge is not defined in the schema.
  26647. func (m *TutorialMutation) ClearEdge(name string) error {
  26648. switch name {
  26649. case tutorial.EdgeEmployee:
  26650. m.ClearEmployee()
  26651. return nil
  26652. }
  26653. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26654. }
  26655. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26656. // It returns an error if the edge is not defined in the schema.
  26657. func (m *TutorialMutation) ResetEdge(name string) error {
  26658. switch name {
  26659. case tutorial.EdgeEmployee:
  26660. m.ResetEmployee()
  26661. return nil
  26662. }
  26663. return fmt.Errorf("unknown Tutorial edge %s", name)
  26664. }
  26665. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26666. type UsageDetailMutation struct {
  26667. config
  26668. op Op
  26669. typ string
  26670. id *uint64
  26671. created_at *time.Time
  26672. updated_at *time.Time
  26673. status *uint8
  26674. addstatus *int8
  26675. _type *int
  26676. add_type *int
  26677. bot_id *string
  26678. receiver_id *string
  26679. app *int
  26680. addapp *int
  26681. session_id *uint64
  26682. addsession_id *int64
  26683. request *string
  26684. response *string
  26685. original_data *custom_types.OriginalData
  26686. total_tokens *uint64
  26687. addtotal_tokens *int64
  26688. prompt_tokens *uint64
  26689. addprompt_tokens *int64
  26690. completion_tokens *uint64
  26691. addcompletion_tokens *int64
  26692. organization_id *uint64
  26693. addorganization_id *int64
  26694. clearedFields map[string]struct{}
  26695. done bool
  26696. oldValue func(context.Context) (*UsageDetail, error)
  26697. predicates []predicate.UsageDetail
  26698. }
  26699. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26700. // usagedetailOption allows management of the mutation configuration using functional options.
  26701. type usagedetailOption func(*UsageDetailMutation)
  26702. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26703. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26704. m := &UsageDetailMutation{
  26705. config: c,
  26706. op: op,
  26707. typ: TypeUsageDetail,
  26708. clearedFields: make(map[string]struct{}),
  26709. }
  26710. for _, opt := range opts {
  26711. opt(m)
  26712. }
  26713. return m
  26714. }
  26715. // withUsageDetailID sets the ID field of the mutation.
  26716. func withUsageDetailID(id uint64) usagedetailOption {
  26717. return func(m *UsageDetailMutation) {
  26718. var (
  26719. err error
  26720. once sync.Once
  26721. value *UsageDetail
  26722. )
  26723. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26724. once.Do(func() {
  26725. if m.done {
  26726. err = errors.New("querying old values post mutation is not allowed")
  26727. } else {
  26728. value, err = m.Client().UsageDetail.Get(ctx, id)
  26729. }
  26730. })
  26731. return value, err
  26732. }
  26733. m.id = &id
  26734. }
  26735. }
  26736. // withUsageDetail sets the old UsageDetail of the mutation.
  26737. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26738. return func(m *UsageDetailMutation) {
  26739. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26740. return node, nil
  26741. }
  26742. m.id = &node.ID
  26743. }
  26744. }
  26745. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26746. // executed in a transaction (ent.Tx), a transactional client is returned.
  26747. func (m UsageDetailMutation) Client() *Client {
  26748. client := &Client{config: m.config}
  26749. client.init()
  26750. return client
  26751. }
  26752. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26753. // it returns an error otherwise.
  26754. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26755. if _, ok := m.driver.(*txDriver); !ok {
  26756. return nil, errors.New("ent: mutation is not running in a transaction")
  26757. }
  26758. tx := &Tx{config: m.config}
  26759. tx.init()
  26760. return tx, nil
  26761. }
  26762. // SetID sets the value of the id field. Note that this
  26763. // operation is only accepted on creation of UsageDetail entities.
  26764. func (m *UsageDetailMutation) SetID(id uint64) {
  26765. m.id = &id
  26766. }
  26767. // ID returns the ID value in the mutation. Note that the ID is only available
  26768. // if it was provided to the builder or after it was returned from the database.
  26769. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26770. if m.id == nil {
  26771. return
  26772. }
  26773. return *m.id, true
  26774. }
  26775. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26776. // That means, if the mutation is applied within a transaction with an isolation level such
  26777. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26778. // or updated by the mutation.
  26779. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26780. switch {
  26781. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26782. id, exists := m.ID()
  26783. if exists {
  26784. return []uint64{id}, nil
  26785. }
  26786. fallthrough
  26787. case m.op.Is(OpUpdate | OpDelete):
  26788. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26789. default:
  26790. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26791. }
  26792. }
  26793. // SetCreatedAt sets the "created_at" field.
  26794. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26795. m.created_at = &t
  26796. }
  26797. // CreatedAt returns the value of the "created_at" field in the mutation.
  26798. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26799. v := m.created_at
  26800. if v == nil {
  26801. return
  26802. }
  26803. return *v, true
  26804. }
  26805. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26806. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26808. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26809. if !m.op.Is(OpUpdateOne) {
  26810. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26811. }
  26812. if m.id == nil || m.oldValue == nil {
  26813. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26814. }
  26815. oldValue, err := m.oldValue(ctx)
  26816. if err != nil {
  26817. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26818. }
  26819. return oldValue.CreatedAt, nil
  26820. }
  26821. // ResetCreatedAt resets all changes to the "created_at" field.
  26822. func (m *UsageDetailMutation) ResetCreatedAt() {
  26823. m.created_at = nil
  26824. }
  26825. // SetUpdatedAt sets the "updated_at" field.
  26826. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26827. m.updated_at = &t
  26828. }
  26829. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26830. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26831. v := m.updated_at
  26832. if v == nil {
  26833. return
  26834. }
  26835. return *v, true
  26836. }
  26837. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26838. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26840. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26841. if !m.op.Is(OpUpdateOne) {
  26842. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26843. }
  26844. if m.id == nil || m.oldValue == nil {
  26845. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26846. }
  26847. oldValue, err := m.oldValue(ctx)
  26848. if err != nil {
  26849. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26850. }
  26851. return oldValue.UpdatedAt, nil
  26852. }
  26853. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26854. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26855. m.updated_at = nil
  26856. }
  26857. // SetStatus sets the "status" field.
  26858. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26859. m.status = &u
  26860. m.addstatus = nil
  26861. }
  26862. // Status returns the value of the "status" field in the mutation.
  26863. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26864. v := m.status
  26865. if v == nil {
  26866. return
  26867. }
  26868. return *v, true
  26869. }
  26870. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26871. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26873. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26874. if !m.op.Is(OpUpdateOne) {
  26875. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26876. }
  26877. if m.id == nil || m.oldValue == nil {
  26878. return v, errors.New("OldStatus requires an ID field in the mutation")
  26879. }
  26880. oldValue, err := m.oldValue(ctx)
  26881. if err != nil {
  26882. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26883. }
  26884. return oldValue.Status, nil
  26885. }
  26886. // AddStatus adds u to the "status" field.
  26887. func (m *UsageDetailMutation) AddStatus(u int8) {
  26888. if m.addstatus != nil {
  26889. *m.addstatus += u
  26890. } else {
  26891. m.addstatus = &u
  26892. }
  26893. }
  26894. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26895. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26896. v := m.addstatus
  26897. if v == nil {
  26898. return
  26899. }
  26900. return *v, true
  26901. }
  26902. // ClearStatus clears the value of the "status" field.
  26903. func (m *UsageDetailMutation) ClearStatus() {
  26904. m.status = nil
  26905. m.addstatus = nil
  26906. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26907. }
  26908. // StatusCleared returns if the "status" field was cleared in this mutation.
  26909. func (m *UsageDetailMutation) StatusCleared() bool {
  26910. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26911. return ok
  26912. }
  26913. // ResetStatus resets all changes to the "status" field.
  26914. func (m *UsageDetailMutation) ResetStatus() {
  26915. m.status = nil
  26916. m.addstatus = nil
  26917. delete(m.clearedFields, usagedetail.FieldStatus)
  26918. }
  26919. // SetType sets the "type" field.
  26920. func (m *UsageDetailMutation) SetType(i int) {
  26921. m._type = &i
  26922. m.add_type = nil
  26923. }
  26924. // GetType returns the value of the "type" field in the mutation.
  26925. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26926. v := m._type
  26927. if v == nil {
  26928. return
  26929. }
  26930. return *v, true
  26931. }
  26932. // OldType returns the old "type" field's value of the UsageDetail entity.
  26933. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26934. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26935. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26936. if !m.op.Is(OpUpdateOne) {
  26937. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26938. }
  26939. if m.id == nil || m.oldValue == nil {
  26940. return v, errors.New("OldType requires an ID field in the mutation")
  26941. }
  26942. oldValue, err := m.oldValue(ctx)
  26943. if err != nil {
  26944. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26945. }
  26946. return oldValue.Type, nil
  26947. }
  26948. // AddType adds i to the "type" field.
  26949. func (m *UsageDetailMutation) AddType(i int) {
  26950. if m.add_type != nil {
  26951. *m.add_type += i
  26952. } else {
  26953. m.add_type = &i
  26954. }
  26955. }
  26956. // AddedType returns the value that was added to the "type" field in this mutation.
  26957. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26958. v := m.add_type
  26959. if v == nil {
  26960. return
  26961. }
  26962. return *v, true
  26963. }
  26964. // ClearType clears the value of the "type" field.
  26965. func (m *UsageDetailMutation) ClearType() {
  26966. m._type = nil
  26967. m.add_type = nil
  26968. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26969. }
  26970. // TypeCleared returns if the "type" field was cleared in this mutation.
  26971. func (m *UsageDetailMutation) TypeCleared() bool {
  26972. _, ok := m.clearedFields[usagedetail.FieldType]
  26973. return ok
  26974. }
  26975. // ResetType resets all changes to the "type" field.
  26976. func (m *UsageDetailMutation) ResetType() {
  26977. m._type = nil
  26978. m.add_type = nil
  26979. delete(m.clearedFields, usagedetail.FieldType)
  26980. }
  26981. // SetBotID sets the "bot_id" field.
  26982. func (m *UsageDetailMutation) SetBotID(s string) {
  26983. m.bot_id = &s
  26984. }
  26985. // BotID returns the value of the "bot_id" field in the mutation.
  26986. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26987. v := m.bot_id
  26988. if v == nil {
  26989. return
  26990. }
  26991. return *v, true
  26992. }
  26993. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26994. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26995. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26996. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26997. if !m.op.Is(OpUpdateOne) {
  26998. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26999. }
  27000. if m.id == nil || m.oldValue == nil {
  27001. return v, errors.New("OldBotID requires an ID field in the mutation")
  27002. }
  27003. oldValue, err := m.oldValue(ctx)
  27004. if err != nil {
  27005. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  27006. }
  27007. return oldValue.BotID, nil
  27008. }
  27009. // ResetBotID resets all changes to the "bot_id" field.
  27010. func (m *UsageDetailMutation) ResetBotID() {
  27011. m.bot_id = nil
  27012. }
  27013. // SetReceiverID sets the "receiver_id" field.
  27014. func (m *UsageDetailMutation) SetReceiverID(s string) {
  27015. m.receiver_id = &s
  27016. }
  27017. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  27018. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  27019. v := m.receiver_id
  27020. if v == nil {
  27021. return
  27022. }
  27023. return *v, true
  27024. }
  27025. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  27026. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27028. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  27029. if !m.op.Is(OpUpdateOne) {
  27030. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  27031. }
  27032. if m.id == nil || m.oldValue == nil {
  27033. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  27034. }
  27035. oldValue, err := m.oldValue(ctx)
  27036. if err != nil {
  27037. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  27038. }
  27039. return oldValue.ReceiverID, nil
  27040. }
  27041. // ResetReceiverID resets all changes to the "receiver_id" field.
  27042. func (m *UsageDetailMutation) ResetReceiverID() {
  27043. m.receiver_id = nil
  27044. }
  27045. // SetApp sets the "app" field.
  27046. func (m *UsageDetailMutation) SetApp(i int) {
  27047. m.app = &i
  27048. m.addapp = nil
  27049. }
  27050. // App returns the value of the "app" field in the mutation.
  27051. func (m *UsageDetailMutation) App() (r int, exists bool) {
  27052. v := m.app
  27053. if v == nil {
  27054. return
  27055. }
  27056. return *v, true
  27057. }
  27058. // OldApp returns the old "app" field's value of the UsageDetail entity.
  27059. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27061. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  27062. if !m.op.Is(OpUpdateOne) {
  27063. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  27064. }
  27065. if m.id == nil || m.oldValue == nil {
  27066. return v, errors.New("OldApp requires an ID field in the mutation")
  27067. }
  27068. oldValue, err := m.oldValue(ctx)
  27069. if err != nil {
  27070. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  27071. }
  27072. return oldValue.App, nil
  27073. }
  27074. // AddApp adds i to the "app" field.
  27075. func (m *UsageDetailMutation) AddApp(i int) {
  27076. if m.addapp != nil {
  27077. *m.addapp += i
  27078. } else {
  27079. m.addapp = &i
  27080. }
  27081. }
  27082. // AddedApp returns the value that was added to the "app" field in this mutation.
  27083. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27084. v := m.addapp
  27085. if v == nil {
  27086. return
  27087. }
  27088. return *v, true
  27089. }
  27090. // ClearApp clears the value of the "app" field.
  27091. func (m *UsageDetailMutation) ClearApp() {
  27092. m.app = nil
  27093. m.addapp = nil
  27094. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27095. }
  27096. // AppCleared returns if the "app" field was cleared in this mutation.
  27097. func (m *UsageDetailMutation) AppCleared() bool {
  27098. _, ok := m.clearedFields[usagedetail.FieldApp]
  27099. return ok
  27100. }
  27101. // ResetApp resets all changes to the "app" field.
  27102. func (m *UsageDetailMutation) ResetApp() {
  27103. m.app = nil
  27104. m.addapp = nil
  27105. delete(m.clearedFields, usagedetail.FieldApp)
  27106. }
  27107. // SetSessionID sets the "session_id" field.
  27108. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27109. m.session_id = &u
  27110. m.addsession_id = nil
  27111. }
  27112. // SessionID returns the value of the "session_id" field in the mutation.
  27113. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27114. v := m.session_id
  27115. if v == nil {
  27116. return
  27117. }
  27118. return *v, true
  27119. }
  27120. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27121. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27123. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27124. if !m.op.Is(OpUpdateOne) {
  27125. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27126. }
  27127. if m.id == nil || m.oldValue == nil {
  27128. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27129. }
  27130. oldValue, err := m.oldValue(ctx)
  27131. if err != nil {
  27132. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27133. }
  27134. return oldValue.SessionID, nil
  27135. }
  27136. // AddSessionID adds u to the "session_id" field.
  27137. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27138. if m.addsession_id != nil {
  27139. *m.addsession_id += u
  27140. } else {
  27141. m.addsession_id = &u
  27142. }
  27143. }
  27144. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27145. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27146. v := m.addsession_id
  27147. if v == nil {
  27148. return
  27149. }
  27150. return *v, true
  27151. }
  27152. // ClearSessionID clears the value of the "session_id" field.
  27153. func (m *UsageDetailMutation) ClearSessionID() {
  27154. m.session_id = nil
  27155. m.addsession_id = nil
  27156. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27157. }
  27158. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27159. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27160. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27161. return ok
  27162. }
  27163. // ResetSessionID resets all changes to the "session_id" field.
  27164. func (m *UsageDetailMutation) ResetSessionID() {
  27165. m.session_id = nil
  27166. m.addsession_id = nil
  27167. delete(m.clearedFields, usagedetail.FieldSessionID)
  27168. }
  27169. // SetRequest sets the "request" field.
  27170. func (m *UsageDetailMutation) SetRequest(s string) {
  27171. m.request = &s
  27172. }
  27173. // Request returns the value of the "request" field in the mutation.
  27174. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27175. v := m.request
  27176. if v == nil {
  27177. return
  27178. }
  27179. return *v, true
  27180. }
  27181. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27182. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27184. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27185. if !m.op.Is(OpUpdateOne) {
  27186. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27187. }
  27188. if m.id == nil || m.oldValue == nil {
  27189. return v, errors.New("OldRequest requires an ID field in the mutation")
  27190. }
  27191. oldValue, err := m.oldValue(ctx)
  27192. if err != nil {
  27193. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27194. }
  27195. return oldValue.Request, nil
  27196. }
  27197. // ResetRequest resets all changes to the "request" field.
  27198. func (m *UsageDetailMutation) ResetRequest() {
  27199. m.request = nil
  27200. }
  27201. // SetResponse sets the "response" field.
  27202. func (m *UsageDetailMutation) SetResponse(s string) {
  27203. m.response = &s
  27204. }
  27205. // Response returns the value of the "response" field in the mutation.
  27206. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27207. v := m.response
  27208. if v == nil {
  27209. return
  27210. }
  27211. return *v, true
  27212. }
  27213. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27214. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27216. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27217. if !m.op.Is(OpUpdateOne) {
  27218. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27219. }
  27220. if m.id == nil || m.oldValue == nil {
  27221. return v, errors.New("OldResponse requires an ID field in the mutation")
  27222. }
  27223. oldValue, err := m.oldValue(ctx)
  27224. if err != nil {
  27225. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27226. }
  27227. return oldValue.Response, nil
  27228. }
  27229. // ResetResponse resets all changes to the "response" field.
  27230. func (m *UsageDetailMutation) ResetResponse() {
  27231. m.response = nil
  27232. }
  27233. // SetOriginalData sets the "original_data" field.
  27234. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27235. m.original_data = &ctd
  27236. }
  27237. // OriginalData returns the value of the "original_data" field in the mutation.
  27238. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27239. v := m.original_data
  27240. if v == nil {
  27241. return
  27242. }
  27243. return *v, true
  27244. }
  27245. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27246. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27248. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27249. if !m.op.Is(OpUpdateOne) {
  27250. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27251. }
  27252. if m.id == nil || m.oldValue == nil {
  27253. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27254. }
  27255. oldValue, err := m.oldValue(ctx)
  27256. if err != nil {
  27257. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27258. }
  27259. return oldValue.OriginalData, nil
  27260. }
  27261. // ResetOriginalData resets all changes to the "original_data" field.
  27262. func (m *UsageDetailMutation) ResetOriginalData() {
  27263. m.original_data = nil
  27264. }
  27265. // SetTotalTokens sets the "total_tokens" field.
  27266. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27267. m.total_tokens = &u
  27268. m.addtotal_tokens = nil
  27269. }
  27270. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27271. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27272. v := m.total_tokens
  27273. if v == nil {
  27274. return
  27275. }
  27276. return *v, true
  27277. }
  27278. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27279. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27281. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27282. if !m.op.Is(OpUpdateOne) {
  27283. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27284. }
  27285. if m.id == nil || m.oldValue == nil {
  27286. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27287. }
  27288. oldValue, err := m.oldValue(ctx)
  27289. if err != nil {
  27290. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27291. }
  27292. return oldValue.TotalTokens, nil
  27293. }
  27294. // AddTotalTokens adds u to the "total_tokens" field.
  27295. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27296. if m.addtotal_tokens != nil {
  27297. *m.addtotal_tokens += u
  27298. } else {
  27299. m.addtotal_tokens = &u
  27300. }
  27301. }
  27302. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27303. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27304. v := m.addtotal_tokens
  27305. if v == nil {
  27306. return
  27307. }
  27308. return *v, true
  27309. }
  27310. // ClearTotalTokens clears the value of the "total_tokens" field.
  27311. func (m *UsageDetailMutation) ClearTotalTokens() {
  27312. m.total_tokens = nil
  27313. m.addtotal_tokens = nil
  27314. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27315. }
  27316. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27317. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27318. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27319. return ok
  27320. }
  27321. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27322. func (m *UsageDetailMutation) ResetTotalTokens() {
  27323. m.total_tokens = nil
  27324. m.addtotal_tokens = nil
  27325. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27326. }
  27327. // SetPromptTokens sets the "prompt_tokens" field.
  27328. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27329. m.prompt_tokens = &u
  27330. m.addprompt_tokens = nil
  27331. }
  27332. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27333. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27334. v := m.prompt_tokens
  27335. if v == nil {
  27336. return
  27337. }
  27338. return *v, true
  27339. }
  27340. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27341. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27342. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27343. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27344. if !m.op.Is(OpUpdateOne) {
  27345. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27346. }
  27347. if m.id == nil || m.oldValue == nil {
  27348. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27349. }
  27350. oldValue, err := m.oldValue(ctx)
  27351. if err != nil {
  27352. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27353. }
  27354. return oldValue.PromptTokens, nil
  27355. }
  27356. // AddPromptTokens adds u to the "prompt_tokens" field.
  27357. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27358. if m.addprompt_tokens != nil {
  27359. *m.addprompt_tokens += u
  27360. } else {
  27361. m.addprompt_tokens = &u
  27362. }
  27363. }
  27364. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27365. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27366. v := m.addprompt_tokens
  27367. if v == nil {
  27368. return
  27369. }
  27370. return *v, true
  27371. }
  27372. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27373. func (m *UsageDetailMutation) ClearPromptTokens() {
  27374. m.prompt_tokens = nil
  27375. m.addprompt_tokens = nil
  27376. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27377. }
  27378. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27379. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27380. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27381. return ok
  27382. }
  27383. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27384. func (m *UsageDetailMutation) ResetPromptTokens() {
  27385. m.prompt_tokens = nil
  27386. m.addprompt_tokens = nil
  27387. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27388. }
  27389. // SetCompletionTokens sets the "completion_tokens" field.
  27390. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27391. m.completion_tokens = &u
  27392. m.addcompletion_tokens = nil
  27393. }
  27394. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27395. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27396. v := m.completion_tokens
  27397. if v == nil {
  27398. return
  27399. }
  27400. return *v, true
  27401. }
  27402. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27403. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27404. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27405. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27406. if !m.op.Is(OpUpdateOne) {
  27407. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27408. }
  27409. if m.id == nil || m.oldValue == nil {
  27410. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27411. }
  27412. oldValue, err := m.oldValue(ctx)
  27413. if err != nil {
  27414. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27415. }
  27416. return oldValue.CompletionTokens, nil
  27417. }
  27418. // AddCompletionTokens adds u to the "completion_tokens" field.
  27419. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27420. if m.addcompletion_tokens != nil {
  27421. *m.addcompletion_tokens += u
  27422. } else {
  27423. m.addcompletion_tokens = &u
  27424. }
  27425. }
  27426. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27427. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27428. v := m.addcompletion_tokens
  27429. if v == nil {
  27430. return
  27431. }
  27432. return *v, true
  27433. }
  27434. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27435. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27436. m.completion_tokens = nil
  27437. m.addcompletion_tokens = nil
  27438. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27439. }
  27440. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27441. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27442. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27443. return ok
  27444. }
  27445. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27446. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27447. m.completion_tokens = nil
  27448. m.addcompletion_tokens = nil
  27449. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27450. }
  27451. // SetOrganizationID sets the "organization_id" field.
  27452. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27453. m.organization_id = &u
  27454. m.addorganization_id = nil
  27455. }
  27456. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27457. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27458. v := m.organization_id
  27459. if v == nil {
  27460. return
  27461. }
  27462. return *v, true
  27463. }
  27464. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27465. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27466. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27467. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27468. if !m.op.Is(OpUpdateOne) {
  27469. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27470. }
  27471. if m.id == nil || m.oldValue == nil {
  27472. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27473. }
  27474. oldValue, err := m.oldValue(ctx)
  27475. if err != nil {
  27476. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27477. }
  27478. return oldValue.OrganizationID, nil
  27479. }
  27480. // AddOrganizationID adds u to the "organization_id" field.
  27481. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27482. if m.addorganization_id != nil {
  27483. *m.addorganization_id += u
  27484. } else {
  27485. m.addorganization_id = &u
  27486. }
  27487. }
  27488. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27489. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27490. v := m.addorganization_id
  27491. if v == nil {
  27492. return
  27493. }
  27494. return *v, true
  27495. }
  27496. // ClearOrganizationID clears the value of the "organization_id" field.
  27497. func (m *UsageDetailMutation) ClearOrganizationID() {
  27498. m.organization_id = nil
  27499. m.addorganization_id = nil
  27500. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27501. }
  27502. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27503. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27504. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27505. return ok
  27506. }
  27507. // ResetOrganizationID resets all changes to the "organization_id" field.
  27508. func (m *UsageDetailMutation) ResetOrganizationID() {
  27509. m.organization_id = nil
  27510. m.addorganization_id = nil
  27511. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27512. }
  27513. // Where appends a list predicates to the UsageDetailMutation builder.
  27514. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27515. m.predicates = append(m.predicates, ps...)
  27516. }
  27517. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27518. // users can use type-assertion to append predicates that do not depend on any generated package.
  27519. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27520. p := make([]predicate.UsageDetail, len(ps))
  27521. for i := range ps {
  27522. p[i] = ps[i]
  27523. }
  27524. m.Where(p...)
  27525. }
  27526. // Op returns the operation name.
  27527. func (m *UsageDetailMutation) Op() Op {
  27528. return m.op
  27529. }
  27530. // SetOp allows setting the mutation operation.
  27531. func (m *UsageDetailMutation) SetOp(op Op) {
  27532. m.op = op
  27533. }
  27534. // Type returns the node type of this mutation (UsageDetail).
  27535. func (m *UsageDetailMutation) Type() string {
  27536. return m.typ
  27537. }
  27538. // Fields returns all fields that were changed during this mutation. Note that in
  27539. // order to get all numeric fields that were incremented/decremented, call
  27540. // AddedFields().
  27541. func (m *UsageDetailMutation) Fields() []string {
  27542. fields := make([]string, 0, 15)
  27543. if m.created_at != nil {
  27544. fields = append(fields, usagedetail.FieldCreatedAt)
  27545. }
  27546. if m.updated_at != nil {
  27547. fields = append(fields, usagedetail.FieldUpdatedAt)
  27548. }
  27549. if m.status != nil {
  27550. fields = append(fields, usagedetail.FieldStatus)
  27551. }
  27552. if m._type != nil {
  27553. fields = append(fields, usagedetail.FieldType)
  27554. }
  27555. if m.bot_id != nil {
  27556. fields = append(fields, usagedetail.FieldBotID)
  27557. }
  27558. if m.receiver_id != nil {
  27559. fields = append(fields, usagedetail.FieldReceiverID)
  27560. }
  27561. if m.app != nil {
  27562. fields = append(fields, usagedetail.FieldApp)
  27563. }
  27564. if m.session_id != nil {
  27565. fields = append(fields, usagedetail.FieldSessionID)
  27566. }
  27567. if m.request != nil {
  27568. fields = append(fields, usagedetail.FieldRequest)
  27569. }
  27570. if m.response != nil {
  27571. fields = append(fields, usagedetail.FieldResponse)
  27572. }
  27573. if m.original_data != nil {
  27574. fields = append(fields, usagedetail.FieldOriginalData)
  27575. }
  27576. if m.total_tokens != nil {
  27577. fields = append(fields, usagedetail.FieldTotalTokens)
  27578. }
  27579. if m.prompt_tokens != nil {
  27580. fields = append(fields, usagedetail.FieldPromptTokens)
  27581. }
  27582. if m.completion_tokens != nil {
  27583. fields = append(fields, usagedetail.FieldCompletionTokens)
  27584. }
  27585. if m.organization_id != nil {
  27586. fields = append(fields, usagedetail.FieldOrganizationID)
  27587. }
  27588. return fields
  27589. }
  27590. // Field returns the value of a field with the given name. The second boolean
  27591. // return value indicates that this field was not set, or was not defined in the
  27592. // schema.
  27593. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27594. switch name {
  27595. case usagedetail.FieldCreatedAt:
  27596. return m.CreatedAt()
  27597. case usagedetail.FieldUpdatedAt:
  27598. return m.UpdatedAt()
  27599. case usagedetail.FieldStatus:
  27600. return m.Status()
  27601. case usagedetail.FieldType:
  27602. return m.GetType()
  27603. case usagedetail.FieldBotID:
  27604. return m.BotID()
  27605. case usagedetail.FieldReceiverID:
  27606. return m.ReceiverID()
  27607. case usagedetail.FieldApp:
  27608. return m.App()
  27609. case usagedetail.FieldSessionID:
  27610. return m.SessionID()
  27611. case usagedetail.FieldRequest:
  27612. return m.Request()
  27613. case usagedetail.FieldResponse:
  27614. return m.Response()
  27615. case usagedetail.FieldOriginalData:
  27616. return m.OriginalData()
  27617. case usagedetail.FieldTotalTokens:
  27618. return m.TotalTokens()
  27619. case usagedetail.FieldPromptTokens:
  27620. return m.PromptTokens()
  27621. case usagedetail.FieldCompletionTokens:
  27622. return m.CompletionTokens()
  27623. case usagedetail.FieldOrganizationID:
  27624. return m.OrganizationID()
  27625. }
  27626. return nil, false
  27627. }
  27628. // OldField returns the old value of the field from the database. An error is
  27629. // returned if the mutation operation is not UpdateOne, or the query to the
  27630. // database failed.
  27631. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27632. switch name {
  27633. case usagedetail.FieldCreatedAt:
  27634. return m.OldCreatedAt(ctx)
  27635. case usagedetail.FieldUpdatedAt:
  27636. return m.OldUpdatedAt(ctx)
  27637. case usagedetail.FieldStatus:
  27638. return m.OldStatus(ctx)
  27639. case usagedetail.FieldType:
  27640. return m.OldType(ctx)
  27641. case usagedetail.FieldBotID:
  27642. return m.OldBotID(ctx)
  27643. case usagedetail.FieldReceiverID:
  27644. return m.OldReceiverID(ctx)
  27645. case usagedetail.FieldApp:
  27646. return m.OldApp(ctx)
  27647. case usagedetail.FieldSessionID:
  27648. return m.OldSessionID(ctx)
  27649. case usagedetail.FieldRequest:
  27650. return m.OldRequest(ctx)
  27651. case usagedetail.FieldResponse:
  27652. return m.OldResponse(ctx)
  27653. case usagedetail.FieldOriginalData:
  27654. return m.OldOriginalData(ctx)
  27655. case usagedetail.FieldTotalTokens:
  27656. return m.OldTotalTokens(ctx)
  27657. case usagedetail.FieldPromptTokens:
  27658. return m.OldPromptTokens(ctx)
  27659. case usagedetail.FieldCompletionTokens:
  27660. return m.OldCompletionTokens(ctx)
  27661. case usagedetail.FieldOrganizationID:
  27662. return m.OldOrganizationID(ctx)
  27663. }
  27664. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27665. }
  27666. // SetField sets the value of a field with the given name. It returns an error if
  27667. // the field is not defined in the schema, or if the type mismatched the field
  27668. // type.
  27669. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27670. switch name {
  27671. case usagedetail.FieldCreatedAt:
  27672. v, ok := value.(time.Time)
  27673. if !ok {
  27674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27675. }
  27676. m.SetCreatedAt(v)
  27677. return nil
  27678. case usagedetail.FieldUpdatedAt:
  27679. v, ok := value.(time.Time)
  27680. if !ok {
  27681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27682. }
  27683. m.SetUpdatedAt(v)
  27684. return nil
  27685. case usagedetail.FieldStatus:
  27686. v, ok := value.(uint8)
  27687. if !ok {
  27688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27689. }
  27690. m.SetStatus(v)
  27691. return nil
  27692. case usagedetail.FieldType:
  27693. v, ok := value.(int)
  27694. if !ok {
  27695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27696. }
  27697. m.SetType(v)
  27698. return nil
  27699. case usagedetail.FieldBotID:
  27700. v, ok := value.(string)
  27701. if !ok {
  27702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27703. }
  27704. m.SetBotID(v)
  27705. return nil
  27706. case usagedetail.FieldReceiverID:
  27707. v, ok := value.(string)
  27708. if !ok {
  27709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27710. }
  27711. m.SetReceiverID(v)
  27712. return nil
  27713. case usagedetail.FieldApp:
  27714. v, ok := value.(int)
  27715. if !ok {
  27716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27717. }
  27718. m.SetApp(v)
  27719. return nil
  27720. case usagedetail.FieldSessionID:
  27721. v, ok := value.(uint64)
  27722. if !ok {
  27723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27724. }
  27725. m.SetSessionID(v)
  27726. return nil
  27727. case usagedetail.FieldRequest:
  27728. v, ok := value.(string)
  27729. if !ok {
  27730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27731. }
  27732. m.SetRequest(v)
  27733. return nil
  27734. case usagedetail.FieldResponse:
  27735. v, ok := value.(string)
  27736. if !ok {
  27737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27738. }
  27739. m.SetResponse(v)
  27740. return nil
  27741. case usagedetail.FieldOriginalData:
  27742. v, ok := value.(custom_types.OriginalData)
  27743. if !ok {
  27744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27745. }
  27746. m.SetOriginalData(v)
  27747. return nil
  27748. case usagedetail.FieldTotalTokens:
  27749. v, ok := value.(uint64)
  27750. if !ok {
  27751. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27752. }
  27753. m.SetTotalTokens(v)
  27754. return nil
  27755. case usagedetail.FieldPromptTokens:
  27756. v, ok := value.(uint64)
  27757. if !ok {
  27758. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27759. }
  27760. m.SetPromptTokens(v)
  27761. return nil
  27762. case usagedetail.FieldCompletionTokens:
  27763. v, ok := value.(uint64)
  27764. if !ok {
  27765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27766. }
  27767. m.SetCompletionTokens(v)
  27768. return nil
  27769. case usagedetail.FieldOrganizationID:
  27770. v, ok := value.(uint64)
  27771. if !ok {
  27772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27773. }
  27774. m.SetOrganizationID(v)
  27775. return nil
  27776. }
  27777. return fmt.Errorf("unknown UsageDetail field %s", name)
  27778. }
  27779. // AddedFields returns all numeric fields that were incremented/decremented during
  27780. // this mutation.
  27781. func (m *UsageDetailMutation) AddedFields() []string {
  27782. var fields []string
  27783. if m.addstatus != nil {
  27784. fields = append(fields, usagedetail.FieldStatus)
  27785. }
  27786. if m.add_type != nil {
  27787. fields = append(fields, usagedetail.FieldType)
  27788. }
  27789. if m.addapp != nil {
  27790. fields = append(fields, usagedetail.FieldApp)
  27791. }
  27792. if m.addsession_id != nil {
  27793. fields = append(fields, usagedetail.FieldSessionID)
  27794. }
  27795. if m.addtotal_tokens != nil {
  27796. fields = append(fields, usagedetail.FieldTotalTokens)
  27797. }
  27798. if m.addprompt_tokens != nil {
  27799. fields = append(fields, usagedetail.FieldPromptTokens)
  27800. }
  27801. if m.addcompletion_tokens != nil {
  27802. fields = append(fields, usagedetail.FieldCompletionTokens)
  27803. }
  27804. if m.addorganization_id != nil {
  27805. fields = append(fields, usagedetail.FieldOrganizationID)
  27806. }
  27807. return fields
  27808. }
  27809. // AddedField returns the numeric value that was incremented/decremented on a field
  27810. // with the given name. The second boolean return value indicates that this field
  27811. // was not set, or was not defined in the schema.
  27812. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27813. switch name {
  27814. case usagedetail.FieldStatus:
  27815. return m.AddedStatus()
  27816. case usagedetail.FieldType:
  27817. return m.AddedType()
  27818. case usagedetail.FieldApp:
  27819. return m.AddedApp()
  27820. case usagedetail.FieldSessionID:
  27821. return m.AddedSessionID()
  27822. case usagedetail.FieldTotalTokens:
  27823. return m.AddedTotalTokens()
  27824. case usagedetail.FieldPromptTokens:
  27825. return m.AddedPromptTokens()
  27826. case usagedetail.FieldCompletionTokens:
  27827. return m.AddedCompletionTokens()
  27828. case usagedetail.FieldOrganizationID:
  27829. return m.AddedOrganizationID()
  27830. }
  27831. return nil, false
  27832. }
  27833. // AddField adds the value to the field with the given name. It returns an error if
  27834. // the field is not defined in the schema, or if the type mismatched the field
  27835. // type.
  27836. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27837. switch name {
  27838. case usagedetail.FieldStatus:
  27839. v, ok := value.(int8)
  27840. if !ok {
  27841. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27842. }
  27843. m.AddStatus(v)
  27844. return nil
  27845. case usagedetail.FieldType:
  27846. v, ok := value.(int)
  27847. if !ok {
  27848. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27849. }
  27850. m.AddType(v)
  27851. return nil
  27852. case usagedetail.FieldApp:
  27853. v, ok := value.(int)
  27854. if !ok {
  27855. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27856. }
  27857. m.AddApp(v)
  27858. return nil
  27859. case usagedetail.FieldSessionID:
  27860. v, ok := value.(int64)
  27861. if !ok {
  27862. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27863. }
  27864. m.AddSessionID(v)
  27865. return nil
  27866. case usagedetail.FieldTotalTokens:
  27867. v, ok := value.(int64)
  27868. if !ok {
  27869. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27870. }
  27871. m.AddTotalTokens(v)
  27872. return nil
  27873. case usagedetail.FieldPromptTokens:
  27874. v, ok := value.(int64)
  27875. if !ok {
  27876. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27877. }
  27878. m.AddPromptTokens(v)
  27879. return nil
  27880. case usagedetail.FieldCompletionTokens:
  27881. v, ok := value.(int64)
  27882. if !ok {
  27883. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27884. }
  27885. m.AddCompletionTokens(v)
  27886. return nil
  27887. case usagedetail.FieldOrganizationID:
  27888. v, ok := value.(int64)
  27889. if !ok {
  27890. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27891. }
  27892. m.AddOrganizationID(v)
  27893. return nil
  27894. }
  27895. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27896. }
  27897. // ClearedFields returns all nullable fields that were cleared during this
  27898. // mutation.
  27899. func (m *UsageDetailMutation) ClearedFields() []string {
  27900. var fields []string
  27901. if m.FieldCleared(usagedetail.FieldStatus) {
  27902. fields = append(fields, usagedetail.FieldStatus)
  27903. }
  27904. if m.FieldCleared(usagedetail.FieldType) {
  27905. fields = append(fields, usagedetail.FieldType)
  27906. }
  27907. if m.FieldCleared(usagedetail.FieldApp) {
  27908. fields = append(fields, usagedetail.FieldApp)
  27909. }
  27910. if m.FieldCleared(usagedetail.FieldSessionID) {
  27911. fields = append(fields, usagedetail.FieldSessionID)
  27912. }
  27913. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27914. fields = append(fields, usagedetail.FieldTotalTokens)
  27915. }
  27916. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27917. fields = append(fields, usagedetail.FieldPromptTokens)
  27918. }
  27919. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27920. fields = append(fields, usagedetail.FieldCompletionTokens)
  27921. }
  27922. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27923. fields = append(fields, usagedetail.FieldOrganizationID)
  27924. }
  27925. return fields
  27926. }
  27927. // FieldCleared returns a boolean indicating if a field with the given name was
  27928. // cleared in this mutation.
  27929. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27930. _, ok := m.clearedFields[name]
  27931. return ok
  27932. }
  27933. // ClearField clears the value of the field with the given name. It returns an
  27934. // error if the field is not defined in the schema.
  27935. func (m *UsageDetailMutation) ClearField(name string) error {
  27936. switch name {
  27937. case usagedetail.FieldStatus:
  27938. m.ClearStatus()
  27939. return nil
  27940. case usagedetail.FieldType:
  27941. m.ClearType()
  27942. return nil
  27943. case usagedetail.FieldApp:
  27944. m.ClearApp()
  27945. return nil
  27946. case usagedetail.FieldSessionID:
  27947. m.ClearSessionID()
  27948. return nil
  27949. case usagedetail.FieldTotalTokens:
  27950. m.ClearTotalTokens()
  27951. return nil
  27952. case usagedetail.FieldPromptTokens:
  27953. m.ClearPromptTokens()
  27954. return nil
  27955. case usagedetail.FieldCompletionTokens:
  27956. m.ClearCompletionTokens()
  27957. return nil
  27958. case usagedetail.FieldOrganizationID:
  27959. m.ClearOrganizationID()
  27960. return nil
  27961. }
  27962. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27963. }
  27964. // ResetField resets all changes in the mutation for the field with the given name.
  27965. // It returns an error if the field is not defined in the schema.
  27966. func (m *UsageDetailMutation) ResetField(name string) error {
  27967. switch name {
  27968. case usagedetail.FieldCreatedAt:
  27969. m.ResetCreatedAt()
  27970. return nil
  27971. case usagedetail.FieldUpdatedAt:
  27972. m.ResetUpdatedAt()
  27973. return nil
  27974. case usagedetail.FieldStatus:
  27975. m.ResetStatus()
  27976. return nil
  27977. case usagedetail.FieldType:
  27978. m.ResetType()
  27979. return nil
  27980. case usagedetail.FieldBotID:
  27981. m.ResetBotID()
  27982. return nil
  27983. case usagedetail.FieldReceiverID:
  27984. m.ResetReceiverID()
  27985. return nil
  27986. case usagedetail.FieldApp:
  27987. m.ResetApp()
  27988. return nil
  27989. case usagedetail.FieldSessionID:
  27990. m.ResetSessionID()
  27991. return nil
  27992. case usagedetail.FieldRequest:
  27993. m.ResetRequest()
  27994. return nil
  27995. case usagedetail.FieldResponse:
  27996. m.ResetResponse()
  27997. return nil
  27998. case usagedetail.FieldOriginalData:
  27999. m.ResetOriginalData()
  28000. return nil
  28001. case usagedetail.FieldTotalTokens:
  28002. m.ResetTotalTokens()
  28003. return nil
  28004. case usagedetail.FieldPromptTokens:
  28005. m.ResetPromptTokens()
  28006. return nil
  28007. case usagedetail.FieldCompletionTokens:
  28008. m.ResetCompletionTokens()
  28009. return nil
  28010. case usagedetail.FieldOrganizationID:
  28011. m.ResetOrganizationID()
  28012. return nil
  28013. }
  28014. return fmt.Errorf("unknown UsageDetail field %s", name)
  28015. }
  28016. // AddedEdges returns all edge names that were set/added in this mutation.
  28017. func (m *UsageDetailMutation) AddedEdges() []string {
  28018. edges := make([]string, 0, 0)
  28019. return edges
  28020. }
  28021. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  28022. // name in this mutation.
  28023. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  28024. return nil
  28025. }
  28026. // RemovedEdges returns all edge names that were removed in this mutation.
  28027. func (m *UsageDetailMutation) RemovedEdges() []string {
  28028. edges := make([]string, 0, 0)
  28029. return edges
  28030. }
  28031. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  28032. // the given name in this mutation.
  28033. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  28034. return nil
  28035. }
  28036. // ClearedEdges returns all edge names that were cleared in this mutation.
  28037. func (m *UsageDetailMutation) ClearedEdges() []string {
  28038. edges := make([]string, 0, 0)
  28039. return edges
  28040. }
  28041. // EdgeCleared returns a boolean which indicates if the edge with the given name
  28042. // was cleared in this mutation.
  28043. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  28044. return false
  28045. }
  28046. // ClearEdge clears the value of the edge with the given name. It returns an error
  28047. // if that edge is not defined in the schema.
  28048. func (m *UsageDetailMutation) ClearEdge(name string) error {
  28049. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  28050. }
  28051. // ResetEdge resets all changes to the edge with the given name in this mutation.
  28052. // It returns an error if the edge is not defined in the schema.
  28053. func (m *UsageDetailMutation) ResetEdge(name string) error {
  28054. return fmt.Errorf("unknown UsageDetail edge %s", name)
  28055. }
  28056. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  28057. type UsageStatisticDayMutation struct {
  28058. config
  28059. op Op
  28060. typ string
  28061. id *uint64
  28062. created_at *time.Time
  28063. updated_at *time.Time
  28064. status *uint8
  28065. addstatus *int8
  28066. deleted_at *time.Time
  28067. addtime *uint64
  28068. addaddtime *int64
  28069. _type *int
  28070. add_type *int
  28071. bot_id *string
  28072. organization_id *uint64
  28073. addorganization_id *int64
  28074. ai_response *uint64
  28075. addai_response *int64
  28076. sop_run *uint64
  28077. addsop_run *int64
  28078. total_friend *uint64
  28079. addtotal_friend *int64
  28080. total_group *uint64
  28081. addtotal_group *int64
  28082. account_balance *uint64
  28083. addaccount_balance *int64
  28084. consume_token *uint64
  28085. addconsume_token *int64
  28086. active_user *uint64
  28087. addactive_user *int64
  28088. new_user *int64
  28089. addnew_user *int64
  28090. label_dist *[]custom_types.LabelDist
  28091. appendlabel_dist []custom_types.LabelDist
  28092. clearedFields map[string]struct{}
  28093. done bool
  28094. oldValue func(context.Context) (*UsageStatisticDay, error)
  28095. predicates []predicate.UsageStatisticDay
  28096. }
  28097. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28098. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28099. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28100. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28101. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28102. m := &UsageStatisticDayMutation{
  28103. config: c,
  28104. op: op,
  28105. typ: TypeUsageStatisticDay,
  28106. clearedFields: make(map[string]struct{}),
  28107. }
  28108. for _, opt := range opts {
  28109. opt(m)
  28110. }
  28111. return m
  28112. }
  28113. // withUsageStatisticDayID sets the ID field of the mutation.
  28114. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28115. return func(m *UsageStatisticDayMutation) {
  28116. var (
  28117. err error
  28118. once sync.Once
  28119. value *UsageStatisticDay
  28120. )
  28121. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28122. once.Do(func() {
  28123. if m.done {
  28124. err = errors.New("querying old values post mutation is not allowed")
  28125. } else {
  28126. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28127. }
  28128. })
  28129. return value, err
  28130. }
  28131. m.id = &id
  28132. }
  28133. }
  28134. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28135. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28136. return func(m *UsageStatisticDayMutation) {
  28137. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28138. return node, nil
  28139. }
  28140. m.id = &node.ID
  28141. }
  28142. }
  28143. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28144. // executed in a transaction (ent.Tx), a transactional client is returned.
  28145. func (m UsageStatisticDayMutation) Client() *Client {
  28146. client := &Client{config: m.config}
  28147. client.init()
  28148. return client
  28149. }
  28150. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28151. // it returns an error otherwise.
  28152. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28153. if _, ok := m.driver.(*txDriver); !ok {
  28154. return nil, errors.New("ent: mutation is not running in a transaction")
  28155. }
  28156. tx := &Tx{config: m.config}
  28157. tx.init()
  28158. return tx, nil
  28159. }
  28160. // SetID sets the value of the id field. Note that this
  28161. // operation is only accepted on creation of UsageStatisticDay entities.
  28162. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28163. m.id = &id
  28164. }
  28165. // ID returns the ID value in the mutation. Note that the ID is only available
  28166. // if it was provided to the builder or after it was returned from the database.
  28167. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28168. if m.id == nil {
  28169. return
  28170. }
  28171. return *m.id, true
  28172. }
  28173. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28174. // That means, if the mutation is applied within a transaction with an isolation level such
  28175. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28176. // or updated by the mutation.
  28177. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28178. switch {
  28179. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28180. id, exists := m.ID()
  28181. if exists {
  28182. return []uint64{id}, nil
  28183. }
  28184. fallthrough
  28185. case m.op.Is(OpUpdate | OpDelete):
  28186. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28187. default:
  28188. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28189. }
  28190. }
  28191. // SetCreatedAt sets the "created_at" field.
  28192. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28193. m.created_at = &t
  28194. }
  28195. // CreatedAt returns the value of the "created_at" field in the mutation.
  28196. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28197. v := m.created_at
  28198. if v == nil {
  28199. return
  28200. }
  28201. return *v, true
  28202. }
  28203. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28204. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28205. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28206. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28207. if !m.op.Is(OpUpdateOne) {
  28208. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28209. }
  28210. if m.id == nil || m.oldValue == nil {
  28211. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28212. }
  28213. oldValue, err := m.oldValue(ctx)
  28214. if err != nil {
  28215. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28216. }
  28217. return oldValue.CreatedAt, nil
  28218. }
  28219. // ResetCreatedAt resets all changes to the "created_at" field.
  28220. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28221. m.created_at = nil
  28222. }
  28223. // SetUpdatedAt sets the "updated_at" field.
  28224. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28225. m.updated_at = &t
  28226. }
  28227. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28228. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28229. v := m.updated_at
  28230. if v == nil {
  28231. return
  28232. }
  28233. return *v, true
  28234. }
  28235. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28236. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28237. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28238. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28239. if !m.op.Is(OpUpdateOne) {
  28240. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28241. }
  28242. if m.id == nil || m.oldValue == nil {
  28243. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28244. }
  28245. oldValue, err := m.oldValue(ctx)
  28246. if err != nil {
  28247. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28248. }
  28249. return oldValue.UpdatedAt, nil
  28250. }
  28251. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28252. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28253. m.updated_at = nil
  28254. }
  28255. // SetStatus sets the "status" field.
  28256. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28257. m.status = &u
  28258. m.addstatus = nil
  28259. }
  28260. // Status returns the value of the "status" field in the mutation.
  28261. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28262. v := m.status
  28263. if v == nil {
  28264. return
  28265. }
  28266. return *v, true
  28267. }
  28268. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28269. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28270. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28271. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28272. if !m.op.Is(OpUpdateOne) {
  28273. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28274. }
  28275. if m.id == nil || m.oldValue == nil {
  28276. return v, errors.New("OldStatus requires an ID field in the mutation")
  28277. }
  28278. oldValue, err := m.oldValue(ctx)
  28279. if err != nil {
  28280. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28281. }
  28282. return oldValue.Status, nil
  28283. }
  28284. // AddStatus adds u to the "status" field.
  28285. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28286. if m.addstatus != nil {
  28287. *m.addstatus += u
  28288. } else {
  28289. m.addstatus = &u
  28290. }
  28291. }
  28292. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28293. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28294. v := m.addstatus
  28295. if v == nil {
  28296. return
  28297. }
  28298. return *v, true
  28299. }
  28300. // ClearStatus clears the value of the "status" field.
  28301. func (m *UsageStatisticDayMutation) ClearStatus() {
  28302. m.status = nil
  28303. m.addstatus = nil
  28304. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28305. }
  28306. // StatusCleared returns if the "status" field was cleared in this mutation.
  28307. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28308. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28309. return ok
  28310. }
  28311. // ResetStatus resets all changes to the "status" field.
  28312. func (m *UsageStatisticDayMutation) ResetStatus() {
  28313. m.status = nil
  28314. m.addstatus = nil
  28315. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28316. }
  28317. // SetDeletedAt sets the "deleted_at" field.
  28318. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28319. m.deleted_at = &t
  28320. }
  28321. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28322. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28323. v := m.deleted_at
  28324. if v == nil {
  28325. return
  28326. }
  28327. return *v, true
  28328. }
  28329. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28330. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28331. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28332. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28333. if !m.op.Is(OpUpdateOne) {
  28334. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28335. }
  28336. if m.id == nil || m.oldValue == nil {
  28337. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28338. }
  28339. oldValue, err := m.oldValue(ctx)
  28340. if err != nil {
  28341. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28342. }
  28343. return oldValue.DeletedAt, nil
  28344. }
  28345. // ClearDeletedAt clears the value of the "deleted_at" field.
  28346. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28347. m.deleted_at = nil
  28348. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28349. }
  28350. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28351. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28352. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28353. return ok
  28354. }
  28355. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28356. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28357. m.deleted_at = nil
  28358. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28359. }
  28360. // SetAddtime sets the "addtime" field.
  28361. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28362. m.addtime = &u
  28363. m.addaddtime = nil
  28364. }
  28365. // Addtime returns the value of the "addtime" field in the mutation.
  28366. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28367. v := m.addtime
  28368. if v == nil {
  28369. return
  28370. }
  28371. return *v, true
  28372. }
  28373. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28374. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28375. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28376. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28377. if !m.op.Is(OpUpdateOne) {
  28378. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28379. }
  28380. if m.id == nil || m.oldValue == nil {
  28381. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28382. }
  28383. oldValue, err := m.oldValue(ctx)
  28384. if err != nil {
  28385. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28386. }
  28387. return oldValue.Addtime, nil
  28388. }
  28389. // AddAddtime adds u to the "addtime" field.
  28390. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28391. if m.addaddtime != nil {
  28392. *m.addaddtime += u
  28393. } else {
  28394. m.addaddtime = &u
  28395. }
  28396. }
  28397. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28398. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28399. v := m.addaddtime
  28400. if v == nil {
  28401. return
  28402. }
  28403. return *v, true
  28404. }
  28405. // ResetAddtime resets all changes to the "addtime" field.
  28406. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28407. m.addtime = nil
  28408. m.addaddtime = nil
  28409. }
  28410. // SetType sets the "type" field.
  28411. func (m *UsageStatisticDayMutation) SetType(i int) {
  28412. m._type = &i
  28413. m.add_type = nil
  28414. }
  28415. // GetType returns the value of the "type" field in the mutation.
  28416. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28417. v := m._type
  28418. if v == nil {
  28419. return
  28420. }
  28421. return *v, true
  28422. }
  28423. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28424. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28425. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28426. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28427. if !m.op.Is(OpUpdateOne) {
  28428. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28429. }
  28430. if m.id == nil || m.oldValue == nil {
  28431. return v, errors.New("OldType requires an ID field in the mutation")
  28432. }
  28433. oldValue, err := m.oldValue(ctx)
  28434. if err != nil {
  28435. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28436. }
  28437. return oldValue.Type, nil
  28438. }
  28439. // AddType adds i to the "type" field.
  28440. func (m *UsageStatisticDayMutation) AddType(i int) {
  28441. if m.add_type != nil {
  28442. *m.add_type += i
  28443. } else {
  28444. m.add_type = &i
  28445. }
  28446. }
  28447. // AddedType returns the value that was added to the "type" field in this mutation.
  28448. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28449. v := m.add_type
  28450. if v == nil {
  28451. return
  28452. }
  28453. return *v, true
  28454. }
  28455. // ResetType resets all changes to the "type" field.
  28456. func (m *UsageStatisticDayMutation) ResetType() {
  28457. m._type = nil
  28458. m.add_type = nil
  28459. }
  28460. // SetBotID sets the "bot_id" field.
  28461. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28462. m.bot_id = &s
  28463. }
  28464. // BotID returns the value of the "bot_id" field in the mutation.
  28465. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28466. v := m.bot_id
  28467. if v == nil {
  28468. return
  28469. }
  28470. return *v, true
  28471. }
  28472. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28473. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28474. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28475. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28476. if !m.op.Is(OpUpdateOne) {
  28477. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28478. }
  28479. if m.id == nil || m.oldValue == nil {
  28480. return v, errors.New("OldBotID requires an ID field in the mutation")
  28481. }
  28482. oldValue, err := m.oldValue(ctx)
  28483. if err != nil {
  28484. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28485. }
  28486. return oldValue.BotID, nil
  28487. }
  28488. // ClearBotID clears the value of the "bot_id" field.
  28489. func (m *UsageStatisticDayMutation) ClearBotID() {
  28490. m.bot_id = nil
  28491. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28492. }
  28493. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28494. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28495. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28496. return ok
  28497. }
  28498. // ResetBotID resets all changes to the "bot_id" field.
  28499. func (m *UsageStatisticDayMutation) ResetBotID() {
  28500. m.bot_id = nil
  28501. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28502. }
  28503. // SetOrganizationID sets the "organization_id" field.
  28504. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28505. m.organization_id = &u
  28506. m.addorganization_id = nil
  28507. }
  28508. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28509. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28510. v := m.organization_id
  28511. if v == nil {
  28512. return
  28513. }
  28514. return *v, true
  28515. }
  28516. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28517. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28518. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28519. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28520. if !m.op.Is(OpUpdateOne) {
  28521. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28522. }
  28523. if m.id == nil || m.oldValue == nil {
  28524. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28525. }
  28526. oldValue, err := m.oldValue(ctx)
  28527. if err != nil {
  28528. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28529. }
  28530. return oldValue.OrganizationID, nil
  28531. }
  28532. // AddOrganizationID adds u to the "organization_id" field.
  28533. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28534. if m.addorganization_id != nil {
  28535. *m.addorganization_id += u
  28536. } else {
  28537. m.addorganization_id = &u
  28538. }
  28539. }
  28540. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28541. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28542. v := m.addorganization_id
  28543. if v == nil {
  28544. return
  28545. }
  28546. return *v, true
  28547. }
  28548. // ClearOrganizationID clears the value of the "organization_id" field.
  28549. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28550. m.organization_id = nil
  28551. m.addorganization_id = nil
  28552. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28553. }
  28554. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28555. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28556. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28557. return ok
  28558. }
  28559. // ResetOrganizationID resets all changes to the "organization_id" field.
  28560. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28561. m.organization_id = nil
  28562. m.addorganization_id = nil
  28563. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28564. }
  28565. // SetAiResponse sets the "ai_response" field.
  28566. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28567. m.ai_response = &u
  28568. m.addai_response = nil
  28569. }
  28570. // AiResponse returns the value of the "ai_response" field in the mutation.
  28571. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28572. v := m.ai_response
  28573. if v == nil {
  28574. return
  28575. }
  28576. return *v, true
  28577. }
  28578. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28579. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28580. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28581. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28582. if !m.op.Is(OpUpdateOne) {
  28583. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28584. }
  28585. if m.id == nil || m.oldValue == nil {
  28586. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28587. }
  28588. oldValue, err := m.oldValue(ctx)
  28589. if err != nil {
  28590. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28591. }
  28592. return oldValue.AiResponse, nil
  28593. }
  28594. // AddAiResponse adds u to the "ai_response" field.
  28595. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28596. if m.addai_response != nil {
  28597. *m.addai_response += u
  28598. } else {
  28599. m.addai_response = &u
  28600. }
  28601. }
  28602. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28603. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28604. v := m.addai_response
  28605. if v == nil {
  28606. return
  28607. }
  28608. return *v, true
  28609. }
  28610. // ResetAiResponse resets all changes to the "ai_response" field.
  28611. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28612. m.ai_response = nil
  28613. m.addai_response = nil
  28614. }
  28615. // SetSopRun sets the "sop_run" field.
  28616. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28617. m.sop_run = &u
  28618. m.addsop_run = nil
  28619. }
  28620. // SopRun returns the value of the "sop_run" field in the mutation.
  28621. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28622. v := m.sop_run
  28623. if v == nil {
  28624. return
  28625. }
  28626. return *v, true
  28627. }
  28628. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28629. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28630. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28631. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28632. if !m.op.Is(OpUpdateOne) {
  28633. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28634. }
  28635. if m.id == nil || m.oldValue == nil {
  28636. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28637. }
  28638. oldValue, err := m.oldValue(ctx)
  28639. if err != nil {
  28640. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28641. }
  28642. return oldValue.SopRun, nil
  28643. }
  28644. // AddSopRun adds u to the "sop_run" field.
  28645. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28646. if m.addsop_run != nil {
  28647. *m.addsop_run += u
  28648. } else {
  28649. m.addsop_run = &u
  28650. }
  28651. }
  28652. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28653. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28654. v := m.addsop_run
  28655. if v == nil {
  28656. return
  28657. }
  28658. return *v, true
  28659. }
  28660. // ResetSopRun resets all changes to the "sop_run" field.
  28661. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28662. m.sop_run = nil
  28663. m.addsop_run = nil
  28664. }
  28665. // SetTotalFriend sets the "total_friend" field.
  28666. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28667. m.total_friend = &u
  28668. m.addtotal_friend = nil
  28669. }
  28670. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28671. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28672. v := m.total_friend
  28673. if v == nil {
  28674. return
  28675. }
  28676. return *v, true
  28677. }
  28678. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28679. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28680. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28681. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28682. if !m.op.Is(OpUpdateOne) {
  28683. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28684. }
  28685. if m.id == nil || m.oldValue == nil {
  28686. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28687. }
  28688. oldValue, err := m.oldValue(ctx)
  28689. if err != nil {
  28690. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28691. }
  28692. return oldValue.TotalFriend, nil
  28693. }
  28694. // AddTotalFriend adds u to the "total_friend" field.
  28695. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28696. if m.addtotal_friend != nil {
  28697. *m.addtotal_friend += u
  28698. } else {
  28699. m.addtotal_friend = &u
  28700. }
  28701. }
  28702. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28703. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28704. v := m.addtotal_friend
  28705. if v == nil {
  28706. return
  28707. }
  28708. return *v, true
  28709. }
  28710. // ResetTotalFriend resets all changes to the "total_friend" field.
  28711. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28712. m.total_friend = nil
  28713. m.addtotal_friend = nil
  28714. }
  28715. // SetTotalGroup sets the "total_group" field.
  28716. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28717. m.total_group = &u
  28718. m.addtotal_group = nil
  28719. }
  28720. // TotalGroup returns the value of the "total_group" field in the mutation.
  28721. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28722. v := m.total_group
  28723. if v == nil {
  28724. return
  28725. }
  28726. return *v, true
  28727. }
  28728. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28729. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28731. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28732. if !m.op.Is(OpUpdateOne) {
  28733. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28734. }
  28735. if m.id == nil || m.oldValue == nil {
  28736. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28737. }
  28738. oldValue, err := m.oldValue(ctx)
  28739. if err != nil {
  28740. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28741. }
  28742. return oldValue.TotalGroup, nil
  28743. }
  28744. // AddTotalGroup adds u to the "total_group" field.
  28745. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28746. if m.addtotal_group != nil {
  28747. *m.addtotal_group += u
  28748. } else {
  28749. m.addtotal_group = &u
  28750. }
  28751. }
  28752. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28753. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28754. v := m.addtotal_group
  28755. if v == nil {
  28756. return
  28757. }
  28758. return *v, true
  28759. }
  28760. // ResetTotalGroup resets all changes to the "total_group" field.
  28761. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28762. m.total_group = nil
  28763. m.addtotal_group = nil
  28764. }
  28765. // SetAccountBalance sets the "account_balance" field.
  28766. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28767. m.account_balance = &u
  28768. m.addaccount_balance = nil
  28769. }
  28770. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28771. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28772. v := m.account_balance
  28773. if v == nil {
  28774. return
  28775. }
  28776. return *v, true
  28777. }
  28778. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28779. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28780. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28781. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28782. if !m.op.Is(OpUpdateOne) {
  28783. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28784. }
  28785. if m.id == nil || m.oldValue == nil {
  28786. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28787. }
  28788. oldValue, err := m.oldValue(ctx)
  28789. if err != nil {
  28790. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28791. }
  28792. return oldValue.AccountBalance, nil
  28793. }
  28794. // AddAccountBalance adds u to the "account_balance" field.
  28795. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28796. if m.addaccount_balance != nil {
  28797. *m.addaccount_balance += u
  28798. } else {
  28799. m.addaccount_balance = &u
  28800. }
  28801. }
  28802. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28803. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28804. v := m.addaccount_balance
  28805. if v == nil {
  28806. return
  28807. }
  28808. return *v, true
  28809. }
  28810. // ResetAccountBalance resets all changes to the "account_balance" field.
  28811. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28812. m.account_balance = nil
  28813. m.addaccount_balance = nil
  28814. }
  28815. // SetConsumeToken sets the "consume_token" field.
  28816. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28817. m.consume_token = &u
  28818. m.addconsume_token = nil
  28819. }
  28820. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28821. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28822. v := m.consume_token
  28823. if v == nil {
  28824. return
  28825. }
  28826. return *v, true
  28827. }
  28828. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28829. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28831. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28832. if !m.op.Is(OpUpdateOne) {
  28833. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28834. }
  28835. if m.id == nil || m.oldValue == nil {
  28836. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28837. }
  28838. oldValue, err := m.oldValue(ctx)
  28839. if err != nil {
  28840. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28841. }
  28842. return oldValue.ConsumeToken, nil
  28843. }
  28844. // AddConsumeToken adds u to the "consume_token" field.
  28845. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28846. if m.addconsume_token != nil {
  28847. *m.addconsume_token += u
  28848. } else {
  28849. m.addconsume_token = &u
  28850. }
  28851. }
  28852. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28853. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28854. v := m.addconsume_token
  28855. if v == nil {
  28856. return
  28857. }
  28858. return *v, true
  28859. }
  28860. // ResetConsumeToken resets all changes to the "consume_token" field.
  28861. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28862. m.consume_token = nil
  28863. m.addconsume_token = nil
  28864. }
  28865. // SetActiveUser sets the "active_user" field.
  28866. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28867. m.active_user = &u
  28868. m.addactive_user = nil
  28869. }
  28870. // ActiveUser returns the value of the "active_user" field in the mutation.
  28871. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28872. v := m.active_user
  28873. if v == nil {
  28874. return
  28875. }
  28876. return *v, true
  28877. }
  28878. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28879. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28880. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28881. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28882. if !m.op.Is(OpUpdateOne) {
  28883. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28884. }
  28885. if m.id == nil || m.oldValue == nil {
  28886. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28887. }
  28888. oldValue, err := m.oldValue(ctx)
  28889. if err != nil {
  28890. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28891. }
  28892. return oldValue.ActiveUser, nil
  28893. }
  28894. // AddActiveUser adds u to the "active_user" field.
  28895. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28896. if m.addactive_user != nil {
  28897. *m.addactive_user += u
  28898. } else {
  28899. m.addactive_user = &u
  28900. }
  28901. }
  28902. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28903. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28904. v := m.addactive_user
  28905. if v == nil {
  28906. return
  28907. }
  28908. return *v, true
  28909. }
  28910. // ResetActiveUser resets all changes to the "active_user" field.
  28911. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28912. m.active_user = nil
  28913. m.addactive_user = nil
  28914. }
  28915. // SetNewUser sets the "new_user" field.
  28916. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28917. m.new_user = &i
  28918. m.addnew_user = nil
  28919. }
  28920. // NewUser returns the value of the "new_user" field in the mutation.
  28921. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28922. v := m.new_user
  28923. if v == nil {
  28924. return
  28925. }
  28926. return *v, true
  28927. }
  28928. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28929. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28931. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28932. if !m.op.Is(OpUpdateOne) {
  28933. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28934. }
  28935. if m.id == nil || m.oldValue == nil {
  28936. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28937. }
  28938. oldValue, err := m.oldValue(ctx)
  28939. if err != nil {
  28940. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28941. }
  28942. return oldValue.NewUser, nil
  28943. }
  28944. // AddNewUser adds i to the "new_user" field.
  28945. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28946. if m.addnew_user != nil {
  28947. *m.addnew_user += i
  28948. } else {
  28949. m.addnew_user = &i
  28950. }
  28951. }
  28952. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28953. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28954. v := m.addnew_user
  28955. if v == nil {
  28956. return
  28957. }
  28958. return *v, true
  28959. }
  28960. // ResetNewUser resets all changes to the "new_user" field.
  28961. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28962. m.new_user = nil
  28963. m.addnew_user = nil
  28964. }
  28965. // SetLabelDist sets the "label_dist" field.
  28966. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28967. m.label_dist = &ctd
  28968. m.appendlabel_dist = nil
  28969. }
  28970. // LabelDist returns the value of the "label_dist" field in the mutation.
  28971. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28972. v := m.label_dist
  28973. if v == nil {
  28974. return
  28975. }
  28976. return *v, true
  28977. }
  28978. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28979. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28981. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28982. if !m.op.Is(OpUpdateOne) {
  28983. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28984. }
  28985. if m.id == nil || m.oldValue == nil {
  28986. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28987. }
  28988. oldValue, err := m.oldValue(ctx)
  28989. if err != nil {
  28990. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28991. }
  28992. return oldValue.LabelDist, nil
  28993. }
  28994. // AppendLabelDist adds ctd to the "label_dist" field.
  28995. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28996. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28997. }
  28998. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28999. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  29000. if len(m.appendlabel_dist) == 0 {
  29001. return nil, false
  29002. }
  29003. return m.appendlabel_dist, true
  29004. }
  29005. // ResetLabelDist resets all changes to the "label_dist" field.
  29006. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  29007. m.label_dist = nil
  29008. m.appendlabel_dist = nil
  29009. }
  29010. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  29011. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  29012. m.predicates = append(m.predicates, ps...)
  29013. }
  29014. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  29015. // users can use type-assertion to append predicates that do not depend on any generated package.
  29016. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  29017. p := make([]predicate.UsageStatisticDay, len(ps))
  29018. for i := range ps {
  29019. p[i] = ps[i]
  29020. }
  29021. m.Where(p...)
  29022. }
  29023. // Op returns the operation name.
  29024. func (m *UsageStatisticDayMutation) Op() Op {
  29025. return m.op
  29026. }
  29027. // SetOp allows setting the mutation operation.
  29028. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  29029. m.op = op
  29030. }
  29031. // Type returns the node type of this mutation (UsageStatisticDay).
  29032. func (m *UsageStatisticDayMutation) Type() string {
  29033. return m.typ
  29034. }
  29035. // Fields returns all fields that were changed during this mutation. Note that in
  29036. // order to get all numeric fields that were incremented/decremented, call
  29037. // AddedFields().
  29038. func (m *UsageStatisticDayMutation) Fields() []string {
  29039. fields := make([]string, 0, 17)
  29040. if m.created_at != nil {
  29041. fields = append(fields, usagestatisticday.FieldCreatedAt)
  29042. }
  29043. if m.updated_at != nil {
  29044. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  29045. }
  29046. if m.status != nil {
  29047. fields = append(fields, usagestatisticday.FieldStatus)
  29048. }
  29049. if m.deleted_at != nil {
  29050. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29051. }
  29052. if m.addtime != nil {
  29053. fields = append(fields, usagestatisticday.FieldAddtime)
  29054. }
  29055. if m._type != nil {
  29056. fields = append(fields, usagestatisticday.FieldType)
  29057. }
  29058. if m.bot_id != nil {
  29059. fields = append(fields, usagestatisticday.FieldBotID)
  29060. }
  29061. if m.organization_id != nil {
  29062. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29063. }
  29064. if m.ai_response != nil {
  29065. fields = append(fields, usagestatisticday.FieldAiResponse)
  29066. }
  29067. if m.sop_run != nil {
  29068. fields = append(fields, usagestatisticday.FieldSopRun)
  29069. }
  29070. if m.total_friend != nil {
  29071. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29072. }
  29073. if m.total_group != nil {
  29074. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29075. }
  29076. if m.account_balance != nil {
  29077. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29078. }
  29079. if m.consume_token != nil {
  29080. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29081. }
  29082. if m.active_user != nil {
  29083. fields = append(fields, usagestatisticday.FieldActiveUser)
  29084. }
  29085. if m.new_user != nil {
  29086. fields = append(fields, usagestatisticday.FieldNewUser)
  29087. }
  29088. if m.label_dist != nil {
  29089. fields = append(fields, usagestatisticday.FieldLabelDist)
  29090. }
  29091. return fields
  29092. }
  29093. // Field returns the value of a field with the given name. The second boolean
  29094. // return value indicates that this field was not set, or was not defined in the
  29095. // schema.
  29096. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29097. switch name {
  29098. case usagestatisticday.FieldCreatedAt:
  29099. return m.CreatedAt()
  29100. case usagestatisticday.FieldUpdatedAt:
  29101. return m.UpdatedAt()
  29102. case usagestatisticday.FieldStatus:
  29103. return m.Status()
  29104. case usagestatisticday.FieldDeletedAt:
  29105. return m.DeletedAt()
  29106. case usagestatisticday.FieldAddtime:
  29107. return m.Addtime()
  29108. case usagestatisticday.FieldType:
  29109. return m.GetType()
  29110. case usagestatisticday.FieldBotID:
  29111. return m.BotID()
  29112. case usagestatisticday.FieldOrganizationID:
  29113. return m.OrganizationID()
  29114. case usagestatisticday.FieldAiResponse:
  29115. return m.AiResponse()
  29116. case usagestatisticday.FieldSopRun:
  29117. return m.SopRun()
  29118. case usagestatisticday.FieldTotalFriend:
  29119. return m.TotalFriend()
  29120. case usagestatisticday.FieldTotalGroup:
  29121. return m.TotalGroup()
  29122. case usagestatisticday.FieldAccountBalance:
  29123. return m.AccountBalance()
  29124. case usagestatisticday.FieldConsumeToken:
  29125. return m.ConsumeToken()
  29126. case usagestatisticday.FieldActiveUser:
  29127. return m.ActiveUser()
  29128. case usagestatisticday.FieldNewUser:
  29129. return m.NewUser()
  29130. case usagestatisticday.FieldLabelDist:
  29131. return m.LabelDist()
  29132. }
  29133. return nil, false
  29134. }
  29135. // OldField returns the old value of the field from the database. An error is
  29136. // returned if the mutation operation is not UpdateOne, or the query to the
  29137. // database failed.
  29138. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29139. switch name {
  29140. case usagestatisticday.FieldCreatedAt:
  29141. return m.OldCreatedAt(ctx)
  29142. case usagestatisticday.FieldUpdatedAt:
  29143. return m.OldUpdatedAt(ctx)
  29144. case usagestatisticday.FieldStatus:
  29145. return m.OldStatus(ctx)
  29146. case usagestatisticday.FieldDeletedAt:
  29147. return m.OldDeletedAt(ctx)
  29148. case usagestatisticday.FieldAddtime:
  29149. return m.OldAddtime(ctx)
  29150. case usagestatisticday.FieldType:
  29151. return m.OldType(ctx)
  29152. case usagestatisticday.FieldBotID:
  29153. return m.OldBotID(ctx)
  29154. case usagestatisticday.FieldOrganizationID:
  29155. return m.OldOrganizationID(ctx)
  29156. case usagestatisticday.FieldAiResponse:
  29157. return m.OldAiResponse(ctx)
  29158. case usagestatisticday.FieldSopRun:
  29159. return m.OldSopRun(ctx)
  29160. case usagestatisticday.FieldTotalFriend:
  29161. return m.OldTotalFriend(ctx)
  29162. case usagestatisticday.FieldTotalGroup:
  29163. return m.OldTotalGroup(ctx)
  29164. case usagestatisticday.FieldAccountBalance:
  29165. return m.OldAccountBalance(ctx)
  29166. case usagestatisticday.FieldConsumeToken:
  29167. return m.OldConsumeToken(ctx)
  29168. case usagestatisticday.FieldActiveUser:
  29169. return m.OldActiveUser(ctx)
  29170. case usagestatisticday.FieldNewUser:
  29171. return m.OldNewUser(ctx)
  29172. case usagestatisticday.FieldLabelDist:
  29173. return m.OldLabelDist(ctx)
  29174. }
  29175. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29176. }
  29177. // SetField sets the value of a field with the given name. It returns an error if
  29178. // the field is not defined in the schema, or if the type mismatched the field
  29179. // type.
  29180. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29181. switch name {
  29182. case usagestatisticday.FieldCreatedAt:
  29183. v, ok := value.(time.Time)
  29184. if !ok {
  29185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29186. }
  29187. m.SetCreatedAt(v)
  29188. return nil
  29189. case usagestatisticday.FieldUpdatedAt:
  29190. v, ok := value.(time.Time)
  29191. if !ok {
  29192. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29193. }
  29194. m.SetUpdatedAt(v)
  29195. return nil
  29196. case usagestatisticday.FieldStatus:
  29197. v, ok := value.(uint8)
  29198. if !ok {
  29199. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29200. }
  29201. m.SetStatus(v)
  29202. return nil
  29203. case usagestatisticday.FieldDeletedAt:
  29204. v, ok := value.(time.Time)
  29205. if !ok {
  29206. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29207. }
  29208. m.SetDeletedAt(v)
  29209. return nil
  29210. case usagestatisticday.FieldAddtime:
  29211. v, ok := value.(uint64)
  29212. if !ok {
  29213. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29214. }
  29215. m.SetAddtime(v)
  29216. return nil
  29217. case usagestatisticday.FieldType:
  29218. v, ok := value.(int)
  29219. if !ok {
  29220. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29221. }
  29222. m.SetType(v)
  29223. return nil
  29224. case usagestatisticday.FieldBotID:
  29225. v, ok := value.(string)
  29226. if !ok {
  29227. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29228. }
  29229. m.SetBotID(v)
  29230. return nil
  29231. case usagestatisticday.FieldOrganizationID:
  29232. v, ok := value.(uint64)
  29233. if !ok {
  29234. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29235. }
  29236. m.SetOrganizationID(v)
  29237. return nil
  29238. case usagestatisticday.FieldAiResponse:
  29239. v, ok := value.(uint64)
  29240. if !ok {
  29241. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29242. }
  29243. m.SetAiResponse(v)
  29244. return nil
  29245. case usagestatisticday.FieldSopRun:
  29246. v, ok := value.(uint64)
  29247. if !ok {
  29248. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29249. }
  29250. m.SetSopRun(v)
  29251. return nil
  29252. case usagestatisticday.FieldTotalFriend:
  29253. v, ok := value.(uint64)
  29254. if !ok {
  29255. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29256. }
  29257. m.SetTotalFriend(v)
  29258. return nil
  29259. case usagestatisticday.FieldTotalGroup:
  29260. v, ok := value.(uint64)
  29261. if !ok {
  29262. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29263. }
  29264. m.SetTotalGroup(v)
  29265. return nil
  29266. case usagestatisticday.FieldAccountBalance:
  29267. v, ok := value.(uint64)
  29268. if !ok {
  29269. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29270. }
  29271. m.SetAccountBalance(v)
  29272. return nil
  29273. case usagestatisticday.FieldConsumeToken:
  29274. v, ok := value.(uint64)
  29275. if !ok {
  29276. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29277. }
  29278. m.SetConsumeToken(v)
  29279. return nil
  29280. case usagestatisticday.FieldActiveUser:
  29281. v, ok := value.(uint64)
  29282. if !ok {
  29283. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29284. }
  29285. m.SetActiveUser(v)
  29286. return nil
  29287. case usagestatisticday.FieldNewUser:
  29288. v, ok := value.(int64)
  29289. if !ok {
  29290. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29291. }
  29292. m.SetNewUser(v)
  29293. return nil
  29294. case usagestatisticday.FieldLabelDist:
  29295. v, ok := value.([]custom_types.LabelDist)
  29296. if !ok {
  29297. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29298. }
  29299. m.SetLabelDist(v)
  29300. return nil
  29301. }
  29302. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29303. }
  29304. // AddedFields returns all numeric fields that were incremented/decremented during
  29305. // this mutation.
  29306. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29307. var fields []string
  29308. if m.addstatus != nil {
  29309. fields = append(fields, usagestatisticday.FieldStatus)
  29310. }
  29311. if m.addaddtime != nil {
  29312. fields = append(fields, usagestatisticday.FieldAddtime)
  29313. }
  29314. if m.add_type != nil {
  29315. fields = append(fields, usagestatisticday.FieldType)
  29316. }
  29317. if m.addorganization_id != nil {
  29318. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29319. }
  29320. if m.addai_response != nil {
  29321. fields = append(fields, usagestatisticday.FieldAiResponse)
  29322. }
  29323. if m.addsop_run != nil {
  29324. fields = append(fields, usagestatisticday.FieldSopRun)
  29325. }
  29326. if m.addtotal_friend != nil {
  29327. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29328. }
  29329. if m.addtotal_group != nil {
  29330. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29331. }
  29332. if m.addaccount_balance != nil {
  29333. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29334. }
  29335. if m.addconsume_token != nil {
  29336. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29337. }
  29338. if m.addactive_user != nil {
  29339. fields = append(fields, usagestatisticday.FieldActiveUser)
  29340. }
  29341. if m.addnew_user != nil {
  29342. fields = append(fields, usagestatisticday.FieldNewUser)
  29343. }
  29344. return fields
  29345. }
  29346. // AddedField returns the numeric value that was incremented/decremented on a field
  29347. // with the given name. The second boolean return value indicates that this field
  29348. // was not set, or was not defined in the schema.
  29349. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29350. switch name {
  29351. case usagestatisticday.FieldStatus:
  29352. return m.AddedStatus()
  29353. case usagestatisticday.FieldAddtime:
  29354. return m.AddedAddtime()
  29355. case usagestatisticday.FieldType:
  29356. return m.AddedType()
  29357. case usagestatisticday.FieldOrganizationID:
  29358. return m.AddedOrganizationID()
  29359. case usagestatisticday.FieldAiResponse:
  29360. return m.AddedAiResponse()
  29361. case usagestatisticday.FieldSopRun:
  29362. return m.AddedSopRun()
  29363. case usagestatisticday.FieldTotalFriend:
  29364. return m.AddedTotalFriend()
  29365. case usagestatisticday.FieldTotalGroup:
  29366. return m.AddedTotalGroup()
  29367. case usagestatisticday.FieldAccountBalance:
  29368. return m.AddedAccountBalance()
  29369. case usagestatisticday.FieldConsumeToken:
  29370. return m.AddedConsumeToken()
  29371. case usagestatisticday.FieldActiveUser:
  29372. return m.AddedActiveUser()
  29373. case usagestatisticday.FieldNewUser:
  29374. return m.AddedNewUser()
  29375. }
  29376. return nil, false
  29377. }
  29378. // AddField adds the value to the field with the given name. It returns an error if
  29379. // the field is not defined in the schema, or if the type mismatched the field
  29380. // type.
  29381. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29382. switch name {
  29383. case usagestatisticday.FieldStatus:
  29384. v, ok := value.(int8)
  29385. if !ok {
  29386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29387. }
  29388. m.AddStatus(v)
  29389. return nil
  29390. case usagestatisticday.FieldAddtime:
  29391. v, ok := value.(int64)
  29392. if !ok {
  29393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29394. }
  29395. m.AddAddtime(v)
  29396. return nil
  29397. case usagestatisticday.FieldType:
  29398. v, ok := value.(int)
  29399. if !ok {
  29400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29401. }
  29402. m.AddType(v)
  29403. return nil
  29404. case usagestatisticday.FieldOrganizationID:
  29405. v, ok := value.(int64)
  29406. if !ok {
  29407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29408. }
  29409. m.AddOrganizationID(v)
  29410. return nil
  29411. case usagestatisticday.FieldAiResponse:
  29412. v, ok := value.(int64)
  29413. if !ok {
  29414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29415. }
  29416. m.AddAiResponse(v)
  29417. return nil
  29418. case usagestatisticday.FieldSopRun:
  29419. v, ok := value.(int64)
  29420. if !ok {
  29421. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29422. }
  29423. m.AddSopRun(v)
  29424. return nil
  29425. case usagestatisticday.FieldTotalFriend:
  29426. v, ok := value.(int64)
  29427. if !ok {
  29428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29429. }
  29430. m.AddTotalFriend(v)
  29431. return nil
  29432. case usagestatisticday.FieldTotalGroup:
  29433. v, ok := value.(int64)
  29434. if !ok {
  29435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29436. }
  29437. m.AddTotalGroup(v)
  29438. return nil
  29439. case usagestatisticday.FieldAccountBalance:
  29440. v, ok := value.(int64)
  29441. if !ok {
  29442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29443. }
  29444. m.AddAccountBalance(v)
  29445. return nil
  29446. case usagestatisticday.FieldConsumeToken:
  29447. v, ok := value.(int64)
  29448. if !ok {
  29449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29450. }
  29451. m.AddConsumeToken(v)
  29452. return nil
  29453. case usagestatisticday.FieldActiveUser:
  29454. v, ok := value.(int64)
  29455. if !ok {
  29456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29457. }
  29458. m.AddActiveUser(v)
  29459. return nil
  29460. case usagestatisticday.FieldNewUser:
  29461. v, ok := value.(int64)
  29462. if !ok {
  29463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29464. }
  29465. m.AddNewUser(v)
  29466. return nil
  29467. }
  29468. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29469. }
  29470. // ClearedFields returns all nullable fields that were cleared during this
  29471. // mutation.
  29472. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29473. var fields []string
  29474. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29475. fields = append(fields, usagestatisticday.FieldStatus)
  29476. }
  29477. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29478. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29479. }
  29480. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29481. fields = append(fields, usagestatisticday.FieldBotID)
  29482. }
  29483. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29484. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29485. }
  29486. return fields
  29487. }
  29488. // FieldCleared returns a boolean indicating if a field with the given name was
  29489. // cleared in this mutation.
  29490. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29491. _, ok := m.clearedFields[name]
  29492. return ok
  29493. }
  29494. // ClearField clears the value of the field with the given name. It returns an
  29495. // error if the field is not defined in the schema.
  29496. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29497. switch name {
  29498. case usagestatisticday.FieldStatus:
  29499. m.ClearStatus()
  29500. return nil
  29501. case usagestatisticday.FieldDeletedAt:
  29502. m.ClearDeletedAt()
  29503. return nil
  29504. case usagestatisticday.FieldBotID:
  29505. m.ClearBotID()
  29506. return nil
  29507. case usagestatisticday.FieldOrganizationID:
  29508. m.ClearOrganizationID()
  29509. return nil
  29510. }
  29511. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29512. }
  29513. // ResetField resets all changes in the mutation for the field with the given name.
  29514. // It returns an error if the field is not defined in the schema.
  29515. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29516. switch name {
  29517. case usagestatisticday.FieldCreatedAt:
  29518. m.ResetCreatedAt()
  29519. return nil
  29520. case usagestatisticday.FieldUpdatedAt:
  29521. m.ResetUpdatedAt()
  29522. return nil
  29523. case usagestatisticday.FieldStatus:
  29524. m.ResetStatus()
  29525. return nil
  29526. case usagestatisticday.FieldDeletedAt:
  29527. m.ResetDeletedAt()
  29528. return nil
  29529. case usagestatisticday.FieldAddtime:
  29530. m.ResetAddtime()
  29531. return nil
  29532. case usagestatisticday.FieldType:
  29533. m.ResetType()
  29534. return nil
  29535. case usagestatisticday.FieldBotID:
  29536. m.ResetBotID()
  29537. return nil
  29538. case usagestatisticday.FieldOrganizationID:
  29539. m.ResetOrganizationID()
  29540. return nil
  29541. case usagestatisticday.FieldAiResponse:
  29542. m.ResetAiResponse()
  29543. return nil
  29544. case usagestatisticday.FieldSopRun:
  29545. m.ResetSopRun()
  29546. return nil
  29547. case usagestatisticday.FieldTotalFriend:
  29548. m.ResetTotalFriend()
  29549. return nil
  29550. case usagestatisticday.FieldTotalGroup:
  29551. m.ResetTotalGroup()
  29552. return nil
  29553. case usagestatisticday.FieldAccountBalance:
  29554. m.ResetAccountBalance()
  29555. return nil
  29556. case usagestatisticday.FieldConsumeToken:
  29557. m.ResetConsumeToken()
  29558. return nil
  29559. case usagestatisticday.FieldActiveUser:
  29560. m.ResetActiveUser()
  29561. return nil
  29562. case usagestatisticday.FieldNewUser:
  29563. m.ResetNewUser()
  29564. return nil
  29565. case usagestatisticday.FieldLabelDist:
  29566. m.ResetLabelDist()
  29567. return nil
  29568. }
  29569. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29570. }
  29571. // AddedEdges returns all edge names that were set/added in this mutation.
  29572. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29573. edges := make([]string, 0, 0)
  29574. return edges
  29575. }
  29576. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29577. // name in this mutation.
  29578. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29579. return nil
  29580. }
  29581. // RemovedEdges returns all edge names that were removed in this mutation.
  29582. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29583. edges := make([]string, 0, 0)
  29584. return edges
  29585. }
  29586. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29587. // the given name in this mutation.
  29588. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29589. return nil
  29590. }
  29591. // ClearedEdges returns all edge names that were cleared in this mutation.
  29592. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29593. edges := make([]string, 0, 0)
  29594. return edges
  29595. }
  29596. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29597. // was cleared in this mutation.
  29598. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29599. return false
  29600. }
  29601. // ClearEdge clears the value of the edge with the given name. It returns an error
  29602. // if that edge is not defined in the schema.
  29603. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29604. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29605. }
  29606. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29607. // It returns an error if the edge is not defined in the schema.
  29608. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29609. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29610. }
  29611. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29612. type UsageStatisticHourMutation struct {
  29613. config
  29614. op Op
  29615. typ string
  29616. id *uint64
  29617. created_at *time.Time
  29618. updated_at *time.Time
  29619. status *uint8
  29620. addstatus *int8
  29621. deleted_at *time.Time
  29622. addtime *uint64
  29623. addaddtime *int64
  29624. _type *int
  29625. add_type *int
  29626. bot_id *string
  29627. organization_id *uint64
  29628. addorganization_id *int64
  29629. ai_response *uint64
  29630. addai_response *int64
  29631. sop_run *uint64
  29632. addsop_run *int64
  29633. total_friend *uint64
  29634. addtotal_friend *int64
  29635. total_group *uint64
  29636. addtotal_group *int64
  29637. account_balance *uint64
  29638. addaccount_balance *int64
  29639. consume_token *uint64
  29640. addconsume_token *int64
  29641. active_user *uint64
  29642. addactive_user *int64
  29643. new_user *int64
  29644. addnew_user *int64
  29645. label_dist *[]custom_types.LabelDist
  29646. appendlabel_dist []custom_types.LabelDist
  29647. clearedFields map[string]struct{}
  29648. done bool
  29649. oldValue func(context.Context) (*UsageStatisticHour, error)
  29650. predicates []predicate.UsageStatisticHour
  29651. }
  29652. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29653. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29654. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29655. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29656. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29657. m := &UsageStatisticHourMutation{
  29658. config: c,
  29659. op: op,
  29660. typ: TypeUsageStatisticHour,
  29661. clearedFields: make(map[string]struct{}),
  29662. }
  29663. for _, opt := range opts {
  29664. opt(m)
  29665. }
  29666. return m
  29667. }
  29668. // withUsageStatisticHourID sets the ID field of the mutation.
  29669. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29670. return func(m *UsageStatisticHourMutation) {
  29671. var (
  29672. err error
  29673. once sync.Once
  29674. value *UsageStatisticHour
  29675. )
  29676. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29677. once.Do(func() {
  29678. if m.done {
  29679. err = errors.New("querying old values post mutation is not allowed")
  29680. } else {
  29681. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29682. }
  29683. })
  29684. return value, err
  29685. }
  29686. m.id = &id
  29687. }
  29688. }
  29689. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29690. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29691. return func(m *UsageStatisticHourMutation) {
  29692. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29693. return node, nil
  29694. }
  29695. m.id = &node.ID
  29696. }
  29697. }
  29698. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29699. // executed in a transaction (ent.Tx), a transactional client is returned.
  29700. func (m UsageStatisticHourMutation) Client() *Client {
  29701. client := &Client{config: m.config}
  29702. client.init()
  29703. return client
  29704. }
  29705. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29706. // it returns an error otherwise.
  29707. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29708. if _, ok := m.driver.(*txDriver); !ok {
  29709. return nil, errors.New("ent: mutation is not running in a transaction")
  29710. }
  29711. tx := &Tx{config: m.config}
  29712. tx.init()
  29713. return tx, nil
  29714. }
  29715. // SetID sets the value of the id field. Note that this
  29716. // operation is only accepted on creation of UsageStatisticHour entities.
  29717. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29718. m.id = &id
  29719. }
  29720. // ID returns the ID value in the mutation. Note that the ID is only available
  29721. // if it was provided to the builder or after it was returned from the database.
  29722. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29723. if m.id == nil {
  29724. return
  29725. }
  29726. return *m.id, true
  29727. }
  29728. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29729. // That means, if the mutation is applied within a transaction with an isolation level such
  29730. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29731. // or updated by the mutation.
  29732. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29733. switch {
  29734. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29735. id, exists := m.ID()
  29736. if exists {
  29737. return []uint64{id}, nil
  29738. }
  29739. fallthrough
  29740. case m.op.Is(OpUpdate | OpDelete):
  29741. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29742. default:
  29743. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29744. }
  29745. }
  29746. // SetCreatedAt sets the "created_at" field.
  29747. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29748. m.created_at = &t
  29749. }
  29750. // CreatedAt returns the value of the "created_at" field in the mutation.
  29751. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29752. v := m.created_at
  29753. if v == nil {
  29754. return
  29755. }
  29756. return *v, true
  29757. }
  29758. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29759. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29760. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29761. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29762. if !m.op.Is(OpUpdateOne) {
  29763. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29764. }
  29765. if m.id == nil || m.oldValue == nil {
  29766. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29767. }
  29768. oldValue, err := m.oldValue(ctx)
  29769. if err != nil {
  29770. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29771. }
  29772. return oldValue.CreatedAt, nil
  29773. }
  29774. // ResetCreatedAt resets all changes to the "created_at" field.
  29775. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29776. m.created_at = nil
  29777. }
  29778. // SetUpdatedAt sets the "updated_at" field.
  29779. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29780. m.updated_at = &t
  29781. }
  29782. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29783. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29784. v := m.updated_at
  29785. if v == nil {
  29786. return
  29787. }
  29788. return *v, true
  29789. }
  29790. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29791. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29792. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29793. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29794. if !m.op.Is(OpUpdateOne) {
  29795. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29796. }
  29797. if m.id == nil || m.oldValue == nil {
  29798. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29799. }
  29800. oldValue, err := m.oldValue(ctx)
  29801. if err != nil {
  29802. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29803. }
  29804. return oldValue.UpdatedAt, nil
  29805. }
  29806. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29807. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29808. m.updated_at = nil
  29809. }
  29810. // SetStatus sets the "status" field.
  29811. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29812. m.status = &u
  29813. m.addstatus = nil
  29814. }
  29815. // Status returns the value of the "status" field in the mutation.
  29816. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29817. v := m.status
  29818. if v == nil {
  29819. return
  29820. }
  29821. return *v, true
  29822. }
  29823. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29824. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29825. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29826. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29827. if !m.op.Is(OpUpdateOne) {
  29828. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29829. }
  29830. if m.id == nil || m.oldValue == nil {
  29831. return v, errors.New("OldStatus requires an ID field in the mutation")
  29832. }
  29833. oldValue, err := m.oldValue(ctx)
  29834. if err != nil {
  29835. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29836. }
  29837. return oldValue.Status, nil
  29838. }
  29839. // AddStatus adds u to the "status" field.
  29840. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29841. if m.addstatus != nil {
  29842. *m.addstatus += u
  29843. } else {
  29844. m.addstatus = &u
  29845. }
  29846. }
  29847. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29848. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29849. v := m.addstatus
  29850. if v == nil {
  29851. return
  29852. }
  29853. return *v, true
  29854. }
  29855. // ClearStatus clears the value of the "status" field.
  29856. func (m *UsageStatisticHourMutation) ClearStatus() {
  29857. m.status = nil
  29858. m.addstatus = nil
  29859. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29860. }
  29861. // StatusCleared returns if the "status" field was cleared in this mutation.
  29862. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29863. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29864. return ok
  29865. }
  29866. // ResetStatus resets all changes to the "status" field.
  29867. func (m *UsageStatisticHourMutation) ResetStatus() {
  29868. m.status = nil
  29869. m.addstatus = nil
  29870. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29871. }
  29872. // SetDeletedAt sets the "deleted_at" field.
  29873. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29874. m.deleted_at = &t
  29875. }
  29876. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29877. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29878. v := m.deleted_at
  29879. if v == nil {
  29880. return
  29881. }
  29882. return *v, true
  29883. }
  29884. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29885. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29886. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29887. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29888. if !m.op.Is(OpUpdateOne) {
  29889. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29890. }
  29891. if m.id == nil || m.oldValue == nil {
  29892. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29893. }
  29894. oldValue, err := m.oldValue(ctx)
  29895. if err != nil {
  29896. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29897. }
  29898. return oldValue.DeletedAt, nil
  29899. }
  29900. // ClearDeletedAt clears the value of the "deleted_at" field.
  29901. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29902. m.deleted_at = nil
  29903. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29904. }
  29905. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29906. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29907. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29908. return ok
  29909. }
  29910. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29911. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29912. m.deleted_at = nil
  29913. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29914. }
  29915. // SetAddtime sets the "addtime" field.
  29916. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29917. m.addtime = &u
  29918. m.addaddtime = nil
  29919. }
  29920. // Addtime returns the value of the "addtime" field in the mutation.
  29921. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29922. v := m.addtime
  29923. if v == nil {
  29924. return
  29925. }
  29926. return *v, true
  29927. }
  29928. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29929. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29930. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29931. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29932. if !m.op.Is(OpUpdateOne) {
  29933. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29934. }
  29935. if m.id == nil || m.oldValue == nil {
  29936. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29937. }
  29938. oldValue, err := m.oldValue(ctx)
  29939. if err != nil {
  29940. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29941. }
  29942. return oldValue.Addtime, nil
  29943. }
  29944. // AddAddtime adds u to the "addtime" field.
  29945. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29946. if m.addaddtime != nil {
  29947. *m.addaddtime += u
  29948. } else {
  29949. m.addaddtime = &u
  29950. }
  29951. }
  29952. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29953. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29954. v := m.addaddtime
  29955. if v == nil {
  29956. return
  29957. }
  29958. return *v, true
  29959. }
  29960. // ResetAddtime resets all changes to the "addtime" field.
  29961. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29962. m.addtime = nil
  29963. m.addaddtime = nil
  29964. }
  29965. // SetType sets the "type" field.
  29966. func (m *UsageStatisticHourMutation) SetType(i int) {
  29967. m._type = &i
  29968. m.add_type = nil
  29969. }
  29970. // GetType returns the value of the "type" field in the mutation.
  29971. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29972. v := m._type
  29973. if v == nil {
  29974. return
  29975. }
  29976. return *v, true
  29977. }
  29978. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29979. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29981. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29982. if !m.op.Is(OpUpdateOne) {
  29983. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29984. }
  29985. if m.id == nil || m.oldValue == nil {
  29986. return v, errors.New("OldType requires an ID field in the mutation")
  29987. }
  29988. oldValue, err := m.oldValue(ctx)
  29989. if err != nil {
  29990. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29991. }
  29992. return oldValue.Type, nil
  29993. }
  29994. // AddType adds i to the "type" field.
  29995. func (m *UsageStatisticHourMutation) AddType(i int) {
  29996. if m.add_type != nil {
  29997. *m.add_type += i
  29998. } else {
  29999. m.add_type = &i
  30000. }
  30001. }
  30002. // AddedType returns the value that was added to the "type" field in this mutation.
  30003. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  30004. v := m.add_type
  30005. if v == nil {
  30006. return
  30007. }
  30008. return *v, true
  30009. }
  30010. // ResetType resets all changes to the "type" field.
  30011. func (m *UsageStatisticHourMutation) ResetType() {
  30012. m._type = nil
  30013. m.add_type = nil
  30014. }
  30015. // SetBotID sets the "bot_id" field.
  30016. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  30017. m.bot_id = &s
  30018. }
  30019. // BotID returns the value of the "bot_id" field in the mutation.
  30020. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  30021. v := m.bot_id
  30022. if v == nil {
  30023. return
  30024. }
  30025. return *v, true
  30026. }
  30027. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  30028. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30030. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  30031. if !m.op.Is(OpUpdateOne) {
  30032. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  30033. }
  30034. if m.id == nil || m.oldValue == nil {
  30035. return v, errors.New("OldBotID requires an ID field in the mutation")
  30036. }
  30037. oldValue, err := m.oldValue(ctx)
  30038. if err != nil {
  30039. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  30040. }
  30041. return oldValue.BotID, nil
  30042. }
  30043. // ClearBotID clears the value of the "bot_id" field.
  30044. func (m *UsageStatisticHourMutation) ClearBotID() {
  30045. m.bot_id = nil
  30046. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  30047. }
  30048. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  30049. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  30050. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  30051. return ok
  30052. }
  30053. // ResetBotID resets all changes to the "bot_id" field.
  30054. func (m *UsageStatisticHourMutation) ResetBotID() {
  30055. m.bot_id = nil
  30056. delete(m.clearedFields, usagestatistichour.FieldBotID)
  30057. }
  30058. // SetOrganizationID sets the "organization_id" field.
  30059. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  30060. m.organization_id = &u
  30061. m.addorganization_id = nil
  30062. }
  30063. // OrganizationID returns the value of the "organization_id" field in the mutation.
  30064. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  30065. v := m.organization_id
  30066. if v == nil {
  30067. return
  30068. }
  30069. return *v, true
  30070. }
  30071. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  30072. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30073. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30074. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  30075. if !m.op.Is(OpUpdateOne) {
  30076. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30077. }
  30078. if m.id == nil || m.oldValue == nil {
  30079. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30080. }
  30081. oldValue, err := m.oldValue(ctx)
  30082. if err != nil {
  30083. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30084. }
  30085. return oldValue.OrganizationID, nil
  30086. }
  30087. // AddOrganizationID adds u to the "organization_id" field.
  30088. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30089. if m.addorganization_id != nil {
  30090. *m.addorganization_id += u
  30091. } else {
  30092. m.addorganization_id = &u
  30093. }
  30094. }
  30095. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30096. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30097. v := m.addorganization_id
  30098. if v == nil {
  30099. return
  30100. }
  30101. return *v, true
  30102. }
  30103. // ClearOrganizationID clears the value of the "organization_id" field.
  30104. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30105. m.organization_id = nil
  30106. m.addorganization_id = nil
  30107. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30108. }
  30109. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30110. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30111. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30112. return ok
  30113. }
  30114. // ResetOrganizationID resets all changes to the "organization_id" field.
  30115. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30116. m.organization_id = nil
  30117. m.addorganization_id = nil
  30118. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30119. }
  30120. // SetAiResponse sets the "ai_response" field.
  30121. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30122. m.ai_response = &u
  30123. m.addai_response = nil
  30124. }
  30125. // AiResponse returns the value of the "ai_response" field in the mutation.
  30126. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30127. v := m.ai_response
  30128. if v == nil {
  30129. return
  30130. }
  30131. return *v, true
  30132. }
  30133. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30134. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30136. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30137. if !m.op.Is(OpUpdateOne) {
  30138. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30139. }
  30140. if m.id == nil || m.oldValue == nil {
  30141. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30142. }
  30143. oldValue, err := m.oldValue(ctx)
  30144. if err != nil {
  30145. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30146. }
  30147. return oldValue.AiResponse, nil
  30148. }
  30149. // AddAiResponse adds u to the "ai_response" field.
  30150. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30151. if m.addai_response != nil {
  30152. *m.addai_response += u
  30153. } else {
  30154. m.addai_response = &u
  30155. }
  30156. }
  30157. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30158. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30159. v := m.addai_response
  30160. if v == nil {
  30161. return
  30162. }
  30163. return *v, true
  30164. }
  30165. // ResetAiResponse resets all changes to the "ai_response" field.
  30166. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30167. m.ai_response = nil
  30168. m.addai_response = nil
  30169. }
  30170. // SetSopRun sets the "sop_run" field.
  30171. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30172. m.sop_run = &u
  30173. m.addsop_run = nil
  30174. }
  30175. // SopRun returns the value of the "sop_run" field in the mutation.
  30176. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30177. v := m.sop_run
  30178. if v == nil {
  30179. return
  30180. }
  30181. return *v, true
  30182. }
  30183. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30184. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30185. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30186. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30187. if !m.op.Is(OpUpdateOne) {
  30188. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30189. }
  30190. if m.id == nil || m.oldValue == nil {
  30191. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30192. }
  30193. oldValue, err := m.oldValue(ctx)
  30194. if err != nil {
  30195. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30196. }
  30197. return oldValue.SopRun, nil
  30198. }
  30199. // AddSopRun adds u to the "sop_run" field.
  30200. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30201. if m.addsop_run != nil {
  30202. *m.addsop_run += u
  30203. } else {
  30204. m.addsop_run = &u
  30205. }
  30206. }
  30207. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30208. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30209. v := m.addsop_run
  30210. if v == nil {
  30211. return
  30212. }
  30213. return *v, true
  30214. }
  30215. // ResetSopRun resets all changes to the "sop_run" field.
  30216. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30217. m.sop_run = nil
  30218. m.addsop_run = nil
  30219. }
  30220. // SetTotalFriend sets the "total_friend" field.
  30221. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30222. m.total_friend = &u
  30223. m.addtotal_friend = nil
  30224. }
  30225. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30226. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30227. v := m.total_friend
  30228. if v == nil {
  30229. return
  30230. }
  30231. return *v, true
  30232. }
  30233. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30234. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30236. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30237. if !m.op.Is(OpUpdateOne) {
  30238. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30239. }
  30240. if m.id == nil || m.oldValue == nil {
  30241. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30242. }
  30243. oldValue, err := m.oldValue(ctx)
  30244. if err != nil {
  30245. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30246. }
  30247. return oldValue.TotalFriend, nil
  30248. }
  30249. // AddTotalFriend adds u to the "total_friend" field.
  30250. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30251. if m.addtotal_friend != nil {
  30252. *m.addtotal_friend += u
  30253. } else {
  30254. m.addtotal_friend = &u
  30255. }
  30256. }
  30257. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30258. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30259. v := m.addtotal_friend
  30260. if v == nil {
  30261. return
  30262. }
  30263. return *v, true
  30264. }
  30265. // ResetTotalFriend resets all changes to the "total_friend" field.
  30266. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30267. m.total_friend = nil
  30268. m.addtotal_friend = nil
  30269. }
  30270. // SetTotalGroup sets the "total_group" field.
  30271. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30272. m.total_group = &u
  30273. m.addtotal_group = nil
  30274. }
  30275. // TotalGroup returns the value of the "total_group" field in the mutation.
  30276. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30277. v := m.total_group
  30278. if v == nil {
  30279. return
  30280. }
  30281. return *v, true
  30282. }
  30283. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30284. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30285. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30286. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30287. if !m.op.Is(OpUpdateOne) {
  30288. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30289. }
  30290. if m.id == nil || m.oldValue == nil {
  30291. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30292. }
  30293. oldValue, err := m.oldValue(ctx)
  30294. if err != nil {
  30295. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30296. }
  30297. return oldValue.TotalGroup, nil
  30298. }
  30299. // AddTotalGroup adds u to the "total_group" field.
  30300. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30301. if m.addtotal_group != nil {
  30302. *m.addtotal_group += u
  30303. } else {
  30304. m.addtotal_group = &u
  30305. }
  30306. }
  30307. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30308. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30309. v := m.addtotal_group
  30310. if v == nil {
  30311. return
  30312. }
  30313. return *v, true
  30314. }
  30315. // ResetTotalGroup resets all changes to the "total_group" field.
  30316. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30317. m.total_group = nil
  30318. m.addtotal_group = nil
  30319. }
  30320. // SetAccountBalance sets the "account_balance" field.
  30321. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30322. m.account_balance = &u
  30323. m.addaccount_balance = nil
  30324. }
  30325. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30326. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30327. v := m.account_balance
  30328. if v == nil {
  30329. return
  30330. }
  30331. return *v, true
  30332. }
  30333. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30334. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30336. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30337. if !m.op.Is(OpUpdateOne) {
  30338. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30339. }
  30340. if m.id == nil || m.oldValue == nil {
  30341. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30342. }
  30343. oldValue, err := m.oldValue(ctx)
  30344. if err != nil {
  30345. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30346. }
  30347. return oldValue.AccountBalance, nil
  30348. }
  30349. // AddAccountBalance adds u to the "account_balance" field.
  30350. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30351. if m.addaccount_balance != nil {
  30352. *m.addaccount_balance += u
  30353. } else {
  30354. m.addaccount_balance = &u
  30355. }
  30356. }
  30357. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30358. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30359. v := m.addaccount_balance
  30360. if v == nil {
  30361. return
  30362. }
  30363. return *v, true
  30364. }
  30365. // ResetAccountBalance resets all changes to the "account_balance" field.
  30366. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30367. m.account_balance = nil
  30368. m.addaccount_balance = nil
  30369. }
  30370. // SetConsumeToken sets the "consume_token" field.
  30371. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30372. m.consume_token = &u
  30373. m.addconsume_token = nil
  30374. }
  30375. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30376. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30377. v := m.consume_token
  30378. if v == nil {
  30379. return
  30380. }
  30381. return *v, true
  30382. }
  30383. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30384. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30385. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30386. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30387. if !m.op.Is(OpUpdateOne) {
  30388. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30389. }
  30390. if m.id == nil || m.oldValue == nil {
  30391. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30392. }
  30393. oldValue, err := m.oldValue(ctx)
  30394. if err != nil {
  30395. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30396. }
  30397. return oldValue.ConsumeToken, nil
  30398. }
  30399. // AddConsumeToken adds u to the "consume_token" field.
  30400. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30401. if m.addconsume_token != nil {
  30402. *m.addconsume_token += u
  30403. } else {
  30404. m.addconsume_token = &u
  30405. }
  30406. }
  30407. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30408. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30409. v := m.addconsume_token
  30410. if v == nil {
  30411. return
  30412. }
  30413. return *v, true
  30414. }
  30415. // ResetConsumeToken resets all changes to the "consume_token" field.
  30416. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30417. m.consume_token = nil
  30418. m.addconsume_token = nil
  30419. }
  30420. // SetActiveUser sets the "active_user" field.
  30421. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30422. m.active_user = &u
  30423. m.addactive_user = nil
  30424. }
  30425. // ActiveUser returns the value of the "active_user" field in the mutation.
  30426. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30427. v := m.active_user
  30428. if v == nil {
  30429. return
  30430. }
  30431. return *v, true
  30432. }
  30433. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30434. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30436. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30437. if !m.op.Is(OpUpdateOne) {
  30438. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30439. }
  30440. if m.id == nil || m.oldValue == nil {
  30441. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30442. }
  30443. oldValue, err := m.oldValue(ctx)
  30444. if err != nil {
  30445. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30446. }
  30447. return oldValue.ActiveUser, nil
  30448. }
  30449. // AddActiveUser adds u to the "active_user" field.
  30450. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30451. if m.addactive_user != nil {
  30452. *m.addactive_user += u
  30453. } else {
  30454. m.addactive_user = &u
  30455. }
  30456. }
  30457. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30458. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30459. v := m.addactive_user
  30460. if v == nil {
  30461. return
  30462. }
  30463. return *v, true
  30464. }
  30465. // ResetActiveUser resets all changes to the "active_user" field.
  30466. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30467. m.active_user = nil
  30468. m.addactive_user = nil
  30469. }
  30470. // SetNewUser sets the "new_user" field.
  30471. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30472. m.new_user = &i
  30473. m.addnew_user = nil
  30474. }
  30475. // NewUser returns the value of the "new_user" field in the mutation.
  30476. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30477. v := m.new_user
  30478. if v == nil {
  30479. return
  30480. }
  30481. return *v, true
  30482. }
  30483. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30484. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30486. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30487. if !m.op.Is(OpUpdateOne) {
  30488. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30489. }
  30490. if m.id == nil || m.oldValue == nil {
  30491. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30492. }
  30493. oldValue, err := m.oldValue(ctx)
  30494. if err != nil {
  30495. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30496. }
  30497. return oldValue.NewUser, nil
  30498. }
  30499. // AddNewUser adds i to the "new_user" field.
  30500. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30501. if m.addnew_user != nil {
  30502. *m.addnew_user += i
  30503. } else {
  30504. m.addnew_user = &i
  30505. }
  30506. }
  30507. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30508. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30509. v := m.addnew_user
  30510. if v == nil {
  30511. return
  30512. }
  30513. return *v, true
  30514. }
  30515. // ResetNewUser resets all changes to the "new_user" field.
  30516. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30517. m.new_user = nil
  30518. m.addnew_user = nil
  30519. }
  30520. // SetLabelDist sets the "label_dist" field.
  30521. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30522. m.label_dist = &ctd
  30523. m.appendlabel_dist = nil
  30524. }
  30525. // LabelDist returns the value of the "label_dist" field in the mutation.
  30526. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30527. v := m.label_dist
  30528. if v == nil {
  30529. return
  30530. }
  30531. return *v, true
  30532. }
  30533. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30534. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30536. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30537. if !m.op.Is(OpUpdateOne) {
  30538. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30539. }
  30540. if m.id == nil || m.oldValue == nil {
  30541. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30542. }
  30543. oldValue, err := m.oldValue(ctx)
  30544. if err != nil {
  30545. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30546. }
  30547. return oldValue.LabelDist, nil
  30548. }
  30549. // AppendLabelDist adds ctd to the "label_dist" field.
  30550. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30551. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30552. }
  30553. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30554. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30555. if len(m.appendlabel_dist) == 0 {
  30556. return nil, false
  30557. }
  30558. return m.appendlabel_dist, true
  30559. }
  30560. // ResetLabelDist resets all changes to the "label_dist" field.
  30561. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30562. m.label_dist = nil
  30563. m.appendlabel_dist = nil
  30564. }
  30565. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30566. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30567. m.predicates = append(m.predicates, ps...)
  30568. }
  30569. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30570. // users can use type-assertion to append predicates that do not depend on any generated package.
  30571. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30572. p := make([]predicate.UsageStatisticHour, len(ps))
  30573. for i := range ps {
  30574. p[i] = ps[i]
  30575. }
  30576. m.Where(p...)
  30577. }
  30578. // Op returns the operation name.
  30579. func (m *UsageStatisticHourMutation) Op() Op {
  30580. return m.op
  30581. }
  30582. // SetOp allows setting the mutation operation.
  30583. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30584. m.op = op
  30585. }
  30586. // Type returns the node type of this mutation (UsageStatisticHour).
  30587. func (m *UsageStatisticHourMutation) Type() string {
  30588. return m.typ
  30589. }
  30590. // Fields returns all fields that were changed during this mutation. Note that in
  30591. // order to get all numeric fields that were incremented/decremented, call
  30592. // AddedFields().
  30593. func (m *UsageStatisticHourMutation) Fields() []string {
  30594. fields := make([]string, 0, 17)
  30595. if m.created_at != nil {
  30596. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30597. }
  30598. if m.updated_at != nil {
  30599. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30600. }
  30601. if m.status != nil {
  30602. fields = append(fields, usagestatistichour.FieldStatus)
  30603. }
  30604. if m.deleted_at != nil {
  30605. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30606. }
  30607. if m.addtime != nil {
  30608. fields = append(fields, usagestatistichour.FieldAddtime)
  30609. }
  30610. if m._type != nil {
  30611. fields = append(fields, usagestatistichour.FieldType)
  30612. }
  30613. if m.bot_id != nil {
  30614. fields = append(fields, usagestatistichour.FieldBotID)
  30615. }
  30616. if m.organization_id != nil {
  30617. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30618. }
  30619. if m.ai_response != nil {
  30620. fields = append(fields, usagestatistichour.FieldAiResponse)
  30621. }
  30622. if m.sop_run != nil {
  30623. fields = append(fields, usagestatistichour.FieldSopRun)
  30624. }
  30625. if m.total_friend != nil {
  30626. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30627. }
  30628. if m.total_group != nil {
  30629. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30630. }
  30631. if m.account_balance != nil {
  30632. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30633. }
  30634. if m.consume_token != nil {
  30635. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30636. }
  30637. if m.active_user != nil {
  30638. fields = append(fields, usagestatistichour.FieldActiveUser)
  30639. }
  30640. if m.new_user != nil {
  30641. fields = append(fields, usagestatistichour.FieldNewUser)
  30642. }
  30643. if m.label_dist != nil {
  30644. fields = append(fields, usagestatistichour.FieldLabelDist)
  30645. }
  30646. return fields
  30647. }
  30648. // Field returns the value of a field with the given name. The second boolean
  30649. // return value indicates that this field was not set, or was not defined in the
  30650. // schema.
  30651. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30652. switch name {
  30653. case usagestatistichour.FieldCreatedAt:
  30654. return m.CreatedAt()
  30655. case usagestatistichour.FieldUpdatedAt:
  30656. return m.UpdatedAt()
  30657. case usagestatistichour.FieldStatus:
  30658. return m.Status()
  30659. case usagestatistichour.FieldDeletedAt:
  30660. return m.DeletedAt()
  30661. case usagestatistichour.FieldAddtime:
  30662. return m.Addtime()
  30663. case usagestatistichour.FieldType:
  30664. return m.GetType()
  30665. case usagestatistichour.FieldBotID:
  30666. return m.BotID()
  30667. case usagestatistichour.FieldOrganizationID:
  30668. return m.OrganizationID()
  30669. case usagestatistichour.FieldAiResponse:
  30670. return m.AiResponse()
  30671. case usagestatistichour.FieldSopRun:
  30672. return m.SopRun()
  30673. case usagestatistichour.FieldTotalFriend:
  30674. return m.TotalFriend()
  30675. case usagestatistichour.FieldTotalGroup:
  30676. return m.TotalGroup()
  30677. case usagestatistichour.FieldAccountBalance:
  30678. return m.AccountBalance()
  30679. case usagestatistichour.FieldConsumeToken:
  30680. return m.ConsumeToken()
  30681. case usagestatistichour.FieldActiveUser:
  30682. return m.ActiveUser()
  30683. case usagestatistichour.FieldNewUser:
  30684. return m.NewUser()
  30685. case usagestatistichour.FieldLabelDist:
  30686. return m.LabelDist()
  30687. }
  30688. return nil, false
  30689. }
  30690. // OldField returns the old value of the field from the database. An error is
  30691. // returned if the mutation operation is not UpdateOne, or the query to the
  30692. // database failed.
  30693. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30694. switch name {
  30695. case usagestatistichour.FieldCreatedAt:
  30696. return m.OldCreatedAt(ctx)
  30697. case usagestatistichour.FieldUpdatedAt:
  30698. return m.OldUpdatedAt(ctx)
  30699. case usagestatistichour.FieldStatus:
  30700. return m.OldStatus(ctx)
  30701. case usagestatistichour.FieldDeletedAt:
  30702. return m.OldDeletedAt(ctx)
  30703. case usagestatistichour.FieldAddtime:
  30704. return m.OldAddtime(ctx)
  30705. case usagestatistichour.FieldType:
  30706. return m.OldType(ctx)
  30707. case usagestatistichour.FieldBotID:
  30708. return m.OldBotID(ctx)
  30709. case usagestatistichour.FieldOrganizationID:
  30710. return m.OldOrganizationID(ctx)
  30711. case usagestatistichour.FieldAiResponse:
  30712. return m.OldAiResponse(ctx)
  30713. case usagestatistichour.FieldSopRun:
  30714. return m.OldSopRun(ctx)
  30715. case usagestatistichour.FieldTotalFriend:
  30716. return m.OldTotalFriend(ctx)
  30717. case usagestatistichour.FieldTotalGroup:
  30718. return m.OldTotalGroup(ctx)
  30719. case usagestatistichour.FieldAccountBalance:
  30720. return m.OldAccountBalance(ctx)
  30721. case usagestatistichour.FieldConsumeToken:
  30722. return m.OldConsumeToken(ctx)
  30723. case usagestatistichour.FieldActiveUser:
  30724. return m.OldActiveUser(ctx)
  30725. case usagestatistichour.FieldNewUser:
  30726. return m.OldNewUser(ctx)
  30727. case usagestatistichour.FieldLabelDist:
  30728. return m.OldLabelDist(ctx)
  30729. }
  30730. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30731. }
  30732. // SetField sets the value of a field with the given name. It returns an error if
  30733. // the field is not defined in the schema, or if the type mismatched the field
  30734. // type.
  30735. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30736. switch name {
  30737. case usagestatistichour.FieldCreatedAt:
  30738. v, ok := value.(time.Time)
  30739. if !ok {
  30740. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30741. }
  30742. m.SetCreatedAt(v)
  30743. return nil
  30744. case usagestatistichour.FieldUpdatedAt:
  30745. v, ok := value.(time.Time)
  30746. if !ok {
  30747. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30748. }
  30749. m.SetUpdatedAt(v)
  30750. return nil
  30751. case usagestatistichour.FieldStatus:
  30752. v, ok := value.(uint8)
  30753. if !ok {
  30754. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30755. }
  30756. m.SetStatus(v)
  30757. return nil
  30758. case usagestatistichour.FieldDeletedAt:
  30759. v, ok := value.(time.Time)
  30760. if !ok {
  30761. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30762. }
  30763. m.SetDeletedAt(v)
  30764. return nil
  30765. case usagestatistichour.FieldAddtime:
  30766. v, ok := value.(uint64)
  30767. if !ok {
  30768. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30769. }
  30770. m.SetAddtime(v)
  30771. return nil
  30772. case usagestatistichour.FieldType:
  30773. v, ok := value.(int)
  30774. if !ok {
  30775. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30776. }
  30777. m.SetType(v)
  30778. return nil
  30779. case usagestatistichour.FieldBotID:
  30780. v, ok := value.(string)
  30781. if !ok {
  30782. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30783. }
  30784. m.SetBotID(v)
  30785. return nil
  30786. case usagestatistichour.FieldOrganizationID:
  30787. v, ok := value.(uint64)
  30788. if !ok {
  30789. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30790. }
  30791. m.SetOrganizationID(v)
  30792. return nil
  30793. case usagestatistichour.FieldAiResponse:
  30794. v, ok := value.(uint64)
  30795. if !ok {
  30796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30797. }
  30798. m.SetAiResponse(v)
  30799. return nil
  30800. case usagestatistichour.FieldSopRun:
  30801. v, ok := value.(uint64)
  30802. if !ok {
  30803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30804. }
  30805. m.SetSopRun(v)
  30806. return nil
  30807. case usagestatistichour.FieldTotalFriend:
  30808. v, ok := value.(uint64)
  30809. if !ok {
  30810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30811. }
  30812. m.SetTotalFriend(v)
  30813. return nil
  30814. case usagestatistichour.FieldTotalGroup:
  30815. v, ok := value.(uint64)
  30816. if !ok {
  30817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30818. }
  30819. m.SetTotalGroup(v)
  30820. return nil
  30821. case usagestatistichour.FieldAccountBalance:
  30822. v, ok := value.(uint64)
  30823. if !ok {
  30824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30825. }
  30826. m.SetAccountBalance(v)
  30827. return nil
  30828. case usagestatistichour.FieldConsumeToken:
  30829. v, ok := value.(uint64)
  30830. if !ok {
  30831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30832. }
  30833. m.SetConsumeToken(v)
  30834. return nil
  30835. case usagestatistichour.FieldActiveUser:
  30836. v, ok := value.(uint64)
  30837. if !ok {
  30838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30839. }
  30840. m.SetActiveUser(v)
  30841. return nil
  30842. case usagestatistichour.FieldNewUser:
  30843. v, ok := value.(int64)
  30844. if !ok {
  30845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30846. }
  30847. m.SetNewUser(v)
  30848. return nil
  30849. case usagestatistichour.FieldLabelDist:
  30850. v, ok := value.([]custom_types.LabelDist)
  30851. if !ok {
  30852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30853. }
  30854. m.SetLabelDist(v)
  30855. return nil
  30856. }
  30857. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30858. }
  30859. // AddedFields returns all numeric fields that were incremented/decremented during
  30860. // this mutation.
  30861. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30862. var fields []string
  30863. if m.addstatus != nil {
  30864. fields = append(fields, usagestatistichour.FieldStatus)
  30865. }
  30866. if m.addaddtime != nil {
  30867. fields = append(fields, usagestatistichour.FieldAddtime)
  30868. }
  30869. if m.add_type != nil {
  30870. fields = append(fields, usagestatistichour.FieldType)
  30871. }
  30872. if m.addorganization_id != nil {
  30873. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30874. }
  30875. if m.addai_response != nil {
  30876. fields = append(fields, usagestatistichour.FieldAiResponse)
  30877. }
  30878. if m.addsop_run != nil {
  30879. fields = append(fields, usagestatistichour.FieldSopRun)
  30880. }
  30881. if m.addtotal_friend != nil {
  30882. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30883. }
  30884. if m.addtotal_group != nil {
  30885. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30886. }
  30887. if m.addaccount_balance != nil {
  30888. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30889. }
  30890. if m.addconsume_token != nil {
  30891. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30892. }
  30893. if m.addactive_user != nil {
  30894. fields = append(fields, usagestatistichour.FieldActiveUser)
  30895. }
  30896. if m.addnew_user != nil {
  30897. fields = append(fields, usagestatistichour.FieldNewUser)
  30898. }
  30899. return fields
  30900. }
  30901. // AddedField returns the numeric value that was incremented/decremented on a field
  30902. // with the given name. The second boolean return value indicates that this field
  30903. // was not set, or was not defined in the schema.
  30904. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30905. switch name {
  30906. case usagestatistichour.FieldStatus:
  30907. return m.AddedStatus()
  30908. case usagestatistichour.FieldAddtime:
  30909. return m.AddedAddtime()
  30910. case usagestatistichour.FieldType:
  30911. return m.AddedType()
  30912. case usagestatistichour.FieldOrganizationID:
  30913. return m.AddedOrganizationID()
  30914. case usagestatistichour.FieldAiResponse:
  30915. return m.AddedAiResponse()
  30916. case usagestatistichour.FieldSopRun:
  30917. return m.AddedSopRun()
  30918. case usagestatistichour.FieldTotalFriend:
  30919. return m.AddedTotalFriend()
  30920. case usagestatistichour.FieldTotalGroup:
  30921. return m.AddedTotalGroup()
  30922. case usagestatistichour.FieldAccountBalance:
  30923. return m.AddedAccountBalance()
  30924. case usagestatistichour.FieldConsumeToken:
  30925. return m.AddedConsumeToken()
  30926. case usagestatistichour.FieldActiveUser:
  30927. return m.AddedActiveUser()
  30928. case usagestatistichour.FieldNewUser:
  30929. return m.AddedNewUser()
  30930. }
  30931. return nil, false
  30932. }
  30933. // AddField adds the value to the field with the given name. It returns an error if
  30934. // the field is not defined in the schema, or if the type mismatched the field
  30935. // type.
  30936. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30937. switch name {
  30938. case usagestatistichour.FieldStatus:
  30939. v, ok := value.(int8)
  30940. if !ok {
  30941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30942. }
  30943. m.AddStatus(v)
  30944. return nil
  30945. case usagestatistichour.FieldAddtime:
  30946. v, ok := value.(int64)
  30947. if !ok {
  30948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30949. }
  30950. m.AddAddtime(v)
  30951. return nil
  30952. case usagestatistichour.FieldType:
  30953. v, ok := value.(int)
  30954. if !ok {
  30955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30956. }
  30957. m.AddType(v)
  30958. return nil
  30959. case usagestatistichour.FieldOrganizationID:
  30960. v, ok := value.(int64)
  30961. if !ok {
  30962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30963. }
  30964. m.AddOrganizationID(v)
  30965. return nil
  30966. case usagestatistichour.FieldAiResponse:
  30967. v, ok := value.(int64)
  30968. if !ok {
  30969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30970. }
  30971. m.AddAiResponse(v)
  30972. return nil
  30973. case usagestatistichour.FieldSopRun:
  30974. v, ok := value.(int64)
  30975. if !ok {
  30976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30977. }
  30978. m.AddSopRun(v)
  30979. return nil
  30980. case usagestatistichour.FieldTotalFriend:
  30981. v, ok := value.(int64)
  30982. if !ok {
  30983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30984. }
  30985. m.AddTotalFriend(v)
  30986. return nil
  30987. case usagestatistichour.FieldTotalGroup:
  30988. v, ok := value.(int64)
  30989. if !ok {
  30990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30991. }
  30992. m.AddTotalGroup(v)
  30993. return nil
  30994. case usagestatistichour.FieldAccountBalance:
  30995. v, ok := value.(int64)
  30996. if !ok {
  30997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30998. }
  30999. m.AddAccountBalance(v)
  31000. return nil
  31001. case usagestatistichour.FieldConsumeToken:
  31002. v, ok := value.(int64)
  31003. if !ok {
  31004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31005. }
  31006. m.AddConsumeToken(v)
  31007. return nil
  31008. case usagestatistichour.FieldActiveUser:
  31009. v, ok := value.(int64)
  31010. if !ok {
  31011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31012. }
  31013. m.AddActiveUser(v)
  31014. return nil
  31015. case usagestatistichour.FieldNewUser:
  31016. v, ok := value.(int64)
  31017. if !ok {
  31018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  31019. }
  31020. m.AddNewUser(v)
  31021. return nil
  31022. }
  31023. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  31024. }
  31025. // ClearedFields returns all nullable fields that were cleared during this
  31026. // mutation.
  31027. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  31028. var fields []string
  31029. if m.FieldCleared(usagestatistichour.FieldStatus) {
  31030. fields = append(fields, usagestatistichour.FieldStatus)
  31031. }
  31032. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  31033. fields = append(fields, usagestatistichour.FieldDeletedAt)
  31034. }
  31035. if m.FieldCleared(usagestatistichour.FieldBotID) {
  31036. fields = append(fields, usagestatistichour.FieldBotID)
  31037. }
  31038. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  31039. fields = append(fields, usagestatistichour.FieldOrganizationID)
  31040. }
  31041. return fields
  31042. }
  31043. // FieldCleared returns a boolean indicating if a field with the given name was
  31044. // cleared in this mutation.
  31045. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  31046. _, ok := m.clearedFields[name]
  31047. return ok
  31048. }
  31049. // ClearField clears the value of the field with the given name. It returns an
  31050. // error if the field is not defined in the schema.
  31051. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  31052. switch name {
  31053. case usagestatistichour.FieldStatus:
  31054. m.ClearStatus()
  31055. return nil
  31056. case usagestatistichour.FieldDeletedAt:
  31057. m.ClearDeletedAt()
  31058. return nil
  31059. case usagestatistichour.FieldBotID:
  31060. m.ClearBotID()
  31061. return nil
  31062. case usagestatistichour.FieldOrganizationID:
  31063. m.ClearOrganizationID()
  31064. return nil
  31065. }
  31066. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  31067. }
  31068. // ResetField resets all changes in the mutation for the field with the given name.
  31069. // It returns an error if the field is not defined in the schema.
  31070. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  31071. switch name {
  31072. case usagestatistichour.FieldCreatedAt:
  31073. m.ResetCreatedAt()
  31074. return nil
  31075. case usagestatistichour.FieldUpdatedAt:
  31076. m.ResetUpdatedAt()
  31077. return nil
  31078. case usagestatistichour.FieldStatus:
  31079. m.ResetStatus()
  31080. return nil
  31081. case usagestatistichour.FieldDeletedAt:
  31082. m.ResetDeletedAt()
  31083. return nil
  31084. case usagestatistichour.FieldAddtime:
  31085. m.ResetAddtime()
  31086. return nil
  31087. case usagestatistichour.FieldType:
  31088. m.ResetType()
  31089. return nil
  31090. case usagestatistichour.FieldBotID:
  31091. m.ResetBotID()
  31092. return nil
  31093. case usagestatistichour.FieldOrganizationID:
  31094. m.ResetOrganizationID()
  31095. return nil
  31096. case usagestatistichour.FieldAiResponse:
  31097. m.ResetAiResponse()
  31098. return nil
  31099. case usagestatistichour.FieldSopRun:
  31100. m.ResetSopRun()
  31101. return nil
  31102. case usagestatistichour.FieldTotalFriend:
  31103. m.ResetTotalFriend()
  31104. return nil
  31105. case usagestatistichour.FieldTotalGroup:
  31106. m.ResetTotalGroup()
  31107. return nil
  31108. case usagestatistichour.FieldAccountBalance:
  31109. m.ResetAccountBalance()
  31110. return nil
  31111. case usagestatistichour.FieldConsumeToken:
  31112. m.ResetConsumeToken()
  31113. return nil
  31114. case usagestatistichour.FieldActiveUser:
  31115. m.ResetActiveUser()
  31116. return nil
  31117. case usagestatistichour.FieldNewUser:
  31118. m.ResetNewUser()
  31119. return nil
  31120. case usagestatistichour.FieldLabelDist:
  31121. m.ResetLabelDist()
  31122. return nil
  31123. }
  31124. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31125. }
  31126. // AddedEdges returns all edge names that were set/added in this mutation.
  31127. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31128. edges := make([]string, 0, 0)
  31129. return edges
  31130. }
  31131. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31132. // name in this mutation.
  31133. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31134. return nil
  31135. }
  31136. // RemovedEdges returns all edge names that were removed in this mutation.
  31137. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31138. edges := make([]string, 0, 0)
  31139. return edges
  31140. }
  31141. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31142. // the given name in this mutation.
  31143. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31144. return nil
  31145. }
  31146. // ClearedEdges returns all edge names that were cleared in this mutation.
  31147. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31148. edges := make([]string, 0, 0)
  31149. return edges
  31150. }
  31151. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31152. // was cleared in this mutation.
  31153. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31154. return false
  31155. }
  31156. // ClearEdge clears the value of the edge with the given name. It returns an error
  31157. // if that edge is not defined in the schema.
  31158. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31159. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31160. }
  31161. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31162. // It returns an error if the edge is not defined in the schema.
  31163. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31164. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31165. }
  31166. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31167. type UsageStatisticMonthMutation struct {
  31168. config
  31169. op Op
  31170. typ string
  31171. id *uint64
  31172. created_at *time.Time
  31173. updated_at *time.Time
  31174. status *uint8
  31175. addstatus *int8
  31176. deleted_at *time.Time
  31177. addtime *uint64
  31178. addaddtime *int64
  31179. _type *int
  31180. add_type *int
  31181. bot_id *string
  31182. organization_id *uint64
  31183. addorganization_id *int64
  31184. ai_response *uint64
  31185. addai_response *int64
  31186. sop_run *uint64
  31187. addsop_run *int64
  31188. total_friend *uint64
  31189. addtotal_friend *int64
  31190. total_group *uint64
  31191. addtotal_group *int64
  31192. account_balance *uint64
  31193. addaccount_balance *int64
  31194. consume_token *uint64
  31195. addconsume_token *int64
  31196. active_user *uint64
  31197. addactive_user *int64
  31198. new_user *int64
  31199. addnew_user *int64
  31200. label_dist *[]custom_types.LabelDist
  31201. appendlabel_dist []custom_types.LabelDist
  31202. clearedFields map[string]struct{}
  31203. done bool
  31204. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31205. predicates []predicate.UsageStatisticMonth
  31206. }
  31207. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31208. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31209. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31210. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31211. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31212. m := &UsageStatisticMonthMutation{
  31213. config: c,
  31214. op: op,
  31215. typ: TypeUsageStatisticMonth,
  31216. clearedFields: make(map[string]struct{}),
  31217. }
  31218. for _, opt := range opts {
  31219. opt(m)
  31220. }
  31221. return m
  31222. }
  31223. // withUsageStatisticMonthID sets the ID field of the mutation.
  31224. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31225. return func(m *UsageStatisticMonthMutation) {
  31226. var (
  31227. err error
  31228. once sync.Once
  31229. value *UsageStatisticMonth
  31230. )
  31231. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31232. once.Do(func() {
  31233. if m.done {
  31234. err = errors.New("querying old values post mutation is not allowed")
  31235. } else {
  31236. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31237. }
  31238. })
  31239. return value, err
  31240. }
  31241. m.id = &id
  31242. }
  31243. }
  31244. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31245. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31246. return func(m *UsageStatisticMonthMutation) {
  31247. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31248. return node, nil
  31249. }
  31250. m.id = &node.ID
  31251. }
  31252. }
  31253. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31254. // executed in a transaction (ent.Tx), a transactional client is returned.
  31255. func (m UsageStatisticMonthMutation) Client() *Client {
  31256. client := &Client{config: m.config}
  31257. client.init()
  31258. return client
  31259. }
  31260. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31261. // it returns an error otherwise.
  31262. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31263. if _, ok := m.driver.(*txDriver); !ok {
  31264. return nil, errors.New("ent: mutation is not running in a transaction")
  31265. }
  31266. tx := &Tx{config: m.config}
  31267. tx.init()
  31268. return tx, nil
  31269. }
  31270. // SetID sets the value of the id field. Note that this
  31271. // operation is only accepted on creation of UsageStatisticMonth entities.
  31272. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31273. m.id = &id
  31274. }
  31275. // ID returns the ID value in the mutation. Note that the ID is only available
  31276. // if it was provided to the builder or after it was returned from the database.
  31277. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31278. if m.id == nil {
  31279. return
  31280. }
  31281. return *m.id, true
  31282. }
  31283. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31284. // That means, if the mutation is applied within a transaction with an isolation level such
  31285. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31286. // or updated by the mutation.
  31287. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31288. switch {
  31289. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31290. id, exists := m.ID()
  31291. if exists {
  31292. return []uint64{id}, nil
  31293. }
  31294. fallthrough
  31295. case m.op.Is(OpUpdate | OpDelete):
  31296. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31297. default:
  31298. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31299. }
  31300. }
  31301. // SetCreatedAt sets the "created_at" field.
  31302. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31303. m.created_at = &t
  31304. }
  31305. // CreatedAt returns the value of the "created_at" field in the mutation.
  31306. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31307. v := m.created_at
  31308. if v == nil {
  31309. return
  31310. }
  31311. return *v, true
  31312. }
  31313. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31314. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31316. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31317. if !m.op.Is(OpUpdateOne) {
  31318. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31319. }
  31320. if m.id == nil || m.oldValue == nil {
  31321. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31322. }
  31323. oldValue, err := m.oldValue(ctx)
  31324. if err != nil {
  31325. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31326. }
  31327. return oldValue.CreatedAt, nil
  31328. }
  31329. // ResetCreatedAt resets all changes to the "created_at" field.
  31330. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31331. m.created_at = nil
  31332. }
  31333. // SetUpdatedAt sets the "updated_at" field.
  31334. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31335. m.updated_at = &t
  31336. }
  31337. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31338. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31339. v := m.updated_at
  31340. if v == nil {
  31341. return
  31342. }
  31343. return *v, true
  31344. }
  31345. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31346. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31347. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31348. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31349. if !m.op.Is(OpUpdateOne) {
  31350. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31351. }
  31352. if m.id == nil || m.oldValue == nil {
  31353. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31354. }
  31355. oldValue, err := m.oldValue(ctx)
  31356. if err != nil {
  31357. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31358. }
  31359. return oldValue.UpdatedAt, nil
  31360. }
  31361. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31362. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31363. m.updated_at = nil
  31364. }
  31365. // SetStatus sets the "status" field.
  31366. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31367. m.status = &u
  31368. m.addstatus = nil
  31369. }
  31370. // Status returns the value of the "status" field in the mutation.
  31371. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31372. v := m.status
  31373. if v == nil {
  31374. return
  31375. }
  31376. return *v, true
  31377. }
  31378. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31379. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31381. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31382. if !m.op.Is(OpUpdateOne) {
  31383. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31384. }
  31385. if m.id == nil || m.oldValue == nil {
  31386. return v, errors.New("OldStatus requires an ID field in the mutation")
  31387. }
  31388. oldValue, err := m.oldValue(ctx)
  31389. if err != nil {
  31390. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31391. }
  31392. return oldValue.Status, nil
  31393. }
  31394. // AddStatus adds u to the "status" field.
  31395. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31396. if m.addstatus != nil {
  31397. *m.addstatus += u
  31398. } else {
  31399. m.addstatus = &u
  31400. }
  31401. }
  31402. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31403. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31404. v := m.addstatus
  31405. if v == nil {
  31406. return
  31407. }
  31408. return *v, true
  31409. }
  31410. // ClearStatus clears the value of the "status" field.
  31411. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31412. m.status = nil
  31413. m.addstatus = nil
  31414. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31415. }
  31416. // StatusCleared returns if the "status" field was cleared in this mutation.
  31417. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31418. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31419. return ok
  31420. }
  31421. // ResetStatus resets all changes to the "status" field.
  31422. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31423. m.status = nil
  31424. m.addstatus = nil
  31425. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31426. }
  31427. // SetDeletedAt sets the "deleted_at" field.
  31428. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31429. m.deleted_at = &t
  31430. }
  31431. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31432. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31433. v := m.deleted_at
  31434. if v == nil {
  31435. return
  31436. }
  31437. return *v, true
  31438. }
  31439. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31440. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31441. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31442. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31443. if !m.op.Is(OpUpdateOne) {
  31444. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31445. }
  31446. if m.id == nil || m.oldValue == nil {
  31447. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31448. }
  31449. oldValue, err := m.oldValue(ctx)
  31450. if err != nil {
  31451. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31452. }
  31453. return oldValue.DeletedAt, nil
  31454. }
  31455. // ClearDeletedAt clears the value of the "deleted_at" field.
  31456. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31457. m.deleted_at = nil
  31458. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31459. }
  31460. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31461. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31462. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31463. return ok
  31464. }
  31465. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31466. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31467. m.deleted_at = nil
  31468. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31469. }
  31470. // SetAddtime sets the "addtime" field.
  31471. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31472. m.addtime = &u
  31473. m.addaddtime = nil
  31474. }
  31475. // Addtime returns the value of the "addtime" field in the mutation.
  31476. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31477. v := m.addtime
  31478. if v == nil {
  31479. return
  31480. }
  31481. return *v, true
  31482. }
  31483. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31484. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31486. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31487. if !m.op.Is(OpUpdateOne) {
  31488. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31489. }
  31490. if m.id == nil || m.oldValue == nil {
  31491. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31492. }
  31493. oldValue, err := m.oldValue(ctx)
  31494. if err != nil {
  31495. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31496. }
  31497. return oldValue.Addtime, nil
  31498. }
  31499. // AddAddtime adds u to the "addtime" field.
  31500. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31501. if m.addaddtime != nil {
  31502. *m.addaddtime += u
  31503. } else {
  31504. m.addaddtime = &u
  31505. }
  31506. }
  31507. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31508. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31509. v := m.addaddtime
  31510. if v == nil {
  31511. return
  31512. }
  31513. return *v, true
  31514. }
  31515. // ResetAddtime resets all changes to the "addtime" field.
  31516. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31517. m.addtime = nil
  31518. m.addaddtime = nil
  31519. }
  31520. // SetType sets the "type" field.
  31521. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31522. m._type = &i
  31523. m.add_type = nil
  31524. }
  31525. // GetType returns the value of the "type" field in the mutation.
  31526. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31527. v := m._type
  31528. if v == nil {
  31529. return
  31530. }
  31531. return *v, true
  31532. }
  31533. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31534. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31535. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31536. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31537. if !m.op.Is(OpUpdateOne) {
  31538. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31539. }
  31540. if m.id == nil || m.oldValue == nil {
  31541. return v, errors.New("OldType requires an ID field in the mutation")
  31542. }
  31543. oldValue, err := m.oldValue(ctx)
  31544. if err != nil {
  31545. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31546. }
  31547. return oldValue.Type, nil
  31548. }
  31549. // AddType adds i to the "type" field.
  31550. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31551. if m.add_type != nil {
  31552. *m.add_type += i
  31553. } else {
  31554. m.add_type = &i
  31555. }
  31556. }
  31557. // AddedType returns the value that was added to the "type" field in this mutation.
  31558. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31559. v := m.add_type
  31560. if v == nil {
  31561. return
  31562. }
  31563. return *v, true
  31564. }
  31565. // ResetType resets all changes to the "type" field.
  31566. func (m *UsageStatisticMonthMutation) ResetType() {
  31567. m._type = nil
  31568. m.add_type = nil
  31569. }
  31570. // SetBotID sets the "bot_id" field.
  31571. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31572. m.bot_id = &s
  31573. }
  31574. // BotID returns the value of the "bot_id" field in the mutation.
  31575. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31576. v := m.bot_id
  31577. if v == nil {
  31578. return
  31579. }
  31580. return *v, true
  31581. }
  31582. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31583. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31584. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31585. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31586. if !m.op.Is(OpUpdateOne) {
  31587. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31588. }
  31589. if m.id == nil || m.oldValue == nil {
  31590. return v, errors.New("OldBotID requires an ID field in the mutation")
  31591. }
  31592. oldValue, err := m.oldValue(ctx)
  31593. if err != nil {
  31594. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31595. }
  31596. return oldValue.BotID, nil
  31597. }
  31598. // ClearBotID clears the value of the "bot_id" field.
  31599. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31600. m.bot_id = nil
  31601. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31602. }
  31603. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31604. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31605. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31606. return ok
  31607. }
  31608. // ResetBotID resets all changes to the "bot_id" field.
  31609. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31610. m.bot_id = nil
  31611. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31612. }
  31613. // SetOrganizationID sets the "organization_id" field.
  31614. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31615. m.organization_id = &u
  31616. m.addorganization_id = nil
  31617. }
  31618. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31619. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31620. v := m.organization_id
  31621. if v == nil {
  31622. return
  31623. }
  31624. return *v, true
  31625. }
  31626. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31627. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31629. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31630. if !m.op.Is(OpUpdateOne) {
  31631. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31632. }
  31633. if m.id == nil || m.oldValue == nil {
  31634. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31635. }
  31636. oldValue, err := m.oldValue(ctx)
  31637. if err != nil {
  31638. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31639. }
  31640. return oldValue.OrganizationID, nil
  31641. }
  31642. // AddOrganizationID adds u to the "organization_id" field.
  31643. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31644. if m.addorganization_id != nil {
  31645. *m.addorganization_id += u
  31646. } else {
  31647. m.addorganization_id = &u
  31648. }
  31649. }
  31650. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31651. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31652. v := m.addorganization_id
  31653. if v == nil {
  31654. return
  31655. }
  31656. return *v, true
  31657. }
  31658. // ClearOrganizationID clears the value of the "organization_id" field.
  31659. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31660. m.organization_id = nil
  31661. m.addorganization_id = nil
  31662. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31663. }
  31664. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31665. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31666. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31667. return ok
  31668. }
  31669. // ResetOrganizationID resets all changes to the "organization_id" field.
  31670. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31671. m.organization_id = nil
  31672. m.addorganization_id = nil
  31673. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31674. }
  31675. // SetAiResponse sets the "ai_response" field.
  31676. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31677. m.ai_response = &u
  31678. m.addai_response = nil
  31679. }
  31680. // AiResponse returns the value of the "ai_response" field in the mutation.
  31681. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31682. v := m.ai_response
  31683. if v == nil {
  31684. return
  31685. }
  31686. return *v, true
  31687. }
  31688. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31689. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31690. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31691. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31692. if !m.op.Is(OpUpdateOne) {
  31693. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31694. }
  31695. if m.id == nil || m.oldValue == nil {
  31696. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31697. }
  31698. oldValue, err := m.oldValue(ctx)
  31699. if err != nil {
  31700. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31701. }
  31702. return oldValue.AiResponse, nil
  31703. }
  31704. // AddAiResponse adds u to the "ai_response" field.
  31705. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31706. if m.addai_response != nil {
  31707. *m.addai_response += u
  31708. } else {
  31709. m.addai_response = &u
  31710. }
  31711. }
  31712. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31713. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31714. v := m.addai_response
  31715. if v == nil {
  31716. return
  31717. }
  31718. return *v, true
  31719. }
  31720. // ResetAiResponse resets all changes to the "ai_response" field.
  31721. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31722. m.ai_response = nil
  31723. m.addai_response = nil
  31724. }
  31725. // SetSopRun sets the "sop_run" field.
  31726. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31727. m.sop_run = &u
  31728. m.addsop_run = nil
  31729. }
  31730. // SopRun returns the value of the "sop_run" field in the mutation.
  31731. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31732. v := m.sop_run
  31733. if v == nil {
  31734. return
  31735. }
  31736. return *v, true
  31737. }
  31738. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31739. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31741. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31742. if !m.op.Is(OpUpdateOne) {
  31743. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31744. }
  31745. if m.id == nil || m.oldValue == nil {
  31746. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31747. }
  31748. oldValue, err := m.oldValue(ctx)
  31749. if err != nil {
  31750. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31751. }
  31752. return oldValue.SopRun, nil
  31753. }
  31754. // AddSopRun adds u to the "sop_run" field.
  31755. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31756. if m.addsop_run != nil {
  31757. *m.addsop_run += u
  31758. } else {
  31759. m.addsop_run = &u
  31760. }
  31761. }
  31762. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31763. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31764. v := m.addsop_run
  31765. if v == nil {
  31766. return
  31767. }
  31768. return *v, true
  31769. }
  31770. // ResetSopRun resets all changes to the "sop_run" field.
  31771. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31772. m.sop_run = nil
  31773. m.addsop_run = nil
  31774. }
  31775. // SetTotalFriend sets the "total_friend" field.
  31776. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31777. m.total_friend = &u
  31778. m.addtotal_friend = nil
  31779. }
  31780. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31781. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31782. v := m.total_friend
  31783. if v == nil {
  31784. return
  31785. }
  31786. return *v, true
  31787. }
  31788. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31789. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31790. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31791. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31792. if !m.op.Is(OpUpdateOne) {
  31793. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31794. }
  31795. if m.id == nil || m.oldValue == nil {
  31796. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31797. }
  31798. oldValue, err := m.oldValue(ctx)
  31799. if err != nil {
  31800. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31801. }
  31802. return oldValue.TotalFriend, nil
  31803. }
  31804. // AddTotalFriend adds u to the "total_friend" field.
  31805. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31806. if m.addtotal_friend != nil {
  31807. *m.addtotal_friend += u
  31808. } else {
  31809. m.addtotal_friend = &u
  31810. }
  31811. }
  31812. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31813. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31814. v := m.addtotal_friend
  31815. if v == nil {
  31816. return
  31817. }
  31818. return *v, true
  31819. }
  31820. // ResetTotalFriend resets all changes to the "total_friend" field.
  31821. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31822. m.total_friend = nil
  31823. m.addtotal_friend = nil
  31824. }
  31825. // SetTotalGroup sets the "total_group" field.
  31826. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31827. m.total_group = &u
  31828. m.addtotal_group = nil
  31829. }
  31830. // TotalGroup returns the value of the "total_group" field in the mutation.
  31831. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31832. v := m.total_group
  31833. if v == nil {
  31834. return
  31835. }
  31836. return *v, true
  31837. }
  31838. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31839. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31841. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31842. if !m.op.Is(OpUpdateOne) {
  31843. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31844. }
  31845. if m.id == nil || m.oldValue == nil {
  31846. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31847. }
  31848. oldValue, err := m.oldValue(ctx)
  31849. if err != nil {
  31850. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31851. }
  31852. return oldValue.TotalGroup, nil
  31853. }
  31854. // AddTotalGroup adds u to the "total_group" field.
  31855. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31856. if m.addtotal_group != nil {
  31857. *m.addtotal_group += u
  31858. } else {
  31859. m.addtotal_group = &u
  31860. }
  31861. }
  31862. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31863. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31864. v := m.addtotal_group
  31865. if v == nil {
  31866. return
  31867. }
  31868. return *v, true
  31869. }
  31870. // ResetTotalGroup resets all changes to the "total_group" field.
  31871. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31872. m.total_group = nil
  31873. m.addtotal_group = nil
  31874. }
  31875. // SetAccountBalance sets the "account_balance" field.
  31876. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31877. m.account_balance = &u
  31878. m.addaccount_balance = nil
  31879. }
  31880. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31881. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31882. v := m.account_balance
  31883. if v == nil {
  31884. return
  31885. }
  31886. return *v, true
  31887. }
  31888. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31889. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31891. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31892. if !m.op.Is(OpUpdateOne) {
  31893. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31894. }
  31895. if m.id == nil || m.oldValue == nil {
  31896. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31897. }
  31898. oldValue, err := m.oldValue(ctx)
  31899. if err != nil {
  31900. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31901. }
  31902. return oldValue.AccountBalance, nil
  31903. }
  31904. // AddAccountBalance adds u to the "account_balance" field.
  31905. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31906. if m.addaccount_balance != nil {
  31907. *m.addaccount_balance += u
  31908. } else {
  31909. m.addaccount_balance = &u
  31910. }
  31911. }
  31912. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31913. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31914. v := m.addaccount_balance
  31915. if v == nil {
  31916. return
  31917. }
  31918. return *v, true
  31919. }
  31920. // ResetAccountBalance resets all changes to the "account_balance" field.
  31921. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31922. m.account_balance = nil
  31923. m.addaccount_balance = nil
  31924. }
  31925. // SetConsumeToken sets the "consume_token" field.
  31926. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31927. m.consume_token = &u
  31928. m.addconsume_token = nil
  31929. }
  31930. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31931. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31932. v := m.consume_token
  31933. if v == nil {
  31934. return
  31935. }
  31936. return *v, true
  31937. }
  31938. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31939. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31940. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31941. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31942. if !m.op.Is(OpUpdateOne) {
  31943. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31944. }
  31945. if m.id == nil || m.oldValue == nil {
  31946. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31947. }
  31948. oldValue, err := m.oldValue(ctx)
  31949. if err != nil {
  31950. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31951. }
  31952. return oldValue.ConsumeToken, nil
  31953. }
  31954. // AddConsumeToken adds u to the "consume_token" field.
  31955. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31956. if m.addconsume_token != nil {
  31957. *m.addconsume_token += u
  31958. } else {
  31959. m.addconsume_token = &u
  31960. }
  31961. }
  31962. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31963. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31964. v := m.addconsume_token
  31965. if v == nil {
  31966. return
  31967. }
  31968. return *v, true
  31969. }
  31970. // ResetConsumeToken resets all changes to the "consume_token" field.
  31971. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31972. m.consume_token = nil
  31973. m.addconsume_token = nil
  31974. }
  31975. // SetActiveUser sets the "active_user" field.
  31976. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31977. m.active_user = &u
  31978. m.addactive_user = nil
  31979. }
  31980. // ActiveUser returns the value of the "active_user" field in the mutation.
  31981. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31982. v := m.active_user
  31983. if v == nil {
  31984. return
  31985. }
  31986. return *v, true
  31987. }
  31988. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31989. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31990. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31991. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31992. if !m.op.Is(OpUpdateOne) {
  31993. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31994. }
  31995. if m.id == nil || m.oldValue == nil {
  31996. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31997. }
  31998. oldValue, err := m.oldValue(ctx)
  31999. if err != nil {
  32000. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  32001. }
  32002. return oldValue.ActiveUser, nil
  32003. }
  32004. // AddActiveUser adds u to the "active_user" field.
  32005. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  32006. if m.addactive_user != nil {
  32007. *m.addactive_user += u
  32008. } else {
  32009. m.addactive_user = &u
  32010. }
  32011. }
  32012. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  32013. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  32014. v := m.addactive_user
  32015. if v == nil {
  32016. return
  32017. }
  32018. return *v, true
  32019. }
  32020. // ResetActiveUser resets all changes to the "active_user" field.
  32021. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  32022. m.active_user = nil
  32023. m.addactive_user = nil
  32024. }
  32025. // SetNewUser sets the "new_user" field.
  32026. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  32027. m.new_user = &i
  32028. m.addnew_user = nil
  32029. }
  32030. // NewUser returns the value of the "new_user" field in the mutation.
  32031. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  32032. v := m.new_user
  32033. if v == nil {
  32034. return
  32035. }
  32036. return *v, true
  32037. }
  32038. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  32039. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32040. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32041. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  32042. if !m.op.Is(OpUpdateOne) {
  32043. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  32044. }
  32045. if m.id == nil || m.oldValue == nil {
  32046. return v, errors.New("OldNewUser requires an ID field in the mutation")
  32047. }
  32048. oldValue, err := m.oldValue(ctx)
  32049. if err != nil {
  32050. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  32051. }
  32052. return oldValue.NewUser, nil
  32053. }
  32054. // AddNewUser adds i to the "new_user" field.
  32055. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  32056. if m.addnew_user != nil {
  32057. *m.addnew_user += i
  32058. } else {
  32059. m.addnew_user = &i
  32060. }
  32061. }
  32062. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  32063. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  32064. v := m.addnew_user
  32065. if v == nil {
  32066. return
  32067. }
  32068. return *v, true
  32069. }
  32070. // ResetNewUser resets all changes to the "new_user" field.
  32071. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  32072. m.new_user = nil
  32073. m.addnew_user = nil
  32074. }
  32075. // SetLabelDist sets the "label_dist" field.
  32076. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32077. m.label_dist = &ctd
  32078. m.appendlabel_dist = nil
  32079. }
  32080. // LabelDist returns the value of the "label_dist" field in the mutation.
  32081. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32082. v := m.label_dist
  32083. if v == nil {
  32084. return
  32085. }
  32086. return *v, true
  32087. }
  32088. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32089. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32091. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32092. if !m.op.Is(OpUpdateOne) {
  32093. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32094. }
  32095. if m.id == nil || m.oldValue == nil {
  32096. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32097. }
  32098. oldValue, err := m.oldValue(ctx)
  32099. if err != nil {
  32100. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32101. }
  32102. return oldValue.LabelDist, nil
  32103. }
  32104. // AppendLabelDist adds ctd to the "label_dist" field.
  32105. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32106. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32107. }
  32108. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32109. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32110. if len(m.appendlabel_dist) == 0 {
  32111. return nil, false
  32112. }
  32113. return m.appendlabel_dist, true
  32114. }
  32115. // ResetLabelDist resets all changes to the "label_dist" field.
  32116. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32117. m.label_dist = nil
  32118. m.appendlabel_dist = nil
  32119. }
  32120. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32121. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32122. m.predicates = append(m.predicates, ps...)
  32123. }
  32124. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32125. // users can use type-assertion to append predicates that do not depend on any generated package.
  32126. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32127. p := make([]predicate.UsageStatisticMonth, len(ps))
  32128. for i := range ps {
  32129. p[i] = ps[i]
  32130. }
  32131. m.Where(p...)
  32132. }
  32133. // Op returns the operation name.
  32134. func (m *UsageStatisticMonthMutation) Op() Op {
  32135. return m.op
  32136. }
  32137. // SetOp allows setting the mutation operation.
  32138. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32139. m.op = op
  32140. }
  32141. // Type returns the node type of this mutation (UsageStatisticMonth).
  32142. func (m *UsageStatisticMonthMutation) Type() string {
  32143. return m.typ
  32144. }
  32145. // Fields returns all fields that were changed during this mutation. Note that in
  32146. // order to get all numeric fields that were incremented/decremented, call
  32147. // AddedFields().
  32148. func (m *UsageStatisticMonthMutation) Fields() []string {
  32149. fields := make([]string, 0, 17)
  32150. if m.created_at != nil {
  32151. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32152. }
  32153. if m.updated_at != nil {
  32154. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32155. }
  32156. if m.status != nil {
  32157. fields = append(fields, usagestatisticmonth.FieldStatus)
  32158. }
  32159. if m.deleted_at != nil {
  32160. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32161. }
  32162. if m.addtime != nil {
  32163. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32164. }
  32165. if m._type != nil {
  32166. fields = append(fields, usagestatisticmonth.FieldType)
  32167. }
  32168. if m.bot_id != nil {
  32169. fields = append(fields, usagestatisticmonth.FieldBotID)
  32170. }
  32171. if m.organization_id != nil {
  32172. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32173. }
  32174. if m.ai_response != nil {
  32175. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32176. }
  32177. if m.sop_run != nil {
  32178. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32179. }
  32180. if m.total_friend != nil {
  32181. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32182. }
  32183. if m.total_group != nil {
  32184. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32185. }
  32186. if m.account_balance != nil {
  32187. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32188. }
  32189. if m.consume_token != nil {
  32190. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32191. }
  32192. if m.active_user != nil {
  32193. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32194. }
  32195. if m.new_user != nil {
  32196. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32197. }
  32198. if m.label_dist != nil {
  32199. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32200. }
  32201. return fields
  32202. }
  32203. // Field returns the value of a field with the given name. The second boolean
  32204. // return value indicates that this field was not set, or was not defined in the
  32205. // schema.
  32206. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32207. switch name {
  32208. case usagestatisticmonth.FieldCreatedAt:
  32209. return m.CreatedAt()
  32210. case usagestatisticmonth.FieldUpdatedAt:
  32211. return m.UpdatedAt()
  32212. case usagestatisticmonth.FieldStatus:
  32213. return m.Status()
  32214. case usagestatisticmonth.FieldDeletedAt:
  32215. return m.DeletedAt()
  32216. case usagestatisticmonth.FieldAddtime:
  32217. return m.Addtime()
  32218. case usagestatisticmonth.FieldType:
  32219. return m.GetType()
  32220. case usagestatisticmonth.FieldBotID:
  32221. return m.BotID()
  32222. case usagestatisticmonth.FieldOrganizationID:
  32223. return m.OrganizationID()
  32224. case usagestatisticmonth.FieldAiResponse:
  32225. return m.AiResponse()
  32226. case usagestatisticmonth.FieldSopRun:
  32227. return m.SopRun()
  32228. case usagestatisticmonth.FieldTotalFriend:
  32229. return m.TotalFriend()
  32230. case usagestatisticmonth.FieldTotalGroup:
  32231. return m.TotalGroup()
  32232. case usagestatisticmonth.FieldAccountBalance:
  32233. return m.AccountBalance()
  32234. case usagestatisticmonth.FieldConsumeToken:
  32235. return m.ConsumeToken()
  32236. case usagestatisticmonth.FieldActiveUser:
  32237. return m.ActiveUser()
  32238. case usagestatisticmonth.FieldNewUser:
  32239. return m.NewUser()
  32240. case usagestatisticmonth.FieldLabelDist:
  32241. return m.LabelDist()
  32242. }
  32243. return nil, false
  32244. }
  32245. // OldField returns the old value of the field from the database. An error is
  32246. // returned if the mutation operation is not UpdateOne, or the query to the
  32247. // database failed.
  32248. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32249. switch name {
  32250. case usagestatisticmonth.FieldCreatedAt:
  32251. return m.OldCreatedAt(ctx)
  32252. case usagestatisticmonth.FieldUpdatedAt:
  32253. return m.OldUpdatedAt(ctx)
  32254. case usagestatisticmonth.FieldStatus:
  32255. return m.OldStatus(ctx)
  32256. case usagestatisticmonth.FieldDeletedAt:
  32257. return m.OldDeletedAt(ctx)
  32258. case usagestatisticmonth.FieldAddtime:
  32259. return m.OldAddtime(ctx)
  32260. case usagestatisticmonth.FieldType:
  32261. return m.OldType(ctx)
  32262. case usagestatisticmonth.FieldBotID:
  32263. return m.OldBotID(ctx)
  32264. case usagestatisticmonth.FieldOrganizationID:
  32265. return m.OldOrganizationID(ctx)
  32266. case usagestatisticmonth.FieldAiResponse:
  32267. return m.OldAiResponse(ctx)
  32268. case usagestatisticmonth.FieldSopRun:
  32269. return m.OldSopRun(ctx)
  32270. case usagestatisticmonth.FieldTotalFriend:
  32271. return m.OldTotalFriend(ctx)
  32272. case usagestatisticmonth.FieldTotalGroup:
  32273. return m.OldTotalGroup(ctx)
  32274. case usagestatisticmonth.FieldAccountBalance:
  32275. return m.OldAccountBalance(ctx)
  32276. case usagestatisticmonth.FieldConsumeToken:
  32277. return m.OldConsumeToken(ctx)
  32278. case usagestatisticmonth.FieldActiveUser:
  32279. return m.OldActiveUser(ctx)
  32280. case usagestatisticmonth.FieldNewUser:
  32281. return m.OldNewUser(ctx)
  32282. case usagestatisticmonth.FieldLabelDist:
  32283. return m.OldLabelDist(ctx)
  32284. }
  32285. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32286. }
  32287. // SetField sets the value of a field with the given name. It returns an error if
  32288. // the field is not defined in the schema, or if the type mismatched the field
  32289. // type.
  32290. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32291. switch name {
  32292. case usagestatisticmonth.FieldCreatedAt:
  32293. v, ok := value.(time.Time)
  32294. if !ok {
  32295. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32296. }
  32297. m.SetCreatedAt(v)
  32298. return nil
  32299. case usagestatisticmonth.FieldUpdatedAt:
  32300. v, ok := value.(time.Time)
  32301. if !ok {
  32302. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32303. }
  32304. m.SetUpdatedAt(v)
  32305. return nil
  32306. case usagestatisticmonth.FieldStatus:
  32307. v, ok := value.(uint8)
  32308. if !ok {
  32309. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32310. }
  32311. m.SetStatus(v)
  32312. return nil
  32313. case usagestatisticmonth.FieldDeletedAt:
  32314. v, ok := value.(time.Time)
  32315. if !ok {
  32316. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32317. }
  32318. m.SetDeletedAt(v)
  32319. return nil
  32320. case usagestatisticmonth.FieldAddtime:
  32321. v, ok := value.(uint64)
  32322. if !ok {
  32323. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32324. }
  32325. m.SetAddtime(v)
  32326. return nil
  32327. case usagestatisticmonth.FieldType:
  32328. v, ok := value.(int)
  32329. if !ok {
  32330. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32331. }
  32332. m.SetType(v)
  32333. return nil
  32334. case usagestatisticmonth.FieldBotID:
  32335. v, ok := value.(string)
  32336. if !ok {
  32337. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32338. }
  32339. m.SetBotID(v)
  32340. return nil
  32341. case usagestatisticmonth.FieldOrganizationID:
  32342. v, ok := value.(uint64)
  32343. if !ok {
  32344. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32345. }
  32346. m.SetOrganizationID(v)
  32347. return nil
  32348. case usagestatisticmonth.FieldAiResponse:
  32349. v, ok := value.(uint64)
  32350. if !ok {
  32351. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32352. }
  32353. m.SetAiResponse(v)
  32354. return nil
  32355. case usagestatisticmonth.FieldSopRun:
  32356. v, ok := value.(uint64)
  32357. if !ok {
  32358. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32359. }
  32360. m.SetSopRun(v)
  32361. return nil
  32362. case usagestatisticmonth.FieldTotalFriend:
  32363. v, ok := value.(uint64)
  32364. if !ok {
  32365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32366. }
  32367. m.SetTotalFriend(v)
  32368. return nil
  32369. case usagestatisticmonth.FieldTotalGroup:
  32370. v, ok := value.(uint64)
  32371. if !ok {
  32372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32373. }
  32374. m.SetTotalGroup(v)
  32375. return nil
  32376. case usagestatisticmonth.FieldAccountBalance:
  32377. v, ok := value.(uint64)
  32378. if !ok {
  32379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32380. }
  32381. m.SetAccountBalance(v)
  32382. return nil
  32383. case usagestatisticmonth.FieldConsumeToken:
  32384. v, ok := value.(uint64)
  32385. if !ok {
  32386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32387. }
  32388. m.SetConsumeToken(v)
  32389. return nil
  32390. case usagestatisticmonth.FieldActiveUser:
  32391. v, ok := value.(uint64)
  32392. if !ok {
  32393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32394. }
  32395. m.SetActiveUser(v)
  32396. return nil
  32397. case usagestatisticmonth.FieldNewUser:
  32398. v, ok := value.(int64)
  32399. if !ok {
  32400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32401. }
  32402. m.SetNewUser(v)
  32403. return nil
  32404. case usagestatisticmonth.FieldLabelDist:
  32405. v, ok := value.([]custom_types.LabelDist)
  32406. if !ok {
  32407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32408. }
  32409. m.SetLabelDist(v)
  32410. return nil
  32411. }
  32412. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32413. }
  32414. // AddedFields returns all numeric fields that were incremented/decremented during
  32415. // this mutation.
  32416. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32417. var fields []string
  32418. if m.addstatus != nil {
  32419. fields = append(fields, usagestatisticmonth.FieldStatus)
  32420. }
  32421. if m.addaddtime != nil {
  32422. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32423. }
  32424. if m.add_type != nil {
  32425. fields = append(fields, usagestatisticmonth.FieldType)
  32426. }
  32427. if m.addorganization_id != nil {
  32428. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32429. }
  32430. if m.addai_response != nil {
  32431. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32432. }
  32433. if m.addsop_run != nil {
  32434. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32435. }
  32436. if m.addtotal_friend != nil {
  32437. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32438. }
  32439. if m.addtotal_group != nil {
  32440. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32441. }
  32442. if m.addaccount_balance != nil {
  32443. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32444. }
  32445. if m.addconsume_token != nil {
  32446. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32447. }
  32448. if m.addactive_user != nil {
  32449. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32450. }
  32451. if m.addnew_user != nil {
  32452. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32453. }
  32454. return fields
  32455. }
  32456. // AddedField returns the numeric value that was incremented/decremented on a field
  32457. // with the given name. The second boolean return value indicates that this field
  32458. // was not set, or was not defined in the schema.
  32459. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32460. switch name {
  32461. case usagestatisticmonth.FieldStatus:
  32462. return m.AddedStatus()
  32463. case usagestatisticmonth.FieldAddtime:
  32464. return m.AddedAddtime()
  32465. case usagestatisticmonth.FieldType:
  32466. return m.AddedType()
  32467. case usagestatisticmonth.FieldOrganizationID:
  32468. return m.AddedOrganizationID()
  32469. case usagestatisticmonth.FieldAiResponse:
  32470. return m.AddedAiResponse()
  32471. case usagestatisticmonth.FieldSopRun:
  32472. return m.AddedSopRun()
  32473. case usagestatisticmonth.FieldTotalFriend:
  32474. return m.AddedTotalFriend()
  32475. case usagestatisticmonth.FieldTotalGroup:
  32476. return m.AddedTotalGroup()
  32477. case usagestatisticmonth.FieldAccountBalance:
  32478. return m.AddedAccountBalance()
  32479. case usagestatisticmonth.FieldConsumeToken:
  32480. return m.AddedConsumeToken()
  32481. case usagestatisticmonth.FieldActiveUser:
  32482. return m.AddedActiveUser()
  32483. case usagestatisticmonth.FieldNewUser:
  32484. return m.AddedNewUser()
  32485. }
  32486. return nil, false
  32487. }
  32488. // AddField adds the value to the field with the given name. It returns an error if
  32489. // the field is not defined in the schema, or if the type mismatched the field
  32490. // type.
  32491. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32492. switch name {
  32493. case usagestatisticmonth.FieldStatus:
  32494. v, ok := value.(int8)
  32495. if !ok {
  32496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32497. }
  32498. m.AddStatus(v)
  32499. return nil
  32500. case usagestatisticmonth.FieldAddtime:
  32501. v, ok := value.(int64)
  32502. if !ok {
  32503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32504. }
  32505. m.AddAddtime(v)
  32506. return nil
  32507. case usagestatisticmonth.FieldType:
  32508. v, ok := value.(int)
  32509. if !ok {
  32510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32511. }
  32512. m.AddType(v)
  32513. return nil
  32514. case usagestatisticmonth.FieldOrganizationID:
  32515. v, ok := value.(int64)
  32516. if !ok {
  32517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32518. }
  32519. m.AddOrganizationID(v)
  32520. return nil
  32521. case usagestatisticmonth.FieldAiResponse:
  32522. v, ok := value.(int64)
  32523. if !ok {
  32524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32525. }
  32526. m.AddAiResponse(v)
  32527. return nil
  32528. case usagestatisticmonth.FieldSopRun:
  32529. v, ok := value.(int64)
  32530. if !ok {
  32531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32532. }
  32533. m.AddSopRun(v)
  32534. return nil
  32535. case usagestatisticmonth.FieldTotalFriend:
  32536. v, ok := value.(int64)
  32537. if !ok {
  32538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32539. }
  32540. m.AddTotalFriend(v)
  32541. return nil
  32542. case usagestatisticmonth.FieldTotalGroup:
  32543. v, ok := value.(int64)
  32544. if !ok {
  32545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32546. }
  32547. m.AddTotalGroup(v)
  32548. return nil
  32549. case usagestatisticmonth.FieldAccountBalance:
  32550. v, ok := value.(int64)
  32551. if !ok {
  32552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32553. }
  32554. m.AddAccountBalance(v)
  32555. return nil
  32556. case usagestatisticmonth.FieldConsumeToken:
  32557. v, ok := value.(int64)
  32558. if !ok {
  32559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32560. }
  32561. m.AddConsumeToken(v)
  32562. return nil
  32563. case usagestatisticmonth.FieldActiveUser:
  32564. v, ok := value.(int64)
  32565. if !ok {
  32566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32567. }
  32568. m.AddActiveUser(v)
  32569. return nil
  32570. case usagestatisticmonth.FieldNewUser:
  32571. v, ok := value.(int64)
  32572. if !ok {
  32573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32574. }
  32575. m.AddNewUser(v)
  32576. return nil
  32577. }
  32578. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32579. }
  32580. // ClearedFields returns all nullable fields that were cleared during this
  32581. // mutation.
  32582. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32583. var fields []string
  32584. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32585. fields = append(fields, usagestatisticmonth.FieldStatus)
  32586. }
  32587. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32588. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32589. }
  32590. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32591. fields = append(fields, usagestatisticmonth.FieldBotID)
  32592. }
  32593. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32594. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32595. }
  32596. return fields
  32597. }
  32598. // FieldCleared returns a boolean indicating if a field with the given name was
  32599. // cleared in this mutation.
  32600. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32601. _, ok := m.clearedFields[name]
  32602. return ok
  32603. }
  32604. // ClearField clears the value of the field with the given name. It returns an
  32605. // error if the field is not defined in the schema.
  32606. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32607. switch name {
  32608. case usagestatisticmonth.FieldStatus:
  32609. m.ClearStatus()
  32610. return nil
  32611. case usagestatisticmonth.FieldDeletedAt:
  32612. m.ClearDeletedAt()
  32613. return nil
  32614. case usagestatisticmonth.FieldBotID:
  32615. m.ClearBotID()
  32616. return nil
  32617. case usagestatisticmonth.FieldOrganizationID:
  32618. m.ClearOrganizationID()
  32619. return nil
  32620. }
  32621. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32622. }
  32623. // ResetField resets all changes in the mutation for the field with the given name.
  32624. // It returns an error if the field is not defined in the schema.
  32625. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32626. switch name {
  32627. case usagestatisticmonth.FieldCreatedAt:
  32628. m.ResetCreatedAt()
  32629. return nil
  32630. case usagestatisticmonth.FieldUpdatedAt:
  32631. m.ResetUpdatedAt()
  32632. return nil
  32633. case usagestatisticmonth.FieldStatus:
  32634. m.ResetStatus()
  32635. return nil
  32636. case usagestatisticmonth.FieldDeletedAt:
  32637. m.ResetDeletedAt()
  32638. return nil
  32639. case usagestatisticmonth.FieldAddtime:
  32640. m.ResetAddtime()
  32641. return nil
  32642. case usagestatisticmonth.FieldType:
  32643. m.ResetType()
  32644. return nil
  32645. case usagestatisticmonth.FieldBotID:
  32646. m.ResetBotID()
  32647. return nil
  32648. case usagestatisticmonth.FieldOrganizationID:
  32649. m.ResetOrganizationID()
  32650. return nil
  32651. case usagestatisticmonth.FieldAiResponse:
  32652. m.ResetAiResponse()
  32653. return nil
  32654. case usagestatisticmonth.FieldSopRun:
  32655. m.ResetSopRun()
  32656. return nil
  32657. case usagestatisticmonth.FieldTotalFriend:
  32658. m.ResetTotalFriend()
  32659. return nil
  32660. case usagestatisticmonth.FieldTotalGroup:
  32661. m.ResetTotalGroup()
  32662. return nil
  32663. case usagestatisticmonth.FieldAccountBalance:
  32664. m.ResetAccountBalance()
  32665. return nil
  32666. case usagestatisticmonth.FieldConsumeToken:
  32667. m.ResetConsumeToken()
  32668. return nil
  32669. case usagestatisticmonth.FieldActiveUser:
  32670. m.ResetActiveUser()
  32671. return nil
  32672. case usagestatisticmonth.FieldNewUser:
  32673. m.ResetNewUser()
  32674. return nil
  32675. case usagestatisticmonth.FieldLabelDist:
  32676. m.ResetLabelDist()
  32677. return nil
  32678. }
  32679. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32680. }
  32681. // AddedEdges returns all edge names that were set/added in this mutation.
  32682. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32683. edges := make([]string, 0, 0)
  32684. return edges
  32685. }
  32686. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32687. // name in this mutation.
  32688. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32689. return nil
  32690. }
  32691. // RemovedEdges returns all edge names that were removed in this mutation.
  32692. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32693. edges := make([]string, 0, 0)
  32694. return edges
  32695. }
  32696. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32697. // the given name in this mutation.
  32698. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32699. return nil
  32700. }
  32701. // ClearedEdges returns all edge names that were cleared in this mutation.
  32702. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32703. edges := make([]string, 0, 0)
  32704. return edges
  32705. }
  32706. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32707. // was cleared in this mutation.
  32708. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32709. return false
  32710. }
  32711. // ClearEdge clears the value of the edge with the given name. It returns an error
  32712. // if that edge is not defined in the schema.
  32713. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32714. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32715. }
  32716. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32717. // It returns an error if the edge is not defined in the schema.
  32718. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32719. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32720. }
  32721. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32722. type UsageTotalMutation struct {
  32723. config
  32724. op Op
  32725. typ string
  32726. id *uint64
  32727. created_at *time.Time
  32728. updated_at *time.Time
  32729. status *uint8
  32730. addstatus *int8
  32731. _type *int
  32732. add_type *int
  32733. bot_id *string
  32734. total_tokens *uint64
  32735. addtotal_tokens *int64
  32736. start_index *uint64
  32737. addstart_index *int64
  32738. end_index *uint64
  32739. addend_index *int64
  32740. organization_id *uint64
  32741. addorganization_id *int64
  32742. clearedFields map[string]struct{}
  32743. done bool
  32744. oldValue func(context.Context) (*UsageTotal, error)
  32745. predicates []predicate.UsageTotal
  32746. }
  32747. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32748. // usagetotalOption allows management of the mutation configuration using functional options.
  32749. type usagetotalOption func(*UsageTotalMutation)
  32750. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32751. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32752. m := &UsageTotalMutation{
  32753. config: c,
  32754. op: op,
  32755. typ: TypeUsageTotal,
  32756. clearedFields: make(map[string]struct{}),
  32757. }
  32758. for _, opt := range opts {
  32759. opt(m)
  32760. }
  32761. return m
  32762. }
  32763. // withUsageTotalID sets the ID field of the mutation.
  32764. func withUsageTotalID(id uint64) usagetotalOption {
  32765. return func(m *UsageTotalMutation) {
  32766. var (
  32767. err error
  32768. once sync.Once
  32769. value *UsageTotal
  32770. )
  32771. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32772. once.Do(func() {
  32773. if m.done {
  32774. err = errors.New("querying old values post mutation is not allowed")
  32775. } else {
  32776. value, err = m.Client().UsageTotal.Get(ctx, id)
  32777. }
  32778. })
  32779. return value, err
  32780. }
  32781. m.id = &id
  32782. }
  32783. }
  32784. // withUsageTotal sets the old UsageTotal of the mutation.
  32785. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32786. return func(m *UsageTotalMutation) {
  32787. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32788. return node, nil
  32789. }
  32790. m.id = &node.ID
  32791. }
  32792. }
  32793. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32794. // executed in a transaction (ent.Tx), a transactional client is returned.
  32795. func (m UsageTotalMutation) Client() *Client {
  32796. client := &Client{config: m.config}
  32797. client.init()
  32798. return client
  32799. }
  32800. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32801. // it returns an error otherwise.
  32802. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32803. if _, ok := m.driver.(*txDriver); !ok {
  32804. return nil, errors.New("ent: mutation is not running in a transaction")
  32805. }
  32806. tx := &Tx{config: m.config}
  32807. tx.init()
  32808. return tx, nil
  32809. }
  32810. // SetID sets the value of the id field. Note that this
  32811. // operation is only accepted on creation of UsageTotal entities.
  32812. func (m *UsageTotalMutation) SetID(id uint64) {
  32813. m.id = &id
  32814. }
  32815. // ID returns the ID value in the mutation. Note that the ID is only available
  32816. // if it was provided to the builder or after it was returned from the database.
  32817. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32818. if m.id == nil {
  32819. return
  32820. }
  32821. return *m.id, true
  32822. }
  32823. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32824. // That means, if the mutation is applied within a transaction with an isolation level such
  32825. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32826. // or updated by the mutation.
  32827. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32828. switch {
  32829. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32830. id, exists := m.ID()
  32831. if exists {
  32832. return []uint64{id}, nil
  32833. }
  32834. fallthrough
  32835. case m.op.Is(OpUpdate | OpDelete):
  32836. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32837. default:
  32838. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32839. }
  32840. }
  32841. // SetCreatedAt sets the "created_at" field.
  32842. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32843. m.created_at = &t
  32844. }
  32845. // CreatedAt returns the value of the "created_at" field in the mutation.
  32846. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32847. v := m.created_at
  32848. if v == nil {
  32849. return
  32850. }
  32851. return *v, true
  32852. }
  32853. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32854. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32855. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32856. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32857. if !m.op.Is(OpUpdateOne) {
  32858. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32859. }
  32860. if m.id == nil || m.oldValue == nil {
  32861. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32862. }
  32863. oldValue, err := m.oldValue(ctx)
  32864. if err != nil {
  32865. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32866. }
  32867. return oldValue.CreatedAt, nil
  32868. }
  32869. // ResetCreatedAt resets all changes to the "created_at" field.
  32870. func (m *UsageTotalMutation) ResetCreatedAt() {
  32871. m.created_at = nil
  32872. }
  32873. // SetUpdatedAt sets the "updated_at" field.
  32874. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32875. m.updated_at = &t
  32876. }
  32877. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32878. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32879. v := m.updated_at
  32880. if v == nil {
  32881. return
  32882. }
  32883. return *v, true
  32884. }
  32885. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32886. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32887. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32888. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32889. if !m.op.Is(OpUpdateOne) {
  32890. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32891. }
  32892. if m.id == nil || m.oldValue == nil {
  32893. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32894. }
  32895. oldValue, err := m.oldValue(ctx)
  32896. if err != nil {
  32897. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32898. }
  32899. return oldValue.UpdatedAt, nil
  32900. }
  32901. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32902. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32903. m.updated_at = nil
  32904. }
  32905. // SetStatus sets the "status" field.
  32906. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32907. m.status = &u
  32908. m.addstatus = nil
  32909. }
  32910. // Status returns the value of the "status" field in the mutation.
  32911. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32912. v := m.status
  32913. if v == nil {
  32914. return
  32915. }
  32916. return *v, true
  32917. }
  32918. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32919. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32920. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32921. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32922. if !m.op.Is(OpUpdateOne) {
  32923. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32924. }
  32925. if m.id == nil || m.oldValue == nil {
  32926. return v, errors.New("OldStatus requires an ID field in the mutation")
  32927. }
  32928. oldValue, err := m.oldValue(ctx)
  32929. if err != nil {
  32930. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32931. }
  32932. return oldValue.Status, nil
  32933. }
  32934. // AddStatus adds u to the "status" field.
  32935. func (m *UsageTotalMutation) AddStatus(u int8) {
  32936. if m.addstatus != nil {
  32937. *m.addstatus += u
  32938. } else {
  32939. m.addstatus = &u
  32940. }
  32941. }
  32942. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32943. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32944. v := m.addstatus
  32945. if v == nil {
  32946. return
  32947. }
  32948. return *v, true
  32949. }
  32950. // ClearStatus clears the value of the "status" field.
  32951. func (m *UsageTotalMutation) ClearStatus() {
  32952. m.status = nil
  32953. m.addstatus = nil
  32954. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32955. }
  32956. // StatusCleared returns if the "status" field was cleared in this mutation.
  32957. func (m *UsageTotalMutation) StatusCleared() bool {
  32958. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32959. return ok
  32960. }
  32961. // ResetStatus resets all changes to the "status" field.
  32962. func (m *UsageTotalMutation) ResetStatus() {
  32963. m.status = nil
  32964. m.addstatus = nil
  32965. delete(m.clearedFields, usagetotal.FieldStatus)
  32966. }
  32967. // SetType sets the "type" field.
  32968. func (m *UsageTotalMutation) SetType(i int) {
  32969. m._type = &i
  32970. m.add_type = nil
  32971. }
  32972. // GetType returns the value of the "type" field in the mutation.
  32973. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32974. v := m._type
  32975. if v == nil {
  32976. return
  32977. }
  32978. return *v, true
  32979. }
  32980. // OldType returns the old "type" field's value of the UsageTotal entity.
  32981. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32982. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32983. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32984. if !m.op.Is(OpUpdateOne) {
  32985. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32986. }
  32987. if m.id == nil || m.oldValue == nil {
  32988. return v, errors.New("OldType requires an ID field in the mutation")
  32989. }
  32990. oldValue, err := m.oldValue(ctx)
  32991. if err != nil {
  32992. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32993. }
  32994. return oldValue.Type, nil
  32995. }
  32996. // AddType adds i to the "type" field.
  32997. func (m *UsageTotalMutation) AddType(i int) {
  32998. if m.add_type != nil {
  32999. *m.add_type += i
  33000. } else {
  33001. m.add_type = &i
  33002. }
  33003. }
  33004. // AddedType returns the value that was added to the "type" field in this mutation.
  33005. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  33006. v := m.add_type
  33007. if v == nil {
  33008. return
  33009. }
  33010. return *v, true
  33011. }
  33012. // ClearType clears the value of the "type" field.
  33013. func (m *UsageTotalMutation) ClearType() {
  33014. m._type = nil
  33015. m.add_type = nil
  33016. m.clearedFields[usagetotal.FieldType] = struct{}{}
  33017. }
  33018. // TypeCleared returns if the "type" field was cleared in this mutation.
  33019. func (m *UsageTotalMutation) TypeCleared() bool {
  33020. _, ok := m.clearedFields[usagetotal.FieldType]
  33021. return ok
  33022. }
  33023. // ResetType resets all changes to the "type" field.
  33024. func (m *UsageTotalMutation) ResetType() {
  33025. m._type = nil
  33026. m.add_type = nil
  33027. delete(m.clearedFields, usagetotal.FieldType)
  33028. }
  33029. // SetBotID sets the "bot_id" field.
  33030. func (m *UsageTotalMutation) SetBotID(s string) {
  33031. m.bot_id = &s
  33032. }
  33033. // BotID returns the value of the "bot_id" field in the mutation.
  33034. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  33035. v := m.bot_id
  33036. if v == nil {
  33037. return
  33038. }
  33039. return *v, true
  33040. }
  33041. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  33042. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33043. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33044. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  33045. if !m.op.Is(OpUpdateOne) {
  33046. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  33047. }
  33048. if m.id == nil || m.oldValue == nil {
  33049. return v, errors.New("OldBotID requires an ID field in the mutation")
  33050. }
  33051. oldValue, err := m.oldValue(ctx)
  33052. if err != nil {
  33053. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  33054. }
  33055. return oldValue.BotID, nil
  33056. }
  33057. // ResetBotID resets all changes to the "bot_id" field.
  33058. func (m *UsageTotalMutation) ResetBotID() {
  33059. m.bot_id = nil
  33060. }
  33061. // SetTotalTokens sets the "total_tokens" field.
  33062. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  33063. m.total_tokens = &u
  33064. m.addtotal_tokens = nil
  33065. }
  33066. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  33067. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  33068. v := m.total_tokens
  33069. if v == nil {
  33070. return
  33071. }
  33072. return *v, true
  33073. }
  33074. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  33075. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33076. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33077. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33078. if !m.op.Is(OpUpdateOne) {
  33079. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33080. }
  33081. if m.id == nil || m.oldValue == nil {
  33082. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33083. }
  33084. oldValue, err := m.oldValue(ctx)
  33085. if err != nil {
  33086. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33087. }
  33088. return oldValue.TotalTokens, nil
  33089. }
  33090. // AddTotalTokens adds u to the "total_tokens" field.
  33091. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33092. if m.addtotal_tokens != nil {
  33093. *m.addtotal_tokens += u
  33094. } else {
  33095. m.addtotal_tokens = &u
  33096. }
  33097. }
  33098. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33099. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33100. v := m.addtotal_tokens
  33101. if v == nil {
  33102. return
  33103. }
  33104. return *v, true
  33105. }
  33106. // ClearTotalTokens clears the value of the "total_tokens" field.
  33107. func (m *UsageTotalMutation) ClearTotalTokens() {
  33108. m.total_tokens = nil
  33109. m.addtotal_tokens = nil
  33110. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33111. }
  33112. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33113. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33114. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33115. return ok
  33116. }
  33117. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33118. func (m *UsageTotalMutation) ResetTotalTokens() {
  33119. m.total_tokens = nil
  33120. m.addtotal_tokens = nil
  33121. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33122. }
  33123. // SetStartIndex sets the "start_index" field.
  33124. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33125. m.start_index = &u
  33126. m.addstart_index = nil
  33127. }
  33128. // StartIndex returns the value of the "start_index" field in the mutation.
  33129. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33130. v := m.start_index
  33131. if v == nil {
  33132. return
  33133. }
  33134. return *v, true
  33135. }
  33136. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33137. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33139. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33140. if !m.op.Is(OpUpdateOne) {
  33141. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33142. }
  33143. if m.id == nil || m.oldValue == nil {
  33144. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33145. }
  33146. oldValue, err := m.oldValue(ctx)
  33147. if err != nil {
  33148. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33149. }
  33150. return oldValue.StartIndex, nil
  33151. }
  33152. // AddStartIndex adds u to the "start_index" field.
  33153. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33154. if m.addstart_index != nil {
  33155. *m.addstart_index += u
  33156. } else {
  33157. m.addstart_index = &u
  33158. }
  33159. }
  33160. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33161. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33162. v := m.addstart_index
  33163. if v == nil {
  33164. return
  33165. }
  33166. return *v, true
  33167. }
  33168. // ClearStartIndex clears the value of the "start_index" field.
  33169. func (m *UsageTotalMutation) ClearStartIndex() {
  33170. m.start_index = nil
  33171. m.addstart_index = nil
  33172. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33173. }
  33174. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33175. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33176. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33177. return ok
  33178. }
  33179. // ResetStartIndex resets all changes to the "start_index" field.
  33180. func (m *UsageTotalMutation) ResetStartIndex() {
  33181. m.start_index = nil
  33182. m.addstart_index = nil
  33183. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33184. }
  33185. // SetEndIndex sets the "end_index" field.
  33186. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33187. m.end_index = &u
  33188. m.addend_index = nil
  33189. }
  33190. // EndIndex returns the value of the "end_index" field in the mutation.
  33191. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33192. v := m.end_index
  33193. if v == nil {
  33194. return
  33195. }
  33196. return *v, true
  33197. }
  33198. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33199. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33201. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33202. if !m.op.Is(OpUpdateOne) {
  33203. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33204. }
  33205. if m.id == nil || m.oldValue == nil {
  33206. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33207. }
  33208. oldValue, err := m.oldValue(ctx)
  33209. if err != nil {
  33210. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33211. }
  33212. return oldValue.EndIndex, nil
  33213. }
  33214. // AddEndIndex adds u to the "end_index" field.
  33215. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33216. if m.addend_index != nil {
  33217. *m.addend_index += u
  33218. } else {
  33219. m.addend_index = &u
  33220. }
  33221. }
  33222. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33223. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33224. v := m.addend_index
  33225. if v == nil {
  33226. return
  33227. }
  33228. return *v, true
  33229. }
  33230. // ClearEndIndex clears the value of the "end_index" field.
  33231. func (m *UsageTotalMutation) ClearEndIndex() {
  33232. m.end_index = nil
  33233. m.addend_index = nil
  33234. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33235. }
  33236. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33237. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33238. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33239. return ok
  33240. }
  33241. // ResetEndIndex resets all changes to the "end_index" field.
  33242. func (m *UsageTotalMutation) ResetEndIndex() {
  33243. m.end_index = nil
  33244. m.addend_index = nil
  33245. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33246. }
  33247. // SetOrganizationID sets the "organization_id" field.
  33248. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33249. m.organization_id = &u
  33250. m.addorganization_id = nil
  33251. }
  33252. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33253. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33254. v := m.organization_id
  33255. if v == nil {
  33256. return
  33257. }
  33258. return *v, true
  33259. }
  33260. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33261. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33263. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33264. if !m.op.Is(OpUpdateOne) {
  33265. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33266. }
  33267. if m.id == nil || m.oldValue == nil {
  33268. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33269. }
  33270. oldValue, err := m.oldValue(ctx)
  33271. if err != nil {
  33272. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33273. }
  33274. return oldValue.OrganizationID, nil
  33275. }
  33276. // AddOrganizationID adds u to the "organization_id" field.
  33277. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33278. if m.addorganization_id != nil {
  33279. *m.addorganization_id += u
  33280. } else {
  33281. m.addorganization_id = &u
  33282. }
  33283. }
  33284. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33285. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33286. v := m.addorganization_id
  33287. if v == nil {
  33288. return
  33289. }
  33290. return *v, true
  33291. }
  33292. // ClearOrganizationID clears the value of the "organization_id" field.
  33293. func (m *UsageTotalMutation) ClearOrganizationID() {
  33294. m.organization_id = nil
  33295. m.addorganization_id = nil
  33296. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33297. }
  33298. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33299. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33300. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33301. return ok
  33302. }
  33303. // ResetOrganizationID resets all changes to the "organization_id" field.
  33304. func (m *UsageTotalMutation) ResetOrganizationID() {
  33305. m.organization_id = nil
  33306. m.addorganization_id = nil
  33307. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33308. }
  33309. // Where appends a list predicates to the UsageTotalMutation builder.
  33310. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33311. m.predicates = append(m.predicates, ps...)
  33312. }
  33313. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33314. // users can use type-assertion to append predicates that do not depend on any generated package.
  33315. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33316. p := make([]predicate.UsageTotal, len(ps))
  33317. for i := range ps {
  33318. p[i] = ps[i]
  33319. }
  33320. m.Where(p...)
  33321. }
  33322. // Op returns the operation name.
  33323. func (m *UsageTotalMutation) Op() Op {
  33324. return m.op
  33325. }
  33326. // SetOp allows setting the mutation operation.
  33327. func (m *UsageTotalMutation) SetOp(op Op) {
  33328. m.op = op
  33329. }
  33330. // Type returns the node type of this mutation (UsageTotal).
  33331. func (m *UsageTotalMutation) Type() string {
  33332. return m.typ
  33333. }
  33334. // Fields returns all fields that were changed during this mutation. Note that in
  33335. // order to get all numeric fields that were incremented/decremented, call
  33336. // AddedFields().
  33337. func (m *UsageTotalMutation) Fields() []string {
  33338. fields := make([]string, 0, 9)
  33339. if m.created_at != nil {
  33340. fields = append(fields, usagetotal.FieldCreatedAt)
  33341. }
  33342. if m.updated_at != nil {
  33343. fields = append(fields, usagetotal.FieldUpdatedAt)
  33344. }
  33345. if m.status != nil {
  33346. fields = append(fields, usagetotal.FieldStatus)
  33347. }
  33348. if m._type != nil {
  33349. fields = append(fields, usagetotal.FieldType)
  33350. }
  33351. if m.bot_id != nil {
  33352. fields = append(fields, usagetotal.FieldBotID)
  33353. }
  33354. if m.total_tokens != nil {
  33355. fields = append(fields, usagetotal.FieldTotalTokens)
  33356. }
  33357. if m.start_index != nil {
  33358. fields = append(fields, usagetotal.FieldStartIndex)
  33359. }
  33360. if m.end_index != nil {
  33361. fields = append(fields, usagetotal.FieldEndIndex)
  33362. }
  33363. if m.organization_id != nil {
  33364. fields = append(fields, usagetotal.FieldOrganizationID)
  33365. }
  33366. return fields
  33367. }
  33368. // Field returns the value of a field with the given name. The second boolean
  33369. // return value indicates that this field was not set, or was not defined in the
  33370. // schema.
  33371. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33372. switch name {
  33373. case usagetotal.FieldCreatedAt:
  33374. return m.CreatedAt()
  33375. case usagetotal.FieldUpdatedAt:
  33376. return m.UpdatedAt()
  33377. case usagetotal.FieldStatus:
  33378. return m.Status()
  33379. case usagetotal.FieldType:
  33380. return m.GetType()
  33381. case usagetotal.FieldBotID:
  33382. return m.BotID()
  33383. case usagetotal.FieldTotalTokens:
  33384. return m.TotalTokens()
  33385. case usagetotal.FieldStartIndex:
  33386. return m.StartIndex()
  33387. case usagetotal.FieldEndIndex:
  33388. return m.EndIndex()
  33389. case usagetotal.FieldOrganizationID:
  33390. return m.OrganizationID()
  33391. }
  33392. return nil, false
  33393. }
  33394. // OldField returns the old value of the field from the database. An error is
  33395. // returned if the mutation operation is not UpdateOne, or the query to the
  33396. // database failed.
  33397. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33398. switch name {
  33399. case usagetotal.FieldCreatedAt:
  33400. return m.OldCreatedAt(ctx)
  33401. case usagetotal.FieldUpdatedAt:
  33402. return m.OldUpdatedAt(ctx)
  33403. case usagetotal.FieldStatus:
  33404. return m.OldStatus(ctx)
  33405. case usagetotal.FieldType:
  33406. return m.OldType(ctx)
  33407. case usagetotal.FieldBotID:
  33408. return m.OldBotID(ctx)
  33409. case usagetotal.FieldTotalTokens:
  33410. return m.OldTotalTokens(ctx)
  33411. case usagetotal.FieldStartIndex:
  33412. return m.OldStartIndex(ctx)
  33413. case usagetotal.FieldEndIndex:
  33414. return m.OldEndIndex(ctx)
  33415. case usagetotal.FieldOrganizationID:
  33416. return m.OldOrganizationID(ctx)
  33417. }
  33418. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33419. }
  33420. // SetField sets the value of a field with the given name. It returns an error if
  33421. // the field is not defined in the schema, or if the type mismatched the field
  33422. // type.
  33423. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33424. switch name {
  33425. case usagetotal.FieldCreatedAt:
  33426. v, ok := value.(time.Time)
  33427. if !ok {
  33428. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33429. }
  33430. m.SetCreatedAt(v)
  33431. return nil
  33432. case usagetotal.FieldUpdatedAt:
  33433. v, ok := value.(time.Time)
  33434. if !ok {
  33435. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33436. }
  33437. m.SetUpdatedAt(v)
  33438. return nil
  33439. case usagetotal.FieldStatus:
  33440. v, ok := value.(uint8)
  33441. if !ok {
  33442. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33443. }
  33444. m.SetStatus(v)
  33445. return nil
  33446. case usagetotal.FieldType:
  33447. v, ok := value.(int)
  33448. if !ok {
  33449. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33450. }
  33451. m.SetType(v)
  33452. return nil
  33453. case usagetotal.FieldBotID:
  33454. v, ok := value.(string)
  33455. if !ok {
  33456. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33457. }
  33458. m.SetBotID(v)
  33459. return nil
  33460. case usagetotal.FieldTotalTokens:
  33461. v, ok := value.(uint64)
  33462. if !ok {
  33463. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33464. }
  33465. m.SetTotalTokens(v)
  33466. return nil
  33467. case usagetotal.FieldStartIndex:
  33468. v, ok := value.(uint64)
  33469. if !ok {
  33470. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33471. }
  33472. m.SetStartIndex(v)
  33473. return nil
  33474. case usagetotal.FieldEndIndex:
  33475. v, ok := value.(uint64)
  33476. if !ok {
  33477. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33478. }
  33479. m.SetEndIndex(v)
  33480. return nil
  33481. case usagetotal.FieldOrganizationID:
  33482. v, ok := value.(uint64)
  33483. if !ok {
  33484. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33485. }
  33486. m.SetOrganizationID(v)
  33487. return nil
  33488. }
  33489. return fmt.Errorf("unknown UsageTotal field %s", name)
  33490. }
  33491. // AddedFields returns all numeric fields that were incremented/decremented during
  33492. // this mutation.
  33493. func (m *UsageTotalMutation) AddedFields() []string {
  33494. var fields []string
  33495. if m.addstatus != nil {
  33496. fields = append(fields, usagetotal.FieldStatus)
  33497. }
  33498. if m.add_type != nil {
  33499. fields = append(fields, usagetotal.FieldType)
  33500. }
  33501. if m.addtotal_tokens != nil {
  33502. fields = append(fields, usagetotal.FieldTotalTokens)
  33503. }
  33504. if m.addstart_index != nil {
  33505. fields = append(fields, usagetotal.FieldStartIndex)
  33506. }
  33507. if m.addend_index != nil {
  33508. fields = append(fields, usagetotal.FieldEndIndex)
  33509. }
  33510. if m.addorganization_id != nil {
  33511. fields = append(fields, usagetotal.FieldOrganizationID)
  33512. }
  33513. return fields
  33514. }
  33515. // AddedField returns the numeric value that was incremented/decremented on a field
  33516. // with the given name. The second boolean return value indicates that this field
  33517. // was not set, or was not defined in the schema.
  33518. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33519. switch name {
  33520. case usagetotal.FieldStatus:
  33521. return m.AddedStatus()
  33522. case usagetotal.FieldType:
  33523. return m.AddedType()
  33524. case usagetotal.FieldTotalTokens:
  33525. return m.AddedTotalTokens()
  33526. case usagetotal.FieldStartIndex:
  33527. return m.AddedStartIndex()
  33528. case usagetotal.FieldEndIndex:
  33529. return m.AddedEndIndex()
  33530. case usagetotal.FieldOrganizationID:
  33531. return m.AddedOrganizationID()
  33532. }
  33533. return nil, false
  33534. }
  33535. // AddField adds the value to the field with the given name. It returns an error if
  33536. // the field is not defined in the schema, or if the type mismatched the field
  33537. // type.
  33538. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33539. switch name {
  33540. case usagetotal.FieldStatus:
  33541. v, ok := value.(int8)
  33542. if !ok {
  33543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33544. }
  33545. m.AddStatus(v)
  33546. return nil
  33547. case usagetotal.FieldType:
  33548. v, ok := value.(int)
  33549. if !ok {
  33550. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33551. }
  33552. m.AddType(v)
  33553. return nil
  33554. case usagetotal.FieldTotalTokens:
  33555. v, ok := value.(int64)
  33556. if !ok {
  33557. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33558. }
  33559. m.AddTotalTokens(v)
  33560. return nil
  33561. case usagetotal.FieldStartIndex:
  33562. v, ok := value.(int64)
  33563. if !ok {
  33564. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33565. }
  33566. m.AddStartIndex(v)
  33567. return nil
  33568. case usagetotal.FieldEndIndex:
  33569. v, ok := value.(int64)
  33570. if !ok {
  33571. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33572. }
  33573. m.AddEndIndex(v)
  33574. return nil
  33575. case usagetotal.FieldOrganizationID:
  33576. v, ok := value.(int64)
  33577. if !ok {
  33578. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33579. }
  33580. m.AddOrganizationID(v)
  33581. return nil
  33582. }
  33583. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33584. }
  33585. // ClearedFields returns all nullable fields that were cleared during this
  33586. // mutation.
  33587. func (m *UsageTotalMutation) ClearedFields() []string {
  33588. var fields []string
  33589. if m.FieldCleared(usagetotal.FieldStatus) {
  33590. fields = append(fields, usagetotal.FieldStatus)
  33591. }
  33592. if m.FieldCleared(usagetotal.FieldType) {
  33593. fields = append(fields, usagetotal.FieldType)
  33594. }
  33595. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33596. fields = append(fields, usagetotal.FieldTotalTokens)
  33597. }
  33598. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33599. fields = append(fields, usagetotal.FieldStartIndex)
  33600. }
  33601. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33602. fields = append(fields, usagetotal.FieldEndIndex)
  33603. }
  33604. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33605. fields = append(fields, usagetotal.FieldOrganizationID)
  33606. }
  33607. return fields
  33608. }
  33609. // FieldCleared returns a boolean indicating if a field with the given name was
  33610. // cleared in this mutation.
  33611. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33612. _, ok := m.clearedFields[name]
  33613. return ok
  33614. }
  33615. // ClearField clears the value of the field with the given name. It returns an
  33616. // error if the field is not defined in the schema.
  33617. func (m *UsageTotalMutation) ClearField(name string) error {
  33618. switch name {
  33619. case usagetotal.FieldStatus:
  33620. m.ClearStatus()
  33621. return nil
  33622. case usagetotal.FieldType:
  33623. m.ClearType()
  33624. return nil
  33625. case usagetotal.FieldTotalTokens:
  33626. m.ClearTotalTokens()
  33627. return nil
  33628. case usagetotal.FieldStartIndex:
  33629. m.ClearStartIndex()
  33630. return nil
  33631. case usagetotal.FieldEndIndex:
  33632. m.ClearEndIndex()
  33633. return nil
  33634. case usagetotal.FieldOrganizationID:
  33635. m.ClearOrganizationID()
  33636. return nil
  33637. }
  33638. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33639. }
  33640. // ResetField resets all changes in the mutation for the field with the given name.
  33641. // It returns an error if the field is not defined in the schema.
  33642. func (m *UsageTotalMutation) ResetField(name string) error {
  33643. switch name {
  33644. case usagetotal.FieldCreatedAt:
  33645. m.ResetCreatedAt()
  33646. return nil
  33647. case usagetotal.FieldUpdatedAt:
  33648. m.ResetUpdatedAt()
  33649. return nil
  33650. case usagetotal.FieldStatus:
  33651. m.ResetStatus()
  33652. return nil
  33653. case usagetotal.FieldType:
  33654. m.ResetType()
  33655. return nil
  33656. case usagetotal.FieldBotID:
  33657. m.ResetBotID()
  33658. return nil
  33659. case usagetotal.FieldTotalTokens:
  33660. m.ResetTotalTokens()
  33661. return nil
  33662. case usagetotal.FieldStartIndex:
  33663. m.ResetStartIndex()
  33664. return nil
  33665. case usagetotal.FieldEndIndex:
  33666. m.ResetEndIndex()
  33667. return nil
  33668. case usagetotal.FieldOrganizationID:
  33669. m.ResetOrganizationID()
  33670. return nil
  33671. }
  33672. return fmt.Errorf("unknown UsageTotal field %s", name)
  33673. }
  33674. // AddedEdges returns all edge names that were set/added in this mutation.
  33675. func (m *UsageTotalMutation) AddedEdges() []string {
  33676. edges := make([]string, 0, 0)
  33677. return edges
  33678. }
  33679. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33680. // name in this mutation.
  33681. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33682. return nil
  33683. }
  33684. // RemovedEdges returns all edge names that were removed in this mutation.
  33685. func (m *UsageTotalMutation) RemovedEdges() []string {
  33686. edges := make([]string, 0, 0)
  33687. return edges
  33688. }
  33689. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33690. // the given name in this mutation.
  33691. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33692. return nil
  33693. }
  33694. // ClearedEdges returns all edge names that were cleared in this mutation.
  33695. func (m *UsageTotalMutation) ClearedEdges() []string {
  33696. edges := make([]string, 0, 0)
  33697. return edges
  33698. }
  33699. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33700. // was cleared in this mutation.
  33701. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33702. return false
  33703. }
  33704. // ClearEdge clears the value of the edge with the given name. It returns an error
  33705. // if that edge is not defined in the schema.
  33706. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33707. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33708. }
  33709. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33710. // It returns an error if the edge is not defined in the schema.
  33711. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33712. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33713. }
  33714. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33715. type WhatsappMutation struct {
  33716. config
  33717. op Op
  33718. typ string
  33719. id *uint64
  33720. created_at *time.Time
  33721. updated_at *time.Time
  33722. status *uint8
  33723. addstatus *int8
  33724. deleted_at *time.Time
  33725. ak *string
  33726. sk *string
  33727. callback *string
  33728. account *string
  33729. nickname *string
  33730. phone *string
  33731. organization_id *uint64
  33732. addorganization_id *int64
  33733. api_base *string
  33734. api_key *string
  33735. allow_list *[]string
  33736. appendallow_list []string
  33737. group_allow_list *[]string
  33738. appendgroup_allow_list []string
  33739. block_list *[]string
  33740. appendblock_list []string
  33741. group_block_list *[]string
  33742. appendgroup_block_list []string
  33743. clearedFields map[string]struct{}
  33744. agent *uint64
  33745. clearedagent bool
  33746. done bool
  33747. oldValue func(context.Context) (*Whatsapp, error)
  33748. predicates []predicate.Whatsapp
  33749. }
  33750. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33751. // whatsappOption allows management of the mutation configuration using functional options.
  33752. type whatsappOption func(*WhatsappMutation)
  33753. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33754. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33755. m := &WhatsappMutation{
  33756. config: c,
  33757. op: op,
  33758. typ: TypeWhatsapp,
  33759. clearedFields: make(map[string]struct{}),
  33760. }
  33761. for _, opt := range opts {
  33762. opt(m)
  33763. }
  33764. return m
  33765. }
  33766. // withWhatsappID sets the ID field of the mutation.
  33767. func withWhatsappID(id uint64) whatsappOption {
  33768. return func(m *WhatsappMutation) {
  33769. var (
  33770. err error
  33771. once sync.Once
  33772. value *Whatsapp
  33773. )
  33774. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33775. once.Do(func() {
  33776. if m.done {
  33777. err = errors.New("querying old values post mutation is not allowed")
  33778. } else {
  33779. value, err = m.Client().Whatsapp.Get(ctx, id)
  33780. }
  33781. })
  33782. return value, err
  33783. }
  33784. m.id = &id
  33785. }
  33786. }
  33787. // withWhatsapp sets the old Whatsapp of the mutation.
  33788. func withWhatsapp(node *Whatsapp) whatsappOption {
  33789. return func(m *WhatsappMutation) {
  33790. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33791. return node, nil
  33792. }
  33793. m.id = &node.ID
  33794. }
  33795. }
  33796. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33797. // executed in a transaction (ent.Tx), a transactional client is returned.
  33798. func (m WhatsappMutation) Client() *Client {
  33799. client := &Client{config: m.config}
  33800. client.init()
  33801. return client
  33802. }
  33803. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33804. // it returns an error otherwise.
  33805. func (m WhatsappMutation) Tx() (*Tx, error) {
  33806. if _, ok := m.driver.(*txDriver); !ok {
  33807. return nil, errors.New("ent: mutation is not running in a transaction")
  33808. }
  33809. tx := &Tx{config: m.config}
  33810. tx.init()
  33811. return tx, nil
  33812. }
  33813. // SetID sets the value of the id field. Note that this
  33814. // operation is only accepted on creation of Whatsapp entities.
  33815. func (m *WhatsappMutation) SetID(id uint64) {
  33816. m.id = &id
  33817. }
  33818. // ID returns the ID value in the mutation. Note that the ID is only available
  33819. // if it was provided to the builder or after it was returned from the database.
  33820. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33821. if m.id == nil {
  33822. return
  33823. }
  33824. return *m.id, true
  33825. }
  33826. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33827. // That means, if the mutation is applied within a transaction with an isolation level such
  33828. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33829. // or updated by the mutation.
  33830. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33831. switch {
  33832. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33833. id, exists := m.ID()
  33834. if exists {
  33835. return []uint64{id}, nil
  33836. }
  33837. fallthrough
  33838. case m.op.Is(OpUpdate | OpDelete):
  33839. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33840. default:
  33841. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33842. }
  33843. }
  33844. // SetCreatedAt sets the "created_at" field.
  33845. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33846. m.created_at = &t
  33847. }
  33848. // CreatedAt returns the value of the "created_at" field in the mutation.
  33849. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33850. v := m.created_at
  33851. if v == nil {
  33852. return
  33853. }
  33854. return *v, true
  33855. }
  33856. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33857. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33859. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33860. if !m.op.Is(OpUpdateOne) {
  33861. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33862. }
  33863. if m.id == nil || m.oldValue == nil {
  33864. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33865. }
  33866. oldValue, err := m.oldValue(ctx)
  33867. if err != nil {
  33868. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33869. }
  33870. return oldValue.CreatedAt, nil
  33871. }
  33872. // ResetCreatedAt resets all changes to the "created_at" field.
  33873. func (m *WhatsappMutation) ResetCreatedAt() {
  33874. m.created_at = nil
  33875. }
  33876. // SetUpdatedAt sets the "updated_at" field.
  33877. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33878. m.updated_at = &t
  33879. }
  33880. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33881. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33882. v := m.updated_at
  33883. if v == nil {
  33884. return
  33885. }
  33886. return *v, true
  33887. }
  33888. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33889. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33890. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33891. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33892. if !m.op.Is(OpUpdateOne) {
  33893. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33894. }
  33895. if m.id == nil || m.oldValue == nil {
  33896. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33897. }
  33898. oldValue, err := m.oldValue(ctx)
  33899. if err != nil {
  33900. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33901. }
  33902. return oldValue.UpdatedAt, nil
  33903. }
  33904. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33905. func (m *WhatsappMutation) ResetUpdatedAt() {
  33906. m.updated_at = nil
  33907. }
  33908. // SetStatus sets the "status" field.
  33909. func (m *WhatsappMutation) SetStatus(u uint8) {
  33910. m.status = &u
  33911. m.addstatus = nil
  33912. }
  33913. // Status returns the value of the "status" field in the mutation.
  33914. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33915. v := m.status
  33916. if v == nil {
  33917. return
  33918. }
  33919. return *v, true
  33920. }
  33921. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33922. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33923. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33924. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33925. if !m.op.Is(OpUpdateOne) {
  33926. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33927. }
  33928. if m.id == nil || m.oldValue == nil {
  33929. return v, errors.New("OldStatus requires an ID field in the mutation")
  33930. }
  33931. oldValue, err := m.oldValue(ctx)
  33932. if err != nil {
  33933. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33934. }
  33935. return oldValue.Status, nil
  33936. }
  33937. // AddStatus adds u to the "status" field.
  33938. func (m *WhatsappMutation) AddStatus(u int8) {
  33939. if m.addstatus != nil {
  33940. *m.addstatus += u
  33941. } else {
  33942. m.addstatus = &u
  33943. }
  33944. }
  33945. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33946. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33947. v := m.addstatus
  33948. if v == nil {
  33949. return
  33950. }
  33951. return *v, true
  33952. }
  33953. // ClearStatus clears the value of the "status" field.
  33954. func (m *WhatsappMutation) ClearStatus() {
  33955. m.status = nil
  33956. m.addstatus = nil
  33957. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33958. }
  33959. // StatusCleared returns if the "status" field was cleared in this mutation.
  33960. func (m *WhatsappMutation) StatusCleared() bool {
  33961. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33962. return ok
  33963. }
  33964. // ResetStatus resets all changes to the "status" field.
  33965. func (m *WhatsappMutation) ResetStatus() {
  33966. m.status = nil
  33967. m.addstatus = nil
  33968. delete(m.clearedFields, whatsapp.FieldStatus)
  33969. }
  33970. // SetDeletedAt sets the "deleted_at" field.
  33971. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33972. m.deleted_at = &t
  33973. }
  33974. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33975. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33976. v := m.deleted_at
  33977. if v == nil {
  33978. return
  33979. }
  33980. return *v, true
  33981. }
  33982. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  33983. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33985. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33986. if !m.op.Is(OpUpdateOne) {
  33987. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33988. }
  33989. if m.id == nil || m.oldValue == nil {
  33990. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33991. }
  33992. oldValue, err := m.oldValue(ctx)
  33993. if err != nil {
  33994. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33995. }
  33996. return oldValue.DeletedAt, nil
  33997. }
  33998. // ClearDeletedAt clears the value of the "deleted_at" field.
  33999. func (m *WhatsappMutation) ClearDeletedAt() {
  34000. m.deleted_at = nil
  34001. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  34002. }
  34003. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  34004. func (m *WhatsappMutation) DeletedAtCleared() bool {
  34005. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  34006. return ok
  34007. }
  34008. // ResetDeletedAt resets all changes to the "deleted_at" field.
  34009. func (m *WhatsappMutation) ResetDeletedAt() {
  34010. m.deleted_at = nil
  34011. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  34012. }
  34013. // SetAk sets the "ak" field.
  34014. func (m *WhatsappMutation) SetAk(s string) {
  34015. m.ak = &s
  34016. }
  34017. // Ak returns the value of the "ak" field in the mutation.
  34018. func (m *WhatsappMutation) Ak() (r string, exists bool) {
  34019. v := m.ak
  34020. if v == nil {
  34021. return
  34022. }
  34023. return *v, true
  34024. }
  34025. // OldAk returns the old "ak" field's value of the Whatsapp entity.
  34026. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34027. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34028. func (m *WhatsappMutation) OldAk(ctx context.Context) (v string, err error) {
  34029. if !m.op.Is(OpUpdateOne) {
  34030. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  34031. }
  34032. if m.id == nil || m.oldValue == nil {
  34033. return v, errors.New("OldAk requires an ID field in the mutation")
  34034. }
  34035. oldValue, err := m.oldValue(ctx)
  34036. if err != nil {
  34037. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  34038. }
  34039. return oldValue.Ak, nil
  34040. }
  34041. // ClearAk clears the value of the "ak" field.
  34042. func (m *WhatsappMutation) ClearAk() {
  34043. m.ak = nil
  34044. m.clearedFields[whatsapp.FieldAk] = struct{}{}
  34045. }
  34046. // AkCleared returns if the "ak" field was cleared in this mutation.
  34047. func (m *WhatsappMutation) AkCleared() bool {
  34048. _, ok := m.clearedFields[whatsapp.FieldAk]
  34049. return ok
  34050. }
  34051. // ResetAk resets all changes to the "ak" field.
  34052. func (m *WhatsappMutation) ResetAk() {
  34053. m.ak = nil
  34054. delete(m.clearedFields, whatsapp.FieldAk)
  34055. }
  34056. // SetSk sets the "sk" field.
  34057. func (m *WhatsappMutation) SetSk(s string) {
  34058. m.sk = &s
  34059. }
  34060. // Sk returns the value of the "sk" field in the mutation.
  34061. func (m *WhatsappMutation) Sk() (r string, exists bool) {
  34062. v := m.sk
  34063. if v == nil {
  34064. return
  34065. }
  34066. return *v, true
  34067. }
  34068. // OldSk returns the old "sk" field's value of the Whatsapp entity.
  34069. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34070. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34071. func (m *WhatsappMutation) OldSk(ctx context.Context) (v string, err error) {
  34072. if !m.op.Is(OpUpdateOne) {
  34073. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  34074. }
  34075. if m.id == nil || m.oldValue == nil {
  34076. return v, errors.New("OldSk requires an ID field in the mutation")
  34077. }
  34078. oldValue, err := m.oldValue(ctx)
  34079. if err != nil {
  34080. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  34081. }
  34082. return oldValue.Sk, nil
  34083. }
  34084. // ResetSk resets all changes to the "sk" field.
  34085. func (m *WhatsappMutation) ResetSk() {
  34086. m.sk = nil
  34087. }
  34088. // SetCallback sets the "callback" field.
  34089. func (m *WhatsappMutation) SetCallback(s string) {
  34090. m.callback = &s
  34091. }
  34092. // Callback returns the value of the "callback" field in the mutation.
  34093. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34094. v := m.callback
  34095. if v == nil {
  34096. return
  34097. }
  34098. return *v, true
  34099. }
  34100. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34101. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34102. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34103. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34104. if !m.op.Is(OpUpdateOne) {
  34105. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34106. }
  34107. if m.id == nil || m.oldValue == nil {
  34108. return v, errors.New("OldCallback requires an ID field in the mutation")
  34109. }
  34110. oldValue, err := m.oldValue(ctx)
  34111. if err != nil {
  34112. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34113. }
  34114. return oldValue.Callback, nil
  34115. }
  34116. // ClearCallback clears the value of the "callback" field.
  34117. func (m *WhatsappMutation) ClearCallback() {
  34118. m.callback = nil
  34119. m.clearedFields[whatsapp.FieldCallback] = struct{}{}
  34120. }
  34121. // CallbackCleared returns if the "callback" field was cleared in this mutation.
  34122. func (m *WhatsappMutation) CallbackCleared() bool {
  34123. _, ok := m.clearedFields[whatsapp.FieldCallback]
  34124. return ok
  34125. }
  34126. // ResetCallback resets all changes to the "callback" field.
  34127. func (m *WhatsappMutation) ResetCallback() {
  34128. m.callback = nil
  34129. delete(m.clearedFields, whatsapp.FieldCallback)
  34130. }
  34131. // SetAccount sets the "account" field.
  34132. func (m *WhatsappMutation) SetAccount(s string) {
  34133. m.account = &s
  34134. }
  34135. // Account returns the value of the "account" field in the mutation.
  34136. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34137. v := m.account
  34138. if v == nil {
  34139. return
  34140. }
  34141. return *v, true
  34142. }
  34143. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34144. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34145. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34146. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34147. if !m.op.Is(OpUpdateOne) {
  34148. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34149. }
  34150. if m.id == nil || m.oldValue == nil {
  34151. return v, errors.New("OldAccount requires an ID field in the mutation")
  34152. }
  34153. oldValue, err := m.oldValue(ctx)
  34154. if err != nil {
  34155. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34156. }
  34157. return oldValue.Account, nil
  34158. }
  34159. // ClearAccount clears the value of the "account" field.
  34160. func (m *WhatsappMutation) ClearAccount() {
  34161. m.account = nil
  34162. m.clearedFields[whatsapp.FieldAccount] = struct{}{}
  34163. }
  34164. // AccountCleared returns if the "account" field was cleared in this mutation.
  34165. func (m *WhatsappMutation) AccountCleared() bool {
  34166. _, ok := m.clearedFields[whatsapp.FieldAccount]
  34167. return ok
  34168. }
  34169. // ResetAccount resets all changes to the "account" field.
  34170. func (m *WhatsappMutation) ResetAccount() {
  34171. m.account = nil
  34172. delete(m.clearedFields, whatsapp.FieldAccount)
  34173. }
  34174. // SetNickname sets the "nickname" field.
  34175. func (m *WhatsappMutation) SetNickname(s string) {
  34176. m.nickname = &s
  34177. }
  34178. // Nickname returns the value of the "nickname" field in the mutation.
  34179. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34180. v := m.nickname
  34181. if v == nil {
  34182. return
  34183. }
  34184. return *v, true
  34185. }
  34186. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34187. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34189. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34190. if !m.op.Is(OpUpdateOne) {
  34191. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34192. }
  34193. if m.id == nil || m.oldValue == nil {
  34194. return v, errors.New("OldNickname requires an ID field in the mutation")
  34195. }
  34196. oldValue, err := m.oldValue(ctx)
  34197. if err != nil {
  34198. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34199. }
  34200. return oldValue.Nickname, nil
  34201. }
  34202. // ResetNickname resets all changes to the "nickname" field.
  34203. func (m *WhatsappMutation) ResetNickname() {
  34204. m.nickname = nil
  34205. }
  34206. // SetPhone sets the "phone" field.
  34207. func (m *WhatsappMutation) SetPhone(s string) {
  34208. m.phone = &s
  34209. }
  34210. // Phone returns the value of the "phone" field in the mutation.
  34211. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34212. v := m.phone
  34213. if v == nil {
  34214. return
  34215. }
  34216. return *v, true
  34217. }
  34218. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34219. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34220. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34221. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34222. if !m.op.Is(OpUpdateOne) {
  34223. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34224. }
  34225. if m.id == nil || m.oldValue == nil {
  34226. return v, errors.New("OldPhone requires an ID field in the mutation")
  34227. }
  34228. oldValue, err := m.oldValue(ctx)
  34229. if err != nil {
  34230. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34231. }
  34232. return oldValue.Phone, nil
  34233. }
  34234. // ResetPhone resets all changes to the "phone" field.
  34235. func (m *WhatsappMutation) ResetPhone() {
  34236. m.phone = nil
  34237. }
  34238. // SetOrganizationID sets the "organization_id" field.
  34239. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34240. m.organization_id = &u
  34241. m.addorganization_id = nil
  34242. }
  34243. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34244. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34245. v := m.organization_id
  34246. if v == nil {
  34247. return
  34248. }
  34249. return *v, true
  34250. }
  34251. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34252. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34253. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34254. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34255. if !m.op.Is(OpUpdateOne) {
  34256. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34257. }
  34258. if m.id == nil || m.oldValue == nil {
  34259. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34260. }
  34261. oldValue, err := m.oldValue(ctx)
  34262. if err != nil {
  34263. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34264. }
  34265. return oldValue.OrganizationID, nil
  34266. }
  34267. // AddOrganizationID adds u to the "organization_id" field.
  34268. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34269. if m.addorganization_id != nil {
  34270. *m.addorganization_id += u
  34271. } else {
  34272. m.addorganization_id = &u
  34273. }
  34274. }
  34275. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34276. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34277. v := m.addorganization_id
  34278. if v == nil {
  34279. return
  34280. }
  34281. return *v, true
  34282. }
  34283. // ClearOrganizationID clears the value of the "organization_id" field.
  34284. func (m *WhatsappMutation) ClearOrganizationID() {
  34285. m.organization_id = nil
  34286. m.addorganization_id = nil
  34287. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34288. }
  34289. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34290. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34291. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34292. return ok
  34293. }
  34294. // ResetOrganizationID resets all changes to the "organization_id" field.
  34295. func (m *WhatsappMutation) ResetOrganizationID() {
  34296. m.organization_id = nil
  34297. m.addorganization_id = nil
  34298. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34299. }
  34300. // SetAgentID sets the "agent_id" field.
  34301. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34302. m.agent = &u
  34303. }
  34304. // AgentID returns the value of the "agent_id" field in the mutation.
  34305. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34306. v := m.agent
  34307. if v == nil {
  34308. return
  34309. }
  34310. return *v, true
  34311. }
  34312. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34313. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34314. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34315. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34316. if !m.op.Is(OpUpdateOne) {
  34317. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34318. }
  34319. if m.id == nil || m.oldValue == nil {
  34320. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34321. }
  34322. oldValue, err := m.oldValue(ctx)
  34323. if err != nil {
  34324. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34325. }
  34326. return oldValue.AgentID, nil
  34327. }
  34328. // ResetAgentID resets all changes to the "agent_id" field.
  34329. func (m *WhatsappMutation) ResetAgentID() {
  34330. m.agent = nil
  34331. }
  34332. // SetAPIBase sets the "api_base" field.
  34333. func (m *WhatsappMutation) SetAPIBase(s string) {
  34334. m.api_base = &s
  34335. }
  34336. // APIBase returns the value of the "api_base" field in the mutation.
  34337. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34338. v := m.api_base
  34339. if v == nil {
  34340. return
  34341. }
  34342. return *v, true
  34343. }
  34344. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34345. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34347. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34348. if !m.op.Is(OpUpdateOne) {
  34349. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34350. }
  34351. if m.id == nil || m.oldValue == nil {
  34352. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34353. }
  34354. oldValue, err := m.oldValue(ctx)
  34355. if err != nil {
  34356. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34357. }
  34358. return oldValue.APIBase, nil
  34359. }
  34360. // ClearAPIBase clears the value of the "api_base" field.
  34361. func (m *WhatsappMutation) ClearAPIBase() {
  34362. m.api_base = nil
  34363. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34364. }
  34365. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34366. func (m *WhatsappMutation) APIBaseCleared() bool {
  34367. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34368. return ok
  34369. }
  34370. // ResetAPIBase resets all changes to the "api_base" field.
  34371. func (m *WhatsappMutation) ResetAPIBase() {
  34372. m.api_base = nil
  34373. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34374. }
  34375. // SetAPIKey sets the "api_key" field.
  34376. func (m *WhatsappMutation) SetAPIKey(s string) {
  34377. m.api_key = &s
  34378. }
  34379. // APIKey returns the value of the "api_key" field in the mutation.
  34380. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34381. v := m.api_key
  34382. if v == nil {
  34383. return
  34384. }
  34385. return *v, true
  34386. }
  34387. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34388. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34389. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34390. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34391. if !m.op.Is(OpUpdateOne) {
  34392. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34393. }
  34394. if m.id == nil || m.oldValue == nil {
  34395. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34396. }
  34397. oldValue, err := m.oldValue(ctx)
  34398. if err != nil {
  34399. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34400. }
  34401. return oldValue.APIKey, nil
  34402. }
  34403. // ClearAPIKey clears the value of the "api_key" field.
  34404. func (m *WhatsappMutation) ClearAPIKey() {
  34405. m.api_key = nil
  34406. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34407. }
  34408. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34409. func (m *WhatsappMutation) APIKeyCleared() bool {
  34410. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34411. return ok
  34412. }
  34413. // ResetAPIKey resets all changes to the "api_key" field.
  34414. func (m *WhatsappMutation) ResetAPIKey() {
  34415. m.api_key = nil
  34416. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34417. }
  34418. // SetAllowList sets the "allow_list" field.
  34419. func (m *WhatsappMutation) SetAllowList(s []string) {
  34420. m.allow_list = &s
  34421. m.appendallow_list = nil
  34422. }
  34423. // AllowList returns the value of the "allow_list" field in the mutation.
  34424. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34425. v := m.allow_list
  34426. if v == nil {
  34427. return
  34428. }
  34429. return *v, true
  34430. }
  34431. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34432. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34433. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34434. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34435. if !m.op.Is(OpUpdateOne) {
  34436. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34437. }
  34438. if m.id == nil || m.oldValue == nil {
  34439. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34440. }
  34441. oldValue, err := m.oldValue(ctx)
  34442. if err != nil {
  34443. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34444. }
  34445. return oldValue.AllowList, nil
  34446. }
  34447. // AppendAllowList adds s to the "allow_list" field.
  34448. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34449. m.appendallow_list = append(m.appendallow_list, s...)
  34450. }
  34451. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34452. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34453. if len(m.appendallow_list) == 0 {
  34454. return nil, false
  34455. }
  34456. return m.appendallow_list, true
  34457. }
  34458. // ClearAllowList clears the value of the "allow_list" field.
  34459. func (m *WhatsappMutation) ClearAllowList() {
  34460. m.allow_list = nil
  34461. m.appendallow_list = nil
  34462. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34463. }
  34464. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34465. func (m *WhatsappMutation) AllowListCleared() bool {
  34466. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34467. return ok
  34468. }
  34469. // ResetAllowList resets all changes to the "allow_list" field.
  34470. func (m *WhatsappMutation) ResetAllowList() {
  34471. m.allow_list = nil
  34472. m.appendallow_list = nil
  34473. delete(m.clearedFields, whatsapp.FieldAllowList)
  34474. }
  34475. // SetGroupAllowList sets the "group_allow_list" field.
  34476. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34477. m.group_allow_list = &s
  34478. m.appendgroup_allow_list = nil
  34479. }
  34480. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34481. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34482. v := m.group_allow_list
  34483. if v == nil {
  34484. return
  34485. }
  34486. return *v, true
  34487. }
  34488. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34489. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34490. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34491. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34492. if !m.op.Is(OpUpdateOne) {
  34493. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34494. }
  34495. if m.id == nil || m.oldValue == nil {
  34496. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34497. }
  34498. oldValue, err := m.oldValue(ctx)
  34499. if err != nil {
  34500. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34501. }
  34502. return oldValue.GroupAllowList, nil
  34503. }
  34504. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34505. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34506. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34507. }
  34508. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34509. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34510. if len(m.appendgroup_allow_list) == 0 {
  34511. return nil, false
  34512. }
  34513. return m.appendgroup_allow_list, true
  34514. }
  34515. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34516. func (m *WhatsappMutation) ClearGroupAllowList() {
  34517. m.group_allow_list = nil
  34518. m.appendgroup_allow_list = nil
  34519. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34520. }
  34521. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34522. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34523. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34524. return ok
  34525. }
  34526. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34527. func (m *WhatsappMutation) ResetGroupAllowList() {
  34528. m.group_allow_list = nil
  34529. m.appendgroup_allow_list = nil
  34530. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34531. }
  34532. // SetBlockList sets the "block_list" field.
  34533. func (m *WhatsappMutation) SetBlockList(s []string) {
  34534. m.block_list = &s
  34535. m.appendblock_list = nil
  34536. }
  34537. // BlockList returns the value of the "block_list" field in the mutation.
  34538. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34539. v := m.block_list
  34540. if v == nil {
  34541. return
  34542. }
  34543. return *v, true
  34544. }
  34545. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34546. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34548. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34549. if !m.op.Is(OpUpdateOne) {
  34550. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34551. }
  34552. if m.id == nil || m.oldValue == nil {
  34553. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34554. }
  34555. oldValue, err := m.oldValue(ctx)
  34556. if err != nil {
  34557. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34558. }
  34559. return oldValue.BlockList, nil
  34560. }
  34561. // AppendBlockList adds s to the "block_list" field.
  34562. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34563. m.appendblock_list = append(m.appendblock_list, s...)
  34564. }
  34565. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34566. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34567. if len(m.appendblock_list) == 0 {
  34568. return nil, false
  34569. }
  34570. return m.appendblock_list, true
  34571. }
  34572. // ClearBlockList clears the value of the "block_list" field.
  34573. func (m *WhatsappMutation) ClearBlockList() {
  34574. m.block_list = nil
  34575. m.appendblock_list = nil
  34576. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34577. }
  34578. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34579. func (m *WhatsappMutation) BlockListCleared() bool {
  34580. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34581. return ok
  34582. }
  34583. // ResetBlockList resets all changes to the "block_list" field.
  34584. func (m *WhatsappMutation) ResetBlockList() {
  34585. m.block_list = nil
  34586. m.appendblock_list = nil
  34587. delete(m.clearedFields, whatsapp.FieldBlockList)
  34588. }
  34589. // SetGroupBlockList sets the "group_block_list" field.
  34590. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34591. m.group_block_list = &s
  34592. m.appendgroup_block_list = nil
  34593. }
  34594. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34595. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34596. v := m.group_block_list
  34597. if v == nil {
  34598. return
  34599. }
  34600. return *v, true
  34601. }
  34602. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34603. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34605. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34606. if !m.op.Is(OpUpdateOne) {
  34607. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34608. }
  34609. if m.id == nil || m.oldValue == nil {
  34610. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34611. }
  34612. oldValue, err := m.oldValue(ctx)
  34613. if err != nil {
  34614. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34615. }
  34616. return oldValue.GroupBlockList, nil
  34617. }
  34618. // AppendGroupBlockList adds s to the "group_block_list" field.
  34619. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34620. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34621. }
  34622. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34623. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34624. if len(m.appendgroup_block_list) == 0 {
  34625. return nil, false
  34626. }
  34627. return m.appendgroup_block_list, true
  34628. }
  34629. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34630. func (m *WhatsappMutation) ClearGroupBlockList() {
  34631. m.group_block_list = nil
  34632. m.appendgroup_block_list = nil
  34633. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34634. }
  34635. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34636. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34637. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34638. return ok
  34639. }
  34640. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34641. func (m *WhatsappMutation) ResetGroupBlockList() {
  34642. m.group_block_list = nil
  34643. m.appendgroup_block_list = nil
  34644. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34645. }
  34646. // ClearAgent clears the "agent" edge to the Agent entity.
  34647. func (m *WhatsappMutation) ClearAgent() {
  34648. m.clearedagent = true
  34649. m.clearedFields[whatsapp.FieldAgentID] = struct{}{}
  34650. }
  34651. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  34652. func (m *WhatsappMutation) AgentCleared() bool {
  34653. return m.clearedagent
  34654. }
  34655. // AgentIDs returns the "agent" edge IDs in the mutation.
  34656. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  34657. // AgentID instead. It exists only for internal usage by the builders.
  34658. func (m *WhatsappMutation) AgentIDs() (ids []uint64) {
  34659. if id := m.agent; id != nil {
  34660. ids = append(ids, *id)
  34661. }
  34662. return
  34663. }
  34664. // ResetAgent resets all changes to the "agent" edge.
  34665. func (m *WhatsappMutation) ResetAgent() {
  34666. m.agent = nil
  34667. m.clearedagent = false
  34668. }
  34669. // Where appends a list predicates to the WhatsappMutation builder.
  34670. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34671. m.predicates = append(m.predicates, ps...)
  34672. }
  34673. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34674. // users can use type-assertion to append predicates that do not depend on any generated package.
  34675. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34676. p := make([]predicate.Whatsapp, len(ps))
  34677. for i := range ps {
  34678. p[i] = ps[i]
  34679. }
  34680. m.Where(p...)
  34681. }
  34682. // Op returns the operation name.
  34683. func (m *WhatsappMutation) Op() Op {
  34684. return m.op
  34685. }
  34686. // SetOp allows setting the mutation operation.
  34687. func (m *WhatsappMutation) SetOp(op Op) {
  34688. m.op = op
  34689. }
  34690. // Type returns the node type of this mutation (Whatsapp).
  34691. func (m *WhatsappMutation) Type() string {
  34692. return m.typ
  34693. }
  34694. // Fields returns all fields that were changed during this mutation. Note that in
  34695. // order to get all numeric fields that were incremented/decremented, call
  34696. // AddedFields().
  34697. func (m *WhatsappMutation) Fields() []string {
  34698. fields := make([]string, 0, 18)
  34699. if m.created_at != nil {
  34700. fields = append(fields, whatsapp.FieldCreatedAt)
  34701. }
  34702. if m.updated_at != nil {
  34703. fields = append(fields, whatsapp.FieldUpdatedAt)
  34704. }
  34705. if m.status != nil {
  34706. fields = append(fields, whatsapp.FieldStatus)
  34707. }
  34708. if m.deleted_at != nil {
  34709. fields = append(fields, whatsapp.FieldDeletedAt)
  34710. }
  34711. if m.ak != nil {
  34712. fields = append(fields, whatsapp.FieldAk)
  34713. }
  34714. if m.sk != nil {
  34715. fields = append(fields, whatsapp.FieldSk)
  34716. }
  34717. if m.callback != nil {
  34718. fields = append(fields, whatsapp.FieldCallback)
  34719. }
  34720. if m.account != nil {
  34721. fields = append(fields, whatsapp.FieldAccount)
  34722. }
  34723. if m.nickname != nil {
  34724. fields = append(fields, whatsapp.FieldNickname)
  34725. }
  34726. if m.phone != nil {
  34727. fields = append(fields, whatsapp.FieldPhone)
  34728. }
  34729. if m.organization_id != nil {
  34730. fields = append(fields, whatsapp.FieldOrganizationID)
  34731. }
  34732. if m.agent != nil {
  34733. fields = append(fields, whatsapp.FieldAgentID)
  34734. }
  34735. if m.api_base != nil {
  34736. fields = append(fields, whatsapp.FieldAPIBase)
  34737. }
  34738. if m.api_key != nil {
  34739. fields = append(fields, whatsapp.FieldAPIKey)
  34740. }
  34741. if m.allow_list != nil {
  34742. fields = append(fields, whatsapp.FieldAllowList)
  34743. }
  34744. if m.group_allow_list != nil {
  34745. fields = append(fields, whatsapp.FieldGroupAllowList)
  34746. }
  34747. if m.block_list != nil {
  34748. fields = append(fields, whatsapp.FieldBlockList)
  34749. }
  34750. if m.group_block_list != nil {
  34751. fields = append(fields, whatsapp.FieldGroupBlockList)
  34752. }
  34753. return fields
  34754. }
  34755. // Field returns the value of a field with the given name. The second boolean
  34756. // return value indicates that this field was not set, or was not defined in the
  34757. // schema.
  34758. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34759. switch name {
  34760. case whatsapp.FieldCreatedAt:
  34761. return m.CreatedAt()
  34762. case whatsapp.FieldUpdatedAt:
  34763. return m.UpdatedAt()
  34764. case whatsapp.FieldStatus:
  34765. return m.Status()
  34766. case whatsapp.FieldDeletedAt:
  34767. return m.DeletedAt()
  34768. case whatsapp.FieldAk:
  34769. return m.Ak()
  34770. case whatsapp.FieldSk:
  34771. return m.Sk()
  34772. case whatsapp.FieldCallback:
  34773. return m.Callback()
  34774. case whatsapp.FieldAccount:
  34775. return m.Account()
  34776. case whatsapp.FieldNickname:
  34777. return m.Nickname()
  34778. case whatsapp.FieldPhone:
  34779. return m.Phone()
  34780. case whatsapp.FieldOrganizationID:
  34781. return m.OrganizationID()
  34782. case whatsapp.FieldAgentID:
  34783. return m.AgentID()
  34784. case whatsapp.FieldAPIBase:
  34785. return m.APIBase()
  34786. case whatsapp.FieldAPIKey:
  34787. return m.APIKey()
  34788. case whatsapp.FieldAllowList:
  34789. return m.AllowList()
  34790. case whatsapp.FieldGroupAllowList:
  34791. return m.GroupAllowList()
  34792. case whatsapp.FieldBlockList:
  34793. return m.BlockList()
  34794. case whatsapp.FieldGroupBlockList:
  34795. return m.GroupBlockList()
  34796. }
  34797. return nil, false
  34798. }
  34799. // OldField returns the old value of the field from the database. An error is
  34800. // returned if the mutation operation is not UpdateOne, or the query to the
  34801. // database failed.
  34802. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34803. switch name {
  34804. case whatsapp.FieldCreatedAt:
  34805. return m.OldCreatedAt(ctx)
  34806. case whatsapp.FieldUpdatedAt:
  34807. return m.OldUpdatedAt(ctx)
  34808. case whatsapp.FieldStatus:
  34809. return m.OldStatus(ctx)
  34810. case whatsapp.FieldDeletedAt:
  34811. return m.OldDeletedAt(ctx)
  34812. case whatsapp.FieldAk:
  34813. return m.OldAk(ctx)
  34814. case whatsapp.FieldSk:
  34815. return m.OldSk(ctx)
  34816. case whatsapp.FieldCallback:
  34817. return m.OldCallback(ctx)
  34818. case whatsapp.FieldAccount:
  34819. return m.OldAccount(ctx)
  34820. case whatsapp.FieldNickname:
  34821. return m.OldNickname(ctx)
  34822. case whatsapp.FieldPhone:
  34823. return m.OldPhone(ctx)
  34824. case whatsapp.FieldOrganizationID:
  34825. return m.OldOrganizationID(ctx)
  34826. case whatsapp.FieldAgentID:
  34827. return m.OldAgentID(ctx)
  34828. case whatsapp.FieldAPIBase:
  34829. return m.OldAPIBase(ctx)
  34830. case whatsapp.FieldAPIKey:
  34831. return m.OldAPIKey(ctx)
  34832. case whatsapp.FieldAllowList:
  34833. return m.OldAllowList(ctx)
  34834. case whatsapp.FieldGroupAllowList:
  34835. return m.OldGroupAllowList(ctx)
  34836. case whatsapp.FieldBlockList:
  34837. return m.OldBlockList(ctx)
  34838. case whatsapp.FieldGroupBlockList:
  34839. return m.OldGroupBlockList(ctx)
  34840. }
  34841. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34842. }
  34843. // SetField sets the value of a field with the given name. It returns an error if
  34844. // the field is not defined in the schema, or if the type mismatched the field
  34845. // type.
  34846. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34847. switch name {
  34848. case whatsapp.FieldCreatedAt:
  34849. v, ok := value.(time.Time)
  34850. if !ok {
  34851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34852. }
  34853. m.SetCreatedAt(v)
  34854. return nil
  34855. case whatsapp.FieldUpdatedAt:
  34856. v, ok := value.(time.Time)
  34857. if !ok {
  34858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34859. }
  34860. m.SetUpdatedAt(v)
  34861. return nil
  34862. case whatsapp.FieldStatus:
  34863. v, ok := value.(uint8)
  34864. if !ok {
  34865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34866. }
  34867. m.SetStatus(v)
  34868. return nil
  34869. case whatsapp.FieldDeletedAt:
  34870. v, ok := value.(time.Time)
  34871. if !ok {
  34872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34873. }
  34874. m.SetDeletedAt(v)
  34875. return nil
  34876. case whatsapp.FieldAk:
  34877. v, ok := value.(string)
  34878. if !ok {
  34879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34880. }
  34881. m.SetAk(v)
  34882. return nil
  34883. case whatsapp.FieldSk:
  34884. v, ok := value.(string)
  34885. if !ok {
  34886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34887. }
  34888. m.SetSk(v)
  34889. return nil
  34890. case whatsapp.FieldCallback:
  34891. v, ok := value.(string)
  34892. if !ok {
  34893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34894. }
  34895. m.SetCallback(v)
  34896. return nil
  34897. case whatsapp.FieldAccount:
  34898. v, ok := value.(string)
  34899. if !ok {
  34900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34901. }
  34902. m.SetAccount(v)
  34903. return nil
  34904. case whatsapp.FieldNickname:
  34905. v, ok := value.(string)
  34906. if !ok {
  34907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34908. }
  34909. m.SetNickname(v)
  34910. return nil
  34911. case whatsapp.FieldPhone:
  34912. v, ok := value.(string)
  34913. if !ok {
  34914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34915. }
  34916. m.SetPhone(v)
  34917. return nil
  34918. case whatsapp.FieldOrganizationID:
  34919. v, ok := value.(uint64)
  34920. if !ok {
  34921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34922. }
  34923. m.SetOrganizationID(v)
  34924. return nil
  34925. case whatsapp.FieldAgentID:
  34926. v, ok := value.(uint64)
  34927. if !ok {
  34928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34929. }
  34930. m.SetAgentID(v)
  34931. return nil
  34932. case whatsapp.FieldAPIBase:
  34933. v, ok := value.(string)
  34934. if !ok {
  34935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34936. }
  34937. m.SetAPIBase(v)
  34938. return nil
  34939. case whatsapp.FieldAPIKey:
  34940. v, ok := value.(string)
  34941. if !ok {
  34942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34943. }
  34944. m.SetAPIKey(v)
  34945. return nil
  34946. case whatsapp.FieldAllowList:
  34947. v, ok := value.([]string)
  34948. if !ok {
  34949. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34950. }
  34951. m.SetAllowList(v)
  34952. return nil
  34953. case whatsapp.FieldGroupAllowList:
  34954. v, ok := value.([]string)
  34955. if !ok {
  34956. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34957. }
  34958. m.SetGroupAllowList(v)
  34959. return nil
  34960. case whatsapp.FieldBlockList:
  34961. v, ok := value.([]string)
  34962. if !ok {
  34963. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34964. }
  34965. m.SetBlockList(v)
  34966. return nil
  34967. case whatsapp.FieldGroupBlockList:
  34968. v, ok := value.([]string)
  34969. if !ok {
  34970. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34971. }
  34972. m.SetGroupBlockList(v)
  34973. return nil
  34974. }
  34975. return fmt.Errorf("unknown Whatsapp field %s", name)
  34976. }
  34977. // AddedFields returns all numeric fields that were incremented/decremented during
  34978. // this mutation.
  34979. func (m *WhatsappMutation) AddedFields() []string {
  34980. var fields []string
  34981. if m.addstatus != nil {
  34982. fields = append(fields, whatsapp.FieldStatus)
  34983. }
  34984. if m.addorganization_id != nil {
  34985. fields = append(fields, whatsapp.FieldOrganizationID)
  34986. }
  34987. return fields
  34988. }
  34989. // AddedField returns the numeric value that was incremented/decremented on a field
  34990. // with the given name. The second boolean return value indicates that this field
  34991. // was not set, or was not defined in the schema.
  34992. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  34993. switch name {
  34994. case whatsapp.FieldStatus:
  34995. return m.AddedStatus()
  34996. case whatsapp.FieldOrganizationID:
  34997. return m.AddedOrganizationID()
  34998. }
  34999. return nil, false
  35000. }
  35001. // AddField adds the value to the field with the given name. It returns an error if
  35002. // the field is not defined in the schema, or if the type mismatched the field
  35003. // type.
  35004. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  35005. switch name {
  35006. case whatsapp.FieldStatus:
  35007. v, ok := value.(int8)
  35008. if !ok {
  35009. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35010. }
  35011. m.AddStatus(v)
  35012. return nil
  35013. case whatsapp.FieldOrganizationID:
  35014. v, ok := value.(int64)
  35015. if !ok {
  35016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35017. }
  35018. m.AddOrganizationID(v)
  35019. return nil
  35020. }
  35021. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  35022. }
  35023. // ClearedFields returns all nullable fields that were cleared during this
  35024. // mutation.
  35025. func (m *WhatsappMutation) ClearedFields() []string {
  35026. var fields []string
  35027. if m.FieldCleared(whatsapp.FieldStatus) {
  35028. fields = append(fields, whatsapp.FieldStatus)
  35029. }
  35030. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  35031. fields = append(fields, whatsapp.FieldDeletedAt)
  35032. }
  35033. if m.FieldCleared(whatsapp.FieldAk) {
  35034. fields = append(fields, whatsapp.FieldAk)
  35035. }
  35036. if m.FieldCleared(whatsapp.FieldCallback) {
  35037. fields = append(fields, whatsapp.FieldCallback)
  35038. }
  35039. if m.FieldCleared(whatsapp.FieldAccount) {
  35040. fields = append(fields, whatsapp.FieldAccount)
  35041. }
  35042. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  35043. fields = append(fields, whatsapp.FieldOrganizationID)
  35044. }
  35045. if m.FieldCleared(whatsapp.FieldAPIBase) {
  35046. fields = append(fields, whatsapp.FieldAPIBase)
  35047. }
  35048. if m.FieldCleared(whatsapp.FieldAPIKey) {
  35049. fields = append(fields, whatsapp.FieldAPIKey)
  35050. }
  35051. if m.FieldCleared(whatsapp.FieldAllowList) {
  35052. fields = append(fields, whatsapp.FieldAllowList)
  35053. }
  35054. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  35055. fields = append(fields, whatsapp.FieldGroupAllowList)
  35056. }
  35057. if m.FieldCleared(whatsapp.FieldBlockList) {
  35058. fields = append(fields, whatsapp.FieldBlockList)
  35059. }
  35060. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  35061. fields = append(fields, whatsapp.FieldGroupBlockList)
  35062. }
  35063. return fields
  35064. }
  35065. // FieldCleared returns a boolean indicating if a field with the given name was
  35066. // cleared in this mutation.
  35067. func (m *WhatsappMutation) FieldCleared(name string) bool {
  35068. _, ok := m.clearedFields[name]
  35069. return ok
  35070. }
  35071. // ClearField clears the value of the field with the given name. It returns an
  35072. // error if the field is not defined in the schema.
  35073. func (m *WhatsappMutation) ClearField(name string) error {
  35074. switch name {
  35075. case whatsapp.FieldStatus:
  35076. m.ClearStatus()
  35077. return nil
  35078. case whatsapp.FieldDeletedAt:
  35079. m.ClearDeletedAt()
  35080. return nil
  35081. case whatsapp.FieldAk:
  35082. m.ClearAk()
  35083. return nil
  35084. case whatsapp.FieldCallback:
  35085. m.ClearCallback()
  35086. return nil
  35087. case whatsapp.FieldAccount:
  35088. m.ClearAccount()
  35089. return nil
  35090. case whatsapp.FieldOrganizationID:
  35091. m.ClearOrganizationID()
  35092. return nil
  35093. case whatsapp.FieldAPIBase:
  35094. m.ClearAPIBase()
  35095. return nil
  35096. case whatsapp.FieldAPIKey:
  35097. m.ClearAPIKey()
  35098. return nil
  35099. case whatsapp.FieldAllowList:
  35100. m.ClearAllowList()
  35101. return nil
  35102. case whatsapp.FieldGroupAllowList:
  35103. m.ClearGroupAllowList()
  35104. return nil
  35105. case whatsapp.FieldBlockList:
  35106. m.ClearBlockList()
  35107. return nil
  35108. case whatsapp.FieldGroupBlockList:
  35109. m.ClearGroupBlockList()
  35110. return nil
  35111. }
  35112. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35113. }
  35114. // ResetField resets all changes in the mutation for the field with the given name.
  35115. // It returns an error if the field is not defined in the schema.
  35116. func (m *WhatsappMutation) ResetField(name string) error {
  35117. switch name {
  35118. case whatsapp.FieldCreatedAt:
  35119. m.ResetCreatedAt()
  35120. return nil
  35121. case whatsapp.FieldUpdatedAt:
  35122. m.ResetUpdatedAt()
  35123. return nil
  35124. case whatsapp.FieldStatus:
  35125. m.ResetStatus()
  35126. return nil
  35127. case whatsapp.FieldDeletedAt:
  35128. m.ResetDeletedAt()
  35129. return nil
  35130. case whatsapp.FieldAk:
  35131. m.ResetAk()
  35132. return nil
  35133. case whatsapp.FieldSk:
  35134. m.ResetSk()
  35135. return nil
  35136. case whatsapp.FieldCallback:
  35137. m.ResetCallback()
  35138. return nil
  35139. case whatsapp.FieldAccount:
  35140. m.ResetAccount()
  35141. return nil
  35142. case whatsapp.FieldNickname:
  35143. m.ResetNickname()
  35144. return nil
  35145. case whatsapp.FieldPhone:
  35146. m.ResetPhone()
  35147. return nil
  35148. case whatsapp.FieldOrganizationID:
  35149. m.ResetOrganizationID()
  35150. return nil
  35151. case whatsapp.FieldAgentID:
  35152. m.ResetAgentID()
  35153. return nil
  35154. case whatsapp.FieldAPIBase:
  35155. m.ResetAPIBase()
  35156. return nil
  35157. case whatsapp.FieldAPIKey:
  35158. m.ResetAPIKey()
  35159. return nil
  35160. case whatsapp.FieldAllowList:
  35161. m.ResetAllowList()
  35162. return nil
  35163. case whatsapp.FieldGroupAllowList:
  35164. m.ResetGroupAllowList()
  35165. return nil
  35166. case whatsapp.FieldBlockList:
  35167. m.ResetBlockList()
  35168. return nil
  35169. case whatsapp.FieldGroupBlockList:
  35170. m.ResetGroupBlockList()
  35171. return nil
  35172. }
  35173. return fmt.Errorf("unknown Whatsapp field %s", name)
  35174. }
  35175. // AddedEdges returns all edge names that were set/added in this mutation.
  35176. func (m *WhatsappMutation) AddedEdges() []string {
  35177. edges := make([]string, 0, 1)
  35178. if m.agent != nil {
  35179. edges = append(edges, whatsapp.EdgeAgent)
  35180. }
  35181. return edges
  35182. }
  35183. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35184. // name in this mutation.
  35185. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35186. switch name {
  35187. case whatsapp.EdgeAgent:
  35188. if id := m.agent; id != nil {
  35189. return []ent.Value{*id}
  35190. }
  35191. }
  35192. return nil
  35193. }
  35194. // RemovedEdges returns all edge names that were removed in this mutation.
  35195. func (m *WhatsappMutation) RemovedEdges() []string {
  35196. edges := make([]string, 0, 1)
  35197. return edges
  35198. }
  35199. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35200. // the given name in this mutation.
  35201. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35202. return nil
  35203. }
  35204. // ClearedEdges returns all edge names that were cleared in this mutation.
  35205. func (m *WhatsappMutation) ClearedEdges() []string {
  35206. edges := make([]string, 0, 1)
  35207. if m.clearedagent {
  35208. edges = append(edges, whatsapp.EdgeAgent)
  35209. }
  35210. return edges
  35211. }
  35212. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35213. // was cleared in this mutation.
  35214. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35215. switch name {
  35216. case whatsapp.EdgeAgent:
  35217. return m.clearedagent
  35218. }
  35219. return false
  35220. }
  35221. // ClearEdge clears the value of the edge with the given name. It returns an error
  35222. // if that edge is not defined in the schema.
  35223. func (m *WhatsappMutation) ClearEdge(name string) error {
  35224. switch name {
  35225. case whatsapp.EdgeAgent:
  35226. m.ClearAgent()
  35227. return nil
  35228. }
  35229. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35230. }
  35231. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35232. // It returns an error if the edge is not defined in the schema.
  35233. func (m *WhatsappMutation) ResetEdge(name string) error {
  35234. switch name {
  35235. case whatsapp.EdgeAgent:
  35236. m.ResetAgent()
  35237. return nil
  35238. }
  35239. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35240. }
  35241. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  35242. type WorkExperienceMutation struct {
  35243. config
  35244. op Op
  35245. typ string
  35246. id *uint64
  35247. created_at *time.Time
  35248. updated_at *time.Time
  35249. deleted_at *time.Time
  35250. start_date *time.Time
  35251. end_date *time.Time
  35252. company *string
  35253. experience *string
  35254. organization_id *uint64
  35255. addorganization_id *int64
  35256. clearedFields map[string]struct{}
  35257. employee *uint64
  35258. clearedemployee bool
  35259. done bool
  35260. oldValue func(context.Context) (*WorkExperience, error)
  35261. predicates []predicate.WorkExperience
  35262. }
  35263. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  35264. // workexperienceOption allows management of the mutation configuration using functional options.
  35265. type workexperienceOption func(*WorkExperienceMutation)
  35266. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  35267. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  35268. m := &WorkExperienceMutation{
  35269. config: c,
  35270. op: op,
  35271. typ: TypeWorkExperience,
  35272. clearedFields: make(map[string]struct{}),
  35273. }
  35274. for _, opt := range opts {
  35275. opt(m)
  35276. }
  35277. return m
  35278. }
  35279. // withWorkExperienceID sets the ID field of the mutation.
  35280. func withWorkExperienceID(id uint64) workexperienceOption {
  35281. return func(m *WorkExperienceMutation) {
  35282. var (
  35283. err error
  35284. once sync.Once
  35285. value *WorkExperience
  35286. )
  35287. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  35288. once.Do(func() {
  35289. if m.done {
  35290. err = errors.New("querying old values post mutation is not allowed")
  35291. } else {
  35292. value, err = m.Client().WorkExperience.Get(ctx, id)
  35293. }
  35294. })
  35295. return value, err
  35296. }
  35297. m.id = &id
  35298. }
  35299. }
  35300. // withWorkExperience sets the old WorkExperience of the mutation.
  35301. func withWorkExperience(node *WorkExperience) workexperienceOption {
  35302. return func(m *WorkExperienceMutation) {
  35303. m.oldValue = func(context.Context) (*WorkExperience, error) {
  35304. return node, nil
  35305. }
  35306. m.id = &node.ID
  35307. }
  35308. }
  35309. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35310. // executed in a transaction (ent.Tx), a transactional client is returned.
  35311. func (m WorkExperienceMutation) Client() *Client {
  35312. client := &Client{config: m.config}
  35313. client.init()
  35314. return client
  35315. }
  35316. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35317. // it returns an error otherwise.
  35318. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  35319. if _, ok := m.driver.(*txDriver); !ok {
  35320. return nil, errors.New("ent: mutation is not running in a transaction")
  35321. }
  35322. tx := &Tx{config: m.config}
  35323. tx.init()
  35324. return tx, nil
  35325. }
  35326. // SetID sets the value of the id field. Note that this
  35327. // operation is only accepted on creation of WorkExperience entities.
  35328. func (m *WorkExperienceMutation) SetID(id uint64) {
  35329. m.id = &id
  35330. }
  35331. // ID returns the ID value in the mutation. Note that the ID is only available
  35332. // if it was provided to the builder or after it was returned from the database.
  35333. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  35334. if m.id == nil {
  35335. return
  35336. }
  35337. return *m.id, true
  35338. }
  35339. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35340. // That means, if the mutation is applied within a transaction with an isolation level such
  35341. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35342. // or updated by the mutation.
  35343. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  35344. switch {
  35345. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35346. id, exists := m.ID()
  35347. if exists {
  35348. return []uint64{id}, nil
  35349. }
  35350. fallthrough
  35351. case m.op.Is(OpUpdate | OpDelete):
  35352. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  35353. default:
  35354. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35355. }
  35356. }
  35357. // SetCreatedAt sets the "created_at" field.
  35358. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  35359. m.created_at = &t
  35360. }
  35361. // CreatedAt returns the value of the "created_at" field in the mutation.
  35362. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  35363. v := m.created_at
  35364. if v == nil {
  35365. return
  35366. }
  35367. return *v, true
  35368. }
  35369. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  35370. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35372. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35373. if !m.op.Is(OpUpdateOne) {
  35374. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35375. }
  35376. if m.id == nil || m.oldValue == nil {
  35377. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35378. }
  35379. oldValue, err := m.oldValue(ctx)
  35380. if err != nil {
  35381. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35382. }
  35383. return oldValue.CreatedAt, nil
  35384. }
  35385. // ResetCreatedAt resets all changes to the "created_at" field.
  35386. func (m *WorkExperienceMutation) ResetCreatedAt() {
  35387. m.created_at = nil
  35388. }
  35389. // SetUpdatedAt sets the "updated_at" field.
  35390. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  35391. m.updated_at = &t
  35392. }
  35393. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35394. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  35395. v := m.updated_at
  35396. if v == nil {
  35397. return
  35398. }
  35399. return *v, true
  35400. }
  35401. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  35402. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35404. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35405. if !m.op.Is(OpUpdateOne) {
  35406. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35407. }
  35408. if m.id == nil || m.oldValue == nil {
  35409. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35410. }
  35411. oldValue, err := m.oldValue(ctx)
  35412. if err != nil {
  35413. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35414. }
  35415. return oldValue.UpdatedAt, nil
  35416. }
  35417. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35418. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  35419. m.updated_at = nil
  35420. }
  35421. // SetDeletedAt sets the "deleted_at" field.
  35422. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  35423. m.deleted_at = &t
  35424. }
  35425. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35426. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  35427. v := m.deleted_at
  35428. if v == nil {
  35429. return
  35430. }
  35431. return *v, true
  35432. }
  35433. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  35434. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35435. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35436. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35437. if !m.op.Is(OpUpdateOne) {
  35438. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35439. }
  35440. if m.id == nil || m.oldValue == nil {
  35441. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35442. }
  35443. oldValue, err := m.oldValue(ctx)
  35444. if err != nil {
  35445. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35446. }
  35447. return oldValue.DeletedAt, nil
  35448. }
  35449. // ClearDeletedAt clears the value of the "deleted_at" field.
  35450. func (m *WorkExperienceMutation) ClearDeletedAt() {
  35451. m.deleted_at = nil
  35452. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  35453. }
  35454. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35455. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  35456. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  35457. return ok
  35458. }
  35459. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35460. func (m *WorkExperienceMutation) ResetDeletedAt() {
  35461. m.deleted_at = nil
  35462. delete(m.clearedFields, workexperience.FieldDeletedAt)
  35463. }
  35464. // SetEmployeeID sets the "employee_id" field.
  35465. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  35466. m.employee = &u
  35467. }
  35468. // EmployeeID returns the value of the "employee_id" field in the mutation.
  35469. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  35470. v := m.employee
  35471. if v == nil {
  35472. return
  35473. }
  35474. return *v, true
  35475. }
  35476. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  35477. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35479. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  35480. if !m.op.Is(OpUpdateOne) {
  35481. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  35482. }
  35483. if m.id == nil || m.oldValue == nil {
  35484. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  35485. }
  35486. oldValue, err := m.oldValue(ctx)
  35487. if err != nil {
  35488. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  35489. }
  35490. return oldValue.EmployeeID, nil
  35491. }
  35492. // ResetEmployeeID resets all changes to the "employee_id" field.
  35493. func (m *WorkExperienceMutation) ResetEmployeeID() {
  35494. m.employee = nil
  35495. }
  35496. // SetStartDate sets the "start_date" field.
  35497. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  35498. m.start_date = &t
  35499. }
  35500. // StartDate returns the value of the "start_date" field in the mutation.
  35501. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  35502. v := m.start_date
  35503. if v == nil {
  35504. return
  35505. }
  35506. return *v, true
  35507. }
  35508. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  35509. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35511. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  35512. if !m.op.Is(OpUpdateOne) {
  35513. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  35514. }
  35515. if m.id == nil || m.oldValue == nil {
  35516. return v, errors.New("OldStartDate requires an ID field in the mutation")
  35517. }
  35518. oldValue, err := m.oldValue(ctx)
  35519. if err != nil {
  35520. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  35521. }
  35522. return oldValue.StartDate, nil
  35523. }
  35524. // ResetStartDate resets all changes to the "start_date" field.
  35525. func (m *WorkExperienceMutation) ResetStartDate() {
  35526. m.start_date = nil
  35527. }
  35528. // SetEndDate sets the "end_date" field.
  35529. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  35530. m.end_date = &t
  35531. }
  35532. // EndDate returns the value of the "end_date" field in the mutation.
  35533. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  35534. v := m.end_date
  35535. if v == nil {
  35536. return
  35537. }
  35538. return *v, true
  35539. }
  35540. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  35541. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35542. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35543. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  35544. if !m.op.Is(OpUpdateOne) {
  35545. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  35546. }
  35547. if m.id == nil || m.oldValue == nil {
  35548. return v, errors.New("OldEndDate requires an ID field in the mutation")
  35549. }
  35550. oldValue, err := m.oldValue(ctx)
  35551. if err != nil {
  35552. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  35553. }
  35554. return oldValue.EndDate, nil
  35555. }
  35556. // ResetEndDate resets all changes to the "end_date" field.
  35557. func (m *WorkExperienceMutation) ResetEndDate() {
  35558. m.end_date = nil
  35559. }
  35560. // SetCompany sets the "company" field.
  35561. func (m *WorkExperienceMutation) SetCompany(s string) {
  35562. m.company = &s
  35563. }
  35564. // Company returns the value of the "company" field in the mutation.
  35565. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  35566. v := m.company
  35567. if v == nil {
  35568. return
  35569. }
  35570. return *v, true
  35571. }
  35572. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  35573. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35574. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35575. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  35576. if !m.op.Is(OpUpdateOne) {
  35577. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35578. }
  35579. if m.id == nil || m.oldValue == nil {
  35580. return v, errors.New("OldCompany requires an ID field in the mutation")
  35581. }
  35582. oldValue, err := m.oldValue(ctx)
  35583. if err != nil {
  35584. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35585. }
  35586. return oldValue.Company, nil
  35587. }
  35588. // ResetCompany resets all changes to the "company" field.
  35589. func (m *WorkExperienceMutation) ResetCompany() {
  35590. m.company = nil
  35591. }
  35592. // SetExperience sets the "experience" field.
  35593. func (m *WorkExperienceMutation) SetExperience(s string) {
  35594. m.experience = &s
  35595. }
  35596. // Experience returns the value of the "experience" field in the mutation.
  35597. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  35598. v := m.experience
  35599. if v == nil {
  35600. return
  35601. }
  35602. return *v, true
  35603. }
  35604. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  35605. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35606. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35607. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  35608. if !m.op.Is(OpUpdateOne) {
  35609. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  35610. }
  35611. if m.id == nil || m.oldValue == nil {
  35612. return v, errors.New("OldExperience requires an ID field in the mutation")
  35613. }
  35614. oldValue, err := m.oldValue(ctx)
  35615. if err != nil {
  35616. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  35617. }
  35618. return oldValue.Experience, nil
  35619. }
  35620. // ResetExperience resets all changes to the "experience" field.
  35621. func (m *WorkExperienceMutation) ResetExperience() {
  35622. m.experience = nil
  35623. }
  35624. // SetOrganizationID sets the "organization_id" field.
  35625. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  35626. m.organization_id = &u
  35627. m.addorganization_id = nil
  35628. }
  35629. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35630. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  35631. v := m.organization_id
  35632. if v == nil {
  35633. return
  35634. }
  35635. return *v, true
  35636. }
  35637. // OldOrganizationID returns the old "organization_id" field's value of the WorkExperience entity.
  35638. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35639. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35640. func (m *WorkExperienceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35641. if !m.op.Is(OpUpdateOne) {
  35642. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35643. }
  35644. if m.id == nil || m.oldValue == nil {
  35645. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  35646. }
  35647. oldValue, err := m.oldValue(ctx)
  35648. if err != nil {
  35649. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  35650. }
  35651. return oldValue.OrganizationID, nil
  35652. }
  35653. // AddOrganizationID adds u to the "organization_id" field.
  35654. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  35655. if m.addorganization_id != nil {
  35656. *m.addorganization_id += u
  35657. } else {
  35658. m.addorganization_id = &u
  35659. }
  35660. }
  35661. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35662. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  35663. v := m.addorganization_id
  35664. if v == nil {
  35665. return
  35666. }
  35667. return *v, true
  35668. }
  35669. // ResetOrganizationID resets all changes to the "organization_id" field.
  35670. func (m *WorkExperienceMutation) ResetOrganizationID() {
  35671. m.organization_id = nil
  35672. m.addorganization_id = nil
  35673. }
  35674. // ClearEmployee clears the "employee" edge to the Employee entity.
  35675. func (m *WorkExperienceMutation) ClearEmployee() {
  35676. m.clearedemployee = true
  35677. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  35678. }
  35679. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  35680. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  35681. return m.clearedemployee
  35682. }
  35683. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  35684. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35685. // EmployeeID instead. It exists only for internal usage by the builders.
  35686. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  35687. if id := m.employee; id != nil {
  35688. ids = append(ids, *id)
  35689. }
  35690. return
  35691. }
  35692. // ResetEmployee resets all changes to the "employee" edge.
  35693. func (m *WorkExperienceMutation) ResetEmployee() {
  35694. m.employee = nil
  35695. m.clearedemployee = false
  35696. }
  35697. // Where appends a list predicates to the WorkExperienceMutation builder.
  35698. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  35699. m.predicates = append(m.predicates, ps...)
  35700. }
  35701. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  35702. // users can use type-assertion to append predicates that do not depend on any generated package.
  35703. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  35704. p := make([]predicate.WorkExperience, len(ps))
  35705. for i := range ps {
  35706. p[i] = ps[i]
  35707. }
  35708. m.Where(p...)
  35709. }
  35710. // Op returns the operation name.
  35711. func (m *WorkExperienceMutation) Op() Op {
  35712. return m.op
  35713. }
  35714. // SetOp allows setting the mutation operation.
  35715. func (m *WorkExperienceMutation) SetOp(op Op) {
  35716. m.op = op
  35717. }
  35718. // Type returns the node type of this mutation (WorkExperience).
  35719. func (m *WorkExperienceMutation) Type() string {
  35720. return m.typ
  35721. }
  35722. // Fields returns all fields that were changed during this mutation. Note that in
  35723. // order to get all numeric fields that were incremented/decremented, call
  35724. // AddedFields().
  35725. func (m *WorkExperienceMutation) Fields() []string {
  35726. fields := make([]string, 0, 9)
  35727. if m.created_at != nil {
  35728. fields = append(fields, workexperience.FieldCreatedAt)
  35729. }
  35730. if m.updated_at != nil {
  35731. fields = append(fields, workexperience.FieldUpdatedAt)
  35732. }
  35733. if m.deleted_at != nil {
  35734. fields = append(fields, workexperience.FieldDeletedAt)
  35735. }
  35736. if m.employee != nil {
  35737. fields = append(fields, workexperience.FieldEmployeeID)
  35738. }
  35739. if m.start_date != nil {
  35740. fields = append(fields, workexperience.FieldStartDate)
  35741. }
  35742. if m.end_date != nil {
  35743. fields = append(fields, workexperience.FieldEndDate)
  35744. }
  35745. if m.company != nil {
  35746. fields = append(fields, workexperience.FieldCompany)
  35747. }
  35748. if m.experience != nil {
  35749. fields = append(fields, workexperience.FieldExperience)
  35750. }
  35751. if m.organization_id != nil {
  35752. fields = append(fields, workexperience.FieldOrganizationID)
  35753. }
  35754. return fields
  35755. }
  35756. // Field returns the value of a field with the given name. The second boolean
  35757. // return value indicates that this field was not set, or was not defined in the
  35758. // schema.
  35759. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  35760. switch name {
  35761. case workexperience.FieldCreatedAt:
  35762. return m.CreatedAt()
  35763. case workexperience.FieldUpdatedAt:
  35764. return m.UpdatedAt()
  35765. case workexperience.FieldDeletedAt:
  35766. return m.DeletedAt()
  35767. case workexperience.FieldEmployeeID:
  35768. return m.EmployeeID()
  35769. case workexperience.FieldStartDate:
  35770. return m.StartDate()
  35771. case workexperience.FieldEndDate:
  35772. return m.EndDate()
  35773. case workexperience.FieldCompany:
  35774. return m.Company()
  35775. case workexperience.FieldExperience:
  35776. return m.Experience()
  35777. case workexperience.FieldOrganizationID:
  35778. return m.OrganizationID()
  35779. }
  35780. return nil, false
  35781. }
  35782. // OldField returns the old value of the field from the database. An error is
  35783. // returned if the mutation operation is not UpdateOne, or the query to the
  35784. // database failed.
  35785. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35786. switch name {
  35787. case workexperience.FieldCreatedAt:
  35788. return m.OldCreatedAt(ctx)
  35789. case workexperience.FieldUpdatedAt:
  35790. return m.OldUpdatedAt(ctx)
  35791. case workexperience.FieldDeletedAt:
  35792. return m.OldDeletedAt(ctx)
  35793. case workexperience.FieldEmployeeID:
  35794. return m.OldEmployeeID(ctx)
  35795. case workexperience.FieldStartDate:
  35796. return m.OldStartDate(ctx)
  35797. case workexperience.FieldEndDate:
  35798. return m.OldEndDate(ctx)
  35799. case workexperience.FieldCompany:
  35800. return m.OldCompany(ctx)
  35801. case workexperience.FieldExperience:
  35802. return m.OldExperience(ctx)
  35803. case workexperience.FieldOrganizationID:
  35804. return m.OldOrganizationID(ctx)
  35805. }
  35806. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  35807. }
  35808. // SetField sets the value of a field with the given name. It returns an error if
  35809. // the field is not defined in the schema, or if the type mismatched the field
  35810. // type.
  35811. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  35812. switch name {
  35813. case workexperience.FieldCreatedAt:
  35814. v, ok := value.(time.Time)
  35815. if !ok {
  35816. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35817. }
  35818. m.SetCreatedAt(v)
  35819. return nil
  35820. case workexperience.FieldUpdatedAt:
  35821. v, ok := value.(time.Time)
  35822. if !ok {
  35823. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35824. }
  35825. m.SetUpdatedAt(v)
  35826. return nil
  35827. case workexperience.FieldDeletedAt:
  35828. v, ok := value.(time.Time)
  35829. if !ok {
  35830. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35831. }
  35832. m.SetDeletedAt(v)
  35833. return nil
  35834. case workexperience.FieldEmployeeID:
  35835. v, ok := value.(uint64)
  35836. if !ok {
  35837. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35838. }
  35839. m.SetEmployeeID(v)
  35840. return nil
  35841. case workexperience.FieldStartDate:
  35842. v, ok := value.(time.Time)
  35843. if !ok {
  35844. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35845. }
  35846. m.SetStartDate(v)
  35847. return nil
  35848. case workexperience.FieldEndDate:
  35849. v, ok := value.(time.Time)
  35850. if !ok {
  35851. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35852. }
  35853. m.SetEndDate(v)
  35854. return nil
  35855. case workexperience.FieldCompany:
  35856. v, ok := value.(string)
  35857. if !ok {
  35858. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35859. }
  35860. m.SetCompany(v)
  35861. return nil
  35862. case workexperience.FieldExperience:
  35863. v, ok := value.(string)
  35864. if !ok {
  35865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35866. }
  35867. m.SetExperience(v)
  35868. return nil
  35869. case workexperience.FieldOrganizationID:
  35870. v, ok := value.(uint64)
  35871. if !ok {
  35872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35873. }
  35874. m.SetOrganizationID(v)
  35875. return nil
  35876. }
  35877. return fmt.Errorf("unknown WorkExperience field %s", name)
  35878. }
  35879. // AddedFields returns all numeric fields that were incremented/decremented during
  35880. // this mutation.
  35881. func (m *WorkExperienceMutation) AddedFields() []string {
  35882. var fields []string
  35883. if m.addorganization_id != nil {
  35884. fields = append(fields, workexperience.FieldOrganizationID)
  35885. }
  35886. return fields
  35887. }
  35888. // AddedField returns the numeric value that was incremented/decremented on a field
  35889. // with the given name. The second boolean return value indicates that this field
  35890. // was not set, or was not defined in the schema.
  35891. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  35892. switch name {
  35893. case workexperience.FieldOrganizationID:
  35894. return m.AddedOrganizationID()
  35895. }
  35896. return nil, false
  35897. }
  35898. // AddField adds the value to the field with the given name. It returns an error if
  35899. // the field is not defined in the schema, or if the type mismatched the field
  35900. // type.
  35901. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  35902. switch name {
  35903. case workexperience.FieldOrganizationID:
  35904. v, ok := value.(int64)
  35905. if !ok {
  35906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35907. }
  35908. m.AddOrganizationID(v)
  35909. return nil
  35910. }
  35911. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  35912. }
  35913. // ClearedFields returns all nullable fields that were cleared during this
  35914. // mutation.
  35915. func (m *WorkExperienceMutation) ClearedFields() []string {
  35916. var fields []string
  35917. if m.FieldCleared(workexperience.FieldDeletedAt) {
  35918. fields = append(fields, workexperience.FieldDeletedAt)
  35919. }
  35920. return fields
  35921. }
  35922. // FieldCleared returns a boolean indicating if a field with the given name was
  35923. // cleared in this mutation.
  35924. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  35925. _, ok := m.clearedFields[name]
  35926. return ok
  35927. }
  35928. // ClearField clears the value of the field with the given name. It returns an
  35929. // error if the field is not defined in the schema.
  35930. func (m *WorkExperienceMutation) ClearField(name string) error {
  35931. switch name {
  35932. case workexperience.FieldDeletedAt:
  35933. m.ClearDeletedAt()
  35934. return nil
  35935. }
  35936. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  35937. }
  35938. // ResetField resets all changes in the mutation for the field with the given name.
  35939. // It returns an error if the field is not defined in the schema.
  35940. func (m *WorkExperienceMutation) ResetField(name string) error {
  35941. switch name {
  35942. case workexperience.FieldCreatedAt:
  35943. m.ResetCreatedAt()
  35944. return nil
  35945. case workexperience.FieldUpdatedAt:
  35946. m.ResetUpdatedAt()
  35947. return nil
  35948. case workexperience.FieldDeletedAt:
  35949. m.ResetDeletedAt()
  35950. return nil
  35951. case workexperience.FieldEmployeeID:
  35952. m.ResetEmployeeID()
  35953. return nil
  35954. case workexperience.FieldStartDate:
  35955. m.ResetStartDate()
  35956. return nil
  35957. case workexperience.FieldEndDate:
  35958. m.ResetEndDate()
  35959. return nil
  35960. case workexperience.FieldCompany:
  35961. m.ResetCompany()
  35962. return nil
  35963. case workexperience.FieldExperience:
  35964. m.ResetExperience()
  35965. return nil
  35966. case workexperience.FieldOrganizationID:
  35967. m.ResetOrganizationID()
  35968. return nil
  35969. }
  35970. return fmt.Errorf("unknown WorkExperience field %s", name)
  35971. }
  35972. // AddedEdges returns all edge names that were set/added in this mutation.
  35973. func (m *WorkExperienceMutation) AddedEdges() []string {
  35974. edges := make([]string, 0, 1)
  35975. if m.employee != nil {
  35976. edges = append(edges, workexperience.EdgeEmployee)
  35977. }
  35978. return edges
  35979. }
  35980. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35981. // name in this mutation.
  35982. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  35983. switch name {
  35984. case workexperience.EdgeEmployee:
  35985. if id := m.employee; id != nil {
  35986. return []ent.Value{*id}
  35987. }
  35988. }
  35989. return nil
  35990. }
  35991. // RemovedEdges returns all edge names that were removed in this mutation.
  35992. func (m *WorkExperienceMutation) RemovedEdges() []string {
  35993. edges := make([]string, 0, 1)
  35994. return edges
  35995. }
  35996. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35997. // the given name in this mutation.
  35998. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  35999. return nil
  36000. }
  36001. // ClearedEdges returns all edge names that were cleared in this mutation.
  36002. func (m *WorkExperienceMutation) ClearedEdges() []string {
  36003. edges := make([]string, 0, 1)
  36004. if m.clearedemployee {
  36005. edges = append(edges, workexperience.EdgeEmployee)
  36006. }
  36007. return edges
  36008. }
  36009. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36010. // was cleared in this mutation.
  36011. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  36012. switch name {
  36013. case workexperience.EdgeEmployee:
  36014. return m.clearedemployee
  36015. }
  36016. return false
  36017. }
  36018. // ClearEdge clears the value of the edge with the given name. It returns an error
  36019. // if that edge is not defined in the schema.
  36020. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  36021. switch name {
  36022. case workexperience.EdgeEmployee:
  36023. m.ClearEmployee()
  36024. return nil
  36025. }
  36026. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  36027. }
  36028. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36029. // It returns an error if the edge is not defined in the schema.
  36030. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  36031. switch name {
  36032. case workexperience.EdgeEmployee:
  36033. m.ResetEmployee()
  36034. return nil
  36035. }
  36036. return fmt.Errorf("unknown WorkExperience edge %s", name)
  36037. }
  36038. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  36039. type WpChatroomMutation struct {
  36040. config
  36041. op Op
  36042. typ string
  36043. id *uint64
  36044. created_at *time.Time
  36045. updated_at *time.Time
  36046. status *uint8
  36047. addstatus *int8
  36048. wx_wxid *string
  36049. chatroom_id *string
  36050. nickname *string
  36051. owner *string
  36052. avatar *string
  36053. member_list *[]string
  36054. appendmember_list []string
  36055. clearedFields map[string]struct{}
  36056. done bool
  36057. oldValue func(context.Context) (*WpChatroom, error)
  36058. predicates []predicate.WpChatroom
  36059. }
  36060. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  36061. // wpchatroomOption allows management of the mutation configuration using functional options.
  36062. type wpchatroomOption func(*WpChatroomMutation)
  36063. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  36064. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  36065. m := &WpChatroomMutation{
  36066. config: c,
  36067. op: op,
  36068. typ: TypeWpChatroom,
  36069. clearedFields: make(map[string]struct{}),
  36070. }
  36071. for _, opt := range opts {
  36072. opt(m)
  36073. }
  36074. return m
  36075. }
  36076. // withWpChatroomID sets the ID field of the mutation.
  36077. func withWpChatroomID(id uint64) wpchatroomOption {
  36078. return func(m *WpChatroomMutation) {
  36079. var (
  36080. err error
  36081. once sync.Once
  36082. value *WpChatroom
  36083. )
  36084. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  36085. once.Do(func() {
  36086. if m.done {
  36087. err = errors.New("querying old values post mutation is not allowed")
  36088. } else {
  36089. value, err = m.Client().WpChatroom.Get(ctx, id)
  36090. }
  36091. })
  36092. return value, err
  36093. }
  36094. m.id = &id
  36095. }
  36096. }
  36097. // withWpChatroom sets the old WpChatroom of the mutation.
  36098. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  36099. return func(m *WpChatroomMutation) {
  36100. m.oldValue = func(context.Context) (*WpChatroom, error) {
  36101. return node, nil
  36102. }
  36103. m.id = &node.ID
  36104. }
  36105. }
  36106. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36107. // executed in a transaction (ent.Tx), a transactional client is returned.
  36108. func (m WpChatroomMutation) Client() *Client {
  36109. client := &Client{config: m.config}
  36110. client.init()
  36111. return client
  36112. }
  36113. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36114. // it returns an error otherwise.
  36115. func (m WpChatroomMutation) Tx() (*Tx, error) {
  36116. if _, ok := m.driver.(*txDriver); !ok {
  36117. return nil, errors.New("ent: mutation is not running in a transaction")
  36118. }
  36119. tx := &Tx{config: m.config}
  36120. tx.init()
  36121. return tx, nil
  36122. }
  36123. // SetID sets the value of the id field. Note that this
  36124. // operation is only accepted on creation of WpChatroom entities.
  36125. func (m *WpChatroomMutation) SetID(id uint64) {
  36126. m.id = &id
  36127. }
  36128. // ID returns the ID value in the mutation. Note that the ID is only available
  36129. // if it was provided to the builder or after it was returned from the database.
  36130. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  36131. if m.id == nil {
  36132. return
  36133. }
  36134. return *m.id, true
  36135. }
  36136. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36137. // That means, if the mutation is applied within a transaction with an isolation level such
  36138. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36139. // or updated by the mutation.
  36140. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  36141. switch {
  36142. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36143. id, exists := m.ID()
  36144. if exists {
  36145. return []uint64{id}, nil
  36146. }
  36147. fallthrough
  36148. case m.op.Is(OpUpdate | OpDelete):
  36149. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  36150. default:
  36151. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36152. }
  36153. }
  36154. // SetCreatedAt sets the "created_at" field.
  36155. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  36156. m.created_at = &t
  36157. }
  36158. // CreatedAt returns the value of the "created_at" field in the mutation.
  36159. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  36160. v := m.created_at
  36161. if v == nil {
  36162. return
  36163. }
  36164. return *v, true
  36165. }
  36166. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  36167. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36168. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36169. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36170. if !m.op.Is(OpUpdateOne) {
  36171. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36172. }
  36173. if m.id == nil || m.oldValue == nil {
  36174. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36175. }
  36176. oldValue, err := m.oldValue(ctx)
  36177. if err != nil {
  36178. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36179. }
  36180. return oldValue.CreatedAt, nil
  36181. }
  36182. // ResetCreatedAt resets all changes to the "created_at" field.
  36183. func (m *WpChatroomMutation) ResetCreatedAt() {
  36184. m.created_at = nil
  36185. }
  36186. // SetUpdatedAt sets the "updated_at" field.
  36187. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  36188. m.updated_at = &t
  36189. }
  36190. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36191. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  36192. v := m.updated_at
  36193. if v == nil {
  36194. return
  36195. }
  36196. return *v, true
  36197. }
  36198. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  36199. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36201. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36202. if !m.op.Is(OpUpdateOne) {
  36203. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36204. }
  36205. if m.id == nil || m.oldValue == nil {
  36206. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36207. }
  36208. oldValue, err := m.oldValue(ctx)
  36209. if err != nil {
  36210. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36211. }
  36212. return oldValue.UpdatedAt, nil
  36213. }
  36214. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36215. func (m *WpChatroomMutation) ResetUpdatedAt() {
  36216. m.updated_at = nil
  36217. }
  36218. // SetStatus sets the "status" field.
  36219. func (m *WpChatroomMutation) SetStatus(u uint8) {
  36220. m.status = &u
  36221. m.addstatus = nil
  36222. }
  36223. // Status returns the value of the "status" field in the mutation.
  36224. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  36225. v := m.status
  36226. if v == nil {
  36227. return
  36228. }
  36229. return *v, true
  36230. }
  36231. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  36232. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36233. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36234. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36235. if !m.op.Is(OpUpdateOne) {
  36236. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36237. }
  36238. if m.id == nil || m.oldValue == nil {
  36239. return v, errors.New("OldStatus requires an ID field in the mutation")
  36240. }
  36241. oldValue, err := m.oldValue(ctx)
  36242. if err != nil {
  36243. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36244. }
  36245. return oldValue.Status, nil
  36246. }
  36247. // AddStatus adds u to the "status" field.
  36248. func (m *WpChatroomMutation) AddStatus(u int8) {
  36249. if m.addstatus != nil {
  36250. *m.addstatus += u
  36251. } else {
  36252. m.addstatus = &u
  36253. }
  36254. }
  36255. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36256. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  36257. v := m.addstatus
  36258. if v == nil {
  36259. return
  36260. }
  36261. return *v, true
  36262. }
  36263. // ClearStatus clears the value of the "status" field.
  36264. func (m *WpChatroomMutation) ClearStatus() {
  36265. m.status = nil
  36266. m.addstatus = nil
  36267. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  36268. }
  36269. // StatusCleared returns if the "status" field was cleared in this mutation.
  36270. func (m *WpChatroomMutation) StatusCleared() bool {
  36271. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  36272. return ok
  36273. }
  36274. // ResetStatus resets all changes to the "status" field.
  36275. func (m *WpChatroomMutation) ResetStatus() {
  36276. m.status = nil
  36277. m.addstatus = nil
  36278. delete(m.clearedFields, wpchatroom.FieldStatus)
  36279. }
  36280. // SetWxWxid sets the "wx_wxid" field.
  36281. func (m *WpChatroomMutation) SetWxWxid(s string) {
  36282. m.wx_wxid = &s
  36283. }
  36284. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36285. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  36286. v := m.wx_wxid
  36287. if v == nil {
  36288. return
  36289. }
  36290. return *v, true
  36291. }
  36292. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  36293. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36295. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36296. if !m.op.Is(OpUpdateOne) {
  36297. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36298. }
  36299. if m.id == nil || m.oldValue == nil {
  36300. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36301. }
  36302. oldValue, err := m.oldValue(ctx)
  36303. if err != nil {
  36304. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36305. }
  36306. return oldValue.WxWxid, nil
  36307. }
  36308. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36309. func (m *WpChatroomMutation) ResetWxWxid() {
  36310. m.wx_wxid = nil
  36311. }
  36312. // SetChatroomID sets the "chatroom_id" field.
  36313. func (m *WpChatroomMutation) SetChatroomID(s string) {
  36314. m.chatroom_id = &s
  36315. }
  36316. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  36317. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  36318. v := m.chatroom_id
  36319. if v == nil {
  36320. return
  36321. }
  36322. return *v, true
  36323. }
  36324. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  36325. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36326. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36327. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  36328. if !m.op.Is(OpUpdateOne) {
  36329. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  36330. }
  36331. if m.id == nil || m.oldValue == nil {
  36332. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  36333. }
  36334. oldValue, err := m.oldValue(ctx)
  36335. if err != nil {
  36336. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  36337. }
  36338. return oldValue.ChatroomID, nil
  36339. }
  36340. // ResetChatroomID resets all changes to the "chatroom_id" field.
  36341. func (m *WpChatroomMutation) ResetChatroomID() {
  36342. m.chatroom_id = nil
  36343. }
  36344. // SetNickname sets the "nickname" field.
  36345. func (m *WpChatroomMutation) SetNickname(s string) {
  36346. m.nickname = &s
  36347. }
  36348. // Nickname returns the value of the "nickname" field in the mutation.
  36349. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  36350. v := m.nickname
  36351. if v == nil {
  36352. return
  36353. }
  36354. return *v, true
  36355. }
  36356. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  36357. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36359. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  36360. if !m.op.Is(OpUpdateOne) {
  36361. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36362. }
  36363. if m.id == nil || m.oldValue == nil {
  36364. return v, errors.New("OldNickname requires an ID field in the mutation")
  36365. }
  36366. oldValue, err := m.oldValue(ctx)
  36367. if err != nil {
  36368. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36369. }
  36370. return oldValue.Nickname, nil
  36371. }
  36372. // ResetNickname resets all changes to the "nickname" field.
  36373. func (m *WpChatroomMutation) ResetNickname() {
  36374. m.nickname = nil
  36375. }
  36376. // SetOwner sets the "owner" field.
  36377. func (m *WpChatroomMutation) SetOwner(s string) {
  36378. m.owner = &s
  36379. }
  36380. // Owner returns the value of the "owner" field in the mutation.
  36381. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  36382. v := m.owner
  36383. if v == nil {
  36384. return
  36385. }
  36386. return *v, true
  36387. }
  36388. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  36389. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36391. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  36392. if !m.op.Is(OpUpdateOne) {
  36393. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  36394. }
  36395. if m.id == nil || m.oldValue == nil {
  36396. return v, errors.New("OldOwner requires an ID field in the mutation")
  36397. }
  36398. oldValue, err := m.oldValue(ctx)
  36399. if err != nil {
  36400. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  36401. }
  36402. return oldValue.Owner, nil
  36403. }
  36404. // ResetOwner resets all changes to the "owner" field.
  36405. func (m *WpChatroomMutation) ResetOwner() {
  36406. m.owner = nil
  36407. }
  36408. // SetAvatar sets the "avatar" field.
  36409. func (m *WpChatroomMutation) SetAvatar(s string) {
  36410. m.avatar = &s
  36411. }
  36412. // Avatar returns the value of the "avatar" field in the mutation.
  36413. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  36414. v := m.avatar
  36415. if v == nil {
  36416. return
  36417. }
  36418. return *v, true
  36419. }
  36420. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  36421. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36423. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36424. if !m.op.Is(OpUpdateOne) {
  36425. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36426. }
  36427. if m.id == nil || m.oldValue == nil {
  36428. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36429. }
  36430. oldValue, err := m.oldValue(ctx)
  36431. if err != nil {
  36432. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36433. }
  36434. return oldValue.Avatar, nil
  36435. }
  36436. // ResetAvatar resets all changes to the "avatar" field.
  36437. func (m *WpChatroomMutation) ResetAvatar() {
  36438. m.avatar = nil
  36439. }
  36440. // SetMemberList sets the "member_list" field.
  36441. func (m *WpChatroomMutation) SetMemberList(s []string) {
  36442. m.member_list = &s
  36443. m.appendmember_list = nil
  36444. }
  36445. // MemberList returns the value of the "member_list" field in the mutation.
  36446. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  36447. v := m.member_list
  36448. if v == nil {
  36449. return
  36450. }
  36451. return *v, true
  36452. }
  36453. // OldMemberList returns the old "member_list" field's value of the WpChatroom entity.
  36454. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36455. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36456. func (m *WpChatroomMutation) OldMemberList(ctx context.Context) (v []string, err error) {
  36457. if !m.op.Is(OpUpdateOne) {
  36458. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  36459. }
  36460. if m.id == nil || m.oldValue == nil {
  36461. return v, errors.New("OldMemberList requires an ID field in the mutation")
  36462. }
  36463. oldValue, err := m.oldValue(ctx)
  36464. if err != nil {
  36465. return v, fmt.Errorf("querying old value for OldMemberList: %w", err)
  36466. }
  36467. return oldValue.MemberList, nil
  36468. }
  36469. // AppendMemberList adds s to the "member_list" field.
  36470. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  36471. m.appendmember_list = append(m.appendmember_list, s...)
  36472. }
  36473. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  36474. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  36475. if len(m.appendmember_list) == 0 {
  36476. return nil, false
  36477. }
  36478. return m.appendmember_list, true
  36479. }
  36480. // ResetMemberList resets all changes to the "member_list" field.
  36481. func (m *WpChatroomMutation) ResetMemberList() {
  36482. m.member_list = nil
  36483. m.appendmember_list = nil
  36484. }
  36485. // Where appends a list predicates to the WpChatroomMutation builder.
  36486. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  36487. m.predicates = append(m.predicates, ps...)
  36488. }
  36489. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  36490. // users can use type-assertion to append predicates that do not depend on any generated package.
  36491. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  36492. p := make([]predicate.WpChatroom, len(ps))
  36493. for i := range ps {
  36494. p[i] = ps[i]
  36495. }
  36496. m.Where(p...)
  36497. }
  36498. // Op returns the operation name.
  36499. func (m *WpChatroomMutation) Op() Op {
  36500. return m.op
  36501. }
  36502. // SetOp allows setting the mutation operation.
  36503. func (m *WpChatroomMutation) SetOp(op Op) {
  36504. m.op = op
  36505. }
  36506. // Type returns the node type of this mutation (WpChatroom).
  36507. func (m *WpChatroomMutation) Type() string {
  36508. return m.typ
  36509. }
  36510. // Fields returns all fields that were changed during this mutation. Note that in
  36511. // order to get all numeric fields that were incremented/decremented, call
  36512. // AddedFields().
  36513. func (m *WpChatroomMutation) Fields() []string {
  36514. fields := make([]string, 0, 9)
  36515. if m.created_at != nil {
  36516. fields = append(fields, wpchatroom.FieldCreatedAt)
  36517. }
  36518. if m.updated_at != nil {
  36519. fields = append(fields, wpchatroom.FieldUpdatedAt)
  36520. }
  36521. if m.status != nil {
  36522. fields = append(fields, wpchatroom.FieldStatus)
  36523. }
  36524. if m.wx_wxid != nil {
  36525. fields = append(fields, wpchatroom.FieldWxWxid)
  36526. }
  36527. if m.chatroom_id != nil {
  36528. fields = append(fields, wpchatroom.FieldChatroomID)
  36529. }
  36530. if m.nickname != nil {
  36531. fields = append(fields, wpchatroom.FieldNickname)
  36532. }
  36533. if m.owner != nil {
  36534. fields = append(fields, wpchatroom.FieldOwner)
  36535. }
  36536. if m.avatar != nil {
  36537. fields = append(fields, wpchatroom.FieldAvatar)
  36538. }
  36539. if m.member_list != nil {
  36540. fields = append(fields, wpchatroom.FieldMemberList)
  36541. }
  36542. return fields
  36543. }
  36544. // Field returns the value of a field with the given name. The second boolean
  36545. // return value indicates that this field was not set, or was not defined in the
  36546. // schema.
  36547. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  36548. switch name {
  36549. case wpchatroom.FieldCreatedAt:
  36550. return m.CreatedAt()
  36551. case wpchatroom.FieldUpdatedAt:
  36552. return m.UpdatedAt()
  36553. case wpchatroom.FieldStatus:
  36554. return m.Status()
  36555. case wpchatroom.FieldWxWxid:
  36556. return m.WxWxid()
  36557. case wpchatroom.FieldChatroomID:
  36558. return m.ChatroomID()
  36559. case wpchatroom.FieldNickname:
  36560. return m.Nickname()
  36561. case wpchatroom.FieldOwner:
  36562. return m.Owner()
  36563. case wpchatroom.FieldAvatar:
  36564. return m.Avatar()
  36565. case wpchatroom.FieldMemberList:
  36566. return m.MemberList()
  36567. }
  36568. return nil, false
  36569. }
  36570. // OldField returns the old value of the field from the database. An error is
  36571. // returned if the mutation operation is not UpdateOne, or the query to the
  36572. // database failed.
  36573. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36574. switch name {
  36575. case wpchatroom.FieldCreatedAt:
  36576. return m.OldCreatedAt(ctx)
  36577. case wpchatroom.FieldUpdatedAt:
  36578. return m.OldUpdatedAt(ctx)
  36579. case wpchatroom.FieldStatus:
  36580. return m.OldStatus(ctx)
  36581. case wpchatroom.FieldWxWxid:
  36582. return m.OldWxWxid(ctx)
  36583. case wpchatroom.FieldChatroomID:
  36584. return m.OldChatroomID(ctx)
  36585. case wpchatroom.FieldNickname:
  36586. return m.OldNickname(ctx)
  36587. case wpchatroom.FieldOwner:
  36588. return m.OldOwner(ctx)
  36589. case wpchatroom.FieldAvatar:
  36590. return m.OldAvatar(ctx)
  36591. case wpchatroom.FieldMemberList:
  36592. return m.OldMemberList(ctx)
  36593. }
  36594. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  36595. }
  36596. // SetField sets the value of a field with the given name. It returns an error if
  36597. // the field is not defined in the schema, or if the type mismatched the field
  36598. // type.
  36599. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  36600. switch name {
  36601. case wpchatroom.FieldCreatedAt:
  36602. v, ok := value.(time.Time)
  36603. if !ok {
  36604. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36605. }
  36606. m.SetCreatedAt(v)
  36607. return nil
  36608. case wpchatroom.FieldUpdatedAt:
  36609. v, ok := value.(time.Time)
  36610. if !ok {
  36611. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36612. }
  36613. m.SetUpdatedAt(v)
  36614. return nil
  36615. case wpchatroom.FieldStatus:
  36616. v, ok := value.(uint8)
  36617. if !ok {
  36618. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36619. }
  36620. m.SetStatus(v)
  36621. return nil
  36622. case wpchatroom.FieldWxWxid:
  36623. v, ok := value.(string)
  36624. if !ok {
  36625. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36626. }
  36627. m.SetWxWxid(v)
  36628. return nil
  36629. case wpchatroom.FieldChatroomID:
  36630. v, ok := value.(string)
  36631. if !ok {
  36632. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36633. }
  36634. m.SetChatroomID(v)
  36635. return nil
  36636. case wpchatroom.FieldNickname:
  36637. v, ok := value.(string)
  36638. if !ok {
  36639. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36640. }
  36641. m.SetNickname(v)
  36642. return nil
  36643. case wpchatroom.FieldOwner:
  36644. v, ok := value.(string)
  36645. if !ok {
  36646. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36647. }
  36648. m.SetOwner(v)
  36649. return nil
  36650. case wpchatroom.FieldAvatar:
  36651. v, ok := value.(string)
  36652. if !ok {
  36653. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36654. }
  36655. m.SetAvatar(v)
  36656. return nil
  36657. case wpchatroom.FieldMemberList:
  36658. v, ok := value.([]string)
  36659. if !ok {
  36660. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36661. }
  36662. m.SetMemberList(v)
  36663. return nil
  36664. }
  36665. return fmt.Errorf("unknown WpChatroom field %s", name)
  36666. }
  36667. // AddedFields returns all numeric fields that were incremented/decremented during
  36668. // this mutation.
  36669. func (m *WpChatroomMutation) AddedFields() []string {
  36670. var fields []string
  36671. if m.addstatus != nil {
  36672. fields = append(fields, wpchatroom.FieldStatus)
  36673. }
  36674. return fields
  36675. }
  36676. // AddedField returns the numeric value that was incremented/decremented on a field
  36677. // with the given name. The second boolean return value indicates that this field
  36678. // was not set, or was not defined in the schema.
  36679. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  36680. switch name {
  36681. case wpchatroom.FieldStatus:
  36682. return m.AddedStatus()
  36683. }
  36684. return nil, false
  36685. }
  36686. // AddField adds the value to the field with the given name. It returns an error if
  36687. // the field is not defined in the schema, or if the type mismatched the field
  36688. // type.
  36689. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  36690. switch name {
  36691. case wpchatroom.FieldStatus:
  36692. v, ok := value.(int8)
  36693. if !ok {
  36694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36695. }
  36696. m.AddStatus(v)
  36697. return nil
  36698. }
  36699. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  36700. }
  36701. // ClearedFields returns all nullable fields that were cleared during this
  36702. // mutation.
  36703. func (m *WpChatroomMutation) ClearedFields() []string {
  36704. var fields []string
  36705. if m.FieldCleared(wpchatroom.FieldStatus) {
  36706. fields = append(fields, wpchatroom.FieldStatus)
  36707. }
  36708. return fields
  36709. }
  36710. // FieldCleared returns a boolean indicating if a field with the given name was
  36711. // cleared in this mutation.
  36712. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  36713. _, ok := m.clearedFields[name]
  36714. return ok
  36715. }
  36716. // ClearField clears the value of the field with the given name. It returns an
  36717. // error if the field is not defined in the schema.
  36718. func (m *WpChatroomMutation) ClearField(name string) error {
  36719. switch name {
  36720. case wpchatroom.FieldStatus:
  36721. m.ClearStatus()
  36722. return nil
  36723. }
  36724. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  36725. }
  36726. // ResetField resets all changes in the mutation for the field with the given name.
  36727. // It returns an error if the field is not defined in the schema.
  36728. func (m *WpChatroomMutation) ResetField(name string) error {
  36729. switch name {
  36730. case wpchatroom.FieldCreatedAt:
  36731. m.ResetCreatedAt()
  36732. return nil
  36733. case wpchatroom.FieldUpdatedAt:
  36734. m.ResetUpdatedAt()
  36735. return nil
  36736. case wpchatroom.FieldStatus:
  36737. m.ResetStatus()
  36738. return nil
  36739. case wpchatroom.FieldWxWxid:
  36740. m.ResetWxWxid()
  36741. return nil
  36742. case wpchatroom.FieldChatroomID:
  36743. m.ResetChatroomID()
  36744. return nil
  36745. case wpchatroom.FieldNickname:
  36746. m.ResetNickname()
  36747. return nil
  36748. case wpchatroom.FieldOwner:
  36749. m.ResetOwner()
  36750. return nil
  36751. case wpchatroom.FieldAvatar:
  36752. m.ResetAvatar()
  36753. return nil
  36754. case wpchatroom.FieldMemberList:
  36755. m.ResetMemberList()
  36756. return nil
  36757. }
  36758. return fmt.Errorf("unknown WpChatroom field %s", name)
  36759. }
  36760. // AddedEdges returns all edge names that were set/added in this mutation.
  36761. func (m *WpChatroomMutation) AddedEdges() []string {
  36762. edges := make([]string, 0, 0)
  36763. return edges
  36764. }
  36765. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36766. // name in this mutation.
  36767. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  36768. return nil
  36769. }
  36770. // RemovedEdges returns all edge names that were removed in this mutation.
  36771. func (m *WpChatroomMutation) RemovedEdges() []string {
  36772. edges := make([]string, 0, 0)
  36773. return edges
  36774. }
  36775. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36776. // the given name in this mutation.
  36777. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  36778. return nil
  36779. }
  36780. // ClearedEdges returns all edge names that were cleared in this mutation.
  36781. func (m *WpChatroomMutation) ClearedEdges() []string {
  36782. edges := make([]string, 0, 0)
  36783. return edges
  36784. }
  36785. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36786. // was cleared in this mutation.
  36787. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  36788. return false
  36789. }
  36790. // ClearEdge clears the value of the edge with the given name. It returns an error
  36791. // if that edge is not defined in the schema.
  36792. func (m *WpChatroomMutation) ClearEdge(name string) error {
  36793. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  36794. }
  36795. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36796. // It returns an error if the edge is not defined in the schema.
  36797. func (m *WpChatroomMutation) ResetEdge(name string) error {
  36798. return fmt.Errorf("unknown WpChatroom edge %s", name)
  36799. }
  36800. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  36801. type WpChatroomMemberMutation struct {
  36802. config
  36803. op Op
  36804. typ string
  36805. id *uint64
  36806. created_at *time.Time
  36807. updated_at *time.Time
  36808. status *uint8
  36809. addstatus *int8
  36810. wx_wxid *string
  36811. wxid *string
  36812. nickname *string
  36813. avatar *string
  36814. clearedFields map[string]struct{}
  36815. done bool
  36816. oldValue func(context.Context) (*WpChatroomMember, error)
  36817. predicates []predicate.WpChatroomMember
  36818. }
  36819. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  36820. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  36821. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  36822. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  36823. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  36824. m := &WpChatroomMemberMutation{
  36825. config: c,
  36826. op: op,
  36827. typ: TypeWpChatroomMember,
  36828. clearedFields: make(map[string]struct{}),
  36829. }
  36830. for _, opt := range opts {
  36831. opt(m)
  36832. }
  36833. return m
  36834. }
  36835. // withWpChatroomMemberID sets the ID field of the mutation.
  36836. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  36837. return func(m *WpChatroomMemberMutation) {
  36838. var (
  36839. err error
  36840. once sync.Once
  36841. value *WpChatroomMember
  36842. )
  36843. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  36844. once.Do(func() {
  36845. if m.done {
  36846. err = errors.New("querying old values post mutation is not allowed")
  36847. } else {
  36848. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  36849. }
  36850. })
  36851. return value, err
  36852. }
  36853. m.id = &id
  36854. }
  36855. }
  36856. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  36857. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  36858. return func(m *WpChatroomMemberMutation) {
  36859. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  36860. return node, nil
  36861. }
  36862. m.id = &node.ID
  36863. }
  36864. }
  36865. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36866. // executed in a transaction (ent.Tx), a transactional client is returned.
  36867. func (m WpChatroomMemberMutation) Client() *Client {
  36868. client := &Client{config: m.config}
  36869. client.init()
  36870. return client
  36871. }
  36872. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36873. // it returns an error otherwise.
  36874. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  36875. if _, ok := m.driver.(*txDriver); !ok {
  36876. return nil, errors.New("ent: mutation is not running in a transaction")
  36877. }
  36878. tx := &Tx{config: m.config}
  36879. tx.init()
  36880. return tx, nil
  36881. }
  36882. // SetID sets the value of the id field. Note that this
  36883. // operation is only accepted on creation of WpChatroomMember entities.
  36884. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  36885. m.id = &id
  36886. }
  36887. // ID returns the ID value in the mutation. Note that the ID is only available
  36888. // if it was provided to the builder or after it was returned from the database.
  36889. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  36890. if m.id == nil {
  36891. return
  36892. }
  36893. return *m.id, true
  36894. }
  36895. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36896. // That means, if the mutation is applied within a transaction with an isolation level such
  36897. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36898. // or updated by the mutation.
  36899. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  36900. switch {
  36901. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36902. id, exists := m.ID()
  36903. if exists {
  36904. return []uint64{id}, nil
  36905. }
  36906. fallthrough
  36907. case m.op.Is(OpUpdate | OpDelete):
  36908. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  36909. default:
  36910. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36911. }
  36912. }
  36913. // SetCreatedAt sets the "created_at" field.
  36914. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  36915. m.created_at = &t
  36916. }
  36917. // CreatedAt returns the value of the "created_at" field in the mutation.
  36918. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  36919. v := m.created_at
  36920. if v == nil {
  36921. return
  36922. }
  36923. return *v, true
  36924. }
  36925. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  36926. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36927. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36928. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36929. if !m.op.Is(OpUpdateOne) {
  36930. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36931. }
  36932. if m.id == nil || m.oldValue == nil {
  36933. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36934. }
  36935. oldValue, err := m.oldValue(ctx)
  36936. if err != nil {
  36937. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36938. }
  36939. return oldValue.CreatedAt, nil
  36940. }
  36941. // ResetCreatedAt resets all changes to the "created_at" field.
  36942. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  36943. m.created_at = nil
  36944. }
  36945. // SetUpdatedAt sets the "updated_at" field.
  36946. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  36947. m.updated_at = &t
  36948. }
  36949. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36950. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  36951. v := m.updated_at
  36952. if v == nil {
  36953. return
  36954. }
  36955. return *v, true
  36956. }
  36957. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  36958. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36959. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36960. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36961. if !m.op.Is(OpUpdateOne) {
  36962. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36963. }
  36964. if m.id == nil || m.oldValue == nil {
  36965. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36966. }
  36967. oldValue, err := m.oldValue(ctx)
  36968. if err != nil {
  36969. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36970. }
  36971. return oldValue.UpdatedAt, nil
  36972. }
  36973. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36974. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  36975. m.updated_at = nil
  36976. }
  36977. // SetStatus sets the "status" field.
  36978. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  36979. m.status = &u
  36980. m.addstatus = nil
  36981. }
  36982. // Status returns the value of the "status" field in the mutation.
  36983. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  36984. v := m.status
  36985. if v == nil {
  36986. return
  36987. }
  36988. return *v, true
  36989. }
  36990. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  36991. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36992. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36993. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36994. if !m.op.Is(OpUpdateOne) {
  36995. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36996. }
  36997. if m.id == nil || m.oldValue == nil {
  36998. return v, errors.New("OldStatus requires an ID field in the mutation")
  36999. }
  37000. oldValue, err := m.oldValue(ctx)
  37001. if err != nil {
  37002. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37003. }
  37004. return oldValue.Status, nil
  37005. }
  37006. // AddStatus adds u to the "status" field.
  37007. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  37008. if m.addstatus != nil {
  37009. *m.addstatus += u
  37010. } else {
  37011. m.addstatus = &u
  37012. }
  37013. }
  37014. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37015. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  37016. v := m.addstatus
  37017. if v == nil {
  37018. return
  37019. }
  37020. return *v, true
  37021. }
  37022. // ClearStatus clears the value of the "status" field.
  37023. func (m *WpChatroomMemberMutation) ClearStatus() {
  37024. m.status = nil
  37025. m.addstatus = nil
  37026. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  37027. }
  37028. // StatusCleared returns if the "status" field was cleared in this mutation.
  37029. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  37030. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  37031. return ok
  37032. }
  37033. // ResetStatus resets all changes to the "status" field.
  37034. func (m *WpChatroomMemberMutation) ResetStatus() {
  37035. m.status = nil
  37036. m.addstatus = nil
  37037. delete(m.clearedFields, wpchatroommember.FieldStatus)
  37038. }
  37039. // SetWxWxid sets the "wx_wxid" field.
  37040. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  37041. m.wx_wxid = &s
  37042. }
  37043. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  37044. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  37045. v := m.wx_wxid
  37046. if v == nil {
  37047. return
  37048. }
  37049. return *v, true
  37050. }
  37051. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  37052. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37053. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37054. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  37055. if !m.op.Is(OpUpdateOne) {
  37056. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  37057. }
  37058. if m.id == nil || m.oldValue == nil {
  37059. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  37060. }
  37061. oldValue, err := m.oldValue(ctx)
  37062. if err != nil {
  37063. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  37064. }
  37065. return oldValue.WxWxid, nil
  37066. }
  37067. // ResetWxWxid resets all changes to the "wx_wxid" field.
  37068. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  37069. m.wx_wxid = nil
  37070. }
  37071. // SetWxid sets the "wxid" field.
  37072. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  37073. m.wxid = &s
  37074. }
  37075. // Wxid returns the value of the "wxid" field in the mutation.
  37076. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  37077. v := m.wxid
  37078. if v == nil {
  37079. return
  37080. }
  37081. return *v, true
  37082. }
  37083. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  37084. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37085. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37086. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  37087. if !m.op.Is(OpUpdateOne) {
  37088. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37089. }
  37090. if m.id == nil || m.oldValue == nil {
  37091. return v, errors.New("OldWxid requires an ID field in the mutation")
  37092. }
  37093. oldValue, err := m.oldValue(ctx)
  37094. if err != nil {
  37095. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37096. }
  37097. return oldValue.Wxid, nil
  37098. }
  37099. // ResetWxid resets all changes to the "wxid" field.
  37100. func (m *WpChatroomMemberMutation) ResetWxid() {
  37101. m.wxid = nil
  37102. }
  37103. // SetNickname sets the "nickname" field.
  37104. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  37105. m.nickname = &s
  37106. }
  37107. // Nickname returns the value of the "nickname" field in the mutation.
  37108. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  37109. v := m.nickname
  37110. if v == nil {
  37111. return
  37112. }
  37113. return *v, true
  37114. }
  37115. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  37116. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37117. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37118. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  37119. if !m.op.Is(OpUpdateOne) {
  37120. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37121. }
  37122. if m.id == nil || m.oldValue == nil {
  37123. return v, errors.New("OldNickname requires an ID field in the mutation")
  37124. }
  37125. oldValue, err := m.oldValue(ctx)
  37126. if err != nil {
  37127. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37128. }
  37129. return oldValue.Nickname, nil
  37130. }
  37131. // ResetNickname resets all changes to the "nickname" field.
  37132. func (m *WpChatroomMemberMutation) ResetNickname() {
  37133. m.nickname = nil
  37134. }
  37135. // SetAvatar sets the "avatar" field.
  37136. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  37137. m.avatar = &s
  37138. }
  37139. // Avatar returns the value of the "avatar" field in the mutation.
  37140. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  37141. v := m.avatar
  37142. if v == nil {
  37143. return
  37144. }
  37145. return *v, true
  37146. }
  37147. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  37148. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37149. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37150. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37151. if !m.op.Is(OpUpdateOne) {
  37152. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37153. }
  37154. if m.id == nil || m.oldValue == nil {
  37155. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37156. }
  37157. oldValue, err := m.oldValue(ctx)
  37158. if err != nil {
  37159. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37160. }
  37161. return oldValue.Avatar, nil
  37162. }
  37163. // ResetAvatar resets all changes to the "avatar" field.
  37164. func (m *WpChatroomMemberMutation) ResetAvatar() {
  37165. m.avatar = nil
  37166. }
  37167. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  37168. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  37169. m.predicates = append(m.predicates, ps...)
  37170. }
  37171. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  37172. // users can use type-assertion to append predicates that do not depend on any generated package.
  37173. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  37174. p := make([]predicate.WpChatroomMember, len(ps))
  37175. for i := range ps {
  37176. p[i] = ps[i]
  37177. }
  37178. m.Where(p...)
  37179. }
  37180. // Op returns the operation name.
  37181. func (m *WpChatroomMemberMutation) Op() Op {
  37182. return m.op
  37183. }
  37184. // SetOp allows setting the mutation operation.
  37185. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  37186. m.op = op
  37187. }
  37188. // Type returns the node type of this mutation (WpChatroomMember).
  37189. func (m *WpChatroomMemberMutation) Type() string {
  37190. return m.typ
  37191. }
  37192. // Fields returns all fields that were changed during this mutation. Note that in
  37193. // order to get all numeric fields that were incremented/decremented, call
  37194. // AddedFields().
  37195. func (m *WpChatroomMemberMutation) Fields() []string {
  37196. fields := make([]string, 0, 7)
  37197. if m.created_at != nil {
  37198. fields = append(fields, wpchatroommember.FieldCreatedAt)
  37199. }
  37200. if m.updated_at != nil {
  37201. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  37202. }
  37203. if m.status != nil {
  37204. fields = append(fields, wpchatroommember.FieldStatus)
  37205. }
  37206. if m.wx_wxid != nil {
  37207. fields = append(fields, wpchatroommember.FieldWxWxid)
  37208. }
  37209. if m.wxid != nil {
  37210. fields = append(fields, wpchatroommember.FieldWxid)
  37211. }
  37212. if m.nickname != nil {
  37213. fields = append(fields, wpchatroommember.FieldNickname)
  37214. }
  37215. if m.avatar != nil {
  37216. fields = append(fields, wpchatroommember.FieldAvatar)
  37217. }
  37218. return fields
  37219. }
  37220. // Field returns the value of a field with the given name. The second boolean
  37221. // return value indicates that this field was not set, or was not defined in the
  37222. // schema.
  37223. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  37224. switch name {
  37225. case wpchatroommember.FieldCreatedAt:
  37226. return m.CreatedAt()
  37227. case wpchatroommember.FieldUpdatedAt:
  37228. return m.UpdatedAt()
  37229. case wpchatroommember.FieldStatus:
  37230. return m.Status()
  37231. case wpchatroommember.FieldWxWxid:
  37232. return m.WxWxid()
  37233. case wpchatroommember.FieldWxid:
  37234. return m.Wxid()
  37235. case wpchatroommember.FieldNickname:
  37236. return m.Nickname()
  37237. case wpchatroommember.FieldAvatar:
  37238. return m.Avatar()
  37239. }
  37240. return nil, false
  37241. }
  37242. // OldField returns the old value of the field from the database. An error is
  37243. // returned if the mutation operation is not UpdateOne, or the query to the
  37244. // database failed.
  37245. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37246. switch name {
  37247. case wpchatroommember.FieldCreatedAt:
  37248. return m.OldCreatedAt(ctx)
  37249. case wpchatroommember.FieldUpdatedAt:
  37250. return m.OldUpdatedAt(ctx)
  37251. case wpchatroommember.FieldStatus:
  37252. return m.OldStatus(ctx)
  37253. case wpchatroommember.FieldWxWxid:
  37254. return m.OldWxWxid(ctx)
  37255. case wpchatroommember.FieldWxid:
  37256. return m.OldWxid(ctx)
  37257. case wpchatroommember.FieldNickname:
  37258. return m.OldNickname(ctx)
  37259. case wpchatroommember.FieldAvatar:
  37260. return m.OldAvatar(ctx)
  37261. }
  37262. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  37263. }
  37264. // SetField sets the value of a field with the given name. It returns an error if
  37265. // the field is not defined in the schema, or if the type mismatched the field
  37266. // type.
  37267. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  37268. switch name {
  37269. case wpchatroommember.FieldCreatedAt:
  37270. v, ok := value.(time.Time)
  37271. if !ok {
  37272. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37273. }
  37274. m.SetCreatedAt(v)
  37275. return nil
  37276. case wpchatroommember.FieldUpdatedAt:
  37277. v, ok := value.(time.Time)
  37278. if !ok {
  37279. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37280. }
  37281. m.SetUpdatedAt(v)
  37282. return nil
  37283. case wpchatroommember.FieldStatus:
  37284. v, ok := value.(uint8)
  37285. if !ok {
  37286. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37287. }
  37288. m.SetStatus(v)
  37289. return nil
  37290. case wpchatroommember.FieldWxWxid:
  37291. v, ok := value.(string)
  37292. if !ok {
  37293. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37294. }
  37295. m.SetWxWxid(v)
  37296. return nil
  37297. case wpchatroommember.FieldWxid:
  37298. v, ok := value.(string)
  37299. if !ok {
  37300. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37301. }
  37302. m.SetWxid(v)
  37303. return nil
  37304. case wpchatroommember.FieldNickname:
  37305. v, ok := value.(string)
  37306. if !ok {
  37307. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37308. }
  37309. m.SetNickname(v)
  37310. return nil
  37311. case wpchatroommember.FieldAvatar:
  37312. v, ok := value.(string)
  37313. if !ok {
  37314. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37315. }
  37316. m.SetAvatar(v)
  37317. return nil
  37318. }
  37319. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37320. }
  37321. // AddedFields returns all numeric fields that were incremented/decremented during
  37322. // this mutation.
  37323. func (m *WpChatroomMemberMutation) AddedFields() []string {
  37324. var fields []string
  37325. if m.addstatus != nil {
  37326. fields = append(fields, wpchatroommember.FieldStatus)
  37327. }
  37328. return fields
  37329. }
  37330. // AddedField returns the numeric value that was incremented/decremented on a field
  37331. // with the given name. The second boolean return value indicates that this field
  37332. // was not set, or was not defined in the schema.
  37333. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  37334. switch name {
  37335. case wpchatroommember.FieldStatus:
  37336. return m.AddedStatus()
  37337. }
  37338. return nil, false
  37339. }
  37340. // AddField adds the value to the field with the given name. It returns an error if
  37341. // the field is not defined in the schema, or if the type mismatched the field
  37342. // type.
  37343. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  37344. switch name {
  37345. case wpchatroommember.FieldStatus:
  37346. v, ok := value.(int8)
  37347. if !ok {
  37348. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37349. }
  37350. m.AddStatus(v)
  37351. return nil
  37352. }
  37353. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  37354. }
  37355. // ClearedFields returns all nullable fields that were cleared during this
  37356. // mutation.
  37357. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  37358. var fields []string
  37359. if m.FieldCleared(wpchatroommember.FieldStatus) {
  37360. fields = append(fields, wpchatroommember.FieldStatus)
  37361. }
  37362. return fields
  37363. }
  37364. // FieldCleared returns a boolean indicating if a field with the given name was
  37365. // cleared in this mutation.
  37366. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  37367. _, ok := m.clearedFields[name]
  37368. return ok
  37369. }
  37370. // ClearField clears the value of the field with the given name. It returns an
  37371. // error if the field is not defined in the schema.
  37372. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  37373. switch name {
  37374. case wpchatroommember.FieldStatus:
  37375. m.ClearStatus()
  37376. return nil
  37377. }
  37378. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  37379. }
  37380. // ResetField resets all changes in the mutation for the field with the given name.
  37381. // It returns an error if the field is not defined in the schema.
  37382. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  37383. switch name {
  37384. case wpchatroommember.FieldCreatedAt:
  37385. m.ResetCreatedAt()
  37386. return nil
  37387. case wpchatroommember.FieldUpdatedAt:
  37388. m.ResetUpdatedAt()
  37389. return nil
  37390. case wpchatroommember.FieldStatus:
  37391. m.ResetStatus()
  37392. return nil
  37393. case wpchatroommember.FieldWxWxid:
  37394. m.ResetWxWxid()
  37395. return nil
  37396. case wpchatroommember.FieldWxid:
  37397. m.ResetWxid()
  37398. return nil
  37399. case wpchatroommember.FieldNickname:
  37400. m.ResetNickname()
  37401. return nil
  37402. case wpchatroommember.FieldAvatar:
  37403. m.ResetAvatar()
  37404. return nil
  37405. }
  37406. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37407. }
  37408. // AddedEdges returns all edge names that were set/added in this mutation.
  37409. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  37410. edges := make([]string, 0, 0)
  37411. return edges
  37412. }
  37413. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37414. // name in this mutation.
  37415. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  37416. return nil
  37417. }
  37418. // RemovedEdges returns all edge names that were removed in this mutation.
  37419. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  37420. edges := make([]string, 0, 0)
  37421. return edges
  37422. }
  37423. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37424. // the given name in this mutation.
  37425. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  37426. return nil
  37427. }
  37428. // ClearedEdges returns all edge names that were cleared in this mutation.
  37429. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  37430. edges := make([]string, 0, 0)
  37431. return edges
  37432. }
  37433. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37434. // was cleared in this mutation.
  37435. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  37436. return false
  37437. }
  37438. // ClearEdge clears the value of the edge with the given name. It returns an error
  37439. // if that edge is not defined in the schema.
  37440. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  37441. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  37442. }
  37443. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37444. // It returns an error if the edge is not defined in the schema.
  37445. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  37446. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  37447. }
  37448. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  37449. type WxMutation struct {
  37450. config
  37451. op Op
  37452. typ string
  37453. id *uint64
  37454. created_at *time.Time
  37455. updated_at *time.Time
  37456. status *uint8
  37457. addstatus *int8
  37458. deleted_at *time.Time
  37459. port *string
  37460. process_id *string
  37461. callback *string
  37462. wxid *string
  37463. account *string
  37464. nickname *string
  37465. tel *string
  37466. head_big *string
  37467. organization_id *uint64
  37468. addorganization_id *int64
  37469. api_base *string
  37470. api_key *string
  37471. allow_list *[]string
  37472. appendallow_list []string
  37473. group_allow_list *[]string
  37474. appendgroup_allow_list []string
  37475. block_list *[]string
  37476. appendblock_list []string
  37477. group_block_list *[]string
  37478. appendgroup_block_list []string
  37479. clearedFields map[string]struct{}
  37480. server *uint64
  37481. clearedserver bool
  37482. agent *uint64
  37483. clearedagent bool
  37484. done bool
  37485. oldValue func(context.Context) (*Wx, error)
  37486. predicates []predicate.Wx
  37487. }
  37488. var _ ent.Mutation = (*WxMutation)(nil)
  37489. // wxOption allows management of the mutation configuration using functional options.
  37490. type wxOption func(*WxMutation)
  37491. // newWxMutation creates new mutation for the Wx entity.
  37492. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  37493. m := &WxMutation{
  37494. config: c,
  37495. op: op,
  37496. typ: TypeWx,
  37497. clearedFields: make(map[string]struct{}),
  37498. }
  37499. for _, opt := range opts {
  37500. opt(m)
  37501. }
  37502. return m
  37503. }
  37504. // withWxID sets the ID field of the mutation.
  37505. func withWxID(id uint64) wxOption {
  37506. return func(m *WxMutation) {
  37507. var (
  37508. err error
  37509. once sync.Once
  37510. value *Wx
  37511. )
  37512. m.oldValue = func(ctx context.Context) (*Wx, error) {
  37513. once.Do(func() {
  37514. if m.done {
  37515. err = errors.New("querying old values post mutation is not allowed")
  37516. } else {
  37517. value, err = m.Client().Wx.Get(ctx, id)
  37518. }
  37519. })
  37520. return value, err
  37521. }
  37522. m.id = &id
  37523. }
  37524. }
  37525. // withWx sets the old Wx of the mutation.
  37526. func withWx(node *Wx) wxOption {
  37527. return func(m *WxMutation) {
  37528. m.oldValue = func(context.Context) (*Wx, error) {
  37529. return node, nil
  37530. }
  37531. m.id = &node.ID
  37532. }
  37533. }
  37534. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37535. // executed in a transaction (ent.Tx), a transactional client is returned.
  37536. func (m WxMutation) Client() *Client {
  37537. client := &Client{config: m.config}
  37538. client.init()
  37539. return client
  37540. }
  37541. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37542. // it returns an error otherwise.
  37543. func (m WxMutation) Tx() (*Tx, error) {
  37544. if _, ok := m.driver.(*txDriver); !ok {
  37545. return nil, errors.New("ent: mutation is not running in a transaction")
  37546. }
  37547. tx := &Tx{config: m.config}
  37548. tx.init()
  37549. return tx, nil
  37550. }
  37551. // SetID sets the value of the id field. Note that this
  37552. // operation is only accepted on creation of Wx entities.
  37553. func (m *WxMutation) SetID(id uint64) {
  37554. m.id = &id
  37555. }
  37556. // ID returns the ID value in the mutation. Note that the ID is only available
  37557. // if it was provided to the builder or after it was returned from the database.
  37558. func (m *WxMutation) ID() (id uint64, exists bool) {
  37559. if m.id == nil {
  37560. return
  37561. }
  37562. return *m.id, true
  37563. }
  37564. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37565. // That means, if the mutation is applied within a transaction with an isolation level such
  37566. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37567. // or updated by the mutation.
  37568. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  37569. switch {
  37570. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37571. id, exists := m.ID()
  37572. if exists {
  37573. return []uint64{id}, nil
  37574. }
  37575. fallthrough
  37576. case m.op.Is(OpUpdate | OpDelete):
  37577. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  37578. default:
  37579. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37580. }
  37581. }
  37582. // SetCreatedAt sets the "created_at" field.
  37583. func (m *WxMutation) SetCreatedAt(t time.Time) {
  37584. m.created_at = &t
  37585. }
  37586. // CreatedAt returns the value of the "created_at" field in the mutation.
  37587. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  37588. v := m.created_at
  37589. if v == nil {
  37590. return
  37591. }
  37592. return *v, true
  37593. }
  37594. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  37595. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37597. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37598. if !m.op.Is(OpUpdateOne) {
  37599. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37600. }
  37601. if m.id == nil || m.oldValue == nil {
  37602. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37603. }
  37604. oldValue, err := m.oldValue(ctx)
  37605. if err != nil {
  37606. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37607. }
  37608. return oldValue.CreatedAt, nil
  37609. }
  37610. // ResetCreatedAt resets all changes to the "created_at" field.
  37611. func (m *WxMutation) ResetCreatedAt() {
  37612. m.created_at = nil
  37613. }
  37614. // SetUpdatedAt sets the "updated_at" field.
  37615. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  37616. m.updated_at = &t
  37617. }
  37618. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37619. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  37620. v := m.updated_at
  37621. if v == nil {
  37622. return
  37623. }
  37624. return *v, true
  37625. }
  37626. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  37627. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37629. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37630. if !m.op.Is(OpUpdateOne) {
  37631. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37632. }
  37633. if m.id == nil || m.oldValue == nil {
  37634. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37635. }
  37636. oldValue, err := m.oldValue(ctx)
  37637. if err != nil {
  37638. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37639. }
  37640. return oldValue.UpdatedAt, nil
  37641. }
  37642. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37643. func (m *WxMutation) ResetUpdatedAt() {
  37644. m.updated_at = nil
  37645. }
  37646. // SetStatus sets the "status" field.
  37647. func (m *WxMutation) SetStatus(u uint8) {
  37648. m.status = &u
  37649. m.addstatus = nil
  37650. }
  37651. // Status returns the value of the "status" field in the mutation.
  37652. func (m *WxMutation) Status() (r uint8, exists bool) {
  37653. v := m.status
  37654. if v == nil {
  37655. return
  37656. }
  37657. return *v, true
  37658. }
  37659. // OldStatus returns the old "status" field's value of the Wx entity.
  37660. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37661. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37662. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37663. if !m.op.Is(OpUpdateOne) {
  37664. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37665. }
  37666. if m.id == nil || m.oldValue == nil {
  37667. return v, errors.New("OldStatus requires an ID field in the mutation")
  37668. }
  37669. oldValue, err := m.oldValue(ctx)
  37670. if err != nil {
  37671. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37672. }
  37673. return oldValue.Status, nil
  37674. }
  37675. // AddStatus adds u to the "status" field.
  37676. func (m *WxMutation) AddStatus(u int8) {
  37677. if m.addstatus != nil {
  37678. *m.addstatus += u
  37679. } else {
  37680. m.addstatus = &u
  37681. }
  37682. }
  37683. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37684. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  37685. v := m.addstatus
  37686. if v == nil {
  37687. return
  37688. }
  37689. return *v, true
  37690. }
  37691. // ClearStatus clears the value of the "status" field.
  37692. func (m *WxMutation) ClearStatus() {
  37693. m.status = nil
  37694. m.addstatus = nil
  37695. m.clearedFields[wx.FieldStatus] = struct{}{}
  37696. }
  37697. // StatusCleared returns if the "status" field was cleared in this mutation.
  37698. func (m *WxMutation) StatusCleared() bool {
  37699. _, ok := m.clearedFields[wx.FieldStatus]
  37700. return ok
  37701. }
  37702. // ResetStatus resets all changes to the "status" field.
  37703. func (m *WxMutation) ResetStatus() {
  37704. m.status = nil
  37705. m.addstatus = nil
  37706. delete(m.clearedFields, wx.FieldStatus)
  37707. }
  37708. // SetDeletedAt sets the "deleted_at" field.
  37709. func (m *WxMutation) SetDeletedAt(t time.Time) {
  37710. m.deleted_at = &t
  37711. }
  37712. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37713. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  37714. v := m.deleted_at
  37715. if v == nil {
  37716. return
  37717. }
  37718. return *v, true
  37719. }
  37720. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  37721. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37723. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37724. if !m.op.Is(OpUpdateOne) {
  37725. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37726. }
  37727. if m.id == nil || m.oldValue == nil {
  37728. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37729. }
  37730. oldValue, err := m.oldValue(ctx)
  37731. if err != nil {
  37732. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37733. }
  37734. return oldValue.DeletedAt, nil
  37735. }
  37736. // ClearDeletedAt clears the value of the "deleted_at" field.
  37737. func (m *WxMutation) ClearDeletedAt() {
  37738. m.deleted_at = nil
  37739. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  37740. }
  37741. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37742. func (m *WxMutation) DeletedAtCleared() bool {
  37743. _, ok := m.clearedFields[wx.FieldDeletedAt]
  37744. return ok
  37745. }
  37746. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37747. func (m *WxMutation) ResetDeletedAt() {
  37748. m.deleted_at = nil
  37749. delete(m.clearedFields, wx.FieldDeletedAt)
  37750. }
  37751. // SetServerID sets the "server_id" field.
  37752. func (m *WxMutation) SetServerID(u uint64) {
  37753. m.server = &u
  37754. }
  37755. // ServerID returns the value of the "server_id" field in the mutation.
  37756. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  37757. v := m.server
  37758. if v == nil {
  37759. return
  37760. }
  37761. return *v, true
  37762. }
  37763. // OldServerID returns the old "server_id" field's value of the Wx entity.
  37764. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37765. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37766. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  37767. if !m.op.Is(OpUpdateOne) {
  37768. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  37769. }
  37770. if m.id == nil || m.oldValue == nil {
  37771. return v, errors.New("OldServerID requires an ID field in the mutation")
  37772. }
  37773. oldValue, err := m.oldValue(ctx)
  37774. if err != nil {
  37775. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  37776. }
  37777. return oldValue.ServerID, nil
  37778. }
  37779. // ClearServerID clears the value of the "server_id" field.
  37780. func (m *WxMutation) ClearServerID() {
  37781. m.server = nil
  37782. m.clearedFields[wx.FieldServerID] = struct{}{}
  37783. }
  37784. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  37785. func (m *WxMutation) ServerIDCleared() bool {
  37786. _, ok := m.clearedFields[wx.FieldServerID]
  37787. return ok
  37788. }
  37789. // ResetServerID resets all changes to the "server_id" field.
  37790. func (m *WxMutation) ResetServerID() {
  37791. m.server = nil
  37792. delete(m.clearedFields, wx.FieldServerID)
  37793. }
  37794. // SetPort sets the "port" field.
  37795. func (m *WxMutation) SetPort(s string) {
  37796. m.port = &s
  37797. }
  37798. // Port returns the value of the "port" field in the mutation.
  37799. func (m *WxMutation) Port() (r string, exists bool) {
  37800. v := m.port
  37801. if v == nil {
  37802. return
  37803. }
  37804. return *v, true
  37805. }
  37806. // OldPort returns the old "port" field's value of the Wx entity.
  37807. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37808. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37809. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  37810. if !m.op.Is(OpUpdateOne) {
  37811. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  37812. }
  37813. if m.id == nil || m.oldValue == nil {
  37814. return v, errors.New("OldPort requires an ID field in the mutation")
  37815. }
  37816. oldValue, err := m.oldValue(ctx)
  37817. if err != nil {
  37818. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  37819. }
  37820. return oldValue.Port, nil
  37821. }
  37822. // ResetPort resets all changes to the "port" field.
  37823. func (m *WxMutation) ResetPort() {
  37824. m.port = nil
  37825. }
  37826. // SetProcessID sets the "process_id" field.
  37827. func (m *WxMutation) SetProcessID(s string) {
  37828. m.process_id = &s
  37829. }
  37830. // ProcessID returns the value of the "process_id" field in the mutation.
  37831. func (m *WxMutation) ProcessID() (r string, exists bool) {
  37832. v := m.process_id
  37833. if v == nil {
  37834. return
  37835. }
  37836. return *v, true
  37837. }
  37838. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  37839. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37841. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  37842. if !m.op.Is(OpUpdateOne) {
  37843. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  37844. }
  37845. if m.id == nil || m.oldValue == nil {
  37846. return v, errors.New("OldProcessID requires an ID field in the mutation")
  37847. }
  37848. oldValue, err := m.oldValue(ctx)
  37849. if err != nil {
  37850. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  37851. }
  37852. return oldValue.ProcessID, nil
  37853. }
  37854. // ResetProcessID resets all changes to the "process_id" field.
  37855. func (m *WxMutation) ResetProcessID() {
  37856. m.process_id = nil
  37857. }
  37858. // SetCallback sets the "callback" field.
  37859. func (m *WxMutation) SetCallback(s string) {
  37860. m.callback = &s
  37861. }
  37862. // Callback returns the value of the "callback" field in the mutation.
  37863. func (m *WxMutation) Callback() (r string, exists bool) {
  37864. v := m.callback
  37865. if v == nil {
  37866. return
  37867. }
  37868. return *v, true
  37869. }
  37870. // OldCallback returns the old "callback" field's value of the Wx entity.
  37871. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37873. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  37874. if !m.op.Is(OpUpdateOne) {
  37875. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37876. }
  37877. if m.id == nil || m.oldValue == nil {
  37878. return v, errors.New("OldCallback requires an ID field in the mutation")
  37879. }
  37880. oldValue, err := m.oldValue(ctx)
  37881. if err != nil {
  37882. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37883. }
  37884. return oldValue.Callback, nil
  37885. }
  37886. // ResetCallback resets all changes to the "callback" field.
  37887. func (m *WxMutation) ResetCallback() {
  37888. m.callback = nil
  37889. }
  37890. // SetWxid sets the "wxid" field.
  37891. func (m *WxMutation) SetWxid(s string) {
  37892. m.wxid = &s
  37893. }
  37894. // Wxid returns the value of the "wxid" field in the mutation.
  37895. func (m *WxMutation) Wxid() (r string, exists bool) {
  37896. v := m.wxid
  37897. if v == nil {
  37898. return
  37899. }
  37900. return *v, true
  37901. }
  37902. // OldWxid returns the old "wxid" field's value of the Wx entity.
  37903. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37905. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  37906. if !m.op.Is(OpUpdateOne) {
  37907. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37908. }
  37909. if m.id == nil || m.oldValue == nil {
  37910. return v, errors.New("OldWxid requires an ID field in the mutation")
  37911. }
  37912. oldValue, err := m.oldValue(ctx)
  37913. if err != nil {
  37914. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37915. }
  37916. return oldValue.Wxid, nil
  37917. }
  37918. // ResetWxid resets all changes to the "wxid" field.
  37919. func (m *WxMutation) ResetWxid() {
  37920. m.wxid = nil
  37921. }
  37922. // SetAccount sets the "account" field.
  37923. func (m *WxMutation) SetAccount(s string) {
  37924. m.account = &s
  37925. }
  37926. // Account returns the value of the "account" field in the mutation.
  37927. func (m *WxMutation) Account() (r string, exists bool) {
  37928. v := m.account
  37929. if v == nil {
  37930. return
  37931. }
  37932. return *v, true
  37933. }
  37934. // OldAccount returns the old "account" field's value of the Wx entity.
  37935. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37936. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37937. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  37938. if !m.op.Is(OpUpdateOne) {
  37939. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37940. }
  37941. if m.id == nil || m.oldValue == nil {
  37942. return v, errors.New("OldAccount requires an ID field in the mutation")
  37943. }
  37944. oldValue, err := m.oldValue(ctx)
  37945. if err != nil {
  37946. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37947. }
  37948. return oldValue.Account, nil
  37949. }
  37950. // ResetAccount resets all changes to the "account" field.
  37951. func (m *WxMutation) ResetAccount() {
  37952. m.account = nil
  37953. }
  37954. // SetNickname sets the "nickname" field.
  37955. func (m *WxMutation) SetNickname(s string) {
  37956. m.nickname = &s
  37957. }
  37958. // Nickname returns the value of the "nickname" field in the mutation.
  37959. func (m *WxMutation) Nickname() (r string, exists bool) {
  37960. v := m.nickname
  37961. if v == nil {
  37962. return
  37963. }
  37964. return *v, true
  37965. }
  37966. // OldNickname returns the old "nickname" field's value of the Wx entity.
  37967. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37968. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37969. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  37970. if !m.op.Is(OpUpdateOne) {
  37971. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37972. }
  37973. if m.id == nil || m.oldValue == nil {
  37974. return v, errors.New("OldNickname requires an ID field in the mutation")
  37975. }
  37976. oldValue, err := m.oldValue(ctx)
  37977. if err != nil {
  37978. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37979. }
  37980. return oldValue.Nickname, nil
  37981. }
  37982. // ResetNickname resets all changes to the "nickname" field.
  37983. func (m *WxMutation) ResetNickname() {
  37984. m.nickname = nil
  37985. }
  37986. // SetTel sets the "tel" field.
  37987. func (m *WxMutation) SetTel(s string) {
  37988. m.tel = &s
  37989. }
  37990. // Tel returns the value of the "tel" field in the mutation.
  37991. func (m *WxMutation) Tel() (r string, exists bool) {
  37992. v := m.tel
  37993. if v == nil {
  37994. return
  37995. }
  37996. return *v, true
  37997. }
  37998. // OldTel returns the old "tel" field's value of the Wx entity.
  37999. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38001. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  38002. if !m.op.Is(OpUpdateOne) {
  38003. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  38004. }
  38005. if m.id == nil || m.oldValue == nil {
  38006. return v, errors.New("OldTel requires an ID field in the mutation")
  38007. }
  38008. oldValue, err := m.oldValue(ctx)
  38009. if err != nil {
  38010. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  38011. }
  38012. return oldValue.Tel, nil
  38013. }
  38014. // ResetTel resets all changes to the "tel" field.
  38015. func (m *WxMutation) ResetTel() {
  38016. m.tel = nil
  38017. }
  38018. // SetHeadBig sets the "head_big" field.
  38019. func (m *WxMutation) SetHeadBig(s string) {
  38020. m.head_big = &s
  38021. }
  38022. // HeadBig returns the value of the "head_big" field in the mutation.
  38023. func (m *WxMutation) HeadBig() (r string, exists bool) {
  38024. v := m.head_big
  38025. if v == nil {
  38026. return
  38027. }
  38028. return *v, true
  38029. }
  38030. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  38031. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38032. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38033. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  38034. if !m.op.Is(OpUpdateOne) {
  38035. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  38036. }
  38037. if m.id == nil || m.oldValue == nil {
  38038. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  38039. }
  38040. oldValue, err := m.oldValue(ctx)
  38041. if err != nil {
  38042. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  38043. }
  38044. return oldValue.HeadBig, nil
  38045. }
  38046. // ResetHeadBig resets all changes to the "head_big" field.
  38047. func (m *WxMutation) ResetHeadBig() {
  38048. m.head_big = nil
  38049. }
  38050. // SetOrganizationID sets the "organization_id" field.
  38051. func (m *WxMutation) SetOrganizationID(u uint64) {
  38052. m.organization_id = &u
  38053. m.addorganization_id = nil
  38054. }
  38055. // OrganizationID returns the value of the "organization_id" field in the mutation.
  38056. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  38057. v := m.organization_id
  38058. if v == nil {
  38059. return
  38060. }
  38061. return *v, true
  38062. }
  38063. // OldOrganizationID returns the old "organization_id" field's value of the Wx entity.
  38064. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38065. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38066. func (m *WxMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  38067. if !m.op.Is(OpUpdateOne) {
  38068. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  38069. }
  38070. if m.id == nil || m.oldValue == nil {
  38071. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  38072. }
  38073. oldValue, err := m.oldValue(ctx)
  38074. if err != nil {
  38075. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  38076. }
  38077. return oldValue.OrganizationID, nil
  38078. }
  38079. // AddOrganizationID adds u to the "organization_id" field.
  38080. func (m *WxMutation) AddOrganizationID(u int64) {
  38081. if m.addorganization_id != nil {
  38082. *m.addorganization_id += u
  38083. } else {
  38084. m.addorganization_id = &u
  38085. }
  38086. }
  38087. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  38088. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  38089. v := m.addorganization_id
  38090. if v == nil {
  38091. return
  38092. }
  38093. return *v, true
  38094. }
  38095. // ClearOrganizationID clears the value of the "organization_id" field.
  38096. func (m *WxMutation) ClearOrganizationID() {
  38097. m.organization_id = nil
  38098. m.addorganization_id = nil
  38099. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  38100. }
  38101. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  38102. func (m *WxMutation) OrganizationIDCleared() bool {
  38103. _, ok := m.clearedFields[wx.FieldOrganizationID]
  38104. return ok
  38105. }
  38106. // ResetOrganizationID resets all changes to the "organization_id" field.
  38107. func (m *WxMutation) ResetOrganizationID() {
  38108. m.organization_id = nil
  38109. m.addorganization_id = nil
  38110. delete(m.clearedFields, wx.FieldOrganizationID)
  38111. }
  38112. // SetAgentID sets the "agent_id" field.
  38113. func (m *WxMutation) SetAgentID(u uint64) {
  38114. m.agent = &u
  38115. }
  38116. // AgentID returns the value of the "agent_id" field in the mutation.
  38117. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  38118. v := m.agent
  38119. if v == nil {
  38120. return
  38121. }
  38122. return *v, true
  38123. }
  38124. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  38125. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38127. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  38128. if !m.op.Is(OpUpdateOne) {
  38129. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38130. }
  38131. if m.id == nil || m.oldValue == nil {
  38132. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38133. }
  38134. oldValue, err := m.oldValue(ctx)
  38135. if err != nil {
  38136. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38137. }
  38138. return oldValue.AgentID, nil
  38139. }
  38140. // ResetAgentID resets all changes to the "agent_id" field.
  38141. func (m *WxMutation) ResetAgentID() {
  38142. m.agent = nil
  38143. }
  38144. // SetAPIBase sets the "api_base" field.
  38145. func (m *WxMutation) SetAPIBase(s string) {
  38146. m.api_base = &s
  38147. }
  38148. // APIBase returns the value of the "api_base" field in the mutation.
  38149. func (m *WxMutation) APIBase() (r string, exists bool) {
  38150. v := m.api_base
  38151. if v == nil {
  38152. return
  38153. }
  38154. return *v, true
  38155. }
  38156. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  38157. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38158. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38159. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38160. if !m.op.Is(OpUpdateOne) {
  38161. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38162. }
  38163. if m.id == nil || m.oldValue == nil {
  38164. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38165. }
  38166. oldValue, err := m.oldValue(ctx)
  38167. if err != nil {
  38168. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38169. }
  38170. return oldValue.APIBase, nil
  38171. }
  38172. // ClearAPIBase clears the value of the "api_base" field.
  38173. func (m *WxMutation) ClearAPIBase() {
  38174. m.api_base = nil
  38175. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  38176. }
  38177. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38178. func (m *WxMutation) APIBaseCleared() bool {
  38179. _, ok := m.clearedFields[wx.FieldAPIBase]
  38180. return ok
  38181. }
  38182. // ResetAPIBase resets all changes to the "api_base" field.
  38183. func (m *WxMutation) ResetAPIBase() {
  38184. m.api_base = nil
  38185. delete(m.clearedFields, wx.FieldAPIBase)
  38186. }
  38187. // SetAPIKey sets the "api_key" field.
  38188. func (m *WxMutation) SetAPIKey(s string) {
  38189. m.api_key = &s
  38190. }
  38191. // APIKey returns the value of the "api_key" field in the mutation.
  38192. func (m *WxMutation) APIKey() (r string, exists bool) {
  38193. v := m.api_key
  38194. if v == nil {
  38195. return
  38196. }
  38197. return *v, true
  38198. }
  38199. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  38200. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38201. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38202. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38203. if !m.op.Is(OpUpdateOne) {
  38204. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38205. }
  38206. if m.id == nil || m.oldValue == nil {
  38207. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38208. }
  38209. oldValue, err := m.oldValue(ctx)
  38210. if err != nil {
  38211. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38212. }
  38213. return oldValue.APIKey, nil
  38214. }
  38215. // ClearAPIKey clears the value of the "api_key" field.
  38216. func (m *WxMutation) ClearAPIKey() {
  38217. m.api_key = nil
  38218. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  38219. }
  38220. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38221. func (m *WxMutation) APIKeyCleared() bool {
  38222. _, ok := m.clearedFields[wx.FieldAPIKey]
  38223. return ok
  38224. }
  38225. // ResetAPIKey resets all changes to the "api_key" field.
  38226. func (m *WxMutation) ResetAPIKey() {
  38227. m.api_key = nil
  38228. delete(m.clearedFields, wx.FieldAPIKey)
  38229. }
  38230. // SetAllowList sets the "allow_list" field.
  38231. func (m *WxMutation) SetAllowList(s []string) {
  38232. m.allow_list = &s
  38233. m.appendallow_list = nil
  38234. }
  38235. // AllowList returns the value of the "allow_list" field in the mutation.
  38236. func (m *WxMutation) AllowList() (r []string, exists bool) {
  38237. v := m.allow_list
  38238. if v == nil {
  38239. return
  38240. }
  38241. return *v, true
  38242. }
  38243. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  38244. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38245. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38246. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38247. if !m.op.Is(OpUpdateOne) {
  38248. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38249. }
  38250. if m.id == nil || m.oldValue == nil {
  38251. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38252. }
  38253. oldValue, err := m.oldValue(ctx)
  38254. if err != nil {
  38255. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38256. }
  38257. return oldValue.AllowList, nil
  38258. }
  38259. // AppendAllowList adds s to the "allow_list" field.
  38260. func (m *WxMutation) AppendAllowList(s []string) {
  38261. m.appendallow_list = append(m.appendallow_list, s...)
  38262. }
  38263. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38264. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  38265. if len(m.appendallow_list) == 0 {
  38266. return nil, false
  38267. }
  38268. return m.appendallow_list, true
  38269. }
  38270. // ResetAllowList resets all changes to the "allow_list" field.
  38271. func (m *WxMutation) ResetAllowList() {
  38272. m.allow_list = nil
  38273. m.appendallow_list = nil
  38274. }
  38275. // SetGroupAllowList sets the "group_allow_list" field.
  38276. func (m *WxMutation) SetGroupAllowList(s []string) {
  38277. m.group_allow_list = &s
  38278. m.appendgroup_allow_list = nil
  38279. }
  38280. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38281. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  38282. v := m.group_allow_list
  38283. if v == nil {
  38284. return
  38285. }
  38286. return *v, true
  38287. }
  38288. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  38289. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38291. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38292. if !m.op.Is(OpUpdateOne) {
  38293. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38294. }
  38295. if m.id == nil || m.oldValue == nil {
  38296. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38297. }
  38298. oldValue, err := m.oldValue(ctx)
  38299. if err != nil {
  38300. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38301. }
  38302. return oldValue.GroupAllowList, nil
  38303. }
  38304. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38305. func (m *WxMutation) AppendGroupAllowList(s []string) {
  38306. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38307. }
  38308. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38309. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  38310. if len(m.appendgroup_allow_list) == 0 {
  38311. return nil, false
  38312. }
  38313. return m.appendgroup_allow_list, true
  38314. }
  38315. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38316. func (m *WxMutation) ResetGroupAllowList() {
  38317. m.group_allow_list = nil
  38318. m.appendgroup_allow_list = nil
  38319. }
  38320. // SetBlockList sets the "block_list" field.
  38321. func (m *WxMutation) SetBlockList(s []string) {
  38322. m.block_list = &s
  38323. m.appendblock_list = nil
  38324. }
  38325. // BlockList returns the value of the "block_list" field in the mutation.
  38326. func (m *WxMutation) BlockList() (r []string, exists bool) {
  38327. v := m.block_list
  38328. if v == nil {
  38329. return
  38330. }
  38331. return *v, true
  38332. }
  38333. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  38334. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38335. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38336. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38337. if !m.op.Is(OpUpdateOne) {
  38338. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38339. }
  38340. if m.id == nil || m.oldValue == nil {
  38341. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38342. }
  38343. oldValue, err := m.oldValue(ctx)
  38344. if err != nil {
  38345. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38346. }
  38347. return oldValue.BlockList, nil
  38348. }
  38349. // AppendBlockList adds s to the "block_list" field.
  38350. func (m *WxMutation) AppendBlockList(s []string) {
  38351. m.appendblock_list = append(m.appendblock_list, s...)
  38352. }
  38353. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38354. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  38355. if len(m.appendblock_list) == 0 {
  38356. return nil, false
  38357. }
  38358. return m.appendblock_list, true
  38359. }
  38360. // ResetBlockList resets all changes to the "block_list" field.
  38361. func (m *WxMutation) ResetBlockList() {
  38362. m.block_list = nil
  38363. m.appendblock_list = nil
  38364. }
  38365. // SetGroupBlockList sets the "group_block_list" field.
  38366. func (m *WxMutation) SetGroupBlockList(s []string) {
  38367. m.group_block_list = &s
  38368. m.appendgroup_block_list = nil
  38369. }
  38370. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38371. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  38372. v := m.group_block_list
  38373. if v == nil {
  38374. return
  38375. }
  38376. return *v, true
  38377. }
  38378. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  38379. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38380. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38381. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38382. if !m.op.Is(OpUpdateOne) {
  38383. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38384. }
  38385. if m.id == nil || m.oldValue == nil {
  38386. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38387. }
  38388. oldValue, err := m.oldValue(ctx)
  38389. if err != nil {
  38390. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38391. }
  38392. return oldValue.GroupBlockList, nil
  38393. }
  38394. // AppendGroupBlockList adds s to the "group_block_list" field.
  38395. func (m *WxMutation) AppendGroupBlockList(s []string) {
  38396. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38397. }
  38398. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38399. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  38400. if len(m.appendgroup_block_list) == 0 {
  38401. return nil, false
  38402. }
  38403. return m.appendgroup_block_list, true
  38404. }
  38405. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38406. func (m *WxMutation) ResetGroupBlockList() {
  38407. m.group_block_list = nil
  38408. m.appendgroup_block_list = nil
  38409. }
  38410. // ClearServer clears the "server" edge to the Server entity.
  38411. func (m *WxMutation) ClearServer() {
  38412. m.clearedserver = true
  38413. m.clearedFields[wx.FieldServerID] = struct{}{}
  38414. }
  38415. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  38416. func (m *WxMutation) ServerCleared() bool {
  38417. return m.ServerIDCleared() || m.clearedserver
  38418. }
  38419. // ServerIDs returns the "server" edge IDs in the mutation.
  38420. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38421. // ServerID instead. It exists only for internal usage by the builders.
  38422. func (m *WxMutation) ServerIDs() (ids []uint64) {
  38423. if id := m.server; id != nil {
  38424. ids = append(ids, *id)
  38425. }
  38426. return
  38427. }
  38428. // ResetServer resets all changes to the "server" edge.
  38429. func (m *WxMutation) ResetServer() {
  38430. m.server = nil
  38431. m.clearedserver = false
  38432. }
  38433. // ClearAgent clears the "agent" edge to the Agent entity.
  38434. func (m *WxMutation) ClearAgent() {
  38435. m.clearedagent = true
  38436. m.clearedFields[wx.FieldAgentID] = struct{}{}
  38437. }
  38438. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38439. func (m *WxMutation) AgentCleared() bool {
  38440. return m.clearedagent
  38441. }
  38442. // AgentIDs returns the "agent" edge IDs in the mutation.
  38443. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38444. // AgentID instead. It exists only for internal usage by the builders.
  38445. func (m *WxMutation) AgentIDs() (ids []uint64) {
  38446. if id := m.agent; id != nil {
  38447. ids = append(ids, *id)
  38448. }
  38449. return
  38450. }
  38451. // ResetAgent resets all changes to the "agent" edge.
  38452. func (m *WxMutation) ResetAgent() {
  38453. m.agent = nil
  38454. m.clearedagent = false
  38455. }
  38456. // Where appends a list predicates to the WxMutation builder.
  38457. func (m *WxMutation) Where(ps ...predicate.Wx) {
  38458. m.predicates = append(m.predicates, ps...)
  38459. }
  38460. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  38461. // users can use type-assertion to append predicates that do not depend on any generated package.
  38462. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  38463. p := make([]predicate.Wx, len(ps))
  38464. for i := range ps {
  38465. p[i] = ps[i]
  38466. }
  38467. m.Where(p...)
  38468. }
  38469. // Op returns the operation name.
  38470. func (m *WxMutation) Op() Op {
  38471. return m.op
  38472. }
  38473. // SetOp allows setting the mutation operation.
  38474. func (m *WxMutation) SetOp(op Op) {
  38475. m.op = op
  38476. }
  38477. // Type returns the node type of this mutation (Wx).
  38478. func (m *WxMutation) Type() string {
  38479. return m.typ
  38480. }
  38481. // Fields returns all fields that were changed during this mutation. Note that in
  38482. // order to get all numeric fields that were incremented/decremented, call
  38483. // AddedFields().
  38484. func (m *WxMutation) Fields() []string {
  38485. fields := make([]string, 0, 21)
  38486. if m.created_at != nil {
  38487. fields = append(fields, wx.FieldCreatedAt)
  38488. }
  38489. if m.updated_at != nil {
  38490. fields = append(fields, wx.FieldUpdatedAt)
  38491. }
  38492. if m.status != nil {
  38493. fields = append(fields, wx.FieldStatus)
  38494. }
  38495. if m.deleted_at != nil {
  38496. fields = append(fields, wx.FieldDeletedAt)
  38497. }
  38498. if m.server != nil {
  38499. fields = append(fields, wx.FieldServerID)
  38500. }
  38501. if m.port != nil {
  38502. fields = append(fields, wx.FieldPort)
  38503. }
  38504. if m.process_id != nil {
  38505. fields = append(fields, wx.FieldProcessID)
  38506. }
  38507. if m.callback != nil {
  38508. fields = append(fields, wx.FieldCallback)
  38509. }
  38510. if m.wxid != nil {
  38511. fields = append(fields, wx.FieldWxid)
  38512. }
  38513. if m.account != nil {
  38514. fields = append(fields, wx.FieldAccount)
  38515. }
  38516. if m.nickname != nil {
  38517. fields = append(fields, wx.FieldNickname)
  38518. }
  38519. if m.tel != nil {
  38520. fields = append(fields, wx.FieldTel)
  38521. }
  38522. if m.head_big != nil {
  38523. fields = append(fields, wx.FieldHeadBig)
  38524. }
  38525. if m.organization_id != nil {
  38526. fields = append(fields, wx.FieldOrganizationID)
  38527. }
  38528. if m.agent != nil {
  38529. fields = append(fields, wx.FieldAgentID)
  38530. }
  38531. if m.api_base != nil {
  38532. fields = append(fields, wx.FieldAPIBase)
  38533. }
  38534. if m.api_key != nil {
  38535. fields = append(fields, wx.FieldAPIKey)
  38536. }
  38537. if m.allow_list != nil {
  38538. fields = append(fields, wx.FieldAllowList)
  38539. }
  38540. if m.group_allow_list != nil {
  38541. fields = append(fields, wx.FieldGroupAllowList)
  38542. }
  38543. if m.block_list != nil {
  38544. fields = append(fields, wx.FieldBlockList)
  38545. }
  38546. if m.group_block_list != nil {
  38547. fields = append(fields, wx.FieldGroupBlockList)
  38548. }
  38549. return fields
  38550. }
  38551. // Field returns the value of a field with the given name. The second boolean
  38552. // return value indicates that this field was not set, or was not defined in the
  38553. // schema.
  38554. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  38555. switch name {
  38556. case wx.FieldCreatedAt:
  38557. return m.CreatedAt()
  38558. case wx.FieldUpdatedAt:
  38559. return m.UpdatedAt()
  38560. case wx.FieldStatus:
  38561. return m.Status()
  38562. case wx.FieldDeletedAt:
  38563. return m.DeletedAt()
  38564. case wx.FieldServerID:
  38565. return m.ServerID()
  38566. case wx.FieldPort:
  38567. return m.Port()
  38568. case wx.FieldProcessID:
  38569. return m.ProcessID()
  38570. case wx.FieldCallback:
  38571. return m.Callback()
  38572. case wx.FieldWxid:
  38573. return m.Wxid()
  38574. case wx.FieldAccount:
  38575. return m.Account()
  38576. case wx.FieldNickname:
  38577. return m.Nickname()
  38578. case wx.FieldTel:
  38579. return m.Tel()
  38580. case wx.FieldHeadBig:
  38581. return m.HeadBig()
  38582. case wx.FieldOrganizationID:
  38583. return m.OrganizationID()
  38584. case wx.FieldAgentID:
  38585. return m.AgentID()
  38586. case wx.FieldAPIBase:
  38587. return m.APIBase()
  38588. case wx.FieldAPIKey:
  38589. return m.APIKey()
  38590. case wx.FieldAllowList:
  38591. return m.AllowList()
  38592. case wx.FieldGroupAllowList:
  38593. return m.GroupAllowList()
  38594. case wx.FieldBlockList:
  38595. return m.BlockList()
  38596. case wx.FieldGroupBlockList:
  38597. return m.GroupBlockList()
  38598. }
  38599. return nil, false
  38600. }
  38601. // OldField returns the old value of the field from the database. An error is
  38602. // returned if the mutation operation is not UpdateOne, or the query to the
  38603. // database failed.
  38604. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38605. switch name {
  38606. case wx.FieldCreatedAt:
  38607. return m.OldCreatedAt(ctx)
  38608. case wx.FieldUpdatedAt:
  38609. return m.OldUpdatedAt(ctx)
  38610. case wx.FieldStatus:
  38611. return m.OldStatus(ctx)
  38612. case wx.FieldDeletedAt:
  38613. return m.OldDeletedAt(ctx)
  38614. case wx.FieldServerID:
  38615. return m.OldServerID(ctx)
  38616. case wx.FieldPort:
  38617. return m.OldPort(ctx)
  38618. case wx.FieldProcessID:
  38619. return m.OldProcessID(ctx)
  38620. case wx.FieldCallback:
  38621. return m.OldCallback(ctx)
  38622. case wx.FieldWxid:
  38623. return m.OldWxid(ctx)
  38624. case wx.FieldAccount:
  38625. return m.OldAccount(ctx)
  38626. case wx.FieldNickname:
  38627. return m.OldNickname(ctx)
  38628. case wx.FieldTel:
  38629. return m.OldTel(ctx)
  38630. case wx.FieldHeadBig:
  38631. return m.OldHeadBig(ctx)
  38632. case wx.FieldOrganizationID:
  38633. return m.OldOrganizationID(ctx)
  38634. case wx.FieldAgentID:
  38635. return m.OldAgentID(ctx)
  38636. case wx.FieldAPIBase:
  38637. return m.OldAPIBase(ctx)
  38638. case wx.FieldAPIKey:
  38639. return m.OldAPIKey(ctx)
  38640. case wx.FieldAllowList:
  38641. return m.OldAllowList(ctx)
  38642. case wx.FieldGroupAllowList:
  38643. return m.OldGroupAllowList(ctx)
  38644. case wx.FieldBlockList:
  38645. return m.OldBlockList(ctx)
  38646. case wx.FieldGroupBlockList:
  38647. return m.OldGroupBlockList(ctx)
  38648. }
  38649. return nil, fmt.Errorf("unknown Wx field %s", name)
  38650. }
  38651. // SetField sets the value of a field with the given name. It returns an error if
  38652. // the field is not defined in the schema, or if the type mismatched the field
  38653. // type.
  38654. func (m *WxMutation) SetField(name string, value ent.Value) error {
  38655. switch name {
  38656. case wx.FieldCreatedAt:
  38657. v, ok := value.(time.Time)
  38658. if !ok {
  38659. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38660. }
  38661. m.SetCreatedAt(v)
  38662. return nil
  38663. case wx.FieldUpdatedAt:
  38664. v, ok := value.(time.Time)
  38665. if !ok {
  38666. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38667. }
  38668. m.SetUpdatedAt(v)
  38669. return nil
  38670. case wx.FieldStatus:
  38671. v, ok := value.(uint8)
  38672. if !ok {
  38673. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38674. }
  38675. m.SetStatus(v)
  38676. return nil
  38677. case wx.FieldDeletedAt:
  38678. v, ok := value.(time.Time)
  38679. if !ok {
  38680. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38681. }
  38682. m.SetDeletedAt(v)
  38683. return nil
  38684. case wx.FieldServerID:
  38685. v, ok := value.(uint64)
  38686. if !ok {
  38687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38688. }
  38689. m.SetServerID(v)
  38690. return nil
  38691. case wx.FieldPort:
  38692. v, ok := value.(string)
  38693. if !ok {
  38694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38695. }
  38696. m.SetPort(v)
  38697. return nil
  38698. case wx.FieldProcessID:
  38699. v, ok := value.(string)
  38700. if !ok {
  38701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38702. }
  38703. m.SetProcessID(v)
  38704. return nil
  38705. case wx.FieldCallback:
  38706. v, ok := value.(string)
  38707. if !ok {
  38708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38709. }
  38710. m.SetCallback(v)
  38711. return nil
  38712. case wx.FieldWxid:
  38713. v, ok := value.(string)
  38714. if !ok {
  38715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38716. }
  38717. m.SetWxid(v)
  38718. return nil
  38719. case wx.FieldAccount:
  38720. v, ok := value.(string)
  38721. if !ok {
  38722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38723. }
  38724. m.SetAccount(v)
  38725. return nil
  38726. case wx.FieldNickname:
  38727. v, ok := value.(string)
  38728. if !ok {
  38729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38730. }
  38731. m.SetNickname(v)
  38732. return nil
  38733. case wx.FieldTel:
  38734. v, ok := value.(string)
  38735. if !ok {
  38736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38737. }
  38738. m.SetTel(v)
  38739. return nil
  38740. case wx.FieldHeadBig:
  38741. v, ok := value.(string)
  38742. if !ok {
  38743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38744. }
  38745. m.SetHeadBig(v)
  38746. return nil
  38747. case wx.FieldOrganizationID:
  38748. v, ok := value.(uint64)
  38749. if !ok {
  38750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38751. }
  38752. m.SetOrganizationID(v)
  38753. return nil
  38754. case wx.FieldAgentID:
  38755. v, ok := value.(uint64)
  38756. if !ok {
  38757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38758. }
  38759. m.SetAgentID(v)
  38760. return nil
  38761. case wx.FieldAPIBase:
  38762. v, ok := value.(string)
  38763. if !ok {
  38764. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38765. }
  38766. m.SetAPIBase(v)
  38767. return nil
  38768. case wx.FieldAPIKey:
  38769. v, ok := value.(string)
  38770. if !ok {
  38771. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38772. }
  38773. m.SetAPIKey(v)
  38774. return nil
  38775. case wx.FieldAllowList:
  38776. v, ok := value.([]string)
  38777. if !ok {
  38778. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38779. }
  38780. m.SetAllowList(v)
  38781. return nil
  38782. case wx.FieldGroupAllowList:
  38783. v, ok := value.([]string)
  38784. if !ok {
  38785. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38786. }
  38787. m.SetGroupAllowList(v)
  38788. return nil
  38789. case wx.FieldBlockList:
  38790. v, ok := value.([]string)
  38791. if !ok {
  38792. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38793. }
  38794. m.SetBlockList(v)
  38795. return nil
  38796. case wx.FieldGroupBlockList:
  38797. v, ok := value.([]string)
  38798. if !ok {
  38799. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38800. }
  38801. m.SetGroupBlockList(v)
  38802. return nil
  38803. }
  38804. return fmt.Errorf("unknown Wx field %s", name)
  38805. }
  38806. // AddedFields returns all numeric fields that were incremented/decremented during
  38807. // this mutation.
  38808. func (m *WxMutation) AddedFields() []string {
  38809. var fields []string
  38810. if m.addstatus != nil {
  38811. fields = append(fields, wx.FieldStatus)
  38812. }
  38813. if m.addorganization_id != nil {
  38814. fields = append(fields, wx.FieldOrganizationID)
  38815. }
  38816. return fields
  38817. }
  38818. // AddedField returns the numeric value that was incremented/decremented on a field
  38819. // with the given name. The second boolean return value indicates that this field
  38820. // was not set, or was not defined in the schema.
  38821. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  38822. switch name {
  38823. case wx.FieldStatus:
  38824. return m.AddedStatus()
  38825. case wx.FieldOrganizationID:
  38826. return m.AddedOrganizationID()
  38827. }
  38828. return nil, false
  38829. }
  38830. // AddField adds the value to the field with the given name. It returns an error if
  38831. // the field is not defined in the schema, or if the type mismatched the field
  38832. // type.
  38833. func (m *WxMutation) AddField(name string, value ent.Value) error {
  38834. switch name {
  38835. case wx.FieldStatus:
  38836. v, ok := value.(int8)
  38837. if !ok {
  38838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38839. }
  38840. m.AddStatus(v)
  38841. return nil
  38842. case wx.FieldOrganizationID:
  38843. v, ok := value.(int64)
  38844. if !ok {
  38845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38846. }
  38847. m.AddOrganizationID(v)
  38848. return nil
  38849. }
  38850. return fmt.Errorf("unknown Wx numeric field %s", name)
  38851. }
  38852. // ClearedFields returns all nullable fields that were cleared during this
  38853. // mutation.
  38854. func (m *WxMutation) ClearedFields() []string {
  38855. var fields []string
  38856. if m.FieldCleared(wx.FieldStatus) {
  38857. fields = append(fields, wx.FieldStatus)
  38858. }
  38859. if m.FieldCleared(wx.FieldDeletedAt) {
  38860. fields = append(fields, wx.FieldDeletedAt)
  38861. }
  38862. if m.FieldCleared(wx.FieldServerID) {
  38863. fields = append(fields, wx.FieldServerID)
  38864. }
  38865. if m.FieldCleared(wx.FieldOrganizationID) {
  38866. fields = append(fields, wx.FieldOrganizationID)
  38867. }
  38868. if m.FieldCleared(wx.FieldAPIBase) {
  38869. fields = append(fields, wx.FieldAPIBase)
  38870. }
  38871. if m.FieldCleared(wx.FieldAPIKey) {
  38872. fields = append(fields, wx.FieldAPIKey)
  38873. }
  38874. return fields
  38875. }
  38876. // FieldCleared returns a boolean indicating if a field with the given name was
  38877. // cleared in this mutation.
  38878. func (m *WxMutation) FieldCleared(name string) bool {
  38879. _, ok := m.clearedFields[name]
  38880. return ok
  38881. }
  38882. // ClearField clears the value of the field with the given name. It returns an
  38883. // error if the field is not defined in the schema.
  38884. func (m *WxMutation) ClearField(name string) error {
  38885. switch name {
  38886. case wx.FieldStatus:
  38887. m.ClearStatus()
  38888. return nil
  38889. case wx.FieldDeletedAt:
  38890. m.ClearDeletedAt()
  38891. return nil
  38892. case wx.FieldServerID:
  38893. m.ClearServerID()
  38894. return nil
  38895. case wx.FieldOrganizationID:
  38896. m.ClearOrganizationID()
  38897. return nil
  38898. case wx.FieldAPIBase:
  38899. m.ClearAPIBase()
  38900. return nil
  38901. case wx.FieldAPIKey:
  38902. m.ClearAPIKey()
  38903. return nil
  38904. }
  38905. return fmt.Errorf("unknown Wx nullable field %s", name)
  38906. }
  38907. // ResetField resets all changes in the mutation for the field with the given name.
  38908. // It returns an error if the field is not defined in the schema.
  38909. func (m *WxMutation) ResetField(name string) error {
  38910. switch name {
  38911. case wx.FieldCreatedAt:
  38912. m.ResetCreatedAt()
  38913. return nil
  38914. case wx.FieldUpdatedAt:
  38915. m.ResetUpdatedAt()
  38916. return nil
  38917. case wx.FieldStatus:
  38918. m.ResetStatus()
  38919. return nil
  38920. case wx.FieldDeletedAt:
  38921. m.ResetDeletedAt()
  38922. return nil
  38923. case wx.FieldServerID:
  38924. m.ResetServerID()
  38925. return nil
  38926. case wx.FieldPort:
  38927. m.ResetPort()
  38928. return nil
  38929. case wx.FieldProcessID:
  38930. m.ResetProcessID()
  38931. return nil
  38932. case wx.FieldCallback:
  38933. m.ResetCallback()
  38934. return nil
  38935. case wx.FieldWxid:
  38936. m.ResetWxid()
  38937. return nil
  38938. case wx.FieldAccount:
  38939. m.ResetAccount()
  38940. return nil
  38941. case wx.FieldNickname:
  38942. m.ResetNickname()
  38943. return nil
  38944. case wx.FieldTel:
  38945. m.ResetTel()
  38946. return nil
  38947. case wx.FieldHeadBig:
  38948. m.ResetHeadBig()
  38949. return nil
  38950. case wx.FieldOrganizationID:
  38951. m.ResetOrganizationID()
  38952. return nil
  38953. case wx.FieldAgentID:
  38954. m.ResetAgentID()
  38955. return nil
  38956. case wx.FieldAPIBase:
  38957. m.ResetAPIBase()
  38958. return nil
  38959. case wx.FieldAPIKey:
  38960. m.ResetAPIKey()
  38961. return nil
  38962. case wx.FieldAllowList:
  38963. m.ResetAllowList()
  38964. return nil
  38965. case wx.FieldGroupAllowList:
  38966. m.ResetGroupAllowList()
  38967. return nil
  38968. case wx.FieldBlockList:
  38969. m.ResetBlockList()
  38970. return nil
  38971. case wx.FieldGroupBlockList:
  38972. m.ResetGroupBlockList()
  38973. return nil
  38974. }
  38975. return fmt.Errorf("unknown Wx field %s", name)
  38976. }
  38977. // AddedEdges returns all edge names that were set/added in this mutation.
  38978. func (m *WxMutation) AddedEdges() []string {
  38979. edges := make([]string, 0, 2)
  38980. if m.server != nil {
  38981. edges = append(edges, wx.EdgeServer)
  38982. }
  38983. if m.agent != nil {
  38984. edges = append(edges, wx.EdgeAgent)
  38985. }
  38986. return edges
  38987. }
  38988. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38989. // name in this mutation.
  38990. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  38991. switch name {
  38992. case wx.EdgeServer:
  38993. if id := m.server; id != nil {
  38994. return []ent.Value{*id}
  38995. }
  38996. case wx.EdgeAgent:
  38997. if id := m.agent; id != nil {
  38998. return []ent.Value{*id}
  38999. }
  39000. }
  39001. return nil
  39002. }
  39003. // RemovedEdges returns all edge names that were removed in this mutation.
  39004. func (m *WxMutation) RemovedEdges() []string {
  39005. edges := make([]string, 0, 2)
  39006. return edges
  39007. }
  39008. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  39009. // the given name in this mutation.
  39010. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  39011. return nil
  39012. }
  39013. // ClearedEdges returns all edge names that were cleared in this mutation.
  39014. func (m *WxMutation) ClearedEdges() []string {
  39015. edges := make([]string, 0, 2)
  39016. if m.clearedserver {
  39017. edges = append(edges, wx.EdgeServer)
  39018. }
  39019. if m.clearedagent {
  39020. edges = append(edges, wx.EdgeAgent)
  39021. }
  39022. return edges
  39023. }
  39024. // EdgeCleared returns a boolean which indicates if the edge with the given name
  39025. // was cleared in this mutation.
  39026. func (m *WxMutation) EdgeCleared(name string) bool {
  39027. switch name {
  39028. case wx.EdgeServer:
  39029. return m.clearedserver
  39030. case wx.EdgeAgent:
  39031. return m.clearedagent
  39032. }
  39033. return false
  39034. }
  39035. // ClearEdge clears the value of the edge with the given name. It returns an error
  39036. // if that edge is not defined in the schema.
  39037. func (m *WxMutation) ClearEdge(name string) error {
  39038. switch name {
  39039. case wx.EdgeServer:
  39040. m.ClearServer()
  39041. return nil
  39042. case wx.EdgeAgent:
  39043. m.ClearAgent()
  39044. return nil
  39045. }
  39046. return fmt.Errorf("unknown Wx unique edge %s", name)
  39047. }
  39048. // ResetEdge resets all changes to the edge with the given name in this mutation.
  39049. // It returns an error if the edge is not defined in the schema.
  39050. func (m *WxMutation) ResetEdge(name string) error {
  39051. switch name {
  39052. case wx.EdgeServer:
  39053. m.ResetServer()
  39054. return nil
  39055. case wx.EdgeAgent:
  39056. m.ResetAgent()
  39057. return nil
  39058. }
  39059. return fmt.Errorf("unknown Wx edge %s", name)
  39060. }
  39061. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  39062. type WxCardMutation struct {
  39063. config
  39064. op Op
  39065. typ string
  39066. id *uint64
  39067. created_at *time.Time
  39068. updated_at *time.Time
  39069. deleted_at *time.Time
  39070. user_id *uint64
  39071. adduser_id *int64
  39072. wx_user_id *uint64
  39073. addwx_user_id *int64
  39074. avatar *string
  39075. logo *string
  39076. name *string
  39077. company *string
  39078. address *string
  39079. phone *string
  39080. official_account *string
  39081. wechat_account *string
  39082. email *string
  39083. api_base *string
  39084. api_key *string
  39085. ai_info *string
  39086. intro *string
  39087. clearedFields map[string]struct{}
  39088. done bool
  39089. oldValue func(context.Context) (*WxCard, error)
  39090. predicates []predicate.WxCard
  39091. }
  39092. var _ ent.Mutation = (*WxCardMutation)(nil)
  39093. // wxcardOption allows management of the mutation configuration using functional options.
  39094. type wxcardOption func(*WxCardMutation)
  39095. // newWxCardMutation creates new mutation for the WxCard entity.
  39096. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  39097. m := &WxCardMutation{
  39098. config: c,
  39099. op: op,
  39100. typ: TypeWxCard,
  39101. clearedFields: make(map[string]struct{}),
  39102. }
  39103. for _, opt := range opts {
  39104. opt(m)
  39105. }
  39106. return m
  39107. }
  39108. // withWxCardID sets the ID field of the mutation.
  39109. func withWxCardID(id uint64) wxcardOption {
  39110. return func(m *WxCardMutation) {
  39111. var (
  39112. err error
  39113. once sync.Once
  39114. value *WxCard
  39115. )
  39116. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  39117. once.Do(func() {
  39118. if m.done {
  39119. err = errors.New("querying old values post mutation is not allowed")
  39120. } else {
  39121. value, err = m.Client().WxCard.Get(ctx, id)
  39122. }
  39123. })
  39124. return value, err
  39125. }
  39126. m.id = &id
  39127. }
  39128. }
  39129. // withWxCard sets the old WxCard of the mutation.
  39130. func withWxCard(node *WxCard) wxcardOption {
  39131. return func(m *WxCardMutation) {
  39132. m.oldValue = func(context.Context) (*WxCard, error) {
  39133. return node, nil
  39134. }
  39135. m.id = &node.ID
  39136. }
  39137. }
  39138. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39139. // executed in a transaction (ent.Tx), a transactional client is returned.
  39140. func (m WxCardMutation) Client() *Client {
  39141. client := &Client{config: m.config}
  39142. client.init()
  39143. return client
  39144. }
  39145. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39146. // it returns an error otherwise.
  39147. func (m WxCardMutation) Tx() (*Tx, error) {
  39148. if _, ok := m.driver.(*txDriver); !ok {
  39149. return nil, errors.New("ent: mutation is not running in a transaction")
  39150. }
  39151. tx := &Tx{config: m.config}
  39152. tx.init()
  39153. return tx, nil
  39154. }
  39155. // SetID sets the value of the id field. Note that this
  39156. // operation is only accepted on creation of WxCard entities.
  39157. func (m *WxCardMutation) SetID(id uint64) {
  39158. m.id = &id
  39159. }
  39160. // ID returns the ID value in the mutation. Note that the ID is only available
  39161. // if it was provided to the builder or after it was returned from the database.
  39162. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  39163. if m.id == nil {
  39164. return
  39165. }
  39166. return *m.id, true
  39167. }
  39168. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39169. // That means, if the mutation is applied within a transaction with an isolation level such
  39170. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39171. // or updated by the mutation.
  39172. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  39173. switch {
  39174. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39175. id, exists := m.ID()
  39176. if exists {
  39177. return []uint64{id}, nil
  39178. }
  39179. fallthrough
  39180. case m.op.Is(OpUpdate | OpDelete):
  39181. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  39182. default:
  39183. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39184. }
  39185. }
  39186. // SetCreatedAt sets the "created_at" field.
  39187. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  39188. m.created_at = &t
  39189. }
  39190. // CreatedAt returns the value of the "created_at" field in the mutation.
  39191. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  39192. v := m.created_at
  39193. if v == nil {
  39194. return
  39195. }
  39196. return *v, true
  39197. }
  39198. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  39199. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39200. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39201. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39202. if !m.op.Is(OpUpdateOne) {
  39203. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39204. }
  39205. if m.id == nil || m.oldValue == nil {
  39206. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39207. }
  39208. oldValue, err := m.oldValue(ctx)
  39209. if err != nil {
  39210. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39211. }
  39212. return oldValue.CreatedAt, nil
  39213. }
  39214. // ResetCreatedAt resets all changes to the "created_at" field.
  39215. func (m *WxCardMutation) ResetCreatedAt() {
  39216. m.created_at = nil
  39217. }
  39218. // SetUpdatedAt sets the "updated_at" field.
  39219. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  39220. m.updated_at = &t
  39221. }
  39222. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39223. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  39224. v := m.updated_at
  39225. if v == nil {
  39226. return
  39227. }
  39228. return *v, true
  39229. }
  39230. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  39231. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39232. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39233. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39234. if !m.op.Is(OpUpdateOne) {
  39235. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39236. }
  39237. if m.id == nil || m.oldValue == nil {
  39238. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39239. }
  39240. oldValue, err := m.oldValue(ctx)
  39241. if err != nil {
  39242. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39243. }
  39244. return oldValue.UpdatedAt, nil
  39245. }
  39246. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39247. func (m *WxCardMutation) ResetUpdatedAt() {
  39248. m.updated_at = nil
  39249. }
  39250. // SetDeletedAt sets the "deleted_at" field.
  39251. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  39252. m.deleted_at = &t
  39253. }
  39254. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39255. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  39256. v := m.deleted_at
  39257. if v == nil {
  39258. return
  39259. }
  39260. return *v, true
  39261. }
  39262. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  39263. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39265. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39266. if !m.op.Is(OpUpdateOne) {
  39267. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39268. }
  39269. if m.id == nil || m.oldValue == nil {
  39270. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39271. }
  39272. oldValue, err := m.oldValue(ctx)
  39273. if err != nil {
  39274. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39275. }
  39276. return oldValue.DeletedAt, nil
  39277. }
  39278. // ClearDeletedAt clears the value of the "deleted_at" field.
  39279. func (m *WxCardMutation) ClearDeletedAt() {
  39280. m.deleted_at = nil
  39281. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  39282. }
  39283. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39284. func (m *WxCardMutation) DeletedAtCleared() bool {
  39285. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  39286. return ok
  39287. }
  39288. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39289. func (m *WxCardMutation) ResetDeletedAt() {
  39290. m.deleted_at = nil
  39291. delete(m.clearedFields, wxcard.FieldDeletedAt)
  39292. }
  39293. // SetUserID sets the "user_id" field.
  39294. func (m *WxCardMutation) SetUserID(u uint64) {
  39295. m.user_id = &u
  39296. m.adduser_id = nil
  39297. }
  39298. // UserID returns the value of the "user_id" field in the mutation.
  39299. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  39300. v := m.user_id
  39301. if v == nil {
  39302. return
  39303. }
  39304. return *v, true
  39305. }
  39306. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  39307. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39308. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39309. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39310. if !m.op.Is(OpUpdateOne) {
  39311. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39312. }
  39313. if m.id == nil || m.oldValue == nil {
  39314. return v, errors.New("OldUserID requires an ID field in the mutation")
  39315. }
  39316. oldValue, err := m.oldValue(ctx)
  39317. if err != nil {
  39318. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39319. }
  39320. return oldValue.UserID, nil
  39321. }
  39322. // AddUserID adds u to the "user_id" field.
  39323. func (m *WxCardMutation) AddUserID(u int64) {
  39324. if m.adduser_id != nil {
  39325. *m.adduser_id += u
  39326. } else {
  39327. m.adduser_id = &u
  39328. }
  39329. }
  39330. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39331. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  39332. v := m.adduser_id
  39333. if v == nil {
  39334. return
  39335. }
  39336. return *v, true
  39337. }
  39338. // ClearUserID clears the value of the "user_id" field.
  39339. func (m *WxCardMutation) ClearUserID() {
  39340. m.user_id = nil
  39341. m.adduser_id = nil
  39342. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  39343. }
  39344. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39345. func (m *WxCardMutation) UserIDCleared() bool {
  39346. _, ok := m.clearedFields[wxcard.FieldUserID]
  39347. return ok
  39348. }
  39349. // ResetUserID resets all changes to the "user_id" field.
  39350. func (m *WxCardMutation) ResetUserID() {
  39351. m.user_id = nil
  39352. m.adduser_id = nil
  39353. delete(m.clearedFields, wxcard.FieldUserID)
  39354. }
  39355. // SetWxUserID sets the "wx_user_id" field.
  39356. func (m *WxCardMutation) SetWxUserID(u uint64) {
  39357. m.wx_user_id = &u
  39358. m.addwx_user_id = nil
  39359. }
  39360. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  39361. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  39362. v := m.wx_user_id
  39363. if v == nil {
  39364. return
  39365. }
  39366. return *v, true
  39367. }
  39368. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  39369. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39370. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39371. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  39372. if !m.op.Is(OpUpdateOne) {
  39373. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  39374. }
  39375. if m.id == nil || m.oldValue == nil {
  39376. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  39377. }
  39378. oldValue, err := m.oldValue(ctx)
  39379. if err != nil {
  39380. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  39381. }
  39382. return oldValue.WxUserID, nil
  39383. }
  39384. // AddWxUserID adds u to the "wx_user_id" field.
  39385. func (m *WxCardMutation) AddWxUserID(u int64) {
  39386. if m.addwx_user_id != nil {
  39387. *m.addwx_user_id += u
  39388. } else {
  39389. m.addwx_user_id = &u
  39390. }
  39391. }
  39392. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  39393. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  39394. v := m.addwx_user_id
  39395. if v == nil {
  39396. return
  39397. }
  39398. return *v, true
  39399. }
  39400. // ClearWxUserID clears the value of the "wx_user_id" field.
  39401. func (m *WxCardMutation) ClearWxUserID() {
  39402. m.wx_user_id = nil
  39403. m.addwx_user_id = nil
  39404. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  39405. }
  39406. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  39407. func (m *WxCardMutation) WxUserIDCleared() bool {
  39408. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  39409. return ok
  39410. }
  39411. // ResetWxUserID resets all changes to the "wx_user_id" field.
  39412. func (m *WxCardMutation) ResetWxUserID() {
  39413. m.wx_user_id = nil
  39414. m.addwx_user_id = nil
  39415. delete(m.clearedFields, wxcard.FieldWxUserID)
  39416. }
  39417. // SetAvatar sets the "avatar" field.
  39418. func (m *WxCardMutation) SetAvatar(s string) {
  39419. m.avatar = &s
  39420. }
  39421. // Avatar returns the value of the "avatar" field in the mutation.
  39422. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  39423. v := m.avatar
  39424. if v == nil {
  39425. return
  39426. }
  39427. return *v, true
  39428. }
  39429. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  39430. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39432. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39433. if !m.op.Is(OpUpdateOne) {
  39434. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39435. }
  39436. if m.id == nil || m.oldValue == nil {
  39437. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39438. }
  39439. oldValue, err := m.oldValue(ctx)
  39440. if err != nil {
  39441. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39442. }
  39443. return oldValue.Avatar, nil
  39444. }
  39445. // ResetAvatar resets all changes to the "avatar" field.
  39446. func (m *WxCardMutation) ResetAvatar() {
  39447. m.avatar = nil
  39448. }
  39449. // SetLogo sets the "logo" field.
  39450. func (m *WxCardMutation) SetLogo(s string) {
  39451. m.logo = &s
  39452. }
  39453. // Logo returns the value of the "logo" field in the mutation.
  39454. func (m *WxCardMutation) Logo() (r string, exists bool) {
  39455. v := m.logo
  39456. if v == nil {
  39457. return
  39458. }
  39459. return *v, true
  39460. }
  39461. // OldLogo returns the old "logo" field's value of the WxCard entity.
  39462. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39464. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  39465. if !m.op.Is(OpUpdateOne) {
  39466. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  39467. }
  39468. if m.id == nil || m.oldValue == nil {
  39469. return v, errors.New("OldLogo requires an ID field in the mutation")
  39470. }
  39471. oldValue, err := m.oldValue(ctx)
  39472. if err != nil {
  39473. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  39474. }
  39475. return oldValue.Logo, nil
  39476. }
  39477. // ResetLogo resets all changes to the "logo" field.
  39478. func (m *WxCardMutation) ResetLogo() {
  39479. m.logo = nil
  39480. }
  39481. // SetName sets the "name" field.
  39482. func (m *WxCardMutation) SetName(s string) {
  39483. m.name = &s
  39484. }
  39485. // Name returns the value of the "name" field in the mutation.
  39486. func (m *WxCardMutation) Name() (r string, exists bool) {
  39487. v := m.name
  39488. if v == nil {
  39489. return
  39490. }
  39491. return *v, true
  39492. }
  39493. // OldName returns the old "name" field's value of the WxCard entity.
  39494. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39496. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  39497. if !m.op.Is(OpUpdateOne) {
  39498. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39499. }
  39500. if m.id == nil || m.oldValue == nil {
  39501. return v, errors.New("OldName requires an ID field in the mutation")
  39502. }
  39503. oldValue, err := m.oldValue(ctx)
  39504. if err != nil {
  39505. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39506. }
  39507. return oldValue.Name, nil
  39508. }
  39509. // ResetName resets all changes to the "name" field.
  39510. func (m *WxCardMutation) ResetName() {
  39511. m.name = nil
  39512. }
  39513. // SetCompany sets the "company" field.
  39514. func (m *WxCardMutation) SetCompany(s string) {
  39515. m.company = &s
  39516. }
  39517. // Company returns the value of the "company" field in the mutation.
  39518. func (m *WxCardMutation) Company() (r string, exists bool) {
  39519. v := m.company
  39520. if v == nil {
  39521. return
  39522. }
  39523. return *v, true
  39524. }
  39525. // OldCompany returns the old "company" field's value of the WxCard entity.
  39526. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39527. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39528. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  39529. if !m.op.Is(OpUpdateOne) {
  39530. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39531. }
  39532. if m.id == nil || m.oldValue == nil {
  39533. return v, errors.New("OldCompany requires an ID field in the mutation")
  39534. }
  39535. oldValue, err := m.oldValue(ctx)
  39536. if err != nil {
  39537. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39538. }
  39539. return oldValue.Company, nil
  39540. }
  39541. // ResetCompany resets all changes to the "company" field.
  39542. func (m *WxCardMutation) ResetCompany() {
  39543. m.company = nil
  39544. }
  39545. // SetAddress sets the "address" field.
  39546. func (m *WxCardMutation) SetAddress(s string) {
  39547. m.address = &s
  39548. }
  39549. // Address returns the value of the "address" field in the mutation.
  39550. func (m *WxCardMutation) Address() (r string, exists bool) {
  39551. v := m.address
  39552. if v == nil {
  39553. return
  39554. }
  39555. return *v, true
  39556. }
  39557. // OldAddress returns the old "address" field's value of the WxCard entity.
  39558. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39560. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  39561. if !m.op.Is(OpUpdateOne) {
  39562. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  39563. }
  39564. if m.id == nil || m.oldValue == nil {
  39565. return v, errors.New("OldAddress requires an ID field in the mutation")
  39566. }
  39567. oldValue, err := m.oldValue(ctx)
  39568. if err != nil {
  39569. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  39570. }
  39571. return oldValue.Address, nil
  39572. }
  39573. // ResetAddress resets all changes to the "address" field.
  39574. func (m *WxCardMutation) ResetAddress() {
  39575. m.address = nil
  39576. }
  39577. // SetPhone sets the "phone" field.
  39578. func (m *WxCardMutation) SetPhone(s string) {
  39579. m.phone = &s
  39580. }
  39581. // Phone returns the value of the "phone" field in the mutation.
  39582. func (m *WxCardMutation) Phone() (r string, exists bool) {
  39583. v := m.phone
  39584. if v == nil {
  39585. return
  39586. }
  39587. return *v, true
  39588. }
  39589. // OldPhone returns the old "phone" field's value of the WxCard entity.
  39590. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39591. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39592. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  39593. if !m.op.Is(OpUpdateOne) {
  39594. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39595. }
  39596. if m.id == nil || m.oldValue == nil {
  39597. return v, errors.New("OldPhone requires an ID field in the mutation")
  39598. }
  39599. oldValue, err := m.oldValue(ctx)
  39600. if err != nil {
  39601. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39602. }
  39603. return oldValue.Phone, nil
  39604. }
  39605. // ResetPhone resets all changes to the "phone" field.
  39606. func (m *WxCardMutation) ResetPhone() {
  39607. m.phone = nil
  39608. }
  39609. // SetOfficialAccount sets the "official_account" field.
  39610. func (m *WxCardMutation) SetOfficialAccount(s string) {
  39611. m.official_account = &s
  39612. }
  39613. // OfficialAccount returns the value of the "official_account" field in the mutation.
  39614. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  39615. v := m.official_account
  39616. if v == nil {
  39617. return
  39618. }
  39619. return *v, true
  39620. }
  39621. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  39622. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39623. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39624. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  39625. if !m.op.Is(OpUpdateOne) {
  39626. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  39627. }
  39628. if m.id == nil || m.oldValue == nil {
  39629. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  39630. }
  39631. oldValue, err := m.oldValue(ctx)
  39632. if err != nil {
  39633. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  39634. }
  39635. return oldValue.OfficialAccount, nil
  39636. }
  39637. // ResetOfficialAccount resets all changes to the "official_account" field.
  39638. func (m *WxCardMutation) ResetOfficialAccount() {
  39639. m.official_account = nil
  39640. }
  39641. // SetWechatAccount sets the "wechat_account" field.
  39642. func (m *WxCardMutation) SetWechatAccount(s string) {
  39643. m.wechat_account = &s
  39644. }
  39645. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  39646. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  39647. v := m.wechat_account
  39648. if v == nil {
  39649. return
  39650. }
  39651. return *v, true
  39652. }
  39653. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  39654. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39656. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  39657. if !m.op.Is(OpUpdateOne) {
  39658. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  39659. }
  39660. if m.id == nil || m.oldValue == nil {
  39661. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  39662. }
  39663. oldValue, err := m.oldValue(ctx)
  39664. if err != nil {
  39665. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  39666. }
  39667. return oldValue.WechatAccount, nil
  39668. }
  39669. // ResetWechatAccount resets all changes to the "wechat_account" field.
  39670. func (m *WxCardMutation) ResetWechatAccount() {
  39671. m.wechat_account = nil
  39672. }
  39673. // SetEmail sets the "email" field.
  39674. func (m *WxCardMutation) SetEmail(s string) {
  39675. m.email = &s
  39676. }
  39677. // Email returns the value of the "email" field in the mutation.
  39678. func (m *WxCardMutation) Email() (r string, exists bool) {
  39679. v := m.email
  39680. if v == nil {
  39681. return
  39682. }
  39683. return *v, true
  39684. }
  39685. // OldEmail returns the old "email" field's value of the WxCard entity.
  39686. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39687. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39688. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  39689. if !m.op.Is(OpUpdateOne) {
  39690. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  39691. }
  39692. if m.id == nil || m.oldValue == nil {
  39693. return v, errors.New("OldEmail requires an ID field in the mutation")
  39694. }
  39695. oldValue, err := m.oldValue(ctx)
  39696. if err != nil {
  39697. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  39698. }
  39699. return oldValue.Email, nil
  39700. }
  39701. // ClearEmail clears the value of the "email" field.
  39702. func (m *WxCardMutation) ClearEmail() {
  39703. m.email = nil
  39704. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  39705. }
  39706. // EmailCleared returns if the "email" field was cleared in this mutation.
  39707. func (m *WxCardMutation) EmailCleared() bool {
  39708. _, ok := m.clearedFields[wxcard.FieldEmail]
  39709. return ok
  39710. }
  39711. // ResetEmail resets all changes to the "email" field.
  39712. func (m *WxCardMutation) ResetEmail() {
  39713. m.email = nil
  39714. delete(m.clearedFields, wxcard.FieldEmail)
  39715. }
  39716. // SetAPIBase sets the "api_base" field.
  39717. func (m *WxCardMutation) SetAPIBase(s string) {
  39718. m.api_base = &s
  39719. }
  39720. // APIBase returns the value of the "api_base" field in the mutation.
  39721. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  39722. v := m.api_base
  39723. if v == nil {
  39724. return
  39725. }
  39726. return *v, true
  39727. }
  39728. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  39729. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39730. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39731. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39732. if !m.op.Is(OpUpdateOne) {
  39733. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39734. }
  39735. if m.id == nil || m.oldValue == nil {
  39736. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39737. }
  39738. oldValue, err := m.oldValue(ctx)
  39739. if err != nil {
  39740. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39741. }
  39742. return oldValue.APIBase, nil
  39743. }
  39744. // ClearAPIBase clears the value of the "api_base" field.
  39745. func (m *WxCardMutation) ClearAPIBase() {
  39746. m.api_base = nil
  39747. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  39748. }
  39749. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39750. func (m *WxCardMutation) APIBaseCleared() bool {
  39751. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  39752. return ok
  39753. }
  39754. // ResetAPIBase resets all changes to the "api_base" field.
  39755. func (m *WxCardMutation) ResetAPIBase() {
  39756. m.api_base = nil
  39757. delete(m.clearedFields, wxcard.FieldAPIBase)
  39758. }
  39759. // SetAPIKey sets the "api_key" field.
  39760. func (m *WxCardMutation) SetAPIKey(s string) {
  39761. m.api_key = &s
  39762. }
  39763. // APIKey returns the value of the "api_key" field in the mutation.
  39764. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  39765. v := m.api_key
  39766. if v == nil {
  39767. return
  39768. }
  39769. return *v, true
  39770. }
  39771. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  39772. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39773. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39774. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39775. if !m.op.Is(OpUpdateOne) {
  39776. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39777. }
  39778. if m.id == nil || m.oldValue == nil {
  39779. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39780. }
  39781. oldValue, err := m.oldValue(ctx)
  39782. if err != nil {
  39783. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39784. }
  39785. return oldValue.APIKey, nil
  39786. }
  39787. // ClearAPIKey clears the value of the "api_key" field.
  39788. func (m *WxCardMutation) ClearAPIKey() {
  39789. m.api_key = nil
  39790. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  39791. }
  39792. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39793. func (m *WxCardMutation) APIKeyCleared() bool {
  39794. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  39795. return ok
  39796. }
  39797. // ResetAPIKey resets all changes to the "api_key" field.
  39798. func (m *WxCardMutation) ResetAPIKey() {
  39799. m.api_key = nil
  39800. delete(m.clearedFields, wxcard.FieldAPIKey)
  39801. }
  39802. // SetAiInfo sets the "ai_info" field.
  39803. func (m *WxCardMutation) SetAiInfo(s string) {
  39804. m.ai_info = &s
  39805. }
  39806. // AiInfo returns the value of the "ai_info" field in the mutation.
  39807. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  39808. v := m.ai_info
  39809. if v == nil {
  39810. return
  39811. }
  39812. return *v, true
  39813. }
  39814. // OldAiInfo returns the old "ai_info" field's value of the WxCard entity.
  39815. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39816. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39817. func (m *WxCardMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  39818. if !m.op.Is(OpUpdateOne) {
  39819. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  39820. }
  39821. if m.id == nil || m.oldValue == nil {
  39822. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  39823. }
  39824. oldValue, err := m.oldValue(ctx)
  39825. if err != nil {
  39826. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  39827. }
  39828. return oldValue.AiInfo, nil
  39829. }
  39830. // ClearAiInfo clears the value of the "ai_info" field.
  39831. func (m *WxCardMutation) ClearAiInfo() {
  39832. m.ai_info = nil
  39833. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  39834. }
  39835. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  39836. func (m *WxCardMutation) AiInfoCleared() bool {
  39837. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  39838. return ok
  39839. }
  39840. // ResetAiInfo resets all changes to the "ai_info" field.
  39841. func (m *WxCardMutation) ResetAiInfo() {
  39842. m.ai_info = nil
  39843. delete(m.clearedFields, wxcard.FieldAiInfo)
  39844. }
  39845. // SetIntro sets the "intro" field.
  39846. func (m *WxCardMutation) SetIntro(s string) {
  39847. m.intro = &s
  39848. }
  39849. // Intro returns the value of the "intro" field in the mutation.
  39850. func (m *WxCardMutation) Intro() (r string, exists bool) {
  39851. v := m.intro
  39852. if v == nil {
  39853. return
  39854. }
  39855. return *v, true
  39856. }
  39857. // OldIntro returns the old "intro" field's value of the WxCard entity.
  39858. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39859. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39860. func (m *WxCardMutation) OldIntro(ctx context.Context) (v string, err error) {
  39861. if !m.op.Is(OpUpdateOne) {
  39862. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  39863. }
  39864. if m.id == nil || m.oldValue == nil {
  39865. return v, errors.New("OldIntro requires an ID field in the mutation")
  39866. }
  39867. oldValue, err := m.oldValue(ctx)
  39868. if err != nil {
  39869. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  39870. }
  39871. return oldValue.Intro, nil
  39872. }
  39873. // ClearIntro clears the value of the "intro" field.
  39874. func (m *WxCardMutation) ClearIntro() {
  39875. m.intro = nil
  39876. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  39877. }
  39878. // IntroCleared returns if the "intro" field was cleared in this mutation.
  39879. func (m *WxCardMutation) IntroCleared() bool {
  39880. _, ok := m.clearedFields[wxcard.FieldIntro]
  39881. return ok
  39882. }
  39883. // ResetIntro resets all changes to the "intro" field.
  39884. func (m *WxCardMutation) ResetIntro() {
  39885. m.intro = nil
  39886. delete(m.clearedFields, wxcard.FieldIntro)
  39887. }
  39888. // Where appends a list predicates to the WxCardMutation builder.
  39889. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  39890. m.predicates = append(m.predicates, ps...)
  39891. }
  39892. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  39893. // users can use type-assertion to append predicates that do not depend on any generated package.
  39894. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  39895. p := make([]predicate.WxCard, len(ps))
  39896. for i := range ps {
  39897. p[i] = ps[i]
  39898. }
  39899. m.Where(p...)
  39900. }
  39901. // Op returns the operation name.
  39902. func (m *WxCardMutation) Op() Op {
  39903. return m.op
  39904. }
  39905. // SetOp allows setting the mutation operation.
  39906. func (m *WxCardMutation) SetOp(op Op) {
  39907. m.op = op
  39908. }
  39909. // Type returns the node type of this mutation (WxCard).
  39910. func (m *WxCardMutation) Type() string {
  39911. return m.typ
  39912. }
  39913. // Fields returns all fields that were changed during this mutation. Note that in
  39914. // order to get all numeric fields that were incremented/decremented, call
  39915. // AddedFields().
  39916. func (m *WxCardMutation) Fields() []string {
  39917. fields := make([]string, 0, 18)
  39918. if m.created_at != nil {
  39919. fields = append(fields, wxcard.FieldCreatedAt)
  39920. }
  39921. if m.updated_at != nil {
  39922. fields = append(fields, wxcard.FieldUpdatedAt)
  39923. }
  39924. if m.deleted_at != nil {
  39925. fields = append(fields, wxcard.FieldDeletedAt)
  39926. }
  39927. if m.user_id != nil {
  39928. fields = append(fields, wxcard.FieldUserID)
  39929. }
  39930. if m.wx_user_id != nil {
  39931. fields = append(fields, wxcard.FieldWxUserID)
  39932. }
  39933. if m.avatar != nil {
  39934. fields = append(fields, wxcard.FieldAvatar)
  39935. }
  39936. if m.logo != nil {
  39937. fields = append(fields, wxcard.FieldLogo)
  39938. }
  39939. if m.name != nil {
  39940. fields = append(fields, wxcard.FieldName)
  39941. }
  39942. if m.company != nil {
  39943. fields = append(fields, wxcard.FieldCompany)
  39944. }
  39945. if m.address != nil {
  39946. fields = append(fields, wxcard.FieldAddress)
  39947. }
  39948. if m.phone != nil {
  39949. fields = append(fields, wxcard.FieldPhone)
  39950. }
  39951. if m.official_account != nil {
  39952. fields = append(fields, wxcard.FieldOfficialAccount)
  39953. }
  39954. if m.wechat_account != nil {
  39955. fields = append(fields, wxcard.FieldWechatAccount)
  39956. }
  39957. if m.email != nil {
  39958. fields = append(fields, wxcard.FieldEmail)
  39959. }
  39960. if m.api_base != nil {
  39961. fields = append(fields, wxcard.FieldAPIBase)
  39962. }
  39963. if m.api_key != nil {
  39964. fields = append(fields, wxcard.FieldAPIKey)
  39965. }
  39966. if m.ai_info != nil {
  39967. fields = append(fields, wxcard.FieldAiInfo)
  39968. }
  39969. if m.intro != nil {
  39970. fields = append(fields, wxcard.FieldIntro)
  39971. }
  39972. return fields
  39973. }
  39974. // Field returns the value of a field with the given name. The second boolean
  39975. // return value indicates that this field was not set, or was not defined in the
  39976. // schema.
  39977. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  39978. switch name {
  39979. case wxcard.FieldCreatedAt:
  39980. return m.CreatedAt()
  39981. case wxcard.FieldUpdatedAt:
  39982. return m.UpdatedAt()
  39983. case wxcard.FieldDeletedAt:
  39984. return m.DeletedAt()
  39985. case wxcard.FieldUserID:
  39986. return m.UserID()
  39987. case wxcard.FieldWxUserID:
  39988. return m.WxUserID()
  39989. case wxcard.FieldAvatar:
  39990. return m.Avatar()
  39991. case wxcard.FieldLogo:
  39992. return m.Logo()
  39993. case wxcard.FieldName:
  39994. return m.Name()
  39995. case wxcard.FieldCompany:
  39996. return m.Company()
  39997. case wxcard.FieldAddress:
  39998. return m.Address()
  39999. case wxcard.FieldPhone:
  40000. return m.Phone()
  40001. case wxcard.FieldOfficialAccount:
  40002. return m.OfficialAccount()
  40003. case wxcard.FieldWechatAccount:
  40004. return m.WechatAccount()
  40005. case wxcard.FieldEmail:
  40006. return m.Email()
  40007. case wxcard.FieldAPIBase:
  40008. return m.APIBase()
  40009. case wxcard.FieldAPIKey:
  40010. return m.APIKey()
  40011. case wxcard.FieldAiInfo:
  40012. return m.AiInfo()
  40013. case wxcard.FieldIntro:
  40014. return m.Intro()
  40015. }
  40016. return nil, false
  40017. }
  40018. // OldField returns the old value of the field from the database. An error is
  40019. // returned if the mutation operation is not UpdateOne, or the query to the
  40020. // database failed.
  40021. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40022. switch name {
  40023. case wxcard.FieldCreatedAt:
  40024. return m.OldCreatedAt(ctx)
  40025. case wxcard.FieldUpdatedAt:
  40026. return m.OldUpdatedAt(ctx)
  40027. case wxcard.FieldDeletedAt:
  40028. return m.OldDeletedAt(ctx)
  40029. case wxcard.FieldUserID:
  40030. return m.OldUserID(ctx)
  40031. case wxcard.FieldWxUserID:
  40032. return m.OldWxUserID(ctx)
  40033. case wxcard.FieldAvatar:
  40034. return m.OldAvatar(ctx)
  40035. case wxcard.FieldLogo:
  40036. return m.OldLogo(ctx)
  40037. case wxcard.FieldName:
  40038. return m.OldName(ctx)
  40039. case wxcard.FieldCompany:
  40040. return m.OldCompany(ctx)
  40041. case wxcard.FieldAddress:
  40042. return m.OldAddress(ctx)
  40043. case wxcard.FieldPhone:
  40044. return m.OldPhone(ctx)
  40045. case wxcard.FieldOfficialAccount:
  40046. return m.OldOfficialAccount(ctx)
  40047. case wxcard.FieldWechatAccount:
  40048. return m.OldWechatAccount(ctx)
  40049. case wxcard.FieldEmail:
  40050. return m.OldEmail(ctx)
  40051. case wxcard.FieldAPIBase:
  40052. return m.OldAPIBase(ctx)
  40053. case wxcard.FieldAPIKey:
  40054. return m.OldAPIKey(ctx)
  40055. case wxcard.FieldAiInfo:
  40056. return m.OldAiInfo(ctx)
  40057. case wxcard.FieldIntro:
  40058. return m.OldIntro(ctx)
  40059. }
  40060. return nil, fmt.Errorf("unknown WxCard field %s", name)
  40061. }
  40062. // SetField sets the value of a field with the given name. It returns an error if
  40063. // the field is not defined in the schema, or if the type mismatched the field
  40064. // type.
  40065. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  40066. switch name {
  40067. case wxcard.FieldCreatedAt:
  40068. v, ok := value.(time.Time)
  40069. if !ok {
  40070. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40071. }
  40072. m.SetCreatedAt(v)
  40073. return nil
  40074. case wxcard.FieldUpdatedAt:
  40075. v, ok := value.(time.Time)
  40076. if !ok {
  40077. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40078. }
  40079. m.SetUpdatedAt(v)
  40080. return nil
  40081. case wxcard.FieldDeletedAt:
  40082. v, ok := value.(time.Time)
  40083. if !ok {
  40084. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40085. }
  40086. m.SetDeletedAt(v)
  40087. return nil
  40088. case wxcard.FieldUserID:
  40089. v, ok := value.(uint64)
  40090. if !ok {
  40091. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40092. }
  40093. m.SetUserID(v)
  40094. return nil
  40095. case wxcard.FieldWxUserID:
  40096. v, ok := value.(uint64)
  40097. if !ok {
  40098. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40099. }
  40100. m.SetWxUserID(v)
  40101. return nil
  40102. case wxcard.FieldAvatar:
  40103. v, ok := value.(string)
  40104. if !ok {
  40105. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40106. }
  40107. m.SetAvatar(v)
  40108. return nil
  40109. case wxcard.FieldLogo:
  40110. v, ok := value.(string)
  40111. if !ok {
  40112. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40113. }
  40114. m.SetLogo(v)
  40115. return nil
  40116. case wxcard.FieldName:
  40117. v, ok := value.(string)
  40118. if !ok {
  40119. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40120. }
  40121. m.SetName(v)
  40122. return nil
  40123. case wxcard.FieldCompany:
  40124. v, ok := value.(string)
  40125. if !ok {
  40126. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40127. }
  40128. m.SetCompany(v)
  40129. return nil
  40130. case wxcard.FieldAddress:
  40131. v, ok := value.(string)
  40132. if !ok {
  40133. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40134. }
  40135. m.SetAddress(v)
  40136. return nil
  40137. case wxcard.FieldPhone:
  40138. v, ok := value.(string)
  40139. if !ok {
  40140. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40141. }
  40142. m.SetPhone(v)
  40143. return nil
  40144. case wxcard.FieldOfficialAccount:
  40145. v, ok := value.(string)
  40146. if !ok {
  40147. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40148. }
  40149. m.SetOfficialAccount(v)
  40150. return nil
  40151. case wxcard.FieldWechatAccount:
  40152. v, ok := value.(string)
  40153. if !ok {
  40154. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40155. }
  40156. m.SetWechatAccount(v)
  40157. return nil
  40158. case wxcard.FieldEmail:
  40159. v, ok := value.(string)
  40160. if !ok {
  40161. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40162. }
  40163. m.SetEmail(v)
  40164. return nil
  40165. case wxcard.FieldAPIBase:
  40166. v, ok := value.(string)
  40167. if !ok {
  40168. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40169. }
  40170. m.SetAPIBase(v)
  40171. return nil
  40172. case wxcard.FieldAPIKey:
  40173. v, ok := value.(string)
  40174. if !ok {
  40175. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40176. }
  40177. m.SetAPIKey(v)
  40178. return nil
  40179. case wxcard.FieldAiInfo:
  40180. v, ok := value.(string)
  40181. if !ok {
  40182. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40183. }
  40184. m.SetAiInfo(v)
  40185. return nil
  40186. case wxcard.FieldIntro:
  40187. v, ok := value.(string)
  40188. if !ok {
  40189. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40190. }
  40191. m.SetIntro(v)
  40192. return nil
  40193. }
  40194. return fmt.Errorf("unknown WxCard field %s", name)
  40195. }
  40196. // AddedFields returns all numeric fields that were incremented/decremented during
  40197. // this mutation.
  40198. func (m *WxCardMutation) AddedFields() []string {
  40199. var fields []string
  40200. if m.adduser_id != nil {
  40201. fields = append(fields, wxcard.FieldUserID)
  40202. }
  40203. if m.addwx_user_id != nil {
  40204. fields = append(fields, wxcard.FieldWxUserID)
  40205. }
  40206. return fields
  40207. }
  40208. // AddedField returns the numeric value that was incremented/decremented on a field
  40209. // with the given name. The second boolean return value indicates that this field
  40210. // was not set, or was not defined in the schema.
  40211. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  40212. switch name {
  40213. case wxcard.FieldUserID:
  40214. return m.AddedUserID()
  40215. case wxcard.FieldWxUserID:
  40216. return m.AddedWxUserID()
  40217. }
  40218. return nil, false
  40219. }
  40220. // AddField adds the value to the field with the given name. It returns an error if
  40221. // the field is not defined in the schema, or if the type mismatched the field
  40222. // type.
  40223. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  40224. switch name {
  40225. case wxcard.FieldUserID:
  40226. v, ok := value.(int64)
  40227. if !ok {
  40228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40229. }
  40230. m.AddUserID(v)
  40231. return nil
  40232. case wxcard.FieldWxUserID:
  40233. v, ok := value.(int64)
  40234. if !ok {
  40235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40236. }
  40237. m.AddWxUserID(v)
  40238. return nil
  40239. }
  40240. return fmt.Errorf("unknown WxCard numeric field %s", name)
  40241. }
  40242. // ClearedFields returns all nullable fields that were cleared during this
  40243. // mutation.
  40244. func (m *WxCardMutation) ClearedFields() []string {
  40245. var fields []string
  40246. if m.FieldCleared(wxcard.FieldDeletedAt) {
  40247. fields = append(fields, wxcard.FieldDeletedAt)
  40248. }
  40249. if m.FieldCleared(wxcard.FieldUserID) {
  40250. fields = append(fields, wxcard.FieldUserID)
  40251. }
  40252. if m.FieldCleared(wxcard.FieldWxUserID) {
  40253. fields = append(fields, wxcard.FieldWxUserID)
  40254. }
  40255. if m.FieldCleared(wxcard.FieldEmail) {
  40256. fields = append(fields, wxcard.FieldEmail)
  40257. }
  40258. if m.FieldCleared(wxcard.FieldAPIBase) {
  40259. fields = append(fields, wxcard.FieldAPIBase)
  40260. }
  40261. if m.FieldCleared(wxcard.FieldAPIKey) {
  40262. fields = append(fields, wxcard.FieldAPIKey)
  40263. }
  40264. if m.FieldCleared(wxcard.FieldAiInfo) {
  40265. fields = append(fields, wxcard.FieldAiInfo)
  40266. }
  40267. if m.FieldCleared(wxcard.FieldIntro) {
  40268. fields = append(fields, wxcard.FieldIntro)
  40269. }
  40270. return fields
  40271. }
  40272. // FieldCleared returns a boolean indicating if a field with the given name was
  40273. // cleared in this mutation.
  40274. func (m *WxCardMutation) FieldCleared(name string) bool {
  40275. _, ok := m.clearedFields[name]
  40276. return ok
  40277. }
  40278. // ClearField clears the value of the field with the given name. It returns an
  40279. // error if the field is not defined in the schema.
  40280. func (m *WxCardMutation) ClearField(name string) error {
  40281. switch name {
  40282. case wxcard.FieldDeletedAt:
  40283. m.ClearDeletedAt()
  40284. return nil
  40285. case wxcard.FieldUserID:
  40286. m.ClearUserID()
  40287. return nil
  40288. case wxcard.FieldWxUserID:
  40289. m.ClearWxUserID()
  40290. return nil
  40291. case wxcard.FieldEmail:
  40292. m.ClearEmail()
  40293. return nil
  40294. case wxcard.FieldAPIBase:
  40295. m.ClearAPIBase()
  40296. return nil
  40297. case wxcard.FieldAPIKey:
  40298. m.ClearAPIKey()
  40299. return nil
  40300. case wxcard.FieldAiInfo:
  40301. m.ClearAiInfo()
  40302. return nil
  40303. case wxcard.FieldIntro:
  40304. m.ClearIntro()
  40305. return nil
  40306. }
  40307. return fmt.Errorf("unknown WxCard nullable field %s", name)
  40308. }
  40309. // ResetField resets all changes in the mutation for the field with the given name.
  40310. // It returns an error if the field is not defined in the schema.
  40311. func (m *WxCardMutation) ResetField(name string) error {
  40312. switch name {
  40313. case wxcard.FieldCreatedAt:
  40314. m.ResetCreatedAt()
  40315. return nil
  40316. case wxcard.FieldUpdatedAt:
  40317. m.ResetUpdatedAt()
  40318. return nil
  40319. case wxcard.FieldDeletedAt:
  40320. m.ResetDeletedAt()
  40321. return nil
  40322. case wxcard.FieldUserID:
  40323. m.ResetUserID()
  40324. return nil
  40325. case wxcard.FieldWxUserID:
  40326. m.ResetWxUserID()
  40327. return nil
  40328. case wxcard.FieldAvatar:
  40329. m.ResetAvatar()
  40330. return nil
  40331. case wxcard.FieldLogo:
  40332. m.ResetLogo()
  40333. return nil
  40334. case wxcard.FieldName:
  40335. m.ResetName()
  40336. return nil
  40337. case wxcard.FieldCompany:
  40338. m.ResetCompany()
  40339. return nil
  40340. case wxcard.FieldAddress:
  40341. m.ResetAddress()
  40342. return nil
  40343. case wxcard.FieldPhone:
  40344. m.ResetPhone()
  40345. return nil
  40346. case wxcard.FieldOfficialAccount:
  40347. m.ResetOfficialAccount()
  40348. return nil
  40349. case wxcard.FieldWechatAccount:
  40350. m.ResetWechatAccount()
  40351. return nil
  40352. case wxcard.FieldEmail:
  40353. m.ResetEmail()
  40354. return nil
  40355. case wxcard.FieldAPIBase:
  40356. m.ResetAPIBase()
  40357. return nil
  40358. case wxcard.FieldAPIKey:
  40359. m.ResetAPIKey()
  40360. return nil
  40361. case wxcard.FieldAiInfo:
  40362. m.ResetAiInfo()
  40363. return nil
  40364. case wxcard.FieldIntro:
  40365. m.ResetIntro()
  40366. return nil
  40367. }
  40368. return fmt.Errorf("unknown WxCard field %s", name)
  40369. }
  40370. // AddedEdges returns all edge names that were set/added in this mutation.
  40371. func (m *WxCardMutation) AddedEdges() []string {
  40372. edges := make([]string, 0, 0)
  40373. return edges
  40374. }
  40375. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40376. // name in this mutation.
  40377. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  40378. return nil
  40379. }
  40380. // RemovedEdges returns all edge names that were removed in this mutation.
  40381. func (m *WxCardMutation) RemovedEdges() []string {
  40382. edges := make([]string, 0, 0)
  40383. return edges
  40384. }
  40385. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40386. // the given name in this mutation.
  40387. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  40388. return nil
  40389. }
  40390. // ClearedEdges returns all edge names that were cleared in this mutation.
  40391. func (m *WxCardMutation) ClearedEdges() []string {
  40392. edges := make([]string, 0, 0)
  40393. return edges
  40394. }
  40395. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40396. // was cleared in this mutation.
  40397. func (m *WxCardMutation) EdgeCleared(name string) bool {
  40398. return false
  40399. }
  40400. // ClearEdge clears the value of the edge with the given name. It returns an error
  40401. // if that edge is not defined in the schema.
  40402. func (m *WxCardMutation) ClearEdge(name string) error {
  40403. return fmt.Errorf("unknown WxCard unique edge %s", name)
  40404. }
  40405. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40406. // It returns an error if the edge is not defined in the schema.
  40407. func (m *WxCardMutation) ResetEdge(name string) error {
  40408. return fmt.Errorf("unknown WxCard edge %s", name)
  40409. }
  40410. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  40411. type WxCardUserMutation struct {
  40412. config
  40413. op Op
  40414. typ string
  40415. id *uint64
  40416. created_at *time.Time
  40417. updated_at *time.Time
  40418. deleted_at *time.Time
  40419. wxid *string
  40420. account *string
  40421. avatar *string
  40422. nickname *string
  40423. remark *string
  40424. phone *string
  40425. open_id *string
  40426. union_id *string
  40427. session_key *string
  40428. is_vip *int
  40429. addis_vip *int
  40430. clearedFields map[string]struct{}
  40431. done bool
  40432. oldValue func(context.Context) (*WxCardUser, error)
  40433. predicates []predicate.WxCardUser
  40434. }
  40435. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  40436. // wxcarduserOption allows management of the mutation configuration using functional options.
  40437. type wxcarduserOption func(*WxCardUserMutation)
  40438. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  40439. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  40440. m := &WxCardUserMutation{
  40441. config: c,
  40442. op: op,
  40443. typ: TypeWxCardUser,
  40444. clearedFields: make(map[string]struct{}),
  40445. }
  40446. for _, opt := range opts {
  40447. opt(m)
  40448. }
  40449. return m
  40450. }
  40451. // withWxCardUserID sets the ID field of the mutation.
  40452. func withWxCardUserID(id uint64) wxcarduserOption {
  40453. return func(m *WxCardUserMutation) {
  40454. var (
  40455. err error
  40456. once sync.Once
  40457. value *WxCardUser
  40458. )
  40459. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  40460. once.Do(func() {
  40461. if m.done {
  40462. err = errors.New("querying old values post mutation is not allowed")
  40463. } else {
  40464. value, err = m.Client().WxCardUser.Get(ctx, id)
  40465. }
  40466. })
  40467. return value, err
  40468. }
  40469. m.id = &id
  40470. }
  40471. }
  40472. // withWxCardUser sets the old WxCardUser of the mutation.
  40473. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  40474. return func(m *WxCardUserMutation) {
  40475. m.oldValue = func(context.Context) (*WxCardUser, error) {
  40476. return node, nil
  40477. }
  40478. m.id = &node.ID
  40479. }
  40480. }
  40481. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40482. // executed in a transaction (ent.Tx), a transactional client is returned.
  40483. func (m WxCardUserMutation) Client() *Client {
  40484. client := &Client{config: m.config}
  40485. client.init()
  40486. return client
  40487. }
  40488. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40489. // it returns an error otherwise.
  40490. func (m WxCardUserMutation) Tx() (*Tx, error) {
  40491. if _, ok := m.driver.(*txDriver); !ok {
  40492. return nil, errors.New("ent: mutation is not running in a transaction")
  40493. }
  40494. tx := &Tx{config: m.config}
  40495. tx.init()
  40496. return tx, nil
  40497. }
  40498. // SetID sets the value of the id field. Note that this
  40499. // operation is only accepted on creation of WxCardUser entities.
  40500. func (m *WxCardUserMutation) SetID(id uint64) {
  40501. m.id = &id
  40502. }
  40503. // ID returns the ID value in the mutation. Note that the ID is only available
  40504. // if it was provided to the builder or after it was returned from the database.
  40505. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  40506. if m.id == nil {
  40507. return
  40508. }
  40509. return *m.id, true
  40510. }
  40511. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40512. // That means, if the mutation is applied within a transaction with an isolation level such
  40513. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40514. // or updated by the mutation.
  40515. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  40516. switch {
  40517. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40518. id, exists := m.ID()
  40519. if exists {
  40520. return []uint64{id}, nil
  40521. }
  40522. fallthrough
  40523. case m.op.Is(OpUpdate | OpDelete):
  40524. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  40525. default:
  40526. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40527. }
  40528. }
  40529. // SetCreatedAt sets the "created_at" field.
  40530. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  40531. m.created_at = &t
  40532. }
  40533. // CreatedAt returns the value of the "created_at" field in the mutation.
  40534. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  40535. v := m.created_at
  40536. if v == nil {
  40537. return
  40538. }
  40539. return *v, true
  40540. }
  40541. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  40542. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40543. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40544. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40545. if !m.op.Is(OpUpdateOne) {
  40546. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40547. }
  40548. if m.id == nil || m.oldValue == nil {
  40549. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40550. }
  40551. oldValue, err := m.oldValue(ctx)
  40552. if err != nil {
  40553. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40554. }
  40555. return oldValue.CreatedAt, nil
  40556. }
  40557. // ResetCreatedAt resets all changes to the "created_at" field.
  40558. func (m *WxCardUserMutation) ResetCreatedAt() {
  40559. m.created_at = nil
  40560. }
  40561. // SetUpdatedAt sets the "updated_at" field.
  40562. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  40563. m.updated_at = &t
  40564. }
  40565. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40566. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  40567. v := m.updated_at
  40568. if v == nil {
  40569. return
  40570. }
  40571. return *v, true
  40572. }
  40573. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  40574. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40576. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40577. if !m.op.Is(OpUpdateOne) {
  40578. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40579. }
  40580. if m.id == nil || m.oldValue == nil {
  40581. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40582. }
  40583. oldValue, err := m.oldValue(ctx)
  40584. if err != nil {
  40585. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40586. }
  40587. return oldValue.UpdatedAt, nil
  40588. }
  40589. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40590. func (m *WxCardUserMutation) ResetUpdatedAt() {
  40591. m.updated_at = nil
  40592. }
  40593. // SetDeletedAt sets the "deleted_at" field.
  40594. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  40595. m.deleted_at = &t
  40596. }
  40597. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40598. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  40599. v := m.deleted_at
  40600. if v == nil {
  40601. return
  40602. }
  40603. return *v, true
  40604. }
  40605. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  40606. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40608. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40609. if !m.op.Is(OpUpdateOne) {
  40610. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40611. }
  40612. if m.id == nil || m.oldValue == nil {
  40613. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40614. }
  40615. oldValue, err := m.oldValue(ctx)
  40616. if err != nil {
  40617. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40618. }
  40619. return oldValue.DeletedAt, nil
  40620. }
  40621. // ClearDeletedAt clears the value of the "deleted_at" field.
  40622. func (m *WxCardUserMutation) ClearDeletedAt() {
  40623. m.deleted_at = nil
  40624. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  40625. }
  40626. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40627. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  40628. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  40629. return ok
  40630. }
  40631. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40632. func (m *WxCardUserMutation) ResetDeletedAt() {
  40633. m.deleted_at = nil
  40634. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  40635. }
  40636. // SetWxid sets the "wxid" field.
  40637. func (m *WxCardUserMutation) SetWxid(s string) {
  40638. m.wxid = &s
  40639. }
  40640. // Wxid returns the value of the "wxid" field in the mutation.
  40641. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  40642. v := m.wxid
  40643. if v == nil {
  40644. return
  40645. }
  40646. return *v, true
  40647. }
  40648. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  40649. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40650. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40651. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  40652. if !m.op.Is(OpUpdateOne) {
  40653. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40654. }
  40655. if m.id == nil || m.oldValue == nil {
  40656. return v, errors.New("OldWxid requires an ID field in the mutation")
  40657. }
  40658. oldValue, err := m.oldValue(ctx)
  40659. if err != nil {
  40660. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40661. }
  40662. return oldValue.Wxid, nil
  40663. }
  40664. // ResetWxid resets all changes to the "wxid" field.
  40665. func (m *WxCardUserMutation) ResetWxid() {
  40666. m.wxid = nil
  40667. }
  40668. // SetAccount sets the "account" field.
  40669. func (m *WxCardUserMutation) SetAccount(s string) {
  40670. m.account = &s
  40671. }
  40672. // Account returns the value of the "account" field in the mutation.
  40673. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  40674. v := m.account
  40675. if v == nil {
  40676. return
  40677. }
  40678. return *v, true
  40679. }
  40680. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  40681. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40682. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40683. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  40684. if !m.op.Is(OpUpdateOne) {
  40685. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40686. }
  40687. if m.id == nil || m.oldValue == nil {
  40688. return v, errors.New("OldAccount requires an ID field in the mutation")
  40689. }
  40690. oldValue, err := m.oldValue(ctx)
  40691. if err != nil {
  40692. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40693. }
  40694. return oldValue.Account, nil
  40695. }
  40696. // ResetAccount resets all changes to the "account" field.
  40697. func (m *WxCardUserMutation) ResetAccount() {
  40698. m.account = nil
  40699. }
  40700. // SetAvatar sets the "avatar" field.
  40701. func (m *WxCardUserMutation) SetAvatar(s string) {
  40702. m.avatar = &s
  40703. }
  40704. // Avatar returns the value of the "avatar" field in the mutation.
  40705. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  40706. v := m.avatar
  40707. if v == nil {
  40708. return
  40709. }
  40710. return *v, true
  40711. }
  40712. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  40713. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40715. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40716. if !m.op.Is(OpUpdateOne) {
  40717. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40718. }
  40719. if m.id == nil || m.oldValue == nil {
  40720. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40721. }
  40722. oldValue, err := m.oldValue(ctx)
  40723. if err != nil {
  40724. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40725. }
  40726. return oldValue.Avatar, nil
  40727. }
  40728. // ResetAvatar resets all changes to the "avatar" field.
  40729. func (m *WxCardUserMutation) ResetAvatar() {
  40730. m.avatar = nil
  40731. }
  40732. // SetNickname sets the "nickname" field.
  40733. func (m *WxCardUserMutation) SetNickname(s string) {
  40734. m.nickname = &s
  40735. }
  40736. // Nickname returns the value of the "nickname" field in the mutation.
  40737. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  40738. v := m.nickname
  40739. if v == nil {
  40740. return
  40741. }
  40742. return *v, true
  40743. }
  40744. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  40745. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40747. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  40748. if !m.op.Is(OpUpdateOne) {
  40749. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40750. }
  40751. if m.id == nil || m.oldValue == nil {
  40752. return v, errors.New("OldNickname requires an ID field in the mutation")
  40753. }
  40754. oldValue, err := m.oldValue(ctx)
  40755. if err != nil {
  40756. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40757. }
  40758. return oldValue.Nickname, nil
  40759. }
  40760. // ResetNickname resets all changes to the "nickname" field.
  40761. func (m *WxCardUserMutation) ResetNickname() {
  40762. m.nickname = nil
  40763. }
  40764. // SetRemark sets the "remark" field.
  40765. func (m *WxCardUserMutation) SetRemark(s string) {
  40766. m.remark = &s
  40767. }
  40768. // Remark returns the value of the "remark" field in the mutation.
  40769. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  40770. v := m.remark
  40771. if v == nil {
  40772. return
  40773. }
  40774. return *v, true
  40775. }
  40776. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  40777. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40779. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  40780. if !m.op.Is(OpUpdateOne) {
  40781. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  40782. }
  40783. if m.id == nil || m.oldValue == nil {
  40784. return v, errors.New("OldRemark requires an ID field in the mutation")
  40785. }
  40786. oldValue, err := m.oldValue(ctx)
  40787. if err != nil {
  40788. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  40789. }
  40790. return oldValue.Remark, nil
  40791. }
  40792. // ResetRemark resets all changes to the "remark" field.
  40793. func (m *WxCardUserMutation) ResetRemark() {
  40794. m.remark = nil
  40795. }
  40796. // SetPhone sets the "phone" field.
  40797. func (m *WxCardUserMutation) SetPhone(s string) {
  40798. m.phone = &s
  40799. }
  40800. // Phone returns the value of the "phone" field in the mutation.
  40801. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  40802. v := m.phone
  40803. if v == nil {
  40804. return
  40805. }
  40806. return *v, true
  40807. }
  40808. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  40809. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40811. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  40812. if !m.op.Is(OpUpdateOne) {
  40813. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40814. }
  40815. if m.id == nil || m.oldValue == nil {
  40816. return v, errors.New("OldPhone requires an ID field in the mutation")
  40817. }
  40818. oldValue, err := m.oldValue(ctx)
  40819. if err != nil {
  40820. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40821. }
  40822. return oldValue.Phone, nil
  40823. }
  40824. // ResetPhone resets all changes to the "phone" field.
  40825. func (m *WxCardUserMutation) ResetPhone() {
  40826. m.phone = nil
  40827. }
  40828. // SetOpenID sets the "open_id" field.
  40829. func (m *WxCardUserMutation) SetOpenID(s string) {
  40830. m.open_id = &s
  40831. }
  40832. // OpenID returns the value of the "open_id" field in the mutation.
  40833. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  40834. v := m.open_id
  40835. if v == nil {
  40836. return
  40837. }
  40838. return *v, true
  40839. }
  40840. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  40841. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40842. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40843. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  40844. if !m.op.Is(OpUpdateOne) {
  40845. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  40846. }
  40847. if m.id == nil || m.oldValue == nil {
  40848. return v, errors.New("OldOpenID requires an ID field in the mutation")
  40849. }
  40850. oldValue, err := m.oldValue(ctx)
  40851. if err != nil {
  40852. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  40853. }
  40854. return oldValue.OpenID, nil
  40855. }
  40856. // ResetOpenID resets all changes to the "open_id" field.
  40857. func (m *WxCardUserMutation) ResetOpenID() {
  40858. m.open_id = nil
  40859. }
  40860. // SetUnionID sets the "union_id" field.
  40861. func (m *WxCardUserMutation) SetUnionID(s string) {
  40862. m.union_id = &s
  40863. }
  40864. // UnionID returns the value of the "union_id" field in the mutation.
  40865. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  40866. v := m.union_id
  40867. if v == nil {
  40868. return
  40869. }
  40870. return *v, true
  40871. }
  40872. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  40873. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40874. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40875. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  40876. if !m.op.Is(OpUpdateOne) {
  40877. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  40878. }
  40879. if m.id == nil || m.oldValue == nil {
  40880. return v, errors.New("OldUnionID requires an ID field in the mutation")
  40881. }
  40882. oldValue, err := m.oldValue(ctx)
  40883. if err != nil {
  40884. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  40885. }
  40886. return oldValue.UnionID, nil
  40887. }
  40888. // ResetUnionID resets all changes to the "union_id" field.
  40889. func (m *WxCardUserMutation) ResetUnionID() {
  40890. m.union_id = nil
  40891. }
  40892. // SetSessionKey sets the "session_key" field.
  40893. func (m *WxCardUserMutation) SetSessionKey(s string) {
  40894. m.session_key = &s
  40895. }
  40896. // SessionKey returns the value of the "session_key" field in the mutation.
  40897. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  40898. v := m.session_key
  40899. if v == nil {
  40900. return
  40901. }
  40902. return *v, true
  40903. }
  40904. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  40905. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40907. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  40908. if !m.op.Is(OpUpdateOne) {
  40909. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  40910. }
  40911. if m.id == nil || m.oldValue == nil {
  40912. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  40913. }
  40914. oldValue, err := m.oldValue(ctx)
  40915. if err != nil {
  40916. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  40917. }
  40918. return oldValue.SessionKey, nil
  40919. }
  40920. // ResetSessionKey resets all changes to the "session_key" field.
  40921. func (m *WxCardUserMutation) ResetSessionKey() {
  40922. m.session_key = nil
  40923. }
  40924. // SetIsVip sets the "is_vip" field.
  40925. func (m *WxCardUserMutation) SetIsVip(i int) {
  40926. m.is_vip = &i
  40927. m.addis_vip = nil
  40928. }
  40929. // IsVip returns the value of the "is_vip" field in the mutation.
  40930. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  40931. v := m.is_vip
  40932. if v == nil {
  40933. return
  40934. }
  40935. return *v, true
  40936. }
  40937. // OldIsVip returns the old "is_vip" field's value of the WxCardUser entity.
  40938. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40939. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40940. func (m *WxCardUserMutation) OldIsVip(ctx context.Context) (v int, err error) {
  40941. if !m.op.Is(OpUpdateOne) {
  40942. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  40943. }
  40944. if m.id == nil || m.oldValue == nil {
  40945. return v, errors.New("OldIsVip requires an ID field in the mutation")
  40946. }
  40947. oldValue, err := m.oldValue(ctx)
  40948. if err != nil {
  40949. return v, fmt.Errorf("querying old value for OldIsVip: %w", err)
  40950. }
  40951. return oldValue.IsVip, nil
  40952. }
  40953. // AddIsVip adds i to the "is_vip" field.
  40954. func (m *WxCardUserMutation) AddIsVip(i int) {
  40955. if m.addis_vip != nil {
  40956. *m.addis_vip += i
  40957. } else {
  40958. m.addis_vip = &i
  40959. }
  40960. }
  40961. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  40962. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  40963. v := m.addis_vip
  40964. if v == nil {
  40965. return
  40966. }
  40967. return *v, true
  40968. }
  40969. // ResetIsVip resets all changes to the "is_vip" field.
  40970. func (m *WxCardUserMutation) ResetIsVip() {
  40971. m.is_vip = nil
  40972. m.addis_vip = nil
  40973. }
  40974. // Where appends a list predicates to the WxCardUserMutation builder.
  40975. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  40976. m.predicates = append(m.predicates, ps...)
  40977. }
  40978. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  40979. // users can use type-assertion to append predicates that do not depend on any generated package.
  40980. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  40981. p := make([]predicate.WxCardUser, len(ps))
  40982. for i := range ps {
  40983. p[i] = ps[i]
  40984. }
  40985. m.Where(p...)
  40986. }
  40987. // Op returns the operation name.
  40988. func (m *WxCardUserMutation) Op() Op {
  40989. return m.op
  40990. }
  40991. // SetOp allows setting the mutation operation.
  40992. func (m *WxCardUserMutation) SetOp(op Op) {
  40993. m.op = op
  40994. }
  40995. // Type returns the node type of this mutation (WxCardUser).
  40996. func (m *WxCardUserMutation) Type() string {
  40997. return m.typ
  40998. }
  40999. // Fields returns all fields that were changed during this mutation. Note that in
  41000. // order to get all numeric fields that were incremented/decremented, call
  41001. // AddedFields().
  41002. func (m *WxCardUserMutation) Fields() []string {
  41003. fields := make([]string, 0, 13)
  41004. if m.created_at != nil {
  41005. fields = append(fields, wxcarduser.FieldCreatedAt)
  41006. }
  41007. if m.updated_at != nil {
  41008. fields = append(fields, wxcarduser.FieldUpdatedAt)
  41009. }
  41010. if m.deleted_at != nil {
  41011. fields = append(fields, wxcarduser.FieldDeletedAt)
  41012. }
  41013. if m.wxid != nil {
  41014. fields = append(fields, wxcarduser.FieldWxid)
  41015. }
  41016. if m.account != nil {
  41017. fields = append(fields, wxcarduser.FieldAccount)
  41018. }
  41019. if m.avatar != nil {
  41020. fields = append(fields, wxcarduser.FieldAvatar)
  41021. }
  41022. if m.nickname != nil {
  41023. fields = append(fields, wxcarduser.FieldNickname)
  41024. }
  41025. if m.remark != nil {
  41026. fields = append(fields, wxcarduser.FieldRemark)
  41027. }
  41028. if m.phone != nil {
  41029. fields = append(fields, wxcarduser.FieldPhone)
  41030. }
  41031. if m.open_id != nil {
  41032. fields = append(fields, wxcarduser.FieldOpenID)
  41033. }
  41034. if m.union_id != nil {
  41035. fields = append(fields, wxcarduser.FieldUnionID)
  41036. }
  41037. if m.session_key != nil {
  41038. fields = append(fields, wxcarduser.FieldSessionKey)
  41039. }
  41040. if m.is_vip != nil {
  41041. fields = append(fields, wxcarduser.FieldIsVip)
  41042. }
  41043. return fields
  41044. }
  41045. // Field returns the value of a field with the given name. The second boolean
  41046. // return value indicates that this field was not set, or was not defined in the
  41047. // schema.
  41048. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  41049. switch name {
  41050. case wxcarduser.FieldCreatedAt:
  41051. return m.CreatedAt()
  41052. case wxcarduser.FieldUpdatedAt:
  41053. return m.UpdatedAt()
  41054. case wxcarduser.FieldDeletedAt:
  41055. return m.DeletedAt()
  41056. case wxcarduser.FieldWxid:
  41057. return m.Wxid()
  41058. case wxcarduser.FieldAccount:
  41059. return m.Account()
  41060. case wxcarduser.FieldAvatar:
  41061. return m.Avatar()
  41062. case wxcarduser.FieldNickname:
  41063. return m.Nickname()
  41064. case wxcarduser.FieldRemark:
  41065. return m.Remark()
  41066. case wxcarduser.FieldPhone:
  41067. return m.Phone()
  41068. case wxcarduser.FieldOpenID:
  41069. return m.OpenID()
  41070. case wxcarduser.FieldUnionID:
  41071. return m.UnionID()
  41072. case wxcarduser.FieldSessionKey:
  41073. return m.SessionKey()
  41074. case wxcarduser.FieldIsVip:
  41075. return m.IsVip()
  41076. }
  41077. return nil, false
  41078. }
  41079. // OldField returns the old value of the field from the database. An error is
  41080. // returned if the mutation operation is not UpdateOne, or the query to the
  41081. // database failed.
  41082. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41083. switch name {
  41084. case wxcarduser.FieldCreatedAt:
  41085. return m.OldCreatedAt(ctx)
  41086. case wxcarduser.FieldUpdatedAt:
  41087. return m.OldUpdatedAt(ctx)
  41088. case wxcarduser.FieldDeletedAt:
  41089. return m.OldDeletedAt(ctx)
  41090. case wxcarduser.FieldWxid:
  41091. return m.OldWxid(ctx)
  41092. case wxcarduser.FieldAccount:
  41093. return m.OldAccount(ctx)
  41094. case wxcarduser.FieldAvatar:
  41095. return m.OldAvatar(ctx)
  41096. case wxcarduser.FieldNickname:
  41097. return m.OldNickname(ctx)
  41098. case wxcarduser.FieldRemark:
  41099. return m.OldRemark(ctx)
  41100. case wxcarduser.FieldPhone:
  41101. return m.OldPhone(ctx)
  41102. case wxcarduser.FieldOpenID:
  41103. return m.OldOpenID(ctx)
  41104. case wxcarduser.FieldUnionID:
  41105. return m.OldUnionID(ctx)
  41106. case wxcarduser.FieldSessionKey:
  41107. return m.OldSessionKey(ctx)
  41108. case wxcarduser.FieldIsVip:
  41109. return m.OldIsVip(ctx)
  41110. }
  41111. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  41112. }
  41113. // SetField sets the value of a field with the given name. It returns an error if
  41114. // the field is not defined in the schema, or if the type mismatched the field
  41115. // type.
  41116. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  41117. switch name {
  41118. case wxcarduser.FieldCreatedAt:
  41119. v, ok := value.(time.Time)
  41120. if !ok {
  41121. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41122. }
  41123. m.SetCreatedAt(v)
  41124. return nil
  41125. case wxcarduser.FieldUpdatedAt:
  41126. v, ok := value.(time.Time)
  41127. if !ok {
  41128. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41129. }
  41130. m.SetUpdatedAt(v)
  41131. return nil
  41132. case wxcarduser.FieldDeletedAt:
  41133. v, ok := value.(time.Time)
  41134. if !ok {
  41135. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41136. }
  41137. m.SetDeletedAt(v)
  41138. return nil
  41139. case wxcarduser.FieldWxid:
  41140. v, ok := value.(string)
  41141. if !ok {
  41142. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41143. }
  41144. m.SetWxid(v)
  41145. return nil
  41146. case wxcarduser.FieldAccount:
  41147. v, ok := value.(string)
  41148. if !ok {
  41149. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41150. }
  41151. m.SetAccount(v)
  41152. return nil
  41153. case wxcarduser.FieldAvatar:
  41154. v, ok := value.(string)
  41155. if !ok {
  41156. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41157. }
  41158. m.SetAvatar(v)
  41159. return nil
  41160. case wxcarduser.FieldNickname:
  41161. v, ok := value.(string)
  41162. if !ok {
  41163. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41164. }
  41165. m.SetNickname(v)
  41166. return nil
  41167. case wxcarduser.FieldRemark:
  41168. v, ok := value.(string)
  41169. if !ok {
  41170. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41171. }
  41172. m.SetRemark(v)
  41173. return nil
  41174. case wxcarduser.FieldPhone:
  41175. v, ok := value.(string)
  41176. if !ok {
  41177. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41178. }
  41179. m.SetPhone(v)
  41180. return nil
  41181. case wxcarduser.FieldOpenID:
  41182. v, ok := value.(string)
  41183. if !ok {
  41184. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41185. }
  41186. m.SetOpenID(v)
  41187. return nil
  41188. case wxcarduser.FieldUnionID:
  41189. v, ok := value.(string)
  41190. if !ok {
  41191. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41192. }
  41193. m.SetUnionID(v)
  41194. return nil
  41195. case wxcarduser.FieldSessionKey:
  41196. v, ok := value.(string)
  41197. if !ok {
  41198. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41199. }
  41200. m.SetSessionKey(v)
  41201. return nil
  41202. case wxcarduser.FieldIsVip:
  41203. v, ok := value.(int)
  41204. if !ok {
  41205. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41206. }
  41207. m.SetIsVip(v)
  41208. return nil
  41209. }
  41210. return fmt.Errorf("unknown WxCardUser field %s", name)
  41211. }
  41212. // AddedFields returns all numeric fields that were incremented/decremented during
  41213. // this mutation.
  41214. func (m *WxCardUserMutation) AddedFields() []string {
  41215. var fields []string
  41216. if m.addis_vip != nil {
  41217. fields = append(fields, wxcarduser.FieldIsVip)
  41218. }
  41219. return fields
  41220. }
  41221. // AddedField returns the numeric value that was incremented/decremented on a field
  41222. // with the given name. The second boolean return value indicates that this field
  41223. // was not set, or was not defined in the schema.
  41224. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  41225. switch name {
  41226. case wxcarduser.FieldIsVip:
  41227. return m.AddedIsVip()
  41228. }
  41229. return nil, false
  41230. }
  41231. // AddField adds the value to the field with the given name. It returns an error if
  41232. // the field is not defined in the schema, or if the type mismatched the field
  41233. // type.
  41234. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  41235. switch name {
  41236. case wxcarduser.FieldIsVip:
  41237. v, ok := value.(int)
  41238. if !ok {
  41239. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41240. }
  41241. m.AddIsVip(v)
  41242. return nil
  41243. }
  41244. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  41245. }
  41246. // ClearedFields returns all nullable fields that were cleared during this
  41247. // mutation.
  41248. func (m *WxCardUserMutation) ClearedFields() []string {
  41249. var fields []string
  41250. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  41251. fields = append(fields, wxcarduser.FieldDeletedAt)
  41252. }
  41253. return fields
  41254. }
  41255. // FieldCleared returns a boolean indicating if a field with the given name was
  41256. // cleared in this mutation.
  41257. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  41258. _, ok := m.clearedFields[name]
  41259. return ok
  41260. }
  41261. // ClearField clears the value of the field with the given name. It returns an
  41262. // error if the field is not defined in the schema.
  41263. func (m *WxCardUserMutation) ClearField(name string) error {
  41264. switch name {
  41265. case wxcarduser.FieldDeletedAt:
  41266. m.ClearDeletedAt()
  41267. return nil
  41268. }
  41269. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  41270. }
  41271. // ResetField resets all changes in the mutation for the field with the given name.
  41272. // It returns an error if the field is not defined in the schema.
  41273. func (m *WxCardUserMutation) ResetField(name string) error {
  41274. switch name {
  41275. case wxcarduser.FieldCreatedAt:
  41276. m.ResetCreatedAt()
  41277. return nil
  41278. case wxcarduser.FieldUpdatedAt:
  41279. m.ResetUpdatedAt()
  41280. return nil
  41281. case wxcarduser.FieldDeletedAt:
  41282. m.ResetDeletedAt()
  41283. return nil
  41284. case wxcarduser.FieldWxid:
  41285. m.ResetWxid()
  41286. return nil
  41287. case wxcarduser.FieldAccount:
  41288. m.ResetAccount()
  41289. return nil
  41290. case wxcarduser.FieldAvatar:
  41291. m.ResetAvatar()
  41292. return nil
  41293. case wxcarduser.FieldNickname:
  41294. m.ResetNickname()
  41295. return nil
  41296. case wxcarduser.FieldRemark:
  41297. m.ResetRemark()
  41298. return nil
  41299. case wxcarduser.FieldPhone:
  41300. m.ResetPhone()
  41301. return nil
  41302. case wxcarduser.FieldOpenID:
  41303. m.ResetOpenID()
  41304. return nil
  41305. case wxcarduser.FieldUnionID:
  41306. m.ResetUnionID()
  41307. return nil
  41308. case wxcarduser.FieldSessionKey:
  41309. m.ResetSessionKey()
  41310. return nil
  41311. case wxcarduser.FieldIsVip:
  41312. m.ResetIsVip()
  41313. return nil
  41314. }
  41315. return fmt.Errorf("unknown WxCardUser field %s", name)
  41316. }
  41317. // AddedEdges returns all edge names that were set/added in this mutation.
  41318. func (m *WxCardUserMutation) AddedEdges() []string {
  41319. edges := make([]string, 0, 0)
  41320. return edges
  41321. }
  41322. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41323. // name in this mutation.
  41324. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  41325. return nil
  41326. }
  41327. // RemovedEdges returns all edge names that were removed in this mutation.
  41328. func (m *WxCardUserMutation) RemovedEdges() []string {
  41329. edges := make([]string, 0, 0)
  41330. return edges
  41331. }
  41332. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41333. // the given name in this mutation.
  41334. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  41335. return nil
  41336. }
  41337. // ClearedEdges returns all edge names that were cleared in this mutation.
  41338. func (m *WxCardUserMutation) ClearedEdges() []string {
  41339. edges := make([]string, 0, 0)
  41340. return edges
  41341. }
  41342. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41343. // was cleared in this mutation.
  41344. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  41345. return false
  41346. }
  41347. // ClearEdge clears the value of the edge with the given name. It returns an error
  41348. // if that edge is not defined in the schema.
  41349. func (m *WxCardUserMutation) ClearEdge(name string) error {
  41350. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  41351. }
  41352. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41353. // It returns an error if the edge is not defined in the schema.
  41354. func (m *WxCardUserMutation) ResetEdge(name string) error {
  41355. return fmt.Errorf("unknown WxCardUser edge %s", name)
  41356. }
  41357. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  41358. type WxCardVisitMutation struct {
  41359. config
  41360. op Op
  41361. typ string
  41362. id *uint64
  41363. created_at *time.Time
  41364. updated_at *time.Time
  41365. deleted_at *time.Time
  41366. user_id *uint64
  41367. adduser_id *int64
  41368. bot_id *uint64
  41369. addbot_id *int64
  41370. bot_type *uint8
  41371. addbot_type *int8
  41372. clearedFields map[string]struct{}
  41373. done bool
  41374. oldValue func(context.Context) (*WxCardVisit, error)
  41375. predicates []predicate.WxCardVisit
  41376. }
  41377. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  41378. // wxcardvisitOption allows management of the mutation configuration using functional options.
  41379. type wxcardvisitOption func(*WxCardVisitMutation)
  41380. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  41381. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  41382. m := &WxCardVisitMutation{
  41383. config: c,
  41384. op: op,
  41385. typ: TypeWxCardVisit,
  41386. clearedFields: make(map[string]struct{}),
  41387. }
  41388. for _, opt := range opts {
  41389. opt(m)
  41390. }
  41391. return m
  41392. }
  41393. // withWxCardVisitID sets the ID field of the mutation.
  41394. func withWxCardVisitID(id uint64) wxcardvisitOption {
  41395. return func(m *WxCardVisitMutation) {
  41396. var (
  41397. err error
  41398. once sync.Once
  41399. value *WxCardVisit
  41400. )
  41401. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  41402. once.Do(func() {
  41403. if m.done {
  41404. err = errors.New("querying old values post mutation is not allowed")
  41405. } else {
  41406. value, err = m.Client().WxCardVisit.Get(ctx, id)
  41407. }
  41408. })
  41409. return value, err
  41410. }
  41411. m.id = &id
  41412. }
  41413. }
  41414. // withWxCardVisit sets the old WxCardVisit of the mutation.
  41415. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  41416. return func(m *WxCardVisitMutation) {
  41417. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  41418. return node, nil
  41419. }
  41420. m.id = &node.ID
  41421. }
  41422. }
  41423. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41424. // executed in a transaction (ent.Tx), a transactional client is returned.
  41425. func (m WxCardVisitMutation) Client() *Client {
  41426. client := &Client{config: m.config}
  41427. client.init()
  41428. return client
  41429. }
  41430. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41431. // it returns an error otherwise.
  41432. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  41433. if _, ok := m.driver.(*txDriver); !ok {
  41434. return nil, errors.New("ent: mutation is not running in a transaction")
  41435. }
  41436. tx := &Tx{config: m.config}
  41437. tx.init()
  41438. return tx, nil
  41439. }
  41440. // SetID sets the value of the id field. Note that this
  41441. // operation is only accepted on creation of WxCardVisit entities.
  41442. func (m *WxCardVisitMutation) SetID(id uint64) {
  41443. m.id = &id
  41444. }
  41445. // ID returns the ID value in the mutation. Note that the ID is only available
  41446. // if it was provided to the builder or after it was returned from the database.
  41447. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  41448. if m.id == nil {
  41449. return
  41450. }
  41451. return *m.id, true
  41452. }
  41453. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41454. // That means, if the mutation is applied within a transaction with an isolation level such
  41455. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41456. // or updated by the mutation.
  41457. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  41458. switch {
  41459. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41460. id, exists := m.ID()
  41461. if exists {
  41462. return []uint64{id}, nil
  41463. }
  41464. fallthrough
  41465. case m.op.Is(OpUpdate | OpDelete):
  41466. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  41467. default:
  41468. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41469. }
  41470. }
  41471. // SetCreatedAt sets the "created_at" field.
  41472. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  41473. m.created_at = &t
  41474. }
  41475. // CreatedAt returns the value of the "created_at" field in the mutation.
  41476. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  41477. v := m.created_at
  41478. if v == nil {
  41479. return
  41480. }
  41481. return *v, true
  41482. }
  41483. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  41484. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41486. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41487. if !m.op.Is(OpUpdateOne) {
  41488. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41489. }
  41490. if m.id == nil || m.oldValue == nil {
  41491. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41492. }
  41493. oldValue, err := m.oldValue(ctx)
  41494. if err != nil {
  41495. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41496. }
  41497. return oldValue.CreatedAt, nil
  41498. }
  41499. // ResetCreatedAt resets all changes to the "created_at" field.
  41500. func (m *WxCardVisitMutation) ResetCreatedAt() {
  41501. m.created_at = nil
  41502. }
  41503. // SetUpdatedAt sets the "updated_at" field.
  41504. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  41505. m.updated_at = &t
  41506. }
  41507. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41508. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  41509. v := m.updated_at
  41510. if v == nil {
  41511. return
  41512. }
  41513. return *v, true
  41514. }
  41515. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  41516. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41517. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41518. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41519. if !m.op.Is(OpUpdateOne) {
  41520. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41521. }
  41522. if m.id == nil || m.oldValue == nil {
  41523. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41524. }
  41525. oldValue, err := m.oldValue(ctx)
  41526. if err != nil {
  41527. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41528. }
  41529. return oldValue.UpdatedAt, nil
  41530. }
  41531. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41532. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  41533. m.updated_at = nil
  41534. }
  41535. // SetDeletedAt sets the "deleted_at" field.
  41536. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  41537. m.deleted_at = &t
  41538. }
  41539. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41540. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  41541. v := m.deleted_at
  41542. if v == nil {
  41543. return
  41544. }
  41545. return *v, true
  41546. }
  41547. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  41548. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41549. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41550. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41551. if !m.op.Is(OpUpdateOne) {
  41552. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41553. }
  41554. if m.id == nil || m.oldValue == nil {
  41555. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41556. }
  41557. oldValue, err := m.oldValue(ctx)
  41558. if err != nil {
  41559. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41560. }
  41561. return oldValue.DeletedAt, nil
  41562. }
  41563. // ClearDeletedAt clears the value of the "deleted_at" field.
  41564. func (m *WxCardVisitMutation) ClearDeletedAt() {
  41565. m.deleted_at = nil
  41566. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  41567. }
  41568. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41569. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  41570. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  41571. return ok
  41572. }
  41573. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41574. func (m *WxCardVisitMutation) ResetDeletedAt() {
  41575. m.deleted_at = nil
  41576. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  41577. }
  41578. // SetUserID sets the "user_id" field.
  41579. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  41580. m.user_id = &u
  41581. m.adduser_id = nil
  41582. }
  41583. // UserID returns the value of the "user_id" field in the mutation.
  41584. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  41585. v := m.user_id
  41586. if v == nil {
  41587. return
  41588. }
  41589. return *v, true
  41590. }
  41591. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  41592. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41594. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41595. if !m.op.Is(OpUpdateOne) {
  41596. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41597. }
  41598. if m.id == nil || m.oldValue == nil {
  41599. return v, errors.New("OldUserID requires an ID field in the mutation")
  41600. }
  41601. oldValue, err := m.oldValue(ctx)
  41602. if err != nil {
  41603. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41604. }
  41605. return oldValue.UserID, nil
  41606. }
  41607. // AddUserID adds u to the "user_id" field.
  41608. func (m *WxCardVisitMutation) AddUserID(u int64) {
  41609. if m.adduser_id != nil {
  41610. *m.adduser_id += u
  41611. } else {
  41612. m.adduser_id = &u
  41613. }
  41614. }
  41615. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41616. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  41617. v := m.adduser_id
  41618. if v == nil {
  41619. return
  41620. }
  41621. return *v, true
  41622. }
  41623. // ClearUserID clears the value of the "user_id" field.
  41624. func (m *WxCardVisitMutation) ClearUserID() {
  41625. m.user_id = nil
  41626. m.adduser_id = nil
  41627. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  41628. }
  41629. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41630. func (m *WxCardVisitMutation) UserIDCleared() bool {
  41631. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  41632. return ok
  41633. }
  41634. // ResetUserID resets all changes to the "user_id" field.
  41635. func (m *WxCardVisitMutation) ResetUserID() {
  41636. m.user_id = nil
  41637. m.adduser_id = nil
  41638. delete(m.clearedFields, wxcardvisit.FieldUserID)
  41639. }
  41640. // SetBotID sets the "bot_id" field.
  41641. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  41642. m.bot_id = &u
  41643. m.addbot_id = nil
  41644. }
  41645. // BotID returns the value of the "bot_id" field in the mutation.
  41646. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  41647. v := m.bot_id
  41648. if v == nil {
  41649. return
  41650. }
  41651. return *v, true
  41652. }
  41653. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  41654. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41655. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41656. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  41657. if !m.op.Is(OpUpdateOne) {
  41658. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41659. }
  41660. if m.id == nil || m.oldValue == nil {
  41661. return v, errors.New("OldBotID requires an ID field in the mutation")
  41662. }
  41663. oldValue, err := m.oldValue(ctx)
  41664. if err != nil {
  41665. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41666. }
  41667. return oldValue.BotID, nil
  41668. }
  41669. // AddBotID adds u to the "bot_id" field.
  41670. func (m *WxCardVisitMutation) AddBotID(u int64) {
  41671. if m.addbot_id != nil {
  41672. *m.addbot_id += u
  41673. } else {
  41674. m.addbot_id = &u
  41675. }
  41676. }
  41677. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  41678. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  41679. v := m.addbot_id
  41680. if v == nil {
  41681. return
  41682. }
  41683. return *v, true
  41684. }
  41685. // ResetBotID resets all changes to the "bot_id" field.
  41686. func (m *WxCardVisitMutation) ResetBotID() {
  41687. m.bot_id = nil
  41688. m.addbot_id = nil
  41689. }
  41690. // SetBotType sets the "bot_type" field.
  41691. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  41692. m.bot_type = &u
  41693. m.addbot_type = nil
  41694. }
  41695. // BotType returns the value of the "bot_type" field in the mutation.
  41696. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  41697. v := m.bot_type
  41698. if v == nil {
  41699. return
  41700. }
  41701. return *v, true
  41702. }
  41703. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  41704. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41706. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  41707. if !m.op.Is(OpUpdateOne) {
  41708. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  41709. }
  41710. if m.id == nil || m.oldValue == nil {
  41711. return v, errors.New("OldBotType requires an ID field in the mutation")
  41712. }
  41713. oldValue, err := m.oldValue(ctx)
  41714. if err != nil {
  41715. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  41716. }
  41717. return oldValue.BotType, nil
  41718. }
  41719. // AddBotType adds u to the "bot_type" field.
  41720. func (m *WxCardVisitMutation) AddBotType(u int8) {
  41721. if m.addbot_type != nil {
  41722. *m.addbot_type += u
  41723. } else {
  41724. m.addbot_type = &u
  41725. }
  41726. }
  41727. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  41728. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  41729. v := m.addbot_type
  41730. if v == nil {
  41731. return
  41732. }
  41733. return *v, true
  41734. }
  41735. // ResetBotType resets all changes to the "bot_type" field.
  41736. func (m *WxCardVisitMutation) ResetBotType() {
  41737. m.bot_type = nil
  41738. m.addbot_type = nil
  41739. }
  41740. // Where appends a list predicates to the WxCardVisitMutation builder.
  41741. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  41742. m.predicates = append(m.predicates, ps...)
  41743. }
  41744. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  41745. // users can use type-assertion to append predicates that do not depend on any generated package.
  41746. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  41747. p := make([]predicate.WxCardVisit, len(ps))
  41748. for i := range ps {
  41749. p[i] = ps[i]
  41750. }
  41751. m.Where(p...)
  41752. }
  41753. // Op returns the operation name.
  41754. func (m *WxCardVisitMutation) Op() Op {
  41755. return m.op
  41756. }
  41757. // SetOp allows setting the mutation operation.
  41758. func (m *WxCardVisitMutation) SetOp(op Op) {
  41759. m.op = op
  41760. }
  41761. // Type returns the node type of this mutation (WxCardVisit).
  41762. func (m *WxCardVisitMutation) Type() string {
  41763. return m.typ
  41764. }
  41765. // Fields returns all fields that were changed during this mutation. Note that in
  41766. // order to get all numeric fields that were incremented/decremented, call
  41767. // AddedFields().
  41768. func (m *WxCardVisitMutation) Fields() []string {
  41769. fields := make([]string, 0, 6)
  41770. if m.created_at != nil {
  41771. fields = append(fields, wxcardvisit.FieldCreatedAt)
  41772. }
  41773. if m.updated_at != nil {
  41774. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  41775. }
  41776. if m.deleted_at != nil {
  41777. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41778. }
  41779. if m.user_id != nil {
  41780. fields = append(fields, wxcardvisit.FieldUserID)
  41781. }
  41782. if m.bot_id != nil {
  41783. fields = append(fields, wxcardvisit.FieldBotID)
  41784. }
  41785. if m.bot_type != nil {
  41786. fields = append(fields, wxcardvisit.FieldBotType)
  41787. }
  41788. return fields
  41789. }
  41790. // Field returns the value of a field with the given name. The second boolean
  41791. // return value indicates that this field was not set, or was not defined in the
  41792. // schema.
  41793. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  41794. switch name {
  41795. case wxcardvisit.FieldCreatedAt:
  41796. return m.CreatedAt()
  41797. case wxcardvisit.FieldUpdatedAt:
  41798. return m.UpdatedAt()
  41799. case wxcardvisit.FieldDeletedAt:
  41800. return m.DeletedAt()
  41801. case wxcardvisit.FieldUserID:
  41802. return m.UserID()
  41803. case wxcardvisit.FieldBotID:
  41804. return m.BotID()
  41805. case wxcardvisit.FieldBotType:
  41806. return m.BotType()
  41807. }
  41808. return nil, false
  41809. }
  41810. // OldField returns the old value of the field from the database. An error is
  41811. // returned if the mutation operation is not UpdateOne, or the query to the
  41812. // database failed.
  41813. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41814. switch name {
  41815. case wxcardvisit.FieldCreatedAt:
  41816. return m.OldCreatedAt(ctx)
  41817. case wxcardvisit.FieldUpdatedAt:
  41818. return m.OldUpdatedAt(ctx)
  41819. case wxcardvisit.FieldDeletedAt:
  41820. return m.OldDeletedAt(ctx)
  41821. case wxcardvisit.FieldUserID:
  41822. return m.OldUserID(ctx)
  41823. case wxcardvisit.FieldBotID:
  41824. return m.OldBotID(ctx)
  41825. case wxcardvisit.FieldBotType:
  41826. return m.OldBotType(ctx)
  41827. }
  41828. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  41829. }
  41830. // SetField sets the value of a field with the given name. It returns an error if
  41831. // the field is not defined in the schema, or if the type mismatched the field
  41832. // type.
  41833. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  41834. switch name {
  41835. case wxcardvisit.FieldCreatedAt:
  41836. v, ok := value.(time.Time)
  41837. if !ok {
  41838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41839. }
  41840. m.SetCreatedAt(v)
  41841. return nil
  41842. case wxcardvisit.FieldUpdatedAt:
  41843. v, ok := value.(time.Time)
  41844. if !ok {
  41845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41846. }
  41847. m.SetUpdatedAt(v)
  41848. return nil
  41849. case wxcardvisit.FieldDeletedAt:
  41850. v, ok := value.(time.Time)
  41851. if !ok {
  41852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41853. }
  41854. m.SetDeletedAt(v)
  41855. return nil
  41856. case wxcardvisit.FieldUserID:
  41857. v, ok := value.(uint64)
  41858. if !ok {
  41859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41860. }
  41861. m.SetUserID(v)
  41862. return nil
  41863. case wxcardvisit.FieldBotID:
  41864. v, ok := value.(uint64)
  41865. if !ok {
  41866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41867. }
  41868. m.SetBotID(v)
  41869. return nil
  41870. case wxcardvisit.FieldBotType:
  41871. v, ok := value.(uint8)
  41872. if !ok {
  41873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41874. }
  41875. m.SetBotType(v)
  41876. return nil
  41877. }
  41878. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41879. }
  41880. // AddedFields returns all numeric fields that were incremented/decremented during
  41881. // this mutation.
  41882. func (m *WxCardVisitMutation) AddedFields() []string {
  41883. var fields []string
  41884. if m.adduser_id != nil {
  41885. fields = append(fields, wxcardvisit.FieldUserID)
  41886. }
  41887. if m.addbot_id != nil {
  41888. fields = append(fields, wxcardvisit.FieldBotID)
  41889. }
  41890. if m.addbot_type != nil {
  41891. fields = append(fields, wxcardvisit.FieldBotType)
  41892. }
  41893. return fields
  41894. }
  41895. // AddedField returns the numeric value that was incremented/decremented on a field
  41896. // with the given name. The second boolean return value indicates that this field
  41897. // was not set, or was not defined in the schema.
  41898. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  41899. switch name {
  41900. case wxcardvisit.FieldUserID:
  41901. return m.AddedUserID()
  41902. case wxcardvisit.FieldBotID:
  41903. return m.AddedBotID()
  41904. case wxcardvisit.FieldBotType:
  41905. return m.AddedBotType()
  41906. }
  41907. return nil, false
  41908. }
  41909. // AddField adds the value to the field with the given name. It returns an error if
  41910. // the field is not defined in the schema, or if the type mismatched the field
  41911. // type.
  41912. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  41913. switch name {
  41914. case wxcardvisit.FieldUserID:
  41915. v, ok := value.(int64)
  41916. if !ok {
  41917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41918. }
  41919. m.AddUserID(v)
  41920. return nil
  41921. case wxcardvisit.FieldBotID:
  41922. v, ok := value.(int64)
  41923. if !ok {
  41924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41925. }
  41926. m.AddBotID(v)
  41927. return nil
  41928. case wxcardvisit.FieldBotType:
  41929. v, ok := value.(int8)
  41930. if !ok {
  41931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41932. }
  41933. m.AddBotType(v)
  41934. return nil
  41935. }
  41936. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  41937. }
  41938. // ClearedFields returns all nullable fields that were cleared during this
  41939. // mutation.
  41940. func (m *WxCardVisitMutation) ClearedFields() []string {
  41941. var fields []string
  41942. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  41943. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41944. }
  41945. if m.FieldCleared(wxcardvisit.FieldUserID) {
  41946. fields = append(fields, wxcardvisit.FieldUserID)
  41947. }
  41948. return fields
  41949. }
  41950. // FieldCleared returns a boolean indicating if a field with the given name was
  41951. // cleared in this mutation.
  41952. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  41953. _, ok := m.clearedFields[name]
  41954. return ok
  41955. }
  41956. // ClearField clears the value of the field with the given name. It returns an
  41957. // error if the field is not defined in the schema.
  41958. func (m *WxCardVisitMutation) ClearField(name string) error {
  41959. switch name {
  41960. case wxcardvisit.FieldDeletedAt:
  41961. m.ClearDeletedAt()
  41962. return nil
  41963. case wxcardvisit.FieldUserID:
  41964. m.ClearUserID()
  41965. return nil
  41966. }
  41967. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  41968. }
  41969. // ResetField resets all changes in the mutation for the field with the given name.
  41970. // It returns an error if the field is not defined in the schema.
  41971. func (m *WxCardVisitMutation) ResetField(name string) error {
  41972. switch name {
  41973. case wxcardvisit.FieldCreatedAt:
  41974. m.ResetCreatedAt()
  41975. return nil
  41976. case wxcardvisit.FieldUpdatedAt:
  41977. m.ResetUpdatedAt()
  41978. return nil
  41979. case wxcardvisit.FieldDeletedAt:
  41980. m.ResetDeletedAt()
  41981. return nil
  41982. case wxcardvisit.FieldUserID:
  41983. m.ResetUserID()
  41984. return nil
  41985. case wxcardvisit.FieldBotID:
  41986. m.ResetBotID()
  41987. return nil
  41988. case wxcardvisit.FieldBotType:
  41989. m.ResetBotType()
  41990. return nil
  41991. }
  41992. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41993. }
  41994. // AddedEdges returns all edge names that were set/added in this mutation.
  41995. func (m *WxCardVisitMutation) AddedEdges() []string {
  41996. edges := make([]string, 0, 0)
  41997. return edges
  41998. }
  41999. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  42000. // name in this mutation.
  42001. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  42002. return nil
  42003. }
  42004. // RemovedEdges returns all edge names that were removed in this mutation.
  42005. func (m *WxCardVisitMutation) RemovedEdges() []string {
  42006. edges := make([]string, 0, 0)
  42007. return edges
  42008. }
  42009. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  42010. // the given name in this mutation.
  42011. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  42012. return nil
  42013. }
  42014. // ClearedEdges returns all edge names that were cleared in this mutation.
  42015. func (m *WxCardVisitMutation) ClearedEdges() []string {
  42016. edges := make([]string, 0, 0)
  42017. return edges
  42018. }
  42019. // EdgeCleared returns a boolean which indicates if the edge with the given name
  42020. // was cleared in this mutation.
  42021. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  42022. return false
  42023. }
  42024. // ClearEdge clears the value of the edge with the given name. It returns an error
  42025. // if that edge is not defined in the schema.
  42026. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  42027. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  42028. }
  42029. // ResetEdge resets all changes to the edge with the given name in this mutation.
  42030. // It returns an error if the edge is not defined in the schema.
  42031. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  42032. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  42033. }