mutation.go 1.3 MB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364636563666367636863696370637163726373637463756376637763786379638063816382638363846385638663876388638963906391639263936394639563966397639863996400640164026403640464056406640764086409641064116412641364146415641664176418641964206421642264236424642564266427642864296430643164326433643464356436643764386439644064416442644364446445644664476448644964506451645264536454645564566457645864596460646164626463646464656466646764686469647064716472647364746475647664776478647964806481648264836484648564866487648864896490649164926493649464956496649764986499650065016502650365046505650665076508650965106511651265136514651565166517651865196520652165226523652465256526652765286529653065316532653365346535653665376538653965406541654265436544654565466547654865496550655165526553655465556556655765586559656065616562656365646565656665676568656965706571657265736574657565766577657865796580658165826583658465856586658765886589659065916592659365946595659665976598659966006601660266036604660566066607660866096610661166126613661466156616661766186619662066216622662366246625662666276628662966306631663266336634663566366637663866396640664166426643664466456646664766486649665066516652665366546655665666576658665966606661666266636664666566666667666866696670667166726673667466756676667766786679668066816682668366846685668666876688668966906691669266936694669566966697669866996700670167026703670467056706670767086709671067116712671367146715671667176718671967206721672267236724672567266727672867296730673167326733673467356736673767386739674067416742674367446745674667476748674967506751675267536754675567566757675867596760676167626763676467656766676767686769677067716772677367746775677667776778677967806781678267836784678567866787678867896790679167926793679467956796679767986799680068016802680368046805680668076808680968106811681268136814681568166817681868196820682168226823682468256826682768286829683068316832683368346835683668376838683968406841684268436844684568466847684868496850685168526853685468556856685768586859686068616862686368646865686668676868686968706871687268736874687568766877687868796880688168826883688468856886688768886889689068916892689368946895689668976898689969006901690269036904690569066907690869096910691169126913691469156916691769186919692069216922692369246925692669276928692969306931693269336934693569366937693869396940694169426943694469456946694769486949695069516952695369546955695669576958695969606961696269636964696569666967696869696970697169726973697469756976697769786979698069816982698369846985698669876988698969906991699269936994699569966997699869997000700170027003700470057006700770087009701070117012701370147015701670177018701970207021702270237024702570267027702870297030703170327033703470357036703770387039704070417042704370447045704670477048704970507051705270537054705570567057705870597060706170627063706470657066706770687069707070717072707370747075707670777078707970807081708270837084708570867087708870897090709170927093709470957096709770987099710071017102710371047105710671077108710971107111711271137114711571167117711871197120712171227123712471257126712771287129713071317132713371347135713671377138713971407141714271437144714571467147714871497150715171527153715471557156715771587159716071617162716371647165716671677168716971707171717271737174717571767177717871797180718171827183718471857186718771887189719071917192719371947195719671977198719972007201720272037204720572067207720872097210721172127213721472157216721772187219722072217222722372247225722672277228722972307231723272337234723572367237723872397240724172427243724472457246724772487249725072517252725372547255725672577258725972607261726272637264726572667267726872697270727172727273727472757276727772787279728072817282728372847285728672877288728972907291729272937294729572967297729872997300730173027303730473057306730773087309731073117312731373147315731673177318731973207321732273237324732573267327732873297330733173327333733473357336733773387339734073417342734373447345734673477348734973507351735273537354735573567357735873597360736173627363736473657366736773687369737073717372737373747375737673777378737973807381738273837384738573867387738873897390739173927393739473957396739773987399740074017402740374047405740674077408740974107411741274137414741574167417741874197420742174227423742474257426742774287429743074317432743374347435743674377438743974407441744274437444744574467447744874497450745174527453745474557456745774587459746074617462746374647465746674677468746974707471747274737474747574767477747874797480748174827483748474857486748774887489749074917492749374947495749674977498749975007501750275037504750575067507750875097510751175127513751475157516751775187519752075217522752375247525752675277528752975307531753275337534753575367537753875397540754175427543754475457546754775487549755075517552755375547555755675577558755975607561756275637564756575667567756875697570757175727573757475757576757775787579758075817582758375847585758675877588758975907591759275937594759575967597759875997600760176027603760476057606760776087609761076117612761376147615761676177618761976207621762276237624762576267627762876297630763176327633763476357636763776387639764076417642764376447645764676477648764976507651765276537654765576567657765876597660766176627663766476657666766776687669767076717672767376747675767676777678767976807681768276837684768576867687768876897690769176927693769476957696769776987699770077017702770377047705770677077708770977107711771277137714771577167717771877197720772177227723772477257726772777287729773077317732773377347735773677377738773977407741774277437744774577467747774877497750775177527753775477557756775777587759776077617762776377647765776677677768776977707771777277737774777577767777777877797780778177827783778477857786778777887789779077917792779377947795779677977798779978007801780278037804780578067807780878097810781178127813781478157816781778187819782078217822782378247825782678277828782978307831783278337834783578367837783878397840784178427843784478457846784778487849785078517852785378547855785678577858785978607861786278637864786578667867786878697870787178727873787478757876787778787879788078817882788378847885788678877888788978907891789278937894789578967897789878997900790179027903790479057906790779087909791079117912791379147915791679177918791979207921792279237924792579267927792879297930793179327933793479357936793779387939794079417942794379447945794679477948794979507951795279537954795579567957795879597960796179627963796479657966796779687969797079717972797379747975797679777978797979807981798279837984798579867987798879897990799179927993799479957996799779987999800080018002800380048005800680078008800980108011801280138014801580168017801880198020802180228023802480258026802780288029803080318032803380348035803680378038803980408041804280438044804580468047804880498050805180528053805480558056805780588059806080618062806380648065806680678068806980708071807280738074807580768077807880798080808180828083808480858086808780888089809080918092809380948095809680978098809981008101810281038104810581068107810881098110811181128113811481158116811781188119812081218122812381248125812681278128812981308131813281338134813581368137813881398140814181428143814481458146814781488149815081518152815381548155815681578158815981608161816281638164816581668167816881698170817181728173817481758176817781788179818081818182818381848185818681878188818981908191819281938194819581968197819881998200820182028203820482058206820782088209821082118212821382148215821682178218821982208221822282238224822582268227822882298230823182328233823482358236823782388239824082418242824382448245824682478248824982508251825282538254825582568257825882598260826182628263826482658266826782688269827082718272827382748275827682778278827982808281828282838284828582868287828882898290829182928293829482958296829782988299830083018302830383048305830683078308830983108311831283138314831583168317831883198320832183228323832483258326832783288329833083318332833383348335833683378338833983408341834283438344834583468347834883498350835183528353835483558356835783588359836083618362836383648365836683678368836983708371837283738374837583768377837883798380838183828383838483858386838783888389839083918392839383948395839683978398839984008401840284038404840584068407840884098410841184128413841484158416841784188419842084218422842384248425842684278428842984308431843284338434843584368437843884398440844184428443844484458446844784488449845084518452845384548455845684578458845984608461846284638464846584668467846884698470847184728473847484758476847784788479848084818482848384848485848684878488848984908491849284938494849584968497849884998500850185028503850485058506850785088509851085118512851385148515851685178518851985208521852285238524852585268527852885298530853185328533853485358536853785388539854085418542854385448545854685478548854985508551855285538554855585568557855885598560856185628563856485658566856785688569857085718572857385748575857685778578857985808581858285838584858585868587858885898590859185928593859485958596859785988599860086018602860386048605860686078608860986108611861286138614861586168617861886198620862186228623862486258626862786288629863086318632863386348635863686378638863986408641864286438644864586468647864886498650865186528653865486558656865786588659866086618662866386648665866686678668866986708671867286738674867586768677867886798680868186828683868486858686868786888689869086918692869386948695869686978698869987008701870287038704870587068707870887098710871187128713871487158716871787188719872087218722872387248725872687278728872987308731873287338734873587368737873887398740874187428743874487458746874787488749875087518752875387548755875687578758875987608761876287638764876587668767876887698770877187728773877487758776877787788779878087818782878387848785878687878788878987908791879287938794879587968797879887998800880188028803880488058806880788088809881088118812881388148815881688178818881988208821882288238824882588268827882888298830883188328833883488358836883788388839884088418842884388448845884688478848884988508851885288538854885588568857885888598860886188628863886488658866886788688869887088718872887388748875887688778878887988808881888288838884888588868887888888898890889188928893889488958896889788988899890089018902890389048905890689078908890989108911891289138914891589168917891889198920892189228923892489258926892789288929893089318932893389348935893689378938893989408941894289438944894589468947894889498950895189528953895489558956895789588959896089618962896389648965896689678968896989708971897289738974897589768977897889798980898189828983898489858986898789888989899089918992899389948995899689978998899990009001900290039004900590069007900890099010901190129013901490159016901790189019902090219022902390249025902690279028902990309031903290339034903590369037903890399040904190429043904490459046904790489049905090519052905390549055905690579058905990609061906290639064906590669067906890699070907190729073907490759076907790789079908090819082908390849085908690879088908990909091909290939094909590969097909890999100910191029103910491059106910791089109911091119112911391149115911691179118911991209121912291239124912591269127912891299130913191329133913491359136913791389139914091419142914391449145914691479148914991509151915291539154915591569157915891599160916191629163916491659166916791689169917091719172917391749175917691779178917991809181918291839184918591869187918891899190919191929193919491959196919791989199920092019202920392049205920692079208920992109211921292139214921592169217921892199220922192229223922492259226922792289229923092319232923392349235923692379238923992409241924292439244924592469247924892499250925192529253925492559256925792589259926092619262926392649265926692679268926992709271927292739274927592769277927892799280928192829283928492859286928792889289929092919292929392949295929692979298929993009301930293039304930593069307930893099310931193129313931493159316931793189319932093219322932393249325932693279328932993309331933293339334933593369337933893399340934193429343934493459346934793489349935093519352935393549355935693579358935993609361936293639364936593669367936893699370937193729373937493759376937793789379938093819382938393849385938693879388938993909391939293939394939593969397939893999400940194029403940494059406940794089409941094119412941394149415941694179418941994209421942294239424942594269427942894299430943194329433943494359436943794389439944094419442944394449445944694479448944994509451945294539454945594569457945894599460946194629463946494659466946794689469947094719472947394749475947694779478947994809481948294839484948594869487948894899490949194929493949494959496949794989499950095019502950395049505950695079508950995109511951295139514951595169517951895199520952195229523952495259526952795289529953095319532953395349535953695379538953995409541954295439544954595469547954895499550955195529553955495559556955795589559956095619562956395649565956695679568956995709571957295739574957595769577957895799580958195829583958495859586958795889589959095919592959395949595959695979598959996009601960296039604960596069607960896099610961196129613961496159616961796189619962096219622962396249625962696279628962996309631963296339634963596369637963896399640964196429643964496459646964796489649965096519652965396549655965696579658965996609661966296639664966596669667966896699670967196729673967496759676967796789679968096819682968396849685968696879688968996909691969296939694969596969697969896999700970197029703970497059706970797089709971097119712971397149715971697179718971997209721972297239724972597269727972897299730973197329733973497359736973797389739974097419742974397449745974697479748974997509751975297539754975597569757975897599760976197629763976497659766976797689769977097719772977397749775977697779778977997809781978297839784978597869787978897899790979197929793979497959796979797989799980098019802980398049805980698079808980998109811981298139814981598169817981898199820982198229823982498259826982798289829983098319832983398349835983698379838983998409841984298439844984598469847984898499850985198529853985498559856985798589859986098619862986398649865986698679868986998709871987298739874987598769877987898799880988198829883988498859886988798889889989098919892989398949895989698979898989999009901990299039904990599069907990899099910991199129913991499159916991799189919992099219922992399249925992699279928992999309931993299339934993599369937993899399940994199429943994499459946994799489949995099519952995399549955995699579958995999609961996299639964996599669967996899699970997199729973997499759976997799789979998099819982998399849985998699879988998999909991999299939994999599969997999899991000010001100021000310004100051000610007100081000910010100111001210013100141001510016100171001810019100201002110022100231002410025100261002710028100291003010031100321003310034100351003610037100381003910040100411004210043100441004510046100471004810049100501005110052100531005410055100561005710058100591006010061100621006310064100651006610067100681006910070100711007210073100741007510076100771007810079100801008110082100831008410085100861008710088100891009010091100921009310094100951009610097100981009910100101011010210103101041010510106101071010810109101101011110112101131011410115101161011710118101191012010121101221012310124101251012610127101281012910130101311013210133101341013510136101371013810139101401014110142101431014410145101461014710148101491015010151101521015310154101551015610157101581015910160101611016210163101641016510166101671016810169101701017110172101731017410175101761017710178101791018010181101821018310184101851018610187101881018910190101911019210193101941019510196101971019810199102001020110202102031020410205102061020710208102091021010211102121021310214102151021610217102181021910220102211022210223102241022510226102271022810229102301023110232102331023410235102361023710238102391024010241102421024310244102451024610247102481024910250102511025210253102541025510256102571025810259102601026110262102631026410265102661026710268102691027010271102721027310274102751027610277102781027910280102811028210283102841028510286102871028810289102901029110292102931029410295102961029710298102991030010301103021030310304103051030610307103081030910310103111031210313103141031510316103171031810319103201032110322103231032410325103261032710328103291033010331103321033310334103351033610337103381033910340103411034210343103441034510346103471034810349103501035110352103531035410355103561035710358103591036010361103621036310364103651036610367103681036910370103711037210373103741037510376103771037810379103801038110382103831038410385103861038710388103891039010391103921039310394103951039610397103981039910400104011040210403104041040510406104071040810409104101041110412104131041410415104161041710418104191042010421104221042310424104251042610427104281042910430104311043210433104341043510436104371043810439104401044110442104431044410445104461044710448104491045010451104521045310454104551045610457104581045910460104611046210463104641046510466104671046810469104701047110472104731047410475104761047710478104791048010481104821048310484104851048610487104881048910490104911049210493104941049510496104971049810499105001050110502105031050410505105061050710508105091051010511105121051310514105151051610517105181051910520105211052210523105241052510526105271052810529105301053110532105331053410535105361053710538105391054010541105421054310544105451054610547105481054910550105511055210553105541055510556105571055810559105601056110562105631056410565105661056710568105691057010571105721057310574105751057610577105781057910580105811058210583105841058510586105871058810589105901059110592105931059410595105961059710598105991060010601106021060310604106051060610607106081060910610106111061210613106141061510616106171061810619106201062110622106231062410625106261062710628106291063010631106321063310634106351063610637106381063910640106411064210643106441064510646106471064810649106501065110652106531065410655106561065710658106591066010661106621066310664106651066610667106681066910670106711067210673106741067510676106771067810679106801068110682106831068410685106861068710688106891069010691106921069310694106951069610697106981069910700107011070210703107041070510706107071070810709107101071110712107131071410715107161071710718107191072010721107221072310724107251072610727107281072910730107311073210733107341073510736107371073810739107401074110742107431074410745107461074710748107491075010751107521075310754107551075610757107581075910760107611076210763107641076510766107671076810769107701077110772107731077410775107761077710778107791078010781107821078310784107851078610787107881078910790107911079210793107941079510796107971079810799108001080110802108031080410805108061080710808108091081010811108121081310814108151081610817108181081910820108211082210823108241082510826108271082810829108301083110832108331083410835108361083710838108391084010841108421084310844108451084610847108481084910850108511085210853108541085510856108571085810859108601086110862108631086410865108661086710868108691087010871108721087310874108751087610877108781087910880108811088210883108841088510886108871088810889108901089110892108931089410895108961089710898108991090010901109021090310904109051090610907109081090910910109111091210913109141091510916109171091810919109201092110922109231092410925109261092710928109291093010931109321093310934109351093610937109381093910940109411094210943109441094510946109471094810949109501095110952109531095410955109561095710958109591096010961109621096310964109651096610967109681096910970109711097210973109741097510976109771097810979109801098110982109831098410985109861098710988109891099010991109921099310994109951099610997109981099911000110011100211003110041100511006110071100811009110101101111012110131101411015110161101711018110191102011021110221102311024110251102611027110281102911030110311103211033110341103511036110371103811039110401104111042110431104411045110461104711048110491105011051110521105311054110551105611057110581105911060110611106211063110641106511066110671106811069110701107111072110731107411075110761107711078110791108011081110821108311084110851108611087110881108911090110911109211093110941109511096110971109811099111001110111102111031110411105111061110711108111091111011111111121111311114111151111611117111181111911120111211112211123111241112511126111271112811129111301113111132111331113411135111361113711138111391114011141111421114311144111451114611147111481114911150111511115211153111541115511156111571115811159111601116111162111631116411165111661116711168111691117011171111721117311174111751117611177111781117911180111811118211183111841118511186111871118811189111901119111192111931119411195111961119711198111991120011201112021120311204112051120611207112081120911210112111121211213112141121511216112171121811219112201122111222112231122411225112261122711228112291123011231112321123311234112351123611237112381123911240112411124211243112441124511246112471124811249112501125111252112531125411255112561125711258112591126011261112621126311264112651126611267112681126911270112711127211273112741127511276112771127811279112801128111282112831128411285112861128711288112891129011291112921129311294112951129611297112981129911300113011130211303113041130511306113071130811309113101131111312113131131411315113161131711318113191132011321113221132311324113251132611327113281132911330113311133211333113341133511336113371133811339113401134111342113431134411345113461134711348113491135011351113521135311354113551135611357113581135911360113611136211363113641136511366113671136811369113701137111372113731137411375113761137711378113791138011381113821138311384113851138611387113881138911390113911139211393113941139511396113971139811399114001140111402114031140411405114061140711408114091141011411114121141311414114151141611417114181141911420114211142211423114241142511426114271142811429114301143111432114331143411435114361143711438114391144011441114421144311444114451144611447114481144911450114511145211453114541145511456114571145811459114601146111462114631146411465114661146711468114691147011471114721147311474114751147611477114781147911480114811148211483114841148511486114871148811489114901149111492114931149411495114961149711498114991150011501115021150311504115051150611507115081150911510115111151211513115141151511516115171151811519115201152111522115231152411525115261152711528115291153011531115321153311534115351153611537115381153911540115411154211543115441154511546115471154811549115501155111552115531155411555115561155711558115591156011561115621156311564115651156611567115681156911570115711157211573115741157511576115771157811579115801158111582115831158411585115861158711588115891159011591115921159311594115951159611597115981159911600116011160211603116041160511606116071160811609116101161111612116131161411615116161161711618116191162011621116221162311624116251162611627116281162911630116311163211633116341163511636116371163811639116401164111642116431164411645116461164711648116491165011651116521165311654116551165611657116581165911660116611166211663116641166511666116671166811669116701167111672116731167411675116761167711678116791168011681116821168311684116851168611687116881168911690116911169211693116941169511696116971169811699117001170111702117031170411705117061170711708117091171011711117121171311714117151171611717117181171911720117211172211723117241172511726117271172811729117301173111732117331173411735117361173711738117391174011741117421174311744117451174611747117481174911750117511175211753117541175511756117571175811759117601176111762117631176411765117661176711768117691177011771117721177311774117751177611777117781177911780117811178211783117841178511786117871178811789117901179111792117931179411795117961179711798117991180011801118021180311804118051180611807118081180911810118111181211813118141181511816118171181811819118201182111822118231182411825118261182711828118291183011831118321183311834118351183611837118381183911840118411184211843118441184511846118471184811849118501185111852118531185411855118561185711858118591186011861118621186311864118651186611867118681186911870118711187211873118741187511876118771187811879118801188111882118831188411885118861188711888118891189011891118921189311894118951189611897118981189911900119011190211903119041190511906119071190811909119101191111912119131191411915119161191711918119191192011921119221192311924119251192611927119281192911930119311193211933119341193511936119371193811939119401194111942119431194411945119461194711948119491195011951119521195311954119551195611957119581195911960119611196211963119641196511966119671196811969119701197111972119731197411975119761197711978119791198011981119821198311984119851198611987119881198911990119911199211993119941199511996119971199811999120001200112002120031200412005120061200712008120091201012011120121201312014120151201612017120181201912020120211202212023120241202512026120271202812029120301203112032120331203412035120361203712038120391204012041120421204312044120451204612047120481204912050120511205212053120541205512056120571205812059120601206112062120631206412065120661206712068120691207012071120721207312074120751207612077120781207912080120811208212083120841208512086120871208812089120901209112092120931209412095120961209712098120991210012101121021210312104121051210612107121081210912110121111211212113121141211512116121171211812119121201212112122121231212412125121261212712128121291213012131121321213312134121351213612137121381213912140121411214212143121441214512146121471214812149121501215112152121531215412155121561215712158121591216012161121621216312164121651216612167121681216912170121711217212173121741217512176121771217812179121801218112182121831218412185121861218712188121891219012191121921219312194121951219612197121981219912200122011220212203122041220512206122071220812209122101221112212122131221412215122161221712218122191222012221122221222312224122251222612227122281222912230122311223212233122341223512236122371223812239122401224112242122431224412245122461224712248122491225012251122521225312254122551225612257122581225912260122611226212263122641226512266122671226812269122701227112272122731227412275122761227712278122791228012281122821228312284122851228612287122881228912290122911229212293122941229512296122971229812299123001230112302123031230412305123061230712308123091231012311123121231312314123151231612317123181231912320123211232212323123241232512326123271232812329123301233112332123331233412335123361233712338123391234012341123421234312344123451234612347123481234912350123511235212353123541235512356123571235812359123601236112362123631236412365123661236712368123691237012371123721237312374123751237612377123781237912380123811238212383123841238512386123871238812389123901239112392123931239412395123961239712398123991240012401124021240312404124051240612407124081240912410124111241212413124141241512416124171241812419124201242112422124231242412425124261242712428124291243012431124321243312434124351243612437124381243912440124411244212443124441244512446124471244812449124501245112452124531245412455124561245712458124591246012461124621246312464124651246612467124681246912470124711247212473124741247512476124771247812479124801248112482124831248412485124861248712488124891249012491124921249312494124951249612497124981249912500125011250212503125041250512506125071250812509125101251112512125131251412515125161251712518125191252012521125221252312524125251252612527125281252912530125311253212533125341253512536125371253812539125401254112542125431254412545125461254712548125491255012551125521255312554125551255612557125581255912560125611256212563125641256512566125671256812569125701257112572125731257412575125761257712578125791258012581125821258312584125851258612587125881258912590125911259212593125941259512596125971259812599126001260112602126031260412605126061260712608126091261012611126121261312614126151261612617126181261912620126211262212623126241262512626126271262812629126301263112632126331263412635126361263712638126391264012641126421264312644126451264612647126481264912650126511265212653126541265512656126571265812659126601266112662126631266412665126661266712668126691267012671126721267312674126751267612677126781267912680126811268212683126841268512686126871268812689126901269112692126931269412695126961269712698126991270012701127021270312704127051270612707127081270912710127111271212713127141271512716127171271812719127201272112722127231272412725127261272712728127291273012731127321273312734127351273612737127381273912740127411274212743127441274512746127471274812749127501275112752127531275412755127561275712758127591276012761127621276312764127651276612767127681276912770127711277212773127741277512776127771277812779127801278112782127831278412785127861278712788127891279012791127921279312794127951279612797127981279912800128011280212803128041280512806128071280812809128101281112812128131281412815128161281712818128191282012821128221282312824128251282612827128281282912830128311283212833128341283512836128371283812839128401284112842128431284412845128461284712848128491285012851128521285312854128551285612857128581285912860128611286212863128641286512866128671286812869128701287112872128731287412875128761287712878128791288012881128821288312884128851288612887128881288912890128911289212893128941289512896128971289812899129001290112902129031290412905129061290712908129091291012911129121291312914129151291612917129181291912920129211292212923129241292512926129271292812929129301293112932129331293412935129361293712938129391294012941129421294312944129451294612947129481294912950129511295212953129541295512956129571295812959129601296112962129631296412965129661296712968129691297012971129721297312974129751297612977129781297912980129811298212983129841298512986129871298812989129901299112992129931299412995129961299712998129991300013001130021300313004130051300613007130081300913010130111301213013130141301513016130171301813019130201302113022130231302413025130261302713028130291303013031130321303313034130351303613037130381303913040130411304213043130441304513046130471304813049130501305113052130531305413055130561305713058130591306013061130621306313064130651306613067130681306913070130711307213073130741307513076130771307813079130801308113082130831308413085130861308713088130891309013091130921309313094130951309613097130981309913100131011310213103131041310513106131071310813109131101311113112131131311413115131161311713118131191312013121131221312313124131251312613127131281312913130131311313213133131341313513136131371313813139131401314113142131431314413145131461314713148131491315013151131521315313154131551315613157131581315913160131611316213163131641316513166131671316813169131701317113172131731317413175131761317713178131791318013181131821318313184131851318613187131881318913190131911319213193131941319513196131971319813199132001320113202132031320413205132061320713208132091321013211132121321313214132151321613217132181321913220132211322213223132241322513226132271322813229132301323113232132331323413235132361323713238132391324013241132421324313244132451324613247132481324913250132511325213253132541325513256132571325813259132601326113262132631326413265132661326713268132691327013271132721327313274132751327613277132781327913280132811328213283132841328513286132871328813289132901329113292132931329413295132961329713298132991330013301133021330313304133051330613307133081330913310133111331213313133141331513316133171331813319133201332113322133231332413325133261332713328133291333013331133321333313334133351333613337133381333913340133411334213343133441334513346133471334813349133501335113352133531335413355133561335713358133591336013361133621336313364133651336613367133681336913370133711337213373133741337513376133771337813379133801338113382133831338413385133861338713388133891339013391133921339313394133951339613397133981339913400134011340213403134041340513406134071340813409134101341113412134131341413415134161341713418134191342013421134221342313424134251342613427134281342913430134311343213433134341343513436134371343813439134401344113442134431344413445134461344713448134491345013451134521345313454134551345613457134581345913460134611346213463134641346513466134671346813469134701347113472134731347413475134761347713478134791348013481134821348313484134851348613487134881348913490134911349213493134941349513496134971349813499135001350113502135031350413505135061350713508135091351013511135121351313514135151351613517135181351913520135211352213523135241352513526135271352813529135301353113532135331353413535135361353713538135391354013541135421354313544135451354613547135481354913550135511355213553135541355513556135571355813559135601356113562135631356413565135661356713568135691357013571135721357313574135751357613577135781357913580135811358213583135841358513586135871358813589135901359113592135931359413595135961359713598135991360013601136021360313604136051360613607136081360913610136111361213613136141361513616136171361813619136201362113622136231362413625136261362713628136291363013631136321363313634136351363613637136381363913640136411364213643136441364513646136471364813649136501365113652136531365413655136561365713658136591366013661136621366313664136651366613667136681366913670136711367213673136741367513676136771367813679136801368113682136831368413685136861368713688136891369013691136921369313694136951369613697136981369913700137011370213703137041370513706137071370813709137101371113712137131371413715137161371713718137191372013721137221372313724137251372613727137281372913730137311373213733137341373513736137371373813739137401374113742137431374413745137461374713748137491375013751137521375313754137551375613757137581375913760137611376213763137641376513766137671376813769137701377113772137731377413775137761377713778137791378013781137821378313784137851378613787137881378913790137911379213793137941379513796137971379813799138001380113802138031380413805138061380713808138091381013811138121381313814138151381613817138181381913820138211382213823138241382513826138271382813829138301383113832138331383413835138361383713838138391384013841138421384313844138451384613847138481384913850138511385213853138541385513856138571385813859138601386113862138631386413865138661386713868138691387013871138721387313874138751387613877138781387913880138811388213883138841388513886138871388813889138901389113892138931389413895138961389713898138991390013901139021390313904139051390613907139081390913910139111391213913139141391513916139171391813919139201392113922139231392413925139261392713928139291393013931139321393313934139351393613937139381393913940139411394213943139441394513946139471394813949139501395113952139531395413955139561395713958139591396013961139621396313964139651396613967139681396913970139711397213973139741397513976139771397813979139801398113982139831398413985139861398713988139891399013991139921399313994139951399613997139981399914000140011400214003140041400514006140071400814009140101401114012140131401414015140161401714018140191402014021140221402314024140251402614027140281402914030140311403214033140341403514036140371403814039140401404114042140431404414045140461404714048140491405014051140521405314054140551405614057140581405914060140611406214063140641406514066140671406814069140701407114072140731407414075140761407714078140791408014081140821408314084140851408614087140881408914090140911409214093140941409514096140971409814099141001410114102141031410414105141061410714108141091411014111141121411314114141151411614117141181411914120141211412214123141241412514126141271412814129141301413114132141331413414135141361413714138141391414014141141421414314144141451414614147141481414914150141511415214153141541415514156141571415814159141601416114162141631416414165141661416714168141691417014171141721417314174141751417614177141781417914180141811418214183141841418514186141871418814189141901419114192141931419414195141961419714198141991420014201142021420314204142051420614207142081420914210142111421214213142141421514216142171421814219142201422114222142231422414225142261422714228142291423014231142321423314234142351423614237142381423914240142411424214243142441424514246142471424814249142501425114252142531425414255142561425714258142591426014261142621426314264142651426614267142681426914270142711427214273142741427514276142771427814279142801428114282142831428414285142861428714288142891429014291142921429314294142951429614297142981429914300143011430214303143041430514306143071430814309143101431114312143131431414315143161431714318143191432014321143221432314324143251432614327143281432914330143311433214333143341433514336143371433814339143401434114342143431434414345143461434714348143491435014351143521435314354143551435614357143581435914360143611436214363143641436514366143671436814369143701437114372143731437414375143761437714378143791438014381143821438314384143851438614387143881438914390143911439214393143941439514396143971439814399144001440114402144031440414405144061440714408144091441014411144121441314414144151441614417144181441914420144211442214423144241442514426144271442814429144301443114432144331443414435144361443714438144391444014441144421444314444144451444614447144481444914450144511445214453144541445514456144571445814459144601446114462144631446414465144661446714468144691447014471144721447314474144751447614477144781447914480144811448214483144841448514486144871448814489144901449114492144931449414495144961449714498144991450014501145021450314504145051450614507145081450914510145111451214513145141451514516145171451814519145201452114522145231452414525145261452714528145291453014531145321453314534145351453614537145381453914540145411454214543145441454514546145471454814549145501455114552145531455414555145561455714558145591456014561145621456314564145651456614567145681456914570145711457214573145741457514576145771457814579145801458114582145831458414585145861458714588145891459014591145921459314594145951459614597145981459914600146011460214603146041460514606146071460814609146101461114612146131461414615146161461714618146191462014621146221462314624146251462614627146281462914630146311463214633146341463514636146371463814639146401464114642146431464414645146461464714648146491465014651146521465314654146551465614657146581465914660146611466214663146641466514666146671466814669146701467114672146731467414675146761467714678146791468014681146821468314684146851468614687146881468914690146911469214693146941469514696146971469814699147001470114702147031470414705147061470714708147091471014711147121471314714147151471614717147181471914720147211472214723147241472514726147271472814729147301473114732147331473414735147361473714738147391474014741147421474314744147451474614747147481474914750147511475214753147541475514756147571475814759147601476114762147631476414765147661476714768147691477014771147721477314774147751477614777147781477914780147811478214783147841478514786147871478814789147901479114792147931479414795147961479714798147991480014801148021480314804148051480614807148081480914810148111481214813148141481514816148171481814819148201482114822148231482414825148261482714828148291483014831148321483314834148351483614837148381483914840148411484214843148441484514846148471484814849148501485114852148531485414855148561485714858148591486014861148621486314864148651486614867148681486914870148711487214873148741487514876148771487814879148801488114882148831488414885148861488714888148891489014891148921489314894148951489614897148981489914900149011490214903149041490514906149071490814909149101491114912149131491414915149161491714918149191492014921149221492314924149251492614927149281492914930149311493214933149341493514936149371493814939149401494114942149431494414945149461494714948149491495014951149521495314954149551495614957149581495914960149611496214963149641496514966149671496814969149701497114972149731497414975149761497714978149791498014981149821498314984149851498614987149881498914990149911499214993149941499514996149971499814999150001500115002150031500415005150061500715008150091501015011150121501315014150151501615017150181501915020150211502215023150241502515026150271502815029150301503115032150331503415035150361503715038150391504015041150421504315044150451504615047150481504915050150511505215053150541505515056150571505815059150601506115062150631506415065150661506715068150691507015071150721507315074150751507615077150781507915080150811508215083150841508515086150871508815089150901509115092150931509415095150961509715098150991510015101151021510315104151051510615107151081510915110151111511215113151141511515116151171511815119151201512115122151231512415125151261512715128151291513015131151321513315134151351513615137151381513915140151411514215143151441514515146151471514815149151501515115152151531515415155151561515715158151591516015161151621516315164151651516615167151681516915170151711517215173151741517515176151771517815179151801518115182151831518415185151861518715188151891519015191151921519315194151951519615197151981519915200152011520215203152041520515206152071520815209152101521115212152131521415215152161521715218152191522015221152221522315224152251522615227152281522915230152311523215233152341523515236152371523815239152401524115242152431524415245152461524715248152491525015251152521525315254152551525615257152581525915260152611526215263152641526515266152671526815269152701527115272152731527415275152761527715278152791528015281152821528315284152851528615287152881528915290152911529215293152941529515296152971529815299153001530115302153031530415305153061530715308153091531015311153121531315314153151531615317153181531915320153211532215323153241532515326153271532815329153301533115332153331533415335153361533715338153391534015341153421534315344153451534615347153481534915350153511535215353153541535515356153571535815359153601536115362153631536415365153661536715368153691537015371153721537315374153751537615377153781537915380153811538215383153841538515386153871538815389153901539115392153931539415395153961539715398153991540015401154021540315404154051540615407154081540915410154111541215413154141541515416154171541815419154201542115422154231542415425154261542715428154291543015431154321543315434154351543615437154381543915440154411544215443154441544515446154471544815449154501545115452154531545415455154561545715458154591546015461154621546315464154651546615467154681546915470154711547215473154741547515476154771547815479154801548115482154831548415485154861548715488154891549015491154921549315494154951549615497154981549915500155011550215503155041550515506155071550815509155101551115512155131551415515155161551715518155191552015521155221552315524155251552615527155281552915530155311553215533155341553515536155371553815539155401554115542155431554415545155461554715548155491555015551155521555315554155551555615557155581555915560155611556215563155641556515566155671556815569155701557115572155731557415575155761557715578155791558015581155821558315584155851558615587155881558915590155911559215593155941559515596155971559815599156001560115602156031560415605156061560715608156091561015611156121561315614156151561615617156181561915620156211562215623156241562515626156271562815629156301563115632156331563415635156361563715638156391564015641156421564315644156451564615647156481564915650156511565215653156541565515656156571565815659156601566115662156631566415665156661566715668156691567015671156721567315674156751567615677156781567915680156811568215683156841568515686156871568815689156901569115692156931569415695156961569715698156991570015701157021570315704157051570615707157081570915710157111571215713157141571515716157171571815719157201572115722157231572415725157261572715728157291573015731157321573315734157351573615737157381573915740157411574215743157441574515746157471574815749157501575115752157531575415755157561575715758157591576015761157621576315764157651576615767157681576915770157711577215773157741577515776157771577815779157801578115782157831578415785157861578715788157891579015791157921579315794157951579615797157981579915800158011580215803158041580515806158071580815809158101581115812158131581415815158161581715818158191582015821158221582315824158251582615827158281582915830158311583215833158341583515836158371583815839158401584115842158431584415845158461584715848158491585015851158521585315854158551585615857158581585915860158611586215863158641586515866158671586815869158701587115872158731587415875158761587715878158791588015881158821588315884158851588615887158881588915890158911589215893158941589515896158971589815899159001590115902159031590415905159061590715908159091591015911159121591315914159151591615917159181591915920159211592215923159241592515926159271592815929159301593115932159331593415935159361593715938159391594015941159421594315944159451594615947159481594915950159511595215953159541595515956159571595815959159601596115962159631596415965159661596715968159691597015971159721597315974159751597615977159781597915980159811598215983159841598515986159871598815989159901599115992159931599415995159961599715998159991600016001160021600316004160051600616007160081600916010160111601216013160141601516016160171601816019160201602116022160231602416025160261602716028160291603016031160321603316034160351603616037160381603916040160411604216043160441604516046160471604816049160501605116052160531605416055160561605716058160591606016061160621606316064160651606616067160681606916070160711607216073160741607516076160771607816079160801608116082160831608416085160861608716088160891609016091160921609316094160951609616097160981609916100161011610216103161041610516106161071610816109161101611116112161131611416115161161611716118161191612016121161221612316124161251612616127161281612916130161311613216133161341613516136161371613816139161401614116142161431614416145161461614716148161491615016151161521615316154161551615616157161581615916160161611616216163161641616516166161671616816169161701617116172161731617416175161761617716178161791618016181161821618316184161851618616187161881618916190161911619216193161941619516196161971619816199162001620116202162031620416205162061620716208162091621016211162121621316214162151621616217162181621916220162211622216223162241622516226162271622816229162301623116232162331623416235162361623716238162391624016241162421624316244162451624616247162481624916250162511625216253162541625516256162571625816259162601626116262162631626416265162661626716268162691627016271162721627316274162751627616277162781627916280162811628216283162841628516286162871628816289162901629116292162931629416295162961629716298162991630016301163021630316304163051630616307163081630916310163111631216313163141631516316163171631816319163201632116322163231632416325163261632716328163291633016331163321633316334163351633616337163381633916340163411634216343163441634516346163471634816349163501635116352163531635416355163561635716358163591636016361163621636316364163651636616367163681636916370163711637216373163741637516376163771637816379163801638116382163831638416385163861638716388163891639016391163921639316394163951639616397163981639916400164011640216403164041640516406164071640816409164101641116412164131641416415164161641716418164191642016421164221642316424164251642616427164281642916430164311643216433164341643516436164371643816439164401644116442164431644416445164461644716448164491645016451164521645316454164551645616457164581645916460164611646216463164641646516466164671646816469164701647116472164731647416475164761647716478164791648016481164821648316484164851648616487164881648916490164911649216493164941649516496164971649816499165001650116502165031650416505165061650716508165091651016511165121651316514165151651616517165181651916520165211652216523165241652516526165271652816529165301653116532165331653416535165361653716538165391654016541165421654316544165451654616547165481654916550165511655216553165541655516556165571655816559165601656116562165631656416565165661656716568165691657016571165721657316574165751657616577165781657916580165811658216583165841658516586165871658816589165901659116592165931659416595165961659716598165991660016601166021660316604166051660616607166081660916610166111661216613166141661516616166171661816619166201662116622166231662416625166261662716628166291663016631166321663316634166351663616637166381663916640166411664216643166441664516646166471664816649166501665116652166531665416655166561665716658166591666016661166621666316664166651666616667166681666916670166711667216673166741667516676166771667816679166801668116682166831668416685166861668716688166891669016691166921669316694166951669616697166981669916700167011670216703167041670516706167071670816709167101671116712167131671416715167161671716718167191672016721167221672316724167251672616727167281672916730167311673216733167341673516736167371673816739167401674116742167431674416745167461674716748167491675016751167521675316754167551675616757167581675916760167611676216763167641676516766167671676816769167701677116772167731677416775167761677716778167791678016781167821678316784167851678616787167881678916790167911679216793167941679516796167971679816799168001680116802168031680416805168061680716808168091681016811168121681316814168151681616817168181681916820168211682216823168241682516826168271682816829168301683116832168331683416835168361683716838168391684016841168421684316844168451684616847168481684916850168511685216853168541685516856168571685816859168601686116862168631686416865168661686716868168691687016871168721687316874168751687616877168781687916880168811688216883168841688516886168871688816889168901689116892168931689416895168961689716898168991690016901169021690316904169051690616907169081690916910169111691216913169141691516916169171691816919169201692116922169231692416925169261692716928169291693016931169321693316934169351693616937169381693916940169411694216943169441694516946169471694816949169501695116952169531695416955169561695716958169591696016961169621696316964169651696616967169681696916970169711697216973169741697516976169771697816979169801698116982169831698416985169861698716988169891699016991169921699316994169951699616997169981699917000170011700217003170041700517006170071700817009170101701117012170131701417015170161701717018170191702017021170221702317024170251702617027170281702917030170311703217033170341703517036170371703817039170401704117042170431704417045170461704717048170491705017051170521705317054170551705617057170581705917060170611706217063170641706517066170671706817069170701707117072170731707417075170761707717078170791708017081170821708317084170851708617087170881708917090170911709217093170941709517096170971709817099171001710117102171031710417105171061710717108171091711017111171121711317114171151711617117171181711917120171211712217123171241712517126171271712817129171301713117132171331713417135171361713717138171391714017141171421714317144171451714617147171481714917150171511715217153171541715517156171571715817159171601716117162171631716417165171661716717168171691717017171171721717317174171751717617177171781717917180171811718217183171841718517186171871718817189171901719117192171931719417195171961719717198171991720017201172021720317204172051720617207172081720917210172111721217213172141721517216172171721817219172201722117222172231722417225172261722717228172291723017231172321723317234172351723617237172381723917240172411724217243172441724517246172471724817249172501725117252172531725417255172561725717258172591726017261172621726317264172651726617267172681726917270172711727217273172741727517276172771727817279172801728117282172831728417285172861728717288172891729017291172921729317294172951729617297172981729917300173011730217303173041730517306173071730817309173101731117312173131731417315173161731717318173191732017321173221732317324173251732617327173281732917330173311733217333173341733517336173371733817339173401734117342173431734417345173461734717348173491735017351173521735317354173551735617357173581735917360173611736217363173641736517366173671736817369173701737117372173731737417375173761737717378173791738017381173821738317384173851738617387173881738917390173911739217393173941739517396173971739817399174001740117402174031740417405174061740717408174091741017411174121741317414174151741617417174181741917420174211742217423174241742517426174271742817429174301743117432174331743417435174361743717438174391744017441174421744317444174451744617447174481744917450174511745217453174541745517456174571745817459174601746117462174631746417465174661746717468174691747017471174721747317474174751747617477174781747917480174811748217483174841748517486174871748817489174901749117492174931749417495174961749717498174991750017501175021750317504175051750617507175081750917510175111751217513175141751517516175171751817519175201752117522175231752417525175261752717528175291753017531175321753317534175351753617537175381753917540175411754217543175441754517546175471754817549175501755117552175531755417555175561755717558175591756017561175621756317564175651756617567175681756917570175711757217573175741757517576175771757817579175801758117582175831758417585175861758717588175891759017591175921759317594175951759617597175981759917600176011760217603176041760517606176071760817609176101761117612176131761417615176161761717618176191762017621176221762317624176251762617627176281762917630176311763217633176341763517636176371763817639176401764117642176431764417645176461764717648176491765017651176521765317654176551765617657176581765917660176611766217663176641766517666176671766817669176701767117672176731767417675176761767717678176791768017681176821768317684176851768617687176881768917690176911769217693176941769517696176971769817699177001770117702177031770417705177061770717708177091771017711177121771317714177151771617717177181771917720177211772217723177241772517726177271772817729177301773117732177331773417735177361773717738177391774017741177421774317744177451774617747177481774917750177511775217753177541775517756177571775817759177601776117762177631776417765177661776717768177691777017771177721777317774177751777617777177781777917780177811778217783177841778517786177871778817789177901779117792177931779417795177961779717798177991780017801178021780317804178051780617807178081780917810178111781217813178141781517816178171781817819178201782117822178231782417825178261782717828178291783017831178321783317834178351783617837178381783917840178411784217843178441784517846178471784817849178501785117852178531785417855178561785717858178591786017861178621786317864178651786617867178681786917870178711787217873178741787517876178771787817879178801788117882178831788417885178861788717888178891789017891178921789317894178951789617897178981789917900179011790217903179041790517906179071790817909179101791117912179131791417915179161791717918179191792017921179221792317924179251792617927179281792917930179311793217933179341793517936179371793817939179401794117942179431794417945179461794717948179491795017951179521795317954179551795617957179581795917960179611796217963179641796517966179671796817969179701797117972179731797417975179761797717978179791798017981179821798317984179851798617987179881798917990179911799217993179941799517996179971799817999180001800118002180031800418005180061800718008180091801018011180121801318014180151801618017180181801918020180211802218023180241802518026180271802818029180301803118032180331803418035180361803718038180391804018041180421804318044180451804618047180481804918050180511805218053180541805518056180571805818059180601806118062180631806418065180661806718068180691807018071180721807318074180751807618077180781807918080180811808218083180841808518086180871808818089180901809118092180931809418095180961809718098180991810018101181021810318104181051810618107181081810918110181111811218113181141811518116181171811818119181201812118122181231812418125181261812718128181291813018131181321813318134181351813618137181381813918140181411814218143181441814518146181471814818149181501815118152181531815418155181561815718158181591816018161181621816318164181651816618167181681816918170181711817218173181741817518176181771817818179181801818118182181831818418185181861818718188181891819018191181921819318194181951819618197181981819918200182011820218203182041820518206182071820818209182101821118212182131821418215182161821718218182191822018221182221822318224182251822618227182281822918230182311823218233182341823518236182371823818239182401824118242182431824418245182461824718248182491825018251182521825318254182551825618257182581825918260182611826218263182641826518266182671826818269182701827118272182731827418275182761827718278182791828018281182821828318284182851828618287182881828918290182911829218293182941829518296182971829818299183001830118302183031830418305183061830718308183091831018311183121831318314183151831618317183181831918320183211832218323183241832518326183271832818329183301833118332183331833418335183361833718338183391834018341183421834318344183451834618347183481834918350183511835218353183541835518356183571835818359183601836118362183631836418365183661836718368183691837018371183721837318374183751837618377183781837918380183811838218383183841838518386183871838818389183901839118392183931839418395183961839718398183991840018401184021840318404184051840618407184081840918410184111841218413184141841518416184171841818419184201842118422184231842418425184261842718428184291843018431184321843318434184351843618437184381843918440184411844218443184441844518446184471844818449184501845118452184531845418455184561845718458184591846018461184621846318464184651846618467184681846918470184711847218473184741847518476184771847818479184801848118482184831848418485184861848718488184891849018491184921849318494184951849618497184981849918500185011850218503185041850518506185071850818509185101851118512185131851418515185161851718518185191852018521185221852318524185251852618527185281852918530185311853218533185341853518536185371853818539185401854118542185431854418545185461854718548185491855018551185521855318554185551855618557185581855918560185611856218563185641856518566185671856818569185701857118572185731857418575185761857718578185791858018581185821858318584185851858618587185881858918590185911859218593185941859518596185971859818599186001860118602186031860418605186061860718608186091861018611186121861318614186151861618617186181861918620186211862218623186241862518626186271862818629186301863118632186331863418635186361863718638186391864018641186421864318644186451864618647186481864918650186511865218653186541865518656186571865818659186601866118662186631866418665186661866718668186691867018671186721867318674186751867618677186781867918680186811868218683186841868518686186871868818689186901869118692186931869418695186961869718698186991870018701187021870318704187051870618707187081870918710187111871218713187141871518716187171871818719187201872118722187231872418725187261872718728187291873018731187321873318734187351873618737187381873918740187411874218743187441874518746187471874818749187501875118752187531875418755187561875718758187591876018761187621876318764187651876618767187681876918770187711877218773187741877518776187771877818779187801878118782187831878418785187861878718788187891879018791187921879318794187951879618797187981879918800188011880218803188041880518806188071880818809188101881118812188131881418815188161881718818188191882018821188221882318824188251882618827188281882918830188311883218833188341883518836188371883818839188401884118842188431884418845188461884718848188491885018851188521885318854188551885618857188581885918860188611886218863188641886518866188671886818869188701887118872188731887418875188761887718878188791888018881188821888318884188851888618887188881888918890188911889218893188941889518896188971889818899189001890118902189031890418905189061890718908189091891018911189121891318914189151891618917189181891918920189211892218923189241892518926189271892818929189301893118932189331893418935189361893718938189391894018941189421894318944189451894618947189481894918950189511895218953189541895518956189571895818959189601896118962189631896418965189661896718968189691897018971189721897318974189751897618977189781897918980189811898218983189841898518986189871898818989189901899118992189931899418995189961899718998189991900019001190021900319004190051900619007190081900919010190111901219013190141901519016190171901819019190201902119022190231902419025190261902719028190291903019031190321903319034190351903619037190381903919040190411904219043190441904519046190471904819049190501905119052190531905419055190561905719058190591906019061190621906319064190651906619067190681906919070190711907219073190741907519076190771907819079190801908119082190831908419085190861908719088190891909019091190921909319094190951909619097190981909919100191011910219103191041910519106191071910819109191101911119112191131911419115191161911719118191191912019121191221912319124191251912619127191281912919130191311913219133191341913519136191371913819139191401914119142191431914419145191461914719148191491915019151191521915319154191551915619157191581915919160191611916219163191641916519166191671916819169191701917119172191731917419175191761917719178191791918019181191821918319184191851918619187191881918919190191911919219193191941919519196191971919819199192001920119202192031920419205192061920719208192091921019211192121921319214192151921619217192181921919220192211922219223192241922519226192271922819229192301923119232192331923419235192361923719238192391924019241192421924319244192451924619247192481924919250192511925219253192541925519256192571925819259192601926119262192631926419265192661926719268192691927019271192721927319274192751927619277192781927919280192811928219283192841928519286192871928819289192901929119292192931929419295192961929719298192991930019301193021930319304193051930619307193081930919310193111931219313193141931519316193171931819319193201932119322193231932419325193261932719328193291933019331193321933319334193351933619337193381933919340193411934219343193441934519346193471934819349193501935119352193531935419355193561935719358193591936019361193621936319364193651936619367193681936919370193711937219373193741937519376193771937819379193801938119382193831938419385193861938719388193891939019391193921939319394193951939619397193981939919400194011940219403194041940519406194071940819409194101941119412194131941419415194161941719418194191942019421194221942319424194251942619427194281942919430194311943219433194341943519436194371943819439194401944119442194431944419445194461944719448194491945019451194521945319454194551945619457194581945919460194611946219463194641946519466194671946819469194701947119472194731947419475194761947719478194791948019481194821948319484194851948619487194881948919490194911949219493194941949519496194971949819499195001950119502195031950419505195061950719508195091951019511195121951319514195151951619517195181951919520195211952219523195241952519526195271952819529195301953119532195331953419535195361953719538195391954019541195421954319544195451954619547195481954919550195511955219553195541955519556195571955819559195601956119562195631956419565195661956719568195691957019571195721957319574195751957619577195781957919580195811958219583195841958519586195871958819589195901959119592195931959419595195961959719598195991960019601196021960319604196051960619607196081960919610196111961219613196141961519616196171961819619196201962119622196231962419625196261962719628196291963019631196321963319634196351963619637196381963919640196411964219643196441964519646196471964819649196501965119652196531965419655196561965719658196591966019661196621966319664196651966619667196681966919670196711967219673196741967519676196771967819679196801968119682196831968419685196861968719688196891969019691196921969319694196951969619697196981969919700197011970219703197041970519706197071970819709197101971119712197131971419715197161971719718197191972019721197221972319724197251972619727197281972919730197311973219733197341973519736197371973819739197401974119742197431974419745197461974719748197491975019751197521975319754197551975619757197581975919760197611976219763197641976519766197671976819769197701977119772197731977419775197761977719778197791978019781197821978319784197851978619787197881978919790197911979219793197941979519796197971979819799198001980119802198031980419805198061980719808198091981019811198121981319814198151981619817198181981919820198211982219823198241982519826198271982819829198301983119832198331983419835198361983719838198391984019841198421984319844198451984619847198481984919850198511985219853198541985519856198571985819859198601986119862198631986419865198661986719868198691987019871198721987319874198751987619877198781987919880198811988219883198841988519886198871988819889198901989119892198931989419895198961989719898198991990019901199021990319904199051990619907199081990919910199111991219913199141991519916199171991819919199201992119922199231992419925199261992719928199291993019931199321993319934199351993619937199381993919940199411994219943199441994519946199471994819949199501995119952199531995419955199561995719958199591996019961199621996319964199651996619967199681996919970199711997219973199741997519976199771997819979199801998119982199831998419985199861998719988199891999019991199921999319994199951999619997199981999920000200012000220003200042000520006200072000820009200102001120012200132001420015200162001720018200192002020021200222002320024200252002620027200282002920030200312003220033200342003520036200372003820039200402004120042200432004420045200462004720048200492005020051200522005320054200552005620057200582005920060200612006220063200642006520066200672006820069200702007120072200732007420075200762007720078200792008020081200822008320084200852008620087200882008920090200912009220093200942009520096200972009820099201002010120102201032010420105201062010720108201092011020111201122011320114201152011620117201182011920120201212012220123201242012520126201272012820129201302013120132201332013420135201362013720138201392014020141201422014320144201452014620147201482014920150201512015220153201542015520156201572015820159201602016120162201632016420165201662016720168201692017020171201722017320174201752017620177201782017920180201812018220183201842018520186201872018820189201902019120192201932019420195201962019720198201992020020201202022020320204202052020620207202082020920210202112021220213202142021520216202172021820219202202022120222202232022420225202262022720228202292023020231202322023320234202352023620237202382023920240202412024220243202442024520246202472024820249202502025120252202532025420255202562025720258202592026020261202622026320264202652026620267202682026920270202712027220273202742027520276202772027820279202802028120282202832028420285202862028720288202892029020291202922029320294202952029620297202982029920300203012030220303203042030520306203072030820309203102031120312203132031420315203162031720318203192032020321203222032320324203252032620327203282032920330203312033220333203342033520336203372033820339203402034120342203432034420345203462034720348203492035020351203522035320354203552035620357203582035920360203612036220363203642036520366203672036820369203702037120372203732037420375203762037720378203792038020381203822038320384203852038620387203882038920390203912039220393203942039520396203972039820399204002040120402204032040420405204062040720408204092041020411204122041320414204152041620417204182041920420204212042220423204242042520426204272042820429204302043120432204332043420435204362043720438204392044020441204422044320444204452044620447204482044920450204512045220453204542045520456204572045820459204602046120462204632046420465204662046720468204692047020471204722047320474204752047620477204782047920480204812048220483204842048520486204872048820489204902049120492204932049420495204962049720498204992050020501205022050320504205052050620507205082050920510205112051220513205142051520516205172051820519205202052120522205232052420525205262052720528205292053020531205322053320534205352053620537205382053920540205412054220543205442054520546205472054820549205502055120552205532055420555205562055720558205592056020561205622056320564205652056620567205682056920570205712057220573205742057520576205772057820579205802058120582205832058420585205862058720588205892059020591205922059320594205952059620597205982059920600206012060220603206042060520606206072060820609206102061120612206132061420615206162061720618206192062020621206222062320624206252062620627206282062920630206312063220633206342063520636206372063820639206402064120642206432064420645206462064720648206492065020651206522065320654206552065620657206582065920660206612066220663206642066520666206672066820669206702067120672206732067420675206762067720678206792068020681206822068320684206852068620687206882068920690206912069220693206942069520696206972069820699207002070120702207032070420705207062070720708207092071020711207122071320714207152071620717207182071920720207212072220723207242072520726207272072820729207302073120732207332073420735207362073720738207392074020741207422074320744207452074620747207482074920750207512075220753207542075520756207572075820759207602076120762207632076420765207662076720768207692077020771207722077320774207752077620777207782077920780207812078220783207842078520786207872078820789207902079120792207932079420795207962079720798207992080020801208022080320804208052080620807208082080920810208112081220813208142081520816208172081820819208202082120822208232082420825208262082720828208292083020831208322083320834208352083620837208382083920840208412084220843208442084520846208472084820849208502085120852208532085420855208562085720858208592086020861208622086320864208652086620867208682086920870208712087220873208742087520876208772087820879208802088120882208832088420885208862088720888208892089020891208922089320894208952089620897208982089920900209012090220903209042090520906209072090820909209102091120912209132091420915209162091720918209192092020921209222092320924209252092620927209282092920930209312093220933209342093520936209372093820939209402094120942209432094420945209462094720948209492095020951209522095320954209552095620957209582095920960209612096220963209642096520966209672096820969209702097120972209732097420975209762097720978209792098020981209822098320984209852098620987209882098920990209912099220993209942099520996209972099820999210002100121002210032100421005210062100721008210092101021011210122101321014210152101621017210182101921020210212102221023210242102521026210272102821029210302103121032210332103421035210362103721038210392104021041210422104321044210452104621047210482104921050210512105221053210542105521056210572105821059210602106121062210632106421065210662106721068210692107021071210722107321074210752107621077210782107921080210812108221083210842108521086210872108821089210902109121092210932109421095210962109721098210992110021101211022110321104211052110621107211082110921110211112111221113211142111521116211172111821119211202112121122211232112421125211262112721128211292113021131211322113321134211352113621137211382113921140211412114221143211442114521146211472114821149211502115121152211532115421155211562115721158211592116021161211622116321164211652116621167211682116921170211712117221173211742117521176211772117821179211802118121182211832118421185211862118721188211892119021191211922119321194211952119621197211982119921200212012120221203212042120521206212072120821209212102121121212212132121421215212162121721218212192122021221212222122321224212252122621227212282122921230212312123221233212342123521236212372123821239212402124121242212432124421245212462124721248212492125021251212522125321254212552125621257212582125921260212612126221263212642126521266212672126821269212702127121272212732127421275212762127721278212792128021281212822128321284212852128621287212882128921290212912129221293212942129521296212972129821299213002130121302213032130421305213062130721308213092131021311213122131321314213152131621317213182131921320213212132221323213242132521326213272132821329213302133121332213332133421335213362133721338213392134021341213422134321344213452134621347213482134921350213512135221353213542135521356213572135821359213602136121362213632136421365213662136721368213692137021371213722137321374213752137621377213782137921380213812138221383213842138521386213872138821389213902139121392213932139421395213962139721398213992140021401214022140321404214052140621407214082140921410214112141221413214142141521416214172141821419214202142121422214232142421425214262142721428214292143021431214322143321434214352143621437214382143921440214412144221443214442144521446214472144821449214502145121452214532145421455214562145721458214592146021461214622146321464214652146621467214682146921470214712147221473214742147521476214772147821479214802148121482214832148421485214862148721488214892149021491214922149321494214952149621497214982149921500215012150221503215042150521506215072150821509215102151121512215132151421515215162151721518215192152021521215222152321524215252152621527215282152921530215312153221533215342153521536215372153821539215402154121542215432154421545215462154721548215492155021551215522155321554215552155621557215582155921560215612156221563215642156521566215672156821569215702157121572215732157421575215762157721578215792158021581215822158321584215852158621587215882158921590215912159221593215942159521596215972159821599216002160121602216032160421605216062160721608216092161021611216122161321614216152161621617216182161921620216212162221623216242162521626216272162821629216302163121632216332163421635216362163721638216392164021641216422164321644216452164621647216482164921650216512165221653216542165521656216572165821659216602166121662216632166421665216662166721668216692167021671216722167321674216752167621677216782167921680216812168221683216842168521686216872168821689216902169121692216932169421695216962169721698216992170021701217022170321704217052170621707217082170921710217112171221713217142171521716217172171821719217202172121722217232172421725217262172721728217292173021731217322173321734217352173621737217382173921740217412174221743217442174521746217472174821749217502175121752217532175421755217562175721758217592176021761217622176321764217652176621767217682176921770217712177221773217742177521776217772177821779217802178121782217832178421785217862178721788217892179021791217922179321794217952179621797217982179921800218012180221803218042180521806218072180821809218102181121812218132181421815218162181721818218192182021821218222182321824218252182621827218282182921830218312183221833218342183521836218372183821839218402184121842218432184421845218462184721848218492185021851218522185321854218552185621857218582185921860218612186221863218642186521866218672186821869218702187121872218732187421875218762187721878218792188021881218822188321884218852188621887218882188921890218912189221893218942189521896218972189821899219002190121902219032190421905219062190721908219092191021911219122191321914219152191621917219182191921920219212192221923219242192521926219272192821929219302193121932219332193421935219362193721938219392194021941219422194321944219452194621947219482194921950219512195221953219542195521956219572195821959219602196121962219632196421965219662196721968219692197021971219722197321974219752197621977219782197921980219812198221983219842198521986219872198821989219902199121992219932199421995219962199721998219992200022001220022200322004220052200622007220082200922010220112201222013220142201522016220172201822019220202202122022220232202422025220262202722028220292203022031220322203322034220352203622037220382203922040220412204222043220442204522046220472204822049220502205122052220532205422055220562205722058220592206022061220622206322064220652206622067220682206922070220712207222073220742207522076220772207822079220802208122082220832208422085220862208722088220892209022091220922209322094220952209622097220982209922100221012210222103221042210522106221072210822109221102211122112221132211422115221162211722118221192212022121221222212322124221252212622127221282212922130221312213222133221342213522136221372213822139221402214122142221432214422145221462214722148221492215022151221522215322154221552215622157221582215922160221612216222163221642216522166221672216822169221702217122172221732217422175221762217722178221792218022181221822218322184221852218622187221882218922190221912219222193221942219522196221972219822199222002220122202222032220422205222062220722208222092221022211222122221322214222152221622217222182221922220222212222222223222242222522226222272222822229222302223122232222332223422235222362223722238222392224022241222422224322244222452224622247222482224922250222512225222253222542225522256222572225822259222602226122262222632226422265222662226722268222692227022271222722227322274222752227622277222782227922280222812228222283222842228522286222872228822289222902229122292222932229422295222962229722298222992230022301223022230322304223052230622307223082230922310223112231222313223142231522316223172231822319223202232122322223232232422325223262232722328223292233022331223322233322334223352233622337223382233922340223412234222343223442234522346223472234822349223502235122352223532235422355223562235722358223592236022361223622236322364223652236622367223682236922370223712237222373223742237522376223772237822379223802238122382223832238422385223862238722388223892239022391223922239322394223952239622397223982239922400224012240222403224042240522406224072240822409224102241122412224132241422415224162241722418224192242022421224222242322424224252242622427224282242922430224312243222433224342243522436224372243822439224402244122442224432244422445224462244722448224492245022451224522245322454224552245622457224582245922460224612246222463224642246522466224672246822469224702247122472224732247422475224762247722478224792248022481224822248322484224852248622487224882248922490224912249222493224942249522496224972249822499225002250122502225032250422505225062250722508225092251022511225122251322514225152251622517225182251922520225212252222523225242252522526225272252822529225302253122532225332253422535225362253722538225392254022541225422254322544225452254622547225482254922550225512255222553225542255522556225572255822559225602256122562225632256422565225662256722568225692257022571225722257322574225752257622577225782257922580225812258222583225842258522586225872258822589225902259122592225932259422595225962259722598225992260022601226022260322604226052260622607226082260922610226112261222613226142261522616226172261822619226202262122622226232262422625226262262722628226292263022631226322263322634226352263622637226382263922640226412264222643226442264522646226472264822649226502265122652226532265422655226562265722658226592266022661226622266322664226652266622667226682266922670226712267222673226742267522676226772267822679226802268122682226832268422685226862268722688226892269022691226922269322694226952269622697226982269922700227012270222703227042270522706227072270822709227102271122712227132271422715227162271722718227192272022721227222272322724227252272622727227282272922730227312273222733227342273522736227372273822739227402274122742227432274422745227462274722748227492275022751227522275322754227552275622757227582275922760227612276222763227642276522766227672276822769227702277122772227732277422775227762277722778227792278022781227822278322784227852278622787227882278922790227912279222793227942279522796227972279822799228002280122802228032280422805228062280722808228092281022811228122281322814228152281622817228182281922820228212282222823228242282522826228272282822829228302283122832228332283422835228362283722838228392284022841228422284322844228452284622847228482284922850228512285222853228542285522856228572285822859228602286122862228632286422865228662286722868228692287022871228722287322874228752287622877228782287922880228812288222883228842288522886228872288822889228902289122892228932289422895228962289722898228992290022901229022290322904229052290622907229082290922910229112291222913229142291522916229172291822919229202292122922229232292422925229262292722928229292293022931229322293322934229352293622937229382293922940229412294222943229442294522946229472294822949229502295122952229532295422955229562295722958229592296022961229622296322964229652296622967229682296922970229712297222973229742297522976229772297822979229802298122982229832298422985229862298722988229892299022991229922299322994229952299622997229982299923000230012300223003230042300523006230072300823009230102301123012230132301423015230162301723018230192302023021230222302323024230252302623027230282302923030230312303223033230342303523036230372303823039230402304123042230432304423045230462304723048230492305023051230522305323054230552305623057230582305923060230612306223063230642306523066230672306823069230702307123072230732307423075230762307723078230792308023081230822308323084230852308623087230882308923090230912309223093230942309523096230972309823099231002310123102231032310423105231062310723108231092311023111231122311323114231152311623117231182311923120231212312223123231242312523126231272312823129231302313123132231332313423135231362313723138231392314023141231422314323144231452314623147231482314923150231512315223153231542315523156231572315823159231602316123162231632316423165231662316723168231692317023171231722317323174231752317623177231782317923180231812318223183231842318523186231872318823189231902319123192231932319423195231962319723198231992320023201232022320323204232052320623207232082320923210232112321223213232142321523216232172321823219232202322123222232232322423225232262322723228232292323023231232322323323234232352323623237232382323923240232412324223243232442324523246232472324823249232502325123252232532325423255232562325723258232592326023261232622326323264232652326623267232682326923270232712327223273232742327523276232772327823279232802328123282232832328423285232862328723288232892329023291232922329323294232952329623297232982329923300233012330223303233042330523306233072330823309233102331123312233132331423315233162331723318233192332023321233222332323324233252332623327233282332923330233312333223333233342333523336233372333823339233402334123342233432334423345233462334723348233492335023351233522335323354233552335623357233582335923360233612336223363233642336523366233672336823369233702337123372233732337423375233762337723378233792338023381233822338323384233852338623387233882338923390233912339223393233942339523396233972339823399234002340123402234032340423405234062340723408234092341023411234122341323414234152341623417234182341923420234212342223423234242342523426234272342823429234302343123432234332343423435234362343723438234392344023441234422344323444234452344623447234482344923450234512345223453234542345523456234572345823459234602346123462234632346423465234662346723468234692347023471234722347323474234752347623477234782347923480234812348223483234842348523486234872348823489234902349123492234932349423495234962349723498234992350023501235022350323504235052350623507235082350923510235112351223513235142351523516235172351823519235202352123522235232352423525235262352723528235292353023531235322353323534235352353623537235382353923540235412354223543235442354523546235472354823549235502355123552235532355423555235562355723558235592356023561235622356323564235652356623567235682356923570235712357223573235742357523576235772357823579235802358123582235832358423585235862358723588235892359023591235922359323594235952359623597235982359923600236012360223603236042360523606236072360823609236102361123612236132361423615236162361723618236192362023621236222362323624236252362623627236282362923630236312363223633236342363523636236372363823639236402364123642236432364423645236462364723648236492365023651236522365323654236552365623657236582365923660236612366223663236642366523666236672366823669236702367123672236732367423675236762367723678236792368023681236822368323684236852368623687236882368923690236912369223693236942369523696236972369823699237002370123702237032370423705237062370723708237092371023711237122371323714237152371623717237182371923720237212372223723237242372523726237272372823729237302373123732237332373423735237362373723738237392374023741237422374323744237452374623747237482374923750237512375223753237542375523756237572375823759237602376123762237632376423765237662376723768237692377023771237722377323774237752377623777237782377923780237812378223783237842378523786237872378823789237902379123792237932379423795237962379723798237992380023801238022380323804238052380623807238082380923810238112381223813238142381523816238172381823819238202382123822238232382423825238262382723828238292383023831238322383323834238352383623837238382383923840238412384223843238442384523846238472384823849238502385123852238532385423855238562385723858238592386023861238622386323864238652386623867238682386923870238712387223873238742387523876238772387823879238802388123882238832388423885238862388723888238892389023891238922389323894238952389623897238982389923900239012390223903239042390523906239072390823909239102391123912239132391423915239162391723918239192392023921239222392323924239252392623927239282392923930239312393223933239342393523936239372393823939239402394123942239432394423945239462394723948239492395023951239522395323954239552395623957239582395923960239612396223963239642396523966239672396823969239702397123972239732397423975239762397723978239792398023981239822398323984239852398623987239882398923990239912399223993239942399523996239972399823999240002400124002240032400424005240062400724008240092401024011240122401324014240152401624017240182401924020240212402224023240242402524026240272402824029240302403124032240332403424035240362403724038240392404024041240422404324044240452404624047240482404924050240512405224053240542405524056240572405824059240602406124062240632406424065240662406724068240692407024071240722407324074240752407624077240782407924080240812408224083240842408524086240872408824089240902409124092240932409424095240962409724098240992410024101241022410324104241052410624107241082410924110241112411224113241142411524116241172411824119241202412124122241232412424125241262412724128241292413024131241322413324134241352413624137241382413924140241412414224143241442414524146241472414824149241502415124152241532415424155241562415724158241592416024161241622416324164241652416624167241682416924170241712417224173241742417524176241772417824179241802418124182241832418424185241862418724188241892419024191241922419324194241952419624197241982419924200242012420224203242042420524206242072420824209242102421124212242132421424215242162421724218242192422024221242222422324224242252422624227242282422924230242312423224233242342423524236242372423824239242402424124242242432424424245242462424724248242492425024251242522425324254242552425624257242582425924260242612426224263242642426524266242672426824269242702427124272242732427424275242762427724278242792428024281242822428324284242852428624287242882428924290242912429224293242942429524296242972429824299243002430124302243032430424305243062430724308243092431024311243122431324314243152431624317243182431924320243212432224323243242432524326243272432824329243302433124332243332433424335243362433724338243392434024341243422434324344243452434624347243482434924350243512435224353243542435524356243572435824359243602436124362243632436424365243662436724368243692437024371243722437324374243752437624377243782437924380243812438224383243842438524386243872438824389243902439124392243932439424395243962439724398243992440024401244022440324404244052440624407244082440924410244112441224413244142441524416244172441824419244202442124422244232442424425244262442724428244292443024431244322443324434244352443624437244382443924440244412444224443244442444524446244472444824449244502445124452244532445424455244562445724458244592446024461244622446324464244652446624467244682446924470244712447224473244742447524476244772447824479244802448124482244832448424485244862448724488244892449024491244922449324494244952449624497244982449924500245012450224503245042450524506245072450824509245102451124512245132451424515245162451724518245192452024521245222452324524245252452624527245282452924530245312453224533245342453524536245372453824539245402454124542245432454424545245462454724548245492455024551245522455324554245552455624557245582455924560245612456224563245642456524566245672456824569245702457124572245732457424575245762457724578245792458024581245822458324584245852458624587245882458924590245912459224593245942459524596245972459824599246002460124602246032460424605246062460724608246092461024611246122461324614246152461624617246182461924620246212462224623246242462524626246272462824629246302463124632246332463424635246362463724638246392464024641246422464324644246452464624647246482464924650246512465224653246542465524656246572465824659246602466124662246632466424665246662466724668246692467024671246722467324674246752467624677246782467924680246812468224683246842468524686246872468824689246902469124692246932469424695246962469724698246992470024701247022470324704247052470624707247082470924710247112471224713247142471524716247172471824719247202472124722247232472424725247262472724728247292473024731247322473324734247352473624737247382473924740247412474224743247442474524746247472474824749247502475124752247532475424755247562475724758247592476024761247622476324764247652476624767247682476924770247712477224773247742477524776247772477824779247802478124782247832478424785247862478724788247892479024791247922479324794247952479624797247982479924800248012480224803248042480524806248072480824809248102481124812248132481424815248162481724818248192482024821248222482324824248252482624827248282482924830248312483224833248342483524836248372483824839248402484124842248432484424845248462484724848248492485024851248522485324854248552485624857248582485924860248612486224863248642486524866248672486824869248702487124872248732487424875248762487724878248792488024881248822488324884248852488624887248882488924890248912489224893248942489524896248972489824899249002490124902249032490424905249062490724908249092491024911249122491324914249152491624917249182491924920249212492224923249242492524926249272492824929249302493124932249332493424935249362493724938249392494024941249422494324944249452494624947249482494924950249512495224953249542495524956249572495824959249602496124962249632496424965249662496724968249692497024971249722497324974249752497624977249782497924980249812498224983249842498524986249872498824989249902499124992249932499424995249962499724998249992500025001250022500325004250052500625007250082500925010250112501225013250142501525016250172501825019250202502125022250232502425025250262502725028250292503025031250322503325034250352503625037250382503925040250412504225043250442504525046250472504825049250502505125052250532505425055250562505725058250592506025061250622506325064250652506625067250682506925070250712507225073250742507525076250772507825079250802508125082250832508425085250862508725088250892509025091250922509325094250952509625097250982509925100251012510225103251042510525106251072510825109251102511125112251132511425115251162511725118251192512025121251222512325124251252512625127251282512925130251312513225133251342513525136251372513825139251402514125142251432514425145251462514725148251492515025151251522515325154251552515625157251582515925160251612516225163251642516525166251672516825169251702517125172251732517425175251762517725178251792518025181251822518325184251852518625187251882518925190251912519225193251942519525196251972519825199252002520125202252032520425205252062520725208252092521025211252122521325214252152521625217252182521925220252212522225223252242522525226252272522825229252302523125232252332523425235252362523725238252392524025241252422524325244252452524625247252482524925250252512525225253252542525525256252572525825259252602526125262252632526425265252662526725268252692527025271252722527325274252752527625277252782527925280252812528225283252842528525286252872528825289252902529125292252932529425295252962529725298252992530025301253022530325304253052530625307253082530925310253112531225313253142531525316253172531825319253202532125322253232532425325253262532725328253292533025331253322533325334253352533625337253382533925340253412534225343253442534525346253472534825349253502535125352253532535425355253562535725358253592536025361253622536325364253652536625367253682536925370253712537225373253742537525376253772537825379253802538125382253832538425385253862538725388253892539025391253922539325394253952539625397253982539925400254012540225403254042540525406254072540825409254102541125412254132541425415254162541725418254192542025421254222542325424254252542625427254282542925430254312543225433254342543525436254372543825439254402544125442254432544425445254462544725448254492545025451254522545325454254552545625457254582545925460254612546225463254642546525466254672546825469254702547125472254732547425475254762547725478254792548025481254822548325484254852548625487254882548925490254912549225493254942549525496254972549825499255002550125502255032550425505255062550725508255092551025511255122551325514255152551625517255182551925520255212552225523255242552525526255272552825529255302553125532255332553425535255362553725538255392554025541255422554325544255452554625547255482554925550255512555225553255542555525556255572555825559255602556125562255632556425565255662556725568255692557025571255722557325574255752557625577255782557925580255812558225583255842558525586255872558825589255902559125592255932559425595255962559725598255992560025601256022560325604256052560625607256082560925610256112561225613256142561525616256172561825619256202562125622256232562425625256262562725628256292563025631256322563325634256352563625637256382563925640256412564225643256442564525646256472564825649256502565125652256532565425655256562565725658256592566025661256622566325664256652566625667256682566925670256712567225673256742567525676256772567825679256802568125682256832568425685256862568725688256892569025691256922569325694256952569625697256982569925700257012570225703257042570525706257072570825709257102571125712257132571425715257162571725718257192572025721257222572325724257252572625727257282572925730257312573225733257342573525736257372573825739257402574125742257432574425745257462574725748257492575025751257522575325754257552575625757257582575925760257612576225763257642576525766257672576825769257702577125772257732577425775257762577725778257792578025781257822578325784257852578625787257882578925790257912579225793257942579525796257972579825799258002580125802258032580425805258062580725808258092581025811258122581325814258152581625817258182581925820258212582225823258242582525826258272582825829258302583125832258332583425835258362583725838258392584025841258422584325844258452584625847258482584925850258512585225853258542585525856258572585825859258602586125862258632586425865258662586725868258692587025871258722587325874258752587625877258782587925880258812588225883258842588525886258872588825889258902589125892258932589425895258962589725898258992590025901259022590325904259052590625907259082590925910259112591225913259142591525916259172591825919259202592125922259232592425925259262592725928259292593025931259322593325934259352593625937259382593925940259412594225943259442594525946259472594825949259502595125952259532595425955259562595725958259592596025961259622596325964259652596625967259682596925970259712597225973259742597525976259772597825979259802598125982259832598425985259862598725988259892599025991259922599325994259952599625997259982599926000260012600226003260042600526006260072600826009260102601126012260132601426015260162601726018260192602026021260222602326024260252602626027260282602926030260312603226033260342603526036260372603826039260402604126042260432604426045260462604726048260492605026051260522605326054260552605626057260582605926060260612606226063260642606526066260672606826069260702607126072260732607426075260762607726078260792608026081260822608326084260852608626087260882608926090260912609226093260942609526096260972609826099261002610126102261032610426105261062610726108261092611026111261122611326114261152611626117261182611926120261212612226123261242612526126261272612826129261302613126132261332613426135261362613726138261392614026141261422614326144261452614626147261482614926150261512615226153261542615526156261572615826159261602616126162261632616426165261662616726168261692617026171261722617326174261752617626177261782617926180261812618226183261842618526186261872618826189261902619126192261932619426195261962619726198261992620026201262022620326204262052620626207262082620926210262112621226213262142621526216262172621826219262202622126222262232622426225262262622726228262292623026231262322623326234262352623626237262382623926240262412624226243262442624526246262472624826249262502625126252262532625426255262562625726258262592626026261262622626326264262652626626267262682626926270262712627226273262742627526276262772627826279262802628126282262832628426285262862628726288262892629026291262922629326294262952629626297262982629926300263012630226303263042630526306263072630826309263102631126312263132631426315263162631726318263192632026321263222632326324263252632626327263282632926330263312633226333263342633526336263372633826339263402634126342263432634426345263462634726348263492635026351263522635326354263552635626357263582635926360263612636226363263642636526366263672636826369263702637126372263732637426375263762637726378263792638026381263822638326384263852638626387263882638926390263912639226393263942639526396263972639826399264002640126402264032640426405264062640726408264092641026411264122641326414264152641626417264182641926420264212642226423264242642526426264272642826429264302643126432264332643426435264362643726438264392644026441264422644326444264452644626447264482644926450264512645226453264542645526456264572645826459264602646126462264632646426465264662646726468264692647026471264722647326474264752647626477264782647926480264812648226483264842648526486264872648826489264902649126492264932649426495264962649726498264992650026501265022650326504265052650626507265082650926510265112651226513265142651526516265172651826519265202652126522265232652426525265262652726528265292653026531265322653326534265352653626537265382653926540265412654226543265442654526546265472654826549265502655126552265532655426555265562655726558265592656026561265622656326564265652656626567265682656926570265712657226573265742657526576265772657826579265802658126582265832658426585265862658726588265892659026591265922659326594265952659626597265982659926600266012660226603266042660526606266072660826609266102661126612266132661426615266162661726618266192662026621266222662326624266252662626627266282662926630266312663226633266342663526636266372663826639266402664126642266432664426645266462664726648266492665026651266522665326654266552665626657266582665926660266612666226663266642666526666266672666826669266702667126672266732667426675266762667726678266792668026681266822668326684266852668626687266882668926690266912669226693266942669526696266972669826699267002670126702267032670426705267062670726708267092671026711267122671326714267152671626717267182671926720267212672226723267242672526726267272672826729267302673126732267332673426735267362673726738267392674026741267422674326744267452674626747267482674926750267512675226753267542675526756267572675826759267602676126762267632676426765267662676726768267692677026771267722677326774267752677626777267782677926780267812678226783267842678526786267872678826789267902679126792267932679426795267962679726798267992680026801268022680326804268052680626807268082680926810268112681226813268142681526816268172681826819268202682126822268232682426825268262682726828268292683026831268322683326834268352683626837268382683926840268412684226843268442684526846268472684826849268502685126852268532685426855268562685726858268592686026861268622686326864268652686626867268682686926870268712687226873268742687526876268772687826879268802688126882268832688426885268862688726888268892689026891268922689326894268952689626897268982689926900269012690226903269042690526906269072690826909269102691126912269132691426915269162691726918269192692026921269222692326924269252692626927269282692926930269312693226933269342693526936269372693826939269402694126942269432694426945269462694726948269492695026951269522695326954269552695626957269582695926960269612696226963269642696526966269672696826969269702697126972269732697426975269762697726978269792698026981269822698326984269852698626987269882698926990269912699226993269942699526996269972699826999270002700127002270032700427005270062700727008270092701027011270122701327014270152701627017270182701927020270212702227023270242702527026270272702827029270302703127032270332703427035270362703727038270392704027041270422704327044270452704627047270482704927050270512705227053270542705527056270572705827059270602706127062270632706427065270662706727068270692707027071270722707327074270752707627077270782707927080270812708227083270842708527086270872708827089270902709127092270932709427095270962709727098270992710027101271022710327104271052710627107271082710927110271112711227113271142711527116271172711827119271202712127122271232712427125271262712727128271292713027131271322713327134271352713627137271382713927140271412714227143271442714527146271472714827149271502715127152271532715427155271562715727158271592716027161271622716327164271652716627167271682716927170271712717227173271742717527176271772717827179271802718127182271832718427185271862718727188271892719027191271922719327194271952719627197271982719927200272012720227203272042720527206272072720827209272102721127212272132721427215272162721727218272192722027221272222722327224272252722627227272282722927230272312723227233272342723527236272372723827239272402724127242272432724427245272462724727248272492725027251272522725327254272552725627257272582725927260272612726227263272642726527266272672726827269272702727127272272732727427275272762727727278272792728027281272822728327284272852728627287272882728927290272912729227293272942729527296272972729827299273002730127302273032730427305273062730727308273092731027311273122731327314273152731627317273182731927320273212732227323273242732527326273272732827329273302733127332273332733427335273362733727338273392734027341273422734327344273452734627347273482734927350273512735227353273542735527356273572735827359273602736127362273632736427365273662736727368273692737027371273722737327374273752737627377273782737927380273812738227383273842738527386273872738827389273902739127392273932739427395273962739727398273992740027401274022740327404274052740627407274082740927410274112741227413274142741527416274172741827419274202742127422274232742427425274262742727428274292743027431274322743327434274352743627437274382743927440274412744227443274442744527446274472744827449274502745127452274532745427455274562745727458274592746027461274622746327464274652746627467274682746927470274712747227473274742747527476274772747827479274802748127482274832748427485274862748727488274892749027491274922749327494274952749627497274982749927500275012750227503275042750527506275072750827509275102751127512275132751427515275162751727518275192752027521275222752327524275252752627527275282752927530275312753227533275342753527536275372753827539275402754127542275432754427545275462754727548275492755027551275522755327554275552755627557275582755927560275612756227563275642756527566275672756827569275702757127572275732757427575275762757727578275792758027581275822758327584275852758627587275882758927590275912759227593275942759527596275972759827599276002760127602276032760427605276062760727608276092761027611276122761327614276152761627617276182761927620276212762227623276242762527626276272762827629276302763127632276332763427635276362763727638276392764027641276422764327644276452764627647276482764927650276512765227653276542765527656276572765827659276602766127662276632766427665276662766727668276692767027671276722767327674276752767627677276782767927680276812768227683276842768527686276872768827689276902769127692276932769427695276962769727698276992770027701277022770327704277052770627707277082770927710277112771227713277142771527716277172771827719277202772127722277232772427725277262772727728277292773027731277322773327734277352773627737277382773927740277412774227743277442774527746277472774827749277502775127752277532775427755277562775727758277592776027761277622776327764277652776627767277682776927770277712777227773277742777527776277772777827779277802778127782277832778427785277862778727788277892779027791277922779327794277952779627797277982779927800278012780227803278042780527806278072780827809278102781127812278132781427815278162781727818278192782027821278222782327824278252782627827278282782927830278312783227833278342783527836278372783827839278402784127842278432784427845278462784727848278492785027851278522785327854278552785627857278582785927860278612786227863278642786527866278672786827869278702787127872278732787427875278762787727878278792788027881278822788327884278852788627887278882788927890278912789227893278942789527896278972789827899279002790127902279032790427905279062790727908279092791027911279122791327914279152791627917279182791927920279212792227923279242792527926279272792827929279302793127932279332793427935279362793727938279392794027941279422794327944279452794627947279482794927950279512795227953279542795527956279572795827959279602796127962279632796427965279662796727968279692797027971279722797327974279752797627977279782797927980279812798227983279842798527986279872798827989279902799127992279932799427995279962799727998279992800028001280022800328004280052800628007280082800928010280112801228013280142801528016280172801828019280202802128022280232802428025280262802728028280292803028031280322803328034280352803628037280382803928040280412804228043280442804528046280472804828049280502805128052280532805428055280562805728058280592806028061280622806328064280652806628067280682806928070280712807228073280742807528076280772807828079280802808128082280832808428085280862808728088280892809028091280922809328094280952809628097280982809928100281012810228103281042810528106281072810828109281102811128112281132811428115281162811728118281192812028121281222812328124281252812628127281282812928130281312813228133281342813528136281372813828139281402814128142281432814428145281462814728148281492815028151281522815328154281552815628157281582815928160281612816228163281642816528166281672816828169281702817128172281732817428175281762817728178281792818028181281822818328184281852818628187281882818928190281912819228193281942819528196281972819828199282002820128202282032820428205282062820728208282092821028211282122821328214282152821628217282182821928220282212822228223282242822528226282272822828229282302823128232282332823428235282362823728238282392824028241282422824328244282452824628247282482824928250282512825228253282542825528256282572825828259282602826128262282632826428265282662826728268282692827028271282722827328274282752827628277282782827928280282812828228283282842828528286282872828828289282902829128292282932829428295282962829728298282992830028301283022830328304283052830628307283082830928310283112831228313283142831528316283172831828319283202832128322283232832428325283262832728328283292833028331283322833328334283352833628337283382833928340283412834228343283442834528346283472834828349283502835128352283532835428355283562835728358283592836028361283622836328364283652836628367283682836928370283712837228373283742837528376283772837828379283802838128382283832838428385283862838728388283892839028391283922839328394283952839628397283982839928400284012840228403284042840528406284072840828409284102841128412284132841428415284162841728418284192842028421284222842328424284252842628427284282842928430284312843228433284342843528436284372843828439284402844128442284432844428445284462844728448284492845028451284522845328454284552845628457284582845928460284612846228463284642846528466284672846828469284702847128472284732847428475284762847728478284792848028481284822848328484284852848628487284882848928490284912849228493284942849528496284972849828499285002850128502285032850428505285062850728508285092851028511285122851328514285152851628517285182851928520285212852228523285242852528526285272852828529285302853128532285332853428535285362853728538285392854028541285422854328544285452854628547285482854928550285512855228553285542855528556285572855828559285602856128562285632856428565285662856728568285692857028571285722857328574285752857628577285782857928580285812858228583285842858528586285872858828589285902859128592285932859428595285962859728598285992860028601286022860328604286052860628607286082860928610286112861228613286142861528616286172861828619286202862128622286232862428625286262862728628286292863028631286322863328634286352863628637286382863928640286412864228643286442864528646286472864828649286502865128652286532865428655286562865728658286592866028661286622866328664286652866628667286682866928670286712867228673286742867528676286772867828679286802868128682286832868428685286862868728688286892869028691286922869328694286952869628697286982869928700287012870228703287042870528706287072870828709287102871128712287132871428715287162871728718287192872028721287222872328724287252872628727287282872928730287312873228733287342873528736287372873828739287402874128742287432874428745287462874728748287492875028751287522875328754287552875628757287582875928760287612876228763287642876528766287672876828769287702877128772287732877428775287762877728778287792878028781287822878328784287852878628787287882878928790287912879228793287942879528796287972879828799288002880128802288032880428805288062880728808288092881028811288122881328814288152881628817288182881928820288212882228823288242882528826288272882828829288302883128832288332883428835288362883728838288392884028841288422884328844288452884628847288482884928850288512885228853288542885528856288572885828859288602886128862288632886428865288662886728868288692887028871288722887328874288752887628877288782887928880288812888228883288842888528886288872888828889288902889128892288932889428895288962889728898288992890028901289022890328904289052890628907289082890928910289112891228913289142891528916289172891828919289202892128922289232892428925289262892728928289292893028931289322893328934289352893628937289382893928940289412894228943289442894528946289472894828949289502895128952289532895428955289562895728958289592896028961289622896328964289652896628967289682896928970289712897228973289742897528976289772897828979289802898128982289832898428985289862898728988289892899028991289922899328994289952899628997289982899929000290012900229003290042900529006290072900829009290102901129012290132901429015290162901729018290192902029021290222902329024290252902629027290282902929030290312903229033290342903529036290372903829039290402904129042290432904429045290462904729048290492905029051290522905329054290552905629057290582905929060290612906229063290642906529066290672906829069290702907129072290732907429075290762907729078290792908029081290822908329084290852908629087290882908929090290912909229093290942909529096290972909829099291002910129102291032910429105291062910729108291092911029111291122911329114291152911629117291182911929120291212912229123291242912529126291272912829129291302913129132291332913429135291362913729138291392914029141291422914329144291452914629147291482914929150291512915229153291542915529156291572915829159291602916129162291632916429165291662916729168291692917029171291722917329174291752917629177291782917929180291812918229183291842918529186291872918829189291902919129192291932919429195291962919729198291992920029201292022920329204292052920629207292082920929210292112921229213292142921529216292172921829219292202922129222292232922429225292262922729228292292923029231292322923329234292352923629237292382923929240292412924229243292442924529246292472924829249292502925129252292532925429255292562925729258292592926029261292622926329264292652926629267292682926929270292712927229273292742927529276292772927829279292802928129282292832928429285292862928729288292892929029291292922929329294292952929629297292982929929300293012930229303293042930529306293072930829309293102931129312293132931429315293162931729318293192932029321293222932329324293252932629327293282932929330293312933229333293342933529336293372933829339293402934129342293432934429345293462934729348293492935029351293522935329354293552935629357293582935929360293612936229363293642936529366293672936829369293702937129372293732937429375293762937729378293792938029381293822938329384293852938629387293882938929390293912939229393293942939529396293972939829399294002940129402294032940429405294062940729408294092941029411294122941329414294152941629417294182941929420294212942229423294242942529426294272942829429294302943129432294332943429435294362943729438294392944029441294422944329444294452944629447294482944929450294512945229453294542945529456294572945829459294602946129462294632946429465294662946729468294692947029471294722947329474294752947629477294782947929480294812948229483294842948529486294872948829489294902949129492294932949429495294962949729498294992950029501295022950329504295052950629507295082950929510295112951229513295142951529516295172951829519295202952129522295232952429525295262952729528295292953029531295322953329534295352953629537295382953929540295412954229543295442954529546295472954829549295502955129552295532955429555295562955729558295592956029561295622956329564295652956629567295682956929570295712957229573295742957529576295772957829579295802958129582295832958429585295862958729588295892959029591295922959329594295952959629597295982959929600296012960229603296042960529606296072960829609296102961129612296132961429615296162961729618296192962029621296222962329624296252962629627296282962929630296312963229633296342963529636296372963829639296402964129642296432964429645296462964729648296492965029651296522965329654296552965629657296582965929660296612966229663296642966529666296672966829669296702967129672296732967429675296762967729678296792968029681296822968329684296852968629687296882968929690296912969229693296942969529696296972969829699297002970129702297032970429705297062970729708297092971029711297122971329714297152971629717297182971929720297212972229723297242972529726297272972829729297302973129732297332973429735297362973729738297392974029741297422974329744297452974629747297482974929750297512975229753297542975529756297572975829759297602976129762297632976429765297662976729768297692977029771297722977329774297752977629777297782977929780297812978229783297842978529786297872978829789297902979129792297932979429795297962979729798297992980029801298022980329804298052980629807298082980929810298112981229813298142981529816298172981829819298202982129822298232982429825298262982729828298292983029831298322983329834298352983629837298382983929840298412984229843298442984529846298472984829849298502985129852298532985429855298562985729858298592986029861298622986329864298652986629867298682986929870298712987229873298742987529876298772987829879298802988129882298832988429885298862988729888298892989029891298922989329894298952989629897298982989929900299012990229903299042990529906299072990829909299102991129912299132991429915299162991729918299192992029921299222992329924299252992629927299282992929930299312993229933299342993529936299372993829939299402994129942299432994429945299462994729948299492995029951299522995329954299552995629957299582995929960299612996229963299642996529966299672996829969299702997129972299732997429975299762997729978299792998029981299822998329984299852998629987299882998929990299912999229993299942999529996299972999829999300003000130002300033000430005300063000730008300093001030011300123001330014300153001630017300183001930020300213002230023300243002530026300273002830029300303003130032300333003430035300363003730038300393004030041300423004330044300453004630047300483004930050300513005230053300543005530056300573005830059300603006130062300633006430065300663006730068300693007030071300723007330074300753007630077300783007930080300813008230083300843008530086300873008830089300903009130092300933009430095300963009730098300993010030101301023010330104301053010630107301083010930110301113011230113301143011530116301173011830119301203012130122301233012430125301263012730128301293013030131301323013330134301353013630137301383013930140301413014230143301443014530146301473014830149301503015130152301533015430155301563015730158301593016030161301623016330164301653016630167301683016930170301713017230173301743017530176301773017830179301803018130182301833018430185301863018730188301893019030191301923019330194301953019630197301983019930200302013020230203302043020530206302073020830209302103021130212302133021430215302163021730218302193022030221302223022330224302253022630227302283022930230302313023230233302343023530236302373023830239302403024130242302433024430245302463024730248302493025030251302523025330254302553025630257302583025930260302613026230263302643026530266302673026830269302703027130272302733027430275302763027730278302793028030281302823028330284302853028630287302883028930290302913029230293302943029530296302973029830299303003030130302303033030430305303063030730308303093031030311303123031330314303153031630317303183031930320303213032230323303243032530326303273032830329303303033130332303333033430335303363033730338303393034030341303423034330344303453034630347303483034930350303513035230353303543035530356303573035830359303603036130362303633036430365303663036730368303693037030371303723037330374303753037630377303783037930380303813038230383303843038530386303873038830389303903039130392303933039430395303963039730398303993040030401304023040330404304053040630407304083040930410304113041230413304143041530416304173041830419304203042130422304233042430425304263042730428304293043030431304323043330434304353043630437304383043930440304413044230443304443044530446304473044830449304503045130452304533045430455304563045730458304593046030461304623046330464304653046630467304683046930470304713047230473304743047530476304773047830479304803048130482304833048430485304863048730488304893049030491304923049330494304953049630497304983049930500305013050230503305043050530506305073050830509305103051130512305133051430515305163051730518305193052030521305223052330524305253052630527305283052930530305313053230533305343053530536305373053830539305403054130542305433054430545305463054730548305493055030551305523055330554305553055630557305583055930560305613056230563305643056530566305673056830569305703057130572305733057430575305763057730578305793058030581305823058330584305853058630587305883058930590305913059230593305943059530596305973059830599306003060130602306033060430605306063060730608306093061030611306123061330614306153061630617306183061930620306213062230623306243062530626306273062830629306303063130632306333063430635306363063730638306393064030641306423064330644306453064630647306483064930650306513065230653306543065530656306573065830659306603066130662306633066430665306663066730668306693067030671306723067330674306753067630677306783067930680306813068230683306843068530686306873068830689306903069130692306933069430695306963069730698306993070030701307023070330704307053070630707307083070930710307113071230713307143071530716307173071830719307203072130722307233072430725307263072730728307293073030731307323073330734307353073630737307383073930740307413074230743307443074530746307473074830749307503075130752307533075430755307563075730758307593076030761307623076330764307653076630767307683076930770307713077230773307743077530776307773077830779307803078130782307833078430785307863078730788307893079030791307923079330794307953079630797307983079930800308013080230803308043080530806308073080830809308103081130812308133081430815308163081730818308193082030821308223082330824308253082630827308283082930830308313083230833308343083530836308373083830839308403084130842308433084430845308463084730848308493085030851308523085330854308553085630857308583085930860308613086230863308643086530866308673086830869308703087130872308733087430875308763087730878308793088030881308823088330884308853088630887308883088930890308913089230893308943089530896308973089830899309003090130902309033090430905309063090730908309093091030911309123091330914309153091630917309183091930920309213092230923309243092530926309273092830929309303093130932309333093430935309363093730938309393094030941309423094330944309453094630947309483094930950309513095230953309543095530956309573095830959309603096130962309633096430965309663096730968309693097030971309723097330974309753097630977309783097930980309813098230983309843098530986309873098830989309903099130992309933099430995309963099730998309993100031001310023100331004310053100631007310083100931010310113101231013310143101531016310173101831019310203102131022310233102431025310263102731028310293103031031310323103331034310353103631037310383103931040310413104231043310443104531046310473104831049310503105131052310533105431055310563105731058310593106031061310623106331064310653106631067310683106931070310713107231073310743107531076310773107831079310803108131082310833108431085310863108731088310893109031091310923109331094310953109631097310983109931100311013110231103311043110531106311073110831109311103111131112311133111431115311163111731118311193112031121311223112331124311253112631127311283112931130311313113231133311343113531136311373113831139311403114131142311433114431145311463114731148311493115031151311523115331154311553115631157311583115931160311613116231163311643116531166311673116831169311703117131172311733117431175311763117731178311793118031181311823118331184311853118631187311883118931190311913119231193311943119531196311973119831199312003120131202312033120431205312063120731208312093121031211312123121331214312153121631217312183121931220312213122231223312243122531226312273122831229312303123131232312333123431235312363123731238312393124031241312423124331244312453124631247312483124931250312513125231253312543125531256312573125831259312603126131262312633126431265312663126731268312693127031271312723127331274312753127631277312783127931280312813128231283312843128531286312873128831289312903129131292312933129431295312963129731298312993130031301313023130331304313053130631307313083130931310313113131231313313143131531316313173131831319313203132131322313233132431325313263132731328313293133031331313323133331334313353133631337313383133931340313413134231343313443134531346313473134831349313503135131352313533135431355313563135731358313593136031361313623136331364313653136631367313683136931370313713137231373313743137531376313773137831379313803138131382313833138431385313863138731388313893139031391313923139331394313953139631397313983139931400314013140231403314043140531406314073140831409314103141131412314133141431415314163141731418314193142031421314223142331424314253142631427314283142931430314313143231433314343143531436314373143831439314403144131442314433144431445314463144731448314493145031451314523145331454314553145631457314583145931460314613146231463314643146531466314673146831469314703147131472314733147431475314763147731478314793148031481314823148331484314853148631487314883148931490314913149231493314943149531496314973149831499315003150131502315033150431505315063150731508315093151031511315123151331514315153151631517315183151931520315213152231523315243152531526315273152831529315303153131532315333153431535315363153731538315393154031541315423154331544315453154631547315483154931550315513155231553315543155531556315573155831559315603156131562315633156431565315663156731568315693157031571315723157331574315753157631577315783157931580315813158231583315843158531586315873158831589315903159131592315933159431595315963159731598315993160031601316023160331604316053160631607316083160931610316113161231613316143161531616316173161831619316203162131622316233162431625316263162731628316293163031631316323163331634316353163631637316383163931640316413164231643316443164531646316473164831649316503165131652316533165431655316563165731658316593166031661316623166331664316653166631667316683166931670316713167231673316743167531676316773167831679316803168131682316833168431685316863168731688316893169031691316923169331694316953169631697316983169931700317013170231703317043170531706317073170831709317103171131712317133171431715317163171731718317193172031721317223172331724317253172631727317283172931730317313173231733317343173531736317373173831739317403174131742317433174431745317463174731748317493175031751317523175331754317553175631757317583175931760317613176231763317643176531766317673176831769317703177131772317733177431775317763177731778317793178031781317823178331784317853178631787317883178931790317913179231793317943179531796317973179831799318003180131802318033180431805318063180731808318093181031811318123181331814318153181631817318183181931820318213182231823318243182531826318273182831829318303183131832318333183431835318363183731838318393184031841318423184331844318453184631847318483184931850318513185231853318543185531856318573185831859318603186131862318633186431865318663186731868318693187031871318723187331874318753187631877318783187931880318813188231883318843188531886318873188831889318903189131892318933189431895318963189731898318993190031901319023190331904319053190631907319083190931910319113191231913319143191531916319173191831919319203192131922319233192431925319263192731928319293193031931319323193331934319353193631937319383193931940319413194231943319443194531946319473194831949319503195131952319533195431955319563195731958319593196031961319623196331964319653196631967319683196931970319713197231973319743197531976319773197831979319803198131982319833198431985319863198731988319893199031991319923199331994319953199631997319983199932000320013200232003320043200532006320073200832009320103201132012320133201432015320163201732018320193202032021320223202332024320253202632027320283202932030320313203232033320343203532036320373203832039320403204132042320433204432045320463204732048320493205032051320523205332054320553205632057320583205932060320613206232063320643206532066320673206832069320703207132072320733207432075320763207732078320793208032081320823208332084320853208632087320883208932090320913209232093320943209532096320973209832099321003210132102321033210432105321063210732108321093211032111321123211332114321153211632117321183211932120321213212232123321243212532126321273212832129321303213132132321333213432135321363213732138321393214032141321423214332144321453214632147321483214932150321513215232153321543215532156321573215832159321603216132162321633216432165321663216732168321693217032171321723217332174321753217632177321783217932180321813218232183321843218532186321873218832189321903219132192321933219432195321963219732198321993220032201322023220332204322053220632207322083220932210322113221232213322143221532216322173221832219322203222132222322233222432225322263222732228322293223032231322323223332234322353223632237322383223932240322413224232243322443224532246322473224832249322503225132252322533225432255322563225732258322593226032261322623226332264322653226632267322683226932270322713227232273322743227532276322773227832279322803228132282322833228432285322863228732288322893229032291322923229332294322953229632297322983229932300323013230232303323043230532306323073230832309323103231132312323133231432315323163231732318323193232032321323223232332324323253232632327323283232932330323313233232333323343233532336323373233832339323403234132342323433234432345323463234732348323493235032351323523235332354323553235632357323583235932360323613236232363323643236532366323673236832369323703237132372323733237432375323763237732378323793238032381323823238332384323853238632387323883238932390323913239232393323943239532396323973239832399324003240132402324033240432405324063240732408324093241032411324123241332414324153241632417324183241932420324213242232423324243242532426324273242832429324303243132432324333243432435324363243732438324393244032441324423244332444324453244632447324483244932450324513245232453324543245532456324573245832459324603246132462324633246432465324663246732468324693247032471324723247332474324753247632477324783247932480324813248232483324843248532486324873248832489324903249132492324933249432495324963249732498324993250032501325023250332504325053250632507325083250932510325113251232513325143251532516325173251832519325203252132522325233252432525325263252732528325293253032531325323253332534325353253632537325383253932540325413254232543325443254532546325473254832549325503255132552325533255432555325563255732558325593256032561325623256332564325653256632567325683256932570325713257232573325743257532576325773257832579325803258132582325833258432585325863258732588325893259032591325923259332594325953259632597325983259932600326013260232603326043260532606326073260832609326103261132612326133261432615326163261732618326193262032621326223262332624326253262632627326283262932630326313263232633326343263532636326373263832639326403264132642326433264432645326463264732648326493265032651326523265332654326553265632657326583265932660326613266232663326643266532666326673266832669326703267132672326733267432675326763267732678326793268032681326823268332684326853268632687326883268932690326913269232693326943269532696326973269832699327003270132702327033270432705327063270732708327093271032711327123271332714327153271632717327183271932720327213272232723327243272532726327273272832729327303273132732327333273432735327363273732738327393274032741327423274332744327453274632747327483274932750327513275232753327543275532756327573275832759327603276132762327633276432765327663276732768327693277032771327723277332774327753277632777327783277932780327813278232783327843278532786327873278832789327903279132792327933279432795327963279732798327993280032801328023280332804328053280632807328083280932810328113281232813328143281532816328173281832819328203282132822328233282432825328263282732828328293283032831328323283332834328353283632837328383283932840328413284232843328443284532846328473284832849328503285132852328533285432855328563285732858328593286032861328623286332864328653286632867328683286932870328713287232873328743287532876328773287832879328803288132882328833288432885328863288732888328893289032891328923289332894328953289632897328983289932900329013290232903329043290532906329073290832909329103291132912329133291432915329163291732918329193292032921329223292332924329253292632927329283292932930329313293232933329343293532936329373293832939329403294132942329433294432945329463294732948329493295032951329523295332954329553295632957329583295932960329613296232963329643296532966329673296832969329703297132972329733297432975329763297732978329793298032981329823298332984329853298632987329883298932990329913299232993329943299532996329973299832999330003300133002330033300433005330063300733008330093301033011330123301333014330153301633017330183301933020330213302233023330243302533026330273302833029330303303133032330333303433035330363303733038330393304033041330423304333044330453304633047330483304933050330513305233053330543305533056330573305833059330603306133062330633306433065330663306733068330693307033071330723307333074330753307633077330783307933080330813308233083330843308533086330873308833089330903309133092330933309433095330963309733098330993310033101331023310333104331053310633107331083310933110331113311233113331143311533116331173311833119331203312133122331233312433125331263312733128331293313033131331323313333134331353313633137331383313933140331413314233143331443314533146331473314833149331503315133152331533315433155331563315733158331593316033161331623316333164331653316633167331683316933170331713317233173331743317533176331773317833179331803318133182331833318433185331863318733188331893319033191331923319333194331953319633197331983319933200332013320233203332043320533206332073320833209332103321133212332133321433215332163321733218332193322033221332223322333224332253322633227332283322933230332313323233233332343323533236332373323833239332403324133242332433324433245332463324733248332493325033251332523325333254332553325633257332583325933260332613326233263332643326533266332673326833269332703327133272332733327433275332763327733278332793328033281332823328333284332853328633287332883328933290332913329233293332943329533296332973329833299333003330133302333033330433305333063330733308333093331033311333123331333314333153331633317333183331933320333213332233323333243332533326333273332833329333303333133332333333333433335333363333733338333393334033341333423334333344333453334633347333483334933350333513335233353333543335533356333573335833359333603336133362333633336433365333663336733368333693337033371333723337333374333753337633377333783337933380333813338233383333843338533386333873338833389333903339133392333933339433395333963339733398333993340033401334023340333404334053340633407334083340933410334113341233413334143341533416334173341833419334203342133422334233342433425334263342733428334293343033431334323343333434334353343633437334383343933440334413344233443334443344533446334473344833449334503345133452334533345433455334563345733458334593346033461334623346333464334653346633467334683346933470334713347233473334743347533476334773347833479334803348133482334833348433485334863348733488334893349033491334923349333494334953349633497334983349933500335013350233503335043350533506335073350833509335103351133512335133351433515335163351733518335193352033521335223352333524335253352633527335283352933530335313353233533335343353533536335373353833539335403354133542335433354433545335463354733548335493355033551335523355333554335553355633557335583355933560335613356233563335643356533566335673356833569335703357133572335733357433575335763357733578335793358033581335823358333584335853358633587335883358933590335913359233593335943359533596335973359833599336003360133602336033360433605336063360733608336093361033611336123361333614336153361633617336183361933620336213362233623336243362533626336273362833629336303363133632336333363433635336363363733638336393364033641336423364333644336453364633647336483364933650336513365233653336543365533656336573365833659336603366133662336633366433665336663366733668336693367033671336723367333674336753367633677336783367933680336813368233683336843368533686336873368833689336903369133692336933369433695336963369733698336993370033701337023370333704337053370633707337083370933710337113371233713337143371533716337173371833719337203372133722337233372433725337263372733728337293373033731337323373333734337353373633737337383373933740337413374233743337443374533746337473374833749337503375133752337533375433755337563375733758337593376033761337623376333764337653376633767337683376933770337713377233773337743377533776337773377833779337803378133782337833378433785337863378733788337893379033791337923379333794337953379633797337983379933800338013380233803338043380533806338073380833809338103381133812338133381433815338163381733818338193382033821338223382333824338253382633827338283382933830338313383233833338343383533836338373383833839338403384133842338433384433845338463384733848338493385033851338523385333854338553385633857338583385933860338613386233863338643386533866338673386833869338703387133872338733387433875338763387733878338793388033881338823388333884338853388633887338883388933890338913389233893338943389533896338973389833899339003390133902339033390433905339063390733908339093391033911339123391333914339153391633917339183391933920339213392233923339243392533926339273392833929339303393133932339333393433935339363393733938339393394033941339423394333944339453394633947339483394933950339513395233953339543395533956339573395833959339603396133962339633396433965339663396733968339693397033971339723397333974339753397633977339783397933980339813398233983339843398533986339873398833989339903399133992339933399433995339963399733998339993400034001340023400334004340053400634007340083400934010340113401234013340143401534016340173401834019340203402134022340233402434025340263402734028340293403034031340323403334034340353403634037340383403934040340413404234043340443404534046340473404834049340503405134052340533405434055340563405734058340593406034061340623406334064340653406634067340683406934070340713407234073340743407534076340773407834079340803408134082340833408434085340863408734088340893409034091340923409334094340953409634097340983409934100341013410234103341043410534106341073410834109341103411134112341133411434115341163411734118341193412034121341223412334124341253412634127341283412934130341313413234133341343413534136341373413834139341403414134142341433414434145341463414734148341493415034151341523415334154341553415634157341583415934160341613416234163341643416534166341673416834169341703417134172341733417434175341763417734178341793418034181341823418334184341853418634187341883418934190341913419234193341943419534196341973419834199342003420134202342033420434205342063420734208342093421034211342123421334214342153421634217342183421934220342213422234223342243422534226342273422834229342303423134232342333423434235342363423734238342393424034241342423424334244342453424634247342483424934250342513425234253342543425534256342573425834259342603426134262342633426434265342663426734268342693427034271342723427334274342753427634277342783427934280342813428234283342843428534286342873428834289342903429134292342933429434295342963429734298342993430034301343023430334304343053430634307343083430934310343113431234313343143431534316343173431834319343203432134322343233432434325343263432734328343293433034331343323433334334343353433634337343383433934340343413434234343343443434534346343473434834349343503435134352343533435434355343563435734358343593436034361343623436334364343653436634367343683436934370343713437234373343743437534376343773437834379343803438134382343833438434385343863438734388343893439034391343923439334394343953439634397343983439934400344013440234403344043440534406344073440834409344103441134412344133441434415344163441734418344193442034421344223442334424344253442634427344283442934430344313443234433344343443534436344373443834439344403444134442344433444434445344463444734448344493445034451344523445334454344553445634457344583445934460344613446234463344643446534466344673446834469344703447134472344733447434475344763447734478344793448034481344823448334484344853448634487344883448934490344913449234493344943449534496344973449834499345003450134502345033450434505345063450734508345093451034511345123451334514345153451634517345183451934520345213452234523345243452534526345273452834529345303453134532345333453434535345363453734538345393454034541345423454334544345453454634547345483454934550345513455234553345543455534556345573455834559345603456134562345633456434565345663456734568345693457034571345723457334574345753457634577345783457934580345813458234583345843458534586345873458834589345903459134592345933459434595345963459734598345993460034601346023460334604346053460634607346083460934610346113461234613346143461534616346173461834619346203462134622346233462434625346263462734628346293463034631346323463334634346353463634637346383463934640346413464234643346443464534646346473464834649346503465134652346533465434655346563465734658346593466034661346623466334664346653466634667346683466934670346713467234673346743467534676346773467834679346803468134682346833468434685346863468734688346893469034691346923469334694346953469634697346983469934700347013470234703347043470534706347073470834709347103471134712347133471434715347163471734718347193472034721347223472334724347253472634727347283472934730347313473234733347343473534736347373473834739347403474134742347433474434745347463474734748347493475034751347523475334754347553475634757347583475934760347613476234763347643476534766347673476834769347703477134772347733477434775347763477734778347793478034781347823478334784347853478634787347883478934790347913479234793347943479534796347973479834799348003480134802348033480434805348063480734808348093481034811348123481334814348153481634817348183481934820348213482234823348243482534826348273482834829348303483134832348333483434835348363483734838348393484034841348423484334844348453484634847348483484934850348513485234853348543485534856348573485834859348603486134862348633486434865348663486734868348693487034871348723487334874348753487634877348783487934880348813488234883348843488534886348873488834889348903489134892348933489434895348963489734898348993490034901349023490334904349053490634907349083490934910349113491234913349143491534916349173491834919349203492134922349233492434925349263492734928349293493034931349323493334934349353493634937349383493934940349413494234943349443494534946349473494834949349503495134952349533495434955349563495734958349593496034961349623496334964349653496634967349683496934970349713497234973349743497534976349773497834979349803498134982349833498434985349863498734988349893499034991349923499334994349953499634997349983499935000350013500235003350043500535006350073500835009350103501135012350133501435015350163501735018350193502035021350223502335024350253502635027350283502935030350313503235033350343503535036350373503835039350403504135042350433504435045350463504735048350493505035051350523505335054350553505635057350583505935060350613506235063350643506535066350673506835069350703507135072350733507435075350763507735078350793508035081350823508335084350853508635087350883508935090350913509235093350943509535096350973509835099351003510135102351033510435105351063510735108351093511035111351123511335114351153511635117351183511935120351213512235123351243512535126351273512835129351303513135132351333513435135351363513735138351393514035141351423514335144351453514635147351483514935150351513515235153351543515535156351573515835159351603516135162351633516435165351663516735168351693517035171351723517335174351753517635177351783517935180351813518235183351843518535186351873518835189351903519135192351933519435195351963519735198351993520035201352023520335204352053520635207352083520935210352113521235213352143521535216352173521835219352203522135222352233522435225352263522735228352293523035231352323523335234352353523635237352383523935240352413524235243352443524535246352473524835249352503525135252352533525435255352563525735258352593526035261352623526335264352653526635267352683526935270352713527235273352743527535276352773527835279352803528135282352833528435285352863528735288352893529035291352923529335294352953529635297352983529935300353013530235303353043530535306353073530835309353103531135312353133531435315353163531735318353193532035321353223532335324353253532635327353283532935330353313533235333353343533535336353373533835339353403534135342353433534435345353463534735348353493535035351353523535335354353553535635357353583535935360353613536235363353643536535366353673536835369353703537135372353733537435375353763537735378353793538035381353823538335384353853538635387353883538935390353913539235393353943539535396353973539835399354003540135402354033540435405354063540735408354093541035411354123541335414354153541635417354183541935420354213542235423354243542535426354273542835429354303543135432354333543435435354363543735438354393544035441354423544335444354453544635447354483544935450354513545235453354543545535456354573545835459354603546135462354633546435465354663546735468354693547035471354723547335474354753547635477354783547935480354813548235483354843548535486354873548835489354903549135492354933549435495354963549735498354993550035501355023550335504355053550635507355083550935510355113551235513355143551535516355173551835519355203552135522355233552435525355263552735528355293553035531355323553335534355353553635537355383553935540355413554235543355443554535546355473554835549355503555135552355533555435555355563555735558355593556035561355623556335564355653556635567355683556935570355713557235573355743557535576355773557835579355803558135582355833558435585355863558735588355893559035591355923559335594355953559635597355983559935600356013560235603356043560535606356073560835609356103561135612356133561435615356163561735618356193562035621356223562335624356253562635627356283562935630356313563235633356343563535636356373563835639356403564135642356433564435645356463564735648356493565035651356523565335654356553565635657356583565935660356613566235663356643566535666356673566835669356703567135672356733567435675356763567735678356793568035681356823568335684356853568635687356883568935690356913569235693356943569535696356973569835699357003570135702357033570435705357063570735708357093571035711357123571335714357153571635717357183571935720357213572235723357243572535726357273572835729357303573135732357333573435735357363573735738357393574035741357423574335744357453574635747357483574935750357513575235753357543575535756357573575835759357603576135762357633576435765357663576735768357693577035771357723577335774357753577635777357783577935780357813578235783357843578535786357873578835789357903579135792357933579435795357963579735798357993580035801358023580335804358053580635807358083580935810358113581235813358143581535816358173581835819358203582135822358233582435825358263582735828358293583035831358323583335834358353583635837358383583935840358413584235843358443584535846358473584835849358503585135852358533585435855358563585735858358593586035861358623586335864358653586635867358683586935870358713587235873358743587535876358773587835879358803588135882358833588435885358863588735888358893589035891358923589335894358953589635897358983589935900359013590235903359043590535906359073590835909359103591135912359133591435915359163591735918359193592035921359223592335924359253592635927359283592935930359313593235933359343593535936359373593835939359403594135942359433594435945359463594735948359493595035951359523595335954359553595635957359583595935960359613596235963359643596535966359673596835969359703597135972359733597435975359763597735978359793598035981359823598335984359853598635987359883598935990359913599235993359943599535996359973599835999360003600136002360033600436005360063600736008360093601036011360123601336014360153601636017360183601936020360213602236023360243602536026360273602836029360303603136032360333603436035360363603736038360393604036041360423604336044360453604636047360483604936050360513605236053360543605536056360573605836059360603606136062360633606436065360663606736068360693607036071360723607336074360753607636077360783607936080360813608236083360843608536086360873608836089360903609136092360933609436095360963609736098360993610036101361023610336104361053610636107361083610936110361113611236113361143611536116361173611836119361203612136122361233612436125361263612736128361293613036131361323613336134361353613636137361383613936140361413614236143361443614536146361473614836149361503615136152361533615436155361563615736158361593616036161361623616336164361653616636167361683616936170361713617236173361743617536176361773617836179361803618136182361833618436185361863618736188361893619036191361923619336194361953619636197361983619936200362013620236203362043620536206362073620836209362103621136212362133621436215362163621736218362193622036221362223622336224362253622636227362283622936230362313623236233362343623536236362373623836239362403624136242362433624436245362463624736248362493625036251362523625336254362553625636257362583625936260362613626236263362643626536266362673626836269362703627136272362733627436275362763627736278362793628036281362823628336284362853628636287362883628936290362913629236293362943629536296362973629836299363003630136302363033630436305363063630736308363093631036311363123631336314363153631636317363183631936320363213632236323363243632536326363273632836329363303633136332363333633436335363363633736338363393634036341363423634336344363453634636347363483634936350363513635236353363543635536356363573635836359363603636136362363633636436365363663636736368363693637036371363723637336374363753637636377363783637936380363813638236383363843638536386363873638836389363903639136392363933639436395363963639736398363993640036401364023640336404364053640636407364083640936410364113641236413364143641536416364173641836419364203642136422364233642436425364263642736428364293643036431364323643336434364353643636437364383643936440364413644236443364443644536446364473644836449364503645136452364533645436455364563645736458364593646036461364623646336464364653646636467364683646936470364713647236473364743647536476364773647836479364803648136482364833648436485364863648736488364893649036491364923649336494364953649636497364983649936500365013650236503365043650536506365073650836509365103651136512365133651436515365163651736518365193652036521365223652336524365253652636527365283652936530365313653236533365343653536536365373653836539365403654136542365433654436545365463654736548365493655036551365523655336554365553655636557365583655936560365613656236563365643656536566365673656836569365703657136572365733657436575365763657736578365793658036581365823658336584365853658636587365883658936590365913659236593365943659536596365973659836599366003660136602366033660436605366063660736608366093661036611366123661336614366153661636617366183661936620366213662236623366243662536626366273662836629366303663136632366333663436635366363663736638366393664036641366423664336644366453664636647366483664936650366513665236653366543665536656366573665836659366603666136662366633666436665366663666736668366693667036671366723667336674366753667636677366783667936680366813668236683366843668536686366873668836689366903669136692366933669436695366963669736698366993670036701367023670336704367053670636707367083670936710367113671236713367143671536716367173671836719367203672136722367233672436725367263672736728367293673036731367323673336734367353673636737367383673936740367413674236743367443674536746367473674836749367503675136752367533675436755367563675736758367593676036761367623676336764367653676636767367683676936770367713677236773367743677536776367773677836779367803678136782367833678436785367863678736788367893679036791367923679336794367953679636797367983679936800368013680236803368043680536806368073680836809368103681136812368133681436815368163681736818368193682036821368223682336824368253682636827368283682936830368313683236833368343683536836368373683836839368403684136842368433684436845368463684736848368493685036851368523685336854368553685636857368583685936860368613686236863368643686536866368673686836869368703687136872368733687436875368763687736878368793688036881368823688336884368853688636887368883688936890368913689236893368943689536896368973689836899369003690136902369033690436905369063690736908369093691036911369123691336914369153691636917369183691936920369213692236923369243692536926369273692836929369303693136932369333693436935369363693736938369393694036941369423694336944369453694636947369483694936950369513695236953369543695536956369573695836959369603696136962369633696436965369663696736968369693697036971369723697336974369753697636977369783697936980369813698236983369843698536986369873698836989369903699136992369933699436995369963699736998369993700037001370023700337004370053700637007370083700937010370113701237013370143701537016370173701837019370203702137022370233702437025370263702737028370293703037031370323703337034370353703637037370383703937040370413704237043370443704537046370473704837049370503705137052370533705437055370563705737058370593706037061370623706337064370653706637067370683706937070370713707237073370743707537076370773707837079370803708137082370833708437085370863708737088370893709037091370923709337094370953709637097370983709937100371013710237103371043710537106371073710837109371103711137112371133711437115371163711737118371193712037121371223712337124371253712637127371283712937130371313713237133371343713537136371373713837139371403714137142371433714437145371463714737148371493715037151371523715337154371553715637157371583715937160371613716237163371643716537166371673716837169371703717137172371733717437175371763717737178371793718037181371823718337184371853718637187371883718937190371913719237193371943719537196371973719837199372003720137202372033720437205372063720737208372093721037211372123721337214372153721637217372183721937220372213722237223372243722537226372273722837229372303723137232372333723437235372363723737238372393724037241372423724337244372453724637247372483724937250372513725237253372543725537256372573725837259372603726137262372633726437265372663726737268372693727037271372723727337274372753727637277372783727937280372813728237283372843728537286372873728837289372903729137292372933729437295372963729737298372993730037301373023730337304373053730637307373083730937310373113731237313373143731537316373173731837319373203732137322373233732437325373263732737328373293733037331373323733337334373353733637337373383733937340373413734237343373443734537346373473734837349373503735137352373533735437355373563735737358373593736037361373623736337364373653736637367373683736937370373713737237373373743737537376373773737837379373803738137382373833738437385373863738737388373893739037391373923739337394373953739637397373983739937400374013740237403374043740537406374073740837409374103741137412374133741437415374163741737418374193742037421374223742337424374253742637427374283742937430374313743237433374343743537436374373743837439374403744137442374433744437445374463744737448374493745037451374523745337454374553745637457374583745937460374613746237463374643746537466374673746837469374703747137472374733747437475374763747737478374793748037481374823748337484374853748637487374883748937490374913749237493374943749537496374973749837499375003750137502375033750437505375063750737508375093751037511375123751337514375153751637517375183751937520375213752237523375243752537526375273752837529375303753137532375333753437535375363753737538375393754037541375423754337544375453754637547375483754937550375513755237553375543755537556375573755837559375603756137562375633756437565375663756737568375693757037571375723757337574375753757637577375783757937580375813758237583375843758537586375873758837589375903759137592375933759437595375963759737598375993760037601376023760337604376053760637607376083760937610376113761237613376143761537616376173761837619376203762137622376233762437625376263762737628376293763037631376323763337634376353763637637376383763937640376413764237643376443764537646376473764837649376503765137652376533765437655376563765737658376593766037661376623766337664376653766637667376683766937670376713767237673376743767537676376773767837679376803768137682376833768437685376863768737688376893769037691376923769337694376953769637697376983769937700377013770237703377043770537706377073770837709377103771137712377133771437715377163771737718377193772037721377223772337724377253772637727377283772937730377313773237733377343773537736377373773837739377403774137742377433774437745377463774737748377493775037751377523775337754377553775637757377583775937760377613776237763377643776537766377673776837769377703777137772377733777437775377763777737778377793778037781377823778337784377853778637787377883778937790377913779237793377943779537796377973779837799378003780137802378033780437805378063780737808378093781037811378123781337814378153781637817378183781937820378213782237823378243782537826378273782837829378303783137832378333783437835378363783737838378393784037841378423784337844378453784637847378483784937850378513785237853378543785537856378573785837859378603786137862378633786437865378663786737868378693787037871378723787337874378753787637877378783787937880378813788237883378843788537886378873788837889378903789137892378933789437895378963789737898378993790037901379023790337904379053790637907379083790937910379113791237913379143791537916379173791837919379203792137922379233792437925379263792737928379293793037931379323793337934379353793637937379383793937940379413794237943379443794537946379473794837949379503795137952379533795437955379563795737958379593796037961379623796337964379653796637967379683796937970379713797237973379743797537976379773797837979379803798137982379833798437985379863798737988379893799037991379923799337994379953799637997379983799938000380013800238003380043800538006380073800838009380103801138012380133801438015380163801738018380193802038021380223802338024380253802638027380283802938030380313803238033380343803538036380373803838039380403804138042380433804438045380463804738048380493805038051380523805338054380553805638057380583805938060380613806238063380643806538066380673806838069380703807138072380733807438075380763807738078380793808038081380823808338084380853808638087380883808938090380913809238093380943809538096380973809838099381003810138102381033810438105381063810738108381093811038111381123811338114381153811638117381183811938120381213812238123381243812538126381273812838129381303813138132381333813438135381363813738138381393814038141381423814338144381453814638147381483814938150381513815238153381543815538156381573815838159381603816138162381633816438165381663816738168381693817038171381723817338174381753817638177381783817938180381813818238183381843818538186381873818838189381903819138192381933819438195381963819738198381993820038201382023820338204382053820638207382083820938210382113821238213382143821538216382173821838219382203822138222382233822438225382263822738228382293823038231382323823338234382353823638237382383823938240382413824238243382443824538246382473824838249382503825138252382533825438255382563825738258382593826038261382623826338264382653826638267382683826938270382713827238273382743827538276382773827838279382803828138282382833828438285382863828738288382893829038291382923829338294382953829638297382983829938300383013830238303383043830538306383073830838309383103831138312383133831438315383163831738318383193832038321383223832338324383253832638327383283832938330383313833238333383343833538336383373833838339383403834138342383433834438345383463834738348383493835038351383523835338354383553835638357383583835938360383613836238363383643836538366383673836838369383703837138372383733837438375383763837738378383793838038381383823838338384383853838638387383883838938390383913839238393383943839538396383973839838399384003840138402384033840438405384063840738408384093841038411384123841338414384153841638417384183841938420384213842238423384243842538426384273842838429384303843138432384333843438435384363843738438384393844038441384423844338444384453844638447384483844938450384513845238453384543845538456384573845838459384603846138462384633846438465384663846738468384693847038471384723847338474384753847638477384783847938480384813848238483384843848538486384873848838489384903849138492384933849438495384963849738498384993850038501385023850338504385053850638507385083850938510385113851238513385143851538516385173851838519385203852138522385233852438525385263852738528385293853038531385323853338534385353853638537385383853938540385413854238543385443854538546385473854838549385503855138552385533855438555385563855738558385593856038561385623856338564385653856638567385683856938570385713857238573385743857538576385773857838579385803858138582385833858438585385863858738588385893859038591385923859338594385953859638597385983859938600386013860238603386043860538606386073860838609386103861138612386133861438615386163861738618386193862038621386223862338624386253862638627386283862938630386313863238633386343863538636386373863838639386403864138642386433864438645386463864738648386493865038651386523865338654386553865638657386583865938660386613866238663386643866538666386673866838669386703867138672386733867438675386763867738678386793868038681386823868338684386853868638687386883868938690386913869238693386943869538696386973869838699387003870138702387033870438705387063870738708387093871038711387123871338714387153871638717387183871938720387213872238723387243872538726387273872838729387303873138732387333873438735387363873738738387393874038741387423874338744387453874638747387483874938750387513875238753387543875538756387573875838759387603876138762387633876438765387663876738768387693877038771387723877338774387753877638777387783877938780387813878238783387843878538786387873878838789387903879138792387933879438795387963879738798387993880038801388023880338804388053880638807388083880938810388113881238813388143881538816388173881838819388203882138822388233882438825388263882738828388293883038831388323883338834388353883638837388383883938840388413884238843388443884538846388473884838849388503885138852388533885438855388563885738858388593886038861388623886338864388653886638867388683886938870388713887238873388743887538876388773887838879388803888138882388833888438885388863888738888388893889038891388923889338894388953889638897388983889938900389013890238903389043890538906389073890838909389103891138912389133891438915389163891738918389193892038921389223892338924389253892638927389283892938930389313893238933389343893538936389373893838939389403894138942389433894438945389463894738948389493895038951389523895338954389553895638957389583895938960389613896238963389643896538966389673896838969389703897138972389733897438975389763897738978389793898038981389823898338984389853898638987389883898938990389913899238993389943899538996389973899838999390003900139002390033900439005390063900739008390093901039011390123901339014390153901639017390183901939020390213902239023390243902539026390273902839029390303903139032390333903439035390363903739038390393904039041390423904339044390453904639047390483904939050390513905239053390543905539056390573905839059390603906139062390633906439065390663906739068390693907039071390723907339074390753907639077390783907939080390813908239083390843908539086390873908839089390903909139092390933909439095390963909739098390993910039101391023910339104391053910639107391083910939110391113911239113391143911539116391173911839119391203912139122391233912439125391263912739128391293913039131391323913339134391353913639137391383913939140391413914239143391443914539146391473914839149391503915139152391533915439155391563915739158391593916039161391623916339164391653916639167391683916939170391713917239173391743917539176391773917839179391803918139182391833918439185391863918739188391893919039191391923919339194391953919639197391983919939200392013920239203392043920539206392073920839209392103921139212392133921439215392163921739218392193922039221392223922339224392253922639227392283922939230392313923239233392343923539236392373923839239392403924139242392433924439245392463924739248392493925039251392523925339254392553925639257392583925939260392613926239263392643926539266392673926839269392703927139272392733927439275392763927739278392793928039281392823928339284392853928639287392883928939290392913929239293392943929539296392973929839299393003930139302393033930439305393063930739308393093931039311393123931339314393153931639317393183931939320393213932239323393243932539326393273932839329393303933139332393333933439335393363933739338393393934039341393423934339344393453934639347393483934939350393513935239353393543935539356393573935839359393603936139362393633936439365393663936739368393693937039371393723937339374393753937639377393783937939380393813938239383393843938539386393873938839389393903939139392393933939439395393963939739398393993940039401394023940339404394053940639407394083940939410394113941239413394143941539416394173941839419394203942139422394233942439425394263942739428394293943039431394323943339434394353943639437394383943939440394413944239443394443944539446394473944839449394503945139452394533945439455394563945739458394593946039461394623946339464394653946639467394683946939470394713947239473394743947539476394773947839479394803948139482394833948439485394863948739488394893949039491394923949339494394953949639497394983949939500395013950239503395043950539506395073950839509395103951139512395133951439515395163951739518395193952039521395223952339524395253952639527395283952939530395313953239533395343953539536395373953839539395403954139542395433954439545395463954739548395493955039551395523955339554395553955639557395583955939560395613956239563395643956539566395673956839569395703957139572395733957439575395763957739578395793958039581395823958339584395853958639587395883958939590395913959239593395943959539596395973959839599396003960139602396033960439605396063960739608396093961039611396123961339614396153961639617396183961939620396213962239623396243962539626396273962839629396303963139632396333963439635396363963739638396393964039641396423964339644396453964639647396483964939650396513965239653396543965539656396573965839659396603966139662396633966439665396663966739668396693967039671396723967339674396753967639677396783967939680396813968239683396843968539686396873968839689396903969139692396933969439695396963969739698396993970039701397023970339704397053970639707397083970939710397113971239713397143971539716397173971839719397203972139722397233972439725397263972739728397293973039731397323973339734397353973639737397383973939740397413974239743397443974539746397473974839749397503975139752397533975439755397563975739758397593976039761397623976339764397653976639767397683976939770397713977239773397743977539776397773977839779397803978139782397833978439785397863978739788397893979039791397923979339794397953979639797397983979939800398013980239803398043980539806398073980839809398103981139812398133981439815398163981739818398193982039821398223982339824398253982639827398283982939830398313983239833398343983539836398373983839839398403984139842398433984439845398463984739848398493985039851398523985339854398553985639857398583985939860398613986239863398643986539866398673986839869398703987139872398733987439875398763987739878398793988039881398823988339884398853988639887398883988939890398913989239893398943989539896398973989839899399003990139902399033990439905399063990739908399093991039911399123991339914399153991639917399183991939920399213992239923399243992539926399273992839929399303993139932399333993439935399363993739938399393994039941399423994339944399453994639947399483994939950399513995239953399543995539956399573995839959399603996139962399633996439965399663996739968399693997039971399723997339974399753997639977399783997939980399813998239983399843998539986399873998839989399903999139992399933999439995399963999739998399994000040001400024000340004400054000640007400084000940010400114001240013400144001540016400174001840019400204002140022400234002440025400264002740028400294003040031400324003340034400354003640037400384003940040400414004240043400444004540046400474004840049400504005140052400534005440055400564005740058400594006040061400624006340064400654006640067400684006940070400714007240073400744007540076400774007840079400804008140082400834008440085400864008740088400894009040091400924009340094400954009640097400984009940100401014010240103401044010540106401074010840109401104011140112401134011440115401164011740118401194012040121401224012340124401254012640127401284012940130401314013240133401344013540136401374013840139401404014140142401434014440145401464014740148401494015040151401524015340154401554015640157401584015940160401614016240163401644016540166401674016840169401704017140172401734017440175401764017740178401794018040181401824018340184401854018640187401884018940190401914019240193401944019540196401974019840199402004020140202402034020440205402064020740208402094021040211402124021340214402154021640217402184021940220402214022240223402244022540226402274022840229402304023140232402334023440235402364023740238402394024040241402424024340244402454024640247402484024940250402514025240253402544025540256402574025840259402604026140262402634026440265402664026740268402694027040271402724027340274402754027640277402784027940280402814028240283402844028540286402874028840289402904029140292402934029440295402964029740298402994030040301403024030340304403054030640307403084030940310403114031240313403144031540316403174031840319403204032140322403234032440325403264032740328403294033040331403324033340334403354033640337403384033940340403414034240343403444034540346403474034840349403504035140352403534035440355403564035740358403594036040361403624036340364403654036640367403684036940370403714037240373403744037540376403774037840379403804038140382403834038440385403864038740388403894039040391403924039340394403954039640397403984039940400404014040240403404044040540406404074040840409404104041140412404134041440415404164041740418404194042040421404224042340424404254042640427404284042940430404314043240433404344043540436404374043840439404404044140442404434044440445404464044740448404494045040451404524045340454404554045640457404584045940460404614046240463404644046540466404674046840469404704047140472404734047440475404764047740478404794048040481404824048340484404854048640487404884048940490404914049240493404944049540496404974049840499405004050140502405034050440505405064050740508405094051040511405124051340514405154051640517405184051940520405214052240523405244052540526405274052840529405304053140532405334053440535405364053740538405394054040541405424054340544405454054640547405484054940550405514055240553405544055540556405574055840559405604056140562405634056440565405664056740568405694057040571405724057340574405754057640577405784057940580405814058240583405844058540586405874058840589405904059140592405934059440595405964059740598405994060040601406024060340604406054060640607406084060940610406114061240613406144061540616406174061840619406204062140622406234062440625406264062740628406294063040631406324063340634406354063640637406384063940640406414064240643406444064540646406474064840649406504065140652406534065440655406564065740658406594066040661406624066340664406654066640667406684066940670406714067240673406744067540676406774067840679406804068140682406834068440685406864068740688406894069040691406924069340694406954069640697406984069940700407014070240703407044070540706407074070840709407104071140712407134071440715407164071740718407194072040721407224072340724407254072640727407284072940730407314073240733407344073540736407374073840739407404074140742407434074440745407464074740748407494075040751407524075340754407554075640757407584075940760407614076240763407644076540766407674076840769407704077140772407734077440775407764077740778407794078040781407824078340784407854078640787407884078940790407914079240793407944079540796407974079840799408004080140802408034080440805408064080740808408094081040811408124081340814408154081640817408184081940820408214082240823408244082540826408274082840829408304083140832408334083440835408364083740838408394084040841408424084340844408454084640847408484084940850408514085240853408544085540856408574085840859408604086140862408634086440865408664086740868408694087040871408724087340874408754087640877408784087940880408814088240883408844088540886408874088840889408904089140892408934089440895408964089740898408994090040901409024090340904409054090640907409084090940910409114091240913409144091540916409174091840919409204092140922409234092440925409264092740928409294093040931409324093340934409354093640937409384093940940409414094240943409444094540946409474094840949409504095140952409534095440955409564095740958409594096040961409624096340964409654096640967409684096940970409714097240973409744097540976409774097840979409804098140982409834098440985409864098740988409894099040991409924099340994409954099640997409984099941000410014100241003410044100541006410074100841009410104101141012410134101441015410164101741018410194102041021410224102341024410254102641027410284102941030410314103241033410344103541036410374103841039410404104141042410434104441045410464104741048410494105041051410524105341054410554105641057410584105941060410614106241063410644106541066410674106841069410704107141072410734107441075410764107741078410794108041081410824108341084410854108641087410884108941090410914109241093410944109541096410974109841099411004110141102411034110441105411064110741108411094111041111411124111341114411154111641117411184111941120411214112241123411244112541126411274112841129411304113141132411334113441135411364113741138411394114041141411424114341144411454114641147411484114941150411514115241153411544115541156411574115841159411604116141162411634116441165411664116741168411694117041171411724117341174411754117641177411784117941180411814118241183411844118541186411874118841189411904119141192411934119441195411964119741198411994120041201412024120341204412054120641207412084120941210412114121241213412144121541216412174121841219412204122141222412234122441225412264122741228412294123041231412324123341234412354123641237412384123941240412414124241243412444124541246412474124841249412504125141252412534125441255412564125741258412594126041261412624126341264412654126641267412684126941270412714127241273412744127541276412774127841279412804128141282412834128441285412864128741288412894129041291412924129341294412954129641297412984129941300413014130241303413044130541306413074130841309413104131141312413134131441315413164131741318413194132041321413224132341324413254132641327413284132941330413314133241333413344133541336413374133841339413404134141342413434134441345413464134741348413494135041351413524135341354413554135641357413584135941360413614136241363413644136541366413674136841369413704137141372413734137441375413764137741378413794138041381413824138341384413854138641387413884138941390413914139241393413944139541396413974139841399414004140141402414034140441405414064140741408414094141041411414124141341414414154141641417414184141941420414214142241423414244142541426414274142841429414304143141432414334143441435414364143741438414394144041441414424144341444414454144641447414484144941450414514145241453414544145541456414574145841459414604146141462414634146441465414664146741468414694147041471414724147341474414754147641477414784147941480414814148241483414844148541486414874148841489414904149141492414934149441495414964149741498414994150041501415024150341504415054150641507415084150941510415114151241513415144151541516415174151841519415204152141522415234152441525415264152741528415294153041531415324153341534415354153641537415384153941540415414154241543415444154541546415474154841549415504155141552415534155441555415564155741558415594156041561415624156341564415654156641567415684156941570415714157241573415744157541576415774157841579415804158141582415834158441585415864158741588415894159041591415924159341594415954159641597415984159941600416014160241603416044160541606416074160841609416104161141612416134161441615416164161741618416194162041621416224162341624416254162641627416284162941630416314163241633416344163541636416374163841639416404164141642416434164441645416464164741648416494165041651416524165341654416554165641657416584165941660416614166241663416644166541666416674166841669416704167141672416734167441675416764167741678416794168041681416824168341684416854168641687416884168941690416914169241693416944169541696416974169841699417004170141702417034170441705417064170741708417094171041711417124171341714417154171641717417184171941720417214172241723417244172541726417274172841729417304173141732417334173441735417364173741738417394174041741417424174341744417454174641747417484174941750417514175241753417544175541756417574175841759417604176141762417634176441765417664176741768417694177041771417724177341774417754177641777417784177941780417814178241783417844178541786417874178841789417904179141792417934179441795417964179741798417994180041801418024180341804418054180641807418084180941810418114181241813418144181541816418174181841819418204182141822418234182441825418264182741828418294183041831418324183341834418354183641837418384183941840418414184241843418444184541846418474184841849418504185141852418534185441855418564185741858418594186041861418624186341864418654186641867418684186941870418714187241873418744187541876418774187841879418804188141882418834188441885418864188741888418894189041891418924189341894418954189641897418984189941900419014190241903419044190541906419074190841909419104191141912419134191441915419164191741918419194192041921419224192341924419254192641927419284192941930419314193241933419344193541936419374193841939419404194141942419434194441945419464194741948419494195041951419524195341954419554195641957419584195941960419614196241963419644196541966419674196841969419704197141972419734197441975419764197741978419794198041981419824198341984419854198641987419884198941990419914199241993419944199541996419974199841999420004200142002420034200442005420064200742008420094201042011420124201342014420154201642017420184201942020420214202242023420244202542026420274202842029420304203142032420334203442035420364203742038420394204042041420424204342044420454204642047420484204942050420514205242053420544205542056420574205842059420604206142062420634206442065420664206742068420694207042071420724207342074420754207642077420784207942080420814208242083420844208542086420874208842089420904209142092420934209442095420964209742098420994210042101421024210342104421054210642107421084210942110421114211242113421144211542116421174211842119421204212142122421234212442125421264212742128421294213042131421324213342134421354213642137421384213942140421414214242143421444214542146421474214842149421504215142152421534215442155421564215742158421594216042161421624216342164421654216642167421684216942170421714217242173421744217542176421774217842179421804218142182421834218442185421864218742188421894219042191421924219342194421954219642197421984219942200422014220242203422044220542206422074220842209422104221142212422134221442215422164221742218422194222042221422224222342224422254222642227422284222942230422314223242233422344223542236422374223842239422404224142242422434224442245422464224742248422494225042251422524225342254422554225642257422584225942260422614226242263422644226542266422674226842269422704227142272422734227442275422764227742278422794228042281422824228342284422854228642287422884228942290422914229242293422944229542296422974229842299423004230142302423034230442305423064230742308423094231042311423124231342314423154231642317423184231942320423214232242323423244232542326423274232842329423304233142332423334233442335423364233742338423394234042341423424234342344423454234642347423484234942350423514235242353423544235542356423574235842359423604236142362423634236442365423664236742368423694237042371423724237342374423754237642377423784237942380423814238242383423844238542386423874238842389423904239142392423934239442395423964239742398423994240042401424024240342404424054240642407424084240942410424114241242413424144241542416424174241842419424204242142422424234242442425424264242742428424294243042431424324243342434424354243642437424384243942440424414244242443424444244542446424474244842449424504245142452424534245442455424564245742458424594246042461424624246342464424654246642467424684246942470424714247242473424744247542476424774247842479424804248142482424834248442485424864248742488424894249042491424924249342494424954249642497424984249942500425014250242503425044250542506425074250842509425104251142512425134251442515425164251742518425194252042521425224252342524425254252642527425284252942530425314253242533425344253542536425374253842539425404254142542425434254442545425464254742548425494255042551425524255342554425554255642557425584255942560425614256242563425644256542566425674256842569425704257142572425734257442575425764257742578425794258042581425824258342584425854258642587425884258942590425914259242593425944259542596425974259842599426004260142602426034260442605426064260742608426094261042611426124261342614426154261642617426184261942620426214262242623426244262542626426274262842629426304263142632426334263442635426364263742638426394264042641426424264342644426454264642647426484264942650426514265242653426544265542656426574265842659426604266142662426634266442665426664266742668426694267042671426724267342674426754267642677426784267942680426814268242683426844268542686426874268842689426904269142692426934269442695426964269742698426994270042701427024270342704427054270642707427084270942710427114271242713427144271542716427174271842719427204272142722427234272442725427264272742728427294273042731427324273342734427354273642737427384273942740427414274242743427444274542746427474274842749427504275142752427534275442755427564275742758427594276042761427624276342764427654276642767427684276942770427714277242773427744277542776427774277842779427804278142782427834278442785427864278742788427894279042791427924279342794427954279642797427984279942800428014280242803428044280542806428074280842809428104281142812428134281442815428164281742818428194282042821428224282342824428254282642827428284282942830428314283242833428344283542836428374283842839428404284142842428434284442845428464284742848428494285042851428524285342854428554285642857428584285942860428614286242863428644286542866428674286842869428704287142872428734287442875428764287742878428794288042881428824288342884428854288642887428884288942890428914289242893428944289542896428974289842899429004290142902429034290442905429064290742908429094291042911429124291342914429154291642917429184291942920429214292242923429244292542926429274292842929429304293142932429334293442935429364293742938429394294042941429424294342944429454294642947429484294942950429514295242953429544295542956429574295842959429604296142962429634296442965429664296742968429694297042971429724297342974429754297642977429784297942980429814298242983429844298542986429874298842989429904299142992429934299442995429964299742998429994300043001430024300343004430054300643007430084300943010430114301243013430144301543016430174301843019430204302143022430234302443025430264302743028430294303043031430324303343034430354303643037430384303943040430414304243043430444304543046430474304843049430504305143052430534305443055430564305743058430594306043061430624306343064430654306643067430684306943070430714307243073430744307543076430774307843079430804308143082430834308443085430864308743088430894309043091430924309343094430954309643097430984309943100431014310243103431044310543106431074310843109431104311143112431134311443115431164311743118431194312043121431224312343124431254312643127431284312943130431314313243133431344313543136431374313843139431404314143142431434314443145431464314743148431494315043151431524315343154431554315643157431584315943160431614316243163431644316543166431674316843169431704317143172431734317443175431764317743178431794318043181431824318343184431854318643187431884318943190431914319243193431944319543196431974319843199432004320143202432034320443205432064320743208432094321043211432124321343214432154321643217432184321943220432214322243223432244322543226432274322843229432304323143232432334323443235432364323743238432394324043241432424324343244432454324643247432484324943250432514325243253432544325543256432574325843259432604326143262432634326443265432664326743268432694327043271432724327343274432754327643277432784327943280432814328243283432844328543286432874328843289432904329143292432934329443295432964329743298432994330043301433024330343304433054330643307433084330943310433114331243313433144331543316433174331843319433204332143322433234332443325433264332743328433294333043331433324333343334433354333643337433384333943340433414334243343433444334543346433474334843349433504335143352433534335443355433564335743358433594336043361433624336343364433654336643367433684336943370433714337243373433744337543376433774337843379433804338143382433834338443385433864338743388433894339043391433924339343394433954339643397433984339943400434014340243403434044340543406434074340843409434104341143412434134341443415434164341743418434194342043421434224342343424434254342643427434284342943430434314343243433434344343543436434374343843439434404344143442434434344443445434464344743448434494345043451434524345343454434554345643457434584345943460434614346243463434644346543466434674346843469434704347143472434734347443475434764347743478434794348043481434824348343484434854348643487434884348943490434914349243493434944349543496434974349843499435004350143502435034350443505435064350743508435094351043511435124351343514435154351643517435184351943520435214352243523435244352543526435274352843529435304353143532435334353443535435364353743538435394354043541435424354343544435454354643547435484354943550435514355243553435544355543556435574355843559435604356143562435634356443565435664356743568435694357043571435724357343574435754357643577435784357943580435814358243583435844358543586435874358843589435904359143592435934359443595435964359743598435994360043601436024360343604436054360643607436084360943610436114361243613436144361543616436174361843619436204362143622436234362443625436264362743628436294363043631436324363343634436354363643637436384363943640436414364243643436444364543646436474364843649436504365143652436534365443655436564365743658436594366043661436624366343664436654366643667436684366943670436714367243673436744367543676436774367843679436804368143682436834368443685436864368743688436894369043691436924369343694436954369643697436984369943700437014370243703437044370543706437074370843709437104371143712437134371443715437164371743718437194372043721437224372343724437254372643727437284372943730437314373243733437344373543736437374373843739437404374143742437434374443745437464374743748437494375043751437524375343754437554375643757437584375943760437614376243763437644376543766437674376843769437704377143772437734377443775437764377743778437794378043781437824378343784437854378643787437884378943790437914379243793437944379543796437974379843799438004380143802438034380443805438064380743808438094381043811438124381343814438154381643817438184381943820438214382243823438244382543826438274382843829438304383143832438334383443835438364383743838438394384043841438424384343844438454384643847438484384943850438514385243853438544385543856438574385843859438604386143862438634386443865438664386743868438694387043871438724387343874438754387643877438784387943880438814388243883438844388543886438874388843889438904389143892438934389443895438964389743898438994390043901439024390343904439054390643907439084390943910439114391243913439144391543916439174391843919439204392143922439234392443925439264392743928439294393043931439324393343934439354393643937439384393943940439414394243943439444394543946439474394843949439504395143952439534395443955439564395743958439594396043961439624396343964439654396643967439684396943970439714397243973439744397543976439774397843979439804398143982439834398443985439864398743988439894399043991439924399343994439954399643997439984399944000440014400244003440044400544006440074400844009440104401144012440134401444015440164401744018440194402044021440224402344024440254402644027440284402944030440314403244033440344403544036440374403844039440404404144042440434404444045440464404744048440494405044051440524405344054440554405644057440584405944060440614406244063440644406544066440674406844069440704407144072440734407444075440764407744078440794408044081440824408344084440854408644087440884408944090440914409244093440944409544096440974409844099441004410144102441034410444105441064410744108441094411044111441124411344114441154411644117441184411944120441214412244123441244412544126441274412844129441304413144132441334413444135441364413744138441394414044141441424414344144441454414644147441484414944150441514415244153441544415544156441574415844159441604416144162441634416444165441664416744168441694417044171441724417344174441754417644177441784417944180441814418244183441844418544186441874418844189441904419144192441934419444195441964419744198441994420044201442024420344204442054420644207442084420944210442114421244213442144421544216442174421844219442204422144222442234422444225442264422744228442294423044231442324423344234442354423644237442384423944240442414424244243442444424544246442474424844249442504425144252442534425444255442564425744258442594426044261442624426344264442654426644267442684426944270442714427244273442744427544276442774427844279442804428144282442834428444285442864428744288442894429044291442924429344294442954429644297442984429944300443014430244303443044430544306443074430844309443104431144312443134431444315443164431744318443194432044321443224432344324443254432644327443284432944330443314433244333443344433544336443374433844339443404434144342443434434444345443464434744348443494435044351443524435344354443554435644357443584435944360443614436244363443644436544366443674436844369443704437144372443734437444375443764437744378443794438044381443824438344384443854438644387443884438944390443914439244393443944439544396443974439844399444004440144402444034440444405444064440744408444094441044411444124441344414444154441644417444184441944420444214442244423444244442544426444274442844429444304443144432444334443444435444364443744438444394444044441444424444344444444454444644447444484444944450444514445244453444544445544456444574445844459444604446144462444634446444465444664446744468444694447044471444724447344474444754447644477444784447944480444814448244483444844448544486444874448844489444904449144492444934449444495444964449744498444994450044501445024450344504445054450644507445084450944510445114451244513445144451544516445174451844519445204452144522445234452444525445264452744528445294453044531445324453344534445354453644537445384453944540445414454244543445444454544546445474454844549445504455144552445534455444555445564455744558445594456044561445624456344564445654456644567445684456944570445714457244573445744457544576445774457844579445804458144582445834458444585445864458744588445894459044591445924459344594445954459644597445984459944600446014460244603446044460544606446074460844609446104461144612446134461444615446164461744618446194462044621446224462344624446254462644627446284462944630446314463244633446344463544636446374463844639446404464144642446434464444645446464464744648446494465044651446524465344654446554465644657446584465944660446614466244663446644466544666446674466844669446704467144672446734467444675446764467744678446794468044681446824468344684446854468644687446884468944690446914469244693446944469544696446974469844699447004470144702447034470444705447064470744708447094471044711447124471344714447154471644717447184471944720447214472244723447244472544726447274472844729447304473144732447334473444735447364473744738447394474044741447424474344744447454474644747447484474944750447514475244753447544475544756447574475844759447604476144762447634476444765447664476744768447694477044771447724477344774447754477644777447784477944780447814478244783447844478544786447874478844789447904479144792447934479444795447964479744798447994480044801448024480344804448054480644807448084480944810448114481244813448144481544816448174481844819448204482144822448234482444825448264482744828448294483044831448324483344834448354483644837448384483944840448414484244843448444484544846448474484844849448504485144852448534485444855448564485744858448594486044861448624486344864448654486644867448684486944870448714487244873448744487544876448774487844879448804488144882448834488444885448864488744888448894489044891448924489344894448954489644897448984489944900449014490244903449044490544906449074490844909449104491144912449134491444915449164491744918449194492044921449224492344924449254492644927449284492944930449314493244933449344493544936449374493844939449404494144942449434494444945449464494744948449494495044951449524495344954449554495644957449584495944960449614496244963449644496544966449674496844969449704497144972449734497444975449764497744978449794498044981449824498344984449854498644987449884498944990449914499244993449944499544996449974499844999450004500145002450034500445005450064500745008450094501045011450124501345014450154501645017450184501945020450214502245023450244502545026450274502845029450304503145032450334503445035450364503745038450394504045041450424504345044450454504645047450484504945050450514505245053450544505545056450574505845059450604506145062450634506445065450664506745068450694507045071450724507345074450754507645077450784507945080450814508245083450844508545086450874508845089450904509145092450934509445095450964509745098450994510045101451024510345104451054510645107451084510945110451114511245113451144511545116451174511845119451204512145122451234512445125451264512745128451294513045131451324513345134451354513645137451384513945140451414514245143451444514545146451474514845149451504515145152451534515445155451564515745158451594516045161451624516345164451654516645167451684516945170451714517245173451744517545176451774517845179451804518145182451834518445185451864518745188451894519045191451924519345194451954519645197451984519945200452014520245203452044520545206452074520845209452104521145212452134521445215452164521745218452194522045221452224522345224452254522645227452284522945230452314523245233452344523545236452374523845239452404524145242452434524445245452464524745248452494525045251452524525345254452554525645257452584525945260452614526245263452644526545266452674526845269452704527145272452734527445275452764527745278452794528045281452824528345284452854528645287452884528945290452914529245293452944529545296452974529845299453004530145302453034530445305453064530745308453094531045311453124531345314453154531645317453184531945320453214532245323453244532545326453274532845329453304533145332453334533445335453364533745338453394534045341453424534345344453454534645347453484534945350453514535245353453544535545356453574535845359453604536145362453634536445365453664536745368453694537045371453724537345374453754537645377453784537945380453814538245383453844538545386453874538845389453904539145392453934539445395453964539745398453994540045401454024540345404454054540645407454084540945410454114541245413454144541545416454174541845419454204542145422454234542445425454264542745428454294543045431454324543345434454354543645437454384543945440454414544245443454444544545446454474544845449454504545145452454534545445455454564545745458454594546045461454624546345464454654546645467454684546945470454714547245473454744547545476454774547845479454804548145482454834548445485454864548745488454894549045491454924549345494454954549645497454984549945500455014550245503455044550545506455074550845509455104551145512455134551445515455164551745518455194552045521455224552345524455254552645527455284552945530455314553245533455344553545536455374553845539455404554145542455434554445545455464554745548455494555045551455524555345554455554555645557455584555945560455614556245563455644556545566455674556845569455704557145572455734557445575455764557745578455794558045581455824558345584455854558645587455884558945590455914559245593455944559545596455974559845599456004560145602456034560445605456064560745608456094561045611456124561345614456154561645617456184561945620456214562245623456244562545626456274562845629456304563145632456334563445635456364563745638456394564045641456424564345644456454564645647456484564945650456514565245653456544565545656456574565845659456604566145662456634566445665456664566745668456694567045671456724567345674456754567645677456784567945680456814568245683456844568545686456874568845689456904569145692456934569445695456964569745698456994570045701457024570345704457054570645707457084570945710457114571245713457144571545716457174571845719457204572145722457234572445725457264572745728457294573045731457324573345734457354573645737457384573945740457414574245743457444574545746457474574845749457504575145752457534575445755457564575745758457594576045761457624576345764457654576645767457684576945770457714577245773457744577545776457774577845779457804578145782457834578445785457864578745788457894579045791457924579345794457954579645797457984579945800458014580245803458044580545806458074580845809458104581145812458134581445815458164581745818458194582045821458224582345824458254582645827458284582945830458314583245833458344583545836458374583845839458404584145842458434584445845458464584745848458494585045851458524585345854458554585645857458584585945860458614586245863458644586545866458674586845869458704587145872458734587445875458764587745878458794588045881458824588345884458854588645887458884588945890458914589245893458944589545896458974589845899459004590145902459034590445905459064590745908459094591045911459124591345914
  1. // Code generated by ent, DO NOT EDIT.
  2. package ent
  3. import (
  4. "context"
  5. "errors"
  6. "fmt"
  7. "sync"
  8. "time"
  9. "wechat-api/ent/agent"
  10. "wechat-api/ent/agentbase"
  11. "wechat-api/ent/aliyunavatar"
  12. "wechat-api/ent/allocagent"
  13. "wechat-api/ent/batchmsg"
  14. "wechat-api/ent/category"
  15. "wechat-api/ent/chatrecords"
  16. "wechat-api/ent/chatsession"
  17. "wechat-api/ent/contact"
  18. "wechat-api/ent/creditbalance"
  19. "wechat-api/ent/creditusage"
  20. "wechat-api/ent/custom_types"
  21. "wechat-api/ent/employee"
  22. "wechat-api/ent/employeeconfig"
  23. "wechat-api/ent/label"
  24. "wechat-api/ent/labelrelationship"
  25. "wechat-api/ent/labeltagging"
  26. "wechat-api/ent/message"
  27. "wechat-api/ent/messagerecords"
  28. "wechat-api/ent/msg"
  29. "wechat-api/ent/payrecharge"
  30. "wechat-api/ent/predicate"
  31. "wechat-api/ent/server"
  32. "wechat-api/ent/sopnode"
  33. "wechat-api/ent/sopstage"
  34. "wechat-api/ent/soptask"
  35. "wechat-api/ent/token"
  36. "wechat-api/ent/tutorial"
  37. "wechat-api/ent/usagedetail"
  38. "wechat-api/ent/usagestatisticday"
  39. "wechat-api/ent/usagestatistichour"
  40. "wechat-api/ent/usagestatisticmonth"
  41. "wechat-api/ent/usagetotal"
  42. "wechat-api/ent/whatsapp"
  43. "wechat-api/ent/workexperience"
  44. "wechat-api/ent/wpchatroom"
  45. "wechat-api/ent/wpchatroommember"
  46. "wechat-api/ent/wx"
  47. "wechat-api/ent/wxcard"
  48. "wechat-api/ent/wxcarduser"
  49. "wechat-api/ent/wxcardvisit"
  50. "entgo.io/ent"
  51. "entgo.io/ent/dialect/sql"
  52. )
  53. const (
  54. // Operation types.
  55. OpCreate = ent.OpCreate
  56. OpDelete = ent.OpDelete
  57. OpDeleteOne = ent.OpDeleteOne
  58. OpUpdate = ent.OpUpdate
  59. OpUpdateOne = ent.OpUpdateOne
  60. // Node types.
  61. TypeAgent = "Agent"
  62. TypeAgentBase = "AgentBase"
  63. TypeAliyunAvatar = "AliyunAvatar"
  64. TypeAllocAgent = "AllocAgent"
  65. TypeBatchMsg = "BatchMsg"
  66. TypeCategory = "Category"
  67. TypeChatRecords = "ChatRecords"
  68. TypeChatSession = "ChatSession"
  69. TypeContact = "Contact"
  70. TypeCreditBalance = "CreditBalance"
  71. TypeCreditUsage = "CreditUsage"
  72. TypeEmployee = "Employee"
  73. TypeEmployeeConfig = "EmployeeConfig"
  74. TypeLabel = "Label"
  75. TypeLabelRelationship = "LabelRelationship"
  76. TypeLabelTagging = "LabelTagging"
  77. TypeMessage = "Message"
  78. TypeMessageRecords = "MessageRecords"
  79. TypeMsg = "Msg"
  80. TypePayRecharge = "PayRecharge"
  81. TypeServer = "Server"
  82. TypeSopNode = "SopNode"
  83. TypeSopStage = "SopStage"
  84. TypeSopTask = "SopTask"
  85. TypeToken = "Token"
  86. TypeTutorial = "Tutorial"
  87. TypeUsageDetail = "UsageDetail"
  88. TypeUsageStatisticDay = "UsageStatisticDay"
  89. TypeUsageStatisticHour = "UsageStatisticHour"
  90. TypeUsageStatisticMonth = "UsageStatisticMonth"
  91. TypeUsageTotal = "UsageTotal"
  92. TypeWhatsapp = "Whatsapp"
  93. TypeWorkExperience = "WorkExperience"
  94. TypeWpChatroom = "WpChatroom"
  95. TypeWpChatroomMember = "WpChatroomMember"
  96. TypeWx = "Wx"
  97. TypeWxCard = "WxCard"
  98. TypeWxCardUser = "WxCardUser"
  99. TypeWxCardVisit = "WxCardVisit"
  100. )
  101. // AgentMutation represents an operation that mutates the Agent nodes in the graph.
  102. type AgentMutation struct {
  103. config
  104. op Op
  105. typ string
  106. id *uint64
  107. created_at *time.Time
  108. updated_at *time.Time
  109. deleted_at *time.Time
  110. name *string
  111. role *string
  112. status *int
  113. addstatus *int
  114. background *string
  115. examples *string
  116. organization_id *uint64
  117. addorganization_id *int64
  118. dataset_id *string
  119. collection_id *string
  120. clearedFields map[string]struct{}
  121. wx_agent map[uint64]struct{}
  122. removedwx_agent map[uint64]struct{}
  123. clearedwx_agent bool
  124. token_agent map[uint64]struct{}
  125. removedtoken_agent map[uint64]struct{}
  126. clearedtoken_agent bool
  127. done bool
  128. oldValue func(context.Context) (*Agent, error)
  129. predicates []predicate.Agent
  130. }
  131. var _ ent.Mutation = (*AgentMutation)(nil)
  132. // agentOption allows management of the mutation configuration using functional options.
  133. type agentOption func(*AgentMutation)
  134. // newAgentMutation creates new mutation for the Agent entity.
  135. func newAgentMutation(c config, op Op, opts ...agentOption) *AgentMutation {
  136. m := &AgentMutation{
  137. config: c,
  138. op: op,
  139. typ: TypeAgent,
  140. clearedFields: make(map[string]struct{}),
  141. }
  142. for _, opt := range opts {
  143. opt(m)
  144. }
  145. return m
  146. }
  147. // withAgentID sets the ID field of the mutation.
  148. func withAgentID(id uint64) agentOption {
  149. return func(m *AgentMutation) {
  150. var (
  151. err error
  152. once sync.Once
  153. value *Agent
  154. )
  155. m.oldValue = func(ctx context.Context) (*Agent, error) {
  156. once.Do(func() {
  157. if m.done {
  158. err = errors.New("querying old values post mutation is not allowed")
  159. } else {
  160. value, err = m.Client().Agent.Get(ctx, id)
  161. }
  162. })
  163. return value, err
  164. }
  165. m.id = &id
  166. }
  167. }
  168. // withAgent sets the old Agent of the mutation.
  169. func withAgent(node *Agent) agentOption {
  170. return func(m *AgentMutation) {
  171. m.oldValue = func(context.Context) (*Agent, error) {
  172. return node, nil
  173. }
  174. m.id = &node.ID
  175. }
  176. }
  177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  178. // executed in a transaction (ent.Tx), a transactional client is returned.
  179. func (m AgentMutation) Client() *Client {
  180. client := &Client{config: m.config}
  181. client.init()
  182. return client
  183. }
  184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  185. // it returns an error otherwise.
  186. func (m AgentMutation) Tx() (*Tx, error) {
  187. if _, ok := m.driver.(*txDriver); !ok {
  188. return nil, errors.New("ent: mutation is not running in a transaction")
  189. }
  190. tx := &Tx{config: m.config}
  191. tx.init()
  192. return tx, nil
  193. }
  194. // SetID sets the value of the id field. Note that this
  195. // operation is only accepted on creation of Agent entities.
  196. func (m *AgentMutation) SetID(id uint64) {
  197. m.id = &id
  198. }
  199. // ID returns the ID value in the mutation. Note that the ID is only available
  200. // if it was provided to the builder or after it was returned from the database.
  201. func (m *AgentMutation) ID() (id uint64, exists bool) {
  202. if m.id == nil {
  203. return
  204. }
  205. return *m.id, true
  206. }
  207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  208. // That means, if the mutation is applied within a transaction with an isolation level such
  209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  210. // or updated by the mutation.
  211. func (m *AgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  212. switch {
  213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  214. id, exists := m.ID()
  215. if exists {
  216. return []uint64{id}, nil
  217. }
  218. fallthrough
  219. case m.op.Is(OpUpdate | OpDelete):
  220. return m.Client().Agent.Query().Where(m.predicates...).IDs(ctx)
  221. default:
  222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  223. }
  224. }
  225. // SetCreatedAt sets the "created_at" field.
  226. func (m *AgentMutation) SetCreatedAt(t time.Time) {
  227. m.created_at = &t
  228. }
  229. // CreatedAt returns the value of the "created_at" field in the mutation.
  230. func (m *AgentMutation) CreatedAt() (r time.Time, exists bool) {
  231. v := m.created_at
  232. if v == nil {
  233. return
  234. }
  235. return *v, true
  236. }
  237. // OldCreatedAt returns the old "created_at" field's value of the Agent entity.
  238. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  240. func (m *AgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  241. if !m.op.Is(OpUpdateOne) {
  242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  243. }
  244. if m.id == nil || m.oldValue == nil {
  245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  246. }
  247. oldValue, err := m.oldValue(ctx)
  248. if err != nil {
  249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  250. }
  251. return oldValue.CreatedAt, nil
  252. }
  253. // ResetCreatedAt resets all changes to the "created_at" field.
  254. func (m *AgentMutation) ResetCreatedAt() {
  255. m.created_at = nil
  256. }
  257. // SetUpdatedAt sets the "updated_at" field.
  258. func (m *AgentMutation) SetUpdatedAt(t time.Time) {
  259. m.updated_at = &t
  260. }
  261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  262. func (m *AgentMutation) UpdatedAt() (r time.Time, exists bool) {
  263. v := m.updated_at
  264. if v == nil {
  265. return
  266. }
  267. return *v, true
  268. }
  269. // OldUpdatedAt returns the old "updated_at" field's value of the Agent entity.
  270. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  272. func (m *AgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  273. if !m.op.Is(OpUpdateOne) {
  274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  275. }
  276. if m.id == nil || m.oldValue == nil {
  277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  278. }
  279. oldValue, err := m.oldValue(ctx)
  280. if err != nil {
  281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  282. }
  283. return oldValue.UpdatedAt, nil
  284. }
  285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  286. func (m *AgentMutation) ResetUpdatedAt() {
  287. m.updated_at = nil
  288. }
  289. // SetDeletedAt sets the "deleted_at" field.
  290. func (m *AgentMutation) SetDeletedAt(t time.Time) {
  291. m.deleted_at = &t
  292. }
  293. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  294. func (m *AgentMutation) DeletedAt() (r time.Time, exists bool) {
  295. v := m.deleted_at
  296. if v == nil {
  297. return
  298. }
  299. return *v, true
  300. }
  301. // OldDeletedAt returns the old "deleted_at" field's value of the Agent entity.
  302. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  303. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  304. func (m *AgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  305. if !m.op.Is(OpUpdateOne) {
  306. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  307. }
  308. if m.id == nil || m.oldValue == nil {
  309. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  310. }
  311. oldValue, err := m.oldValue(ctx)
  312. if err != nil {
  313. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  314. }
  315. return oldValue.DeletedAt, nil
  316. }
  317. // ClearDeletedAt clears the value of the "deleted_at" field.
  318. func (m *AgentMutation) ClearDeletedAt() {
  319. m.deleted_at = nil
  320. m.clearedFields[agent.FieldDeletedAt] = struct{}{}
  321. }
  322. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  323. func (m *AgentMutation) DeletedAtCleared() bool {
  324. _, ok := m.clearedFields[agent.FieldDeletedAt]
  325. return ok
  326. }
  327. // ResetDeletedAt resets all changes to the "deleted_at" field.
  328. func (m *AgentMutation) ResetDeletedAt() {
  329. m.deleted_at = nil
  330. delete(m.clearedFields, agent.FieldDeletedAt)
  331. }
  332. // SetName sets the "name" field.
  333. func (m *AgentMutation) SetName(s string) {
  334. m.name = &s
  335. }
  336. // Name returns the value of the "name" field in the mutation.
  337. func (m *AgentMutation) Name() (r string, exists bool) {
  338. v := m.name
  339. if v == nil {
  340. return
  341. }
  342. return *v, true
  343. }
  344. // OldName returns the old "name" field's value of the Agent entity.
  345. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  346. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  347. func (m *AgentMutation) OldName(ctx context.Context) (v string, err error) {
  348. if !m.op.Is(OpUpdateOne) {
  349. return v, errors.New("OldName is only allowed on UpdateOne operations")
  350. }
  351. if m.id == nil || m.oldValue == nil {
  352. return v, errors.New("OldName requires an ID field in the mutation")
  353. }
  354. oldValue, err := m.oldValue(ctx)
  355. if err != nil {
  356. return v, fmt.Errorf("querying old value for OldName: %w", err)
  357. }
  358. return oldValue.Name, nil
  359. }
  360. // ResetName resets all changes to the "name" field.
  361. func (m *AgentMutation) ResetName() {
  362. m.name = nil
  363. }
  364. // SetRole sets the "role" field.
  365. func (m *AgentMutation) SetRole(s string) {
  366. m.role = &s
  367. }
  368. // Role returns the value of the "role" field in the mutation.
  369. func (m *AgentMutation) Role() (r string, exists bool) {
  370. v := m.role
  371. if v == nil {
  372. return
  373. }
  374. return *v, true
  375. }
  376. // OldRole returns the old "role" field's value of the Agent entity.
  377. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  378. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  379. func (m *AgentMutation) OldRole(ctx context.Context) (v string, err error) {
  380. if !m.op.Is(OpUpdateOne) {
  381. return v, errors.New("OldRole is only allowed on UpdateOne operations")
  382. }
  383. if m.id == nil || m.oldValue == nil {
  384. return v, errors.New("OldRole requires an ID field in the mutation")
  385. }
  386. oldValue, err := m.oldValue(ctx)
  387. if err != nil {
  388. return v, fmt.Errorf("querying old value for OldRole: %w", err)
  389. }
  390. return oldValue.Role, nil
  391. }
  392. // ResetRole resets all changes to the "role" field.
  393. func (m *AgentMutation) ResetRole() {
  394. m.role = nil
  395. }
  396. // SetStatus sets the "status" field.
  397. func (m *AgentMutation) SetStatus(i int) {
  398. m.status = &i
  399. m.addstatus = nil
  400. }
  401. // Status returns the value of the "status" field in the mutation.
  402. func (m *AgentMutation) Status() (r int, exists bool) {
  403. v := m.status
  404. if v == nil {
  405. return
  406. }
  407. return *v, true
  408. }
  409. // OldStatus returns the old "status" field's value of the Agent entity.
  410. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  411. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  412. func (m *AgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  413. if !m.op.Is(OpUpdateOne) {
  414. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  415. }
  416. if m.id == nil || m.oldValue == nil {
  417. return v, errors.New("OldStatus requires an ID field in the mutation")
  418. }
  419. oldValue, err := m.oldValue(ctx)
  420. if err != nil {
  421. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  422. }
  423. return oldValue.Status, nil
  424. }
  425. // AddStatus adds i to the "status" field.
  426. func (m *AgentMutation) AddStatus(i int) {
  427. if m.addstatus != nil {
  428. *m.addstatus += i
  429. } else {
  430. m.addstatus = &i
  431. }
  432. }
  433. // AddedStatus returns the value that was added to the "status" field in this mutation.
  434. func (m *AgentMutation) AddedStatus() (r int, exists bool) {
  435. v := m.addstatus
  436. if v == nil {
  437. return
  438. }
  439. return *v, true
  440. }
  441. // ClearStatus clears the value of the "status" field.
  442. func (m *AgentMutation) ClearStatus() {
  443. m.status = nil
  444. m.addstatus = nil
  445. m.clearedFields[agent.FieldStatus] = struct{}{}
  446. }
  447. // StatusCleared returns if the "status" field was cleared in this mutation.
  448. func (m *AgentMutation) StatusCleared() bool {
  449. _, ok := m.clearedFields[agent.FieldStatus]
  450. return ok
  451. }
  452. // ResetStatus resets all changes to the "status" field.
  453. func (m *AgentMutation) ResetStatus() {
  454. m.status = nil
  455. m.addstatus = nil
  456. delete(m.clearedFields, agent.FieldStatus)
  457. }
  458. // SetBackground sets the "background" field.
  459. func (m *AgentMutation) SetBackground(s string) {
  460. m.background = &s
  461. }
  462. // Background returns the value of the "background" field in the mutation.
  463. func (m *AgentMutation) Background() (r string, exists bool) {
  464. v := m.background
  465. if v == nil {
  466. return
  467. }
  468. return *v, true
  469. }
  470. // OldBackground returns the old "background" field's value of the Agent entity.
  471. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  472. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  473. func (m *AgentMutation) OldBackground(ctx context.Context) (v string, err error) {
  474. if !m.op.Is(OpUpdateOne) {
  475. return v, errors.New("OldBackground is only allowed on UpdateOne operations")
  476. }
  477. if m.id == nil || m.oldValue == nil {
  478. return v, errors.New("OldBackground requires an ID field in the mutation")
  479. }
  480. oldValue, err := m.oldValue(ctx)
  481. if err != nil {
  482. return v, fmt.Errorf("querying old value for OldBackground: %w", err)
  483. }
  484. return oldValue.Background, nil
  485. }
  486. // ClearBackground clears the value of the "background" field.
  487. func (m *AgentMutation) ClearBackground() {
  488. m.background = nil
  489. m.clearedFields[agent.FieldBackground] = struct{}{}
  490. }
  491. // BackgroundCleared returns if the "background" field was cleared in this mutation.
  492. func (m *AgentMutation) BackgroundCleared() bool {
  493. _, ok := m.clearedFields[agent.FieldBackground]
  494. return ok
  495. }
  496. // ResetBackground resets all changes to the "background" field.
  497. func (m *AgentMutation) ResetBackground() {
  498. m.background = nil
  499. delete(m.clearedFields, agent.FieldBackground)
  500. }
  501. // SetExamples sets the "examples" field.
  502. func (m *AgentMutation) SetExamples(s string) {
  503. m.examples = &s
  504. }
  505. // Examples returns the value of the "examples" field in the mutation.
  506. func (m *AgentMutation) Examples() (r string, exists bool) {
  507. v := m.examples
  508. if v == nil {
  509. return
  510. }
  511. return *v, true
  512. }
  513. // OldExamples returns the old "examples" field's value of the Agent entity.
  514. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  515. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  516. func (m *AgentMutation) OldExamples(ctx context.Context) (v string, err error) {
  517. if !m.op.Is(OpUpdateOne) {
  518. return v, errors.New("OldExamples is only allowed on UpdateOne operations")
  519. }
  520. if m.id == nil || m.oldValue == nil {
  521. return v, errors.New("OldExamples requires an ID field in the mutation")
  522. }
  523. oldValue, err := m.oldValue(ctx)
  524. if err != nil {
  525. return v, fmt.Errorf("querying old value for OldExamples: %w", err)
  526. }
  527. return oldValue.Examples, nil
  528. }
  529. // ClearExamples clears the value of the "examples" field.
  530. func (m *AgentMutation) ClearExamples() {
  531. m.examples = nil
  532. m.clearedFields[agent.FieldExamples] = struct{}{}
  533. }
  534. // ExamplesCleared returns if the "examples" field was cleared in this mutation.
  535. func (m *AgentMutation) ExamplesCleared() bool {
  536. _, ok := m.clearedFields[agent.FieldExamples]
  537. return ok
  538. }
  539. // ResetExamples resets all changes to the "examples" field.
  540. func (m *AgentMutation) ResetExamples() {
  541. m.examples = nil
  542. delete(m.clearedFields, agent.FieldExamples)
  543. }
  544. // SetOrganizationID sets the "organization_id" field.
  545. func (m *AgentMutation) SetOrganizationID(u uint64) {
  546. m.organization_id = &u
  547. m.addorganization_id = nil
  548. }
  549. // OrganizationID returns the value of the "organization_id" field in the mutation.
  550. func (m *AgentMutation) OrganizationID() (r uint64, exists bool) {
  551. v := m.organization_id
  552. if v == nil {
  553. return
  554. }
  555. return *v, true
  556. }
  557. // OldOrganizationID returns the old "organization_id" field's value of the Agent entity.
  558. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  559. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  560. func (m *AgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  561. if !m.op.Is(OpUpdateOne) {
  562. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  563. }
  564. if m.id == nil || m.oldValue == nil {
  565. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  566. }
  567. oldValue, err := m.oldValue(ctx)
  568. if err != nil {
  569. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  570. }
  571. return oldValue.OrganizationID, nil
  572. }
  573. // AddOrganizationID adds u to the "organization_id" field.
  574. func (m *AgentMutation) AddOrganizationID(u int64) {
  575. if m.addorganization_id != nil {
  576. *m.addorganization_id += u
  577. } else {
  578. m.addorganization_id = &u
  579. }
  580. }
  581. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  582. func (m *AgentMutation) AddedOrganizationID() (r int64, exists bool) {
  583. v := m.addorganization_id
  584. if v == nil {
  585. return
  586. }
  587. return *v, true
  588. }
  589. // ResetOrganizationID resets all changes to the "organization_id" field.
  590. func (m *AgentMutation) ResetOrganizationID() {
  591. m.organization_id = nil
  592. m.addorganization_id = nil
  593. }
  594. // SetDatasetID sets the "dataset_id" field.
  595. func (m *AgentMutation) SetDatasetID(s string) {
  596. m.dataset_id = &s
  597. }
  598. // DatasetID returns the value of the "dataset_id" field in the mutation.
  599. func (m *AgentMutation) DatasetID() (r string, exists bool) {
  600. v := m.dataset_id
  601. if v == nil {
  602. return
  603. }
  604. return *v, true
  605. }
  606. // OldDatasetID returns the old "dataset_id" field's value of the Agent entity.
  607. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  609. func (m *AgentMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  610. if !m.op.Is(OpUpdateOne) {
  611. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  612. }
  613. if m.id == nil || m.oldValue == nil {
  614. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  615. }
  616. oldValue, err := m.oldValue(ctx)
  617. if err != nil {
  618. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  619. }
  620. return oldValue.DatasetID, nil
  621. }
  622. // ResetDatasetID resets all changes to the "dataset_id" field.
  623. func (m *AgentMutation) ResetDatasetID() {
  624. m.dataset_id = nil
  625. }
  626. // SetCollectionID sets the "collection_id" field.
  627. func (m *AgentMutation) SetCollectionID(s string) {
  628. m.collection_id = &s
  629. }
  630. // CollectionID returns the value of the "collection_id" field in the mutation.
  631. func (m *AgentMutation) CollectionID() (r string, exists bool) {
  632. v := m.collection_id
  633. if v == nil {
  634. return
  635. }
  636. return *v, true
  637. }
  638. // OldCollectionID returns the old "collection_id" field's value of the Agent entity.
  639. // If the Agent object wasn't provided to the builder, the object is fetched from the database.
  640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  641. func (m *AgentMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  642. if !m.op.Is(OpUpdateOne) {
  643. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  644. }
  645. if m.id == nil || m.oldValue == nil {
  646. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  647. }
  648. oldValue, err := m.oldValue(ctx)
  649. if err != nil {
  650. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  651. }
  652. return oldValue.CollectionID, nil
  653. }
  654. // ResetCollectionID resets all changes to the "collection_id" field.
  655. func (m *AgentMutation) ResetCollectionID() {
  656. m.collection_id = nil
  657. }
  658. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  659. func (m *AgentMutation) AddWxAgentIDs(ids ...uint64) {
  660. if m.wx_agent == nil {
  661. m.wx_agent = make(map[uint64]struct{})
  662. }
  663. for i := range ids {
  664. m.wx_agent[ids[i]] = struct{}{}
  665. }
  666. }
  667. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  668. func (m *AgentMutation) ClearWxAgent() {
  669. m.clearedwx_agent = true
  670. }
  671. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  672. func (m *AgentMutation) WxAgentCleared() bool {
  673. return m.clearedwx_agent
  674. }
  675. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  676. func (m *AgentMutation) RemoveWxAgentIDs(ids ...uint64) {
  677. if m.removedwx_agent == nil {
  678. m.removedwx_agent = make(map[uint64]struct{})
  679. }
  680. for i := range ids {
  681. delete(m.wx_agent, ids[i])
  682. m.removedwx_agent[ids[i]] = struct{}{}
  683. }
  684. }
  685. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  686. func (m *AgentMutation) RemovedWxAgentIDs() (ids []uint64) {
  687. for id := range m.removedwx_agent {
  688. ids = append(ids, id)
  689. }
  690. return
  691. }
  692. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  693. func (m *AgentMutation) WxAgentIDs() (ids []uint64) {
  694. for id := range m.wx_agent {
  695. ids = append(ids, id)
  696. }
  697. return
  698. }
  699. // ResetWxAgent resets all changes to the "wx_agent" edge.
  700. func (m *AgentMutation) ResetWxAgent() {
  701. m.wx_agent = nil
  702. m.clearedwx_agent = false
  703. m.removedwx_agent = nil
  704. }
  705. // AddTokenAgentIDs adds the "token_agent" edge to the Token entity by ids.
  706. func (m *AgentMutation) AddTokenAgentIDs(ids ...uint64) {
  707. if m.token_agent == nil {
  708. m.token_agent = make(map[uint64]struct{})
  709. }
  710. for i := range ids {
  711. m.token_agent[ids[i]] = struct{}{}
  712. }
  713. }
  714. // ClearTokenAgent clears the "token_agent" edge to the Token entity.
  715. func (m *AgentMutation) ClearTokenAgent() {
  716. m.clearedtoken_agent = true
  717. }
  718. // TokenAgentCleared reports if the "token_agent" edge to the Token entity was cleared.
  719. func (m *AgentMutation) TokenAgentCleared() bool {
  720. return m.clearedtoken_agent
  721. }
  722. // RemoveTokenAgentIDs removes the "token_agent" edge to the Token entity by IDs.
  723. func (m *AgentMutation) RemoveTokenAgentIDs(ids ...uint64) {
  724. if m.removedtoken_agent == nil {
  725. m.removedtoken_agent = make(map[uint64]struct{})
  726. }
  727. for i := range ids {
  728. delete(m.token_agent, ids[i])
  729. m.removedtoken_agent[ids[i]] = struct{}{}
  730. }
  731. }
  732. // RemovedTokenAgent returns the removed IDs of the "token_agent" edge to the Token entity.
  733. func (m *AgentMutation) RemovedTokenAgentIDs() (ids []uint64) {
  734. for id := range m.removedtoken_agent {
  735. ids = append(ids, id)
  736. }
  737. return
  738. }
  739. // TokenAgentIDs returns the "token_agent" edge IDs in the mutation.
  740. func (m *AgentMutation) TokenAgentIDs() (ids []uint64) {
  741. for id := range m.token_agent {
  742. ids = append(ids, id)
  743. }
  744. return
  745. }
  746. // ResetTokenAgent resets all changes to the "token_agent" edge.
  747. func (m *AgentMutation) ResetTokenAgent() {
  748. m.token_agent = nil
  749. m.clearedtoken_agent = false
  750. m.removedtoken_agent = nil
  751. }
  752. // Where appends a list predicates to the AgentMutation builder.
  753. func (m *AgentMutation) Where(ps ...predicate.Agent) {
  754. m.predicates = append(m.predicates, ps...)
  755. }
  756. // WhereP appends storage-level predicates to the AgentMutation builder. Using this method,
  757. // users can use type-assertion to append predicates that do not depend on any generated package.
  758. func (m *AgentMutation) WhereP(ps ...func(*sql.Selector)) {
  759. p := make([]predicate.Agent, len(ps))
  760. for i := range ps {
  761. p[i] = ps[i]
  762. }
  763. m.Where(p...)
  764. }
  765. // Op returns the operation name.
  766. func (m *AgentMutation) Op() Op {
  767. return m.op
  768. }
  769. // SetOp allows setting the mutation operation.
  770. func (m *AgentMutation) SetOp(op Op) {
  771. m.op = op
  772. }
  773. // Type returns the node type of this mutation (Agent).
  774. func (m *AgentMutation) Type() string {
  775. return m.typ
  776. }
  777. // Fields returns all fields that were changed during this mutation. Note that in
  778. // order to get all numeric fields that were incremented/decremented, call
  779. // AddedFields().
  780. func (m *AgentMutation) Fields() []string {
  781. fields := make([]string, 0, 11)
  782. if m.created_at != nil {
  783. fields = append(fields, agent.FieldCreatedAt)
  784. }
  785. if m.updated_at != nil {
  786. fields = append(fields, agent.FieldUpdatedAt)
  787. }
  788. if m.deleted_at != nil {
  789. fields = append(fields, agent.FieldDeletedAt)
  790. }
  791. if m.name != nil {
  792. fields = append(fields, agent.FieldName)
  793. }
  794. if m.role != nil {
  795. fields = append(fields, agent.FieldRole)
  796. }
  797. if m.status != nil {
  798. fields = append(fields, agent.FieldStatus)
  799. }
  800. if m.background != nil {
  801. fields = append(fields, agent.FieldBackground)
  802. }
  803. if m.examples != nil {
  804. fields = append(fields, agent.FieldExamples)
  805. }
  806. if m.organization_id != nil {
  807. fields = append(fields, agent.FieldOrganizationID)
  808. }
  809. if m.dataset_id != nil {
  810. fields = append(fields, agent.FieldDatasetID)
  811. }
  812. if m.collection_id != nil {
  813. fields = append(fields, agent.FieldCollectionID)
  814. }
  815. return fields
  816. }
  817. // Field returns the value of a field with the given name. The second boolean
  818. // return value indicates that this field was not set, or was not defined in the
  819. // schema.
  820. func (m *AgentMutation) Field(name string) (ent.Value, bool) {
  821. switch name {
  822. case agent.FieldCreatedAt:
  823. return m.CreatedAt()
  824. case agent.FieldUpdatedAt:
  825. return m.UpdatedAt()
  826. case agent.FieldDeletedAt:
  827. return m.DeletedAt()
  828. case agent.FieldName:
  829. return m.Name()
  830. case agent.FieldRole:
  831. return m.Role()
  832. case agent.FieldStatus:
  833. return m.Status()
  834. case agent.FieldBackground:
  835. return m.Background()
  836. case agent.FieldExamples:
  837. return m.Examples()
  838. case agent.FieldOrganizationID:
  839. return m.OrganizationID()
  840. case agent.FieldDatasetID:
  841. return m.DatasetID()
  842. case agent.FieldCollectionID:
  843. return m.CollectionID()
  844. }
  845. return nil, false
  846. }
  847. // OldField returns the old value of the field from the database. An error is
  848. // returned if the mutation operation is not UpdateOne, or the query to the
  849. // database failed.
  850. func (m *AgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  851. switch name {
  852. case agent.FieldCreatedAt:
  853. return m.OldCreatedAt(ctx)
  854. case agent.FieldUpdatedAt:
  855. return m.OldUpdatedAt(ctx)
  856. case agent.FieldDeletedAt:
  857. return m.OldDeletedAt(ctx)
  858. case agent.FieldName:
  859. return m.OldName(ctx)
  860. case agent.FieldRole:
  861. return m.OldRole(ctx)
  862. case agent.FieldStatus:
  863. return m.OldStatus(ctx)
  864. case agent.FieldBackground:
  865. return m.OldBackground(ctx)
  866. case agent.FieldExamples:
  867. return m.OldExamples(ctx)
  868. case agent.FieldOrganizationID:
  869. return m.OldOrganizationID(ctx)
  870. case agent.FieldDatasetID:
  871. return m.OldDatasetID(ctx)
  872. case agent.FieldCollectionID:
  873. return m.OldCollectionID(ctx)
  874. }
  875. return nil, fmt.Errorf("unknown Agent field %s", name)
  876. }
  877. // SetField sets the value of a field with the given name. It returns an error if
  878. // the field is not defined in the schema, or if the type mismatched the field
  879. // type.
  880. func (m *AgentMutation) SetField(name string, value ent.Value) error {
  881. switch name {
  882. case agent.FieldCreatedAt:
  883. v, ok := value.(time.Time)
  884. if !ok {
  885. return fmt.Errorf("unexpected type %T for field %s", value, name)
  886. }
  887. m.SetCreatedAt(v)
  888. return nil
  889. case agent.FieldUpdatedAt:
  890. v, ok := value.(time.Time)
  891. if !ok {
  892. return fmt.Errorf("unexpected type %T for field %s", value, name)
  893. }
  894. m.SetUpdatedAt(v)
  895. return nil
  896. case agent.FieldDeletedAt:
  897. v, ok := value.(time.Time)
  898. if !ok {
  899. return fmt.Errorf("unexpected type %T for field %s", value, name)
  900. }
  901. m.SetDeletedAt(v)
  902. return nil
  903. case agent.FieldName:
  904. v, ok := value.(string)
  905. if !ok {
  906. return fmt.Errorf("unexpected type %T for field %s", value, name)
  907. }
  908. m.SetName(v)
  909. return nil
  910. case agent.FieldRole:
  911. v, ok := value.(string)
  912. if !ok {
  913. return fmt.Errorf("unexpected type %T for field %s", value, name)
  914. }
  915. m.SetRole(v)
  916. return nil
  917. case agent.FieldStatus:
  918. v, ok := value.(int)
  919. if !ok {
  920. return fmt.Errorf("unexpected type %T for field %s", value, name)
  921. }
  922. m.SetStatus(v)
  923. return nil
  924. case agent.FieldBackground:
  925. v, ok := value.(string)
  926. if !ok {
  927. return fmt.Errorf("unexpected type %T for field %s", value, name)
  928. }
  929. m.SetBackground(v)
  930. return nil
  931. case agent.FieldExamples:
  932. v, ok := value.(string)
  933. if !ok {
  934. return fmt.Errorf("unexpected type %T for field %s", value, name)
  935. }
  936. m.SetExamples(v)
  937. return nil
  938. case agent.FieldOrganizationID:
  939. v, ok := value.(uint64)
  940. if !ok {
  941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  942. }
  943. m.SetOrganizationID(v)
  944. return nil
  945. case agent.FieldDatasetID:
  946. v, ok := value.(string)
  947. if !ok {
  948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  949. }
  950. m.SetDatasetID(v)
  951. return nil
  952. case agent.FieldCollectionID:
  953. v, ok := value.(string)
  954. if !ok {
  955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  956. }
  957. m.SetCollectionID(v)
  958. return nil
  959. }
  960. return fmt.Errorf("unknown Agent field %s", name)
  961. }
  962. // AddedFields returns all numeric fields that were incremented/decremented during
  963. // this mutation.
  964. func (m *AgentMutation) AddedFields() []string {
  965. var fields []string
  966. if m.addstatus != nil {
  967. fields = append(fields, agent.FieldStatus)
  968. }
  969. if m.addorganization_id != nil {
  970. fields = append(fields, agent.FieldOrganizationID)
  971. }
  972. return fields
  973. }
  974. // AddedField returns the numeric value that was incremented/decremented on a field
  975. // with the given name. The second boolean return value indicates that this field
  976. // was not set, or was not defined in the schema.
  977. func (m *AgentMutation) AddedField(name string) (ent.Value, bool) {
  978. switch name {
  979. case agent.FieldStatus:
  980. return m.AddedStatus()
  981. case agent.FieldOrganizationID:
  982. return m.AddedOrganizationID()
  983. }
  984. return nil, false
  985. }
  986. // AddField adds the value to the field with the given name. It returns an error if
  987. // the field is not defined in the schema, or if the type mismatched the field
  988. // type.
  989. func (m *AgentMutation) AddField(name string, value ent.Value) error {
  990. switch name {
  991. case agent.FieldStatus:
  992. v, ok := value.(int)
  993. if !ok {
  994. return fmt.Errorf("unexpected type %T for field %s", value, name)
  995. }
  996. m.AddStatus(v)
  997. return nil
  998. case agent.FieldOrganizationID:
  999. v, ok := value.(int64)
  1000. if !ok {
  1001. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1002. }
  1003. m.AddOrganizationID(v)
  1004. return nil
  1005. }
  1006. return fmt.Errorf("unknown Agent numeric field %s", name)
  1007. }
  1008. // ClearedFields returns all nullable fields that were cleared during this
  1009. // mutation.
  1010. func (m *AgentMutation) ClearedFields() []string {
  1011. var fields []string
  1012. if m.FieldCleared(agent.FieldDeletedAt) {
  1013. fields = append(fields, agent.FieldDeletedAt)
  1014. }
  1015. if m.FieldCleared(agent.FieldStatus) {
  1016. fields = append(fields, agent.FieldStatus)
  1017. }
  1018. if m.FieldCleared(agent.FieldBackground) {
  1019. fields = append(fields, agent.FieldBackground)
  1020. }
  1021. if m.FieldCleared(agent.FieldExamples) {
  1022. fields = append(fields, agent.FieldExamples)
  1023. }
  1024. return fields
  1025. }
  1026. // FieldCleared returns a boolean indicating if a field with the given name was
  1027. // cleared in this mutation.
  1028. func (m *AgentMutation) FieldCleared(name string) bool {
  1029. _, ok := m.clearedFields[name]
  1030. return ok
  1031. }
  1032. // ClearField clears the value of the field with the given name. It returns an
  1033. // error if the field is not defined in the schema.
  1034. func (m *AgentMutation) ClearField(name string) error {
  1035. switch name {
  1036. case agent.FieldDeletedAt:
  1037. m.ClearDeletedAt()
  1038. return nil
  1039. case agent.FieldStatus:
  1040. m.ClearStatus()
  1041. return nil
  1042. case agent.FieldBackground:
  1043. m.ClearBackground()
  1044. return nil
  1045. case agent.FieldExamples:
  1046. m.ClearExamples()
  1047. return nil
  1048. }
  1049. return fmt.Errorf("unknown Agent nullable field %s", name)
  1050. }
  1051. // ResetField resets all changes in the mutation for the field with the given name.
  1052. // It returns an error if the field is not defined in the schema.
  1053. func (m *AgentMutation) ResetField(name string) error {
  1054. switch name {
  1055. case agent.FieldCreatedAt:
  1056. m.ResetCreatedAt()
  1057. return nil
  1058. case agent.FieldUpdatedAt:
  1059. m.ResetUpdatedAt()
  1060. return nil
  1061. case agent.FieldDeletedAt:
  1062. m.ResetDeletedAt()
  1063. return nil
  1064. case agent.FieldName:
  1065. m.ResetName()
  1066. return nil
  1067. case agent.FieldRole:
  1068. m.ResetRole()
  1069. return nil
  1070. case agent.FieldStatus:
  1071. m.ResetStatus()
  1072. return nil
  1073. case agent.FieldBackground:
  1074. m.ResetBackground()
  1075. return nil
  1076. case agent.FieldExamples:
  1077. m.ResetExamples()
  1078. return nil
  1079. case agent.FieldOrganizationID:
  1080. m.ResetOrganizationID()
  1081. return nil
  1082. case agent.FieldDatasetID:
  1083. m.ResetDatasetID()
  1084. return nil
  1085. case agent.FieldCollectionID:
  1086. m.ResetCollectionID()
  1087. return nil
  1088. }
  1089. return fmt.Errorf("unknown Agent field %s", name)
  1090. }
  1091. // AddedEdges returns all edge names that were set/added in this mutation.
  1092. func (m *AgentMutation) AddedEdges() []string {
  1093. edges := make([]string, 0, 2)
  1094. if m.wx_agent != nil {
  1095. edges = append(edges, agent.EdgeWxAgent)
  1096. }
  1097. if m.token_agent != nil {
  1098. edges = append(edges, agent.EdgeTokenAgent)
  1099. }
  1100. return edges
  1101. }
  1102. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  1103. // name in this mutation.
  1104. func (m *AgentMutation) AddedIDs(name string) []ent.Value {
  1105. switch name {
  1106. case agent.EdgeWxAgent:
  1107. ids := make([]ent.Value, 0, len(m.wx_agent))
  1108. for id := range m.wx_agent {
  1109. ids = append(ids, id)
  1110. }
  1111. return ids
  1112. case agent.EdgeTokenAgent:
  1113. ids := make([]ent.Value, 0, len(m.token_agent))
  1114. for id := range m.token_agent {
  1115. ids = append(ids, id)
  1116. }
  1117. return ids
  1118. }
  1119. return nil
  1120. }
  1121. // RemovedEdges returns all edge names that were removed in this mutation.
  1122. func (m *AgentMutation) RemovedEdges() []string {
  1123. edges := make([]string, 0, 2)
  1124. if m.removedwx_agent != nil {
  1125. edges = append(edges, agent.EdgeWxAgent)
  1126. }
  1127. if m.removedtoken_agent != nil {
  1128. edges = append(edges, agent.EdgeTokenAgent)
  1129. }
  1130. return edges
  1131. }
  1132. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  1133. // the given name in this mutation.
  1134. func (m *AgentMutation) RemovedIDs(name string) []ent.Value {
  1135. switch name {
  1136. case agent.EdgeWxAgent:
  1137. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  1138. for id := range m.removedwx_agent {
  1139. ids = append(ids, id)
  1140. }
  1141. return ids
  1142. case agent.EdgeTokenAgent:
  1143. ids := make([]ent.Value, 0, len(m.removedtoken_agent))
  1144. for id := range m.removedtoken_agent {
  1145. ids = append(ids, id)
  1146. }
  1147. return ids
  1148. }
  1149. return nil
  1150. }
  1151. // ClearedEdges returns all edge names that were cleared in this mutation.
  1152. func (m *AgentMutation) ClearedEdges() []string {
  1153. edges := make([]string, 0, 2)
  1154. if m.clearedwx_agent {
  1155. edges = append(edges, agent.EdgeWxAgent)
  1156. }
  1157. if m.clearedtoken_agent {
  1158. edges = append(edges, agent.EdgeTokenAgent)
  1159. }
  1160. return edges
  1161. }
  1162. // EdgeCleared returns a boolean which indicates if the edge with the given name
  1163. // was cleared in this mutation.
  1164. func (m *AgentMutation) EdgeCleared(name string) bool {
  1165. switch name {
  1166. case agent.EdgeWxAgent:
  1167. return m.clearedwx_agent
  1168. case agent.EdgeTokenAgent:
  1169. return m.clearedtoken_agent
  1170. }
  1171. return false
  1172. }
  1173. // ClearEdge clears the value of the edge with the given name. It returns an error
  1174. // if that edge is not defined in the schema.
  1175. func (m *AgentMutation) ClearEdge(name string) error {
  1176. switch name {
  1177. }
  1178. return fmt.Errorf("unknown Agent unique edge %s", name)
  1179. }
  1180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  1181. // It returns an error if the edge is not defined in the schema.
  1182. func (m *AgentMutation) ResetEdge(name string) error {
  1183. switch name {
  1184. case agent.EdgeWxAgent:
  1185. m.ResetWxAgent()
  1186. return nil
  1187. case agent.EdgeTokenAgent:
  1188. m.ResetTokenAgent()
  1189. return nil
  1190. }
  1191. return fmt.Errorf("unknown Agent edge %s", name)
  1192. }
  1193. // AgentBaseMutation represents an operation that mutates the AgentBase nodes in the graph.
  1194. type AgentBaseMutation struct {
  1195. config
  1196. op Op
  1197. typ string
  1198. id *string
  1199. q *string
  1200. a *string
  1201. chunk_index *uint64
  1202. addchunk_index *int64
  1203. indexes *[]string
  1204. appendindexes []string
  1205. dataset_id *string
  1206. collection_id *string
  1207. source_name *string
  1208. can_write *[]bool
  1209. appendcan_write []bool
  1210. is_owner *[]bool
  1211. appendis_owner []bool
  1212. clearedFields map[string]struct{}
  1213. wx_agent map[uint64]struct{}
  1214. removedwx_agent map[uint64]struct{}
  1215. clearedwx_agent bool
  1216. done bool
  1217. oldValue func(context.Context) (*AgentBase, error)
  1218. predicates []predicate.AgentBase
  1219. }
  1220. var _ ent.Mutation = (*AgentBaseMutation)(nil)
  1221. // agentbaseOption allows management of the mutation configuration using functional options.
  1222. type agentbaseOption func(*AgentBaseMutation)
  1223. // newAgentBaseMutation creates new mutation for the AgentBase entity.
  1224. func newAgentBaseMutation(c config, op Op, opts ...agentbaseOption) *AgentBaseMutation {
  1225. m := &AgentBaseMutation{
  1226. config: c,
  1227. op: op,
  1228. typ: TypeAgentBase,
  1229. clearedFields: make(map[string]struct{}),
  1230. }
  1231. for _, opt := range opts {
  1232. opt(m)
  1233. }
  1234. return m
  1235. }
  1236. // withAgentBaseID sets the ID field of the mutation.
  1237. func withAgentBaseID(id string) agentbaseOption {
  1238. return func(m *AgentBaseMutation) {
  1239. var (
  1240. err error
  1241. once sync.Once
  1242. value *AgentBase
  1243. )
  1244. m.oldValue = func(ctx context.Context) (*AgentBase, error) {
  1245. once.Do(func() {
  1246. if m.done {
  1247. err = errors.New("querying old values post mutation is not allowed")
  1248. } else {
  1249. value, err = m.Client().AgentBase.Get(ctx, id)
  1250. }
  1251. })
  1252. return value, err
  1253. }
  1254. m.id = &id
  1255. }
  1256. }
  1257. // withAgentBase sets the old AgentBase of the mutation.
  1258. func withAgentBase(node *AgentBase) agentbaseOption {
  1259. return func(m *AgentBaseMutation) {
  1260. m.oldValue = func(context.Context) (*AgentBase, error) {
  1261. return node, nil
  1262. }
  1263. m.id = &node.ID
  1264. }
  1265. }
  1266. // Client returns a new `ent.Client` from the mutation. If the mutation was
  1267. // executed in a transaction (ent.Tx), a transactional client is returned.
  1268. func (m AgentBaseMutation) Client() *Client {
  1269. client := &Client{config: m.config}
  1270. client.init()
  1271. return client
  1272. }
  1273. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  1274. // it returns an error otherwise.
  1275. func (m AgentBaseMutation) Tx() (*Tx, error) {
  1276. if _, ok := m.driver.(*txDriver); !ok {
  1277. return nil, errors.New("ent: mutation is not running in a transaction")
  1278. }
  1279. tx := &Tx{config: m.config}
  1280. tx.init()
  1281. return tx, nil
  1282. }
  1283. // SetID sets the value of the id field. Note that this
  1284. // operation is only accepted on creation of AgentBase entities.
  1285. func (m *AgentBaseMutation) SetID(id string) {
  1286. m.id = &id
  1287. }
  1288. // ID returns the ID value in the mutation. Note that the ID is only available
  1289. // if it was provided to the builder or after it was returned from the database.
  1290. func (m *AgentBaseMutation) ID() (id string, exists bool) {
  1291. if m.id == nil {
  1292. return
  1293. }
  1294. return *m.id, true
  1295. }
  1296. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  1297. // That means, if the mutation is applied within a transaction with an isolation level such
  1298. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  1299. // or updated by the mutation.
  1300. func (m *AgentBaseMutation) IDs(ctx context.Context) ([]string, error) {
  1301. switch {
  1302. case m.op.Is(OpUpdateOne | OpDeleteOne):
  1303. id, exists := m.ID()
  1304. if exists {
  1305. return []string{id}, nil
  1306. }
  1307. fallthrough
  1308. case m.op.Is(OpUpdate | OpDelete):
  1309. return m.Client().AgentBase.Query().Where(m.predicates...).IDs(ctx)
  1310. default:
  1311. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  1312. }
  1313. }
  1314. // SetQ sets the "q" field.
  1315. func (m *AgentBaseMutation) SetQ(s string) {
  1316. m.q = &s
  1317. }
  1318. // Q returns the value of the "q" field in the mutation.
  1319. func (m *AgentBaseMutation) Q() (r string, exists bool) {
  1320. v := m.q
  1321. if v == nil {
  1322. return
  1323. }
  1324. return *v, true
  1325. }
  1326. // OldQ returns the old "q" field's value of the AgentBase entity.
  1327. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1329. func (m *AgentBaseMutation) OldQ(ctx context.Context) (v string, err error) {
  1330. if !m.op.Is(OpUpdateOne) {
  1331. return v, errors.New("OldQ is only allowed on UpdateOne operations")
  1332. }
  1333. if m.id == nil || m.oldValue == nil {
  1334. return v, errors.New("OldQ requires an ID field in the mutation")
  1335. }
  1336. oldValue, err := m.oldValue(ctx)
  1337. if err != nil {
  1338. return v, fmt.Errorf("querying old value for OldQ: %w", err)
  1339. }
  1340. return oldValue.Q, nil
  1341. }
  1342. // ClearQ clears the value of the "q" field.
  1343. func (m *AgentBaseMutation) ClearQ() {
  1344. m.q = nil
  1345. m.clearedFields[agentbase.FieldQ] = struct{}{}
  1346. }
  1347. // QCleared returns if the "q" field was cleared in this mutation.
  1348. func (m *AgentBaseMutation) QCleared() bool {
  1349. _, ok := m.clearedFields[agentbase.FieldQ]
  1350. return ok
  1351. }
  1352. // ResetQ resets all changes to the "q" field.
  1353. func (m *AgentBaseMutation) ResetQ() {
  1354. m.q = nil
  1355. delete(m.clearedFields, agentbase.FieldQ)
  1356. }
  1357. // SetA sets the "a" field.
  1358. func (m *AgentBaseMutation) SetA(s string) {
  1359. m.a = &s
  1360. }
  1361. // A returns the value of the "a" field in the mutation.
  1362. func (m *AgentBaseMutation) A() (r string, exists bool) {
  1363. v := m.a
  1364. if v == nil {
  1365. return
  1366. }
  1367. return *v, true
  1368. }
  1369. // OldA returns the old "a" field's value of the AgentBase entity.
  1370. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1372. func (m *AgentBaseMutation) OldA(ctx context.Context) (v string, err error) {
  1373. if !m.op.Is(OpUpdateOne) {
  1374. return v, errors.New("OldA is only allowed on UpdateOne operations")
  1375. }
  1376. if m.id == nil || m.oldValue == nil {
  1377. return v, errors.New("OldA requires an ID field in the mutation")
  1378. }
  1379. oldValue, err := m.oldValue(ctx)
  1380. if err != nil {
  1381. return v, fmt.Errorf("querying old value for OldA: %w", err)
  1382. }
  1383. return oldValue.A, nil
  1384. }
  1385. // ClearA clears the value of the "a" field.
  1386. func (m *AgentBaseMutation) ClearA() {
  1387. m.a = nil
  1388. m.clearedFields[agentbase.FieldA] = struct{}{}
  1389. }
  1390. // ACleared returns if the "a" field was cleared in this mutation.
  1391. func (m *AgentBaseMutation) ACleared() bool {
  1392. _, ok := m.clearedFields[agentbase.FieldA]
  1393. return ok
  1394. }
  1395. // ResetA resets all changes to the "a" field.
  1396. func (m *AgentBaseMutation) ResetA() {
  1397. m.a = nil
  1398. delete(m.clearedFields, agentbase.FieldA)
  1399. }
  1400. // SetChunkIndex sets the "chunk_index" field.
  1401. func (m *AgentBaseMutation) SetChunkIndex(u uint64) {
  1402. m.chunk_index = &u
  1403. m.addchunk_index = nil
  1404. }
  1405. // ChunkIndex returns the value of the "chunk_index" field in the mutation.
  1406. func (m *AgentBaseMutation) ChunkIndex() (r uint64, exists bool) {
  1407. v := m.chunk_index
  1408. if v == nil {
  1409. return
  1410. }
  1411. return *v, true
  1412. }
  1413. // OldChunkIndex returns the old "chunk_index" field's value of the AgentBase entity.
  1414. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1416. func (m *AgentBaseMutation) OldChunkIndex(ctx context.Context) (v uint64, err error) {
  1417. if !m.op.Is(OpUpdateOne) {
  1418. return v, errors.New("OldChunkIndex is only allowed on UpdateOne operations")
  1419. }
  1420. if m.id == nil || m.oldValue == nil {
  1421. return v, errors.New("OldChunkIndex requires an ID field in the mutation")
  1422. }
  1423. oldValue, err := m.oldValue(ctx)
  1424. if err != nil {
  1425. return v, fmt.Errorf("querying old value for OldChunkIndex: %w", err)
  1426. }
  1427. return oldValue.ChunkIndex, nil
  1428. }
  1429. // AddChunkIndex adds u to the "chunk_index" field.
  1430. func (m *AgentBaseMutation) AddChunkIndex(u int64) {
  1431. if m.addchunk_index != nil {
  1432. *m.addchunk_index += u
  1433. } else {
  1434. m.addchunk_index = &u
  1435. }
  1436. }
  1437. // AddedChunkIndex returns the value that was added to the "chunk_index" field in this mutation.
  1438. func (m *AgentBaseMutation) AddedChunkIndex() (r int64, exists bool) {
  1439. v := m.addchunk_index
  1440. if v == nil {
  1441. return
  1442. }
  1443. return *v, true
  1444. }
  1445. // ResetChunkIndex resets all changes to the "chunk_index" field.
  1446. func (m *AgentBaseMutation) ResetChunkIndex() {
  1447. m.chunk_index = nil
  1448. m.addchunk_index = nil
  1449. }
  1450. // SetIndexes sets the "indexes" field.
  1451. func (m *AgentBaseMutation) SetIndexes(s []string) {
  1452. m.indexes = &s
  1453. m.appendindexes = nil
  1454. }
  1455. // Indexes returns the value of the "indexes" field in the mutation.
  1456. func (m *AgentBaseMutation) Indexes() (r []string, exists bool) {
  1457. v := m.indexes
  1458. if v == nil {
  1459. return
  1460. }
  1461. return *v, true
  1462. }
  1463. // OldIndexes returns the old "indexes" field's value of the AgentBase entity.
  1464. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1465. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1466. func (m *AgentBaseMutation) OldIndexes(ctx context.Context) (v []string, err error) {
  1467. if !m.op.Is(OpUpdateOne) {
  1468. return v, errors.New("OldIndexes is only allowed on UpdateOne operations")
  1469. }
  1470. if m.id == nil || m.oldValue == nil {
  1471. return v, errors.New("OldIndexes requires an ID field in the mutation")
  1472. }
  1473. oldValue, err := m.oldValue(ctx)
  1474. if err != nil {
  1475. return v, fmt.Errorf("querying old value for OldIndexes: %w", err)
  1476. }
  1477. return oldValue.Indexes, nil
  1478. }
  1479. // AppendIndexes adds s to the "indexes" field.
  1480. func (m *AgentBaseMutation) AppendIndexes(s []string) {
  1481. m.appendindexes = append(m.appendindexes, s...)
  1482. }
  1483. // AppendedIndexes returns the list of values that were appended to the "indexes" field in this mutation.
  1484. func (m *AgentBaseMutation) AppendedIndexes() ([]string, bool) {
  1485. if len(m.appendindexes) == 0 {
  1486. return nil, false
  1487. }
  1488. return m.appendindexes, true
  1489. }
  1490. // ClearIndexes clears the value of the "indexes" field.
  1491. func (m *AgentBaseMutation) ClearIndexes() {
  1492. m.indexes = nil
  1493. m.appendindexes = nil
  1494. m.clearedFields[agentbase.FieldIndexes] = struct{}{}
  1495. }
  1496. // IndexesCleared returns if the "indexes" field was cleared in this mutation.
  1497. func (m *AgentBaseMutation) IndexesCleared() bool {
  1498. _, ok := m.clearedFields[agentbase.FieldIndexes]
  1499. return ok
  1500. }
  1501. // ResetIndexes resets all changes to the "indexes" field.
  1502. func (m *AgentBaseMutation) ResetIndexes() {
  1503. m.indexes = nil
  1504. m.appendindexes = nil
  1505. delete(m.clearedFields, agentbase.FieldIndexes)
  1506. }
  1507. // SetDatasetID sets the "dataset_id" field.
  1508. func (m *AgentBaseMutation) SetDatasetID(s string) {
  1509. m.dataset_id = &s
  1510. }
  1511. // DatasetID returns the value of the "dataset_id" field in the mutation.
  1512. func (m *AgentBaseMutation) DatasetID() (r string, exists bool) {
  1513. v := m.dataset_id
  1514. if v == nil {
  1515. return
  1516. }
  1517. return *v, true
  1518. }
  1519. // OldDatasetID returns the old "dataset_id" field's value of the AgentBase entity.
  1520. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1522. func (m *AgentBaseMutation) OldDatasetID(ctx context.Context) (v string, err error) {
  1523. if !m.op.Is(OpUpdateOne) {
  1524. return v, errors.New("OldDatasetID is only allowed on UpdateOne operations")
  1525. }
  1526. if m.id == nil || m.oldValue == nil {
  1527. return v, errors.New("OldDatasetID requires an ID field in the mutation")
  1528. }
  1529. oldValue, err := m.oldValue(ctx)
  1530. if err != nil {
  1531. return v, fmt.Errorf("querying old value for OldDatasetID: %w", err)
  1532. }
  1533. return oldValue.DatasetID, nil
  1534. }
  1535. // ClearDatasetID clears the value of the "dataset_id" field.
  1536. func (m *AgentBaseMutation) ClearDatasetID() {
  1537. m.dataset_id = nil
  1538. m.clearedFields[agentbase.FieldDatasetID] = struct{}{}
  1539. }
  1540. // DatasetIDCleared returns if the "dataset_id" field was cleared in this mutation.
  1541. func (m *AgentBaseMutation) DatasetIDCleared() bool {
  1542. _, ok := m.clearedFields[agentbase.FieldDatasetID]
  1543. return ok
  1544. }
  1545. // ResetDatasetID resets all changes to the "dataset_id" field.
  1546. func (m *AgentBaseMutation) ResetDatasetID() {
  1547. m.dataset_id = nil
  1548. delete(m.clearedFields, agentbase.FieldDatasetID)
  1549. }
  1550. // SetCollectionID sets the "collection_id" field.
  1551. func (m *AgentBaseMutation) SetCollectionID(s string) {
  1552. m.collection_id = &s
  1553. }
  1554. // CollectionID returns the value of the "collection_id" field in the mutation.
  1555. func (m *AgentBaseMutation) CollectionID() (r string, exists bool) {
  1556. v := m.collection_id
  1557. if v == nil {
  1558. return
  1559. }
  1560. return *v, true
  1561. }
  1562. // OldCollectionID returns the old "collection_id" field's value of the AgentBase entity.
  1563. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1564. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1565. func (m *AgentBaseMutation) OldCollectionID(ctx context.Context) (v string, err error) {
  1566. if !m.op.Is(OpUpdateOne) {
  1567. return v, errors.New("OldCollectionID is only allowed on UpdateOne operations")
  1568. }
  1569. if m.id == nil || m.oldValue == nil {
  1570. return v, errors.New("OldCollectionID requires an ID field in the mutation")
  1571. }
  1572. oldValue, err := m.oldValue(ctx)
  1573. if err != nil {
  1574. return v, fmt.Errorf("querying old value for OldCollectionID: %w", err)
  1575. }
  1576. return oldValue.CollectionID, nil
  1577. }
  1578. // ClearCollectionID clears the value of the "collection_id" field.
  1579. func (m *AgentBaseMutation) ClearCollectionID() {
  1580. m.collection_id = nil
  1581. m.clearedFields[agentbase.FieldCollectionID] = struct{}{}
  1582. }
  1583. // CollectionIDCleared returns if the "collection_id" field was cleared in this mutation.
  1584. func (m *AgentBaseMutation) CollectionIDCleared() bool {
  1585. _, ok := m.clearedFields[agentbase.FieldCollectionID]
  1586. return ok
  1587. }
  1588. // ResetCollectionID resets all changes to the "collection_id" field.
  1589. func (m *AgentBaseMutation) ResetCollectionID() {
  1590. m.collection_id = nil
  1591. delete(m.clearedFields, agentbase.FieldCollectionID)
  1592. }
  1593. // SetSourceName sets the "source_name" field.
  1594. func (m *AgentBaseMutation) SetSourceName(s string) {
  1595. m.source_name = &s
  1596. }
  1597. // SourceName returns the value of the "source_name" field in the mutation.
  1598. func (m *AgentBaseMutation) SourceName() (r string, exists bool) {
  1599. v := m.source_name
  1600. if v == nil {
  1601. return
  1602. }
  1603. return *v, true
  1604. }
  1605. // OldSourceName returns the old "source_name" field's value of the AgentBase entity.
  1606. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1607. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1608. func (m *AgentBaseMutation) OldSourceName(ctx context.Context) (v string, err error) {
  1609. if !m.op.Is(OpUpdateOne) {
  1610. return v, errors.New("OldSourceName is only allowed on UpdateOne operations")
  1611. }
  1612. if m.id == nil || m.oldValue == nil {
  1613. return v, errors.New("OldSourceName requires an ID field in the mutation")
  1614. }
  1615. oldValue, err := m.oldValue(ctx)
  1616. if err != nil {
  1617. return v, fmt.Errorf("querying old value for OldSourceName: %w", err)
  1618. }
  1619. return oldValue.SourceName, nil
  1620. }
  1621. // ClearSourceName clears the value of the "source_name" field.
  1622. func (m *AgentBaseMutation) ClearSourceName() {
  1623. m.source_name = nil
  1624. m.clearedFields[agentbase.FieldSourceName] = struct{}{}
  1625. }
  1626. // SourceNameCleared returns if the "source_name" field was cleared in this mutation.
  1627. func (m *AgentBaseMutation) SourceNameCleared() bool {
  1628. _, ok := m.clearedFields[agentbase.FieldSourceName]
  1629. return ok
  1630. }
  1631. // ResetSourceName resets all changes to the "source_name" field.
  1632. func (m *AgentBaseMutation) ResetSourceName() {
  1633. m.source_name = nil
  1634. delete(m.clearedFields, agentbase.FieldSourceName)
  1635. }
  1636. // SetCanWrite sets the "can_write" field.
  1637. func (m *AgentBaseMutation) SetCanWrite(b []bool) {
  1638. m.can_write = &b
  1639. m.appendcan_write = nil
  1640. }
  1641. // CanWrite returns the value of the "can_write" field in the mutation.
  1642. func (m *AgentBaseMutation) CanWrite() (r []bool, exists bool) {
  1643. v := m.can_write
  1644. if v == nil {
  1645. return
  1646. }
  1647. return *v, true
  1648. }
  1649. // OldCanWrite returns the old "can_write" field's value of the AgentBase entity.
  1650. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1652. func (m *AgentBaseMutation) OldCanWrite(ctx context.Context) (v []bool, err error) {
  1653. if !m.op.Is(OpUpdateOne) {
  1654. return v, errors.New("OldCanWrite is only allowed on UpdateOne operations")
  1655. }
  1656. if m.id == nil || m.oldValue == nil {
  1657. return v, errors.New("OldCanWrite requires an ID field in the mutation")
  1658. }
  1659. oldValue, err := m.oldValue(ctx)
  1660. if err != nil {
  1661. return v, fmt.Errorf("querying old value for OldCanWrite: %w", err)
  1662. }
  1663. return oldValue.CanWrite, nil
  1664. }
  1665. // AppendCanWrite adds b to the "can_write" field.
  1666. func (m *AgentBaseMutation) AppendCanWrite(b []bool) {
  1667. m.appendcan_write = append(m.appendcan_write, b...)
  1668. }
  1669. // AppendedCanWrite returns the list of values that were appended to the "can_write" field in this mutation.
  1670. func (m *AgentBaseMutation) AppendedCanWrite() ([]bool, bool) {
  1671. if len(m.appendcan_write) == 0 {
  1672. return nil, false
  1673. }
  1674. return m.appendcan_write, true
  1675. }
  1676. // ClearCanWrite clears the value of the "can_write" field.
  1677. func (m *AgentBaseMutation) ClearCanWrite() {
  1678. m.can_write = nil
  1679. m.appendcan_write = nil
  1680. m.clearedFields[agentbase.FieldCanWrite] = struct{}{}
  1681. }
  1682. // CanWriteCleared returns if the "can_write" field was cleared in this mutation.
  1683. func (m *AgentBaseMutation) CanWriteCleared() bool {
  1684. _, ok := m.clearedFields[agentbase.FieldCanWrite]
  1685. return ok
  1686. }
  1687. // ResetCanWrite resets all changes to the "can_write" field.
  1688. func (m *AgentBaseMutation) ResetCanWrite() {
  1689. m.can_write = nil
  1690. m.appendcan_write = nil
  1691. delete(m.clearedFields, agentbase.FieldCanWrite)
  1692. }
  1693. // SetIsOwner sets the "is_owner" field.
  1694. func (m *AgentBaseMutation) SetIsOwner(b []bool) {
  1695. m.is_owner = &b
  1696. m.appendis_owner = nil
  1697. }
  1698. // IsOwner returns the value of the "is_owner" field in the mutation.
  1699. func (m *AgentBaseMutation) IsOwner() (r []bool, exists bool) {
  1700. v := m.is_owner
  1701. if v == nil {
  1702. return
  1703. }
  1704. return *v, true
  1705. }
  1706. // OldIsOwner returns the old "is_owner" field's value of the AgentBase entity.
  1707. // If the AgentBase object wasn't provided to the builder, the object is fetched from the database.
  1708. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  1709. func (m *AgentBaseMutation) OldIsOwner(ctx context.Context) (v []bool, err error) {
  1710. if !m.op.Is(OpUpdateOne) {
  1711. return v, errors.New("OldIsOwner is only allowed on UpdateOne operations")
  1712. }
  1713. if m.id == nil || m.oldValue == nil {
  1714. return v, errors.New("OldIsOwner requires an ID field in the mutation")
  1715. }
  1716. oldValue, err := m.oldValue(ctx)
  1717. if err != nil {
  1718. return v, fmt.Errorf("querying old value for OldIsOwner: %w", err)
  1719. }
  1720. return oldValue.IsOwner, nil
  1721. }
  1722. // AppendIsOwner adds b to the "is_owner" field.
  1723. func (m *AgentBaseMutation) AppendIsOwner(b []bool) {
  1724. m.appendis_owner = append(m.appendis_owner, b...)
  1725. }
  1726. // AppendedIsOwner returns the list of values that were appended to the "is_owner" field in this mutation.
  1727. func (m *AgentBaseMutation) AppendedIsOwner() ([]bool, bool) {
  1728. if len(m.appendis_owner) == 0 {
  1729. return nil, false
  1730. }
  1731. return m.appendis_owner, true
  1732. }
  1733. // ClearIsOwner clears the value of the "is_owner" field.
  1734. func (m *AgentBaseMutation) ClearIsOwner() {
  1735. m.is_owner = nil
  1736. m.appendis_owner = nil
  1737. m.clearedFields[agentbase.FieldIsOwner] = struct{}{}
  1738. }
  1739. // IsOwnerCleared returns if the "is_owner" field was cleared in this mutation.
  1740. func (m *AgentBaseMutation) IsOwnerCleared() bool {
  1741. _, ok := m.clearedFields[agentbase.FieldIsOwner]
  1742. return ok
  1743. }
  1744. // ResetIsOwner resets all changes to the "is_owner" field.
  1745. func (m *AgentBaseMutation) ResetIsOwner() {
  1746. m.is_owner = nil
  1747. m.appendis_owner = nil
  1748. delete(m.clearedFields, agentbase.FieldIsOwner)
  1749. }
  1750. // AddWxAgentIDs adds the "wx_agent" edge to the Wx entity by ids.
  1751. func (m *AgentBaseMutation) AddWxAgentIDs(ids ...uint64) {
  1752. if m.wx_agent == nil {
  1753. m.wx_agent = make(map[uint64]struct{})
  1754. }
  1755. for i := range ids {
  1756. m.wx_agent[ids[i]] = struct{}{}
  1757. }
  1758. }
  1759. // ClearWxAgent clears the "wx_agent" edge to the Wx entity.
  1760. func (m *AgentBaseMutation) ClearWxAgent() {
  1761. m.clearedwx_agent = true
  1762. }
  1763. // WxAgentCleared reports if the "wx_agent" edge to the Wx entity was cleared.
  1764. func (m *AgentBaseMutation) WxAgentCleared() bool {
  1765. return m.clearedwx_agent
  1766. }
  1767. // RemoveWxAgentIDs removes the "wx_agent" edge to the Wx entity by IDs.
  1768. func (m *AgentBaseMutation) RemoveWxAgentIDs(ids ...uint64) {
  1769. if m.removedwx_agent == nil {
  1770. m.removedwx_agent = make(map[uint64]struct{})
  1771. }
  1772. for i := range ids {
  1773. delete(m.wx_agent, ids[i])
  1774. m.removedwx_agent[ids[i]] = struct{}{}
  1775. }
  1776. }
  1777. // RemovedWxAgent returns the removed IDs of the "wx_agent" edge to the Wx entity.
  1778. func (m *AgentBaseMutation) RemovedWxAgentIDs() (ids []uint64) {
  1779. for id := range m.removedwx_agent {
  1780. ids = append(ids, id)
  1781. }
  1782. return
  1783. }
  1784. // WxAgentIDs returns the "wx_agent" edge IDs in the mutation.
  1785. func (m *AgentBaseMutation) WxAgentIDs() (ids []uint64) {
  1786. for id := range m.wx_agent {
  1787. ids = append(ids, id)
  1788. }
  1789. return
  1790. }
  1791. // ResetWxAgent resets all changes to the "wx_agent" edge.
  1792. func (m *AgentBaseMutation) ResetWxAgent() {
  1793. m.wx_agent = nil
  1794. m.clearedwx_agent = false
  1795. m.removedwx_agent = nil
  1796. }
  1797. // Where appends a list predicates to the AgentBaseMutation builder.
  1798. func (m *AgentBaseMutation) Where(ps ...predicate.AgentBase) {
  1799. m.predicates = append(m.predicates, ps...)
  1800. }
  1801. // WhereP appends storage-level predicates to the AgentBaseMutation builder. Using this method,
  1802. // users can use type-assertion to append predicates that do not depend on any generated package.
  1803. func (m *AgentBaseMutation) WhereP(ps ...func(*sql.Selector)) {
  1804. p := make([]predicate.AgentBase, len(ps))
  1805. for i := range ps {
  1806. p[i] = ps[i]
  1807. }
  1808. m.Where(p...)
  1809. }
  1810. // Op returns the operation name.
  1811. func (m *AgentBaseMutation) Op() Op {
  1812. return m.op
  1813. }
  1814. // SetOp allows setting the mutation operation.
  1815. func (m *AgentBaseMutation) SetOp(op Op) {
  1816. m.op = op
  1817. }
  1818. // Type returns the node type of this mutation (AgentBase).
  1819. func (m *AgentBaseMutation) Type() string {
  1820. return m.typ
  1821. }
  1822. // Fields returns all fields that were changed during this mutation. Note that in
  1823. // order to get all numeric fields that were incremented/decremented, call
  1824. // AddedFields().
  1825. func (m *AgentBaseMutation) Fields() []string {
  1826. fields := make([]string, 0, 9)
  1827. if m.q != nil {
  1828. fields = append(fields, agentbase.FieldQ)
  1829. }
  1830. if m.a != nil {
  1831. fields = append(fields, agentbase.FieldA)
  1832. }
  1833. if m.chunk_index != nil {
  1834. fields = append(fields, agentbase.FieldChunkIndex)
  1835. }
  1836. if m.indexes != nil {
  1837. fields = append(fields, agentbase.FieldIndexes)
  1838. }
  1839. if m.dataset_id != nil {
  1840. fields = append(fields, agentbase.FieldDatasetID)
  1841. }
  1842. if m.collection_id != nil {
  1843. fields = append(fields, agentbase.FieldCollectionID)
  1844. }
  1845. if m.source_name != nil {
  1846. fields = append(fields, agentbase.FieldSourceName)
  1847. }
  1848. if m.can_write != nil {
  1849. fields = append(fields, agentbase.FieldCanWrite)
  1850. }
  1851. if m.is_owner != nil {
  1852. fields = append(fields, agentbase.FieldIsOwner)
  1853. }
  1854. return fields
  1855. }
  1856. // Field returns the value of a field with the given name. The second boolean
  1857. // return value indicates that this field was not set, or was not defined in the
  1858. // schema.
  1859. func (m *AgentBaseMutation) Field(name string) (ent.Value, bool) {
  1860. switch name {
  1861. case agentbase.FieldQ:
  1862. return m.Q()
  1863. case agentbase.FieldA:
  1864. return m.A()
  1865. case agentbase.FieldChunkIndex:
  1866. return m.ChunkIndex()
  1867. case agentbase.FieldIndexes:
  1868. return m.Indexes()
  1869. case agentbase.FieldDatasetID:
  1870. return m.DatasetID()
  1871. case agentbase.FieldCollectionID:
  1872. return m.CollectionID()
  1873. case agentbase.FieldSourceName:
  1874. return m.SourceName()
  1875. case agentbase.FieldCanWrite:
  1876. return m.CanWrite()
  1877. case agentbase.FieldIsOwner:
  1878. return m.IsOwner()
  1879. }
  1880. return nil, false
  1881. }
  1882. // OldField returns the old value of the field from the database. An error is
  1883. // returned if the mutation operation is not UpdateOne, or the query to the
  1884. // database failed.
  1885. func (m *AgentBaseMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  1886. switch name {
  1887. case agentbase.FieldQ:
  1888. return m.OldQ(ctx)
  1889. case agentbase.FieldA:
  1890. return m.OldA(ctx)
  1891. case agentbase.FieldChunkIndex:
  1892. return m.OldChunkIndex(ctx)
  1893. case agentbase.FieldIndexes:
  1894. return m.OldIndexes(ctx)
  1895. case agentbase.FieldDatasetID:
  1896. return m.OldDatasetID(ctx)
  1897. case agentbase.FieldCollectionID:
  1898. return m.OldCollectionID(ctx)
  1899. case agentbase.FieldSourceName:
  1900. return m.OldSourceName(ctx)
  1901. case agentbase.FieldCanWrite:
  1902. return m.OldCanWrite(ctx)
  1903. case agentbase.FieldIsOwner:
  1904. return m.OldIsOwner(ctx)
  1905. }
  1906. return nil, fmt.Errorf("unknown AgentBase field %s", name)
  1907. }
  1908. // SetField sets the value of a field with the given name. It returns an error if
  1909. // the field is not defined in the schema, or if the type mismatched the field
  1910. // type.
  1911. func (m *AgentBaseMutation) SetField(name string, value ent.Value) error {
  1912. switch name {
  1913. case agentbase.FieldQ:
  1914. v, ok := value.(string)
  1915. if !ok {
  1916. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1917. }
  1918. m.SetQ(v)
  1919. return nil
  1920. case agentbase.FieldA:
  1921. v, ok := value.(string)
  1922. if !ok {
  1923. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1924. }
  1925. m.SetA(v)
  1926. return nil
  1927. case agentbase.FieldChunkIndex:
  1928. v, ok := value.(uint64)
  1929. if !ok {
  1930. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1931. }
  1932. m.SetChunkIndex(v)
  1933. return nil
  1934. case agentbase.FieldIndexes:
  1935. v, ok := value.([]string)
  1936. if !ok {
  1937. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1938. }
  1939. m.SetIndexes(v)
  1940. return nil
  1941. case agentbase.FieldDatasetID:
  1942. v, ok := value.(string)
  1943. if !ok {
  1944. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1945. }
  1946. m.SetDatasetID(v)
  1947. return nil
  1948. case agentbase.FieldCollectionID:
  1949. v, ok := value.(string)
  1950. if !ok {
  1951. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1952. }
  1953. m.SetCollectionID(v)
  1954. return nil
  1955. case agentbase.FieldSourceName:
  1956. v, ok := value.(string)
  1957. if !ok {
  1958. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1959. }
  1960. m.SetSourceName(v)
  1961. return nil
  1962. case agentbase.FieldCanWrite:
  1963. v, ok := value.([]bool)
  1964. if !ok {
  1965. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1966. }
  1967. m.SetCanWrite(v)
  1968. return nil
  1969. case agentbase.FieldIsOwner:
  1970. v, ok := value.([]bool)
  1971. if !ok {
  1972. return fmt.Errorf("unexpected type %T for field %s", value, name)
  1973. }
  1974. m.SetIsOwner(v)
  1975. return nil
  1976. }
  1977. return fmt.Errorf("unknown AgentBase field %s", name)
  1978. }
  1979. // AddedFields returns all numeric fields that were incremented/decremented during
  1980. // this mutation.
  1981. func (m *AgentBaseMutation) AddedFields() []string {
  1982. var fields []string
  1983. if m.addchunk_index != nil {
  1984. fields = append(fields, agentbase.FieldChunkIndex)
  1985. }
  1986. return fields
  1987. }
  1988. // AddedField returns the numeric value that was incremented/decremented on a field
  1989. // with the given name. The second boolean return value indicates that this field
  1990. // was not set, or was not defined in the schema.
  1991. func (m *AgentBaseMutation) AddedField(name string) (ent.Value, bool) {
  1992. switch name {
  1993. case agentbase.FieldChunkIndex:
  1994. return m.AddedChunkIndex()
  1995. }
  1996. return nil, false
  1997. }
  1998. // AddField adds the value to the field with the given name. It returns an error if
  1999. // the field is not defined in the schema, or if the type mismatched the field
  2000. // type.
  2001. func (m *AgentBaseMutation) AddField(name string, value ent.Value) error {
  2002. switch name {
  2003. case agentbase.FieldChunkIndex:
  2004. v, ok := value.(int64)
  2005. if !ok {
  2006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2007. }
  2008. m.AddChunkIndex(v)
  2009. return nil
  2010. }
  2011. return fmt.Errorf("unknown AgentBase numeric field %s", name)
  2012. }
  2013. // ClearedFields returns all nullable fields that were cleared during this
  2014. // mutation.
  2015. func (m *AgentBaseMutation) ClearedFields() []string {
  2016. var fields []string
  2017. if m.FieldCleared(agentbase.FieldQ) {
  2018. fields = append(fields, agentbase.FieldQ)
  2019. }
  2020. if m.FieldCleared(agentbase.FieldA) {
  2021. fields = append(fields, agentbase.FieldA)
  2022. }
  2023. if m.FieldCleared(agentbase.FieldIndexes) {
  2024. fields = append(fields, agentbase.FieldIndexes)
  2025. }
  2026. if m.FieldCleared(agentbase.FieldDatasetID) {
  2027. fields = append(fields, agentbase.FieldDatasetID)
  2028. }
  2029. if m.FieldCleared(agentbase.FieldCollectionID) {
  2030. fields = append(fields, agentbase.FieldCollectionID)
  2031. }
  2032. if m.FieldCleared(agentbase.FieldSourceName) {
  2033. fields = append(fields, agentbase.FieldSourceName)
  2034. }
  2035. if m.FieldCleared(agentbase.FieldCanWrite) {
  2036. fields = append(fields, agentbase.FieldCanWrite)
  2037. }
  2038. if m.FieldCleared(agentbase.FieldIsOwner) {
  2039. fields = append(fields, agentbase.FieldIsOwner)
  2040. }
  2041. return fields
  2042. }
  2043. // FieldCleared returns a boolean indicating if a field with the given name was
  2044. // cleared in this mutation.
  2045. func (m *AgentBaseMutation) FieldCleared(name string) bool {
  2046. _, ok := m.clearedFields[name]
  2047. return ok
  2048. }
  2049. // ClearField clears the value of the field with the given name. It returns an
  2050. // error if the field is not defined in the schema.
  2051. func (m *AgentBaseMutation) ClearField(name string) error {
  2052. switch name {
  2053. case agentbase.FieldQ:
  2054. m.ClearQ()
  2055. return nil
  2056. case agentbase.FieldA:
  2057. m.ClearA()
  2058. return nil
  2059. case agentbase.FieldIndexes:
  2060. m.ClearIndexes()
  2061. return nil
  2062. case agentbase.FieldDatasetID:
  2063. m.ClearDatasetID()
  2064. return nil
  2065. case agentbase.FieldCollectionID:
  2066. m.ClearCollectionID()
  2067. return nil
  2068. case agentbase.FieldSourceName:
  2069. m.ClearSourceName()
  2070. return nil
  2071. case agentbase.FieldCanWrite:
  2072. m.ClearCanWrite()
  2073. return nil
  2074. case agentbase.FieldIsOwner:
  2075. m.ClearIsOwner()
  2076. return nil
  2077. }
  2078. return fmt.Errorf("unknown AgentBase nullable field %s", name)
  2079. }
  2080. // ResetField resets all changes in the mutation for the field with the given name.
  2081. // It returns an error if the field is not defined in the schema.
  2082. func (m *AgentBaseMutation) ResetField(name string) error {
  2083. switch name {
  2084. case agentbase.FieldQ:
  2085. m.ResetQ()
  2086. return nil
  2087. case agentbase.FieldA:
  2088. m.ResetA()
  2089. return nil
  2090. case agentbase.FieldChunkIndex:
  2091. m.ResetChunkIndex()
  2092. return nil
  2093. case agentbase.FieldIndexes:
  2094. m.ResetIndexes()
  2095. return nil
  2096. case agentbase.FieldDatasetID:
  2097. m.ResetDatasetID()
  2098. return nil
  2099. case agentbase.FieldCollectionID:
  2100. m.ResetCollectionID()
  2101. return nil
  2102. case agentbase.FieldSourceName:
  2103. m.ResetSourceName()
  2104. return nil
  2105. case agentbase.FieldCanWrite:
  2106. m.ResetCanWrite()
  2107. return nil
  2108. case agentbase.FieldIsOwner:
  2109. m.ResetIsOwner()
  2110. return nil
  2111. }
  2112. return fmt.Errorf("unknown AgentBase field %s", name)
  2113. }
  2114. // AddedEdges returns all edge names that were set/added in this mutation.
  2115. func (m *AgentBaseMutation) AddedEdges() []string {
  2116. edges := make([]string, 0, 1)
  2117. if m.wx_agent != nil {
  2118. edges = append(edges, agentbase.EdgeWxAgent)
  2119. }
  2120. return edges
  2121. }
  2122. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  2123. // name in this mutation.
  2124. func (m *AgentBaseMutation) AddedIDs(name string) []ent.Value {
  2125. switch name {
  2126. case agentbase.EdgeWxAgent:
  2127. ids := make([]ent.Value, 0, len(m.wx_agent))
  2128. for id := range m.wx_agent {
  2129. ids = append(ids, id)
  2130. }
  2131. return ids
  2132. }
  2133. return nil
  2134. }
  2135. // RemovedEdges returns all edge names that were removed in this mutation.
  2136. func (m *AgentBaseMutation) RemovedEdges() []string {
  2137. edges := make([]string, 0, 1)
  2138. if m.removedwx_agent != nil {
  2139. edges = append(edges, agentbase.EdgeWxAgent)
  2140. }
  2141. return edges
  2142. }
  2143. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  2144. // the given name in this mutation.
  2145. func (m *AgentBaseMutation) RemovedIDs(name string) []ent.Value {
  2146. switch name {
  2147. case agentbase.EdgeWxAgent:
  2148. ids := make([]ent.Value, 0, len(m.removedwx_agent))
  2149. for id := range m.removedwx_agent {
  2150. ids = append(ids, id)
  2151. }
  2152. return ids
  2153. }
  2154. return nil
  2155. }
  2156. // ClearedEdges returns all edge names that were cleared in this mutation.
  2157. func (m *AgentBaseMutation) ClearedEdges() []string {
  2158. edges := make([]string, 0, 1)
  2159. if m.clearedwx_agent {
  2160. edges = append(edges, agentbase.EdgeWxAgent)
  2161. }
  2162. return edges
  2163. }
  2164. // EdgeCleared returns a boolean which indicates if the edge with the given name
  2165. // was cleared in this mutation.
  2166. func (m *AgentBaseMutation) EdgeCleared(name string) bool {
  2167. switch name {
  2168. case agentbase.EdgeWxAgent:
  2169. return m.clearedwx_agent
  2170. }
  2171. return false
  2172. }
  2173. // ClearEdge clears the value of the edge with the given name. It returns an error
  2174. // if that edge is not defined in the schema.
  2175. func (m *AgentBaseMutation) ClearEdge(name string) error {
  2176. switch name {
  2177. }
  2178. return fmt.Errorf("unknown AgentBase unique edge %s", name)
  2179. }
  2180. // ResetEdge resets all changes to the edge with the given name in this mutation.
  2181. // It returns an error if the edge is not defined in the schema.
  2182. func (m *AgentBaseMutation) ResetEdge(name string) error {
  2183. switch name {
  2184. case agentbase.EdgeWxAgent:
  2185. m.ResetWxAgent()
  2186. return nil
  2187. }
  2188. return fmt.Errorf("unknown AgentBase edge %s", name)
  2189. }
  2190. // AliyunAvatarMutation represents an operation that mutates the AliyunAvatar nodes in the graph.
  2191. type AliyunAvatarMutation struct {
  2192. config
  2193. op Op
  2194. typ string
  2195. id *uint64
  2196. created_at *time.Time
  2197. updated_at *time.Time
  2198. deleted_at *time.Time
  2199. user_id *uint64
  2200. adduser_id *int64
  2201. biz_id *string
  2202. access_key_id *string
  2203. access_key_secret *string
  2204. app_id *string
  2205. tenant_id *uint64
  2206. addtenant_id *int64
  2207. response *string
  2208. token *string
  2209. session_id *string
  2210. clearedFields map[string]struct{}
  2211. done bool
  2212. oldValue func(context.Context) (*AliyunAvatar, error)
  2213. predicates []predicate.AliyunAvatar
  2214. }
  2215. var _ ent.Mutation = (*AliyunAvatarMutation)(nil)
  2216. // aliyunavatarOption allows management of the mutation configuration using functional options.
  2217. type aliyunavatarOption func(*AliyunAvatarMutation)
  2218. // newAliyunAvatarMutation creates new mutation for the AliyunAvatar entity.
  2219. func newAliyunAvatarMutation(c config, op Op, opts ...aliyunavatarOption) *AliyunAvatarMutation {
  2220. m := &AliyunAvatarMutation{
  2221. config: c,
  2222. op: op,
  2223. typ: TypeAliyunAvatar,
  2224. clearedFields: make(map[string]struct{}),
  2225. }
  2226. for _, opt := range opts {
  2227. opt(m)
  2228. }
  2229. return m
  2230. }
  2231. // withAliyunAvatarID sets the ID field of the mutation.
  2232. func withAliyunAvatarID(id uint64) aliyunavatarOption {
  2233. return func(m *AliyunAvatarMutation) {
  2234. var (
  2235. err error
  2236. once sync.Once
  2237. value *AliyunAvatar
  2238. )
  2239. m.oldValue = func(ctx context.Context) (*AliyunAvatar, error) {
  2240. once.Do(func() {
  2241. if m.done {
  2242. err = errors.New("querying old values post mutation is not allowed")
  2243. } else {
  2244. value, err = m.Client().AliyunAvatar.Get(ctx, id)
  2245. }
  2246. })
  2247. return value, err
  2248. }
  2249. m.id = &id
  2250. }
  2251. }
  2252. // withAliyunAvatar sets the old AliyunAvatar of the mutation.
  2253. func withAliyunAvatar(node *AliyunAvatar) aliyunavatarOption {
  2254. return func(m *AliyunAvatarMutation) {
  2255. m.oldValue = func(context.Context) (*AliyunAvatar, error) {
  2256. return node, nil
  2257. }
  2258. m.id = &node.ID
  2259. }
  2260. }
  2261. // Client returns a new `ent.Client` from the mutation. If the mutation was
  2262. // executed in a transaction (ent.Tx), a transactional client is returned.
  2263. func (m AliyunAvatarMutation) Client() *Client {
  2264. client := &Client{config: m.config}
  2265. client.init()
  2266. return client
  2267. }
  2268. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  2269. // it returns an error otherwise.
  2270. func (m AliyunAvatarMutation) Tx() (*Tx, error) {
  2271. if _, ok := m.driver.(*txDriver); !ok {
  2272. return nil, errors.New("ent: mutation is not running in a transaction")
  2273. }
  2274. tx := &Tx{config: m.config}
  2275. tx.init()
  2276. return tx, nil
  2277. }
  2278. // SetID sets the value of the id field. Note that this
  2279. // operation is only accepted on creation of AliyunAvatar entities.
  2280. func (m *AliyunAvatarMutation) SetID(id uint64) {
  2281. m.id = &id
  2282. }
  2283. // ID returns the ID value in the mutation. Note that the ID is only available
  2284. // if it was provided to the builder or after it was returned from the database.
  2285. func (m *AliyunAvatarMutation) ID() (id uint64, exists bool) {
  2286. if m.id == nil {
  2287. return
  2288. }
  2289. return *m.id, true
  2290. }
  2291. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  2292. // That means, if the mutation is applied within a transaction with an isolation level such
  2293. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  2294. // or updated by the mutation.
  2295. func (m *AliyunAvatarMutation) IDs(ctx context.Context) ([]uint64, error) {
  2296. switch {
  2297. case m.op.Is(OpUpdateOne | OpDeleteOne):
  2298. id, exists := m.ID()
  2299. if exists {
  2300. return []uint64{id}, nil
  2301. }
  2302. fallthrough
  2303. case m.op.Is(OpUpdate | OpDelete):
  2304. return m.Client().AliyunAvatar.Query().Where(m.predicates...).IDs(ctx)
  2305. default:
  2306. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  2307. }
  2308. }
  2309. // SetCreatedAt sets the "created_at" field.
  2310. func (m *AliyunAvatarMutation) SetCreatedAt(t time.Time) {
  2311. m.created_at = &t
  2312. }
  2313. // CreatedAt returns the value of the "created_at" field in the mutation.
  2314. func (m *AliyunAvatarMutation) CreatedAt() (r time.Time, exists bool) {
  2315. v := m.created_at
  2316. if v == nil {
  2317. return
  2318. }
  2319. return *v, true
  2320. }
  2321. // OldCreatedAt returns the old "created_at" field's value of the AliyunAvatar entity.
  2322. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2324. func (m *AliyunAvatarMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  2325. if !m.op.Is(OpUpdateOne) {
  2326. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  2327. }
  2328. if m.id == nil || m.oldValue == nil {
  2329. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  2330. }
  2331. oldValue, err := m.oldValue(ctx)
  2332. if err != nil {
  2333. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  2334. }
  2335. return oldValue.CreatedAt, nil
  2336. }
  2337. // ResetCreatedAt resets all changes to the "created_at" field.
  2338. func (m *AliyunAvatarMutation) ResetCreatedAt() {
  2339. m.created_at = nil
  2340. }
  2341. // SetUpdatedAt sets the "updated_at" field.
  2342. func (m *AliyunAvatarMutation) SetUpdatedAt(t time.Time) {
  2343. m.updated_at = &t
  2344. }
  2345. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  2346. func (m *AliyunAvatarMutation) UpdatedAt() (r time.Time, exists bool) {
  2347. v := m.updated_at
  2348. if v == nil {
  2349. return
  2350. }
  2351. return *v, true
  2352. }
  2353. // OldUpdatedAt returns the old "updated_at" field's value of the AliyunAvatar entity.
  2354. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2356. func (m *AliyunAvatarMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  2357. if !m.op.Is(OpUpdateOne) {
  2358. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  2359. }
  2360. if m.id == nil || m.oldValue == nil {
  2361. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  2362. }
  2363. oldValue, err := m.oldValue(ctx)
  2364. if err != nil {
  2365. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  2366. }
  2367. return oldValue.UpdatedAt, nil
  2368. }
  2369. // ResetUpdatedAt resets all changes to the "updated_at" field.
  2370. func (m *AliyunAvatarMutation) ResetUpdatedAt() {
  2371. m.updated_at = nil
  2372. }
  2373. // SetDeletedAt sets the "deleted_at" field.
  2374. func (m *AliyunAvatarMutation) SetDeletedAt(t time.Time) {
  2375. m.deleted_at = &t
  2376. }
  2377. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  2378. func (m *AliyunAvatarMutation) DeletedAt() (r time.Time, exists bool) {
  2379. v := m.deleted_at
  2380. if v == nil {
  2381. return
  2382. }
  2383. return *v, true
  2384. }
  2385. // OldDeletedAt returns the old "deleted_at" field's value of the AliyunAvatar entity.
  2386. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2387. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2388. func (m *AliyunAvatarMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  2389. if !m.op.Is(OpUpdateOne) {
  2390. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  2391. }
  2392. if m.id == nil || m.oldValue == nil {
  2393. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  2394. }
  2395. oldValue, err := m.oldValue(ctx)
  2396. if err != nil {
  2397. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  2398. }
  2399. return oldValue.DeletedAt, nil
  2400. }
  2401. // ClearDeletedAt clears the value of the "deleted_at" field.
  2402. func (m *AliyunAvatarMutation) ClearDeletedAt() {
  2403. m.deleted_at = nil
  2404. m.clearedFields[aliyunavatar.FieldDeletedAt] = struct{}{}
  2405. }
  2406. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  2407. func (m *AliyunAvatarMutation) DeletedAtCleared() bool {
  2408. _, ok := m.clearedFields[aliyunavatar.FieldDeletedAt]
  2409. return ok
  2410. }
  2411. // ResetDeletedAt resets all changes to the "deleted_at" field.
  2412. func (m *AliyunAvatarMutation) ResetDeletedAt() {
  2413. m.deleted_at = nil
  2414. delete(m.clearedFields, aliyunavatar.FieldDeletedAt)
  2415. }
  2416. // SetUserID sets the "user_id" field.
  2417. func (m *AliyunAvatarMutation) SetUserID(u uint64) {
  2418. m.user_id = &u
  2419. m.adduser_id = nil
  2420. }
  2421. // UserID returns the value of the "user_id" field in the mutation.
  2422. func (m *AliyunAvatarMutation) UserID() (r uint64, exists bool) {
  2423. v := m.user_id
  2424. if v == nil {
  2425. return
  2426. }
  2427. return *v, true
  2428. }
  2429. // OldUserID returns the old "user_id" field's value of the AliyunAvatar entity.
  2430. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2432. func (m *AliyunAvatarMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  2433. if !m.op.Is(OpUpdateOne) {
  2434. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  2435. }
  2436. if m.id == nil || m.oldValue == nil {
  2437. return v, errors.New("OldUserID requires an ID field in the mutation")
  2438. }
  2439. oldValue, err := m.oldValue(ctx)
  2440. if err != nil {
  2441. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  2442. }
  2443. return oldValue.UserID, nil
  2444. }
  2445. // AddUserID adds u to the "user_id" field.
  2446. func (m *AliyunAvatarMutation) AddUserID(u int64) {
  2447. if m.adduser_id != nil {
  2448. *m.adduser_id += u
  2449. } else {
  2450. m.adduser_id = &u
  2451. }
  2452. }
  2453. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  2454. func (m *AliyunAvatarMutation) AddedUserID() (r int64, exists bool) {
  2455. v := m.adduser_id
  2456. if v == nil {
  2457. return
  2458. }
  2459. return *v, true
  2460. }
  2461. // ResetUserID resets all changes to the "user_id" field.
  2462. func (m *AliyunAvatarMutation) ResetUserID() {
  2463. m.user_id = nil
  2464. m.adduser_id = nil
  2465. }
  2466. // SetBizID sets the "biz_id" field.
  2467. func (m *AliyunAvatarMutation) SetBizID(s string) {
  2468. m.biz_id = &s
  2469. }
  2470. // BizID returns the value of the "biz_id" field in the mutation.
  2471. func (m *AliyunAvatarMutation) BizID() (r string, exists bool) {
  2472. v := m.biz_id
  2473. if v == nil {
  2474. return
  2475. }
  2476. return *v, true
  2477. }
  2478. // OldBizID returns the old "biz_id" field's value of the AliyunAvatar entity.
  2479. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2481. func (m *AliyunAvatarMutation) OldBizID(ctx context.Context) (v string, err error) {
  2482. if !m.op.Is(OpUpdateOne) {
  2483. return v, errors.New("OldBizID is only allowed on UpdateOne operations")
  2484. }
  2485. if m.id == nil || m.oldValue == nil {
  2486. return v, errors.New("OldBizID requires an ID field in the mutation")
  2487. }
  2488. oldValue, err := m.oldValue(ctx)
  2489. if err != nil {
  2490. return v, fmt.Errorf("querying old value for OldBizID: %w", err)
  2491. }
  2492. return oldValue.BizID, nil
  2493. }
  2494. // ResetBizID resets all changes to the "biz_id" field.
  2495. func (m *AliyunAvatarMutation) ResetBizID() {
  2496. m.biz_id = nil
  2497. }
  2498. // SetAccessKeyID sets the "access_key_id" field.
  2499. func (m *AliyunAvatarMutation) SetAccessKeyID(s string) {
  2500. m.access_key_id = &s
  2501. }
  2502. // AccessKeyID returns the value of the "access_key_id" field in the mutation.
  2503. func (m *AliyunAvatarMutation) AccessKeyID() (r string, exists bool) {
  2504. v := m.access_key_id
  2505. if v == nil {
  2506. return
  2507. }
  2508. return *v, true
  2509. }
  2510. // OldAccessKeyID returns the old "access_key_id" field's value of the AliyunAvatar entity.
  2511. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2512. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2513. func (m *AliyunAvatarMutation) OldAccessKeyID(ctx context.Context) (v string, err error) {
  2514. if !m.op.Is(OpUpdateOne) {
  2515. return v, errors.New("OldAccessKeyID is only allowed on UpdateOne operations")
  2516. }
  2517. if m.id == nil || m.oldValue == nil {
  2518. return v, errors.New("OldAccessKeyID requires an ID field in the mutation")
  2519. }
  2520. oldValue, err := m.oldValue(ctx)
  2521. if err != nil {
  2522. return v, fmt.Errorf("querying old value for OldAccessKeyID: %w", err)
  2523. }
  2524. return oldValue.AccessKeyID, nil
  2525. }
  2526. // ResetAccessKeyID resets all changes to the "access_key_id" field.
  2527. func (m *AliyunAvatarMutation) ResetAccessKeyID() {
  2528. m.access_key_id = nil
  2529. }
  2530. // SetAccessKeySecret sets the "access_key_secret" field.
  2531. func (m *AliyunAvatarMutation) SetAccessKeySecret(s string) {
  2532. m.access_key_secret = &s
  2533. }
  2534. // AccessKeySecret returns the value of the "access_key_secret" field in the mutation.
  2535. func (m *AliyunAvatarMutation) AccessKeySecret() (r string, exists bool) {
  2536. v := m.access_key_secret
  2537. if v == nil {
  2538. return
  2539. }
  2540. return *v, true
  2541. }
  2542. // OldAccessKeySecret returns the old "access_key_secret" field's value of the AliyunAvatar entity.
  2543. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2544. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2545. func (m *AliyunAvatarMutation) OldAccessKeySecret(ctx context.Context) (v string, err error) {
  2546. if !m.op.Is(OpUpdateOne) {
  2547. return v, errors.New("OldAccessKeySecret is only allowed on UpdateOne operations")
  2548. }
  2549. if m.id == nil || m.oldValue == nil {
  2550. return v, errors.New("OldAccessKeySecret requires an ID field in the mutation")
  2551. }
  2552. oldValue, err := m.oldValue(ctx)
  2553. if err != nil {
  2554. return v, fmt.Errorf("querying old value for OldAccessKeySecret: %w", err)
  2555. }
  2556. return oldValue.AccessKeySecret, nil
  2557. }
  2558. // ResetAccessKeySecret resets all changes to the "access_key_secret" field.
  2559. func (m *AliyunAvatarMutation) ResetAccessKeySecret() {
  2560. m.access_key_secret = nil
  2561. }
  2562. // SetAppID sets the "app_id" field.
  2563. func (m *AliyunAvatarMutation) SetAppID(s string) {
  2564. m.app_id = &s
  2565. }
  2566. // AppID returns the value of the "app_id" field in the mutation.
  2567. func (m *AliyunAvatarMutation) AppID() (r string, exists bool) {
  2568. v := m.app_id
  2569. if v == nil {
  2570. return
  2571. }
  2572. return *v, true
  2573. }
  2574. // OldAppID returns the old "app_id" field's value of the AliyunAvatar entity.
  2575. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2577. func (m *AliyunAvatarMutation) OldAppID(ctx context.Context) (v string, err error) {
  2578. if !m.op.Is(OpUpdateOne) {
  2579. return v, errors.New("OldAppID is only allowed on UpdateOne operations")
  2580. }
  2581. if m.id == nil || m.oldValue == nil {
  2582. return v, errors.New("OldAppID requires an ID field in the mutation")
  2583. }
  2584. oldValue, err := m.oldValue(ctx)
  2585. if err != nil {
  2586. return v, fmt.Errorf("querying old value for OldAppID: %w", err)
  2587. }
  2588. return oldValue.AppID, nil
  2589. }
  2590. // ClearAppID clears the value of the "app_id" field.
  2591. func (m *AliyunAvatarMutation) ClearAppID() {
  2592. m.app_id = nil
  2593. m.clearedFields[aliyunavatar.FieldAppID] = struct{}{}
  2594. }
  2595. // AppIDCleared returns if the "app_id" field was cleared in this mutation.
  2596. func (m *AliyunAvatarMutation) AppIDCleared() bool {
  2597. _, ok := m.clearedFields[aliyunavatar.FieldAppID]
  2598. return ok
  2599. }
  2600. // ResetAppID resets all changes to the "app_id" field.
  2601. func (m *AliyunAvatarMutation) ResetAppID() {
  2602. m.app_id = nil
  2603. delete(m.clearedFields, aliyunavatar.FieldAppID)
  2604. }
  2605. // SetTenantID sets the "tenant_id" field.
  2606. func (m *AliyunAvatarMutation) SetTenantID(u uint64) {
  2607. m.tenant_id = &u
  2608. m.addtenant_id = nil
  2609. }
  2610. // TenantID returns the value of the "tenant_id" field in the mutation.
  2611. func (m *AliyunAvatarMutation) TenantID() (r uint64, exists bool) {
  2612. v := m.tenant_id
  2613. if v == nil {
  2614. return
  2615. }
  2616. return *v, true
  2617. }
  2618. // OldTenantID returns the old "tenant_id" field's value of the AliyunAvatar entity.
  2619. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2620. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2621. func (m *AliyunAvatarMutation) OldTenantID(ctx context.Context) (v uint64, err error) {
  2622. if !m.op.Is(OpUpdateOne) {
  2623. return v, errors.New("OldTenantID is only allowed on UpdateOne operations")
  2624. }
  2625. if m.id == nil || m.oldValue == nil {
  2626. return v, errors.New("OldTenantID requires an ID field in the mutation")
  2627. }
  2628. oldValue, err := m.oldValue(ctx)
  2629. if err != nil {
  2630. return v, fmt.Errorf("querying old value for OldTenantID: %w", err)
  2631. }
  2632. return oldValue.TenantID, nil
  2633. }
  2634. // AddTenantID adds u to the "tenant_id" field.
  2635. func (m *AliyunAvatarMutation) AddTenantID(u int64) {
  2636. if m.addtenant_id != nil {
  2637. *m.addtenant_id += u
  2638. } else {
  2639. m.addtenant_id = &u
  2640. }
  2641. }
  2642. // AddedTenantID returns the value that was added to the "tenant_id" field in this mutation.
  2643. func (m *AliyunAvatarMutation) AddedTenantID() (r int64, exists bool) {
  2644. v := m.addtenant_id
  2645. if v == nil {
  2646. return
  2647. }
  2648. return *v, true
  2649. }
  2650. // ResetTenantID resets all changes to the "tenant_id" field.
  2651. func (m *AliyunAvatarMutation) ResetTenantID() {
  2652. m.tenant_id = nil
  2653. m.addtenant_id = nil
  2654. }
  2655. // SetResponse sets the "response" field.
  2656. func (m *AliyunAvatarMutation) SetResponse(s string) {
  2657. m.response = &s
  2658. }
  2659. // Response returns the value of the "response" field in the mutation.
  2660. func (m *AliyunAvatarMutation) Response() (r string, exists bool) {
  2661. v := m.response
  2662. if v == nil {
  2663. return
  2664. }
  2665. return *v, true
  2666. }
  2667. // OldResponse returns the old "response" field's value of the AliyunAvatar entity.
  2668. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2669. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2670. func (m *AliyunAvatarMutation) OldResponse(ctx context.Context) (v string, err error) {
  2671. if !m.op.Is(OpUpdateOne) {
  2672. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  2673. }
  2674. if m.id == nil || m.oldValue == nil {
  2675. return v, errors.New("OldResponse requires an ID field in the mutation")
  2676. }
  2677. oldValue, err := m.oldValue(ctx)
  2678. if err != nil {
  2679. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  2680. }
  2681. return oldValue.Response, nil
  2682. }
  2683. // ResetResponse resets all changes to the "response" field.
  2684. func (m *AliyunAvatarMutation) ResetResponse() {
  2685. m.response = nil
  2686. }
  2687. // SetToken sets the "token" field.
  2688. func (m *AliyunAvatarMutation) SetToken(s string) {
  2689. m.token = &s
  2690. }
  2691. // Token returns the value of the "token" field in the mutation.
  2692. func (m *AliyunAvatarMutation) Token() (r string, exists bool) {
  2693. v := m.token
  2694. if v == nil {
  2695. return
  2696. }
  2697. return *v, true
  2698. }
  2699. // OldToken returns the old "token" field's value of the AliyunAvatar entity.
  2700. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2701. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2702. func (m *AliyunAvatarMutation) OldToken(ctx context.Context) (v string, err error) {
  2703. if !m.op.Is(OpUpdateOne) {
  2704. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  2705. }
  2706. if m.id == nil || m.oldValue == nil {
  2707. return v, errors.New("OldToken requires an ID field in the mutation")
  2708. }
  2709. oldValue, err := m.oldValue(ctx)
  2710. if err != nil {
  2711. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  2712. }
  2713. return oldValue.Token, nil
  2714. }
  2715. // ResetToken resets all changes to the "token" field.
  2716. func (m *AliyunAvatarMutation) ResetToken() {
  2717. m.token = nil
  2718. }
  2719. // SetSessionID sets the "session_id" field.
  2720. func (m *AliyunAvatarMutation) SetSessionID(s string) {
  2721. m.session_id = &s
  2722. }
  2723. // SessionID returns the value of the "session_id" field in the mutation.
  2724. func (m *AliyunAvatarMutation) SessionID() (r string, exists bool) {
  2725. v := m.session_id
  2726. if v == nil {
  2727. return
  2728. }
  2729. return *v, true
  2730. }
  2731. // OldSessionID returns the old "session_id" field's value of the AliyunAvatar entity.
  2732. // If the AliyunAvatar object wasn't provided to the builder, the object is fetched from the database.
  2733. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  2734. func (m *AliyunAvatarMutation) OldSessionID(ctx context.Context) (v string, err error) {
  2735. if !m.op.Is(OpUpdateOne) {
  2736. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  2737. }
  2738. if m.id == nil || m.oldValue == nil {
  2739. return v, errors.New("OldSessionID requires an ID field in the mutation")
  2740. }
  2741. oldValue, err := m.oldValue(ctx)
  2742. if err != nil {
  2743. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  2744. }
  2745. return oldValue.SessionID, nil
  2746. }
  2747. // ResetSessionID resets all changes to the "session_id" field.
  2748. func (m *AliyunAvatarMutation) ResetSessionID() {
  2749. m.session_id = nil
  2750. }
  2751. // Where appends a list predicates to the AliyunAvatarMutation builder.
  2752. func (m *AliyunAvatarMutation) Where(ps ...predicate.AliyunAvatar) {
  2753. m.predicates = append(m.predicates, ps...)
  2754. }
  2755. // WhereP appends storage-level predicates to the AliyunAvatarMutation builder. Using this method,
  2756. // users can use type-assertion to append predicates that do not depend on any generated package.
  2757. func (m *AliyunAvatarMutation) WhereP(ps ...func(*sql.Selector)) {
  2758. p := make([]predicate.AliyunAvatar, len(ps))
  2759. for i := range ps {
  2760. p[i] = ps[i]
  2761. }
  2762. m.Where(p...)
  2763. }
  2764. // Op returns the operation name.
  2765. func (m *AliyunAvatarMutation) Op() Op {
  2766. return m.op
  2767. }
  2768. // SetOp allows setting the mutation operation.
  2769. func (m *AliyunAvatarMutation) SetOp(op Op) {
  2770. m.op = op
  2771. }
  2772. // Type returns the node type of this mutation (AliyunAvatar).
  2773. func (m *AliyunAvatarMutation) Type() string {
  2774. return m.typ
  2775. }
  2776. // Fields returns all fields that were changed during this mutation. Note that in
  2777. // order to get all numeric fields that were incremented/decremented, call
  2778. // AddedFields().
  2779. func (m *AliyunAvatarMutation) Fields() []string {
  2780. fields := make([]string, 0, 12)
  2781. if m.created_at != nil {
  2782. fields = append(fields, aliyunavatar.FieldCreatedAt)
  2783. }
  2784. if m.updated_at != nil {
  2785. fields = append(fields, aliyunavatar.FieldUpdatedAt)
  2786. }
  2787. if m.deleted_at != nil {
  2788. fields = append(fields, aliyunavatar.FieldDeletedAt)
  2789. }
  2790. if m.user_id != nil {
  2791. fields = append(fields, aliyunavatar.FieldUserID)
  2792. }
  2793. if m.biz_id != nil {
  2794. fields = append(fields, aliyunavatar.FieldBizID)
  2795. }
  2796. if m.access_key_id != nil {
  2797. fields = append(fields, aliyunavatar.FieldAccessKeyID)
  2798. }
  2799. if m.access_key_secret != nil {
  2800. fields = append(fields, aliyunavatar.FieldAccessKeySecret)
  2801. }
  2802. if m.app_id != nil {
  2803. fields = append(fields, aliyunavatar.FieldAppID)
  2804. }
  2805. if m.tenant_id != nil {
  2806. fields = append(fields, aliyunavatar.FieldTenantID)
  2807. }
  2808. if m.response != nil {
  2809. fields = append(fields, aliyunavatar.FieldResponse)
  2810. }
  2811. if m.token != nil {
  2812. fields = append(fields, aliyunavatar.FieldToken)
  2813. }
  2814. if m.session_id != nil {
  2815. fields = append(fields, aliyunavatar.FieldSessionID)
  2816. }
  2817. return fields
  2818. }
  2819. // Field returns the value of a field with the given name. The second boolean
  2820. // return value indicates that this field was not set, or was not defined in the
  2821. // schema.
  2822. func (m *AliyunAvatarMutation) Field(name string) (ent.Value, bool) {
  2823. switch name {
  2824. case aliyunavatar.FieldCreatedAt:
  2825. return m.CreatedAt()
  2826. case aliyunavatar.FieldUpdatedAt:
  2827. return m.UpdatedAt()
  2828. case aliyunavatar.FieldDeletedAt:
  2829. return m.DeletedAt()
  2830. case aliyunavatar.FieldUserID:
  2831. return m.UserID()
  2832. case aliyunavatar.FieldBizID:
  2833. return m.BizID()
  2834. case aliyunavatar.FieldAccessKeyID:
  2835. return m.AccessKeyID()
  2836. case aliyunavatar.FieldAccessKeySecret:
  2837. return m.AccessKeySecret()
  2838. case aliyunavatar.FieldAppID:
  2839. return m.AppID()
  2840. case aliyunavatar.FieldTenantID:
  2841. return m.TenantID()
  2842. case aliyunavatar.FieldResponse:
  2843. return m.Response()
  2844. case aliyunavatar.FieldToken:
  2845. return m.Token()
  2846. case aliyunavatar.FieldSessionID:
  2847. return m.SessionID()
  2848. }
  2849. return nil, false
  2850. }
  2851. // OldField returns the old value of the field from the database. An error is
  2852. // returned if the mutation operation is not UpdateOne, or the query to the
  2853. // database failed.
  2854. func (m *AliyunAvatarMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  2855. switch name {
  2856. case aliyunavatar.FieldCreatedAt:
  2857. return m.OldCreatedAt(ctx)
  2858. case aliyunavatar.FieldUpdatedAt:
  2859. return m.OldUpdatedAt(ctx)
  2860. case aliyunavatar.FieldDeletedAt:
  2861. return m.OldDeletedAt(ctx)
  2862. case aliyunavatar.FieldUserID:
  2863. return m.OldUserID(ctx)
  2864. case aliyunavatar.FieldBizID:
  2865. return m.OldBizID(ctx)
  2866. case aliyunavatar.FieldAccessKeyID:
  2867. return m.OldAccessKeyID(ctx)
  2868. case aliyunavatar.FieldAccessKeySecret:
  2869. return m.OldAccessKeySecret(ctx)
  2870. case aliyunavatar.FieldAppID:
  2871. return m.OldAppID(ctx)
  2872. case aliyunavatar.FieldTenantID:
  2873. return m.OldTenantID(ctx)
  2874. case aliyunavatar.FieldResponse:
  2875. return m.OldResponse(ctx)
  2876. case aliyunavatar.FieldToken:
  2877. return m.OldToken(ctx)
  2878. case aliyunavatar.FieldSessionID:
  2879. return m.OldSessionID(ctx)
  2880. }
  2881. return nil, fmt.Errorf("unknown AliyunAvatar field %s", name)
  2882. }
  2883. // SetField sets the value of a field with the given name. It returns an error if
  2884. // the field is not defined in the schema, or if the type mismatched the field
  2885. // type.
  2886. func (m *AliyunAvatarMutation) SetField(name string, value ent.Value) error {
  2887. switch name {
  2888. case aliyunavatar.FieldCreatedAt:
  2889. v, ok := value.(time.Time)
  2890. if !ok {
  2891. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2892. }
  2893. m.SetCreatedAt(v)
  2894. return nil
  2895. case aliyunavatar.FieldUpdatedAt:
  2896. v, ok := value.(time.Time)
  2897. if !ok {
  2898. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2899. }
  2900. m.SetUpdatedAt(v)
  2901. return nil
  2902. case aliyunavatar.FieldDeletedAt:
  2903. v, ok := value.(time.Time)
  2904. if !ok {
  2905. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2906. }
  2907. m.SetDeletedAt(v)
  2908. return nil
  2909. case aliyunavatar.FieldUserID:
  2910. v, ok := value.(uint64)
  2911. if !ok {
  2912. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2913. }
  2914. m.SetUserID(v)
  2915. return nil
  2916. case aliyunavatar.FieldBizID:
  2917. v, ok := value.(string)
  2918. if !ok {
  2919. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2920. }
  2921. m.SetBizID(v)
  2922. return nil
  2923. case aliyunavatar.FieldAccessKeyID:
  2924. v, ok := value.(string)
  2925. if !ok {
  2926. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2927. }
  2928. m.SetAccessKeyID(v)
  2929. return nil
  2930. case aliyunavatar.FieldAccessKeySecret:
  2931. v, ok := value.(string)
  2932. if !ok {
  2933. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2934. }
  2935. m.SetAccessKeySecret(v)
  2936. return nil
  2937. case aliyunavatar.FieldAppID:
  2938. v, ok := value.(string)
  2939. if !ok {
  2940. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2941. }
  2942. m.SetAppID(v)
  2943. return nil
  2944. case aliyunavatar.FieldTenantID:
  2945. v, ok := value.(uint64)
  2946. if !ok {
  2947. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2948. }
  2949. m.SetTenantID(v)
  2950. return nil
  2951. case aliyunavatar.FieldResponse:
  2952. v, ok := value.(string)
  2953. if !ok {
  2954. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2955. }
  2956. m.SetResponse(v)
  2957. return nil
  2958. case aliyunavatar.FieldToken:
  2959. v, ok := value.(string)
  2960. if !ok {
  2961. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2962. }
  2963. m.SetToken(v)
  2964. return nil
  2965. case aliyunavatar.FieldSessionID:
  2966. v, ok := value.(string)
  2967. if !ok {
  2968. return fmt.Errorf("unexpected type %T for field %s", value, name)
  2969. }
  2970. m.SetSessionID(v)
  2971. return nil
  2972. }
  2973. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  2974. }
  2975. // AddedFields returns all numeric fields that were incremented/decremented during
  2976. // this mutation.
  2977. func (m *AliyunAvatarMutation) AddedFields() []string {
  2978. var fields []string
  2979. if m.adduser_id != nil {
  2980. fields = append(fields, aliyunavatar.FieldUserID)
  2981. }
  2982. if m.addtenant_id != nil {
  2983. fields = append(fields, aliyunavatar.FieldTenantID)
  2984. }
  2985. return fields
  2986. }
  2987. // AddedField returns the numeric value that was incremented/decremented on a field
  2988. // with the given name. The second boolean return value indicates that this field
  2989. // was not set, or was not defined in the schema.
  2990. func (m *AliyunAvatarMutation) AddedField(name string) (ent.Value, bool) {
  2991. switch name {
  2992. case aliyunavatar.FieldUserID:
  2993. return m.AddedUserID()
  2994. case aliyunavatar.FieldTenantID:
  2995. return m.AddedTenantID()
  2996. }
  2997. return nil, false
  2998. }
  2999. // AddField adds the value to the field with the given name. It returns an error if
  3000. // the field is not defined in the schema, or if the type mismatched the field
  3001. // type.
  3002. func (m *AliyunAvatarMutation) AddField(name string, value ent.Value) error {
  3003. switch name {
  3004. case aliyunavatar.FieldUserID:
  3005. v, ok := value.(int64)
  3006. if !ok {
  3007. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3008. }
  3009. m.AddUserID(v)
  3010. return nil
  3011. case aliyunavatar.FieldTenantID:
  3012. v, ok := value.(int64)
  3013. if !ok {
  3014. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3015. }
  3016. m.AddTenantID(v)
  3017. return nil
  3018. }
  3019. return fmt.Errorf("unknown AliyunAvatar numeric field %s", name)
  3020. }
  3021. // ClearedFields returns all nullable fields that were cleared during this
  3022. // mutation.
  3023. func (m *AliyunAvatarMutation) ClearedFields() []string {
  3024. var fields []string
  3025. if m.FieldCleared(aliyunavatar.FieldDeletedAt) {
  3026. fields = append(fields, aliyunavatar.FieldDeletedAt)
  3027. }
  3028. if m.FieldCleared(aliyunavatar.FieldAppID) {
  3029. fields = append(fields, aliyunavatar.FieldAppID)
  3030. }
  3031. return fields
  3032. }
  3033. // FieldCleared returns a boolean indicating if a field with the given name was
  3034. // cleared in this mutation.
  3035. func (m *AliyunAvatarMutation) FieldCleared(name string) bool {
  3036. _, ok := m.clearedFields[name]
  3037. return ok
  3038. }
  3039. // ClearField clears the value of the field with the given name. It returns an
  3040. // error if the field is not defined in the schema.
  3041. func (m *AliyunAvatarMutation) ClearField(name string) error {
  3042. switch name {
  3043. case aliyunavatar.FieldDeletedAt:
  3044. m.ClearDeletedAt()
  3045. return nil
  3046. case aliyunavatar.FieldAppID:
  3047. m.ClearAppID()
  3048. return nil
  3049. }
  3050. return fmt.Errorf("unknown AliyunAvatar nullable field %s", name)
  3051. }
  3052. // ResetField resets all changes in the mutation for the field with the given name.
  3053. // It returns an error if the field is not defined in the schema.
  3054. func (m *AliyunAvatarMutation) ResetField(name string) error {
  3055. switch name {
  3056. case aliyunavatar.FieldCreatedAt:
  3057. m.ResetCreatedAt()
  3058. return nil
  3059. case aliyunavatar.FieldUpdatedAt:
  3060. m.ResetUpdatedAt()
  3061. return nil
  3062. case aliyunavatar.FieldDeletedAt:
  3063. m.ResetDeletedAt()
  3064. return nil
  3065. case aliyunavatar.FieldUserID:
  3066. m.ResetUserID()
  3067. return nil
  3068. case aliyunavatar.FieldBizID:
  3069. m.ResetBizID()
  3070. return nil
  3071. case aliyunavatar.FieldAccessKeyID:
  3072. m.ResetAccessKeyID()
  3073. return nil
  3074. case aliyunavatar.FieldAccessKeySecret:
  3075. m.ResetAccessKeySecret()
  3076. return nil
  3077. case aliyunavatar.FieldAppID:
  3078. m.ResetAppID()
  3079. return nil
  3080. case aliyunavatar.FieldTenantID:
  3081. m.ResetTenantID()
  3082. return nil
  3083. case aliyunavatar.FieldResponse:
  3084. m.ResetResponse()
  3085. return nil
  3086. case aliyunavatar.FieldToken:
  3087. m.ResetToken()
  3088. return nil
  3089. case aliyunavatar.FieldSessionID:
  3090. m.ResetSessionID()
  3091. return nil
  3092. }
  3093. return fmt.Errorf("unknown AliyunAvatar field %s", name)
  3094. }
  3095. // AddedEdges returns all edge names that were set/added in this mutation.
  3096. func (m *AliyunAvatarMutation) AddedEdges() []string {
  3097. edges := make([]string, 0, 0)
  3098. return edges
  3099. }
  3100. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3101. // name in this mutation.
  3102. func (m *AliyunAvatarMutation) AddedIDs(name string) []ent.Value {
  3103. return nil
  3104. }
  3105. // RemovedEdges returns all edge names that were removed in this mutation.
  3106. func (m *AliyunAvatarMutation) RemovedEdges() []string {
  3107. edges := make([]string, 0, 0)
  3108. return edges
  3109. }
  3110. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3111. // the given name in this mutation.
  3112. func (m *AliyunAvatarMutation) RemovedIDs(name string) []ent.Value {
  3113. return nil
  3114. }
  3115. // ClearedEdges returns all edge names that were cleared in this mutation.
  3116. func (m *AliyunAvatarMutation) ClearedEdges() []string {
  3117. edges := make([]string, 0, 0)
  3118. return edges
  3119. }
  3120. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3121. // was cleared in this mutation.
  3122. func (m *AliyunAvatarMutation) EdgeCleared(name string) bool {
  3123. return false
  3124. }
  3125. // ClearEdge clears the value of the edge with the given name. It returns an error
  3126. // if that edge is not defined in the schema.
  3127. func (m *AliyunAvatarMutation) ClearEdge(name string) error {
  3128. return fmt.Errorf("unknown AliyunAvatar unique edge %s", name)
  3129. }
  3130. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3131. // It returns an error if the edge is not defined in the schema.
  3132. func (m *AliyunAvatarMutation) ResetEdge(name string) error {
  3133. return fmt.Errorf("unknown AliyunAvatar edge %s", name)
  3134. }
  3135. // AllocAgentMutation represents an operation that mutates the AllocAgent nodes in the graph.
  3136. type AllocAgentMutation struct {
  3137. config
  3138. op Op
  3139. typ string
  3140. id *uint64
  3141. created_at *time.Time
  3142. updated_at *time.Time
  3143. deleted_at *time.Time
  3144. user_id *string
  3145. organization_id *uint64
  3146. addorganization_id *int64
  3147. agents *[]uint64
  3148. appendagents []uint64
  3149. status *int
  3150. addstatus *int
  3151. clearedFields map[string]struct{}
  3152. done bool
  3153. oldValue func(context.Context) (*AllocAgent, error)
  3154. predicates []predicate.AllocAgent
  3155. }
  3156. var _ ent.Mutation = (*AllocAgentMutation)(nil)
  3157. // allocagentOption allows management of the mutation configuration using functional options.
  3158. type allocagentOption func(*AllocAgentMutation)
  3159. // newAllocAgentMutation creates new mutation for the AllocAgent entity.
  3160. func newAllocAgentMutation(c config, op Op, opts ...allocagentOption) *AllocAgentMutation {
  3161. m := &AllocAgentMutation{
  3162. config: c,
  3163. op: op,
  3164. typ: TypeAllocAgent,
  3165. clearedFields: make(map[string]struct{}),
  3166. }
  3167. for _, opt := range opts {
  3168. opt(m)
  3169. }
  3170. return m
  3171. }
  3172. // withAllocAgentID sets the ID field of the mutation.
  3173. func withAllocAgentID(id uint64) allocagentOption {
  3174. return func(m *AllocAgentMutation) {
  3175. var (
  3176. err error
  3177. once sync.Once
  3178. value *AllocAgent
  3179. )
  3180. m.oldValue = func(ctx context.Context) (*AllocAgent, error) {
  3181. once.Do(func() {
  3182. if m.done {
  3183. err = errors.New("querying old values post mutation is not allowed")
  3184. } else {
  3185. value, err = m.Client().AllocAgent.Get(ctx, id)
  3186. }
  3187. })
  3188. return value, err
  3189. }
  3190. m.id = &id
  3191. }
  3192. }
  3193. // withAllocAgent sets the old AllocAgent of the mutation.
  3194. func withAllocAgent(node *AllocAgent) allocagentOption {
  3195. return func(m *AllocAgentMutation) {
  3196. m.oldValue = func(context.Context) (*AllocAgent, error) {
  3197. return node, nil
  3198. }
  3199. m.id = &node.ID
  3200. }
  3201. }
  3202. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3203. // executed in a transaction (ent.Tx), a transactional client is returned.
  3204. func (m AllocAgentMutation) Client() *Client {
  3205. client := &Client{config: m.config}
  3206. client.init()
  3207. return client
  3208. }
  3209. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3210. // it returns an error otherwise.
  3211. func (m AllocAgentMutation) Tx() (*Tx, error) {
  3212. if _, ok := m.driver.(*txDriver); !ok {
  3213. return nil, errors.New("ent: mutation is not running in a transaction")
  3214. }
  3215. tx := &Tx{config: m.config}
  3216. tx.init()
  3217. return tx, nil
  3218. }
  3219. // SetID sets the value of the id field. Note that this
  3220. // operation is only accepted on creation of AllocAgent entities.
  3221. func (m *AllocAgentMutation) SetID(id uint64) {
  3222. m.id = &id
  3223. }
  3224. // ID returns the ID value in the mutation. Note that the ID is only available
  3225. // if it was provided to the builder or after it was returned from the database.
  3226. func (m *AllocAgentMutation) ID() (id uint64, exists bool) {
  3227. if m.id == nil {
  3228. return
  3229. }
  3230. return *m.id, true
  3231. }
  3232. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3233. // That means, if the mutation is applied within a transaction with an isolation level such
  3234. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3235. // or updated by the mutation.
  3236. func (m *AllocAgentMutation) IDs(ctx context.Context) ([]uint64, error) {
  3237. switch {
  3238. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3239. id, exists := m.ID()
  3240. if exists {
  3241. return []uint64{id}, nil
  3242. }
  3243. fallthrough
  3244. case m.op.Is(OpUpdate | OpDelete):
  3245. return m.Client().AllocAgent.Query().Where(m.predicates...).IDs(ctx)
  3246. default:
  3247. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  3248. }
  3249. }
  3250. // SetCreatedAt sets the "created_at" field.
  3251. func (m *AllocAgentMutation) SetCreatedAt(t time.Time) {
  3252. m.created_at = &t
  3253. }
  3254. // CreatedAt returns the value of the "created_at" field in the mutation.
  3255. func (m *AllocAgentMutation) CreatedAt() (r time.Time, exists bool) {
  3256. v := m.created_at
  3257. if v == nil {
  3258. return
  3259. }
  3260. return *v, true
  3261. }
  3262. // OldCreatedAt returns the old "created_at" field's value of the AllocAgent entity.
  3263. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3264. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3265. func (m *AllocAgentMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  3266. if !m.op.Is(OpUpdateOne) {
  3267. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  3268. }
  3269. if m.id == nil || m.oldValue == nil {
  3270. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  3271. }
  3272. oldValue, err := m.oldValue(ctx)
  3273. if err != nil {
  3274. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  3275. }
  3276. return oldValue.CreatedAt, nil
  3277. }
  3278. // ResetCreatedAt resets all changes to the "created_at" field.
  3279. func (m *AllocAgentMutation) ResetCreatedAt() {
  3280. m.created_at = nil
  3281. }
  3282. // SetUpdatedAt sets the "updated_at" field.
  3283. func (m *AllocAgentMutation) SetUpdatedAt(t time.Time) {
  3284. m.updated_at = &t
  3285. }
  3286. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  3287. func (m *AllocAgentMutation) UpdatedAt() (r time.Time, exists bool) {
  3288. v := m.updated_at
  3289. if v == nil {
  3290. return
  3291. }
  3292. return *v, true
  3293. }
  3294. // OldUpdatedAt returns the old "updated_at" field's value of the AllocAgent entity.
  3295. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3296. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3297. func (m *AllocAgentMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  3298. if !m.op.Is(OpUpdateOne) {
  3299. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  3300. }
  3301. if m.id == nil || m.oldValue == nil {
  3302. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  3303. }
  3304. oldValue, err := m.oldValue(ctx)
  3305. if err != nil {
  3306. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  3307. }
  3308. return oldValue.UpdatedAt, nil
  3309. }
  3310. // ResetUpdatedAt resets all changes to the "updated_at" field.
  3311. func (m *AllocAgentMutation) ResetUpdatedAt() {
  3312. m.updated_at = nil
  3313. }
  3314. // SetDeletedAt sets the "deleted_at" field.
  3315. func (m *AllocAgentMutation) SetDeletedAt(t time.Time) {
  3316. m.deleted_at = &t
  3317. }
  3318. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  3319. func (m *AllocAgentMutation) DeletedAt() (r time.Time, exists bool) {
  3320. v := m.deleted_at
  3321. if v == nil {
  3322. return
  3323. }
  3324. return *v, true
  3325. }
  3326. // OldDeletedAt returns the old "deleted_at" field's value of the AllocAgent entity.
  3327. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3329. func (m *AllocAgentMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  3330. if !m.op.Is(OpUpdateOne) {
  3331. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  3332. }
  3333. if m.id == nil || m.oldValue == nil {
  3334. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  3335. }
  3336. oldValue, err := m.oldValue(ctx)
  3337. if err != nil {
  3338. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  3339. }
  3340. return oldValue.DeletedAt, nil
  3341. }
  3342. // ClearDeletedAt clears the value of the "deleted_at" field.
  3343. func (m *AllocAgentMutation) ClearDeletedAt() {
  3344. m.deleted_at = nil
  3345. m.clearedFields[allocagent.FieldDeletedAt] = struct{}{}
  3346. }
  3347. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  3348. func (m *AllocAgentMutation) DeletedAtCleared() bool {
  3349. _, ok := m.clearedFields[allocagent.FieldDeletedAt]
  3350. return ok
  3351. }
  3352. // ResetDeletedAt resets all changes to the "deleted_at" field.
  3353. func (m *AllocAgentMutation) ResetDeletedAt() {
  3354. m.deleted_at = nil
  3355. delete(m.clearedFields, allocagent.FieldDeletedAt)
  3356. }
  3357. // SetUserID sets the "user_id" field.
  3358. func (m *AllocAgentMutation) SetUserID(s string) {
  3359. m.user_id = &s
  3360. }
  3361. // UserID returns the value of the "user_id" field in the mutation.
  3362. func (m *AllocAgentMutation) UserID() (r string, exists bool) {
  3363. v := m.user_id
  3364. if v == nil {
  3365. return
  3366. }
  3367. return *v, true
  3368. }
  3369. // OldUserID returns the old "user_id" field's value of the AllocAgent entity.
  3370. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3371. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3372. func (m *AllocAgentMutation) OldUserID(ctx context.Context) (v string, err error) {
  3373. if !m.op.Is(OpUpdateOne) {
  3374. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  3375. }
  3376. if m.id == nil || m.oldValue == nil {
  3377. return v, errors.New("OldUserID requires an ID field in the mutation")
  3378. }
  3379. oldValue, err := m.oldValue(ctx)
  3380. if err != nil {
  3381. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  3382. }
  3383. return oldValue.UserID, nil
  3384. }
  3385. // ClearUserID clears the value of the "user_id" field.
  3386. func (m *AllocAgentMutation) ClearUserID() {
  3387. m.user_id = nil
  3388. m.clearedFields[allocagent.FieldUserID] = struct{}{}
  3389. }
  3390. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  3391. func (m *AllocAgentMutation) UserIDCleared() bool {
  3392. _, ok := m.clearedFields[allocagent.FieldUserID]
  3393. return ok
  3394. }
  3395. // ResetUserID resets all changes to the "user_id" field.
  3396. func (m *AllocAgentMutation) ResetUserID() {
  3397. m.user_id = nil
  3398. delete(m.clearedFields, allocagent.FieldUserID)
  3399. }
  3400. // SetOrganizationID sets the "organization_id" field.
  3401. func (m *AllocAgentMutation) SetOrganizationID(u uint64) {
  3402. m.organization_id = &u
  3403. m.addorganization_id = nil
  3404. }
  3405. // OrganizationID returns the value of the "organization_id" field in the mutation.
  3406. func (m *AllocAgentMutation) OrganizationID() (r uint64, exists bool) {
  3407. v := m.organization_id
  3408. if v == nil {
  3409. return
  3410. }
  3411. return *v, true
  3412. }
  3413. // OldOrganizationID returns the old "organization_id" field's value of the AllocAgent entity.
  3414. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3415. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3416. func (m *AllocAgentMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  3417. if !m.op.Is(OpUpdateOne) {
  3418. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  3419. }
  3420. if m.id == nil || m.oldValue == nil {
  3421. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  3422. }
  3423. oldValue, err := m.oldValue(ctx)
  3424. if err != nil {
  3425. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  3426. }
  3427. return oldValue.OrganizationID, nil
  3428. }
  3429. // AddOrganizationID adds u to the "organization_id" field.
  3430. func (m *AllocAgentMutation) AddOrganizationID(u int64) {
  3431. if m.addorganization_id != nil {
  3432. *m.addorganization_id += u
  3433. } else {
  3434. m.addorganization_id = &u
  3435. }
  3436. }
  3437. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  3438. func (m *AllocAgentMutation) AddedOrganizationID() (r int64, exists bool) {
  3439. v := m.addorganization_id
  3440. if v == nil {
  3441. return
  3442. }
  3443. return *v, true
  3444. }
  3445. // ClearOrganizationID clears the value of the "organization_id" field.
  3446. func (m *AllocAgentMutation) ClearOrganizationID() {
  3447. m.organization_id = nil
  3448. m.addorganization_id = nil
  3449. m.clearedFields[allocagent.FieldOrganizationID] = struct{}{}
  3450. }
  3451. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  3452. func (m *AllocAgentMutation) OrganizationIDCleared() bool {
  3453. _, ok := m.clearedFields[allocagent.FieldOrganizationID]
  3454. return ok
  3455. }
  3456. // ResetOrganizationID resets all changes to the "organization_id" field.
  3457. func (m *AllocAgentMutation) ResetOrganizationID() {
  3458. m.organization_id = nil
  3459. m.addorganization_id = nil
  3460. delete(m.clearedFields, allocagent.FieldOrganizationID)
  3461. }
  3462. // SetAgents sets the "agents" field.
  3463. func (m *AllocAgentMutation) SetAgents(u []uint64) {
  3464. m.agents = &u
  3465. m.appendagents = nil
  3466. }
  3467. // Agents returns the value of the "agents" field in the mutation.
  3468. func (m *AllocAgentMutation) Agents() (r []uint64, exists bool) {
  3469. v := m.agents
  3470. if v == nil {
  3471. return
  3472. }
  3473. return *v, true
  3474. }
  3475. // OldAgents returns the old "agents" field's value of the AllocAgent entity.
  3476. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3478. func (m *AllocAgentMutation) OldAgents(ctx context.Context) (v []uint64, err error) {
  3479. if !m.op.Is(OpUpdateOne) {
  3480. return v, errors.New("OldAgents is only allowed on UpdateOne operations")
  3481. }
  3482. if m.id == nil || m.oldValue == nil {
  3483. return v, errors.New("OldAgents requires an ID field in the mutation")
  3484. }
  3485. oldValue, err := m.oldValue(ctx)
  3486. if err != nil {
  3487. return v, fmt.Errorf("querying old value for OldAgents: %w", err)
  3488. }
  3489. return oldValue.Agents, nil
  3490. }
  3491. // AppendAgents adds u to the "agents" field.
  3492. func (m *AllocAgentMutation) AppendAgents(u []uint64) {
  3493. m.appendagents = append(m.appendagents, u...)
  3494. }
  3495. // AppendedAgents returns the list of values that were appended to the "agents" field in this mutation.
  3496. func (m *AllocAgentMutation) AppendedAgents() ([]uint64, bool) {
  3497. if len(m.appendagents) == 0 {
  3498. return nil, false
  3499. }
  3500. return m.appendagents, true
  3501. }
  3502. // ResetAgents resets all changes to the "agents" field.
  3503. func (m *AllocAgentMutation) ResetAgents() {
  3504. m.agents = nil
  3505. m.appendagents = nil
  3506. }
  3507. // SetStatus sets the "status" field.
  3508. func (m *AllocAgentMutation) SetStatus(i int) {
  3509. m.status = &i
  3510. m.addstatus = nil
  3511. }
  3512. // Status returns the value of the "status" field in the mutation.
  3513. func (m *AllocAgentMutation) Status() (r int, exists bool) {
  3514. v := m.status
  3515. if v == nil {
  3516. return
  3517. }
  3518. return *v, true
  3519. }
  3520. // OldStatus returns the old "status" field's value of the AllocAgent entity.
  3521. // If the AllocAgent object wasn't provided to the builder, the object is fetched from the database.
  3522. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  3523. func (m *AllocAgentMutation) OldStatus(ctx context.Context) (v int, err error) {
  3524. if !m.op.Is(OpUpdateOne) {
  3525. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  3526. }
  3527. if m.id == nil || m.oldValue == nil {
  3528. return v, errors.New("OldStatus requires an ID field in the mutation")
  3529. }
  3530. oldValue, err := m.oldValue(ctx)
  3531. if err != nil {
  3532. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  3533. }
  3534. return oldValue.Status, nil
  3535. }
  3536. // AddStatus adds i to the "status" field.
  3537. func (m *AllocAgentMutation) AddStatus(i int) {
  3538. if m.addstatus != nil {
  3539. *m.addstatus += i
  3540. } else {
  3541. m.addstatus = &i
  3542. }
  3543. }
  3544. // AddedStatus returns the value that was added to the "status" field in this mutation.
  3545. func (m *AllocAgentMutation) AddedStatus() (r int, exists bool) {
  3546. v := m.addstatus
  3547. if v == nil {
  3548. return
  3549. }
  3550. return *v, true
  3551. }
  3552. // ClearStatus clears the value of the "status" field.
  3553. func (m *AllocAgentMutation) ClearStatus() {
  3554. m.status = nil
  3555. m.addstatus = nil
  3556. m.clearedFields[allocagent.FieldStatus] = struct{}{}
  3557. }
  3558. // StatusCleared returns if the "status" field was cleared in this mutation.
  3559. func (m *AllocAgentMutation) StatusCleared() bool {
  3560. _, ok := m.clearedFields[allocagent.FieldStatus]
  3561. return ok
  3562. }
  3563. // ResetStatus resets all changes to the "status" field.
  3564. func (m *AllocAgentMutation) ResetStatus() {
  3565. m.status = nil
  3566. m.addstatus = nil
  3567. delete(m.clearedFields, allocagent.FieldStatus)
  3568. }
  3569. // Where appends a list predicates to the AllocAgentMutation builder.
  3570. func (m *AllocAgentMutation) Where(ps ...predicate.AllocAgent) {
  3571. m.predicates = append(m.predicates, ps...)
  3572. }
  3573. // WhereP appends storage-level predicates to the AllocAgentMutation builder. Using this method,
  3574. // users can use type-assertion to append predicates that do not depend on any generated package.
  3575. func (m *AllocAgentMutation) WhereP(ps ...func(*sql.Selector)) {
  3576. p := make([]predicate.AllocAgent, len(ps))
  3577. for i := range ps {
  3578. p[i] = ps[i]
  3579. }
  3580. m.Where(p...)
  3581. }
  3582. // Op returns the operation name.
  3583. func (m *AllocAgentMutation) Op() Op {
  3584. return m.op
  3585. }
  3586. // SetOp allows setting the mutation operation.
  3587. func (m *AllocAgentMutation) SetOp(op Op) {
  3588. m.op = op
  3589. }
  3590. // Type returns the node type of this mutation (AllocAgent).
  3591. func (m *AllocAgentMutation) Type() string {
  3592. return m.typ
  3593. }
  3594. // Fields returns all fields that were changed during this mutation. Note that in
  3595. // order to get all numeric fields that were incremented/decremented, call
  3596. // AddedFields().
  3597. func (m *AllocAgentMutation) Fields() []string {
  3598. fields := make([]string, 0, 7)
  3599. if m.created_at != nil {
  3600. fields = append(fields, allocagent.FieldCreatedAt)
  3601. }
  3602. if m.updated_at != nil {
  3603. fields = append(fields, allocagent.FieldUpdatedAt)
  3604. }
  3605. if m.deleted_at != nil {
  3606. fields = append(fields, allocagent.FieldDeletedAt)
  3607. }
  3608. if m.user_id != nil {
  3609. fields = append(fields, allocagent.FieldUserID)
  3610. }
  3611. if m.organization_id != nil {
  3612. fields = append(fields, allocagent.FieldOrganizationID)
  3613. }
  3614. if m.agents != nil {
  3615. fields = append(fields, allocagent.FieldAgents)
  3616. }
  3617. if m.status != nil {
  3618. fields = append(fields, allocagent.FieldStatus)
  3619. }
  3620. return fields
  3621. }
  3622. // Field returns the value of a field with the given name. The second boolean
  3623. // return value indicates that this field was not set, or was not defined in the
  3624. // schema.
  3625. func (m *AllocAgentMutation) Field(name string) (ent.Value, bool) {
  3626. switch name {
  3627. case allocagent.FieldCreatedAt:
  3628. return m.CreatedAt()
  3629. case allocagent.FieldUpdatedAt:
  3630. return m.UpdatedAt()
  3631. case allocagent.FieldDeletedAt:
  3632. return m.DeletedAt()
  3633. case allocagent.FieldUserID:
  3634. return m.UserID()
  3635. case allocagent.FieldOrganizationID:
  3636. return m.OrganizationID()
  3637. case allocagent.FieldAgents:
  3638. return m.Agents()
  3639. case allocagent.FieldStatus:
  3640. return m.Status()
  3641. }
  3642. return nil, false
  3643. }
  3644. // OldField returns the old value of the field from the database. An error is
  3645. // returned if the mutation operation is not UpdateOne, or the query to the
  3646. // database failed.
  3647. func (m *AllocAgentMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  3648. switch name {
  3649. case allocagent.FieldCreatedAt:
  3650. return m.OldCreatedAt(ctx)
  3651. case allocagent.FieldUpdatedAt:
  3652. return m.OldUpdatedAt(ctx)
  3653. case allocagent.FieldDeletedAt:
  3654. return m.OldDeletedAt(ctx)
  3655. case allocagent.FieldUserID:
  3656. return m.OldUserID(ctx)
  3657. case allocagent.FieldOrganizationID:
  3658. return m.OldOrganizationID(ctx)
  3659. case allocagent.FieldAgents:
  3660. return m.OldAgents(ctx)
  3661. case allocagent.FieldStatus:
  3662. return m.OldStatus(ctx)
  3663. }
  3664. return nil, fmt.Errorf("unknown AllocAgent field %s", name)
  3665. }
  3666. // SetField sets the value of a field with the given name. It returns an error if
  3667. // the field is not defined in the schema, or if the type mismatched the field
  3668. // type.
  3669. func (m *AllocAgentMutation) SetField(name string, value ent.Value) error {
  3670. switch name {
  3671. case allocagent.FieldCreatedAt:
  3672. v, ok := value.(time.Time)
  3673. if !ok {
  3674. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3675. }
  3676. m.SetCreatedAt(v)
  3677. return nil
  3678. case allocagent.FieldUpdatedAt:
  3679. v, ok := value.(time.Time)
  3680. if !ok {
  3681. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3682. }
  3683. m.SetUpdatedAt(v)
  3684. return nil
  3685. case allocagent.FieldDeletedAt:
  3686. v, ok := value.(time.Time)
  3687. if !ok {
  3688. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3689. }
  3690. m.SetDeletedAt(v)
  3691. return nil
  3692. case allocagent.FieldUserID:
  3693. v, ok := value.(string)
  3694. if !ok {
  3695. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3696. }
  3697. m.SetUserID(v)
  3698. return nil
  3699. case allocagent.FieldOrganizationID:
  3700. v, ok := value.(uint64)
  3701. if !ok {
  3702. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3703. }
  3704. m.SetOrganizationID(v)
  3705. return nil
  3706. case allocagent.FieldAgents:
  3707. v, ok := value.([]uint64)
  3708. if !ok {
  3709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3710. }
  3711. m.SetAgents(v)
  3712. return nil
  3713. case allocagent.FieldStatus:
  3714. v, ok := value.(int)
  3715. if !ok {
  3716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3717. }
  3718. m.SetStatus(v)
  3719. return nil
  3720. }
  3721. return fmt.Errorf("unknown AllocAgent field %s", name)
  3722. }
  3723. // AddedFields returns all numeric fields that were incremented/decremented during
  3724. // this mutation.
  3725. func (m *AllocAgentMutation) AddedFields() []string {
  3726. var fields []string
  3727. if m.addorganization_id != nil {
  3728. fields = append(fields, allocagent.FieldOrganizationID)
  3729. }
  3730. if m.addstatus != nil {
  3731. fields = append(fields, allocagent.FieldStatus)
  3732. }
  3733. return fields
  3734. }
  3735. // AddedField returns the numeric value that was incremented/decremented on a field
  3736. // with the given name. The second boolean return value indicates that this field
  3737. // was not set, or was not defined in the schema.
  3738. func (m *AllocAgentMutation) AddedField(name string) (ent.Value, bool) {
  3739. switch name {
  3740. case allocagent.FieldOrganizationID:
  3741. return m.AddedOrganizationID()
  3742. case allocagent.FieldStatus:
  3743. return m.AddedStatus()
  3744. }
  3745. return nil, false
  3746. }
  3747. // AddField adds the value to the field with the given name. It returns an error if
  3748. // the field is not defined in the schema, or if the type mismatched the field
  3749. // type.
  3750. func (m *AllocAgentMutation) AddField(name string, value ent.Value) error {
  3751. switch name {
  3752. case allocagent.FieldOrganizationID:
  3753. v, ok := value.(int64)
  3754. if !ok {
  3755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3756. }
  3757. m.AddOrganizationID(v)
  3758. return nil
  3759. case allocagent.FieldStatus:
  3760. v, ok := value.(int)
  3761. if !ok {
  3762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  3763. }
  3764. m.AddStatus(v)
  3765. return nil
  3766. }
  3767. return fmt.Errorf("unknown AllocAgent numeric field %s", name)
  3768. }
  3769. // ClearedFields returns all nullable fields that were cleared during this
  3770. // mutation.
  3771. func (m *AllocAgentMutation) ClearedFields() []string {
  3772. var fields []string
  3773. if m.FieldCleared(allocagent.FieldDeletedAt) {
  3774. fields = append(fields, allocagent.FieldDeletedAt)
  3775. }
  3776. if m.FieldCleared(allocagent.FieldUserID) {
  3777. fields = append(fields, allocagent.FieldUserID)
  3778. }
  3779. if m.FieldCleared(allocagent.FieldOrganizationID) {
  3780. fields = append(fields, allocagent.FieldOrganizationID)
  3781. }
  3782. if m.FieldCleared(allocagent.FieldStatus) {
  3783. fields = append(fields, allocagent.FieldStatus)
  3784. }
  3785. return fields
  3786. }
  3787. // FieldCleared returns a boolean indicating if a field with the given name was
  3788. // cleared in this mutation.
  3789. func (m *AllocAgentMutation) FieldCleared(name string) bool {
  3790. _, ok := m.clearedFields[name]
  3791. return ok
  3792. }
  3793. // ClearField clears the value of the field with the given name. It returns an
  3794. // error if the field is not defined in the schema.
  3795. func (m *AllocAgentMutation) ClearField(name string) error {
  3796. switch name {
  3797. case allocagent.FieldDeletedAt:
  3798. m.ClearDeletedAt()
  3799. return nil
  3800. case allocagent.FieldUserID:
  3801. m.ClearUserID()
  3802. return nil
  3803. case allocagent.FieldOrganizationID:
  3804. m.ClearOrganizationID()
  3805. return nil
  3806. case allocagent.FieldStatus:
  3807. m.ClearStatus()
  3808. return nil
  3809. }
  3810. return fmt.Errorf("unknown AllocAgent nullable field %s", name)
  3811. }
  3812. // ResetField resets all changes in the mutation for the field with the given name.
  3813. // It returns an error if the field is not defined in the schema.
  3814. func (m *AllocAgentMutation) ResetField(name string) error {
  3815. switch name {
  3816. case allocagent.FieldCreatedAt:
  3817. m.ResetCreatedAt()
  3818. return nil
  3819. case allocagent.FieldUpdatedAt:
  3820. m.ResetUpdatedAt()
  3821. return nil
  3822. case allocagent.FieldDeletedAt:
  3823. m.ResetDeletedAt()
  3824. return nil
  3825. case allocagent.FieldUserID:
  3826. m.ResetUserID()
  3827. return nil
  3828. case allocagent.FieldOrganizationID:
  3829. m.ResetOrganizationID()
  3830. return nil
  3831. case allocagent.FieldAgents:
  3832. m.ResetAgents()
  3833. return nil
  3834. case allocagent.FieldStatus:
  3835. m.ResetStatus()
  3836. return nil
  3837. }
  3838. return fmt.Errorf("unknown AllocAgent field %s", name)
  3839. }
  3840. // AddedEdges returns all edge names that were set/added in this mutation.
  3841. func (m *AllocAgentMutation) AddedEdges() []string {
  3842. edges := make([]string, 0, 0)
  3843. return edges
  3844. }
  3845. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  3846. // name in this mutation.
  3847. func (m *AllocAgentMutation) AddedIDs(name string) []ent.Value {
  3848. return nil
  3849. }
  3850. // RemovedEdges returns all edge names that were removed in this mutation.
  3851. func (m *AllocAgentMutation) RemovedEdges() []string {
  3852. edges := make([]string, 0, 0)
  3853. return edges
  3854. }
  3855. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  3856. // the given name in this mutation.
  3857. func (m *AllocAgentMutation) RemovedIDs(name string) []ent.Value {
  3858. return nil
  3859. }
  3860. // ClearedEdges returns all edge names that were cleared in this mutation.
  3861. func (m *AllocAgentMutation) ClearedEdges() []string {
  3862. edges := make([]string, 0, 0)
  3863. return edges
  3864. }
  3865. // EdgeCleared returns a boolean which indicates if the edge with the given name
  3866. // was cleared in this mutation.
  3867. func (m *AllocAgentMutation) EdgeCleared(name string) bool {
  3868. return false
  3869. }
  3870. // ClearEdge clears the value of the edge with the given name. It returns an error
  3871. // if that edge is not defined in the schema.
  3872. func (m *AllocAgentMutation) ClearEdge(name string) error {
  3873. return fmt.Errorf("unknown AllocAgent unique edge %s", name)
  3874. }
  3875. // ResetEdge resets all changes to the edge with the given name in this mutation.
  3876. // It returns an error if the edge is not defined in the schema.
  3877. func (m *AllocAgentMutation) ResetEdge(name string) error {
  3878. return fmt.Errorf("unknown AllocAgent edge %s", name)
  3879. }
  3880. // BatchMsgMutation represents an operation that mutates the BatchMsg nodes in the graph.
  3881. type BatchMsgMutation struct {
  3882. config
  3883. op Op
  3884. typ string
  3885. id *uint64
  3886. created_at *time.Time
  3887. updated_at *time.Time
  3888. deleted_at *time.Time
  3889. status *uint8
  3890. addstatus *int8
  3891. batch_no *string
  3892. task_name *string
  3893. fromwxid *string
  3894. msg *string
  3895. tag *string
  3896. tagids *string
  3897. total *int32
  3898. addtotal *int32
  3899. success *int32
  3900. addsuccess *int32
  3901. fail *int32
  3902. addfail *int32
  3903. start_time *time.Time
  3904. stop_time *time.Time
  3905. send_time *time.Time
  3906. _type *int32
  3907. add_type *int32
  3908. organization_id *uint64
  3909. addorganization_id *int64
  3910. clearedFields map[string]struct{}
  3911. done bool
  3912. oldValue func(context.Context) (*BatchMsg, error)
  3913. predicates []predicate.BatchMsg
  3914. }
  3915. var _ ent.Mutation = (*BatchMsgMutation)(nil)
  3916. // batchmsgOption allows management of the mutation configuration using functional options.
  3917. type batchmsgOption func(*BatchMsgMutation)
  3918. // newBatchMsgMutation creates new mutation for the BatchMsg entity.
  3919. func newBatchMsgMutation(c config, op Op, opts ...batchmsgOption) *BatchMsgMutation {
  3920. m := &BatchMsgMutation{
  3921. config: c,
  3922. op: op,
  3923. typ: TypeBatchMsg,
  3924. clearedFields: make(map[string]struct{}),
  3925. }
  3926. for _, opt := range opts {
  3927. opt(m)
  3928. }
  3929. return m
  3930. }
  3931. // withBatchMsgID sets the ID field of the mutation.
  3932. func withBatchMsgID(id uint64) batchmsgOption {
  3933. return func(m *BatchMsgMutation) {
  3934. var (
  3935. err error
  3936. once sync.Once
  3937. value *BatchMsg
  3938. )
  3939. m.oldValue = func(ctx context.Context) (*BatchMsg, error) {
  3940. once.Do(func() {
  3941. if m.done {
  3942. err = errors.New("querying old values post mutation is not allowed")
  3943. } else {
  3944. value, err = m.Client().BatchMsg.Get(ctx, id)
  3945. }
  3946. })
  3947. return value, err
  3948. }
  3949. m.id = &id
  3950. }
  3951. }
  3952. // withBatchMsg sets the old BatchMsg of the mutation.
  3953. func withBatchMsg(node *BatchMsg) batchmsgOption {
  3954. return func(m *BatchMsgMutation) {
  3955. m.oldValue = func(context.Context) (*BatchMsg, error) {
  3956. return node, nil
  3957. }
  3958. m.id = &node.ID
  3959. }
  3960. }
  3961. // Client returns a new `ent.Client` from the mutation. If the mutation was
  3962. // executed in a transaction (ent.Tx), a transactional client is returned.
  3963. func (m BatchMsgMutation) Client() *Client {
  3964. client := &Client{config: m.config}
  3965. client.init()
  3966. return client
  3967. }
  3968. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  3969. // it returns an error otherwise.
  3970. func (m BatchMsgMutation) Tx() (*Tx, error) {
  3971. if _, ok := m.driver.(*txDriver); !ok {
  3972. return nil, errors.New("ent: mutation is not running in a transaction")
  3973. }
  3974. tx := &Tx{config: m.config}
  3975. tx.init()
  3976. return tx, nil
  3977. }
  3978. // SetID sets the value of the id field. Note that this
  3979. // operation is only accepted on creation of BatchMsg entities.
  3980. func (m *BatchMsgMutation) SetID(id uint64) {
  3981. m.id = &id
  3982. }
  3983. // ID returns the ID value in the mutation. Note that the ID is only available
  3984. // if it was provided to the builder or after it was returned from the database.
  3985. func (m *BatchMsgMutation) ID() (id uint64, exists bool) {
  3986. if m.id == nil {
  3987. return
  3988. }
  3989. return *m.id, true
  3990. }
  3991. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  3992. // That means, if the mutation is applied within a transaction with an isolation level such
  3993. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  3994. // or updated by the mutation.
  3995. func (m *BatchMsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  3996. switch {
  3997. case m.op.Is(OpUpdateOne | OpDeleteOne):
  3998. id, exists := m.ID()
  3999. if exists {
  4000. return []uint64{id}, nil
  4001. }
  4002. fallthrough
  4003. case m.op.Is(OpUpdate | OpDelete):
  4004. return m.Client().BatchMsg.Query().Where(m.predicates...).IDs(ctx)
  4005. default:
  4006. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  4007. }
  4008. }
  4009. // SetCreatedAt sets the "created_at" field.
  4010. func (m *BatchMsgMutation) SetCreatedAt(t time.Time) {
  4011. m.created_at = &t
  4012. }
  4013. // CreatedAt returns the value of the "created_at" field in the mutation.
  4014. func (m *BatchMsgMutation) CreatedAt() (r time.Time, exists bool) {
  4015. v := m.created_at
  4016. if v == nil {
  4017. return
  4018. }
  4019. return *v, true
  4020. }
  4021. // OldCreatedAt returns the old "created_at" field's value of the BatchMsg entity.
  4022. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4023. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4024. func (m *BatchMsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  4025. if !m.op.Is(OpUpdateOne) {
  4026. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  4027. }
  4028. if m.id == nil || m.oldValue == nil {
  4029. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  4030. }
  4031. oldValue, err := m.oldValue(ctx)
  4032. if err != nil {
  4033. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  4034. }
  4035. return oldValue.CreatedAt, nil
  4036. }
  4037. // ResetCreatedAt resets all changes to the "created_at" field.
  4038. func (m *BatchMsgMutation) ResetCreatedAt() {
  4039. m.created_at = nil
  4040. }
  4041. // SetUpdatedAt sets the "updated_at" field.
  4042. func (m *BatchMsgMutation) SetUpdatedAt(t time.Time) {
  4043. m.updated_at = &t
  4044. }
  4045. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  4046. func (m *BatchMsgMutation) UpdatedAt() (r time.Time, exists bool) {
  4047. v := m.updated_at
  4048. if v == nil {
  4049. return
  4050. }
  4051. return *v, true
  4052. }
  4053. // OldUpdatedAt returns the old "updated_at" field's value of the BatchMsg entity.
  4054. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4055. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4056. func (m *BatchMsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  4057. if !m.op.Is(OpUpdateOne) {
  4058. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  4059. }
  4060. if m.id == nil || m.oldValue == nil {
  4061. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  4062. }
  4063. oldValue, err := m.oldValue(ctx)
  4064. if err != nil {
  4065. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  4066. }
  4067. return oldValue.UpdatedAt, nil
  4068. }
  4069. // ResetUpdatedAt resets all changes to the "updated_at" field.
  4070. func (m *BatchMsgMutation) ResetUpdatedAt() {
  4071. m.updated_at = nil
  4072. }
  4073. // SetDeletedAt sets the "deleted_at" field.
  4074. func (m *BatchMsgMutation) SetDeletedAt(t time.Time) {
  4075. m.deleted_at = &t
  4076. }
  4077. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  4078. func (m *BatchMsgMutation) DeletedAt() (r time.Time, exists bool) {
  4079. v := m.deleted_at
  4080. if v == nil {
  4081. return
  4082. }
  4083. return *v, true
  4084. }
  4085. // OldDeletedAt returns the old "deleted_at" field's value of the BatchMsg entity.
  4086. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4088. func (m *BatchMsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  4089. if !m.op.Is(OpUpdateOne) {
  4090. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  4091. }
  4092. if m.id == nil || m.oldValue == nil {
  4093. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  4094. }
  4095. oldValue, err := m.oldValue(ctx)
  4096. if err != nil {
  4097. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  4098. }
  4099. return oldValue.DeletedAt, nil
  4100. }
  4101. // ClearDeletedAt clears the value of the "deleted_at" field.
  4102. func (m *BatchMsgMutation) ClearDeletedAt() {
  4103. m.deleted_at = nil
  4104. m.clearedFields[batchmsg.FieldDeletedAt] = struct{}{}
  4105. }
  4106. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  4107. func (m *BatchMsgMutation) DeletedAtCleared() bool {
  4108. _, ok := m.clearedFields[batchmsg.FieldDeletedAt]
  4109. return ok
  4110. }
  4111. // ResetDeletedAt resets all changes to the "deleted_at" field.
  4112. func (m *BatchMsgMutation) ResetDeletedAt() {
  4113. m.deleted_at = nil
  4114. delete(m.clearedFields, batchmsg.FieldDeletedAt)
  4115. }
  4116. // SetStatus sets the "status" field.
  4117. func (m *BatchMsgMutation) SetStatus(u uint8) {
  4118. m.status = &u
  4119. m.addstatus = nil
  4120. }
  4121. // Status returns the value of the "status" field in the mutation.
  4122. func (m *BatchMsgMutation) Status() (r uint8, exists bool) {
  4123. v := m.status
  4124. if v == nil {
  4125. return
  4126. }
  4127. return *v, true
  4128. }
  4129. // OldStatus returns the old "status" field's value of the BatchMsg entity.
  4130. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4131. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4132. func (m *BatchMsgMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  4133. if !m.op.Is(OpUpdateOne) {
  4134. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  4135. }
  4136. if m.id == nil || m.oldValue == nil {
  4137. return v, errors.New("OldStatus requires an ID field in the mutation")
  4138. }
  4139. oldValue, err := m.oldValue(ctx)
  4140. if err != nil {
  4141. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  4142. }
  4143. return oldValue.Status, nil
  4144. }
  4145. // AddStatus adds u to the "status" field.
  4146. func (m *BatchMsgMutation) AddStatus(u int8) {
  4147. if m.addstatus != nil {
  4148. *m.addstatus += u
  4149. } else {
  4150. m.addstatus = &u
  4151. }
  4152. }
  4153. // AddedStatus returns the value that was added to the "status" field in this mutation.
  4154. func (m *BatchMsgMutation) AddedStatus() (r int8, exists bool) {
  4155. v := m.addstatus
  4156. if v == nil {
  4157. return
  4158. }
  4159. return *v, true
  4160. }
  4161. // ClearStatus clears the value of the "status" field.
  4162. func (m *BatchMsgMutation) ClearStatus() {
  4163. m.status = nil
  4164. m.addstatus = nil
  4165. m.clearedFields[batchmsg.FieldStatus] = struct{}{}
  4166. }
  4167. // StatusCleared returns if the "status" field was cleared in this mutation.
  4168. func (m *BatchMsgMutation) StatusCleared() bool {
  4169. _, ok := m.clearedFields[batchmsg.FieldStatus]
  4170. return ok
  4171. }
  4172. // ResetStatus resets all changes to the "status" field.
  4173. func (m *BatchMsgMutation) ResetStatus() {
  4174. m.status = nil
  4175. m.addstatus = nil
  4176. delete(m.clearedFields, batchmsg.FieldStatus)
  4177. }
  4178. // SetBatchNo sets the "batch_no" field.
  4179. func (m *BatchMsgMutation) SetBatchNo(s string) {
  4180. m.batch_no = &s
  4181. }
  4182. // BatchNo returns the value of the "batch_no" field in the mutation.
  4183. func (m *BatchMsgMutation) BatchNo() (r string, exists bool) {
  4184. v := m.batch_no
  4185. if v == nil {
  4186. return
  4187. }
  4188. return *v, true
  4189. }
  4190. // OldBatchNo returns the old "batch_no" field's value of the BatchMsg entity.
  4191. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4192. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4193. func (m *BatchMsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  4194. if !m.op.Is(OpUpdateOne) {
  4195. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  4196. }
  4197. if m.id == nil || m.oldValue == nil {
  4198. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  4199. }
  4200. oldValue, err := m.oldValue(ctx)
  4201. if err != nil {
  4202. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  4203. }
  4204. return oldValue.BatchNo, nil
  4205. }
  4206. // ClearBatchNo clears the value of the "batch_no" field.
  4207. func (m *BatchMsgMutation) ClearBatchNo() {
  4208. m.batch_no = nil
  4209. m.clearedFields[batchmsg.FieldBatchNo] = struct{}{}
  4210. }
  4211. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  4212. func (m *BatchMsgMutation) BatchNoCleared() bool {
  4213. _, ok := m.clearedFields[batchmsg.FieldBatchNo]
  4214. return ok
  4215. }
  4216. // ResetBatchNo resets all changes to the "batch_no" field.
  4217. func (m *BatchMsgMutation) ResetBatchNo() {
  4218. m.batch_no = nil
  4219. delete(m.clearedFields, batchmsg.FieldBatchNo)
  4220. }
  4221. // SetTaskName sets the "task_name" field.
  4222. func (m *BatchMsgMutation) SetTaskName(s string) {
  4223. m.task_name = &s
  4224. }
  4225. // TaskName returns the value of the "task_name" field in the mutation.
  4226. func (m *BatchMsgMutation) TaskName() (r string, exists bool) {
  4227. v := m.task_name
  4228. if v == nil {
  4229. return
  4230. }
  4231. return *v, true
  4232. }
  4233. // OldTaskName returns the old "task_name" field's value of the BatchMsg entity.
  4234. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4235. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4236. func (m *BatchMsgMutation) OldTaskName(ctx context.Context) (v string, err error) {
  4237. if !m.op.Is(OpUpdateOne) {
  4238. return v, errors.New("OldTaskName is only allowed on UpdateOne operations")
  4239. }
  4240. if m.id == nil || m.oldValue == nil {
  4241. return v, errors.New("OldTaskName requires an ID field in the mutation")
  4242. }
  4243. oldValue, err := m.oldValue(ctx)
  4244. if err != nil {
  4245. return v, fmt.Errorf("querying old value for OldTaskName: %w", err)
  4246. }
  4247. return oldValue.TaskName, nil
  4248. }
  4249. // ClearTaskName clears the value of the "task_name" field.
  4250. func (m *BatchMsgMutation) ClearTaskName() {
  4251. m.task_name = nil
  4252. m.clearedFields[batchmsg.FieldTaskName] = struct{}{}
  4253. }
  4254. // TaskNameCleared returns if the "task_name" field was cleared in this mutation.
  4255. func (m *BatchMsgMutation) TaskNameCleared() bool {
  4256. _, ok := m.clearedFields[batchmsg.FieldTaskName]
  4257. return ok
  4258. }
  4259. // ResetTaskName resets all changes to the "task_name" field.
  4260. func (m *BatchMsgMutation) ResetTaskName() {
  4261. m.task_name = nil
  4262. delete(m.clearedFields, batchmsg.FieldTaskName)
  4263. }
  4264. // SetFromwxid sets the "fromwxid" field.
  4265. func (m *BatchMsgMutation) SetFromwxid(s string) {
  4266. m.fromwxid = &s
  4267. }
  4268. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  4269. func (m *BatchMsgMutation) Fromwxid() (r string, exists bool) {
  4270. v := m.fromwxid
  4271. if v == nil {
  4272. return
  4273. }
  4274. return *v, true
  4275. }
  4276. // OldFromwxid returns the old "fromwxid" field's value of the BatchMsg entity.
  4277. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4278. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4279. func (m *BatchMsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  4280. if !m.op.Is(OpUpdateOne) {
  4281. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  4282. }
  4283. if m.id == nil || m.oldValue == nil {
  4284. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  4285. }
  4286. oldValue, err := m.oldValue(ctx)
  4287. if err != nil {
  4288. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  4289. }
  4290. return oldValue.Fromwxid, nil
  4291. }
  4292. // ClearFromwxid clears the value of the "fromwxid" field.
  4293. func (m *BatchMsgMutation) ClearFromwxid() {
  4294. m.fromwxid = nil
  4295. m.clearedFields[batchmsg.FieldFromwxid] = struct{}{}
  4296. }
  4297. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  4298. func (m *BatchMsgMutation) FromwxidCleared() bool {
  4299. _, ok := m.clearedFields[batchmsg.FieldFromwxid]
  4300. return ok
  4301. }
  4302. // ResetFromwxid resets all changes to the "fromwxid" field.
  4303. func (m *BatchMsgMutation) ResetFromwxid() {
  4304. m.fromwxid = nil
  4305. delete(m.clearedFields, batchmsg.FieldFromwxid)
  4306. }
  4307. // SetMsg sets the "msg" field.
  4308. func (m *BatchMsgMutation) SetMsg(s string) {
  4309. m.msg = &s
  4310. }
  4311. // Msg returns the value of the "msg" field in the mutation.
  4312. func (m *BatchMsgMutation) Msg() (r string, exists bool) {
  4313. v := m.msg
  4314. if v == nil {
  4315. return
  4316. }
  4317. return *v, true
  4318. }
  4319. // OldMsg returns the old "msg" field's value of the BatchMsg entity.
  4320. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4321. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4322. func (m *BatchMsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  4323. if !m.op.Is(OpUpdateOne) {
  4324. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  4325. }
  4326. if m.id == nil || m.oldValue == nil {
  4327. return v, errors.New("OldMsg requires an ID field in the mutation")
  4328. }
  4329. oldValue, err := m.oldValue(ctx)
  4330. if err != nil {
  4331. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  4332. }
  4333. return oldValue.Msg, nil
  4334. }
  4335. // ClearMsg clears the value of the "msg" field.
  4336. func (m *BatchMsgMutation) ClearMsg() {
  4337. m.msg = nil
  4338. m.clearedFields[batchmsg.FieldMsg] = struct{}{}
  4339. }
  4340. // MsgCleared returns if the "msg" field was cleared in this mutation.
  4341. func (m *BatchMsgMutation) MsgCleared() bool {
  4342. _, ok := m.clearedFields[batchmsg.FieldMsg]
  4343. return ok
  4344. }
  4345. // ResetMsg resets all changes to the "msg" field.
  4346. func (m *BatchMsgMutation) ResetMsg() {
  4347. m.msg = nil
  4348. delete(m.clearedFields, batchmsg.FieldMsg)
  4349. }
  4350. // SetTag sets the "tag" field.
  4351. func (m *BatchMsgMutation) SetTag(s string) {
  4352. m.tag = &s
  4353. }
  4354. // Tag returns the value of the "tag" field in the mutation.
  4355. func (m *BatchMsgMutation) Tag() (r string, exists bool) {
  4356. v := m.tag
  4357. if v == nil {
  4358. return
  4359. }
  4360. return *v, true
  4361. }
  4362. // OldTag returns the old "tag" field's value of the BatchMsg entity.
  4363. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4364. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4365. func (m *BatchMsgMutation) OldTag(ctx context.Context) (v string, err error) {
  4366. if !m.op.Is(OpUpdateOne) {
  4367. return v, errors.New("OldTag is only allowed on UpdateOne operations")
  4368. }
  4369. if m.id == nil || m.oldValue == nil {
  4370. return v, errors.New("OldTag requires an ID field in the mutation")
  4371. }
  4372. oldValue, err := m.oldValue(ctx)
  4373. if err != nil {
  4374. return v, fmt.Errorf("querying old value for OldTag: %w", err)
  4375. }
  4376. return oldValue.Tag, nil
  4377. }
  4378. // ClearTag clears the value of the "tag" field.
  4379. func (m *BatchMsgMutation) ClearTag() {
  4380. m.tag = nil
  4381. m.clearedFields[batchmsg.FieldTag] = struct{}{}
  4382. }
  4383. // TagCleared returns if the "tag" field was cleared in this mutation.
  4384. func (m *BatchMsgMutation) TagCleared() bool {
  4385. _, ok := m.clearedFields[batchmsg.FieldTag]
  4386. return ok
  4387. }
  4388. // ResetTag resets all changes to the "tag" field.
  4389. func (m *BatchMsgMutation) ResetTag() {
  4390. m.tag = nil
  4391. delete(m.clearedFields, batchmsg.FieldTag)
  4392. }
  4393. // SetTagids sets the "tagids" field.
  4394. func (m *BatchMsgMutation) SetTagids(s string) {
  4395. m.tagids = &s
  4396. }
  4397. // Tagids returns the value of the "tagids" field in the mutation.
  4398. func (m *BatchMsgMutation) Tagids() (r string, exists bool) {
  4399. v := m.tagids
  4400. if v == nil {
  4401. return
  4402. }
  4403. return *v, true
  4404. }
  4405. // OldTagids returns the old "tagids" field's value of the BatchMsg entity.
  4406. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4407. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4408. func (m *BatchMsgMutation) OldTagids(ctx context.Context) (v string, err error) {
  4409. if !m.op.Is(OpUpdateOne) {
  4410. return v, errors.New("OldTagids is only allowed on UpdateOne operations")
  4411. }
  4412. if m.id == nil || m.oldValue == nil {
  4413. return v, errors.New("OldTagids requires an ID field in the mutation")
  4414. }
  4415. oldValue, err := m.oldValue(ctx)
  4416. if err != nil {
  4417. return v, fmt.Errorf("querying old value for OldTagids: %w", err)
  4418. }
  4419. return oldValue.Tagids, nil
  4420. }
  4421. // ClearTagids clears the value of the "tagids" field.
  4422. func (m *BatchMsgMutation) ClearTagids() {
  4423. m.tagids = nil
  4424. m.clearedFields[batchmsg.FieldTagids] = struct{}{}
  4425. }
  4426. // TagidsCleared returns if the "tagids" field was cleared in this mutation.
  4427. func (m *BatchMsgMutation) TagidsCleared() bool {
  4428. _, ok := m.clearedFields[batchmsg.FieldTagids]
  4429. return ok
  4430. }
  4431. // ResetTagids resets all changes to the "tagids" field.
  4432. func (m *BatchMsgMutation) ResetTagids() {
  4433. m.tagids = nil
  4434. delete(m.clearedFields, batchmsg.FieldTagids)
  4435. }
  4436. // SetTotal sets the "total" field.
  4437. func (m *BatchMsgMutation) SetTotal(i int32) {
  4438. m.total = &i
  4439. m.addtotal = nil
  4440. }
  4441. // Total returns the value of the "total" field in the mutation.
  4442. func (m *BatchMsgMutation) Total() (r int32, exists bool) {
  4443. v := m.total
  4444. if v == nil {
  4445. return
  4446. }
  4447. return *v, true
  4448. }
  4449. // OldTotal returns the old "total" field's value of the BatchMsg entity.
  4450. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4451. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4452. func (m *BatchMsgMutation) OldTotal(ctx context.Context) (v int32, err error) {
  4453. if !m.op.Is(OpUpdateOne) {
  4454. return v, errors.New("OldTotal is only allowed on UpdateOne operations")
  4455. }
  4456. if m.id == nil || m.oldValue == nil {
  4457. return v, errors.New("OldTotal requires an ID field in the mutation")
  4458. }
  4459. oldValue, err := m.oldValue(ctx)
  4460. if err != nil {
  4461. return v, fmt.Errorf("querying old value for OldTotal: %w", err)
  4462. }
  4463. return oldValue.Total, nil
  4464. }
  4465. // AddTotal adds i to the "total" field.
  4466. func (m *BatchMsgMutation) AddTotal(i int32) {
  4467. if m.addtotal != nil {
  4468. *m.addtotal += i
  4469. } else {
  4470. m.addtotal = &i
  4471. }
  4472. }
  4473. // AddedTotal returns the value that was added to the "total" field in this mutation.
  4474. func (m *BatchMsgMutation) AddedTotal() (r int32, exists bool) {
  4475. v := m.addtotal
  4476. if v == nil {
  4477. return
  4478. }
  4479. return *v, true
  4480. }
  4481. // ClearTotal clears the value of the "total" field.
  4482. func (m *BatchMsgMutation) ClearTotal() {
  4483. m.total = nil
  4484. m.addtotal = nil
  4485. m.clearedFields[batchmsg.FieldTotal] = struct{}{}
  4486. }
  4487. // TotalCleared returns if the "total" field was cleared in this mutation.
  4488. func (m *BatchMsgMutation) TotalCleared() bool {
  4489. _, ok := m.clearedFields[batchmsg.FieldTotal]
  4490. return ok
  4491. }
  4492. // ResetTotal resets all changes to the "total" field.
  4493. func (m *BatchMsgMutation) ResetTotal() {
  4494. m.total = nil
  4495. m.addtotal = nil
  4496. delete(m.clearedFields, batchmsg.FieldTotal)
  4497. }
  4498. // SetSuccess sets the "success" field.
  4499. func (m *BatchMsgMutation) SetSuccess(i int32) {
  4500. m.success = &i
  4501. m.addsuccess = nil
  4502. }
  4503. // Success returns the value of the "success" field in the mutation.
  4504. func (m *BatchMsgMutation) Success() (r int32, exists bool) {
  4505. v := m.success
  4506. if v == nil {
  4507. return
  4508. }
  4509. return *v, true
  4510. }
  4511. // OldSuccess returns the old "success" field's value of the BatchMsg entity.
  4512. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4514. func (m *BatchMsgMutation) OldSuccess(ctx context.Context) (v int32, err error) {
  4515. if !m.op.Is(OpUpdateOne) {
  4516. return v, errors.New("OldSuccess is only allowed on UpdateOne operations")
  4517. }
  4518. if m.id == nil || m.oldValue == nil {
  4519. return v, errors.New("OldSuccess requires an ID field in the mutation")
  4520. }
  4521. oldValue, err := m.oldValue(ctx)
  4522. if err != nil {
  4523. return v, fmt.Errorf("querying old value for OldSuccess: %w", err)
  4524. }
  4525. return oldValue.Success, nil
  4526. }
  4527. // AddSuccess adds i to the "success" field.
  4528. func (m *BatchMsgMutation) AddSuccess(i int32) {
  4529. if m.addsuccess != nil {
  4530. *m.addsuccess += i
  4531. } else {
  4532. m.addsuccess = &i
  4533. }
  4534. }
  4535. // AddedSuccess returns the value that was added to the "success" field in this mutation.
  4536. func (m *BatchMsgMutation) AddedSuccess() (r int32, exists bool) {
  4537. v := m.addsuccess
  4538. if v == nil {
  4539. return
  4540. }
  4541. return *v, true
  4542. }
  4543. // ClearSuccess clears the value of the "success" field.
  4544. func (m *BatchMsgMutation) ClearSuccess() {
  4545. m.success = nil
  4546. m.addsuccess = nil
  4547. m.clearedFields[batchmsg.FieldSuccess] = struct{}{}
  4548. }
  4549. // SuccessCleared returns if the "success" field was cleared in this mutation.
  4550. func (m *BatchMsgMutation) SuccessCleared() bool {
  4551. _, ok := m.clearedFields[batchmsg.FieldSuccess]
  4552. return ok
  4553. }
  4554. // ResetSuccess resets all changes to the "success" field.
  4555. func (m *BatchMsgMutation) ResetSuccess() {
  4556. m.success = nil
  4557. m.addsuccess = nil
  4558. delete(m.clearedFields, batchmsg.FieldSuccess)
  4559. }
  4560. // SetFail sets the "fail" field.
  4561. func (m *BatchMsgMutation) SetFail(i int32) {
  4562. m.fail = &i
  4563. m.addfail = nil
  4564. }
  4565. // Fail returns the value of the "fail" field in the mutation.
  4566. func (m *BatchMsgMutation) Fail() (r int32, exists bool) {
  4567. v := m.fail
  4568. if v == nil {
  4569. return
  4570. }
  4571. return *v, true
  4572. }
  4573. // OldFail returns the old "fail" field's value of the BatchMsg entity.
  4574. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4576. func (m *BatchMsgMutation) OldFail(ctx context.Context) (v int32, err error) {
  4577. if !m.op.Is(OpUpdateOne) {
  4578. return v, errors.New("OldFail is only allowed on UpdateOne operations")
  4579. }
  4580. if m.id == nil || m.oldValue == nil {
  4581. return v, errors.New("OldFail requires an ID field in the mutation")
  4582. }
  4583. oldValue, err := m.oldValue(ctx)
  4584. if err != nil {
  4585. return v, fmt.Errorf("querying old value for OldFail: %w", err)
  4586. }
  4587. return oldValue.Fail, nil
  4588. }
  4589. // AddFail adds i to the "fail" field.
  4590. func (m *BatchMsgMutation) AddFail(i int32) {
  4591. if m.addfail != nil {
  4592. *m.addfail += i
  4593. } else {
  4594. m.addfail = &i
  4595. }
  4596. }
  4597. // AddedFail returns the value that was added to the "fail" field in this mutation.
  4598. func (m *BatchMsgMutation) AddedFail() (r int32, exists bool) {
  4599. v := m.addfail
  4600. if v == nil {
  4601. return
  4602. }
  4603. return *v, true
  4604. }
  4605. // ClearFail clears the value of the "fail" field.
  4606. func (m *BatchMsgMutation) ClearFail() {
  4607. m.fail = nil
  4608. m.addfail = nil
  4609. m.clearedFields[batchmsg.FieldFail] = struct{}{}
  4610. }
  4611. // FailCleared returns if the "fail" field was cleared in this mutation.
  4612. func (m *BatchMsgMutation) FailCleared() bool {
  4613. _, ok := m.clearedFields[batchmsg.FieldFail]
  4614. return ok
  4615. }
  4616. // ResetFail resets all changes to the "fail" field.
  4617. func (m *BatchMsgMutation) ResetFail() {
  4618. m.fail = nil
  4619. m.addfail = nil
  4620. delete(m.clearedFields, batchmsg.FieldFail)
  4621. }
  4622. // SetStartTime sets the "start_time" field.
  4623. func (m *BatchMsgMutation) SetStartTime(t time.Time) {
  4624. m.start_time = &t
  4625. }
  4626. // StartTime returns the value of the "start_time" field in the mutation.
  4627. func (m *BatchMsgMutation) StartTime() (r time.Time, exists bool) {
  4628. v := m.start_time
  4629. if v == nil {
  4630. return
  4631. }
  4632. return *v, true
  4633. }
  4634. // OldStartTime returns the old "start_time" field's value of the BatchMsg entity.
  4635. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4637. func (m *BatchMsgMutation) OldStartTime(ctx context.Context) (v time.Time, err error) {
  4638. if !m.op.Is(OpUpdateOne) {
  4639. return v, errors.New("OldStartTime is only allowed on UpdateOne operations")
  4640. }
  4641. if m.id == nil || m.oldValue == nil {
  4642. return v, errors.New("OldStartTime requires an ID field in the mutation")
  4643. }
  4644. oldValue, err := m.oldValue(ctx)
  4645. if err != nil {
  4646. return v, fmt.Errorf("querying old value for OldStartTime: %w", err)
  4647. }
  4648. return oldValue.StartTime, nil
  4649. }
  4650. // ClearStartTime clears the value of the "start_time" field.
  4651. func (m *BatchMsgMutation) ClearStartTime() {
  4652. m.start_time = nil
  4653. m.clearedFields[batchmsg.FieldStartTime] = struct{}{}
  4654. }
  4655. // StartTimeCleared returns if the "start_time" field was cleared in this mutation.
  4656. func (m *BatchMsgMutation) StartTimeCleared() bool {
  4657. _, ok := m.clearedFields[batchmsg.FieldStartTime]
  4658. return ok
  4659. }
  4660. // ResetStartTime resets all changes to the "start_time" field.
  4661. func (m *BatchMsgMutation) ResetStartTime() {
  4662. m.start_time = nil
  4663. delete(m.clearedFields, batchmsg.FieldStartTime)
  4664. }
  4665. // SetStopTime sets the "stop_time" field.
  4666. func (m *BatchMsgMutation) SetStopTime(t time.Time) {
  4667. m.stop_time = &t
  4668. }
  4669. // StopTime returns the value of the "stop_time" field in the mutation.
  4670. func (m *BatchMsgMutation) StopTime() (r time.Time, exists bool) {
  4671. v := m.stop_time
  4672. if v == nil {
  4673. return
  4674. }
  4675. return *v, true
  4676. }
  4677. // OldStopTime returns the old "stop_time" field's value of the BatchMsg entity.
  4678. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4680. func (m *BatchMsgMutation) OldStopTime(ctx context.Context) (v time.Time, err error) {
  4681. if !m.op.Is(OpUpdateOne) {
  4682. return v, errors.New("OldStopTime is only allowed on UpdateOne operations")
  4683. }
  4684. if m.id == nil || m.oldValue == nil {
  4685. return v, errors.New("OldStopTime requires an ID field in the mutation")
  4686. }
  4687. oldValue, err := m.oldValue(ctx)
  4688. if err != nil {
  4689. return v, fmt.Errorf("querying old value for OldStopTime: %w", err)
  4690. }
  4691. return oldValue.StopTime, nil
  4692. }
  4693. // ClearStopTime clears the value of the "stop_time" field.
  4694. func (m *BatchMsgMutation) ClearStopTime() {
  4695. m.stop_time = nil
  4696. m.clearedFields[batchmsg.FieldStopTime] = struct{}{}
  4697. }
  4698. // StopTimeCleared returns if the "stop_time" field was cleared in this mutation.
  4699. func (m *BatchMsgMutation) StopTimeCleared() bool {
  4700. _, ok := m.clearedFields[batchmsg.FieldStopTime]
  4701. return ok
  4702. }
  4703. // ResetStopTime resets all changes to the "stop_time" field.
  4704. func (m *BatchMsgMutation) ResetStopTime() {
  4705. m.stop_time = nil
  4706. delete(m.clearedFields, batchmsg.FieldStopTime)
  4707. }
  4708. // SetSendTime sets the "send_time" field.
  4709. func (m *BatchMsgMutation) SetSendTime(t time.Time) {
  4710. m.send_time = &t
  4711. }
  4712. // SendTime returns the value of the "send_time" field in the mutation.
  4713. func (m *BatchMsgMutation) SendTime() (r time.Time, exists bool) {
  4714. v := m.send_time
  4715. if v == nil {
  4716. return
  4717. }
  4718. return *v, true
  4719. }
  4720. // OldSendTime returns the old "send_time" field's value of the BatchMsg entity.
  4721. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4723. func (m *BatchMsgMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  4724. if !m.op.Is(OpUpdateOne) {
  4725. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  4726. }
  4727. if m.id == nil || m.oldValue == nil {
  4728. return v, errors.New("OldSendTime requires an ID field in the mutation")
  4729. }
  4730. oldValue, err := m.oldValue(ctx)
  4731. if err != nil {
  4732. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  4733. }
  4734. return oldValue.SendTime, nil
  4735. }
  4736. // ClearSendTime clears the value of the "send_time" field.
  4737. func (m *BatchMsgMutation) ClearSendTime() {
  4738. m.send_time = nil
  4739. m.clearedFields[batchmsg.FieldSendTime] = struct{}{}
  4740. }
  4741. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  4742. func (m *BatchMsgMutation) SendTimeCleared() bool {
  4743. _, ok := m.clearedFields[batchmsg.FieldSendTime]
  4744. return ok
  4745. }
  4746. // ResetSendTime resets all changes to the "send_time" field.
  4747. func (m *BatchMsgMutation) ResetSendTime() {
  4748. m.send_time = nil
  4749. delete(m.clearedFields, batchmsg.FieldSendTime)
  4750. }
  4751. // SetType sets the "type" field.
  4752. func (m *BatchMsgMutation) SetType(i int32) {
  4753. m._type = &i
  4754. m.add_type = nil
  4755. }
  4756. // GetType returns the value of the "type" field in the mutation.
  4757. func (m *BatchMsgMutation) GetType() (r int32, exists bool) {
  4758. v := m._type
  4759. if v == nil {
  4760. return
  4761. }
  4762. return *v, true
  4763. }
  4764. // OldType returns the old "type" field's value of the BatchMsg entity.
  4765. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4767. func (m *BatchMsgMutation) OldType(ctx context.Context) (v int32, err error) {
  4768. if !m.op.Is(OpUpdateOne) {
  4769. return v, errors.New("OldType is only allowed on UpdateOne operations")
  4770. }
  4771. if m.id == nil || m.oldValue == nil {
  4772. return v, errors.New("OldType requires an ID field in the mutation")
  4773. }
  4774. oldValue, err := m.oldValue(ctx)
  4775. if err != nil {
  4776. return v, fmt.Errorf("querying old value for OldType: %w", err)
  4777. }
  4778. return oldValue.Type, nil
  4779. }
  4780. // AddType adds i to the "type" field.
  4781. func (m *BatchMsgMutation) AddType(i int32) {
  4782. if m.add_type != nil {
  4783. *m.add_type += i
  4784. } else {
  4785. m.add_type = &i
  4786. }
  4787. }
  4788. // AddedType returns the value that was added to the "type" field in this mutation.
  4789. func (m *BatchMsgMutation) AddedType() (r int32, exists bool) {
  4790. v := m.add_type
  4791. if v == nil {
  4792. return
  4793. }
  4794. return *v, true
  4795. }
  4796. // ClearType clears the value of the "type" field.
  4797. func (m *BatchMsgMutation) ClearType() {
  4798. m._type = nil
  4799. m.add_type = nil
  4800. m.clearedFields[batchmsg.FieldType] = struct{}{}
  4801. }
  4802. // TypeCleared returns if the "type" field was cleared in this mutation.
  4803. func (m *BatchMsgMutation) TypeCleared() bool {
  4804. _, ok := m.clearedFields[batchmsg.FieldType]
  4805. return ok
  4806. }
  4807. // ResetType resets all changes to the "type" field.
  4808. func (m *BatchMsgMutation) ResetType() {
  4809. m._type = nil
  4810. m.add_type = nil
  4811. delete(m.clearedFields, batchmsg.FieldType)
  4812. }
  4813. // SetOrganizationID sets the "organization_id" field.
  4814. func (m *BatchMsgMutation) SetOrganizationID(u uint64) {
  4815. m.organization_id = &u
  4816. m.addorganization_id = nil
  4817. }
  4818. // OrganizationID returns the value of the "organization_id" field in the mutation.
  4819. func (m *BatchMsgMutation) OrganizationID() (r uint64, exists bool) {
  4820. v := m.organization_id
  4821. if v == nil {
  4822. return
  4823. }
  4824. return *v, true
  4825. }
  4826. // OldOrganizationID returns the old "organization_id" field's value of the BatchMsg entity.
  4827. // If the BatchMsg object wasn't provided to the builder, the object is fetched from the database.
  4828. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  4829. func (m *BatchMsgMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  4830. if !m.op.Is(OpUpdateOne) {
  4831. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  4832. }
  4833. if m.id == nil || m.oldValue == nil {
  4834. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  4835. }
  4836. oldValue, err := m.oldValue(ctx)
  4837. if err != nil {
  4838. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  4839. }
  4840. return oldValue.OrganizationID, nil
  4841. }
  4842. // AddOrganizationID adds u to the "organization_id" field.
  4843. func (m *BatchMsgMutation) AddOrganizationID(u int64) {
  4844. if m.addorganization_id != nil {
  4845. *m.addorganization_id += u
  4846. } else {
  4847. m.addorganization_id = &u
  4848. }
  4849. }
  4850. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  4851. func (m *BatchMsgMutation) AddedOrganizationID() (r int64, exists bool) {
  4852. v := m.addorganization_id
  4853. if v == nil {
  4854. return
  4855. }
  4856. return *v, true
  4857. }
  4858. // ResetOrganizationID resets all changes to the "organization_id" field.
  4859. func (m *BatchMsgMutation) ResetOrganizationID() {
  4860. m.organization_id = nil
  4861. m.addorganization_id = nil
  4862. }
  4863. // Where appends a list predicates to the BatchMsgMutation builder.
  4864. func (m *BatchMsgMutation) Where(ps ...predicate.BatchMsg) {
  4865. m.predicates = append(m.predicates, ps...)
  4866. }
  4867. // WhereP appends storage-level predicates to the BatchMsgMutation builder. Using this method,
  4868. // users can use type-assertion to append predicates that do not depend on any generated package.
  4869. func (m *BatchMsgMutation) WhereP(ps ...func(*sql.Selector)) {
  4870. p := make([]predicate.BatchMsg, len(ps))
  4871. for i := range ps {
  4872. p[i] = ps[i]
  4873. }
  4874. m.Where(p...)
  4875. }
  4876. // Op returns the operation name.
  4877. func (m *BatchMsgMutation) Op() Op {
  4878. return m.op
  4879. }
  4880. // SetOp allows setting the mutation operation.
  4881. func (m *BatchMsgMutation) SetOp(op Op) {
  4882. m.op = op
  4883. }
  4884. // Type returns the node type of this mutation (BatchMsg).
  4885. func (m *BatchMsgMutation) Type() string {
  4886. return m.typ
  4887. }
  4888. // Fields returns all fields that were changed during this mutation. Note that in
  4889. // order to get all numeric fields that were incremented/decremented, call
  4890. // AddedFields().
  4891. func (m *BatchMsgMutation) Fields() []string {
  4892. fields := make([]string, 0, 18)
  4893. if m.created_at != nil {
  4894. fields = append(fields, batchmsg.FieldCreatedAt)
  4895. }
  4896. if m.updated_at != nil {
  4897. fields = append(fields, batchmsg.FieldUpdatedAt)
  4898. }
  4899. if m.deleted_at != nil {
  4900. fields = append(fields, batchmsg.FieldDeletedAt)
  4901. }
  4902. if m.status != nil {
  4903. fields = append(fields, batchmsg.FieldStatus)
  4904. }
  4905. if m.batch_no != nil {
  4906. fields = append(fields, batchmsg.FieldBatchNo)
  4907. }
  4908. if m.task_name != nil {
  4909. fields = append(fields, batchmsg.FieldTaskName)
  4910. }
  4911. if m.fromwxid != nil {
  4912. fields = append(fields, batchmsg.FieldFromwxid)
  4913. }
  4914. if m.msg != nil {
  4915. fields = append(fields, batchmsg.FieldMsg)
  4916. }
  4917. if m.tag != nil {
  4918. fields = append(fields, batchmsg.FieldTag)
  4919. }
  4920. if m.tagids != nil {
  4921. fields = append(fields, batchmsg.FieldTagids)
  4922. }
  4923. if m.total != nil {
  4924. fields = append(fields, batchmsg.FieldTotal)
  4925. }
  4926. if m.success != nil {
  4927. fields = append(fields, batchmsg.FieldSuccess)
  4928. }
  4929. if m.fail != nil {
  4930. fields = append(fields, batchmsg.FieldFail)
  4931. }
  4932. if m.start_time != nil {
  4933. fields = append(fields, batchmsg.FieldStartTime)
  4934. }
  4935. if m.stop_time != nil {
  4936. fields = append(fields, batchmsg.FieldStopTime)
  4937. }
  4938. if m.send_time != nil {
  4939. fields = append(fields, batchmsg.FieldSendTime)
  4940. }
  4941. if m._type != nil {
  4942. fields = append(fields, batchmsg.FieldType)
  4943. }
  4944. if m.organization_id != nil {
  4945. fields = append(fields, batchmsg.FieldOrganizationID)
  4946. }
  4947. return fields
  4948. }
  4949. // Field returns the value of a field with the given name. The second boolean
  4950. // return value indicates that this field was not set, or was not defined in the
  4951. // schema.
  4952. func (m *BatchMsgMutation) Field(name string) (ent.Value, bool) {
  4953. switch name {
  4954. case batchmsg.FieldCreatedAt:
  4955. return m.CreatedAt()
  4956. case batchmsg.FieldUpdatedAt:
  4957. return m.UpdatedAt()
  4958. case batchmsg.FieldDeletedAt:
  4959. return m.DeletedAt()
  4960. case batchmsg.FieldStatus:
  4961. return m.Status()
  4962. case batchmsg.FieldBatchNo:
  4963. return m.BatchNo()
  4964. case batchmsg.FieldTaskName:
  4965. return m.TaskName()
  4966. case batchmsg.FieldFromwxid:
  4967. return m.Fromwxid()
  4968. case batchmsg.FieldMsg:
  4969. return m.Msg()
  4970. case batchmsg.FieldTag:
  4971. return m.Tag()
  4972. case batchmsg.FieldTagids:
  4973. return m.Tagids()
  4974. case batchmsg.FieldTotal:
  4975. return m.Total()
  4976. case batchmsg.FieldSuccess:
  4977. return m.Success()
  4978. case batchmsg.FieldFail:
  4979. return m.Fail()
  4980. case batchmsg.FieldStartTime:
  4981. return m.StartTime()
  4982. case batchmsg.FieldStopTime:
  4983. return m.StopTime()
  4984. case batchmsg.FieldSendTime:
  4985. return m.SendTime()
  4986. case batchmsg.FieldType:
  4987. return m.GetType()
  4988. case batchmsg.FieldOrganizationID:
  4989. return m.OrganizationID()
  4990. }
  4991. return nil, false
  4992. }
  4993. // OldField returns the old value of the field from the database. An error is
  4994. // returned if the mutation operation is not UpdateOne, or the query to the
  4995. // database failed.
  4996. func (m *BatchMsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  4997. switch name {
  4998. case batchmsg.FieldCreatedAt:
  4999. return m.OldCreatedAt(ctx)
  5000. case batchmsg.FieldUpdatedAt:
  5001. return m.OldUpdatedAt(ctx)
  5002. case batchmsg.FieldDeletedAt:
  5003. return m.OldDeletedAt(ctx)
  5004. case batchmsg.FieldStatus:
  5005. return m.OldStatus(ctx)
  5006. case batchmsg.FieldBatchNo:
  5007. return m.OldBatchNo(ctx)
  5008. case batchmsg.FieldTaskName:
  5009. return m.OldTaskName(ctx)
  5010. case batchmsg.FieldFromwxid:
  5011. return m.OldFromwxid(ctx)
  5012. case batchmsg.FieldMsg:
  5013. return m.OldMsg(ctx)
  5014. case batchmsg.FieldTag:
  5015. return m.OldTag(ctx)
  5016. case batchmsg.FieldTagids:
  5017. return m.OldTagids(ctx)
  5018. case batchmsg.FieldTotal:
  5019. return m.OldTotal(ctx)
  5020. case batchmsg.FieldSuccess:
  5021. return m.OldSuccess(ctx)
  5022. case batchmsg.FieldFail:
  5023. return m.OldFail(ctx)
  5024. case batchmsg.FieldStartTime:
  5025. return m.OldStartTime(ctx)
  5026. case batchmsg.FieldStopTime:
  5027. return m.OldStopTime(ctx)
  5028. case batchmsg.FieldSendTime:
  5029. return m.OldSendTime(ctx)
  5030. case batchmsg.FieldType:
  5031. return m.OldType(ctx)
  5032. case batchmsg.FieldOrganizationID:
  5033. return m.OldOrganizationID(ctx)
  5034. }
  5035. return nil, fmt.Errorf("unknown BatchMsg field %s", name)
  5036. }
  5037. // SetField sets the value of a field with the given name. It returns an error if
  5038. // the field is not defined in the schema, or if the type mismatched the field
  5039. // type.
  5040. func (m *BatchMsgMutation) SetField(name string, value ent.Value) error {
  5041. switch name {
  5042. case batchmsg.FieldCreatedAt:
  5043. v, ok := value.(time.Time)
  5044. if !ok {
  5045. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5046. }
  5047. m.SetCreatedAt(v)
  5048. return nil
  5049. case batchmsg.FieldUpdatedAt:
  5050. v, ok := value.(time.Time)
  5051. if !ok {
  5052. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5053. }
  5054. m.SetUpdatedAt(v)
  5055. return nil
  5056. case batchmsg.FieldDeletedAt:
  5057. v, ok := value.(time.Time)
  5058. if !ok {
  5059. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5060. }
  5061. m.SetDeletedAt(v)
  5062. return nil
  5063. case batchmsg.FieldStatus:
  5064. v, ok := value.(uint8)
  5065. if !ok {
  5066. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5067. }
  5068. m.SetStatus(v)
  5069. return nil
  5070. case batchmsg.FieldBatchNo:
  5071. v, ok := value.(string)
  5072. if !ok {
  5073. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5074. }
  5075. m.SetBatchNo(v)
  5076. return nil
  5077. case batchmsg.FieldTaskName:
  5078. v, ok := value.(string)
  5079. if !ok {
  5080. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5081. }
  5082. m.SetTaskName(v)
  5083. return nil
  5084. case batchmsg.FieldFromwxid:
  5085. v, ok := value.(string)
  5086. if !ok {
  5087. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5088. }
  5089. m.SetFromwxid(v)
  5090. return nil
  5091. case batchmsg.FieldMsg:
  5092. v, ok := value.(string)
  5093. if !ok {
  5094. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5095. }
  5096. m.SetMsg(v)
  5097. return nil
  5098. case batchmsg.FieldTag:
  5099. v, ok := value.(string)
  5100. if !ok {
  5101. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5102. }
  5103. m.SetTag(v)
  5104. return nil
  5105. case batchmsg.FieldTagids:
  5106. v, ok := value.(string)
  5107. if !ok {
  5108. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5109. }
  5110. m.SetTagids(v)
  5111. return nil
  5112. case batchmsg.FieldTotal:
  5113. v, ok := value.(int32)
  5114. if !ok {
  5115. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5116. }
  5117. m.SetTotal(v)
  5118. return nil
  5119. case batchmsg.FieldSuccess:
  5120. v, ok := value.(int32)
  5121. if !ok {
  5122. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5123. }
  5124. m.SetSuccess(v)
  5125. return nil
  5126. case batchmsg.FieldFail:
  5127. v, ok := value.(int32)
  5128. if !ok {
  5129. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5130. }
  5131. m.SetFail(v)
  5132. return nil
  5133. case batchmsg.FieldStartTime:
  5134. v, ok := value.(time.Time)
  5135. if !ok {
  5136. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5137. }
  5138. m.SetStartTime(v)
  5139. return nil
  5140. case batchmsg.FieldStopTime:
  5141. v, ok := value.(time.Time)
  5142. if !ok {
  5143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5144. }
  5145. m.SetStopTime(v)
  5146. return nil
  5147. case batchmsg.FieldSendTime:
  5148. v, ok := value.(time.Time)
  5149. if !ok {
  5150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5151. }
  5152. m.SetSendTime(v)
  5153. return nil
  5154. case batchmsg.FieldType:
  5155. v, ok := value.(int32)
  5156. if !ok {
  5157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5158. }
  5159. m.SetType(v)
  5160. return nil
  5161. case batchmsg.FieldOrganizationID:
  5162. v, ok := value.(uint64)
  5163. if !ok {
  5164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5165. }
  5166. m.SetOrganizationID(v)
  5167. return nil
  5168. }
  5169. return fmt.Errorf("unknown BatchMsg field %s", name)
  5170. }
  5171. // AddedFields returns all numeric fields that were incremented/decremented during
  5172. // this mutation.
  5173. func (m *BatchMsgMutation) AddedFields() []string {
  5174. var fields []string
  5175. if m.addstatus != nil {
  5176. fields = append(fields, batchmsg.FieldStatus)
  5177. }
  5178. if m.addtotal != nil {
  5179. fields = append(fields, batchmsg.FieldTotal)
  5180. }
  5181. if m.addsuccess != nil {
  5182. fields = append(fields, batchmsg.FieldSuccess)
  5183. }
  5184. if m.addfail != nil {
  5185. fields = append(fields, batchmsg.FieldFail)
  5186. }
  5187. if m.add_type != nil {
  5188. fields = append(fields, batchmsg.FieldType)
  5189. }
  5190. if m.addorganization_id != nil {
  5191. fields = append(fields, batchmsg.FieldOrganizationID)
  5192. }
  5193. return fields
  5194. }
  5195. // AddedField returns the numeric value that was incremented/decremented on a field
  5196. // with the given name. The second boolean return value indicates that this field
  5197. // was not set, or was not defined in the schema.
  5198. func (m *BatchMsgMutation) AddedField(name string) (ent.Value, bool) {
  5199. switch name {
  5200. case batchmsg.FieldStatus:
  5201. return m.AddedStatus()
  5202. case batchmsg.FieldTotal:
  5203. return m.AddedTotal()
  5204. case batchmsg.FieldSuccess:
  5205. return m.AddedSuccess()
  5206. case batchmsg.FieldFail:
  5207. return m.AddedFail()
  5208. case batchmsg.FieldType:
  5209. return m.AddedType()
  5210. case batchmsg.FieldOrganizationID:
  5211. return m.AddedOrganizationID()
  5212. }
  5213. return nil, false
  5214. }
  5215. // AddField adds the value to the field with the given name. It returns an error if
  5216. // the field is not defined in the schema, or if the type mismatched the field
  5217. // type.
  5218. func (m *BatchMsgMutation) AddField(name string, value ent.Value) error {
  5219. switch name {
  5220. case batchmsg.FieldStatus:
  5221. v, ok := value.(int8)
  5222. if !ok {
  5223. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5224. }
  5225. m.AddStatus(v)
  5226. return nil
  5227. case batchmsg.FieldTotal:
  5228. v, ok := value.(int32)
  5229. if !ok {
  5230. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5231. }
  5232. m.AddTotal(v)
  5233. return nil
  5234. case batchmsg.FieldSuccess:
  5235. v, ok := value.(int32)
  5236. if !ok {
  5237. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5238. }
  5239. m.AddSuccess(v)
  5240. return nil
  5241. case batchmsg.FieldFail:
  5242. v, ok := value.(int32)
  5243. if !ok {
  5244. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5245. }
  5246. m.AddFail(v)
  5247. return nil
  5248. case batchmsg.FieldType:
  5249. v, ok := value.(int32)
  5250. if !ok {
  5251. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5252. }
  5253. m.AddType(v)
  5254. return nil
  5255. case batchmsg.FieldOrganizationID:
  5256. v, ok := value.(int64)
  5257. if !ok {
  5258. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5259. }
  5260. m.AddOrganizationID(v)
  5261. return nil
  5262. }
  5263. return fmt.Errorf("unknown BatchMsg numeric field %s", name)
  5264. }
  5265. // ClearedFields returns all nullable fields that were cleared during this
  5266. // mutation.
  5267. func (m *BatchMsgMutation) ClearedFields() []string {
  5268. var fields []string
  5269. if m.FieldCleared(batchmsg.FieldDeletedAt) {
  5270. fields = append(fields, batchmsg.FieldDeletedAt)
  5271. }
  5272. if m.FieldCleared(batchmsg.FieldStatus) {
  5273. fields = append(fields, batchmsg.FieldStatus)
  5274. }
  5275. if m.FieldCleared(batchmsg.FieldBatchNo) {
  5276. fields = append(fields, batchmsg.FieldBatchNo)
  5277. }
  5278. if m.FieldCleared(batchmsg.FieldTaskName) {
  5279. fields = append(fields, batchmsg.FieldTaskName)
  5280. }
  5281. if m.FieldCleared(batchmsg.FieldFromwxid) {
  5282. fields = append(fields, batchmsg.FieldFromwxid)
  5283. }
  5284. if m.FieldCleared(batchmsg.FieldMsg) {
  5285. fields = append(fields, batchmsg.FieldMsg)
  5286. }
  5287. if m.FieldCleared(batchmsg.FieldTag) {
  5288. fields = append(fields, batchmsg.FieldTag)
  5289. }
  5290. if m.FieldCleared(batchmsg.FieldTagids) {
  5291. fields = append(fields, batchmsg.FieldTagids)
  5292. }
  5293. if m.FieldCleared(batchmsg.FieldTotal) {
  5294. fields = append(fields, batchmsg.FieldTotal)
  5295. }
  5296. if m.FieldCleared(batchmsg.FieldSuccess) {
  5297. fields = append(fields, batchmsg.FieldSuccess)
  5298. }
  5299. if m.FieldCleared(batchmsg.FieldFail) {
  5300. fields = append(fields, batchmsg.FieldFail)
  5301. }
  5302. if m.FieldCleared(batchmsg.FieldStartTime) {
  5303. fields = append(fields, batchmsg.FieldStartTime)
  5304. }
  5305. if m.FieldCleared(batchmsg.FieldStopTime) {
  5306. fields = append(fields, batchmsg.FieldStopTime)
  5307. }
  5308. if m.FieldCleared(batchmsg.FieldSendTime) {
  5309. fields = append(fields, batchmsg.FieldSendTime)
  5310. }
  5311. if m.FieldCleared(batchmsg.FieldType) {
  5312. fields = append(fields, batchmsg.FieldType)
  5313. }
  5314. return fields
  5315. }
  5316. // FieldCleared returns a boolean indicating if a field with the given name was
  5317. // cleared in this mutation.
  5318. func (m *BatchMsgMutation) FieldCleared(name string) bool {
  5319. _, ok := m.clearedFields[name]
  5320. return ok
  5321. }
  5322. // ClearField clears the value of the field with the given name. It returns an
  5323. // error if the field is not defined in the schema.
  5324. func (m *BatchMsgMutation) ClearField(name string) error {
  5325. switch name {
  5326. case batchmsg.FieldDeletedAt:
  5327. m.ClearDeletedAt()
  5328. return nil
  5329. case batchmsg.FieldStatus:
  5330. m.ClearStatus()
  5331. return nil
  5332. case batchmsg.FieldBatchNo:
  5333. m.ClearBatchNo()
  5334. return nil
  5335. case batchmsg.FieldTaskName:
  5336. m.ClearTaskName()
  5337. return nil
  5338. case batchmsg.FieldFromwxid:
  5339. m.ClearFromwxid()
  5340. return nil
  5341. case batchmsg.FieldMsg:
  5342. m.ClearMsg()
  5343. return nil
  5344. case batchmsg.FieldTag:
  5345. m.ClearTag()
  5346. return nil
  5347. case batchmsg.FieldTagids:
  5348. m.ClearTagids()
  5349. return nil
  5350. case batchmsg.FieldTotal:
  5351. m.ClearTotal()
  5352. return nil
  5353. case batchmsg.FieldSuccess:
  5354. m.ClearSuccess()
  5355. return nil
  5356. case batchmsg.FieldFail:
  5357. m.ClearFail()
  5358. return nil
  5359. case batchmsg.FieldStartTime:
  5360. m.ClearStartTime()
  5361. return nil
  5362. case batchmsg.FieldStopTime:
  5363. m.ClearStopTime()
  5364. return nil
  5365. case batchmsg.FieldSendTime:
  5366. m.ClearSendTime()
  5367. return nil
  5368. case batchmsg.FieldType:
  5369. m.ClearType()
  5370. return nil
  5371. }
  5372. return fmt.Errorf("unknown BatchMsg nullable field %s", name)
  5373. }
  5374. // ResetField resets all changes in the mutation for the field with the given name.
  5375. // It returns an error if the field is not defined in the schema.
  5376. func (m *BatchMsgMutation) ResetField(name string) error {
  5377. switch name {
  5378. case batchmsg.FieldCreatedAt:
  5379. m.ResetCreatedAt()
  5380. return nil
  5381. case batchmsg.FieldUpdatedAt:
  5382. m.ResetUpdatedAt()
  5383. return nil
  5384. case batchmsg.FieldDeletedAt:
  5385. m.ResetDeletedAt()
  5386. return nil
  5387. case batchmsg.FieldStatus:
  5388. m.ResetStatus()
  5389. return nil
  5390. case batchmsg.FieldBatchNo:
  5391. m.ResetBatchNo()
  5392. return nil
  5393. case batchmsg.FieldTaskName:
  5394. m.ResetTaskName()
  5395. return nil
  5396. case batchmsg.FieldFromwxid:
  5397. m.ResetFromwxid()
  5398. return nil
  5399. case batchmsg.FieldMsg:
  5400. m.ResetMsg()
  5401. return nil
  5402. case batchmsg.FieldTag:
  5403. m.ResetTag()
  5404. return nil
  5405. case batchmsg.FieldTagids:
  5406. m.ResetTagids()
  5407. return nil
  5408. case batchmsg.FieldTotal:
  5409. m.ResetTotal()
  5410. return nil
  5411. case batchmsg.FieldSuccess:
  5412. m.ResetSuccess()
  5413. return nil
  5414. case batchmsg.FieldFail:
  5415. m.ResetFail()
  5416. return nil
  5417. case batchmsg.FieldStartTime:
  5418. m.ResetStartTime()
  5419. return nil
  5420. case batchmsg.FieldStopTime:
  5421. m.ResetStopTime()
  5422. return nil
  5423. case batchmsg.FieldSendTime:
  5424. m.ResetSendTime()
  5425. return nil
  5426. case batchmsg.FieldType:
  5427. m.ResetType()
  5428. return nil
  5429. case batchmsg.FieldOrganizationID:
  5430. m.ResetOrganizationID()
  5431. return nil
  5432. }
  5433. return fmt.Errorf("unknown BatchMsg field %s", name)
  5434. }
  5435. // AddedEdges returns all edge names that were set/added in this mutation.
  5436. func (m *BatchMsgMutation) AddedEdges() []string {
  5437. edges := make([]string, 0, 0)
  5438. return edges
  5439. }
  5440. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5441. // name in this mutation.
  5442. func (m *BatchMsgMutation) AddedIDs(name string) []ent.Value {
  5443. return nil
  5444. }
  5445. // RemovedEdges returns all edge names that were removed in this mutation.
  5446. func (m *BatchMsgMutation) RemovedEdges() []string {
  5447. edges := make([]string, 0, 0)
  5448. return edges
  5449. }
  5450. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5451. // the given name in this mutation.
  5452. func (m *BatchMsgMutation) RemovedIDs(name string) []ent.Value {
  5453. return nil
  5454. }
  5455. // ClearedEdges returns all edge names that were cleared in this mutation.
  5456. func (m *BatchMsgMutation) ClearedEdges() []string {
  5457. edges := make([]string, 0, 0)
  5458. return edges
  5459. }
  5460. // EdgeCleared returns a boolean which indicates if the edge with the given name
  5461. // was cleared in this mutation.
  5462. func (m *BatchMsgMutation) EdgeCleared(name string) bool {
  5463. return false
  5464. }
  5465. // ClearEdge clears the value of the edge with the given name. It returns an error
  5466. // if that edge is not defined in the schema.
  5467. func (m *BatchMsgMutation) ClearEdge(name string) error {
  5468. return fmt.Errorf("unknown BatchMsg unique edge %s", name)
  5469. }
  5470. // ResetEdge resets all changes to the edge with the given name in this mutation.
  5471. // It returns an error if the edge is not defined in the schema.
  5472. func (m *BatchMsgMutation) ResetEdge(name string) error {
  5473. return fmt.Errorf("unknown BatchMsg edge %s", name)
  5474. }
  5475. // CategoryMutation represents an operation that mutates the Category nodes in the graph.
  5476. type CategoryMutation struct {
  5477. config
  5478. op Op
  5479. typ string
  5480. id *uint64
  5481. created_at *time.Time
  5482. updated_at *time.Time
  5483. deleted_at *time.Time
  5484. name *string
  5485. organization_id *uint64
  5486. addorganization_id *int64
  5487. clearedFields map[string]struct{}
  5488. done bool
  5489. oldValue func(context.Context) (*Category, error)
  5490. predicates []predicate.Category
  5491. }
  5492. var _ ent.Mutation = (*CategoryMutation)(nil)
  5493. // categoryOption allows management of the mutation configuration using functional options.
  5494. type categoryOption func(*CategoryMutation)
  5495. // newCategoryMutation creates new mutation for the Category entity.
  5496. func newCategoryMutation(c config, op Op, opts ...categoryOption) *CategoryMutation {
  5497. m := &CategoryMutation{
  5498. config: c,
  5499. op: op,
  5500. typ: TypeCategory,
  5501. clearedFields: make(map[string]struct{}),
  5502. }
  5503. for _, opt := range opts {
  5504. opt(m)
  5505. }
  5506. return m
  5507. }
  5508. // withCategoryID sets the ID field of the mutation.
  5509. func withCategoryID(id uint64) categoryOption {
  5510. return func(m *CategoryMutation) {
  5511. var (
  5512. err error
  5513. once sync.Once
  5514. value *Category
  5515. )
  5516. m.oldValue = func(ctx context.Context) (*Category, error) {
  5517. once.Do(func() {
  5518. if m.done {
  5519. err = errors.New("querying old values post mutation is not allowed")
  5520. } else {
  5521. value, err = m.Client().Category.Get(ctx, id)
  5522. }
  5523. })
  5524. return value, err
  5525. }
  5526. m.id = &id
  5527. }
  5528. }
  5529. // withCategory sets the old Category of the mutation.
  5530. func withCategory(node *Category) categoryOption {
  5531. return func(m *CategoryMutation) {
  5532. m.oldValue = func(context.Context) (*Category, error) {
  5533. return node, nil
  5534. }
  5535. m.id = &node.ID
  5536. }
  5537. }
  5538. // Client returns a new `ent.Client` from the mutation. If the mutation was
  5539. // executed in a transaction (ent.Tx), a transactional client is returned.
  5540. func (m CategoryMutation) Client() *Client {
  5541. client := &Client{config: m.config}
  5542. client.init()
  5543. return client
  5544. }
  5545. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  5546. // it returns an error otherwise.
  5547. func (m CategoryMutation) Tx() (*Tx, error) {
  5548. if _, ok := m.driver.(*txDriver); !ok {
  5549. return nil, errors.New("ent: mutation is not running in a transaction")
  5550. }
  5551. tx := &Tx{config: m.config}
  5552. tx.init()
  5553. return tx, nil
  5554. }
  5555. // SetID sets the value of the id field. Note that this
  5556. // operation is only accepted on creation of Category entities.
  5557. func (m *CategoryMutation) SetID(id uint64) {
  5558. m.id = &id
  5559. }
  5560. // ID returns the ID value in the mutation. Note that the ID is only available
  5561. // if it was provided to the builder or after it was returned from the database.
  5562. func (m *CategoryMutation) ID() (id uint64, exists bool) {
  5563. if m.id == nil {
  5564. return
  5565. }
  5566. return *m.id, true
  5567. }
  5568. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  5569. // That means, if the mutation is applied within a transaction with an isolation level such
  5570. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  5571. // or updated by the mutation.
  5572. func (m *CategoryMutation) IDs(ctx context.Context) ([]uint64, error) {
  5573. switch {
  5574. case m.op.Is(OpUpdateOne | OpDeleteOne):
  5575. id, exists := m.ID()
  5576. if exists {
  5577. return []uint64{id}, nil
  5578. }
  5579. fallthrough
  5580. case m.op.Is(OpUpdate | OpDelete):
  5581. return m.Client().Category.Query().Where(m.predicates...).IDs(ctx)
  5582. default:
  5583. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  5584. }
  5585. }
  5586. // SetCreatedAt sets the "created_at" field.
  5587. func (m *CategoryMutation) SetCreatedAt(t time.Time) {
  5588. m.created_at = &t
  5589. }
  5590. // CreatedAt returns the value of the "created_at" field in the mutation.
  5591. func (m *CategoryMutation) CreatedAt() (r time.Time, exists bool) {
  5592. v := m.created_at
  5593. if v == nil {
  5594. return
  5595. }
  5596. return *v, true
  5597. }
  5598. // OldCreatedAt returns the old "created_at" field's value of the Category entity.
  5599. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5600. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5601. func (m *CategoryMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  5602. if !m.op.Is(OpUpdateOne) {
  5603. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  5604. }
  5605. if m.id == nil || m.oldValue == nil {
  5606. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  5607. }
  5608. oldValue, err := m.oldValue(ctx)
  5609. if err != nil {
  5610. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  5611. }
  5612. return oldValue.CreatedAt, nil
  5613. }
  5614. // ResetCreatedAt resets all changes to the "created_at" field.
  5615. func (m *CategoryMutation) ResetCreatedAt() {
  5616. m.created_at = nil
  5617. }
  5618. // SetUpdatedAt sets the "updated_at" field.
  5619. func (m *CategoryMutation) SetUpdatedAt(t time.Time) {
  5620. m.updated_at = &t
  5621. }
  5622. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  5623. func (m *CategoryMutation) UpdatedAt() (r time.Time, exists bool) {
  5624. v := m.updated_at
  5625. if v == nil {
  5626. return
  5627. }
  5628. return *v, true
  5629. }
  5630. // OldUpdatedAt returns the old "updated_at" field's value of the Category entity.
  5631. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5632. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5633. func (m *CategoryMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  5634. if !m.op.Is(OpUpdateOne) {
  5635. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  5636. }
  5637. if m.id == nil || m.oldValue == nil {
  5638. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  5639. }
  5640. oldValue, err := m.oldValue(ctx)
  5641. if err != nil {
  5642. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  5643. }
  5644. return oldValue.UpdatedAt, nil
  5645. }
  5646. // ResetUpdatedAt resets all changes to the "updated_at" field.
  5647. func (m *CategoryMutation) ResetUpdatedAt() {
  5648. m.updated_at = nil
  5649. }
  5650. // SetDeletedAt sets the "deleted_at" field.
  5651. func (m *CategoryMutation) SetDeletedAt(t time.Time) {
  5652. m.deleted_at = &t
  5653. }
  5654. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  5655. func (m *CategoryMutation) DeletedAt() (r time.Time, exists bool) {
  5656. v := m.deleted_at
  5657. if v == nil {
  5658. return
  5659. }
  5660. return *v, true
  5661. }
  5662. // OldDeletedAt returns the old "deleted_at" field's value of the Category entity.
  5663. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5665. func (m *CategoryMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  5666. if !m.op.Is(OpUpdateOne) {
  5667. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  5668. }
  5669. if m.id == nil || m.oldValue == nil {
  5670. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  5671. }
  5672. oldValue, err := m.oldValue(ctx)
  5673. if err != nil {
  5674. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  5675. }
  5676. return oldValue.DeletedAt, nil
  5677. }
  5678. // ClearDeletedAt clears the value of the "deleted_at" field.
  5679. func (m *CategoryMutation) ClearDeletedAt() {
  5680. m.deleted_at = nil
  5681. m.clearedFields[category.FieldDeletedAt] = struct{}{}
  5682. }
  5683. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  5684. func (m *CategoryMutation) DeletedAtCleared() bool {
  5685. _, ok := m.clearedFields[category.FieldDeletedAt]
  5686. return ok
  5687. }
  5688. // ResetDeletedAt resets all changes to the "deleted_at" field.
  5689. func (m *CategoryMutation) ResetDeletedAt() {
  5690. m.deleted_at = nil
  5691. delete(m.clearedFields, category.FieldDeletedAt)
  5692. }
  5693. // SetName sets the "name" field.
  5694. func (m *CategoryMutation) SetName(s string) {
  5695. m.name = &s
  5696. }
  5697. // Name returns the value of the "name" field in the mutation.
  5698. func (m *CategoryMutation) Name() (r string, exists bool) {
  5699. v := m.name
  5700. if v == nil {
  5701. return
  5702. }
  5703. return *v, true
  5704. }
  5705. // OldName returns the old "name" field's value of the Category entity.
  5706. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5708. func (m *CategoryMutation) OldName(ctx context.Context) (v string, err error) {
  5709. if !m.op.Is(OpUpdateOne) {
  5710. return v, errors.New("OldName is only allowed on UpdateOne operations")
  5711. }
  5712. if m.id == nil || m.oldValue == nil {
  5713. return v, errors.New("OldName requires an ID field in the mutation")
  5714. }
  5715. oldValue, err := m.oldValue(ctx)
  5716. if err != nil {
  5717. return v, fmt.Errorf("querying old value for OldName: %w", err)
  5718. }
  5719. return oldValue.Name, nil
  5720. }
  5721. // ResetName resets all changes to the "name" field.
  5722. func (m *CategoryMutation) ResetName() {
  5723. m.name = nil
  5724. }
  5725. // SetOrganizationID sets the "organization_id" field.
  5726. func (m *CategoryMutation) SetOrganizationID(u uint64) {
  5727. m.organization_id = &u
  5728. m.addorganization_id = nil
  5729. }
  5730. // OrganizationID returns the value of the "organization_id" field in the mutation.
  5731. func (m *CategoryMutation) OrganizationID() (r uint64, exists bool) {
  5732. v := m.organization_id
  5733. if v == nil {
  5734. return
  5735. }
  5736. return *v, true
  5737. }
  5738. // OldOrganizationID returns the old "organization_id" field's value of the Category entity.
  5739. // If the Category object wasn't provided to the builder, the object is fetched from the database.
  5740. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  5741. func (m *CategoryMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  5742. if !m.op.Is(OpUpdateOne) {
  5743. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  5744. }
  5745. if m.id == nil || m.oldValue == nil {
  5746. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  5747. }
  5748. oldValue, err := m.oldValue(ctx)
  5749. if err != nil {
  5750. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  5751. }
  5752. return oldValue.OrganizationID, nil
  5753. }
  5754. // AddOrganizationID adds u to the "organization_id" field.
  5755. func (m *CategoryMutation) AddOrganizationID(u int64) {
  5756. if m.addorganization_id != nil {
  5757. *m.addorganization_id += u
  5758. } else {
  5759. m.addorganization_id = &u
  5760. }
  5761. }
  5762. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  5763. func (m *CategoryMutation) AddedOrganizationID() (r int64, exists bool) {
  5764. v := m.addorganization_id
  5765. if v == nil {
  5766. return
  5767. }
  5768. return *v, true
  5769. }
  5770. // ResetOrganizationID resets all changes to the "organization_id" field.
  5771. func (m *CategoryMutation) ResetOrganizationID() {
  5772. m.organization_id = nil
  5773. m.addorganization_id = nil
  5774. }
  5775. // Where appends a list predicates to the CategoryMutation builder.
  5776. func (m *CategoryMutation) Where(ps ...predicate.Category) {
  5777. m.predicates = append(m.predicates, ps...)
  5778. }
  5779. // WhereP appends storage-level predicates to the CategoryMutation builder. Using this method,
  5780. // users can use type-assertion to append predicates that do not depend on any generated package.
  5781. func (m *CategoryMutation) WhereP(ps ...func(*sql.Selector)) {
  5782. p := make([]predicate.Category, len(ps))
  5783. for i := range ps {
  5784. p[i] = ps[i]
  5785. }
  5786. m.Where(p...)
  5787. }
  5788. // Op returns the operation name.
  5789. func (m *CategoryMutation) Op() Op {
  5790. return m.op
  5791. }
  5792. // SetOp allows setting the mutation operation.
  5793. func (m *CategoryMutation) SetOp(op Op) {
  5794. m.op = op
  5795. }
  5796. // Type returns the node type of this mutation (Category).
  5797. func (m *CategoryMutation) Type() string {
  5798. return m.typ
  5799. }
  5800. // Fields returns all fields that were changed during this mutation. Note that in
  5801. // order to get all numeric fields that were incremented/decremented, call
  5802. // AddedFields().
  5803. func (m *CategoryMutation) Fields() []string {
  5804. fields := make([]string, 0, 5)
  5805. if m.created_at != nil {
  5806. fields = append(fields, category.FieldCreatedAt)
  5807. }
  5808. if m.updated_at != nil {
  5809. fields = append(fields, category.FieldUpdatedAt)
  5810. }
  5811. if m.deleted_at != nil {
  5812. fields = append(fields, category.FieldDeletedAt)
  5813. }
  5814. if m.name != nil {
  5815. fields = append(fields, category.FieldName)
  5816. }
  5817. if m.organization_id != nil {
  5818. fields = append(fields, category.FieldOrganizationID)
  5819. }
  5820. return fields
  5821. }
  5822. // Field returns the value of a field with the given name. The second boolean
  5823. // return value indicates that this field was not set, or was not defined in the
  5824. // schema.
  5825. func (m *CategoryMutation) Field(name string) (ent.Value, bool) {
  5826. switch name {
  5827. case category.FieldCreatedAt:
  5828. return m.CreatedAt()
  5829. case category.FieldUpdatedAt:
  5830. return m.UpdatedAt()
  5831. case category.FieldDeletedAt:
  5832. return m.DeletedAt()
  5833. case category.FieldName:
  5834. return m.Name()
  5835. case category.FieldOrganizationID:
  5836. return m.OrganizationID()
  5837. }
  5838. return nil, false
  5839. }
  5840. // OldField returns the old value of the field from the database. An error is
  5841. // returned if the mutation operation is not UpdateOne, or the query to the
  5842. // database failed.
  5843. func (m *CategoryMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  5844. switch name {
  5845. case category.FieldCreatedAt:
  5846. return m.OldCreatedAt(ctx)
  5847. case category.FieldUpdatedAt:
  5848. return m.OldUpdatedAt(ctx)
  5849. case category.FieldDeletedAt:
  5850. return m.OldDeletedAt(ctx)
  5851. case category.FieldName:
  5852. return m.OldName(ctx)
  5853. case category.FieldOrganizationID:
  5854. return m.OldOrganizationID(ctx)
  5855. }
  5856. return nil, fmt.Errorf("unknown Category field %s", name)
  5857. }
  5858. // SetField sets the value of a field with the given name. It returns an error if
  5859. // the field is not defined in the schema, or if the type mismatched the field
  5860. // type.
  5861. func (m *CategoryMutation) SetField(name string, value ent.Value) error {
  5862. switch name {
  5863. case category.FieldCreatedAt:
  5864. v, ok := value.(time.Time)
  5865. if !ok {
  5866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5867. }
  5868. m.SetCreatedAt(v)
  5869. return nil
  5870. case category.FieldUpdatedAt:
  5871. v, ok := value.(time.Time)
  5872. if !ok {
  5873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5874. }
  5875. m.SetUpdatedAt(v)
  5876. return nil
  5877. case category.FieldDeletedAt:
  5878. v, ok := value.(time.Time)
  5879. if !ok {
  5880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5881. }
  5882. m.SetDeletedAt(v)
  5883. return nil
  5884. case category.FieldName:
  5885. v, ok := value.(string)
  5886. if !ok {
  5887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5888. }
  5889. m.SetName(v)
  5890. return nil
  5891. case category.FieldOrganizationID:
  5892. v, ok := value.(uint64)
  5893. if !ok {
  5894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5895. }
  5896. m.SetOrganizationID(v)
  5897. return nil
  5898. }
  5899. return fmt.Errorf("unknown Category field %s", name)
  5900. }
  5901. // AddedFields returns all numeric fields that were incremented/decremented during
  5902. // this mutation.
  5903. func (m *CategoryMutation) AddedFields() []string {
  5904. var fields []string
  5905. if m.addorganization_id != nil {
  5906. fields = append(fields, category.FieldOrganizationID)
  5907. }
  5908. return fields
  5909. }
  5910. // AddedField returns the numeric value that was incremented/decremented on a field
  5911. // with the given name. The second boolean return value indicates that this field
  5912. // was not set, or was not defined in the schema.
  5913. func (m *CategoryMutation) AddedField(name string) (ent.Value, bool) {
  5914. switch name {
  5915. case category.FieldOrganizationID:
  5916. return m.AddedOrganizationID()
  5917. }
  5918. return nil, false
  5919. }
  5920. // AddField adds the value to the field with the given name. It returns an error if
  5921. // the field is not defined in the schema, or if the type mismatched the field
  5922. // type.
  5923. func (m *CategoryMutation) AddField(name string, value ent.Value) error {
  5924. switch name {
  5925. case category.FieldOrganizationID:
  5926. v, ok := value.(int64)
  5927. if !ok {
  5928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  5929. }
  5930. m.AddOrganizationID(v)
  5931. return nil
  5932. }
  5933. return fmt.Errorf("unknown Category numeric field %s", name)
  5934. }
  5935. // ClearedFields returns all nullable fields that were cleared during this
  5936. // mutation.
  5937. func (m *CategoryMutation) ClearedFields() []string {
  5938. var fields []string
  5939. if m.FieldCleared(category.FieldDeletedAt) {
  5940. fields = append(fields, category.FieldDeletedAt)
  5941. }
  5942. return fields
  5943. }
  5944. // FieldCleared returns a boolean indicating if a field with the given name was
  5945. // cleared in this mutation.
  5946. func (m *CategoryMutation) FieldCleared(name string) bool {
  5947. _, ok := m.clearedFields[name]
  5948. return ok
  5949. }
  5950. // ClearField clears the value of the field with the given name. It returns an
  5951. // error if the field is not defined in the schema.
  5952. func (m *CategoryMutation) ClearField(name string) error {
  5953. switch name {
  5954. case category.FieldDeletedAt:
  5955. m.ClearDeletedAt()
  5956. return nil
  5957. }
  5958. return fmt.Errorf("unknown Category nullable field %s", name)
  5959. }
  5960. // ResetField resets all changes in the mutation for the field with the given name.
  5961. // It returns an error if the field is not defined in the schema.
  5962. func (m *CategoryMutation) ResetField(name string) error {
  5963. switch name {
  5964. case category.FieldCreatedAt:
  5965. m.ResetCreatedAt()
  5966. return nil
  5967. case category.FieldUpdatedAt:
  5968. m.ResetUpdatedAt()
  5969. return nil
  5970. case category.FieldDeletedAt:
  5971. m.ResetDeletedAt()
  5972. return nil
  5973. case category.FieldName:
  5974. m.ResetName()
  5975. return nil
  5976. case category.FieldOrganizationID:
  5977. m.ResetOrganizationID()
  5978. return nil
  5979. }
  5980. return fmt.Errorf("unknown Category field %s", name)
  5981. }
  5982. // AddedEdges returns all edge names that were set/added in this mutation.
  5983. func (m *CategoryMutation) AddedEdges() []string {
  5984. edges := make([]string, 0, 0)
  5985. return edges
  5986. }
  5987. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  5988. // name in this mutation.
  5989. func (m *CategoryMutation) AddedIDs(name string) []ent.Value {
  5990. return nil
  5991. }
  5992. // RemovedEdges returns all edge names that were removed in this mutation.
  5993. func (m *CategoryMutation) RemovedEdges() []string {
  5994. edges := make([]string, 0, 0)
  5995. return edges
  5996. }
  5997. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  5998. // the given name in this mutation.
  5999. func (m *CategoryMutation) RemovedIDs(name string) []ent.Value {
  6000. return nil
  6001. }
  6002. // ClearedEdges returns all edge names that were cleared in this mutation.
  6003. func (m *CategoryMutation) ClearedEdges() []string {
  6004. edges := make([]string, 0, 0)
  6005. return edges
  6006. }
  6007. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6008. // was cleared in this mutation.
  6009. func (m *CategoryMutation) EdgeCleared(name string) bool {
  6010. return false
  6011. }
  6012. // ClearEdge clears the value of the edge with the given name. It returns an error
  6013. // if that edge is not defined in the schema.
  6014. func (m *CategoryMutation) ClearEdge(name string) error {
  6015. return fmt.Errorf("unknown Category unique edge %s", name)
  6016. }
  6017. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6018. // It returns an error if the edge is not defined in the schema.
  6019. func (m *CategoryMutation) ResetEdge(name string) error {
  6020. return fmt.Errorf("unknown Category edge %s", name)
  6021. }
  6022. // ChatRecordsMutation represents an operation that mutates the ChatRecords nodes in the graph.
  6023. type ChatRecordsMutation struct {
  6024. config
  6025. op Op
  6026. typ string
  6027. id *uint64
  6028. created_at *time.Time
  6029. updated_at *time.Time
  6030. deleted_at *time.Time
  6031. content *string
  6032. content_type *uint8
  6033. addcontent_type *int8
  6034. session_id *uint64
  6035. addsession_id *int64
  6036. user_id *uint64
  6037. adduser_id *int64
  6038. bot_id *uint64
  6039. addbot_id *int64
  6040. bot_type *uint8
  6041. addbot_type *int8
  6042. clearedFields map[string]struct{}
  6043. done bool
  6044. oldValue func(context.Context) (*ChatRecords, error)
  6045. predicates []predicate.ChatRecords
  6046. }
  6047. var _ ent.Mutation = (*ChatRecordsMutation)(nil)
  6048. // chatrecordsOption allows management of the mutation configuration using functional options.
  6049. type chatrecordsOption func(*ChatRecordsMutation)
  6050. // newChatRecordsMutation creates new mutation for the ChatRecords entity.
  6051. func newChatRecordsMutation(c config, op Op, opts ...chatrecordsOption) *ChatRecordsMutation {
  6052. m := &ChatRecordsMutation{
  6053. config: c,
  6054. op: op,
  6055. typ: TypeChatRecords,
  6056. clearedFields: make(map[string]struct{}),
  6057. }
  6058. for _, opt := range opts {
  6059. opt(m)
  6060. }
  6061. return m
  6062. }
  6063. // withChatRecordsID sets the ID field of the mutation.
  6064. func withChatRecordsID(id uint64) chatrecordsOption {
  6065. return func(m *ChatRecordsMutation) {
  6066. var (
  6067. err error
  6068. once sync.Once
  6069. value *ChatRecords
  6070. )
  6071. m.oldValue = func(ctx context.Context) (*ChatRecords, error) {
  6072. once.Do(func() {
  6073. if m.done {
  6074. err = errors.New("querying old values post mutation is not allowed")
  6075. } else {
  6076. value, err = m.Client().ChatRecords.Get(ctx, id)
  6077. }
  6078. })
  6079. return value, err
  6080. }
  6081. m.id = &id
  6082. }
  6083. }
  6084. // withChatRecords sets the old ChatRecords of the mutation.
  6085. func withChatRecords(node *ChatRecords) chatrecordsOption {
  6086. return func(m *ChatRecordsMutation) {
  6087. m.oldValue = func(context.Context) (*ChatRecords, error) {
  6088. return node, nil
  6089. }
  6090. m.id = &node.ID
  6091. }
  6092. }
  6093. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6094. // executed in a transaction (ent.Tx), a transactional client is returned.
  6095. func (m ChatRecordsMutation) Client() *Client {
  6096. client := &Client{config: m.config}
  6097. client.init()
  6098. return client
  6099. }
  6100. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6101. // it returns an error otherwise.
  6102. func (m ChatRecordsMutation) Tx() (*Tx, error) {
  6103. if _, ok := m.driver.(*txDriver); !ok {
  6104. return nil, errors.New("ent: mutation is not running in a transaction")
  6105. }
  6106. tx := &Tx{config: m.config}
  6107. tx.init()
  6108. return tx, nil
  6109. }
  6110. // SetID sets the value of the id field. Note that this
  6111. // operation is only accepted on creation of ChatRecords entities.
  6112. func (m *ChatRecordsMutation) SetID(id uint64) {
  6113. m.id = &id
  6114. }
  6115. // ID returns the ID value in the mutation. Note that the ID is only available
  6116. // if it was provided to the builder or after it was returned from the database.
  6117. func (m *ChatRecordsMutation) ID() (id uint64, exists bool) {
  6118. if m.id == nil {
  6119. return
  6120. }
  6121. return *m.id, true
  6122. }
  6123. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6124. // That means, if the mutation is applied within a transaction with an isolation level such
  6125. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6126. // or updated by the mutation.
  6127. func (m *ChatRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  6128. switch {
  6129. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6130. id, exists := m.ID()
  6131. if exists {
  6132. return []uint64{id}, nil
  6133. }
  6134. fallthrough
  6135. case m.op.Is(OpUpdate | OpDelete):
  6136. return m.Client().ChatRecords.Query().Where(m.predicates...).IDs(ctx)
  6137. default:
  6138. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  6139. }
  6140. }
  6141. // SetCreatedAt sets the "created_at" field.
  6142. func (m *ChatRecordsMutation) SetCreatedAt(t time.Time) {
  6143. m.created_at = &t
  6144. }
  6145. // CreatedAt returns the value of the "created_at" field in the mutation.
  6146. func (m *ChatRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  6147. v := m.created_at
  6148. if v == nil {
  6149. return
  6150. }
  6151. return *v, true
  6152. }
  6153. // OldCreatedAt returns the old "created_at" field's value of the ChatRecords entity.
  6154. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6156. func (m *ChatRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  6157. if !m.op.Is(OpUpdateOne) {
  6158. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  6159. }
  6160. if m.id == nil || m.oldValue == nil {
  6161. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  6162. }
  6163. oldValue, err := m.oldValue(ctx)
  6164. if err != nil {
  6165. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  6166. }
  6167. return oldValue.CreatedAt, nil
  6168. }
  6169. // ResetCreatedAt resets all changes to the "created_at" field.
  6170. func (m *ChatRecordsMutation) ResetCreatedAt() {
  6171. m.created_at = nil
  6172. }
  6173. // SetUpdatedAt sets the "updated_at" field.
  6174. func (m *ChatRecordsMutation) SetUpdatedAt(t time.Time) {
  6175. m.updated_at = &t
  6176. }
  6177. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  6178. func (m *ChatRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  6179. v := m.updated_at
  6180. if v == nil {
  6181. return
  6182. }
  6183. return *v, true
  6184. }
  6185. // OldUpdatedAt returns the old "updated_at" field's value of the ChatRecords entity.
  6186. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6187. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6188. func (m *ChatRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  6189. if !m.op.Is(OpUpdateOne) {
  6190. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  6191. }
  6192. if m.id == nil || m.oldValue == nil {
  6193. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  6194. }
  6195. oldValue, err := m.oldValue(ctx)
  6196. if err != nil {
  6197. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  6198. }
  6199. return oldValue.UpdatedAt, nil
  6200. }
  6201. // ResetUpdatedAt resets all changes to the "updated_at" field.
  6202. func (m *ChatRecordsMutation) ResetUpdatedAt() {
  6203. m.updated_at = nil
  6204. }
  6205. // SetDeletedAt sets the "deleted_at" field.
  6206. func (m *ChatRecordsMutation) SetDeletedAt(t time.Time) {
  6207. m.deleted_at = &t
  6208. }
  6209. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  6210. func (m *ChatRecordsMutation) DeletedAt() (r time.Time, exists bool) {
  6211. v := m.deleted_at
  6212. if v == nil {
  6213. return
  6214. }
  6215. return *v, true
  6216. }
  6217. // OldDeletedAt returns the old "deleted_at" field's value of the ChatRecords entity.
  6218. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6219. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6220. func (m *ChatRecordsMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  6221. if !m.op.Is(OpUpdateOne) {
  6222. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  6223. }
  6224. if m.id == nil || m.oldValue == nil {
  6225. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  6226. }
  6227. oldValue, err := m.oldValue(ctx)
  6228. if err != nil {
  6229. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  6230. }
  6231. return oldValue.DeletedAt, nil
  6232. }
  6233. // ClearDeletedAt clears the value of the "deleted_at" field.
  6234. func (m *ChatRecordsMutation) ClearDeletedAt() {
  6235. m.deleted_at = nil
  6236. m.clearedFields[chatrecords.FieldDeletedAt] = struct{}{}
  6237. }
  6238. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  6239. func (m *ChatRecordsMutation) DeletedAtCleared() bool {
  6240. _, ok := m.clearedFields[chatrecords.FieldDeletedAt]
  6241. return ok
  6242. }
  6243. // ResetDeletedAt resets all changes to the "deleted_at" field.
  6244. func (m *ChatRecordsMutation) ResetDeletedAt() {
  6245. m.deleted_at = nil
  6246. delete(m.clearedFields, chatrecords.FieldDeletedAt)
  6247. }
  6248. // SetContent sets the "content" field.
  6249. func (m *ChatRecordsMutation) SetContent(s string) {
  6250. m.content = &s
  6251. }
  6252. // Content returns the value of the "content" field in the mutation.
  6253. func (m *ChatRecordsMutation) Content() (r string, exists bool) {
  6254. v := m.content
  6255. if v == nil {
  6256. return
  6257. }
  6258. return *v, true
  6259. }
  6260. // OldContent returns the old "content" field's value of the ChatRecords entity.
  6261. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6263. func (m *ChatRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  6264. if !m.op.Is(OpUpdateOne) {
  6265. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  6266. }
  6267. if m.id == nil || m.oldValue == nil {
  6268. return v, errors.New("OldContent requires an ID field in the mutation")
  6269. }
  6270. oldValue, err := m.oldValue(ctx)
  6271. if err != nil {
  6272. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  6273. }
  6274. return oldValue.Content, nil
  6275. }
  6276. // ResetContent resets all changes to the "content" field.
  6277. func (m *ChatRecordsMutation) ResetContent() {
  6278. m.content = nil
  6279. }
  6280. // SetContentType sets the "content_type" field.
  6281. func (m *ChatRecordsMutation) SetContentType(u uint8) {
  6282. m.content_type = &u
  6283. m.addcontent_type = nil
  6284. }
  6285. // ContentType returns the value of the "content_type" field in the mutation.
  6286. func (m *ChatRecordsMutation) ContentType() (r uint8, exists bool) {
  6287. v := m.content_type
  6288. if v == nil {
  6289. return
  6290. }
  6291. return *v, true
  6292. }
  6293. // OldContentType returns the old "content_type" field's value of the ChatRecords entity.
  6294. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6295. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6296. func (m *ChatRecordsMutation) OldContentType(ctx context.Context) (v uint8, err error) {
  6297. if !m.op.Is(OpUpdateOne) {
  6298. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  6299. }
  6300. if m.id == nil || m.oldValue == nil {
  6301. return v, errors.New("OldContentType requires an ID field in the mutation")
  6302. }
  6303. oldValue, err := m.oldValue(ctx)
  6304. if err != nil {
  6305. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  6306. }
  6307. return oldValue.ContentType, nil
  6308. }
  6309. // AddContentType adds u to the "content_type" field.
  6310. func (m *ChatRecordsMutation) AddContentType(u int8) {
  6311. if m.addcontent_type != nil {
  6312. *m.addcontent_type += u
  6313. } else {
  6314. m.addcontent_type = &u
  6315. }
  6316. }
  6317. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  6318. func (m *ChatRecordsMutation) AddedContentType() (r int8, exists bool) {
  6319. v := m.addcontent_type
  6320. if v == nil {
  6321. return
  6322. }
  6323. return *v, true
  6324. }
  6325. // ResetContentType resets all changes to the "content_type" field.
  6326. func (m *ChatRecordsMutation) ResetContentType() {
  6327. m.content_type = nil
  6328. m.addcontent_type = nil
  6329. }
  6330. // SetSessionID sets the "session_id" field.
  6331. func (m *ChatRecordsMutation) SetSessionID(u uint64) {
  6332. m.session_id = &u
  6333. m.addsession_id = nil
  6334. }
  6335. // SessionID returns the value of the "session_id" field in the mutation.
  6336. func (m *ChatRecordsMutation) SessionID() (r uint64, exists bool) {
  6337. v := m.session_id
  6338. if v == nil {
  6339. return
  6340. }
  6341. return *v, true
  6342. }
  6343. // OldSessionID returns the old "session_id" field's value of the ChatRecords entity.
  6344. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6345. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6346. func (m *ChatRecordsMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  6347. if !m.op.Is(OpUpdateOne) {
  6348. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  6349. }
  6350. if m.id == nil || m.oldValue == nil {
  6351. return v, errors.New("OldSessionID requires an ID field in the mutation")
  6352. }
  6353. oldValue, err := m.oldValue(ctx)
  6354. if err != nil {
  6355. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  6356. }
  6357. return oldValue.SessionID, nil
  6358. }
  6359. // AddSessionID adds u to the "session_id" field.
  6360. func (m *ChatRecordsMutation) AddSessionID(u int64) {
  6361. if m.addsession_id != nil {
  6362. *m.addsession_id += u
  6363. } else {
  6364. m.addsession_id = &u
  6365. }
  6366. }
  6367. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  6368. func (m *ChatRecordsMutation) AddedSessionID() (r int64, exists bool) {
  6369. v := m.addsession_id
  6370. if v == nil {
  6371. return
  6372. }
  6373. return *v, true
  6374. }
  6375. // ResetSessionID resets all changes to the "session_id" field.
  6376. func (m *ChatRecordsMutation) ResetSessionID() {
  6377. m.session_id = nil
  6378. m.addsession_id = nil
  6379. }
  6380. // SetUserID sets the "user_id" field.
  6381. func (m *ChatRecordsMutation) SetUserID(u uint64) {
  6382. m.user_id = &u
  6383. m.adduser_id = nil
  6384. }
  6385. // UserID returns the value of the "user_id" field in the mutation.
  6386. func (m *ChatRecordsMutation) UserID() (r uint64, exists bool) {
  6387. v := m.user_id
  6388. if v == nil {
  6389. return
  6390. }
  6391. return *v, true
  6392. }
  6393. // OldUserID returns the old "user_id" field's value of the ChatRecords entity.
  6394. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6395. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6396. func (m *ChatRecordsMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  6397. if !m.op.Is(OpUpdateOne) {
  6398. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  6399. }
  6400. if m.id == nil || m.oldValue == nil {
  6401. return v, errors.New("OldUserID requires an ID field in the mutation")
  6402. }
  6403. oldValue, err := m.oldValue(ctx)
  6404. if err != nil {
  6405. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  6406. }
  6407. return oldValue.UserID, nil
  6408. }
  6409. // AddUserID adds u to the "user_id" field.
  6410. func (m *ChatRecordsMutation) AddUserID(u int64) {
  6411. if m.adduser_id != nil {
  6412. *m.adduser_id += u
  6413. } else {
  6414. m.adduser_id = &u
  6415. }
  6416. }
  6417. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  6418. func (m *ChatRecordsMutation) AddedUserID() (r int64, exists bool) {
  6419. v := m.adduser_id
  6420. if v == nil {
  6421. return
  6422. }
  6423. return *v, true
  6424. }
  6425. // ResetUserID resets all changes to the "user_id" field.
  6426. func (m *ChatRecordsMutation) ResetUserID() {
  6427. m.user_id = nil
  6428. m.adduser_id = nil
  6429. }
  6430. // SetBotID sets the "bot_id" field.
  6431. func (m *ChatRecordsMutation) SetBotID(u uint64) {
  6432. m.bot_id = &u
  6433. m.addbot_id = nil
  6434. }
  6435. // BotID returns the value of the "bot_id" field in the mutation.
  6436. func (m *ChatRecordsMutation) BotID() (r uint64, exists bool) {
  6437. v := m.bot_id
  6438. if v == nil {
  6439. return
  6440. }
  6441. return *v, true
  6442. }
  6443. // OldBotID returns the old "bot_id" field's value of the ChatRecords entity.
  6444. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6446. func (m *ChatRecordsMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  6447. if !m.op.Is(OpUpdateOne) {
  6448. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  6449. }
  6450. if m.id == nil || m.oldValue == nil {
  6451. return v, errors.New("OldBotID requires an ID field in the mutation")
  6452. }
  6453. oldValue, err := m.oldValue(ctx)
  6454. if err != nil {
  6455. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  6456. }
  6457. return oldValue.BotID, nil
  6458. }
  6459. // AddBotID adds u to the "bot_id" field.
  6460. func (m *ChatRecordsMutation) AddBotID(u int64) {
  6461. if m.addbot_id != nil {
  6462. *m.addbot_id += u
  6463. } else {
  6464. m.addbot_id = &u
  6465. }
  6466. }
  6467. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  6468. func (m *ChatRecordsMutation) AddedBotID() (r int64, exists bool) {
  6469. v := m.addbot_id
  6470. if v == nil {
  6471. return
  6472. }
  6473. return *v, true
  6474. }
  6475. // ResetBotID resets all changes to the "bot_id" field.
  6476. func (m *ChatRecordsMutation) ResetBotID() {
  6477. m.bot_id = nil
  6478. m.addbot_id = nil
  6479. }
  6480. // SetBotType sets the "bot_type" field.
  6481. func (m *ChatRecordsMutation) SetBotType(u uint8) {
  6482. m.bot_type = &u
  6483. m.addbot_type = nil
  6484. }
  6485. // BotType returns the value of the "bot_type" field in the mutation.
  6486. func (m *ChatRecordsMutation) BotType() (r uint8, exists bool) {
  6487. v := m.bot_type
  6488. if v == nil {
  6489. return
  6490. }
  6491. return *v, true
  6492. }
  6493. // OldBotType returns the old "bot_type" field's value of the ChatRecords entity.
  6494. // If the ChatRecords object wasn't provided to the builder, the object is fetched from the database.
  6495. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  6496. func (m *ChatRecordsMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  6497. if !m.op.Is(OpUpdateOne) {
  6498. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  6499. }
  6500. if m.id == nil || m.oldValue == nil {
  6501. return v, errors.New("OldBotType requires an ID field in the mutation")
  6502. }
  6503. oldValue, err := m.oldValue(ctx)
  6504. if err != nil {
  6505. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  6506. }
  6507. return oldValue.BotType, nil
  6508. }
  6509. // AddBotType adds u to the "bot_type" field.
  6510. func (m *ChatRecordsMutation) AddBotType(u int8) {
  6511. if m.addbot_type != nil {
  6512. *m.addbot_type += u
  6513. } else {
  6514. m.addbot_type = &u
  6515. }
  6516. }
  6517. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  6518. func (m *ChatRecordsMutation) AddedBotType() (r int8, exists bool) {
  6519. v := m.addbot_type
  6520. if v == nil {
  6521. return
  6522. }
  6523. return *v, true
  6524. }
  6525. // ResetBotType resets all changes to the "bot_type" field.
  6526. func (m *ChatRecordsMutation) ResetBotType() {
  6527. m.bot_type = nil
  6528. m.addbot_type = nil
  6529. }
  6530. // Where appends a list predicates to the ChatRecordsMutation builder.
  6531. func (m *ChatRecordsMutation) Where(ps ...predicate.ChatRecords) {
  6532. m.predicates = append(m.predicates, ps...)
  6533. }
  6534. // WhereP appends storage-level predicates to the ChatRecordsMutation builder. Using this method,
  6535. // users can use type-assertion to append predicates that do not depend on any generated package.
  6536. func (m *ChatRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  6537. p := make([]predicate.ChatRecords, len(ps))
  6538. for i := range ps {
  6539. p[i] = ps[i]
  6540. }
  6541. m.Where(p...)
  6542. }
  6543. // Op returns the operation name.
  6544. func (m *ChatRecordsMutation) Op() Op {
  6545. return m.op
  6546. }
  6547. // SetOp allows setting the mutation operation.
  6548. func (m *ChatRecordsMutation) SetOp(op Op) {
  6549. m.op = op
  6550. }
  6551. // Type returns the node type of this mutation (ChatRecords).
  6552. func (m *ChatRecordsMutation) Type() string {
  6553. return m.typ
  6554. }
  6555. // Fields returns all fields that were changed during this mutation. Note that in
  6556. // order to get all numeric fields that were incremented/decremented, call
  6557. // AddedFields().
  6558. func (m *ChatRecordsMutation) Fields() []string {
  6559. fields := make([]string, 0, 9)
  6560. if m.created_at != nil {
  6561. fields = append(fields, chatrecords.FieldCreatedAt)
  6562. }
  6563. if m.updated_at != nil {
  6564. fields = append(fields, chatrecords.FieldUpdatedAt)
  6565. }
  6566. if m.deleted_at != nil {
  6567. fields = append(fields, chatrecords.FieldDeletedAt)
  6568. }
  6569. if m.content != nil {
  6570. fields = append(fields, chatrecords.FieldContent)
  6571. }
  6572. if m.content_type != nil {
  6573. fields = append(fields, chatrecords.FieldContentType)
  6574. }
  6575. if m.session_id != nil {
  6576. fields = append(fields, chatrecords.FieldSessionID)
  6577. }
  6578. if m.user_id != nil {
  6579. fields = append(fields, chatrecords.FieldUserID)
  6580. }
  6581. if m.bot_id != nil {
  6582. fields = append(fields, chatrecords.FieldBotID)
  6583. }
  6584. if m.bot_type != nil {
  6585. fields = append(fields, chatrecords.FieldBotType)
  6586. }
  6587. return fields
  6588. }
  6589. // Field returns the value of a field with the given name. The second boolean
  6590. // return value indicates that this field was not set, or was not defined in the
  6591. // schema.
  6592. func (m *ChatRecordsMutation) Field(name string) (ent.Value, bool) {
  6593. switch name {
  6594. case chatrecords.FieldCreatedAt:
  6595. return m.CreatedAt()
  6596. case chatrecords.FieldUpdatedAt:
  6597. return m.UpdatedAt()
  6598. case chatrecords.FieldDeletedAt:
  6599. return m.DeletedAt()
  6600. case chatrecords.FieldContent:
  6601. return m.Content()
  6602. case chatrecords.FieldContentType:
  6603. return m.ContentType()
  6604. case chatrecords.FieldSessionID:
  6605. return m.SessionID()
  6606. case chatrecords.FieldUserID:
  6607. return m.UserID()
  6608. case chatrecords.FieldBotID:
  6609. return m.BotID()
  6610. case chatrecords.FieldBotType:
  6611. return m.BotType()
  6612. }
  6613. return nil, false
  6614. }
  6615. // OldField returns the old value of the field from the database. An error is
  6616. // returned if the mutation operation is not UpdateOne, or the query to the
  6617. // database failed.
  6618. func (m *ChatRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  6619. switch name {
  6620. case chatrecords.FieldCreatedAt:
  6621. return m.OldCreatedAt(ctx)
  6622. case chatrecords.FieldUpdatedAt:
  6623. return m.OldUpdatedAt(ctx)
  6624. case chatrecords.FieldDeletedAt:
  6625. return m.OldDeletedAt(ctx)
  6626. case chatrecords.FieldContent:
  6627. return m.OldContent(ctx)
  6628. case chatrecords.FieldContentType:
  6629. return m.OldContentType(ctx)
  6630. case chatrecords.FieldSessionID:
  6631. return m.OldSessionID(ctx)
  6632. case chatrecords.FieldUserID:
  6633. return m.OldUserID(ctx)
  6634. case chatrecords.FieldBotID:
  6635. return m.OldBotID(ctx)
  6636. case chatrecords.FieldBotType:
  6637. return m.OldBotType(ctx)
  6638. }
  6639. return nil, fmt.Errorf("unknown ChatRecords field %s", name)
  6640. }
  6641. // SetField sets the value of a field with the given name. It returns an error if
  6642. // the field is not defined in the schema, or if the type mismatched the field
  6643. // type.
  6644. func (m *ChatRecordsMutation) SetField(name string, value ent.Value) error {
  6645. switch name {
  6646. case chatrecords.FieldCreatedAt:
  6647. v, ok := value.(time.Time)
  6648. if !ok {
  6649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6650. }
  6651. m.SetCreatedAt(v)
  6652. return nil
  6653. case chatrecords.FieldUpdatedAt:
  6654. v, ok := value.(time.Time)
  6655. if !ok {
  6656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6657. }
  6658. m.SetUpdatedAt(v)
  6659. return nil
  6660. case chatrecords.FieldDeletedAt:
  6661. v, ok := value.(time.Time)
  6662. if !ok {
  6663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6664. }
  6665. m.SetDeletedAt(v)
  6666. return nil
  6667. case chatrecords.FieldContent:
  6668. v, ok := value.(string)
  6669. if !ok {
  6670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6671. }
  6672. m.SetContent(v)
  6673. return nil
  6674. case chatrecords.FieldContentType:
  6675. v, ok := value.(uint8)
  6676. if !ok {
  6677. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6678. }
  6679. m.SetContentType(v)
  6680. return nil
  6681. case chatrecords.FieldSessionID:
  6682. v, ok := value.(uint64)
  6683. if !ok {
  6684. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6685. }
  6686. m.SetSessionID(v)
  6687. return nil
  6688. case chatrecords.FieldUserID:
  6689. v, ok := value.(uint64)
  6690. if !ok {
  6691. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6692. }
  6693. m.SetUserID(v)
  6694. return nil
  6695. case chatrecords.FieldBotID:
  6696. v, ok := value.(uint64)
  6697. if !ok {
  6698. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6699. }
  6700. m.SetBotID(v)
  6701. return nil
  6702. case chatrecords.FieldBotType:
  6703. v, ok := value.(uint8)
  6704. if !ok {
  6705. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6706. }
  6707. m.SetBotType(v)
  6708. return nil
  6709. }
  6710. return fmt.Errorf("unknown ChatRecords field %s", name)
  6711. }
  6712. // AddedFields returns all numeric fields that were incremented/decremented during
  6713. // this mutation.
  6714. func (m *ChatRecordsMutation) AddedFields() []string {
  6715. var fields []string
  6716. if m.addcontent_type != nil {
  6717. fields = append(fields, chatrecords.FieldContentType)
  6718. }
  6719. if m.addsession_id != nil {
  6720. fields = append(fields, chatrecords.FieldSessionID)
  6721. }
  6722. if m.adduser_id != nil {
  6723. fields = append(fields, chatrecords.FieldUserID)
  6724. }
  6725. if m.addbot_id != nil {
  6726. fields = append(fields, chatrecords.FieldBotID)
  6727. }
  6728. if m.addbot_type != nil {
  6729. fields = append(fields, chatrecords.FieldBotType)
  6730. }
  6731. return fields
  6732. }
  6733. // AddedField returns the numeric value that was incremented/decremented on a field
  6734. // with the given name. The second boolean return value indicates that this field
  6735. // was not set, or was not defined in the schema.
  6736. func (m *ChatRecordsMutation) AddedField(name string) (ent.Value, bool) {
  6737. switch name {
  6738. case chatrecords.FieldContentType:
  6739. return m.AddedContentType()
  6740. case chatrecords.FieldSessionID:
  6741. return m.AddedSessionID()
  6742. case chatrecords.FieldUserID:
  6743. return m.AddedUserID()
  6744. case chatrecords.FieldBotID:
  6745. return m.AddedBotID()
  6746. case chatrecords.FieldBotType:
  6747. return m.AddedBotType()
  6748. }
  6749. return nil, false
  6750. }
  6751. // AddField adds the value to the field with the given name. It returns an error if
  6752. // the field is not defined in the schema, or if the type mismatched the field
  6753. // type.
  6754. func (m *ChatRecordsMutation) AddField(name string, value ent.Value) error {
  6755. switch name {
  6756. case chatrecords.FieldContentType:
  6757. v, ok := value.(int8)
  6758. if !ok {
  6759. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6760. }
  6761. m.AddContentType(v)
  6762. return nil
  6763. case chatrecords.FieldSessionID:
  6764. v, ok := value.(int64)
  6765. if !ok {
  6766. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6767. }
  6768. m.AddSessionID(v)
  6769. return nil
  6770. case chatrecords.FieldUserID:
  6771. v, ok := value.(int64)
  6772. if !ok {
  6773. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6774. }
  6775. m.AddUserID(v)
  6776. return nil
  6777. case chatrecords.FieldBotID:
  6778. v, ok := value.(int64)
  6779. if !ok {
  6780. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6781. }
  6782. m.AddBotID(v)
  6783. return nil
  6784. case chatrecords.FieldBotType:
  6785. v, ok := value.(int8)
  6786. if !ok {
  6787. return fmt.Errorf("unexpected type %T for field %s", value, name)
  6788. }
  6789. m.AddBotType(v)
  6790. return nil
  6791. }
  6792. return fmt.Errorf("unknown ChatRecords numeric field %s", name)
  6793. }
  6794. // ClearedFields returns all nullable fields that were cleared during this
  6795. // mutation.
  6796. func (m *ChatRecordsMutation) ClearedFields() []string {
  6797. var fields []string
  6798. if m.FieldCleared(chatrecords.FieldDeletedAt) {
  6799. fields = append(fields, chatrecords.FieldDeletedAt)
  6800. }
  6801. return fields
  6802. }
  6803. // FieldCleared returns a boolean indicating if a field with the given name was
  6804. // cleared in this mutation.
  6805. func (m *ChatRecordsMutation) FieldCleared(name string) bool {
  6806. _, ok := m.clearedFields[name]
  6807. return ok
  6808. }
  6809. // ClearField clears the value of the field with the given name. It returns an
  6810. // error if the field is not defined in the schema.
  6811. func (m *ChatRecordsMutation) ClearField(name string) error {
  6812. switch name {
  6813. case chatrecords.FieldDeletedAt:
  6814. m.ClearDeletedAt()
  6815. return nil
  6816. }
  6817. return fmt.Errorf("unknown ChatRecords nullable field %s", name)
  6818. }
  6819. // ResetField resets all changes in the mutation for the field with the given name.
  6820. // It returns an error if the field is not defined in the schema.
  6821. func (m *ChatRecordsMutation) ResetField(name string) error {
  6822. switch name {
  6823. case chatrecords.FieldCreatedAt:
  6824. m.ResetCreatedAt()
  6825. return nil
  6826. case chatrecords.FieldUpdatedAt:
  6827. m.ResetUpdatedAt()
  6828. return nil
  6829. case chatrecords.FieldDeletedAt:
  6830. m.ResetDeletedAt()
  6831. return nil
  6832. case chatrecords.FieldContent:
  6833. m.ResetContent()
  6834. return nil
  6835. case chatrecords.FieldContentType:
  6836. m.ResetContentType()
  6837. return nil
  6838. case chatrecords.FieldSessionID:
  6839. m.ResetSessionID()
  6840. return nil
  6841. case chatrecords.FieldUserID:
  6842. m.ResetUserID()
  6843. return nil
  6844. case chatrecords.FieldBotID:
  6845. m.ResetBotID()
  6846. return nil
  6847. case chatrecords.FieldBotType:
  6848. m.ResetBotType()
  6849. return nil
  6850. }
  6851. return fmt.Errorf("unknown ChatRecords field %s", name)
  6852. }
  6853. // AddedEdges returns all edge names that were set/added in this mutation.
  6854. func (m *ChatRecordsMutation) AddedEdges() []string {
  6855. edges := make([]string, 0, 0)
  6856. return edges
  6857. }
  6858. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  6859. // name in this mutation.
  6860. func (m *ChatRecordsMutation) AddedIDs(name string) []ent.Value {
  6861. return nil
  6862. }
  6863. // RemovedEdges returns all edge names that were removed in this mutation.
  6864. func (m *ChatRecordsMutation) RemovedEdges() []string {
  6865. edges := make([]string, 0, 0)
  6866. return edges
  6867. }
  6868. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  6869. // the given name in this mutation.
  6870. func (m *ChatRecordsMutation) RemovedIDs(name string) []ent.Value {
  6871. return nil
  6872. }
  6873. // ClearedEdges returns all edge names that were cleared in this mutation.
  6874. func (m *ChatRecordsMutation) ClearedEdges() []string {
  6875. edges := make([]string, 0, 0)
  6876. return edges
  6877. }
  6878. // EdgeCleared returns a boolean which indicates if the edge with the given name
  6879. // was cleared in this mutation.
  6880. func (m *ChatRecordsMutation) EdgeCleared(name string) bool {
  6881. return false
  6882. }
  6883. // ClearEdge clears the value of the edge with the given name. It returns an error
  6884. // if that edge is not defined in the schema.
  6885. func (m *ChatRecordsMutation) ClearEdge(name string) error {
  6886. return fmt.Errorf("unknown ChatRecords unique edge %s", name)
  6887. }
  6888. // ResetEdge resets all changes to the edge with the given name in this mutation.
  6889. // It returns an error if the edge is not defined in the schema.
  6890. func (m *ChatRecordsMutation) ResetEdge(name string) error {
  6891. return fmt.Errorf("unknown ChatRecords edge %s", name)
  6892. }
  6893. // ChatSessionMutation represents an operation that mutates the ChatSession nodes in the graph.
  6894. type ChatSessionMutation struct {
  6895. config
  6896. op Op
  6897. typ string
  6898. id *uint64
  6899. created_at *time.Time
  6900. updated_at *time.Time
  6901. deleted_at *time.Time
  6902. name *string
  6903. user_id *uint64
  6904. adduser_id *int64
  6905. bot_id *uint64
  6906. addbot_id *int64
  6907. bot_type *uint8
  6908. addbot_type *int8
  6909. clearedFields map[string]struct{}
  6910. done bool
  6911. oldValue func(context.Context) (*ChatSession, error)
  6912. predicates []predicate.ChatSession
  6913. }
  6914. var _ ent.Mutation = (*ChatSessionMutation)(nil)
  6915. // chatsessionOption allows management of the mutation configuration using functional options.
  6916. type chatsessionOption func(*ChatSessionMutation)
  6917. // newChatSessionMutation creates new mutation for the ChatSession entity.
  6918. func newChatSessionMutation(c config, op Op, opts ...chatsessionOption) *ChatSessionMutation {
  6919. m := &ChatSessionMutation{
  6920. config: c,
  6921. op: op,
  6922. typ: TypeChatSession,
  6923. clearedFields: make(map[string]struct{}),
  6924. }
  6925. for _, opt := range opts {
  6926. opt(m)
  6927. }
  6928. return m
  6929. }
  6930. // withChatSessionID sets the ID field of the mutation.
  6931. func withChatSessionID(id uint64) chatsessionOption {
  6932. return func(m *ChatSessionMutation) {
  6933. var (
  6934. err error
  6935. once sync.Once
  6936. value *ChatSession
  6937. )
  6938. m.oldValue = func(ctx context.Context) (*ChatSession, error) {
  6939. once.Do(func() {
  6940. if m.done {
  6941. err = errors.New("querying old values post mutation is not allowed")
  6942. } else {
  6943. value, err = m.Client().ChatSession.Get(ctx, id)
  6944. }
  6945. })
  6946. return value, err
  6947. }
  6948. m.id = &id
  6949. }
  6950. }
  6951. // withChatSession sets the old ChatSession of the mutation.
  6952. func withChatSession(node *ChatSession) chatsessionOption {
  6953. return func(m *ChatSessionMutation) {
  6954. m.oldValue = func(context.Context) (*ChatSession, error) {
  6955. return node, nil
  6956. }
  6957. m.id = &node.ID
  6958. }
  6959. }
  6960. // Client returns a new `ent.Client` from the mutation. If the mutation was
  6961. // executed in a transaction (ent.Tx), a transactional client is returned.
  6962. func (m ChatSessionMutation) Client() *Client {
  6963. client := &Client{config: m.config}
  6964. client.init()
  6965. return client
  6966. }
  6967. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  6968. // it returns an error otherwise.
  6969. func (m ChatSessionMutation) Tx() (*Tx, error) {
  6970. if _, ok := m.driver.(*txDriver); !ok {
  6971. return nil, errors.New("ent: mutation is not running in a transaction")
  6972. }
  6973. tx := &Tx{config: m.config}
  6974. tx.init()
  6975. return tx, nil
  6976. }
  6977. // SetID sets the value of the id field. Note that this
  6978. // operation is only accepted on creation of ChatSession entities.
  6979. func (m *ChatSessionMutation) SetID(id uint64) {
  6980. m.id = &id
  6981. }
  6982. // ID returns the ID value in the mutation. Note that the ID is only available
  6983. // if it was provided to the builder or after it was returned from the database.
  6984. func (m *ChatSessionMutation) ID() (id uint64, exists bool) {
  6985. if m.id == nil {
  6986. return
  6987. }
  6988. return *m.id, true
  6989. }
  6990. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  6991. // That means, if the mutation is applied within a transaction with an isolation level such
  6992. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  6993. // or updated by the mutation.
  6994. func (m *ChatSessionMutation) IDs(ctx context.Context) ([]uint64, error) {
  6995. switch {
  6996. case m.op.Is(OpUpdateOne | OpDeleteOne):
  6997. id, exists := m.ID()
  6998. if exists {
  6999. return []uint64{id}, nil
  7000. }
  7001. fallthrough
  7002. case m.op.Is(OpUpdate | OpDelete):
  7003. return m.Client().ChatSession.Query().Where(m.predicates...).IDs(ctx)
  7004. default:
  7005. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7006. }
  7007. }
  7008. // SetCreatedAt sets the "created_at" field.
  7009. func (m *ChatSessionMutation) SetCreatedAt(t time.Time) {
  7010. m.created_at = &t
  7011. }
  7012. // CreatedAt returns the value of the "created_at" field in the mutation.
  7013. func (m *ChatSessionMutation) CreatedAt() (r time.Time, exists bool) {
  7014. v := m.created_at
  7015. if v == nil {
  7016. return
  7017. }
  7018. return *v, true
  7019. }
  7020. // OldCreatedAt returns the old "created_at" field's value of the ChatSession entity.
  7021. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7022. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7023. func (m *ChatSessionMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7024. if !m.op.Is(OpUpdateOne) {
  7025. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7026. }
  7027. if m.id == nil || m.oldValue == nil {
  7028. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7029. }
  7030. oldValue, err := m.oldValue(ctx)
  7031. if err != nil {
  7032. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7033. }
  7034. return oldValue.CreatedAt, nil
  7035. }
  7036. // ResetCreatedAt resets all changes to the "created_at" field.
  7037. func (m *ChatSessionMutation) ResetCreatedAt() {
  7038. m.created_at = nil
  7039. }
  7040. // SetUpdatedAt sets the "updated_at" field.
  7041. func (m *ChatSessionMutation) SetUpdatedAt(t time.Time) {
  7042. m.updated_at = &t
  7043. }
  7044. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7045. func (m *ChatSessionMutation) UpdatedAt() (r time.Time, exists bool) {
  7046. v := m.updated_at
  7047. if v == nil {
  7048. return
  7049. }
  7050. return *v, true
  7051. }
  7052. // OldUpdatedAt returns the old "updated_at" field's value of the ChatSession entity.
  7053. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7054. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7055. func (m *ChatSessionMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7056. if !m.op.Is(OpUpdateOne) {
  7057. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7058. }
  7059. if m.id == nil || m.oldValue == nil {
  7060. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7061. }
  7062. oldValue, err := m.oldValue(ctx)
  7063. if err != nil {
  7064. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7065. }
  7066. return oldValue.UpdatedAt, nil
  7067. }
  7068. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7069. func (m *ChatSessionMutation) ResetUpdatedAt() {
  7070. m.updated_at = nil
  7071. }
  7072. // SetDeletedAt sets the "deleted_at" field.
  7073. func (m *ChatSessionMutation) SetDeletedAt(t time.Time) {
  7074. m.deleted_at = &t
  7075. }
  7076. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7077. func (m *ChatSessionMutation) DeletedAt() (r time.Time, exists bool) {
  7078. v := m.deleted_at
  7079. if v == nil {
  7080. return
  7081. }
  7082. return *v, true
  7083. }
  7084. // OldDeletedAt returns the old "deleted_at" field's value of the ChatSession entity.
  7085. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7086. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7087. func (m *ChatSessionMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7088. if !m.op.Is(OpUpdateOne) {
  7089. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7090. }
  7091. if m.id == nil || m.oldValue == nil {
  7092. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7093. }
  7094. oldValue, err := m.oldValue(ctx)
  7095. if err != nil {
  7096. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7097. }
  7098. return oldValue.DeletedAt, nil
  7099. }
  7100. // ClearDeletedAt clears the value of the "deleted_at" field.
  7101. func (m *ChatSessionMutation) ClearDeletedAt() {
  7102. m.deleted_at = nil
  7103. m.clearedFields[chatsession.FieldDeletedAt] = struct{}{}
  7104. }
  7105. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7106. func (m *ChatSessionMutation) DeletedAtCleared() bool {
  7107. _, ok := m.clearedFields[chatsession.FieldDeletedAt]
  7108. return ok
  7109. }
  7110. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7111. func (m *ChatSessionMutation) ResetDeletedAt() {
  7112. m.deleted_at = nil
  7113. delete(m.clearedFields, chatsession.FieldDeletedAt)
  7114. }
  7115. // SetName sets the "name" field.
  7116. func (m *ChatSessionMutation) SetName(s string) {
  7117. m.name = &s
  7118. }
  7119. // Name returns the value of the "name" field in the mutation.
  7120. func (m *ChatSessionMutation) Name() (r string, exists bool) {
  7121. v := m.name
  7122. if v == nil {
  7123. return
  7124. }
  7125. return *v, true
  7126. }
  7127. // OldName returns the old "name" field's value of the ChatSession entity.
  7128. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7130. func (m *ChatSessionMutation) OldName(ctx context.Context) (v string, err error) {
  7131. if !m.op.Is(OpUpdateOne) {
  7132. return v, errors.New("OldName is only allowed on UpdateOne operations")
  7133. }
  7134. if m.id == nil || m.oldValue == nil {
  7135. return v, errors.New("OldName requires an ID field in the mutation")
  7136. }
  7137. oldValue, err := m.oldValue(ctx)
  7138. if err != nil {
  7139. return v, fmt.Errorf("querying old value for OldName: %w", err)
  7140. }
  7141. return oldValue.Name, nil
  7142. }
  7143. // ResetName resets all changes to the "name" field.
  7144. func (m *ChatSessionMutation) ResetName() {
  7145. m.name = nil
  7146. }
  7147. // SetUserID sets the "user_id" field.
  7148. func (m *ChatSessionMutation) SetUserID(u uint64) {
  7149. m.user_id = &u
  7150. m.adduser_id = nil
  7151. }
  7152. // UserID returns the value of the "user_id" field in the mutation.
  7153. func (m *ChatSessionMutation) UserID() (r uint64, exists bool) {
  7154. v := m.user_id
  7155. if v == nil {
  7156. return
  7157. }
  7158. return *v, true
  7159. }
  7160. // OldUserID returns the old "user_id" field's value of the ChatSession entity.
  7161. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7163. func (m *ChatSessionMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  7164. if !m.op.Is(OpUpdateOne) {
  7165. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  7166. }
  7167. if m.id == nil || m.oldValue == nil {
  7168. return v, errors.New("OldUserID requires an ID field in the mutation")
  7169. }
  7170. oldValue, err := m.oldValue(ctx)
  7171. if err != nil {
  7172. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  7173. }
  7174. return oldValue.UserID, nil
  7175. }
  7176. // AddUserID adds u to the "user_id" field.
  7177. func (m *ChatSessionMutation) AddUserID(u int64) {
  7178. if m.adduser_id != nil {
  7179. *m.adduser_id += u
  7180. } else {
  7181. m.adduser_id = &u
  7182. }
  7183. }
  7184. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  7185. func (m *ChatSessionMutation) AddedUserID() (r int64, exists bool) {
  7186. v := m.adduser_id
  7187. if v == nil {
  7188. return
  7189. }
  7190. return *v, true
  7191. }
  7192. // ResetUserID resets all changes to the "user_id" field.
  7193. func (m *ChatSessionMutation) ResetUserID() {
  7194. m.user_id = nil
  7195. m.adduser_id = nil
  7196. }
  7197. // SetBotID sets the "bot_id" field.
  7198. func (m *ChatSessionMutation) SetBotID(u uint64) {
  7199. m.bot_id = &u
  7200. m.addbot_id = nil
  7201. }
  7202. // BotID returns the value of the "bot_id" field in the mutation.
  7203. func (m *ChatSessionMutation) BotID() (r uint64, exists bool) {
  7204. v := m.bot_id
  7205. if v == nil {
  7206. return
  7207. }
  7208. return *v, true
  7209. }
  7210. // OldBotID returns the old "bot_id" field's value of the ChatSession entity.
  7211. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7212. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7213. func (m *ChatSessionMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  7214. if !m.op.Is(OpUpdateOne) {
  7215. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  7216. }
  7217. if m.id == nil || m.oldValue == nil {
  7218. return v, errors.New("OldBotID requires an ID field in the mutation")
  7219. }
  7220. oldValue, err := m.oldValue(ctx)
  7221. if err != nil {
  7222. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  7223. }
  7224. return oldValue.BotID, nil
  7225. }
  7226. // AddBotID adds u to the "bot_id" field.
  7227. func (m *ChatSessionMutation) AddBotID(u int64) {
  7228. if m.addbot_id != nil {
  7229. *m.addbot_id += u
  7230. } else {
  7231. m.addbot_id = &u
  7232. }
  7233. }
  7234. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  7235. func (m *ChatSessionMutation) AddedBotID() (r int64, exists bool) {
  7236. v := m.addbot_id
  7237. if v == nil {
  7238. return
  7239. }
  7240. return *v, true
  7241. }
  7242. // ResetBotID resets all changes to the "bot_id" field.
  7243. func (m *ChatSessionMutation) ResetBotID() {
  7244. m.bot_id = nil
  7245. m.addbot_id = nil
  7246. }
  7247. // SetBotType sets the "bot_type" field.
  7248. func (m *ChatSessionMutation) SetBotType(u uint8) {
  7249. m.bot_type = &u
  7250. m.addbot_type = nil
  7251. }
  7252. // BotType returns the value of the "bot_type" field in the mutation.
  7253. func (m *ChatSessionMutation) BotType() (r uint8, exists bool) {
  7254. v := m.bot_type
  7255. if v == nil {
  7256. return
  7257. }
  7258. return *v, true
  7259. }
  7260. // OldBotType returns the old "bot_type" field's value of the ChatSession entity.
  7261. // If the ChatSession object wasn't provided to the builder, the object is fetched from the database.
  7262. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7263. func (m *ChatSessionMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  7264. if !m.op.Is(OpUpdateOne) {
  7265. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  7266. }
  7267. if m.id == nil || m.oldValue == nil {
  7268. return v, errors.New("OldBotType requires an ID field in the mutation")
  7269. }
  7270. oldValue, err := m.oldValue(ctx)
  7271. if err != nil {
  7272. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  7273. }
  7274. return oldValue.BotType, nil
  7275. }
  7276. // AddBotType adds u to the "bot_type" field.
  7277. func (m *ChatSessionMutation) AddBotType(u int8) {
  7278. if m.addbot_type != nil {
  7279. *m.addbot_type += u
  7280. } else {
  7281. m.addbot_type = &u
  7282. }
  7283. }
  7284. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  7285. func (m *ChatSessionMutation) AddedBotType() (r int8, exists bool) {
  7286. v := m.addbot_type
  7287. if v == nil {
  7288. return
  7289. }
  7290. return *v, true
  7291. }
  7292. // ResetBotType resets all changes to the "bot_type" field.
  7293. func (m *ChatSessionMutation) ResetBotType() {
  7294. m.bot_type = nil
  7295. m.addbot_type = nil
  7296. }
  7297. // Where appends a list predicates to the ChatSessionMutation builder.
  7298. func (m *ChatSessionMutation) Where(ps ...predicate.ChatSession) {
  7299. m.predicates = append(m.predicates, ps...)
  7300. }
  7301. // WhereP appends storage-level predicates to the ChatSessionMutation builder. Using this method,
  7302. // users can use type-assertion to append predicates that do not depend on any generated package.
  7303. func (m *ChatSessionMutation) WhereP(ps ...func(*sql.Selector)) {
  7304. p := make([]predicate.ChatSession, len(ps))
  7305. for i := range ps {
  7306. p[i] = ps[i]
  7307. }
  7308. m.Where(p...)
  7309. }
  7310. // Op returns the operation name.
  7311. func (m *ChatSessionMutation) Op() Op {
  7312. return m.op
  7313. }
  7314. // SetOp allows setting the mutation operation.
  7315. func (m *ChatSessionMutation) SetOp(op Op) {
  7316. m.op = op
  7317. }
  7318. // Type returns the node type of this mutation (ChatSession).
  7319. func (m *ChatSessionMutation) Type() string {
  7320. return m.typ
  7321. }
  7322. // Fields returns all fields that were changed during this mutation. Note that in
  7323. // order to get all numeric fields that were incremented/decremented, call
  7324. // AddedFields().
  7325. func (m *ChatSessionMutation) Fields() []string {
  7326. fields := make([]string, 0, 7)
  7327. if m.created_at != nil {
  7328. fields = append(fields, chatsession.FieldCreatedAt)
  7329. }
  7330. if m.updated_at != nil {
  7331. fields = append(fields, chatsession.FieldUpdatedAt)
  7332. }
  7333. if m.deleted_at != nil {
  7334. fields = append(fields, chatsession.FieldDeletedAt)
  7335. }
  7336. if m.name != nil {
  7337. fields = append(fields, chatsession.FieldName)
  7338. }
  7339. if m.user_id != nil {
  7340. fields = append(fields, chatsession.FieldUserID)
  7341. }
  7342. if m.bot_id != nil {
  7343. fields = append(fields, chatsession.FieldBotID)
  7344. }
  7345. if m.bot_type != nil {
  7346. fields = append(fields, chatsession.FieldBotType)
  7347. }
  7348. return fields
  7349. }
  7350. // Field returns the value of a field with the given name. The second boolean
  7351. // return value indicates that this field was not set, or was not defined in the
  7352. // schema.
  7353. func (m *ChatSessionMutation) Field(name string) (ent.Value, bool) {
  7354. switch name {
  7355. case chatsession.FieldCreatedAt:
  7356. return m.CreatedAt()
  7357. case chatsession.FieldUpdatedAt:
  7358. return m.UpdatedAt()
  7359. case chatsession.FieldDeletedAt:
  7360. return m.DeletedAt()
  7361. case chatsession.FieldName:
  7362. return m.Name()
  7363. case chatsession.FieldUserID:
  7364. return m.UserID()
  7365. case chatsession.FieldBotID:
  7366. return m.BotID()
  7367. case chatsession.FieldBotType:
  7368. return m.BotType()
  7369. }
  7370. return nil, false
  7371. }
  7372. // OldField returns the old value of the field from the database. An error is
  7373. // returned if the mutation operation is not UpdateOne, or the query to the
  7374. // database failed.
  7375. func (m *ChatSessionMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  7376. switch name {
  7377. case chatsession.FieldCreatedAt:
  7378. return m.OldCreatedAt(ctx)
  7379. case chatsession.FieldUpdatedAt:
  7380. return m.OldUpdatedAt(ctx)
  7381. case chatsession.FieldDeletedAt:
  7382. return m.OldDeletedAt(ctx)
  7383. case chatsession.FieldName:
  7384. return m.OldName(ctx)
  7385. case chatsession.FieldUserID:
  7386. return m.OldUserID(ctx)
  7387. case chatsession.FieldBotID:
  7388. return m.OldBotID(ctx)
  7389. case chatsession.FieldBotType:
  7390. return m.OldBotType(ctx)
  7391. }
  7392. return nil, fmt.Errorf("unknown ChatSession field %s", name)
  7393. }
  7394. // SetField sets the value of a field with the given name. It returns an error if
  7395. // the field is not defined in the schema, or if the type mismatched the field
  7396. // type.
  7397. func (m *ChatSessionMutation) SetField(name string, value ent.Value) error {
  7398. switch name {
  7399. case chatsession.FieldCreatedAt:
  7400. v, ok := value.(time.Time)
  7401. if !ok {
  7402. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7403. }
  7404. m.SetCreatedAt(v)
  7405. return nil
  7406. case chatsession.FieldUpdatedAt:
  7407. v, ok := value.(time.Time)
  7408. if !ok {
  7409. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7410. }
  7411. m.SetUpdatedAt(v)
  7412. return nil
  7413. case chatsession.FieldDeletedAt:
  7414. v, ok := value.(time.Time)
  7415. if !ok {
  7416. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7417. }
  7418. m.SetDeletedAt(v)
  7419. return nil
  7420. case chatsession.FieldName:
  7421. v, ok := value.(string)
  7422. if !ok {
  7423. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7424. }
  7425. m.SetName(v)
  7426. return nil
  7427. case chatsession.FieldUserID:
  7428. v, ok := value.(uint64)
  7429. if !ok {
  7430. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7431. }
  7432. m.SetUserID(v)
  7433. return nil
  7434. case chatsession.FieldBotID:
  7435. v, ok := value.(uint64)
  7436. if !ok {
  7437. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7438. }
  7439. m.SetBotID(v)
  7440. return nil
  7441. case chatsession.FieldBotType:
  7442. v, ok := value.(uint8)
  7443. if !ok {
  7444. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7445. }
  7446. m.SetBotType(v)
  7447. return nil
  7448. }
  7449. return fmt.Errorf("unknown ChatSession field %s", name)
  7450. }
  7451. // AddedFields returns all numeric fields that were incremented/decremented during
  7452. // this mutation.
  7453. func (m *ChatSessionMutation) AddedFields() []string {
  7454. var fields []string
  7455. if m.adduser_id != nil {
  7456. fields = append(fields, chatsession.FieldUserID)
  7457. }
  7458. if m.addbot_id != nil {
  7459. fields = append(fields, chatsession.FieldBotID)
  7460. }
  7461. if m.addbot_type != nil {
  7462. fields = append(fields, chatsession.FieldBotType)
  7463. }
  7464. return fields
  7465. }
  7466. // AddedField returns the numeric value that was incremented/decremented on a field
  7467. // with the given name. The second boolean return value indicates that this field
  7468. // was not set, or was not defined in the schema.
  7469. func (m *ChatSessionMutation) AddedField(name string) (ent.Value, bool) {
  7470. switch name {
  7471. case chatsession.FieldUserID:
  7472. return m.AddedUserID()
  7473. case chatsession.FieldBotID:
  7474. return m.AddedBotID()
  7475. case chatsession.FieldBotType:
  7476. return m.AddedBotType()
  7477. }
  7478. return nil, false
  7479. }
  7480. // AddField adds the value to the field with the given name. It returns an error if
  7481. // the field is not defined in the schema, or if the type mismatched the field
  7482. // type.
  7483. func (m *ChatSessionMutation) AddField(name string, value ent.Value) error {
  7484. switch name {
  7485. case chatsession.FieldUserID:
  7486. v, ok := value.(int64)
  7487. if !ok {
  7488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7489. }
  7490. m.AddUserID(v)
  7491. return nil
  7492. case chatsession.FieldBotID:
  7493. v, ok := value.(int64)
  7494. if !ok {
  7495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7496. }
  7497. m.AddBotID(v)
  7498. return nil
  7499. case chatsession.FieldBotType:
  7500. v, ok := value.(int8)
  7501. if !ok {
  7502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  7503. }
  7504. m.AddBotType(v)
  7505. return nil
  7506. }
  7507. return fmt.Errorf("unknown ChatSession numeric field %s", name)
  7508. }
  7509. // ClearedFields returns all nullable fields that were cleared during this
  7510. // mutation.
  7511. func (m *ChatSessionMutation) ClearedFields() []string {
  7512. var fields []string
  7513. if m.FieldCleared(chatsession.FieldDeletedAt) {
  7514. fields = append(fields, chatsession.FieldDeletedAt)
  7515. }
  7516. return fields
  7517. }
  7518. // FieldCleared returns a boolean indicating if a field with the given name was
  7519. // cleared in this mutation.
  7520. func (m *ChatSessionMutation) FieldCleared(name string) bool {
  7521. _, ok := m.clearedFields[name]
  7522. return ok
  7523. }
  7524. // ClearField clears the value of the field with the given name. It returns an
  7525. // error if the field is not defined in the schema.
  7526. func (m *ChatSessionMutation) ClearField(name string) error {
  7527. switch name {
  7528. case chatsession.FieldDeletedAt:
  7529. m.ClearDeletedAt()
  7530. return nil
  7531. }
  7532. return fmt.Errorf("unknown ChatSession nullable field %s", name)
  7533. }
  7534. // ResetField resets all changes in the mutation for the field with the given name.
  7535. // It returns an error if the field is not defined in the schema.
  7536. func (m *ChatSessionMutation) ResetField(name string) error {
  7537. switch name {
  7538. case chatsession.FieldCreatedAt:
  7539. m.ResetCreatedAt()
  7540. return nil
  7541. case chatsession.FieldUpdatedAt:
  7542. m.ResetUpdatedAt()
  7543. return nil
  7544. case chatsession.FieldDeletedAt:
  7545. m.ResetDeletedAt()
  7546. return nil
  7547. case chatsession.FieldName:
  7548. m.ResetName()
  7549. return nil
  7550. case chatsession.FieldUserID:
  7551. m.ResetUserID()
  7552. return nil
  7553. case chatsession.FieldBotID:
  7554. m.ResetBotID()
  7555. return nil
  7556. case chatsession.FieldBotType:
  7557. m.ResetBotType()
  7558. return nil
  7559. }
  7560. return fmt.Errorf("unknown ChatSession field %s", name)
  7561. }
  7562. // AddedEdges returns all edge names that were set/added in this mutation.
  7563. func (m *ChatSessionMutation) AddedEdges() []string {
  7564. edges := make([]string, 0, 0)
  7565. return edges
  7566. }
  7567. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  7568. // name in this mutation.
  7569. func (m *ChatSessionMutation) AddedIDs(name string) []ent.Value {
  7570. return nil
  7571. }
  7572. // RemovedEdges returns all edge names that were removed in this mutation.
  7573. func (m *ChatSessionMutation) RemovedEdges() []string {
  7574. edges := make([]string, 0, 0)
  7575. return edges
  7576. }
  7577. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  7578. // the given name in this mutation.
  7579. func (m *ChatSessionMutation) RemovedIDs(name string) []ent.Value {
  7580. return nil
  7581. }
  7582. // ClearedEdges returns all edge names that were cleared in this mutation.
  7583. func (m *ChatSessionMutation) ClearedEdges() []string {
  7584. edges := make([]string, 0, 0)
  7585. return edges
  7586. }
  7587. // EdgeCleared returns a boolean which indicates if the edge with the given name
  7588. // was cleared in this mutation.
  7589. func (m *ChatSessionMutation) EdgeCleared(name string) bool {
  7590. return false
  7591. }
  7592. // ClearEdge clears the value of the edge with the given name. It returns an error
  7593. // if that edge is not defined in the schema.
  7594. func (m *ChatSessionMutation) ClearEdge(name string) error {
  7595. return fmt.Errorf("unknown ChatSession unique edge %s", name)
  7596. }
  7597. // ResetEdge resets all changes to the edge with the given name in this mutation.
  7598. // It returns an error if the edge is not defined in the schema.
  7599. func (m *ChatSessionMutation) ResetEdge(name string) error {
  7600. return fmt.Errorf("unknown ChatSession edge %s", name)
  7601. }
  7602. // ContactMutation represents an operation that mutates the Contact nodes in the graph.
  7603. type ContactMutation struct {
  7604. config
  7605. op Op
  7606. typ string
  7607. id *uint64
  7608. created_at *time.Time
  7609. updated_at *time.Time
  7610. status *uint8
  7611. addstatus *int8
  7612. deleted_at *time.Time
  7613. wx_wxid *string
  7614. _type *int
  7615. add_type *int
  7616. wxid *string
  7617. account *string
  7618. nickname *string
  7619. markname *string
  7620. headimg *string
  7621. sex *int
  7622. addsex *int
  7623. starrole *string
  7624. dontseeit *int
  7625. adddontseeit *int
  7626. dontseeme *int
  7627. adddontseeme *int
  7628. lag *string
  7629. gid *string
  7630. gname *string
  7631. v3 *string
  7632. organization_id *uint64
  7633. addorganization_id *int64
  7634. clearedFields map[string]struct{}
  7635. contact_relationships map[uint64]struct{}
  7636. removedcontact_relationships map[uint64]struct{}
  7637. clearedcontact_relationships bool
  7638. contact_messages map[uint64]struct{}
  7639. removedcontact_messages map[uint64]struct{}
  7640. clearedcontact_messages bool
  7641. done bool
  7642. oldValue func(context.Context) (*Contact, error)
  7643. predicates []predicate.Contact
  7644. }
  7645. var _ ent.Mutation = (*ContactMutation)(nil)
  7646. // contactOption allows management of the mutation configuration using functional options.
  7647. type contactOption func(*ContactMutation)
  7648. // newContactMutation creates new mutation for the Contact entity.
  7649. func newContactMutation(c config, op Op, opts ...contactOption) *ContactMutation {
  7650. m := &ContactMutation{
  7651. config: c,
  7652. op: op,
  7653. typ: TypeContact,
  7654. clearedFields: make(map[string]struct{}),
  7655. }
  7656. for _, opt := range opts {
  7657. opt(m)
  7658. }
  7659. return m
  7660. }
  7661. // withContactID sets the ID field of the mutation.
  7662. func withContactID(id uint64) contactOption {
  7663. return func(m *ContactMutation) {
  7664. var (
  7665. err error
  7666. once sync.Once
  7667. value *Contact
  7668. )
  7669. m.oldValue = func(ctx context.Context) (*Contact, error) {
  7670. once.Do(func() {
  7671. if m.done {
  7672. err = errors.New("querying old values post mutation is not allowed")
  7673. } else {
  7674. value, err = m.Client().Contact.Get(ctx, id)
  7675. }
  7676. })
  7677. return value, err
  7678. }
  7679. m.id = &id
  7680. }
  7681. }
  7682. // withContact sets the old Contact of the mutation.
  7683. func withContact(node *Contact) contactOption {
  7684. return func(m *ContactMutation) {
  7685. m.oldValue = func(context.Context) (*Contact, error) {
  7686. return node, nil
  7687. }
  7688. m.id = &node.ID
  7689. }
  7690. }
  7691. // Client returns a new `ent.Client` from the mutation. If the mutation was
  7692. // executed in a transaction (ent.Tx), a transactional client is returned.
  7693. func (m ContactMutation) Client() *Client {
  7694. client := &Client{config: m.config}
  7695. client.init()
  7696. return client
  7697. }
  7698. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  7699. // it returns an error otherwise.
  7700. func (m ContactMutation) Tx() (*Tx, error) {
  7701. if _, ok := m.driver.(*txDriver); !ok {
  7702. return nil, errors.New("ent: mutation is not running in a transaction")
  7703. }
  7704. tx := &Tx{config: m.config}
  7705. tx.init()
  7706. return tx, nil
  7707. }
  7708. // SetID sets the value of the id field. Note that this
  7709. // operation is only accepted on creation of Contact entities.
  7710. func (m *ContactMutation) SetID(id uint64) {
  7711. m.id = &id
  7712. }
  7713. // ID returns the ID value in the mutation. Note that the ID is only available
  7714. // if it was provided to the builder or after it was returned from the database.
  7715. func (m *ContactMutation) ID() (id uint64, exists bool) {
  7716. if m.id == nil {
  7717. return
  7718. }
  7719. return *m.id, true
  7720. }
  7721. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  7722. // That means, if the mutation is applied within a transaction with an isolation level such
  7723. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  7724. // or updated by the mutation.
  7725. func (m *ContactMutation) IDs(ctx context.Context) ([]uint64, error) {
  7726. switch {
  7727. case m.op.Is(OpUpdateOne | OpDeleteOne):
  7728. id, exists := m.ID()
  7729. if exists {
  7730. return []uint64{id}, nil
  7731. }
  7732. fallthrough
  7733. case m.op.Is(OpUpdate | OpDelete):
  7734. return m.Client().Contact.Query().Where(m.predicates...).IDs(ctx)
  7735. default:
  7736. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  7737. }
  7738. }
  7739. // SetCreatedAt sets the "created_at" field.
  7740. func (m *ContactMutation) SetCreatedAt(t time.Time) {
  7741. m.created_at = &t
  7742. }
  7743. // CreatedAt returns the value of the "created_at" field in the mutation.
  7744. func (m *ContactMutation) CreatedAt() (r time.Time, exists bool) {
  7745. v := m.created_at
  7746. if v == nil {
  7747. return
  7748. }
  7749. return *v, true
  7750. }
  7751. // OldCreatedAt returns the old "created_at" field's value of the Contact entity.
  7752. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7754. func (m *ContactMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  7755. if !m.op.Is(OpUpdateOne) {
  7756. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  7757. }
  7758. if m.id == nil || m.oldValue == nil {
  7759. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  7760. }
  7761. oldValue, err := m.oldValue(ctx)
  7762. if err != nil {
  7763. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  7764. }
  7765. return oldValue.CreatedAt, nil
  7766. }
  7767. // ResetCreatedAt resets all changes to the "created_at" field.
  7768. func (m *ContactMutation) ResetCreatedAt() {
  7769. m.created_at = nil
  7770. }
  7771. // SetUpdatedAt sets the "updated_at" field.
  7772. func (m *ContactMutation) SetUpdatedAt(t time.Time) {
  7773. m.updated_at = &t
  7774. }
  7775. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  7776. func (m *ContactMutation) UpdatedAt() (r time.Time, exists bool) {
  7777. v := m.updated_at
  7778. if v == nil {
  7779. return
  7780. }
  7781. return *v, true
  7782. }
  7783. // OldUpdatedAt returns the old "updated_at" field's value of the Contact entity.
  7784. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7786. func (m *ContactMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  7787. if !m.op.Is(OpUpdateOne) {
  7788. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  7789. }
  7790. if m.id == nil || m.oldValue == nil {
  7791. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  7792. }
  7793. oldValue, err := m.oldValue(ctx)
  7794. if err != nil {
  7795. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  7796. }
  7797. return oldValue.UpdatedAt, nil
  7798. }
  7799. // ResetUpdatedAt resets all changes to the "updated_at" field.
  7800. func (m *ContactMutation) ResetUpdatedAt() {
  7801. m.updated_at = nil
  7802. }
  7803. // SetStatus sets the "status" field.
  7804. func (m *ContactMutation) SetStatus(u uint8) {
  7805. m.status = &u
  7806. m.addstatus = nil
  7807. }
  7808. // Status returns the value of the "status" field in the mutation.
  7809. func (m *ContactMutation) Status() (r uint8, exists bool) {
  7810. v := m.status
  7811. if v == nil {
  7812. return
  7813. }
  7814. return *v, true
  7815. }
  7816. // OldStatus returns the old "status" field's value of the Contact entity.
  7817. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7818. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7819. func (m *ContactMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  7820. if !m.op.Is(OpUpdateOne) {
  7821. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  7822. }
  7823. if m.id == nil || m.oldValue == nil {
  7824. return v, errors.New("OldStatus requires an ID field in the mutation")
  7825. }
  7826. oldValue, err := m.oldValue(ctx)
  7827. if err != nil {
  7828. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  7829. }
  7830. return oldValue.Status, nil
  7831. }
  7832. // AddStatus adds u to the "status" field.
  7833. func (m *ContactMutation) AddStatus(u int8) {
  7834. if m.addstatus != nil {
  7835. *m.addstatus += u
  7836. } else {
  7837. m.addstatus = &u
  7838. }
  7839. }
  7840. // AddedStatus returns the value that was added to the "status" field in this mutation.
  7841. func (m *ContactMutation) AddedStatus() (r int8, exists bool) {
  7842. v := m.addstatus
  7843. if v == nil {
  7844. return
  7845. }
  7846. return *v, true
  7847. }
  7848. // ClearStatus clears the value of the "status" field.
  7849. func (m *ContactMutation) ClearStatus() {
  7850. m.status = nil
  7851. m.addstatus = nil
  7852. m.clearedFields[contact.FieldStatus] = struct{}{}
  7853. }
  7854. // StatusCleared returns if the "status" field was cleared in this mutation.
  7855. func (m *ContactMutation) StatusCleared() bool {
  7856. _, ok := m.clearedFields[contact.FieldStatus]
  7857. return ok
  7858. }
  7859. // ResetStatus resets all changes to the "status" field.
  7860. func (m *ContactMutation) ResetStatus() {
  7861. m.status = nil
  7862. m.addstatus = nil
  7863. delete(m.clearedFields, contact.FieldStatus)
  7864. }
  7865. // SetDeletedAt sets the "deleted_at" field.
  7866. func (m *ContactMutation) SetDeletedAt(t time.Time) {
  7867. m.deleted_at = &t
  7868. }
  7869. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  7870. func (m *ContactMutation) DeletedAt() (r time.Time, exists bool) {
  7871. v := m.deleted_at
  7872. if v == nil {
  7873. return
  7874. }
  7875. return *v, true
  7876. }
  7877. // OldDeletedAt returns the old "deleted_at" field's value of the Contact entity.
  7878. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7879. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7880. func (m *ContactMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  7881. if !m.op.Is(OpUpdateOne) {
  7882. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  7883. }
  7884. if m.id == nil || m.oldValue == nil {
  7885. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  7886. }
  7887. oldValue, err := m.oldValue(ctx)
  7888. if err != nil {
  7889. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  7890. }
  7891. return oldValue.DeletedAt, nil
  7892. }
  7893. // ClearDeletedAt clears the value of the "deleted_at" field.
  7894. func (m *ContactMutation) ClearDeletedAt() {
  7895. m.deleted_at = nil
  7896. m.clearedFields[contact.FieldDeletedAt] = struct{}{}
  7897. }
  7898. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  7899. func (m *ContactMutation) DeletedAtCleared() bool {
  7900. _, ok := m.clearedFields[contact.FieldDeletedAt]
  7901. return ok
  7902. }
  7903. // ResetDeletedAt resets all changes to the "deleted_at" field.
  7904. func (m *ContactMutation) ResetDeletedAt() {
  7905. m.deleted_at = nil
  7906. delete(m.clearedFields, contact.FieldDeletedAt)
  7907. }
  7908. // SetWxWxid sets the "wx_wxid" field.
  7909. func (m *ContactMutation) SetWxWxid(s string) {
  7910. m.wx_wxid = &s
  7911. }
  7912. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  7913. func (m *ContactMutation) WxWxid() (r string, exists bool) {
  7914. v := m.wx_wxid
  7915. if v == nil {
  7916. return
  7917. }
  7918. return *v, true
  7919. }
  7920. // OldWxWxid returns the old "wx_wxid" field's value of the Contact entity.
  7921. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7922. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7923. func (m *ContactMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  7924. if !m.op.Is(OpUpdateOne) {
  7925. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  7926. }
  7927. if m.id == nil || m.oldValue == nil {
  7928. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  7929. }
  7930. oldValue, err := m.oldValue(ctx)
  7931. if err != nil {
  7932. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  7933. }
  7934. return oldValue.WxWxid, nil
  7935. }
  7936. // ResetWxWxid resets all changes to the "wx_wxid" field.
  7937. func (m *ContactMutation) ResetWxWxid() {
  7938. m.wx_wxid = nil
  7939. }
  7940. // SetType sets the "type" field.
  7941. func (m *ContactMutation) SetType(i int) {
  7942. m._type = &i
  7943. m.add_type = nil
  7944. }
  7945. // GetType returns the value of the "type" field in the mutation.
  7946. func (m *ContactMutation) GetType() (r int, exists bool) {
  7947. v := m._type
  7948. if v == nil {
  7949. return
  7950. }
  7951. return *v, true
  7952. }
  7953. // OldType returns the old "type" field's value of the Contact entity.
  7954. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  7955. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  7956. func (m *ContactMutation) OldType(ctx context.Context) (v int, err error) {
  7957. if !m.op.Is(OpUpdateOne) {
  7958. return v, errors.New("OldType is only allowed on UpdateOne operations")
  7959. }
  7960. if m.id == nil || m.oldValue == nil {
  7961. return v, errors.New("OldType requires an ID field in the mutation")
  7962. }
  7963. oldValue, err := m.oldValue(ctx)
  7964. if err != nil {
  7965. return v, fmt.Errorf("querying old value for OldType: %w", err)
  7966. }
  7967. return oldValue.Type, nil
  7968. }
  7969. // AddType adds i to the "type" field.
  7970. func (m *ContactMutation) AddType(i int) {
  7971. if m.add_type != nil {
  7972. *m.add_type += i
  7973. } else {
  7974. m.add_type = &i
  7975. }
  7976. }
  7977. // AddedType returns the value that was added to the "type" field in this mutation.
  7978. func (m *ContactMutation) AddedType() (r int, exists bool) {
  7979. v := m.add_type
  7980. if v == nil {
  7981. return
  7982. }
  7983. return *v, true
  7984. }
  7985. // ClearType clears the value of the "type" field.
  7986. func (m *ContactMutation) ClearType() {
  7987. m._type = nil
  7988. m.add_type = nil
  7989. m.clearedFields[contact.FieldType] = struct{}{}
  7990. }
  7991. // TypeCleared returns if the "type" field was cleared in this mutation.
  7992. func (m *ContactMutation) TypeCleared() bool {
  7993. _, ok := m.clearedFields[contact.FieldType]
  7994. return ok
  7995. }
  7996. // ResetType resets all changes to the "type" field.
  7997. func (m *ContactMutation) ResetType() {
  7998. m._type = nil
  7999. m.add_type = nil
  8000. delete(m.clearedFields, contact.FieldType)
  8001. }
  8002. // SetWxid sets the "wxid" field.
  8003. func (m *ContactMutation) SetWxid(s string) {
  8004. m.wxid = &s
  8005. }
  8006. // Wxid returns the value of the "wxid" field in the mutation.
  8007. func (m *ContactMutation) Wxid() (r string, exists bool) {
  8008. v := m.wxid
  8009. if v == nil {
  8010. return
  8011. }
  8012. return *v, true
  8013. }
  8014. // OldWxid returns the old "wxid" field's value of the Contact entity.
  8015. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8016. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8017. func (m *ContactMutation) OldWxid(ctx context.Context) (v string, err error) {
  8018. if !m.op.Is(OpUpdateOne) {
  8019. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  8020. }
  8021. if m.id == nil || m.oldValue == nil {
  8022. return v, errors.New("OldWxid requires an ID field in the mutation")
  8023. }
  8024. oldValue, err := m.oldValue(ctx)
  8025. if err != nil {
  8026. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  8027. }
  8028. return oldValue.Wxid, nil
  8029. }
  8030. // ResetWxid resets all changes to the "wxid" field.
  8031. func (m *ContactMutation) ResetWxid() {
  8032. m.wxid = nil
  8033. }
  8034. // SetAccount sets the "account" field.
  8035. func (m *ContactMutation) SetAccount(s string) {
  8036. m.account = &s
  8037. }
  8038. // Account returns the value of the "account" field in the mutation.
  8039. func (m *ContactMutation) Account() (r string, exists bool) {
  8040. v := m.account
  8041. if v == nil {
  8042. return
  8043. }
  8044. return *v, true
  8045. }
  8046. // OldAccount returns the old "account" field's value of the Contact entity.
  8047. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8049. func (m *ContactMutation) OldAccount(ctx context.Context) (v string, err error) {
  8050. if !m.op.Is(OpUpdateOne) {
  8051. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  8052. }
  8053. if m.id == nil || m.oldValue == nil {
  8054. return v, errors.New("OldAccount requires an ID field in the mutation")
  8055. }
  8056. oldValue, err := m.oldValue(ctx)
  8057. if err != nil {
  8058. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  8059. }
  8060. return oldValue.Account, nil
  8061. }
  8062. // ResetAccount resets all changes to the "account" field.
  8063. func (m *ContactMutation) ResetAccount() {
  8064. m.account = nil
  8065. }
  8066. // SetNickname sets the "nickname" field.
  8067. func (m *ContactMutation) SetNickname(s string) {
  8068. m.nickname = &s
  8069. }
  8070. // Nickname returns the value of the "nickname" field in the mutation.
  8071. func (m *ContactMutation) Nickname() (r string, exists bool) {
  8072. v := m.nickname
  8073. if v == nil {
  8074. return
  8075. }
  8076. return *v, true
  8077. }
  8078. // OldNickname returns the old "nickname" field's value of the Contact entity.
  8079. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8080. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8081. func (m *ContactMutation) OldNickname(ctx context.Context) (v string, err error) {
  8082. if !m.op.Is(OpUpdateOne) {
  8083. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  8084. }
  8085. if m.id == nil || m.oldValue == nil {
  8086. return v, errors.New("OldNickname requires an ID field in the mutation")
  8087. }
  8088. oldValue, err := m.oldValue(ctx)
  8089. if err != nil {
  8090. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  8091. }
  8092. return oldValue.Nickname, nil
  8093. }
  8094. // ResetNickname resets all changes to the "nickname" field.
  8095. func (m *ContactMutation) ResetNickname() {
  8096. m.nickname = nil
  8097. }
  8098. // SetMarkname sets the "markname" field.
  8099. func (m *ContactMutation) SetMarkname(s string) {
  8100. m.markname = &s
  8101. }
  8102. // Markname returns the value of the "markname" field in the mutation.
  8103. func (m *ContactMutation) Markname() (r string, exists bool) {
  8104. v := m.markname
  8105. if v == nil {
  8106. return
  8107. }
  8108. return *v, true
  8109. }
  8110. // OldMarkname returns the old "markname" field's value of the Contact entity.
  8111. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8112. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8113. func (m *ContactMutation) OldMarkname(ctx context.Context) (v string, err error) {
  8114. if !m.op.Is(OpUpdateOne) {
  8115. return v, errors.New("OldMarkname is only allowed on UpdateOne operations")
  8116. }
  8117. if m.id == nil || m.oldValue == nil {
  8118. return v, errors.New("OldMarkname requires an ID field in the mutation")
  8119. }
  8120. oldValue, err := m.oldValue(ctx)
  8121. if err != nil {
  8122. return v, fmt.Errorf("querying old value for OldMarkname: %w", err)
  8123. }
  8124. return oldValue.Markname, nil
  8125. }
  8126. // ResetMarkname resets all changes to the "markname" field.
  8127. func (m *ContactMutation) ResetMarkname() {
  8128. m.markname = nil
  8129. }
  8130. // SetHeadimg sets the "headimg" field.
  8131. func (m *ContactMutation) SetHeadimg(s string) {
  8132. m.headimg = &s
  8133. }
  8134. // Headimg returns the value of the "headimg" field in the mutation.
  8135. func (m *ContactMutation) Headimg() (r string, exists bool) {
  8136. v := m.headimg
  8137. if v == nil {
  8138. return
  8139. }
  8140. return *v, true
  8141. }
  8142. // OldHeadimg returns the old "headimg" field's value of the Contact entity.
  8143. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8144. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8145. func (m *ContactMutation) OldHeadimg(ctx context.Context) (v string, err error) {
  8146. if !m.op.Is(OpUpdateOne) {
  8147. return v, errors.New("OldHeadimg is only allowed on UpdateOne operations")
  8148. }
  8149. if m.id == nil || m.oldValue == nil {
  8150. return v, errors.New("OldHeadimg requires an ID field in the mutation")
  8151. }
  8152. oldValue, err := m.oldValue(ctx)
  8153. if err != nil {
  8154. return v, fmt.Errorf("querying old value for OldHeadimg: %w", err)
  8155. }
  8156. return oldValue.Headimg, nil
  8157. }
  8158. // ResetHeadimg resets all changes to the "headimg" field.
  8159. func (m *ContactMutation) ResetHeadimg() {
  8160. m.headimg = nil
  8161. }
  8162. // SetSex sets the "sex" field.
  8163. func (m *ContactMutation) SetSex(i int) {
  8164. m.sex = &i
  8165. m.addsex = nil
  8166. }
  8167. // Sex returns the value of the "sex" field in the mutation.
  8168. func (m *ContactMutation) Sex() (r int, exists bool) {
  8169. v := m.sex
  8170. if v == nil {
  8171. return
  8172. }
  8173. return *v, true
  8174. }
  8175. // OldSex returns the old "sex" field's value of the Contact entity.
  8176. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8177. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8178. func (m *ContactMutation) OldSex(ctx context.Context) (v int, err error) {
  8179. if !m.op.Is(OpUpdateOne) {
  8180. return v, errors.New("OldSex is only allowed on UpdateOne operations")
  8181. }
  8182. if m.id == nil || m.oldValue == nil {
  8183. return v, errors.New("OldSex requires an ID field in the mutation")
  8184. }
  8185. oldValue, err := m.oldValue(ctx)
  8186. if err != nil {
  8187. return v, fmt.Errorf("querying old value for OldSex: %w", err)
  8188. }
  8189. return oldValue.Sex, nil
  8190. }
  8191. // AddSex adds i to the "sex" field.
  8192. func (m *ContactMutation) AddSex(i int) {
  8193. if m.addsex != nil {
  8194. *m.addsex += i
  8195. } else {
  8196. m.addsex = &i
  8197. }
  8198. }
  8199. // AddedSex returns the value that was added to the "sex" field in this mutation.
  8200. func (m *ContactMutation) AddedSex() (r int, exists bool) {
  8201. v := m.addsex
  8202. if v == nil {
  8203. return
  8204. }
  8205. return *v, true
  8206. }
  8207. // ResetSex resets all changes to the "sex" field.
  8208. func (m *ContactMutation) ResetSex() {
  8209. m.sex = nil
  8210. m.addsex = nil
  8211. }
  8212. // SetStarrole sets the "starrole" field.
  8213. func (m *ContactMutation) SetStarrole(s string) {
  8214. m.starrole = &s
  8215. }
  8216. // Starrole returns the value of the "starrole" field in the mutation.
  8217. func (m *ContactMutation) Starrole() (r string, exists bool) {
  8218. v := m.starrole
  8219. if v == nil {
  8220. return
  8221. }
  8222. return *v, true
  8223. }
  8224. // OldStarrole returns the old "starrole" field's value of the Contact entity.
  8225. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8227. func (m *ContactMutation) OldStarrole(ctx context.Context) (v string, err error) {
  8228. if !m.op.Is(OpUpdateOne) {
  8229. return v, errors.New("OldStarrole is only allowed on UpdateOne operations")
  8230. }
  8231. if m.id == nil || m.oldValue == nil {
  8232. return v, errors.New("OldStarrole requires an ID field in the mutation")
  8233. }
  8234. oldValue, err := m.oldValue(ctx)
  8235. if err != nil {
  8236. return v, fmt.Errorf("querying old value for OldStarrole: %w", err)
  8237. }
  8238. return oldValue.Starrole, nil
  8239. }
  8240. // ResetStarrole resets all changes to the "starrole" field.
  8241. func (m *ContactMutation) ResetStarrole() {
  8242. m.starrole = nil
  8243. }
  8244. // SetDontseeit sets the "dontseeit" field.
  8245. func (m *ContactMutation) SetDontseeit(i int) {
  8246. m.dontseeit = &i
  8247. m.adddontseeit = nil
  8248. }
  8249. // Dontseeit returns the value of the "dontseeit" field in the mutation.
  8250. func (m *ContactMutation) Dontseeit() (r int, exists bool) {
  8251. v := m.dontseeit
  8252. if v == nil {
  8253. return
  8254. }
  8255. return *v, true
  8256. }
  8257. // OldDontseeit returns the old "dontseeit" field's value of the Contact entity.
  8258. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8260. func (m *ContactMutation) OldDontseeit(ctx context.Context) (v int, err error) {
  8261. if !m.op.Is(OpUpdateOne) {
  8262. return v, errors.New("OldDontseeit is only allowed on UpdateOne operations")
  8263. }
  8264. if m.id == nil || m.oldValue == nil {
  8265. return v, errors.New("OldDontseeit requires an ID field in the mutation")
  8266. }
  8267. oldValue, err := m.oldValue(ctx)
  8268. if err != nil {
  8269. return v, fmt.Errorf("querying old value for OldDontseeit: %w", err)
  8270. }
  8271. return oldValue.Dontseeit, nil
  8272. }
  8273. // AddDontseeit adds i to the "dontseeit" field.
  8274. func (m *ContactMutation) AddDontseeit(i int) {
  8275. if m.adddontseeit != nil {
  8276. *m.adddontseeit += i
  8277. } else {
  8278. m.adddontseeit = &i
  8279. }
  8280. }
  8281. // AddedDontseeit returns the value that was added to the "dontseeit" field in this mutation.
  8282. func (m *ContactMutation) AddedDontseeit() (r int, exists bool) {
  8283. v := m.adddontseeit
  8284. if v == nil {
  8285. return
  8286. }
  8287. return *v, true
  8288. }
  8289. // ResetDontseeit resets all changes to the "dontseeit" field.
  8290. func (m *ContactMutation) ResetDontseeit() {
  8291. m.dontseeit = nil
  8292. m.adddontseeit = nil
  8293. }
  8294. // SetDontseeme sets the "dontseeme" field.
  8295. func (m *ContactMutation) SetDontseeme(i int) {
  8296. m.dontseeme = &i
  8297. m.adddontseeme = nil
  8298. }
  8299. // Dontseeme returns the value of the "dontseeme" field in the mutation.
  8300. func (m *ContactMutation) Dontseeme() (r int, exists bool) {
  8301. v := m.dontseeme
  8302. if v == nil {
  8303. return
  8304. }
  8305. return *v, true
  8306. }
  8307. // OldDontseeme returns the old "dontseeme" field's value of the Contact entity.
  8308. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8310. func (m *ContactMutation) OldDontseeme(ctx context.Context) (v int, err error) {
  8311. if !m.op.Is(OpUpdateOne) {
  8312. return v, errors.New("OldDontseeme is only allowed on UpdateOne operations")
  8313. }
  8314. if m.id == nil || m.oldValue == nil {
  8315. return v, errors.New("OldDontseeme requires an ID field in the mutation")
  8316. }
  8317. oldValue, err := m.oldValue(ctx)
  8318. if err != nil {
  8319. return v, fmt.Errorf("querying old value for OldDontseeme: %w", err)
  8320. }
  8321. return oldValue.Dontseeme, nil
  8322. }
  8323. // AddDontseeme adds i to the "dontseeme" field.
  8324. func (m *ContactMutation) AddDontseeme(i int) {
  8325. if m.adddontseeme != nil {
  8326. *m.adddontseeme += i
  8327. } else {
  8328. m.adddontseeme = &i
  8329. }
  8330. }
  8331. // AddedDontseeme returns the value that was added to the "dontseeme" field in this mutation.
  8332. func (m *ContactMutation) AddedDontseeme() (r int, exists bool) {
  8333. v := m.adddontseeme
  8334. if v == nil {
  8335. return
  8336. }
  8337. return *v, true
  8338. }
  8339. // ResetDontseeme resets all changes to the "dontseeme" field.
  8340. func (m *ContactMutation) ResetDontseeme() {
  8341. m.dontseeme = nil
  8342. m.adddontseeme = nil
  8343. }
  8344. // SetLag sets the "lag" field.
  8345. func (m *ContactMutation) SetLag(s string) {
  8346. m.lag = &s
  8347. }
  8348. // Lag returns the value of the "lag" field in the mutation.
  8349. func (m *ContactMutation) Lag() (r string, exists bool) {
  8350. v := m.lag
  8351. if v == nil {
  8352. return
  8353. }
  8354. return *v, true
  8355. }
  8356. // OldLag returns the old "lag" field's value of the Contact entity.
  8357. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8358. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8359. func (m *ContactMutation) OldLag(ctx context.Context) (v string, err error) {
  8360. if !m.op.Is(OpUpdateOne) {
  8361. return v, errors.New("OldLag is only allowed on UpdateOne operations")
  8362. }
  8363. if m.id == nil || m.oldValue == nil {
  8364. return v, errors.New("OldLag requires an ID field in the mutation")
  8365. }
  8366. oldValue, err := m.oldValue(ctx)
  8367. if err != nil {
  8368. return v, fmt.Errorf("querying old value for OldLag: %w", err)
  8369. }
  8370. return oldValue.Lag, nil
  8371. }
  8372. // ResetLag resets all changes to the "lag" field.
  8373. func (m *ContactMutation) ResetLag() {
  8374. m.lag = nil
  8375. }
  8376. // SetGid sets the "gid" field.
  8377. func (m *ContactMutation) SetGid(s string) {
  8378. m.gid = &s
  8379. }
  8380. // Gid returns the value of the "gid" field in the mutation.
  8381. func (m *ContactMutation) Gid() (r string, exists bool) {
  8382. v := m.gid
  8383. if v == nil {
  8384. return
  8385. }
  8386. return *v, true
  8387. }
  8388. // OldGid returns the old "gid" field's value of the Contact entity.
  8389. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8391. func (m *ContactMutation) OldGid(ctx context.Context) (v string, err error) {
  8392. if !m.op.Is(OpUpdateOne) {
  8393. return v, errors.New("OldGid is only allowed on UpdateOne operations")
  8394. }
  8395. if m.id == nil || m.oldValue == nil {
  8396. return v, errors.New("OldGid requires an ID field in the mutation")
  8397. }
  8398. oldValue, err := m.oldValue(ctx)
  8399. if err != nil {
  8400. return v, fmt.Errorf("querying old value for OldGid: %w", err)
  8401. }
  8402. return oldValue.Gid, nil
  8403. }
  8404. // ResetGid resets all changes to the "gid" field.
  8405. func (m *ContactMutation) ResetGid() {
  8406. m.gid = nil
  8407. }
  8408. // SetGname sets the "gname" field.
  8409. func (m *ContactMutation) SetGname(s string) {
  8410. m.gname = &s
  8411. }
  8412. // Gname returns the value of the "gname" field in the mutation.
  8413. func (m *ContactMutation) Gname() (r string, exists bool) {
  8414. v := m.gname
  8415. if v == nil {
  8416. return
  8417. }
  8418. return *v, true
  8419. }
  8420. // OldGname returns the old "gname" field's value of the Contact entity.
  8421. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8422. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8423. func (m *ContactMutation) OldGname(ctx context.Context) (v string, err error) {
  8424. if !m.op.Is(OpUpdateOne) {
  8425. return v, errors.New("OldGname is only allowed on UpdateOne operations")
  8426. }
  8427. if m.id == nil || m.oldValue == nil {
  8428. return v, errors.New("OldGname requires an ID field in the mutation")
  8429. }
  8430. oldValue, err := m.oldValue(ctx)
  8431. if err != nil {
  8432. return v, fmt.Errorf("querying old value for OldGname: %w", err)
  8433. }
  8434. return oldValue.Gname, nil
  8435. }
  8436. // ResetGname resets all changes to the "gname" field.
  8437. func (m *ContactMutation) ResetGname() {
  8438. m.gname = nil
  8439. }
  8440. // SetV3 sets the "v3" field.
  8441. func (m *ContactMutation) SetV3(s string) {
  8442. m.v3 = &s
  8443. }
  8444. // V3 returns the value of the "v3" field in the mutation.
  8445. func (m *ContactMutation) V3() (r string, exists bool) {
  8446. v := m.v3
  8447. if v == nil {
  8448. return
  8449. }
  8450. return *v, true
  8451. }
  8452. // OldV3 returns the old "v3" field's value of the Contact entity.
  8453. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8454. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8455. func (m *ContactMutation) OldV3(ctx context.Context) (v string, err error) {
  8456. if !m.op.Is(OpUpdateOne) {
  8457. return v, errors.New("OldV3 is only allowed on UpdateOne operations")
  8458. }
  8459. if m.id == nil || m.oldValue == nil {
  8460. return v, errors.New("OldV3 requires an ID field in the mutation")
  8461. }
  8462. oldValue, err := m.oldValue(ctx)
  8463. if err != nil {
  8464. return v, fmt.Errorf("querying old value for OldV3: %w", err)
  8465. }
  8466. return oldValue.V3, nil
  8467. }
  8468. // ResetV3 resets all changes to the "v3" field.
  8469. func (m *ContactMutation) ResetV3() {
  8470. m.v3 = nil
  8471. }
  8472. // SetOrganizationID sets the "organization_id" field.
  8473. func (m *ContactMutation) SetOrganizationID(u uint64) {
  8474. m.organization_id = &u
  8475. m.addorganization_id = nil
  8476. }
  8477. // OrganizationID returns the value of the "organization_id" field in the mutation.
  8478. func (m *ContactMutation) OrganizationID() (r uint64, exists bool) {
  8479. v := m.organization_id
  8480. if v == nil {
  8481. return
  8482. }
  8483. return *v, true
  8484. }
  8485. // OldOrganizationID returns the old "organization_id" field's value of the Contact entity.
  8486. // If the Contact object wasn't provided to the builder, the object is fetched from the database.
  8487. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  8488. func (m *ContactMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  8489. if !m.op.Is(OpUpdateOne) {
  8490. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  8491. }
  8492. if m.id == nil || m.oldValue == nil {
  8493. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  8494. }
  8495. oldValue, err := m.oldValue(ctx)
  8496. if err != nil {
  8497. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  8498. }
  8499. return oldValue.OrganizationID, nil
  8500. }
  8501. // AddOrganizationID adds u to the "organization_id" field.
  8502. func (m *ContactMutation) AddOrganizationID(u int64) {
  8503. if m.addorganization_id != nil {
  8504. *m.addorganization_id += u
  8505. } else {
  8506. m.addorganization_id = &u
  8507. }
  8508. }
  8509. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  8510. func (m *ContactMutation) AddedOrganizationID() (r int64, exists bool) {
  8511. v := m.addorganization_id
  8512. if v == nil {
  8513. return
  8514. }
  8515. return *v, true
  8516. }
  8517. // ClearOrganizationID clears the value of the "organization_id" field.
  8518. func (m *ContactMutation) ClearOrganizationID() {
  8519. m.organization_id = nil
  8520. m.addorganization_id = nil
  8521. m.clearedFields[contact.FieldOrganizationID] = struct{}{}
  8522. }
  8523. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  8524. func (m *ContactMutation) OrganizationIDCleared() bool {
  8525. _, ok := m.clearedFields[contact.FieldOrganizationID]
  8526. return ok
  8527. }
  8528. // ResetOrganizationID resets all changes to the "organization_id" field.
  8529. func (m *ContactMutation) ResetOrganizationID() {
  8530. m.organization_id = nil
  8531. m.addorganization_id = nil
  8532. delete(m.clearedFields, contact.FieldOrganizationID)
  8533. }
  8534. // AddContactRelationshipIDs adds the "contact_relationships" edge to the LabelRelationship entity by ids.
  8535. func (m *ContactMutation) AddContactRelationshipIDs(ids ...uint64) {
  8536. if m.contact_relationships == nil {
  8537. m.contact_relationships = make(map[uint64]struct{})
  8538. }
  8539. for i := range ids {
  8540. m.contact_relationships[ids[i]] = struct{}{}
  8541. }
  8542. }
  8543. // ClearContactRelationships clears the "contact_relationships" edge to the LabelRelationship entity.
  8544. func (m *ContactMutation) ClearContactRelationships() {
  8545. m.clearedcontact_relationships = true
  8546. }
  8547. // ContactRelationshipsCleared reports if the "contact_relationships" edge to the LabelRelationship entity was cleared.
  8548. func (m *ContactMutation) ContactRelationshipsCleared() bool {
  8549. return m.clearedcontact_relationships
  8550. }
  8551. // RemoveContactRelationshipIDs removes the "contact_relationships" edge to the LabelRelationship entity by IDs.
  8552. func (m *ContactMutation) RemoveContactRelationshipIDs(ids ...uint64) {
  8553. if m.removedcontact_relationships == nil {
  8554. m.removedcontact_relationships = make(map[uint64]struct{})
  8555. }
  8556. for i := range ids {
  8557. delete(m.contact_relationships, ids[i])
  8558. m.removedcontact_relationships[ids[i]] = struct{}{}
  8559. }
  8560. }
  8561. // RemovedContactRelationships returns the removed IDs of the "contact_relationships" edge to the LabelRelationship entity.
  8562. func (m *ContactMutation) RemovedContactRelationshipsIDs() (ids []uint64) {
  8563. for id := range m.removedcontact_relationships {
  8564. ids = append(ids, id)
  8565. }
  8566. return
  8567. }
  8568. // ContactRelationshipsIDs returns the "contact_relationships" edge IDs in the mutation.
  8569. func (m *ContactMutation) ContactRelationshipsIDs() (ids []uint64) {
  8570. for id := range m.contact_relationships {
  8571. ids = append(ids, id)
  8572. }
  8573. return
  8574. }
  8575. // ResetContactRelationships resets all changes to the "contact_relationships" edge.
  8576. func (m *ContactMutation) ResetContactRelationships() {
  8577. m.contact_relationships = nil
  8578. m.clearedcontact_relationships = false
  8579. m.removedcontact_relationships = nil
  8580. }
  8581. // AddContactMessageIDs adds the "contact_messages" edge to the MessageRecords entity by ids.
  8582. func (m *ContactMutation) AddContactMessageIDs(ids ...uint64) {
  8583. if m.contact_messages == nil {
  8584. m.contact_messages = make(map[uint64]struct{})
  8585. }
  8586. for i := range ids {
  8587. m.contact_messages[ids[i]] = struct{}{}
  8588. }
  8589. }
  8590. // ClearContactMessages clears the "contact_messages" edge to the MessageRecords entity.
  8591. func (m *ContactMutation) ClearContactMessages() {
  8592. m.clearedcontact_messages = true
  8593. }
  8594. // ContactMessagesCleared reports if the "contact_messages" edge to the MessageRecords entity was cleared.
  8595. func (m *ContactMutation) ContactMessagesCleared() bool {
  8596. return m.clearedcontact_messages
  8597. }
  8598. // RemoveContactMessageIDs removes the "contact_messages" edge to the MessageRecords entity by IDs.
  8599. func (m *ContactMutation) RemoveContactMessageIDs(ids ...uint64) {
  8600. if m.removedcontact_messages == nil {
  8601. m.removedcontact_messages = make(map[uint64]struct{})
  8602. }
  8603. for i := range ids {
  8604. delete(m.contact_messages, ids[i])
  8605. m.removedcontact_messages[ids[i]] = struct{}{}
  8606. }
  8607. }
  8608. // RemovedContactMessages returns the removed IDs of the "contact_messages" edge to the MessageRecords entity.
  8609. func (m *ContactMutation) RemovedContactMessagesIDs() (ids []uint64) {
  8610. for id := range m.removedcontact_messages {
  8611. ids = append(ids, id)
  8612. }
  8613. return
  8614. }
  8615. // ContactMessagesIDs returns the "contact_messages" edge IDs in the mutation.
  8616. func (m *ContactMutation) ContactMessagesIDs() (ids []uint64) {
  8617. for id := range m.contact_messages {
  8618. ids = append(ids, id)
  8619. }
  8620. return
  8621. }
  8622. // ResetContactMessages resets all changes to the "contact_messages" edge.
  8623. func (m *ContactMutation) ResetContactMessages() {
  8624. m.contact_messages = nil
  8625. m.clearedcontact_messages = false
  8626. m.removedcontact_messages = nil
  8627. }
  8628. // Where appends a list predicates to the ContactMutation builder.
  8629. func (m *ContactMutation) Where(ps ...predicate.Contact) {
  8630. m.predicates = append(m.predicates, ps...)
  8631. }
  8632. // WhereP appends storage-level predicates to the ContactMutation builder. Using this method,
  8633. // users can use type-assertion to append predicates that do not depend on any generated package.
  8634. func (m *ContactMutation) WhereP(ps ...func(*sql.Selector)) {
  8635. p := make([]predicate.Contact, len(ps))
  8636. for i := range ps {
  8637. p[i] = ps[i]
  8638. }
  8639. m.Where(p...)
  8640. }
  8641. // Op returns the operation name.
  8642. func (m *ContactMutation) Op() Op {
  8643. return m.op
  8644. }
  8645. // SetOp allows setting the mutation operation.
  8646. func (m *ContactMutation) SetOp(op Op) {
  8647. m.op = op
  8648. }
  8649. // Type returns the node type of this mutation (Contact).
  8650. func (m *ContactMutation) Type() string {
  8651. return m.typ
  8652. }
  8653. // Fields returns all fields that were changed during this mutation. Note that in
  8654. // order to get all numeric fields that were incremented/decremented, call
  8655. // AddedFields().
  8656. func (m *ContactMutation) Fields() []string {
  8657. fields := make([]string, 0, 20)
  8658. if m.created_at != nil {
  8659. fields = append(fields, contact.FieldCreatedAt)
  8660. }
  8661. if m.updated_at != nil {
  8662. fields = append(fields, contact.FieldUpdatedAt)
  8663. }
  8664. if m.status != nil {
  8665. fields = append(fields, contact.FieldStatus)
  8666. }
  8667. if m.deleted_at != nil {
  8668. fields = append(fields, contact.FieldDeletedAt)
  8669. }
  8670. if m.wx_wxid != nil {
  8671. fields = append(fields, contact.FieldWxWxid)
  8672. }
  8673. if m._type != nil {
  8674. fields = append(fields, contact.FieldType)
  8675. }
  8676. if m.wxid != nil {
  8677. fields = append(fields, contact.FieldWxid)
  8678. }
  8679. if m.account != nil {
  8680. fields = append(fields, contact.FieldAccount)
  8681. }
  8682. if m.nickname != nil {
  8683. fields = append(fields, contact.FieldNickname)
  8684. }
  8685. if m.markname != nil {
  8686. fields = append(fields, contact.FieldMarkname)
  8687. }
  8688. if m.headimg != nil {
  8689. fields = append(fields, contact.FieldHeadimg)
  8690. }
  8691. if m.sex != nil {
  8692. fields = append(fields, contact.FieldSex)
  8693. }
  8694. if m.starrole != nil {
  8695. fields = append(fields, contact.FieldStarrole)
  8696. }
  8697. if m.dontseeit != nil {
  8698. fields = append(fields, contact.FieldDontseeit)
  8699. }
  8700. if m.dontseeme != nil {
  8701. fields = append(fields, contact.FieldDontseeme)
  8702. }
  8703. if m.lag != nil {
  8704. fields = append(fields, contact.FieldLag)
  8705. }
  8706. if m.gid != nil {
  8707. fields = append(fields, contact.FieldGid)
  8708. }
  8709. if m.gname != nil {
  8710. fields = append(fields, contact.FieldGname)
  8711. }
  8712. if m.v3 != nil {
  8713. fields = append(fields, contact.FieldV3)
  8714. }
  8715. if m.organization_id != nil {
  8716. fields = append(fields, contact.FieldOrganizationID)
  8717. }
  8718. return fields
  8719. }
  8720. // Field returns the value of a field with the given name. The second boolean
  8721. // return value indicates that this field was not set, or was not defined in the
  8722. // schema.
  8723. func (m *ContactMutation) Field(name string) (ent.Value, bool) {
  8724. switch name {
  8725. case contact.FieldCreatedAt:
  8726. return m.CreatedAt()
  8727. case contact.FieldUpdatedAt:
  8728. return m.UpdatedAt()
  8729. case contact.FieldStatus:
  8730. return m.Status()
  8731. case contact.FieldDeletedAt:
  8732. return m.DeletedAt()
  8733. case contact.FieldWxWxid:
  8734. return m.WxWxid()
  8735. case contact.FieldType:
  8736. return m.GetType()
  8737. case contact.FieldWxid:
  8738. return m.Wxid()
  8739. case contact.FieldAccount:
  8740. return m.Account()
  8741. case contact.FieldNickname:
  8742. return m.Nickname()
  8743. case contact.FieldMarkname:
  8744. return m.Markname()
  8745. case contact.FieldHeadimg:
  8746. return m.Headimg()
  8747. case contact.FieldSex:
  8748. return m.Sex()
  8749. case contact.FieldStarrole:
  8750. return m.Starrole()
  8751. case contact.FieldDontseeit:
  8752. return m.Dontseeit()
  8753. case contact.FieldDontseeme:
  8754. return m.Dontseeme()
  8755. case contact.FieldLag:
  8756. return m.Lag()
  8757. case contact.FieldGid:
  8758. return m.Gid()
  8759. case contact.FieldGname:
  8760. return m.Gname()
  8761. case contact.FieldV3:
  8762. return m.V3()
  8763. case contact.FieldOrganizationID:
  8764. return m.OrganizationID()
  8765. }
  8766. return nil, false
  8767. }
  8768. // OldField returns the old value of the field from the database. An error is
  8769. // returned if the mutation operation is not UpdateOne, or the query to the
  8770. // database failed.
  8771. func (m *ContactMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  8772. switch name {
  8773. case contact.FieldCreatedAt:
  8774. return m.OldCreatedAt(ctx)
  8775. case contact.FieldUpdatedAt:
  8776. return m.OldUpdatedAt(ctx)
  8777. case contact.FieldStatus:
  8778. return m.OldStatus(ctx)
  8779. case contact.FieldDeletedAt:
  8780. return m.OldDeletedAt(ctx)
  8781. case contact.FieldWxWxid:
  8782. return m.OldWxWxid(ctx)
  8783. case contact.FieldType:
  8784. return m.OldType(ctx)
  8785. case contact.FieldWxid:
  8786. return m.OldWxid(ctx)
  8787. case contact.FieldAccount:
  8788. return m.OldAccount(ctx)
  8789. case contact.FieldNickname:
  8790. return m.OldNickname(ctx)
  8791. case contact.FieldMarkname:
  8792. return m.OldMarkname(ctx)
  8793. case contact.FieldHeadimg:
  8794. return m.OldHeadimg(ctx)
  8795. case contact.FieldSex:
  8796. return m.OldSex(ctx)
  8797. case contact.FieldStarrole:
  8798. return m.OldStarrole(ctx)
  8799. case contact.FieldDontseeit:
  8800. return m.OldDontseeit(ctx)
  8801. case contact.FieldDontseeme:
  8802. return m.OldDontseeme(ctx)
  8803. case contact.FieldLag:
  8804. return m.OldLag(ctx)
  8805. case contact.FieldGid:
  8806. return m.OldGid(ctx)
  8807. case contact.FieldGname:
  8808. return m.OldGname(ctx)
  8809. case contact.FieldV3:
  8810. return m.OldV3(ctx)
  8811. case contact.FieldOrganizationID:
  8812. return m.OldOrganizationID(ctx)
  8813. }
  8814. return nil, fmt.Errorf("unknown Contact field %s", name)
  8815. }
  8816. // SetField sets the value of a field with the given name. It returns an error if
  8817. // the field is not defined in the schema, or if the type mismatched the field
  8818. // type.
  8819. func (m *ContactMutation) SetField(name string, value ent.Value) error {
  8820. switch name {
  8821. case contact.FieldCreatedAt:
  8822. v, ok := value.(time.Time)
  8823. if !ok {
  8824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8825. }
  8826. m.SetCreatedAt(v)
  8827. return nil
  8828. case contact.FieldUpdatedAt:
  8829. v, ok := value.(time.Time)
  8830. if !ok {
  8831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8832. }
  8833. m.SetUpdatedAt(v)
  8834. return nil
  8835. case contact.FieldStatus:
  8836. v, ok := value.(uint8)
  8837. if !ok {
  8838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8839. }
  8840. m.SetStatus(v)
  8841. return nil
  8842. case contact.FieldDeletedAt:
  8843. v, ok := value.(time.Time)
  8844. if !ok {
  8845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8846. }
  8847. m.SetDeletedAt(v)
  8848. return nil
  8849. case contact.FieldWxWxid:
  8850. v, ok := value.(string)
  8851. if !ok {
  8852. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8853. }
  8854. m.SetWxWxid(v)
  8855. return nil
  8856. case contact.FieldType:
  8857. v, ok := value.(int)
  8858. if !ok {
  8859. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8860. }
  8861. m.SetType(v)
  8862. return nil
  8863. case contact.FieldWxid:
  8864. v, ok := value.(string)
  8865. if !ok {
  8866. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8867. }
  8868. m.SetWxid(v)
  8869. return nil
  8870. case contact.FieldAccount:
  8871. v, ok := value.(string)
  8872. if !ok {
  8873. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8874. }
  8875. m.SetAccount(v)
  8876. return nil
  8877. case contact.FieldNickname:
  8878. v, ok := value.(string)
  8879. if !ok {
  8880. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8881. }
  8882. m.SetNickname(v)
  8883. return nil
  8884. case contact.FieldMarkname:
  8885. v, ok := value.(string)
  8886. if !ok {
  8887. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8888. }
  8889. m.SetMarkname(v)
  8890. return nil
  8891. case contact.FieldHeadimg:
  8892. v, ok := value.(string)
  8893. if !ok {
  8894. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8895. }
  8896. m.SetHeadimg(v)
  8897. return nil
  8898. case contact.FieldSex:
  8899. v, ok := value.(int)
  8900. if !ok {
  8901. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8902. }
  8903. m.SetSex(v)
  8904. return nil
  8905. case contact.FieldStarrole:
  8906. v, ok := value.(string)
  8907. if !ok {
  8908. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8909. }
  8910. m.SetStarrole(v)
  8911. return nil
  8912. case contact.FieldDontseeit:
  8913. v, ok := value.(int)
  8914. if !ok {
  8915. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8916. }
  8917. m.SetDontseeit(v)
  8918. return nil
  8919. case contact.FieldDontseeme:
  8920. v, ok := value.(int)
  8921. if !ok {
  8922. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8923. }
  8924. m.SetDontseeme(v)
  8925. return nil
  8926. case contact.FieldLag:
  8927. v, ok := value.(string)
  8928. if !ok {
  8929. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8930. }
  8931. m.SetLag(v)
  8932. return nil
  8933. case contact.FieldGid:
  8934. v, ok := value.(string)
  8935. if !ok {
  8936. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8937. }
  8938. m.SetGid(v)
  8939. return nil
  8940. case contact.FieldGname:
  8941. v, ok := value.(string)
  8942. if !ok {
  8943. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8944. }
  8945. m.SetGname(v)
  8946. return nil
  8947. case contact.FieldV3:
  8948. v, ok := value.(string)
  8949. if !ok {
  8950. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8951. }
  8952. m.SetV3(v)
  8953. return nil
  8954. case contact.FieldOrganizationID:
  8955. v, ok := value.(uint64)
  8956. if !ok {
  8957. return fmt.Errorf("unexpected type %T for field %s", value, name)
  8958. }
  8959. m.SetOrganizationID(v)
  8960. return nil
  8961. }
  8962. return fmt.Errorf("unknown Contact field %s", name)
  8963. }
  8964. // AddedFields returns all numeric fields that were incremented/decremented during
  8965. // this mutation.
  8966. func (m *ContactMutation) AddedFields() []string {
  8967. var fields []string
  8968. if m.addstatus != nil {
  8969. fields = append(fields, contact.FieldStatus)
  8970. }
  8971. if m.add_type != nil {
  8972. fields = append(fields, contact.FieldType)
  8973. }
  8974. if m.addsex != nil {
  8975. fields = append(fields, contact.FieldSex)
  8976. }
  8977. if m.adddontseeit != nil {
  8978. fields = append(fields, contact.FieldDontseeit)
  8979. }
  8980. if m.adddontseeme != nil {
  8981. fields = append(fields, contact.FieldDontseeme)
  8982. }
  8983. if m.addorganization_id != nil {
  8984. fields = append(fields, contact.FieldOrganizationID)
  8985. }
  8986. return fields
  8987. }
  8988. // AddedField returns the numeric value that was incremented/decremented on a field
  8989. // with the given name. The second boolean return value indicates that this field
  8990. // was not set, or was not defined in the schema.
  8991. func (m *ContactMutation) AddedField(name string) (ent.Value, bool) {
  8992. switch name {
  8993. case contact.FieldStatus:
  8994. return m.AddedStatus()
  8995. case contact.FieldType:
  8996. return m.AddedType()
  8997. case contact.FieldSex:
  8998. return m.AddedSex()
  8999. case contact.FieldDontseeit:
  9000. return m.AddedDontseeit()
  9001. case contact.FieldDontseeme:
  9002. return m.AddedDontseeme()
  9003. case contact.FieldOrganizationID:
  9004. return m.AddedOrganizationID()
  9005. }
  9006. return nil, false
  9007. }
  9008. // AddField adds the value to the field with the given name. It returns an error if
  9009. // the field is not defined in the schema, or if the type mismatched the field
  9010. // type.
  9011. func (m *ContactMutation) AddField(name string, value ent.Value) error {
  9012. switch name {
  9013. case contact.FieldStatus:
  9014. v, ok := value.(int8)
  9015. if !ok {
  9016. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9017. }
  9018. m.AddStatus(v)
  9019. return nil
  9020. case contact.FieldType:
  9021. v, ok := value.(int)
  9022. if !ok {
  9023. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9024. }
  9025. m.AddType(v)
  9026. return nil
  9027. case contact.FieldSex:
  9028. v, ok := value.(int)
  9029. if !ok {
  9030. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9031. }
  9032. m.AddSex(v)
  9033. return nil
  9034. case contact.FieldDontseeit:
  9035. v, ok := value.(int)
  9036. if !ok {
  9037. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9038. }
  9039. m.AddDontseeit(v)
  9040. return nil
  9041. case contact.FieldDontseeme:
  9042. v, ok := value.(int)
  9043. if !ok {
  9044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9045. }
  9046. m.AddDontseeme(v)
  9047. return nil
  9048. case contact.FieldOrganizationID:
  9049. v, ok := value.(int64)
  9050. if !ok {
  9051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9052. }
  9053. m.AddOrganizationID(v)
  9054. return nil
  9055. }
  9056. return fmt.Errorf("unknown Contact numeric field %s", name)
  9057. }
  9058. // ClearedFields returns all nullable fields that were cleared during this
  9059. // mutation.
  9060. func (m *ContactMutation) ClearedFields() []string {
  9061. var fields []string
  9062. if m.FieldCleared(contact.FieldStatus) {
  9063. fields = append(fields, contact.FieldStatus)
  9064. }
  9065. if m.FieldCleared(contact.FieldDeletedAt) {
  9066. fields = append(fields, contact.FieldDeletedAt)
  9067. }
  9068. if m.FieldCleared(contact.FieldType) {
  9069. fields = append(fields, contact.FieldType)
  9070. }
  9071. if m.FieldCleared(contact.FieldOrganizationID) {
  9072. fields = append(fields, contact.FieldOrganizationID)
  9073. }
  9074. return fields
  9075. }
  9076. // FieldCleared returns a boolean indicating if a field with the given name was
  9077. // cleared in this mutation.
  9078. func (m *ContactMutation) FieldCleared(name string) bool {
  9079. _, ok := m.clearedFields[name]
  9080. return ok
  9081. }
  9082. // ClearField clears the value of the field with the given name. It returns an
  9083. // error if the field is not defined in the schema.
  9084. func (m *ContactMutation) ClearField(name string) error {
  9085. switch name {
  9086. case contact.FieldStatus:
  9087. m.ClearStatus()
  9088. return nil
  9089. case contact.FieldDeletedAt:
  9090. m.ClearDeletedAt()
  9091. return nil
  9092. case contact.FieldType:
  9093. m.ClearType()
  9094. return nil
  9095. case contact.FieldOrganizationID:
  9096. m.ClearOrganizationID()
  9097. return nil
  9098. }
  9099. return fmt.Errorf("unknown Contact nullable field %s", name)
  9100. }
  9101. // ResetField resets all changes in the mutation for the field with the given name.
  9102. // It returns an error if the field is not defined in the schema.
  9103. func (m *ContactMutation) ResetField(name string) error {
  9104. switch name {
  9105. case contact.FieldCreatedAt:
  9106. m.ResetCreatedAt()
  9107. return nil
  9108. case contact.FieldUpdatedAt:
  9109. m.ResetUpdatedAt()
  9110. return nil
  9111. case contact.FieldStatus:
  9112. m.ResetStatus()
  9113. return nil
  9114. case contact.FieldDeletedAt:
  9115. m.ResetDeletedAt()
  9116. return nil
  9117. case contact.FieldWxWxid:
  9118. m.ResetWxWxid()
  9119. return nil
  9120. case contact.FieldType:
  9121. m.ResetType()
  9122. return nil
  9123. case contact.FieldWxid:
  9124. m.ResetWxid()
  9125. return nil
  9126. case contact.FieldAccount:
  9127. m.ResetAccount()
  9128. return nil
  9129. case contact.FieldNickname:
  9130. m.ResetNickname()
  9131. return nil
  9132. case contact.FieldMarkname:
  9133. m.ResetMarkname()
  9134. return nil
  9135. case contact.FieldHeadimg:
  9136. m.ResetHeadimg()
  9137. return nil
  9138. case contact.FieldSex:
  9139. m.ResetSex()
  9140. return nil
  9141. case contact.FieldStarrole:
  9142. m.ResetStarrole()
  9143. return nil
  9144. case contact.FieldDontseeit:
  9145. m.ResetDontseeit()
  9146. return nil
  9147. case contact.FieldDontseeme:
  9148. m.ResetDontseeme()
  9149. return nil
  9150. case contact.FieldLag:
  9151. m.ResetLag()
  9152. return nil
  9153. case contact.FieldGid:
  9154. m.ResetGid()
  9155. return nil
  9156. case contact.FieldGname:
  9157. m.ResetGname()
  9158. return nil
  9159. case contact.FieldV3:
  9160. m.ResetV3()
  9161. return nil
  9162. case contact.FieldOrganizationID:
  9163. m.ResetOrganizationID()
  9164. return nil
  9165. }
  9166. return fmt.Errorf("unknown Contact field %s", name)
  9167. }
  9168. // AddedEdges returns all edge names that were set/added in this mutation.
  9169. func (m *ContactMutation) AddedEdges() []string {
  9170. edges := make([]string, 0, 2)
  9171. if m.contact_relationships != nil {
  9172. edges = append(edges, contact.EdgeContactRelationships)
  9173. }
  9174. if m.contact_messages != nil {
  9175. edges = append(edges, contact.EdgeContactMessages)
  9176. }
  9177. return edges
  9178. }
  9179. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9180. // name in this mutation.
  9181. func (m *ContactMutation) AddedIDs(name string) []ent.Value {
  9182. switch name {
  9183. case contact.EdgeContactRelationships:
  9184. ids := make([]ent.Value, 0, len(m.contact_relationships))
  9185. for id := range m.contact_relationships {
  9186. ids = append(ids, id)
  9187. }
  9188. return ids
  9189. case contact.EdgeContactMessages:
  9190. ids := make([]ent.Value, 0, len(m.contact_messages))
  9191. for id := range m.contact_messages {
  9192. ids = append(ids, id)
  9193. }
  9194. return ids
  9195. }
  9196. return nil
  9197. }
  9198. // RemovedEdges returns all edge names that were removed in this mutation.
  9199. func (m *ContactMutation) RemovedEdges() []string {
  9200. edges := make([]string, 0, 2)
  9201. if m.removedcontact_relationships != nil {
  9202. edges = append(edges, contact.EdgeContactRelationships)
  9203. }
  9204. if m.removedcontact_messages != nil {
  9205. edges = append(edges, contact.EdgeContactMessages)
  9206. }
  9207. return edges
  9208. }
  9209. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9210. // the given name in this mutation.
  9211. func (m *ContactMutation) RemovedIDs(name string) []ent.Value {
  9212. switch name {
  9213. case contact.EdgeContactRelationships:
  9214. ids := make([]ent.Value, 0, len(m.removedcontact_relationships))
  9215. for id := range m.removedcontact_relationships {
  9216. ids = append(ids, id)
  9217. }
  9218. return ids
  9219. case contact.EdgeContactMessages:
  9220. ids := make([]ent.Value, 0, len(m.removedcontact_messages))
  9221. for id := range m.removedcontact_messages {
  9222. ids = append(ids, id)
  9223. }
  9224. return ids
  9225. }
  9226. return nil
  9227. }
  9228. // ClearedEdges returns all edge names that were cleared in this mutation.
  9229. func (m *ContactMutation) ClearedEdges() []string {
  9230. edges := make([]string, 0, 2)
  9231. if m.clearedcontact_relationships {
  9232. edges = append(edges, contact.EdgeContactRelationships)
  9233. }
  9234. if m.clearedcontact_messages {
  9235. edges = append(edges, contact.EdgeContactMessages)
  9236. }
  9237. return edges
  9238. }
  9239. // EdgeCleared returns a boolean which indicates if the edge with the given name
  9240. // was cleared in this mutation.
  9241. func (m *ContactMutation) EdgeCleared(name string) bool {
  9242. switch name {
  9243. case contact.EdgeContactRelationships:
  9244. return m.clearedcontact_relationships
  9245. case contact.EdgeContactMessages:
  9246. return m.clearedcontact_messages
  9247. }
  9248. return false
  9249. }
  9250. // ClearEdge clears the value of the edge with the given name. It returns an error
  9251. // if that edge is not defined in the schema.
  9252. func (m *ContactMutation) ClearEdge(name string) error {
  9253. switch name {
  9254. }
  9255. return fmt.Errorf("unknown Contact unique edge %s", name)
  9256. }
  9257. // ResetEdge resets all changes to the edge with the given name in this mutation.
  9258. // It returns an error if the edge is not defined in the schema.
  9259. func (m *ContactMutation) ResetEdge(name string) error {
  9260. switch name {
  9261. case contact.EdgeContactRelationships:
  9262. m.ResetContactRelationships()
  9263. return nil
  9264. case contact.EdgeContactMessages:
  9265. m.ResetContactMessages()
  9266. return nil
  9267. }
  9268. return fmt.Errorf("unknown Contact edge %s", name)
  9269. }
  9270. // CreditBalanceMutation represents an operation that mutates the CreditBalance nodes in the graph.
  9271. type CreditBalanceMutation struct {
  9272. config
  9273. op Op
  9274. typ string
  9275. id *uint64
  9276. created_at *time.Time
  9277. updated_at *time.Time
  9278. deleted_at *time.Time
  9279. user_id *string
  9280. balance *float32
  9281. addbalance *float32
  9282. status *int
  9283. addstatus *int
  9284. organization_id *uint64
  9285. addorganization_id *int64
  9286. clearedFields map[string]struct{}
  9287. done bool
  9288. oldValue func(context.Context) (*CreditBalance, error)
  9289. predicates []predicate.CreditBalance
  9290. }
  9291. var _ ent.Mutation = (*CreditBalanceMutation)(nil)
  9292. // creditbalanceOption allows management of the mutation configuration using functional options.
  9293. type creditbalanceOption func(*CreditBalanceMutation)
  9294. // newCreditBalanceMutation creates new mutation for the CreditBalance entity.
  9295. func newCreditBalanceMutation(c config, op Op, opts ...creditbalanceOption) *CreditBalanceMutation {
  9296. m := &CreditBalanceMutation{
  9297. config: c,
  9298. op: op,
  9299. typ: TypeCreditBalance,
  9300. clearedFields: make(map[string]struct{}),
  9301. }
  9302. for _, opt := range opts {
  9303. opt(m)
  9304. }
  9305. return m
  9306. }
  9307. // withCreditBalanceID sets the ID field of the mutation.
  9308. func withCreditBalanceID(id uint64) creditbalanceOption {
  9309. return func(m *CreditBalanceMutation) {
  9310. var (
  9311. err error
  9312. once sync.Once
  9313. value *CreditBalance
  9314. )
  9315. m.oldValue = func(ctx context.Context) (*CreditBalance, error) {
  9316. once.Do(func() {
  9317. if m.done {
  9318. err = errors.New("querying old values post mutation is not allowed")
  9319. } else {
  9320. value, err = m.Client().CreditBalance.Get(ctx, id)
  9321. }
  9322. })
  9323. return value, err
  9324. }
  9325. m.id = &id
  9326. }
  9327. }
  9328. // withCreditBalance sets the old CreditBalance of the mutation.
  9329. func withCreditBalance(node *CreditBalance) creditbalanceOption {
  9330. return func(m *CreditBalanceMutation) {
  9331. m.oldValue = func(context.Context) (*CreditBalance, error) {
  9332. return node, nil
  9333. }
  9334. m.id = &node.ID
  9335. }
  9336. }
  9337. // Client returns a new `ent.Client` from the mutation. If the mutation was
  9338. // executed in a transaction (ent.Tx), a transactional client is returned.
  9339. func (m CreditBalanceMutation) Client() *Client {
  9340. client := &Client{config: m.config}
  9341. client.init()
  9342. return client
  9343. }
  9344. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  9345. // it returns an error otherwise.
  9346. func (m CreditBalanceMutation) Tx() (*Tx, error) {
  9347. if _, ok := m.driver.(*txDriver); !ok {
  9348. return nil, errors.New("ent: mutation is not running in a transaction")
  9349. }
  9350. tx := &Tx{config: m.config}
  9351. tx.init()
  9352. return tx, nil
  9353. }
  9354. // SetID sets the value of the id field. Note that this
  9355. // operation is only accepted on creation of CreditBalance entities.
  9356. func (m *CreditBalanceMutation) SetID(id uint64) {
  9357. m.id = &id
  9358. }
  9359. // ID returns the ID value in the mutation. Note that the ID is only available
  9360. // if it was provided to the builder or after it was returned from the database.
  9361. func (m *CreditBalanceMutation) ID() (id uint64, exists bool) {
  9362. if m.id == nil {
  9363. return
  9364. }
  9365. return *m.id, true
  9366. }
  9367. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  9368. // That means, if the mutation is applied within a transaction with an isolation level such
  9369. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  9370. // or updated by the mutation.
  9371. func (m *CreditBalanceMutation) IDs(ctx context.Context) ([]uint64, error) {
  9372. switch {
  9373. case m.op.Is(OpUpdateOne | OpDeleteOne):
  9374. id, exists := m.ID()
  9375. if exists {
  9376. return []uint64{id}, nil
  9377. }
  9378. fallthrough
  9379. case m.op.Is(OpUpdate | OpDelete):
  9380. return m.Client().CreditBalance.Query().Where(m.predicates...).IDs(ctx)
  9381. default:
  9382. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  9383. }
  9384. }
  9385. // SetCreatedAt sets the "created_at" field.
  9386. func (m *CreditBalanceMutation) SetCreatedAt(t time.Time) {
  9387. m.created_at = &t
  9388. }
  9389. // CreatedAt returns the value of the "created_at" field in the mutation.
  9390. func (m *CreditBalanceMutation) CreatedAt() (r time.Time, exists bool) {
  9391. v := m.created_at
  9392. if v == nil {
  9393. return
  9394. }
  9395. return *v, true
  9396. }
  9397. // OldCreatedAt returns the old "created_at" field's value of the CreditBalance entity.
  9398. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9399. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9400. func (m *CreditBalanceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  9401. if !m.op.Is(OpUpdateOne) {
  9402. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  9403. }
  9404. if m.id == nil || m.oldValue == nil {
  9405. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  9406. }
  9407. oldValue, err := m.oldValue(ctx)
  9408. if err != nil {
  9409. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  9410. }
  9411. return oldValue.CreatedAt, nil
  9412. }
  9413. // ResetCreatedAt resets all changes to the "created_at" field.
  9414. func (m *CreditBalanceMutation) ResetCreatedAt() {
  9415. m.created_at = nil
  9416. }
  9417. // SetUpdatedAt sets the "updated_at" field.
  9418. func (m *CreditBalanceMutation) SetUpdatedAt(t time.Time) {
  9419. m.updated_at = &t
  9420. }
  9421. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  9422. func (m *CreditBalanceMutation) UpdatedAt() (r time.Time, exists bool) {
  9423. v := m.updated_at
  9424. if v == nil {
  9425. return
  9426. }
  9427. return *v, true
  9428. }
  9429. // OldUpdatedAt returns the old "updated_at" field's value of the CreditBalance entity.
  9430. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9431. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9432. func (m *CreditBalanceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  9433. if !m.op.Is(OpUpdateOne) {
  9434. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  9435. }
  9436. if m.id == nil || m.oldValue == nil {
  9437. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  9438. }
  9439. oldValue, err := m.oldValue(ctx)
  9440. if err != nil {
  9441. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  9442. }
  9443. return oldValue.UpdatedAt, nil
  9444. }
  9445. // ResetUpdatedAt resets all changes to the "updated_at" field.
  9446. func (m *CreditBalanceMutation) ResetUpdatedAt() {
  9447. m.updated_at = nil
  9448. }
  9449. // SetDeletedAt sets the "deleted_at" field.
  9450. func (m *CreditBalanceMutation) SetDeletedAt(t time.Time) {
  9451. m.deleted_at = &t
  9452. }
  9453. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  9454. func (m *CreditBalanceMutation) DeletedAt() (r time.Time, exists bool) {
  9455. v := m.deleted_at
  9456. if v == nil {
  9457. return
  9458. }
  9459. return *v, true
  9460. }
  9461. // OldDeletedAt returns the old "deleted_at" field's value of the CreditBalance entity.
  9462. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9464. func (m *CreditBalanceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  9465. if !m.op.Is(OpUpdateOne) {
  9466. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  9467. }
  9468. if m.id == nil || m.oldValue == nil {
  9469. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  9470. }
  9471. oldValue, err := m.oldValue(ctx)
  9472. if err != nil {
  9473. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  9474. }
  9475. return oldValue.DeletedAt, nil
  9476. }
  9477. // ClearDeletedAt clears the value of the "deleted_at" field.
  9478. func (m *CreditBalanceMutation) ClearDeletedAt() {
  9479. m.deleted_at = nil
  9480. m.clearedFields[creditbalance.FieldDeletedAt] = struct{}{}
  9481. }
  9482. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  9483. func (m *CreditBalanceMutation) DeletedAtCleared() bool {
  9484. _, ok := m.clearedFields[creditbalance.FieldDeletedAt]
  9485. return ok
  9486. }
  9487. // ResetDeletedAt resets all changes to the "deleted_at" field.
  9488. func (m *CreditBalanceMutation) ResetDeletedAt() {
  9489. m.deleted_at = nil
  9490. delete(m.clearedFields, creditbalance.FieldDeletedAt)
  9491. }
  9492. // SetUserID sets the "user_id" field.
  9493. func (m *CreditBalanceMutation) SetUserID(s string) {
  9494. m.user_id = &s
  9495. }
  9496. // UserID returns the value of the "user_id" field in the mutation.
  9497. func (m *CreditBalanceMutation) UserID() (r string, exists bool) {
  9498. v := m.user_id
  9499. if v == nil {
  9500. return
  9501. }
  9502. return *v, true
  9503. }
  9504. // OldUserID returns the old "user_id" field's value of the CreditBalance entity.
  9505. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9506. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9507. func (m *CreditBalanceMutation) OldUserID(ctx context.Context) (v string, err error) {
  9508. if !m.op.Is(OpUpdateOne) {
  9509. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  9510. }
  9511. if m.id == nil || m.oldValue == nil {
  9512. return v, errors.New("OldUserID requires an ID field in the mutation")
  9513. }
  9514. oldValue, err := m.oldValue(ctx)
  9515. if err != nil {
  9516. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  9517. }
  9518. return oldValue.UserID, nil
  9519. }
  9520. // ResetUserID resets all changes to the "user_id" field.
  9521. func (m *CreditBalanceMutation) ResetUserID() {
  9522. m.user_id = nil
  9523. }
  9524. // SetBalance sets the "balance" field.
  9525. func (m *CreditBalanceMutation) SetBalance(f float32) {
  9526. m.balance = &f
  9527. m.addbalance = nil
  9528. }
  9529. // Balance returns the value of the "balance" field in the mutation.
  9530. func (m *CreditBalanceMutation) Balance() (r float32, exists bool) {
  9531. v := m.balance
  9532. if v == nil {
  9533. return
  9534. }
  9535. return *v, true
  9536. }
  9537. // OldBalance returns the old "balance" field's value of the CreditBalance entity.
  9538. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9539. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9540. func (m *CreditBalanceMutation) OldBalance(ctx context.Context) (v float32, err error) {
  9541. if !m.op.Is(OpUpdateOne) {
  9542. return v, errors.New("OldBalance is only allowed on UpdateOne operations")
  9543. }
  9544. if m.id == nil || m.oldValue == nil {
  9545. return v, errors.New("OldBalance requires an ID field in the mutation")
  9546. }
  9547. oldValue, err := m.oldValue(ctx)
  9548. if err != nil {
  9549. return v, fmt.Errorf("querying old value for OldBalance: %w", err)
  9550. }
  9551. return oldValue.Balance, nil
  9552. }
  9553. // AddBalance adds f to the "balance" field.
  9554. func (m *CreditBalanceMutation) AddBalance(f float32) {
  9555. if m.addbalance != nil {
  9556. *m.addbalance += f
  9557. } else {
  9558. m.addbalance = &f
  9559. }
  9560. }
  9561. // AddedBalance returns the value that was added to the "balance" field in this mutation.
  9562. func (m *CreditBalanceMutation) AddedBalance() (r float32, exists bool) {
  9563. v := m.addbalance
  9564. if v == nil {
  9565. return
  9566. }
  9567. return *v, true
  9568. }
  9569. // ResetBalance resets all changes to the "balance" field.
  9570. func (m *CreditBalanceMutation) ResetBalance() {
  9571. m.balance = nil
  9572. m.addbalance = nil
  9573. }
  9574. // SetStatus sets the "status" field.
  9575. func (m *CreditBalanceMutation) SetStatus(i int) {
  9576. m.status = &i
  9577. m.addstatus = nil
  9578. }
  9579. // Status returns the value of the "status" field in the mutation.
  9580. func (m *CreditBalanceMutation) Status() (r int, exists bool) {
  9581. v := m.status
  9582. if v == nil {
  9583. return
  9584. }
  9585. return *v, true
  9586. }
  9587. // OldStatus returns the old "status" field's value of the CreditBalance entity.
  9588. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9589. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9590. func (m *CreditBalanceMutation) OldStatus(ctx context.Context) (v int, err error) {
  9591. if !m.op.Is(OpUpdateOne) {
  9592. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  9593. }
  9594. if m.id == nil || m.oldValue == nil {
  9595. return v, errors.New("OldStatus requires an ID field in the mutation")
  9596. }
  9597. oldValue, err := m.oldValue(ctx)
  9598. if err != nil {
  9599. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  9600. }
  9601. return oldValue.Status, nil
  9602. }
  9603. // AddStatus adds i to the "status" field.
  9604. func (m *CreditBalanceMutation) AddStatus(i int) {
  9605. if m.addstatus != nil {
  9606. *m.addstatus += i
  9607. } else {
  9608. m.addstatus = &i
  9609. }
  9610. }
  9611. // AddedStatus returns the value that was added to the "status" field in this mutation.
  9612. func (m *CreditBalanceMutation) AddedStatus() (r int, exists bool) {
  9613. v := m.addstatus
  9614. if v == nil {
  9615. return
  9616. }
  9617. return *v, true
  9618. }
  9619. // ClearStatus clears the value of the "status" field.
  9620. func (m *CreditBalanceMutation) ClearStatus() {
  9621. m.status = nil
  9622. m.addstatus = nil
  9623. m.clearedFields[creditbalance.FieldStatus] = struct{}{}
  9624. }
  9625. // StatusCleared returns if the "status" field was cleared in this mutation.
  9626. func (m *CreditBalanceMutation) StatusCleared() bool {
  9627. _, ok := m.clearedFields[creditbalance.FieldStatus]
  9628. return ok
  9629. }
  9630. // ResetStatus resets all changes to the "status" field.
  9631. func (m *CreditBalanceMutation) ResetStatus() {
  9632. m.status = nil
  9633. m.addstatus = nil
  9634. delete(m.clearedFields, creditbalance.FieldStatus)
  9635. }
  9636. // SetOrganizationID sets the "organization_id" field.
  9637. func (m *CreditBalanceMutation) SetOrganizationID(u uint64) {
  9638. m.organization_id = &u
  9639. m.addorganization_id = nil
  9640. }
  9641. // OrganizationID returns the value of the "organization_id" field in the mutation.
  9642. func (m *CreditBalanceMutation) OrganizationID() (r uint64, exists bool) {
  9643. v := m.organization_id
  9644. if v == nil {
  9645. return
  9646. }
  9647. return *v, true
  9648. }
  9649. // OldOrganizationID returns the old "organization_id" field's value of the CreditBalance entity.
  9650. // If the CreditBalance object wasn't provided to the builder, the object is fetched from the database.
  9651. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  9652. func (m *CreditBalanceMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  9653. if !m.op.Is(OpUpdateOne) {
  9654. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  9655. }
  9656. if m.id == nil || m.oldValue == nil {
  9657. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  9658. }
  9659. oldValue, err := m.oldValue(ctx)
  9660. if err != nil {
  9661. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  9662. }
  9663. return oldValue.OrganizationID, nil
  9664. }
  9665. // AddOrganizationID adds u to the "organization_id" field.
  9666. func (m *CreditBalanceMutation) AddOrganizationID(u int64) {
  9667. if m.addorganization_id != nil {
  9668. *m.addorganization_id += u
  9669. } else {
  9670. m.addorganization_id = &u
  9671. }
  9672. }
  9673. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  9674. func (m *CreditBalanceMutation) AddedOrganizationID() (r int64, exists bool) {
  9675. v := m.addorganization_id
  9676. if v == nil {
  9677. return
  9678. }
  9679. return *v, true
  9680. }
  9681. // ClearOrganizationID clears the value of the "organization_id" field.
  9682. func (m *CreditBalanceMutation) ClearOrganizationID() {
  9683. m.organization_id = nil
  9684. m.addorganization_id = nil
  9685. m.clearedFields[creditbalance.FieldOrganizationID] = struct{}{}
  9686. }
  9687. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  9688. func (m *CreditBalanceMutation) OrganizationIDCleared() bool {
  9689. _, ok := m.clearedFields[creditbalance.FieldOrganizationID]
  9690. return ok
  9691. }
  9692. // ResetOrganizationID resets all changes to the "organization_id" field.
  9693. func (m *CreditBalanceMutation) ResetOrganizationID() {
  9694. m.organization_id = nil
  9695. m.addorganization_id = nil
  9696. delete(m.clearedFields, creditbalance.FieldOrganizationID)
  9697. }
  9698. // Where appends a list predicates to the CreditBalanceMutation builder.
  9699. func (m *CreditBalanceMutation) Where(ps ...predicate.CreditBalance) {
  9700. m.predicates = append(m.predicates, ps...)
  9701. }
  9702. // WhereP appends storage-level predicates to the CreditBalanceMutation builder. Using this method,
  9703. // users can use type-assertion to append predicates that do not depend on any generated package.
  9704. func (m *CreditBalanceMutation) WhereP(ps ...func(*sql.Selector)) {
  9705. p := make([]predicate.CreditBalance, len(ps))
  9706. for i := range ps {
  9707. p[i] = ps[i]
  9708. }
  9709. m.Where(p...)
  9710. }
  9711. // Op returns the operation name.
  9712. func (m *CreditBalanceMutation) Op() Op {
  9713. return m.op
  9714. }
  9715. // SetOp allows setting the mutation operation.
  9716. func (m *CreditBalanceMutation) SetOp(op Op) {
  9717. m.op = op
  9718. }
  9719. // Type returns the node type of this mutation (CreditBalance).
  9720. func (m *CreditBalanceMutation) Type() string {
  9721. return m.typ
  9722. }
  9723. // Fields returns all fields that were changed during this mutation. Note that in
  9724. // order to get all numeric fields that were incremented/decremented, call
  9725. // AddedFields().
  9726. func (m *CreditBalanceMutation) Fields() []string {
  9727. fields := make([]string, 0, 7)
  9728. if m.created_at != nil {
  9729. fields = append(fields, creditbalance.FieldCreatedAt)
  9730. }
  9731. if m.updated_at != nil {
  9732. fields = append(fields, creditbalance.FieldUpdatedAt)
  9733. }
  9734. if m.deleted_at != nil {
  9735. fields = append(fields, creditbalance.FieldDeletedAt)
  9736. }
  9737. if m.user_id != nil {
  9738. fields = append(fields, creditbalance.FieldUserID)
  9739. }
  9740. if m.balance != nil {
  9741. fields = append(fields, creditbalance.FieldBalance)
  9742. }
  9743. if m.status != nil {
  9744. fields = append(fields, creditbalance.FieldStatus)
  9745. }
  9746. if m.organization_id != nil {
  9747. fields = append(fields, creditbalance.FieldOrganizationID)
  9748. }
  9749. return fields
  9750. }
  9751. // Field returns the value of a field with the given name. The second boolean
  9752. // return value indicates that this field was not set, or was not defined in the
  9753. // schema.
  9754. func (m *CreditBalanceMutation) Field(name string) (ent.Value, bool) {
  9755. switch name {
  9756. case creditbalance.FieldCreatedAt:
  9757. return m.CreatedAt()
  9758. case creditbalance.FieldUpdatedAt:
  9759. return m.UpdatedAt()
  9760. case creditbalance.FieldDeletedAt:
  9761. return m.DeletedAt()
  9762. case creditbalance.FieldUserID:
  9763. return m.UserID()
  9764. case creditbalance.FieldBalance:
  9765. return m.Balance()
  9766. case creditbalance.FieldStatus:
  9767. return m.Status()
  9768. case creditbalance.FieldOrganizationID:
  9769. return m.OrganizationID()
  9770. }
  9771. return nil, false
  9772. }
  9773. // OldField returns the old value of the field from the database. An error is
  9774. // returned if the mutation operation is not UpdateOne, or the query to the
  9775. // database failed.
  9776. func (m *CreditBalanceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  9777. switch name {
  9778. case creditbalance.FieldCreatedAt:
  9779. return m.OldCreatedAt(ctx)
  9780. case creditbalance.FieldUpdatedAt:
  9781. return m.OldUpdatedAt(ctx)
  9782. case creditbalance.FieldDeletedAt:
  9783. return m.OldDeletedAt(ctx)
  9784. case creditbalance.FieldUserID:
  9785. return m.OldUserID(ctx)
  9786. case creditbalance.FieldBalance:
  9787. return m.OldBalance(ctx)
  9788. case creditbalance.FieldStatus:
  9789. return m.OldStatus(ctx)
  9790. case creditbalance.FieldOrganizationID:
  9791. return m.OldOrganizationID(ctx)
  9792. }
  9793. return nil, fmt.Errorf("unknown CreditBalance field %s", name)
  9794. }
  9795. // SetField sets the value of a field with the given name. It returns an error if
  9796. // the field is not defined in the schema, or if the type mismatched the field
  9797. // type.
  9798. func (m *CreditBalanceMutation) SetField(name string, value ent.Value) error {
  9799. switch name {
  9800. case creditbalance.FieldCreatedAt:
  9801. v, ok := value.(time.Time)
  9802. if !ok {
  9803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9804. }
  9805. m.SetCreatedAt(v)
  9806. return nil
  9807. case creditbalance.FieldUpdatedAt:
  9808. v, ok := value.(time.Time)
  9809. if !ok {
  9810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9811. }
  9812. m.SetUpdatedAt(v)
  9813. return nil
  9814. case creditbalance.FieldDeletedAt:
  9815. v, ok := value.(time.Time)
  9816. if !ok {
  9817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9818. }
  9819. m.SetDeletedAt(v)
  9820. return nil
  9821. case creditbalance.FieldUserID:
  9822. v, ok := value.(string)
  9823. if !ok {
  9824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9825. }
  9826. m.SetUserID(v)
  9827. return nil
  9828. case creditbalance.FieldBalance:
  9829. v, ok := value.(float32)
  9830. if !ok {
  9831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9832. }
  9833. m.SetBalance(v)
  9834. return nil
  9835. case creditbalance.FieldStatus:
  9836. v, ok := value.(int)
  9837. if !ok {
  9838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9839. }
  9840. m.SetStatus(v)
  9841. return nil
  9842. case creditbalance.FieldOrganizationID:
  9843. v, ok := value.(uint64)
  9844. if !ok {
  9845. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9846. }
  9847. m.SetOrganizationID(v)
  9848. return nil
  9849. }
  9850. return fmt.Errorf("unknown CreditBalance field %s", name)
  9851. }
  9852. // AddedFields returns all numeric fields that were incremented/decremented during
  9853. // this mutation.
  9854. func (m *CreditBalanceMutation) AddedFields() []string {
  9855. var fields []string
  9856. if m.addbalance != nil {
  9857. fields = append(fields, creditbalance.FieldBalance)
  9858. }
  9859. if m.addstatus != nil {
  9860. fields = append(fields, creditbalance.FieldStatus)
  9861. }
  9862. if m.addorganization_id != nil {
  9863. fields = append(fields, creditbalance.FieldOrganizationID)
  9864. }
  9865. return fields
  9866. }
  9867. // AddedField returns the numeric value that was incremented/decremented on a field
  9868. // with the given name. The second boolean return value indicates that this field
  9869. // was not set, or was not defined in the schema.
  9870. func (m *CreditBalanceMutation) AddedField(name string) (ent.Value, bool) {
  9871. switch name {
  9872. case creditbalance.FieldBalance:
  9873. return m.AddedBalance()
  9874. case creditbalance.FieldStatus:
  9875. return m.AddedStatus()
  9876. case creditbalance.FieldOrganizationID:
  9877. return m.AddedOrganizationID()
  9878. }
  9879. return nil, false
  9880. }
  9881. // AddField adds the value to the field with the given name. It returns an error if
  9882. // the field is not defined in the schema, or if the type mismatched the field
  9883. // type.
  9884. func (m *CreditBalanceMutation) AddField(name string, value ent.Value) error {
  9885. switch name {
  9886. case creditbalance.FieldBalance:
  9887. v, ok := value.(float32)
  9888. if !ok {
  9889. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9890. }
  9891. m.AddBalance(v)
  9892. return nil
  9893. case creditbalance.FieldStatus:
  9894. v, ok := value.(int)
  9895. if !ok {
  9896. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9897. }
  9898. m.AddStatus(v)
  9899. return nil
  9900. case creditbalance.FieldOrganizationID:
  9901. v, ok := value.(int64)
  9902. if !ok {
  9903. return fmt.Errorf("unexpected type %T for field %s", value, name)
  9904. }
  9905. m.AddOrganizationID(v)
  9906. return nil
  9907. }
  9908. return fmt.Errorf("unknown CreditBalance numeric field %s", name)
  9909. }
  9910. // ClearedFields returns all nullable fields that were cleared during this
  9911. // mutation.
  9912. func (m *CreditBalanceMutation) ClearedFields() []string {
  9913. var fields []string
  9914. if m.FieldCleared(creditbalance.FieldDeletedAt) {
  9915. fields = append(fields, creditbalance.FieldDeletedAt)
  9916. }
  9917. if m.FieldCleared(creditbalance.FieldStatus) {
  9918. fields = append(fields, creditbalance.FieldStatus)
  9919. }
  9920. if m.FieldCleared(creditbalance.FieldOrganizationID) {
  9921. fields = append(fields, creditbalance.FieldOrganizationID)
  9922. }
  9923. return fields
  9924. }
  9925. // FieldCleared returns a boolean indicating if a field with the given name was
  9926. // cleared in this mutation.
  9927. func (m *CreditBalanceMutation) FieldCleared(name string) bool {
  9928. _, ok := m.clearedFields[name]
  9929. return ok
  9930. }
  9931. // ClearField clears the value of the field with the given name. It returns an
  9932. // error if the field is not defined in the schema.
  9933. func (m *CreditBalanceMutation) ClearField(name string) error {
  9934. switch name {
  9935. case creditbalance.FieldDeletedAt:
  9936. m.ClearDeletedAt()
  9937. return nil
  9938. case creditbalance.FieldStatus:
  9939. m.ClearStatus()
  9940. return nil
  9941. case creditbalance.FieldOrganizationID:
  9942. m.ClearOrganizationID()
  9943. return nil
  9944. }
  9945. return fmt.Errorf("unknown CreditBalance nullable field %s", name)
  9946. }
  9947. // ResetField resets all changes in the mutation for the field with the given name.
  9948. // It returns an error if the field is not defined in the schema.
  9949. func (m *CreditBalanceMutation) ResetField(name string) error {
  9950. switch name {
  9951. case creditbalance.FieldCreatedAt:
  9952. m.ResetCreatedAt()
  9953. return nil
  9954. case creditbalance.FieldUpdatedAt:
  9955. m.ResetUpdatedAt()
  9956. return nil
  9957. case creditbalance.FieldDeletedAt:
  9958. m.ResetDeletedAt()
  9959. return nil
  9960. case creditbalance.FieldUserID:
  9961. m.ResetUserID()
  9962. return nil
  9963. case creditbalance.FieldBalance:
  9964. m.ResetBalance()
  9965. return nil
  9966. case creditbalance.FieldStatus:
  9967. m.ResetStatus()
  9968. return nil
  9969. case creditbalance.FieldOrganizationID:
  9970. m.ResetOrganizationID()
  9971. return nil
  9972. }
  9973. return fmt.Errorf("unknown CreditBalance field %s", name)
  9974. }
  9975. // AddedEdges returns all edge names that were set/added in this mutation.
  9976. func (m *CreditBalanceMutation) AddedEdges() []string {
  9977. edges := make([]string, 0, 0)
  9978. return edges
  9979. }
  9980. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  9981. // name in this mutation.
  9982. func (m *CreditBalanceMutation) AddedIDs(name string) []ent.Value {
  9983. return nil
  9984. }
  9985. // RemovedEdges returns all edge names that were removed in this mutation.
  9986. func (m *CreditBalanceMutation) RemovedEdges() []string {
  9987. edges := make([]string, 0, 0)
  9988. return edges
  9989. }
  9990. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  9991. // the given name in this mutation.
  9992. func (m *CreditBalanceMutation) RemovedIDs(name string) []ent.Value {
  9993. return nil
  9994. }
  9995. // ClearedEdges returns all edge names that were cleared in this mutation.
  9996. func (m *CreditBalanceMutation) ClearedEdges() []string {
  9997. edges := make([]string, 0, 0)
  9998. return edges
  9999. }
  10000. // EdgeCleared returns a boolean which indicates if the edge with the given name
  10001. // was cleared in this mutation.
  10002. func (m *CreditBalanceMutation) EdgeCleared(name string) bool {
  10003. return false
  10004. }
  10005. // ClearEdge clears the value of the edge with the given name. It returns an error
  10006. // if that edge is not defined in the schema.
  10007. func (m *CreditBalanceMutation) ClearEdge(name string) error {
  10008. return fmt.Errorf("unknown CreditBalance unique edge %s", name)
  10009. }
  10010. // ResetEdge resets all changes to the edge with the given name in this mutation.
  10011. // It returns an error if the edge is not defined in the schema.
  10012. func (m *CreditBalanceMutation) ResetEdge(name string) error {
  10013. return fmt.Errorf("unknown CreditBalance edge %s", name)
  10014. }
  10015. // CreditUsageMutation represents an operation that mutates the CreditUsage nodes in the graph.
  10016. type CreditUsageMutation struct {
  10017. config
  10018. op Op
  10019. typ string
  10020. id *uint64
  10021. created_at *time.Time
  10022. updated_at *time.Time
  10023. deleted_at *time.Time
  10024. user_id *string
  10025. number *float32
  10026. addnumber *float32
  10027. status *int
  10028. addstatus *int
  10029. ntype *int
  10030. addntype *int
  10031. table *string
  10032. organization_id *uint64
  10033. addorganization_id *int64
  10034. nid *uint64
  10035. addnid *int64
  10036. reason *string
  10037. operator *string
  10038. clearedFields map[string]struct{}
  10039. done bool
  10040. oldValue func(context.Context) (*CreditUsage, error)
  10041. predicates []predicate.CreditUsage
  10042. }
  10043. var _ ent.Mutation = (*CreditUsageMutation)(nil)
  10044. // creditusageOption allows management of the mutation configuration using functional options.
  10045. type creditusageOption func(*CreditUsageMutation)
  10046. // newCreditUsageMutation creates new mutation for the CreditUsage entity.
  10047. func newCreditUsageMutation(c config, op Op, opts ...creditusageOption) *CreditUsageMutation {
  10048. m := &CreditUsageMutation{
  10049. config: c,
  10050. op: op,
  10051. typ: TypeCreditUsage,
  10052. clearedFields: make(map[string]struct{}),
  10053. }
  10054. for _, opt := range opts {
  10055. opt(m)
  10056. }
  10057. return m
  10058. }
  10059. // withCreditUsageID sets the ID field of the mutation.
  10060. func withCreditUsageID(id uint64) creditusageOption {
  10061. return func(m *CreditUsageMutation) {
  10062. var (
  10063. err error
  10064. once sync.Once
  10065. value *CreditUsage
  10066. )
  10067. m.oldValue = func(ctx context.Context) (*CreditUsage, error) {
  10068. once.Do(func() {
  10069. if m.done {
  10070. err = errors.New("querying old values post mutation is not allowed")
  10071. } else {
  10072. value, err = m.Client().CreditUsage.Get(ctx, id)
  10073. }
  10074. })
  10075. return value, err
  10076. }
  10077. m.id = &id
  10078. }
  10079. }
  10080. // withCreditUsage sets the old CreditUsage of the mutation.
  10081. func withCreditUsage(node *CreditUsage) creditusageOption {
  10082. return func(m *CreditUsageMutation) {
  10083. m.oldValue = func(context.Context) (*CreditUsage, error) {
  10084. return node, nil
  10085. }
  10086. m.id = &node.ID
  10087. }
  10088. }
  10089. // Client returns a new `ent.Client` from the mutation. If the mutation was
  10090. // executed in a transaction (ent.Tx), a transactional client is returned.
  10091. func (m CreditUsageMutation) Client() *Client {
  10092. client := &Client{config: m.config}
  10093. client.init()
  10094. return client
  10095. }
  10096. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  10097. // it returns an error otherwise.
  10098. func (m CreditUsageMutation) Tx() (*Tx, error) {
  10099. if _, ok := m.driver.(*txDriver); !ok {
  10100. return nil, errors.New("ent: mutation is not running in a transaction")
  10101. }
  10102. tx := &Tx{config: m.config}
  10103. tx.init()
  10104. return tx, nil
  10105. }
  10106. // SetID sets the value of the id field. Note that this
  10107. // operation is only accepted on creation of CreditUsage entities.
  10108. func (m *CreditUsageMutation) SetID(id uint64) {
  10109. m.id = &id
  10110. }
  10111. // ID returns the ID value in the mutation. Note that the ID is only available
  10112. // if it was provided to the builder or after it was returned from the database.
  10113. func (m *CreditUsageMutation) ID() (id uint64, exists bool) {
  10114. if m.id == nil {
  10115. return
  10116. }
  10117. return *m.id, true
  10118. }
  10119. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  10120. // That means, if the mutation is applied within a transaction with an isolation level such
  10121. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  10122. // or updated by the mutation.
  10123. func (m *CreditUsageMutation) IDs(ctx context.Context) ([]uint64, error) {
  10124. switch {
  10125. case m.op.Is(OpUpdateOne | OpDeleteOne):
  10126. id, exists := m.ID()
  10127. if exists {
  10128. return []uint64{id}, nil
  10129. }
  10130. fallthrough
  10131. case m.op.Is(OpUpdate | OpDelete):
  10132. return m.Client().CreditUsage.Query().Where(m.predicates...).IDs(ctx)
  10133. default:
  10134. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  10135. }
  10136. }
  10137. // SetCreatedAt sets the "created_at" field.
  10138. func (m *CreditUsageMutation) SetCreatedAt(t time.Time) {
  10139. m.created_at = &t
  10140. }
  10141. // CreatedAt returns the value of the "created_at" field in the mutation.
  10142. func (m *CreditUsageMutation) CreatedAt() (r time.Time, exists bool) {
  10143. v := m.created_at
  10144. if v == nil {
  10145. return
  10146. }
  10147. return *v, true
  10148. }
  10149. // OldCreatedAt returns the old "created_at" field's value of the CreditUsage entity.
  10150. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10152. func (m *CreditUsageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  10153. if !m.op.Is(OpUpdateOne) {
  10154. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  10155. }
  10156. if m.id == nil || m.oldValue == nil {
  10157. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  10158. }
  10159. oldValue, err := m.oldValue(ctx)
  10160. if err != nil {
  10161. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  10162. }
  10163. return oldValue.CreatedAt, nil
  10164. }
  10165. // ResetCreatedAt resets all changes to the "created_at" field.
  10166. func (m *CreditUsageMutation) ResetCreatedAt() {
  10167. m.created_at = nil
  10168. }
  10169. // SetUpdatedAt sets the "updated_at" field.
  10170. func (m *CreditUsageMutation) SetUpdatedAt(t time.Time) {
  10171. m.updated_at = &t
  10172. }
  10173. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  10174. func (m *CreditUsageMutation) UpdatedAt() (r time.Time, exists bool) {
  10175. v := m.updated_at
  10176. if v == nil {
  10177. return
  10178. }
  10179. return *v, true
  10180. }
  10181. // OldUpdatedAt returns the old "updated_at" field's value of the CreditUsage entity.
  10182. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10183. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10184. func (m *CreditUsageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  10185. if !m.op.Is(OpUpdateOne) {
  10186. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  10187. }
  10188. if m.id == nil || m.oldValue == nil {
  10189. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  10190. }
  10191. oldValue, err := m.oldValue(ctx)
  10192. if err != nil {
  10193. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  10194. }
  10195. return oldValue.UpdatedAt, nil
  10196. }
  10197. // ResetUpdatedAt resets all changes to the "updated_at" field.
  10198. func (m *CreditUsageMutation) ResetUpdatedAt() {
  10199. m.updated_at = nil
  10200. }
  10201. // SetDeletedAt sets the "deleted_at" field.
  10202. func (m *CreditUsageMutation) SetDeletedAt(t time.Time) {
  10203. m.deleted_at = &t
  10204. }
  10205. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  10206. func (m *CreditUsageMutation) DeletedAt() (r time.Time, exists bool) {
  10207. v := m.deleted_at
  10208. if v == nil {
  10209. return
  10210. }
  10211. return *v, true
  10212. }
  10213. // OldDeletedAt returns the old "deleted_at" field's value of the CreditUsage entity.
  10214. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10215. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10216. func (m *CreditUsageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  10217. if !m.op.Is(OpUpdateOne) {
  10218. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  10219. }
  10220. if m.id == nil || m.oldValue == nil {
  10221. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  10222. }
  10223. oldValue, err := m.oldValue(ctx)
  10224. if err != nil {
  10225. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  10226. }
  10227. return oldValue.DeletedAt, nil
  10228. }
  10229. // ClearDeletedAt clears the value of the "deleted_at" field.
  10230. func (m *CreditUsageMutation) ClearDeletedAt() {
  10231. m.deleted_at = nil
  10232. m.clearedFields[creditusage.FieldDeletedAt] = struct{}{}
  10233. }
  10234. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  10235. func (m *CreditUsageMutation) DeletedAtCleared() bool {
  10236. _, ok := m.clearedFields[creditusage.FieldDeletedAt]
  10237. return ok
  10238. }
  10239. // ResetDeletedAt resets all changes to the "deleted_at" field.
  10240. func (m *CreditUsageMutation) ResetDeletedAt() {
  10241. m.deleted_at = nil
  10242. delete(m.clearedFields, creditusage.FieldDeletedAt)
  10243. }
  10244. // SetUserID sets the "user_id" field.
  10245. func (m *CreditUsageMutation) SetUserID(s string) {
  10246. m.user_id = &s
  10247. }
  10248. // UserID returns the value of the "user_id" field in the mutation.
  10249. func (m *CreditUsageMutation) UserID() (r string, exists bool) {
  10250. v := m.user_id
  10251. if v == nil {
  10252. return
  10253. }
  10254. return *v, true
  10255. }
  10256. // OldUserID returns the old "user_id" field's value of the CreditUsage entity.
  10257. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10259. func (m *CreditUsageMutation) OldUserID(ctx context.Context) (v string, err error) {
  10260. if !m.op.Is(OpUpdateOne) {
  10261. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  10262. }
  10263. if m.id == nil || m.oldValue == nil {
  10264. return v, errors.New("OldUserID requires an ID field in the mutation")
  10265. }
  10266. oldValue, err := m.oldValue(ctx)
  10267. if err != nil {
  10268. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  10269. }
  10270. return oldValue.UserID, nil
  10271. }
  10272. // ResetUserID resets all changes to the "user_id" field.
  10273. func (m *CreditUsageMutation) ResetUserID() {
  10274. m.user_id = nil
  10275. }
  10276. // SetNumber sets the "number" field.
  10277. func (m *CreditUsageMutation) SetNumber(f float32) {
  10278. m.number = &f
  10279. m.addnumber = nil
  10280. }
  10281. // Number returns the value of the "number" field in the mutation.
  10282. func (m *CreditUsageMutation) Number() (r float32, exists bool) {
  10283. v := m.number
  10284. if v == nil {
  10285. return
  10286. }
  10287. return *v, true
  10288. }
  10289. // OldNumber returns the old "number" 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) OldNumber(ctx context.Context) (v float32, err error) {
  10293. if !m.op.Is(OpUpdateOne) {
  10294. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  10295. }
  10296. if m.id == nil || m.oldValue == nil {
  10297. return v, errors.New("OldNumber 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 OldNumber: %w", err)
  10302. }
  10303. return oldValue.Number, nil
  10304. }
  10305. // AddNumber adds f to the "number" field.
  10306. func (m *CreditUsageMutation) AddNumber(f float32) {
  10307. if m.addnumber != nil {
  10308. *m.addnumber += f
  10309. } else {
  10310. m.addnumber = &f
  10311. }
  10312. }
  10313. // AddedNumber returns the value that was added to the "number" field in this mutation.
  10314. func (m *CreditUsageMutation) AddedNumber() (r float32, exists bool) {
  10315. v := m.addnumber
  10316. if v == nil {
  10317. return
  10318. }
  10319. return *v, true
  10320. }
  10321. // ResetNumber resets all changes to the "number" field.
  10322. func (m *CreditUsageMutation) ResetNumber() {
  10323. m.number = nil
  10324. m.addnumber = nil
  10325. }
  10326. // SetStatus sets the "status" field.
  10327. func (m *CreditUsageMutation) SetStatus(i int) {
  10328. m.status = &i
  10329. m.addstatus = nil
  10330. }
  10331. // Status returns the value of the "status" field in the mutation.
  10332. func (m *CreditUsageMutation) Status() (r int, exists bool) {
  10333. v := m.status
  10334. if v == nil {
  10335. return
  10336. }
  10337. return *v, true
  10338. }
  10339. // OldStatus returns the old "status" field's value of the CreditUsage entity.
  10340. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10341. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10342. func (m *CreditUsageMutation) OldStatus(ctx context.Context) (v int, err error) {
  10343. if !m.op.Is(OpUpdateOne) {
  10344. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  10345. }
  10346. if m.id == nil || m.oldValue == nil {
  10347. return v, errors.New("OldStatus requires an ID field in the mutation")
  10348. }
  10349. oldValue, err := m.oldValue(ctx)
  10350. if err != nil {
  10351. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  10352. }
  10353. return oldValue.Status, nil
  10354. }
  10355. // AddStatus adds i to the "status" field.
  10356. func (m *CreditUsageMutation) AddStatus(i int) {
  10357. if m.addstatus != nil {
  10358. *m.addstatus += i
  10359. } else {
  10360. m.addstatus = &i
  10361. }
  10362. }
  10363. // AddedStatus returns the value that was added to the "status" field in this mutation.
  10364. func (m *CreditUsageMutation) AddedStatus() (r int, exists bool) {
  10365. v := m.addstatus
  10366. if v == nil {
  10367. return
  10368. }
  10369. return *v, true
  10370. }
  10371. // ClearStatus clears the value of the "status" field.
  10372. func (m *CreditUsageMutation) ClearStatus() {
  10373. m.status = nil
  10374. m.addstatus = nil
  10375. m.clearedFields[creditusage.FieldStatus] = struct{}{}
  10376. }
  10377. // StatusCleared returns if the "status" field was cleared in this mutation.
  10378. func (m *CreditUsageMutation) StatusCleared() bool {
  10379. _, ok := m.clearedFields[creditusage.FieldStatus]
  10380. return ok
  10381. }
  10382. // ResetStatus resets all changes to the "status" field.
  10383. func (m *CreditUsageMutation) ResetStatus() {
  10384. m.status = nil
  10385. m.addstatus = nil
  10386. delete(m.clearedFields, creditusage.FieldStatus)
  10387. }
  10388. // SetNtype sets the "ntype" field.
  10389. func (m *CreditUsageMutation) SetNtype(i int) {
  10390. m.ntype = &i
  10391. m.addntype = nil
  10392. }
  10393. // Ntype returns the value of the "ntype" field in the mutation.
  10394. func (m *CreditUsageMutation) Ntype() (r int, exists bool) {
  10395. v := m.ntype
  10396. if v == nil {
  10397. return
  10398. }
  10399. return *v, true
  10400. }
  10401. // OldNtype returns the old "ntype" field's value of the CreditUsage entity.
  10402. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10403. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10404. func (m *CreditUsageMutation) OldNtype(ctx context.Context) (v int, err error) {
  10405. if !m.op.Is(OpUpdateOne) {
  10406. return v, errors.New("OldNtype is only allowed on UpdateOne operations")
  10407. }
  10408. if m.id == nil || m.oldValue == nil {
  10409. return v, errors.New("OldNtype requires an ID field in the mutation")
  10410. }
  10411. oldValue, err := m.oldValue(ctx)
  10412. if err != nil {
  10413. return v, fmt.Errorf("querying old value for OldNtype: %w", err)
  10414. }
  10415. return oldValue.Ntype, nil
  10416. }
  10417. // AddNtype adds i to the "ntype" field.
  10418. func (m *CreditUsageMutation) AddNtype(i int) {
  10419. if m.addntype != nil {
  10420. *m.addntype += i
  10421. } else {
  10422. m.addntype = &i
  10423. }
  10424. }
  10425. // AddedNtype returns the value that was added to the "ntype" field in this mutation.
  10426. func (m *CreditUsageMutation) AddedNtype() (r int, exists bool) {
  10427. v := m.addntype
  10428. if v == nil {
  10429. return
  10430. }
  10431. return *v, true
  10432. }
  10433. // ResetNtype resets all changes to the "ntype" field.
  10434. func (m *CreditUsageMutation) ResetNtype() {
  10435. m.ntype = nil
  10436. m.addntype = nil
  10437. }
  10438. // SetTable sets the "table" field.
  10439. func (m *CreditUsageMutation) SetTable(s string) {
  10440. m.table = &s
  10441. }
  10442. // Table returns the value of the "table" field in the mutation.
  10443. func (m *CreditUsageMutation) Table() (r string, exists bool) {
  10444. v := m.table
  10445. if v == nil {
  10446. return
  10447. }
  10448. return *v, true
  10449. }
  10450. // OldTable returns the old "table" field's value of the CreditUsage entity.
  10451. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10452. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10453. func (m *CreditUsageMutation) OldTable(ctx context.Context) (v string, err error) {
  10454. if !m.op.Is(OpUpdateOne) {
  10455. return v, errors.New("OldTable is only allowed on UpdateOne operations")
  10456. }
  10457. if m.id == nil || m.oldValue == nil {
  10458. return v, errors.New("OldTable requires an ID field in the mutation")
  10459. }
  10460. oldValue, err := m.oldValue(ctx)
  10461. if err != nil {
  10462. return v, fmt.Errorf("querying old value for OldTable: %w", err)
  10463. }
  10464. return oldValue.Table, nil
  10465. }
  10466. // ResetTable resets all changes to the "table" field.
  10467. func (m *CreditUsageMutation) ResetTable() {
  10468. m.table = nil
  10469. }
  10470. // SetOrganizationID sets the "organization_id" field.
  10471. func (m *CreditUsageMutation) SetOrganizationID(u uint64) {
  10472. m.organization_id = &u
  10473. m.addorganization_id = nil
  10474. }
  10475. // OrganizationID returns the value of the "organization_id" field in the mutation.
  10476. func (m *CreditUsageMutation) OrganizationID() (r uint64, exists bool) {
  10477. v := m.organization_id
  10478. if v == nil {
  10479. return
  10480. }
  10481. return *v, true
  10482. }
  10483. // OldOrganizationID returns the old "organization_id" field's value of the CreditUsage entity.
  10484. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10485. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10486. func (m *CreditUsageMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  10487. if !m.op.Is(OpUpdateOne) {
  10488. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  10489. }
  10490. if m.id == nil || m.oldValue == nil {
  10491. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  10492. }
  10493. oldValue, err := m.oldValue(ctx)
  10494. if err != nil {
  10495. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  10496. }
  10497. return oldValue.OrganizationID, nil
  10498. }
  10499. // AddOrganizationID adds u to the "organization_id" field.
  10500. func (m *CreditUsageMutation) AddOrganizationID(u int64) {
  10501. if m.addorganization_id != nil {
  10502. *m.addorganization_id += u
  10503. } else {
  10504. m.addorganization_id = &u
  10505. }
  10506. }
  10507. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  10508. func (m *CreditUsageMutation) AddedOrganizationID() (r int64, exists bool) {
  10509. v := m.addorganization_id
  10510. if v == nil {
  10511. return
  10512. }
  10513. return *v, true
  10514. }
  10515. // ClearOrganizationID clears the value of the "organization_id" field.
  10516. func (m *CreditUsageMutation) ClearOrganizationID() {
  10517. m.organization_id = nil
  10518. m.addorganization_id = nil
  10519. m.clearedFields[creditusage.FieldOrganizationID] = struct{}{}
  10520. }
  10521. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  10522. func (m *CreditUsageMutation) OrganizationIDCleared() bool {
  10523. _, ok := m.clearedFields[creditusage.FieldOrganizationID]
  10524. return ok
  10525. }
  10526. // ResetOrganizationID resets all changes to the "organization_id" field.
  10527. func (m *CreditUsageMutation) ResetOrganizationID() {
  10528. m.organization_id = nil
  10529. m.addorganization_id = nil
  10530. delete(m.clearedFields, creditusage.FieldOrganizationID)
  10531. }
  10532. // SetNid sets the "nid" field.
  10533. func (m *CreditUsageMutation) SetNid(u uint64) {
  10534. m.nid = &u
  10535. m.addnid = nil
  10536. }
  10537. // Nid returns the value of the "nid" field in the mutation.
  10538. func (m *CreditUsageMutation) Nid() (r uint64, exists bool) {
  10539. v := m.nid
  10540. if v == nil {
  10541. return
  10542. }
  10543. return *v, true
  10544. }
  10545. // OldNid returns the old "nid" field's value of the CreditUsage entity.
  10546. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10547. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10548. func (m *CreditUsageMutation) OldNid(ctx context.Context) (v uint64, err error) {
  10549. if !m.op.Is(OpUpdateOne) {
  10550. return v, errors.New("OldNid is only allowed on UpdateOne operations")
  10551. }
  10552. if m.id == nil || m.oldValue == nil {
  10553. return v, errors.New("OldNid requires an ID field in the mutation")
  10554. }
  10555. oldValue, err := m.oldValue(ctx)
  10556. if err != nil {
  10557. return v, fmt.Errorf("querying old value for OldNid: %w", err)
  10558. }
  10559. return oldValue.Nid, nil
  10560. }
  10561. // AddNid adds u to the "nid" field.
  10562. func (m *CreditUsageMutation) AddNid(u int64) {
  10563. if m.addnid != nil {
  10564. *m.addnid += u
  10565. } else {
  10566. m.addnid = &u
  10567. }
  10568. }
  10569. // AddedNid returns the value that was added to the "nid" field in this mutation.
  10570. func (m *CreditUsageMutation) AddedNid() (r int64, exists bool) {
  10571. v := m.addnid
  10572. if v == nil {
  10573. return
  10574. }
  10575. return *v, true
  10576. }
  10577. // ResetNid resets all changes to the "nid" field.
  10578. func (m *CreditUsageMutation) ResetNid() {
  10579. m.nid = nil
  10580. m.addnid = nil
  10581. }
  10582. // SetReason sets the "reason" field.
  10583. func (m *CreditUsageMutation) SetReason(s string) {
  10584. m.reason = &s
  10585. }
  10586. // Reason returns the value of the "reason" field in the mutation.
  10587. func (m *CreditUsageMutation) Reason() (r string, exists bool) {
  10588. v := m.reason
  10589. if v == nil {
  10590. return
  10591. }
  10592. return *v, true
  10593. }
  10594. // OldReason returns the old "reason" field's value of the CreditUsage entity.
  10595. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10596. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10597. func (m *CreditUsageMutation) OldReason(ctx context.Context) (v string, err error) {
  10598. if !m.op.Is(OpUpdateOne) {
  10599. return v, errors.New("OldReason is only allowed on UpdateOne operations")
  10600. }
  10601. if m.id == nil || m.oldValue == nil {
  10602. return v, errors.New("OldReason requires an ID field in the mutation")
  10603. }
  10604. oldValue, err := m.oldValue(ctx)
  10605. if err != nil {
  10606. return v, fmt.Errorf("querying old value for OldReason: %w", err)
  10607. }
  10608. return oldValue.Reason, nil
  10609. }
  10610. // ResetReason resets all changes to the "reason" field.
  10611. func (m *CreditUsageMutation) ResetReason() {
  10612. m.reason = nil
  10613. }
  10614. // SetOperator sets the "operator" field.
  10615. func (m *CreditUsageMutation) SetOperator(s string) {
  10616. m.operator = &s
  10617. }
  10618. // Operator returns the value of the "operator" field in the mutation.
  10619. func (m *CreditUsageMutation) Operator() (r string, exists bool) {
  10620. v := m.operator
  10621. if v == nil {
  10622. return
  10623. }
  10624. return *v, true
  10625. }
  10626. // OldOperator returns the old "operator" field's value of the CreditUsage entity.
  10627. // If the CreditUsage object wasn't provided to the builder, the object is fetched from the database.
  10628. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  10629. func (m *CreditUsageMutation) OldOperator(ctx context.Context) (v string, err error) {
  10630. if !m.op.Is(OpUpdateOne) {
  10631. return v, errors.New("OldOperator is only allowed on UpdateOne operations")
  10632. }
  10633. if m.id == nil || m.oldValue == nil {
  10634. return v, errors.New("OldOperator requires an ID field in the mutation")
  10635. }
  10636. oldValue, err := m.oldValue(ctx)
  10637. if err != nil {
  10638. return v, fmt.Errorf("querying old value for OldOperator: %w", err)
  10639. }
  10640. return oldValue.Operator, nil
  10641. }
  10642. // ResetOperator resets all changes to the "operator" field.
  10643. func (m *CreditUsageMutation) ResetOperator() {
  10644. m.operator = nil
  10645. }
  10646. // Where appends a list predicates to the CreditUsageMutation builder.
  10647. func (m *CreditUsageMutation) Where(ps ...predicate.CreditUsage) {
  10648. m.predicates = append(m.predicates, ps...)
  10649. }
  10650. // WhereP appends storage-level predicates to the CreditUsageMutation builder. Using this method,
  10651. // users can use type-assertion to append predicates that do not depend on any generated package.
  10652. func (m *CreditUsageMutation) WhereP(ps ...func(*sql.Selector)) {
  10653. p := make([]predicate.CreditUsage, len(ps))
  10654. for i := range ps {
  10655. p[i] = ps[i]
  10656. }
  10657. m.Where(p...)
  10658. }
  10659. // Op returns the operation name.
  10660. func (m *CreditUsageMutation) Op() Op {
  10661. return m.op
  10662. }
  10663. // SetOp allows setting the mutation operation.
  10664. func (m *CreditUsageMutation) SetOp(op Op) {
  10665. m.op = op
  10666. }
  10667. // Type returns the node type of this mutation (CreditUsage).
  10668. func (m *CreditUsageMutation) Type() string {
  10669. return m.typ
  10670. }
  10671. // Fields returns all fields that were changed during this mutation. Note that in
  10672. // order to get all numeric fields that were incremented/decremented, call
  10673. // AddedFields().
  10674. func (m *CreditUsageMutation) Fields() []string {
  10675. fields := make([]string, 0, 12)
  10676. if m.created_at != nil {
  10677. fields = append(fields, creditusage.FieldCreatedAt)
  10678. }
  10679. if m.updated_at != nil {
  10680. fields = append(fields, creditusage.FieldUpdatedAt)
  10681. }
  10682. if m.deleted_at != nil {
  10683. fields = append(fields, creditusage.FieldDeletedAt)
  10684. }
  10685. if m.user_id != nil {
  10686. fields = append(fields, creditusage.FieldUserID)
  10687. }
  10688. if m.number != nil {
  10689. fields = append(fields, creditusage.FieldNumber)
  10690. }
  10691. if m.status != nil {
  10692. fields = append(fields, creditusage.FieldStatus)
  10693. }
  10694. if m.ntype != nil {
  10695. fields = append(fields, creditusage.FieldNtype)
  10696. }
  10697. if m.table != nil {
  10698. fields = append(fields, creditusage.FieldTable)
  10699. }
  10700. if m.organization_id != nil {
  10701. fields = append(fields, creditusage.FieldOrganizationID)
  10702. }
  10703. if m.nid != nil {
  10704. fields = append(fields, creditusage.FieldNid)
  10705. }
  10706. if m.reason != nil {
  10707. fields = append(fields, creditusage.FieldReason)
  10708. }
  10709. if m.operator != nil {
  10710. fields = append(fields, creditusage.FieldOperator)
  10711. }
  10712. return fields
  10713. }
  10714. // Field returns the value of a field with the given name. The second boolean
  10715. // return value indicates that this field was not set, or was not defined in the
  10716. // schema.
  10717. func (m *CreditUsageMutation) Field(name string) (ent.Value, bool) {
  10718. switch name {
  10719. case creditusage.FieldCreatedAt:
  10720. return m.CreatedAt()
  10721. case creditusage.FieldUpdatedAt:
  10722. return m.UpdatedAt()
  10723. case creditusage.FieldDeletedAt:
  10724. return m.DeletedAt()
  10725. case creditusage.FieldUserID:
  10726. return m.UserID()
  10727. case creditusage.FieldNumber:
  10728. return m.Number()
  10729. case creditusage.FieldStatus:
  10730. return m.Status()
  10731. case creditusage.FieldNtype:
  10732. return m.Ntype()
  10733. case creditusage.FieldTable:
  10734. return m.Table()
  10735. case creditusage.FieldOrganizationID:
  10736. return m.OrganizationID()
  10737. case creditusage.FieldNid:
  10738. return m.Nid()
  10739. case creditusage.FieldReason:
  10740. return m.Reason()
  10741. case creditusage.FieldOperator:
  10742. return m.Operator()
  10743. }
  10744. return nil, false
  10745. }
  10746. // OldField returns the old value of the field from the database. An error is
  10747. // returned if the mutation operation is not UpdateOne, or the query to the
  10748. // database failed.
  10749. func (m *CreditUsageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  10750. switch name {
  10751. case creditusage.FieldCreatedAt:
  10752. return m.OldCreatedAt(ctx)
  10753. case creditusage.FieldUpdatedAt:
  10754. return m.OldUpdatedAt(ctx)
  10755. case creditusage.FieldDeletedAt:
  10756. return m.OldDeletedAt(ctx)
  10757. case creditusage.FieldUserID:
  10758. return m.OldUserID(ctx)
  10759. case creditusage.FieldNumber:
  10760. return m.OldNumber(ctx)
  10761. case creditusage.FieldStatus:
  10762. return m.OldStatus(ctx)
  10763. case creditusage.FieldNtype:
  10764. return m.OldNtype(ctx)
  10765. case creditusage.FieldTable:
  10766. return m.OldTable(ctx)
  10767. case creditusage.FieldOrganizationID:
  10768. return m.OldOrganizationID(ctx)
  10769. case creditusage.FieldNid:
  10770. return m.OldNid(ctx)
  10771. case creditusage.FieldReason:
  10772. return m.OldReason(ctx)
  10773. case creditusage.FieldOperator:
  10774. return m.OldOperator(ctx)
  10775. }
  10776. return nil, fmt.Errorf("unknown CreditUsage field %s", name)
  10777. }
  10778. // SetField sets the value of a field with the given name. It returns an error if
  10779. // the field is not defined in the schema, or if the type mismatched the field
  10780. // type.
  10781. func (m *CreditUsageMutation) SetField(name string, value ent.Value) error {
  10782. switch name {
  10783. case creditusage.FieldCreatedAt:
  10784. v, ok := value.(time.Time)
  10785. if !ok {
  10786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10787. }
  10788. m.SetCreatedAt(v)
  10789. return nil
  10790. case creditusage.FieldUpdatedAt:
  10791. v, ok := value.(time.Time)
  10792. if !ok {
  10793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10794. }
  10795. m.SetUpdatedAt(v)
  10796. return nil
  10797. case creditusage.FieldDeletedAt:
  10798. v, ok := value.(time.Time)
  10799. if !ok {
  10800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10801. }
  10802. m.SetDeletedAt(v)
  10803. return nil
  10804. case creditusage.FieldUserID:
  10805. v, ok := value.(string)
  10806. if !ok {
  10807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10808. }
  10809. m.SetUserID(v)
  10810. return nil
  10811. case creditusage.FieldNumber:
  10812. v, ok := value.(float32)
  10813. if !ok {
  10814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10815. }
  10816. m.SetNumber(v)
  10817. return nil
  10818. case creditusage.FieldStatus:
  10819. v, ok := value.(int)
  10820. if !ok {
  10821. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10822. }
  10823. m.SetStatus(v)
  10824. return nil
  10825. case creditusage.FieldNtype:
  10826. v, ok := value.(int)
  10827. if !ok {
  10828. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10829. }
  10830. m.SetNtype(v)
  10831. return nil
  10832. case creditusage.FieldTable:
  10833. v, ok := value.(string)
  10834. if !ok {
  10835. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10836. }
  10837. m.SetTable(v)
  10838. return nil
  10839. case creditusage.FieldOrganizationID:
  10840. v, ok := value.(uint64)
  10841. if !ok {
  10842. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10843. }
  10844. m.SetOrganizationID(v)
  10845. return nil
  10846. case creditusage.FieldNid:
  10847. v, ok := value.(uint64)
  10848. if !ok {
  10849. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10850. }
  10851. m.SetNid(v)
  10852. return nil
  10853. case creditusage.FieldReason:
  10854. v, ok := value.(string)
  10855. if !ok {
  10856. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10857. }
  10858. m.SetReason(v)
  10859. return nil
  10860. case creditusage.FieldOperator:
  10861. v, ok := value.(string)
  10862. if !ok {
  10863. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10864. }
  10865. m.SetOperator(v)
  10866. return nil
  10867. }
  10868. return fmt.Errorf("unknown CreditUsage field %s", name)
  10869. }
  10870. // AddedFields returns all numeric fields that were incremented/decremented during
  10871. // this mutation.
  10872. func (m *CreditUsageMutation) AddedFields() []string {
  10873. var fields []string
  10874. if m.addnumber != nil {
  10875. fields = append(fields, creditusage.FieldNumber)
  10876. }
  10877. if m.addstatus != nil {
  10878. fields = append(fields, creditusage.FieldStatus)
  10879. }
  10880. if m.addntype != nil {
  10881. fields = append(fields, creditusage.FieldNtype)
  10882. }
  10883. if m.addorganization_id != nil {
  10884. fields = append(fields, creditusage.FieldOrganizationID)
  10885. }
  10886. if m.addnid != nil {
  10887. fields = append(fields, creditusage.FieldNid)
  10888. }
  10889. return fields
  10890. }
  10891. // AddedField returns the numeric value that was incremented/decremented on a field
  10892. // with the given name. The second boolean return value indicates that this field
  10893. // was not set, or was not defined in the schema.
  10894. func (m *CreditUsageMutation) AddedField(name string) (ent.Value, bool) {
  10895. switch name {
  10896. case creditusage.FieldNumber:
  10897. return m.AddedNumber()
  10898. case creditusage.FieldStatus:
  10899. return m.AddedStatus()
  10900. case creditusage.FieldNtype:
  10901. return m.AddedNtype()
  10902. case creditusage.FieldOrganizationID:
  10903. return m.AddedOrganizationID()
  10904. case creditusage.FieldNid:
  10905. return m.AddedNid()
  10906. }
  10907. return nil, false
  10908. }
  10909. // AddField adds the value to the field with the given name. It returns an error if
  10910. // the field is not defined in the schema, or if the type mismatched the field
  10911. // type.
  10912. func (m *CreditUsageMutation) AddField(name string, value ent.Value) error {
  10913. switch name {
  10914. case creditusage.FieldNumber:
  10915. v, ok := value.(float32)
  10916. if !ok {
  10917. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10918. }
  10919. m.AddNumber(v)
  10920. return nil
  10921. case creditusage.FieldStatus:
  10922. v, ok := value.(int)
  10923. if !ok {
  10924. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10925. }
  10926. m.AddStatus(v)
  10927. return nil
  10928. case creditusage.FieldNtype:
  10929. v, ok := value.(int)
  10930. if !ok {
  10931. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10932. }
  10933. m.AddNtype(v)
  10934. return nil
  10935. case creditusage.FieldOrganizationID:
  10936. v, ok := value.(int64)
  10937. if !ok {
  10938. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10939. }
  10940. m.AddOrganizationID(v)
  10941. return nil
  10942. case creditusage.FieldNid:
  10943. v, ok := value.(int64)
  10944. if !ok {
  10945. return fmt.Errorf("unexpected type %T for field %s", value, name)
  10946. }
  10947. m.AddNid(v)
  10948. return nil
  10949. }
  10950. return fmt.Errorf("unknown CreditUsage numeric field %s", name)
  10951. }
  10952. // ClearedFields returns all nullable fields that were cleared during this
  10953. // mutation.
  10954. func (m *CreditUsageMutation) ClearedFields() []string {
  10955. var fields []string
  10956. if m.FieldCleared(creditusage.FieldDeletedAt) {
  10957. fields = append(fields, creditusage.FieldDeletedAt)
  10958. }
  10959. if m.FieldCleared(creditusage.FieldStatus) {
  10960. fields = append(fields, creditusage.FieldStatus)
  10961. }
  10962. if m.FieldCleared(creditusage.FieldOrganizationID) {
  10963. fields = append(fields, creditusage.FieldOrganizationID)
  10964. }
  10965. return fields
  10966. }
  10967. // FieldCleared returns a boolean indicating if a field with the given name was
  10968. // cleared in this mutation.
  10969. func (m *CreditUsageMutation) FieldCleared(name string) bool {
  10970. _, ok := m.clearedFields[name]
  10971. return ok
  10972. }
  10973. // ClearField clears the value of the field with the given name. It returns an
  10974. // error if the field is not defined in the schema.
  10975. func (m *CreditUsageMutation) ClearField(name string) error {
  10976. switch name {
  10977. case creditusage.FieldDeletedAt:
  10978. m.ClearDeletedAt()
  10979. return nil
  10980. case creditusage.FieldStatus:
  10981. m.ClearStatus()
  10982. return nil
  10983. case creditusage.FieldOrganizationID:
  10984. m.ClearOrganizationID()
  10985. return nil
  10986. }
  10987. return fmt.Errorf("unknown CreditUsage nullable field %s", name)
  10988. }
  10989. // ResetField resets all changes in the mutation for the field with the given name.
  10990. // It returns an error if the field is not defined in the schema.
  10991. func (m *CreditUsageMutation) ResetField(name string) error {
  10992. switch name {
  10993. case creditusage.FieldCreatedAt:
  10994. m.ResetCreatedAt()
  10995. return nil
  10996. case creditusage.FieldUpdatedAt:
  10997. m.ResetUpdatedAt()
  10998. return nil
  10999. case creditusage.FieldDeletedAt:
  11000. m.ResetDeletedAt()
  11001. return nil
  11002. case creditusage.FieldUserID:
  11003. m.ResetUserID()
  11004. return nil
  11005. case creditusage.FieldNumber:
  11006. m.ResetNumber()
  11007. return nil
  11008. case creditusage.FieldStatus:
  11009. m.ResetStatus()
  11010. return nil
  11011. case creditusage.FieldNtype:
  11012. m.ResetNtype()
  11013. return nil
  11014. case creditusage.FieldTable:
  11015. m.ResetTable()
  11016. return nil
  11017. case creditusage.FieldOrganizationID:
  11018. m.ResetOrganizationID()
  11019. return nil
  11020. case creditusage.FieldNid:
  11021. m.ResetNid()
  11022. return nil
  11023. case creditusage.FieldReason:
  11024. m.ResetReason()
  11025. return nil
  11026. case creditusage.FieldOperator:
  11027. m.ResetOperator()
  11028. return nil
  11029. }
  11030. return fmt.Errorf("unknown CreditUsage field %s", name)
  11031. }
  11032. // AddedEdges returns all edge names that were set/added in this mutation.
  11033. func (m *CreditUsageMutation) AddedEdges() []string {
  11034. edges := make([]string, 0, 0)
  11035. return edges
  11036. }
  11037. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  11038. // name in this mutation.
  11039. func (m *CreditUsageMutation) AddedIDs(name string) []ent.Value {
  11040. return nil
  11041. }
  11042. // RemovedEdges returns all edge names that were removed in this mutation.
  11043. func (m *CreditUsageMutation) RemovedEdges() []string {
  11044. edges := make([]string, 0, 0)
  11045. return edges
  11046. }
  11047. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  11048. // the given name in this mutation.
  11049. func (m *CreditUsageMutation) RemovedIDs(name string) []ent.Value {
  11050. return nil
  11051. }
  11052. // ClearedEdges returns all edge names that were cleared in this mutation.
  11053. func (m *CreditUsageMutation) ClearedEdges() []string {
  11054. edges := make([]string, 0, 0)
  11055. return edges
  11056. }
  11057. // EdgeCleared returns a boolean which indicates if the edge with the given name
  11058. // was cleared in this mutation.
  11059. func (m *CreditUsageMutation) EdgeCleared(name string) bool {
  11060. return false
  11061. }
  11062. // ClearEdge clears the value of the edge with the given name. It returns an error
  11063. // if that edge is not defined in the schema.
  11064. func (m *CreditUsageMutation) ClearEdge(name string) error {
  11065. return fmt.Errorf("unknown CreditUsage unique edge %s", name)
  11066. }
  11067. // ResetEdge resets all changes to the edge with the given name in this mutation.
  11068. // It returns an error if the edge is not defined in the schema.
  11069. func (m *CreditUsageMutation) ResetEdge(name string) error {
  11070. return fmt.Errorf("unknown CreditUsage edge %s", name)
  11071. }
  11072. // EmployeeMutation represents an operation that mutates the Employee nodes in the graph.
  11073. type EmployeeMutation struct {
  11074. config
  11075. op Op
  11076. typ string
  11077. id *uint64
  11078. created_at *time.Time
  11079. updated_at *time.Time
  11080. deleted_at *time.Time
  11081. title *string
  11082. avatar *string
  11083. tags *string
  11084. hire_count *int
  11085. addhire_count *int
  11086. service_count *int
  11087. addservice_count *int
  11088. achievement_count *int
  11089. addachievement_count *int
  11090. intro *string
  11091. estimate *string
  11092. skill *string
  11093. ability_type *string
  11094. scene *string
  11095. switch_in *string
  11096. video_url *string
  11097. organization_id *uint64
  11098. addorganization_id *int64
  11099. category_id *uint64
  11100. addcategory_id *int64
  11101. api_base *string
  11102. api_key *string
  11103. ai_info *string
  11104. is_vip *int
  11105. addis_vip *int
  11106. chat_url *string
  11107. clearedFields map[string]struct{}
  11108. em_work_experiences map[uint64]struct{}
  11109. removedem_work_experiences map[uint64]struct{}
  11110. clearedem_work_experiences bool
  11111. em_tutorial map[uint64]struct{}
  11112. removedem_tutorial map[uint64]struct{}
  11113. clearedem_tutorial bool
  11114. done bool
  11115. oldValue func(context.Context) (*Employee, error)
  11116. predicates []predicate.Employee
  11117. }
  11118. var _ ent.Mutation = (*EmployeeMutation)(nil)
  11119. // employeeOption allows management of the mutation configuration using functional options.
  11120. type employeeOption func(*EmployeeMutation)
  11121. // newEmployeeMutation creates new mutation for the Employee entity.
  11122. func newEmployeeMutation(c config, op Op, opts ...employeeOption) *EmployeeMutation {
  11123. m := &EmployeeMutation{
  11124. config: c,
  11125. op: op,
  11126. typ: TypeEmployee,
  11127. clearedFields: make(map[string]struct{}),
  11128. }
  11129. for _, opt := range opts {
  11130. opt(m)
  11131. }
  11132. return m
  11133. }
  11134. // withEmployeeID sets the ID field of the mutation.
  11135. func withEmployeeID(id uint64) employeeOption {
  11136. return func(m *EmployeeMutation) {
  11137. var (
  11138. err error
  11139. once sync.Once
  11140. value *Employee
  11141. )
  11142. m.oldValue = func(ctx context.Context) (*Employee, error) {
  11143. once.Do(func() {
  11144. if m.done {
  11145. err = errors.New("querying old values post mutation is not allowed")
  11146. } else {
  11147. value, err = m.Client().Employee.Get(ctx, id)
  11148. }
  11149. })
  11150. return value, err
  11151. }
  11152. m.id = &id
  11153. }
  11154. }
  11155. // withEmployee sets the old Employee of the mutation.
  11156. func withEmployee(node *Employee) employeeOption {
  11157. return func(m *EmployeeMutation) {
  11158. m.oldValue = func(context.Context) (*Employee, error) {
  11159. return node, nil
  11160. }
  11161. m.id = &node.ID
  11162. }
  11163. }
  11164. // Client returns a new `ent.Client` from the mutation. If the mutation was
  11165. // executed in a transaction (ent.Tx), a transactional client is returned.
  11166. func (m EmployeeMutation) Client() *Client {
  11167. client := &Client{config: m.config}
  11168. client.init()
  11169. return client
  11170. }
  11171. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  11172. // it returns an error otherwise.
  11173. func (m EmployeeMutation) Tx() (*Tx, error) {
  11174. if _, ok := m.driver.(*txDriver); !ok {
  11175. return nil, errors.New("ent: mutation is not running in a transaction")
  11176. }
  11177. tx := &Tx{config: m.config}
  11178. tx.init()
  11179. return tx, nil
  11180. }
  11181. // SetID sets the value of the id field. Note that this
  11182. // operation is only accepted on creation of Employee entities.
  11183. func (m *EmployeeMutation) SetID(id uint64) {
  11184. m.id = &id
  11185. }
  11186. // ID returns the ID value in the mutation. Note that the ID is only available
  11187. // if it was provided to the builder or after it was returned from the database.
  11188. func (m *EmployeeMutation) ID() (id uint64, exists bool) {
  11189. if m.id == nil {
  11190. return
  11191. }
  11192. return *m.id, true
  11193. }
  11194. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  11195. // That means, if the mutation is applied within a transaction with an isolation level such
  11196. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  11197. // or updated by the mutation.
  11198. func (m *EmployeeMutation) IDs(ctx context.Context) ([]uint64, error) {
  11199. switch {
  11200. case m.op.Is(OpUpdateOne | OpDeleteOne):
  11201. id, exists := m.ID()
  11202. if exists {
  11203. return []uint64{id}, nil
  11204. }
  11205. fallthrough
  11206. case m.op.Is(OpUpdate | OpDelete):
  11207. return m.Client().Employee.Query().Where(m.predicates...).IDs(ctx)
  11208. default:
  11209. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  11210. }
  11211. }
  11212. // SetCreatedAt sets the "created_at" field.
  11213. func (m *EmployeeMutation) SetCreatedAt(t time.Time) {
  11214. m.created_at = &t
  11215. }
  11216. // CreatedAt returns the value of the "created_at" field in the mutation.
  11217. func (m *EmployeeMutation) CreatedAt() (r time.Time, exists bool) {
  11218. v := m.created_at
  11219. if v == nil {
  11220. return
  11221. }
  11222. return *v, true
  11223. }
  11224. // OldCreatedAt returns the old "created_at" field's value of the Employee entity.
  11225. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11226. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11227. func (m *EmployeeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  11228. if !m.op.Is(OpUpdateOne) {
  11229. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  11230. }
  11231. if m.id == nil || m.oldValue == nil {
  11232. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  11233. }
  11234. oldValue, err := m.oldValue(ctx)
  11235. if err != nil {
  11236. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  11237. }
  11238. return oldValue.CreatedAt, nil
  11239. }
  11240. // ResetCreatedAt resets all changes to the "created_at" field.
  11241. func (m *EmployeeMutation) ResetCreatedAt() {
  11242. m.created_at = nil
  11243. }
  11244. // SetUpdatedAt sets the "updated_at" field.
  11245. func (m *EmployeeMutation) SetUpdatedAt(t time.Time) {
  11246. m.updated_at = &t
  11247. }
  11248. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  11249. func (m *EmployeeMutation) UpdatedAt() (r time.Time, exists bool) {
  11250. v := m.updated_at
  11251. if v == nil {
  11252. return
  11253. }
  11254. return *v, true
  11255. }
  11256. // OldUpdatedAt returns the old "updated_at" field's value of the Employee entity.
  11257. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11259. func (m *EmployeeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  11260. if !m.op.Is(OpUpdateOne) {
  11261. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  11262. }
  11263. if m.id == nil || m.oldValue == nil {
  11264. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  11265. }
  11266. oldValue, err := m.oldValue(ctx)
  11267. if err != nil {
  11268. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  11269. }
  11270. return oldValue.UpdatedAt, nil
  11271. }
  11272. // ResetUpdatedAt resets all changes to the "updated_at" field.
  11273. func (m *EmployeeMutation) ResetUpdatedAt() {
  11274. m.updated_at = nil
  11275. }
  11276. // SetDeletedAt sets the "deleted_at" field.
  11277. func (m *EmployeeMutation) SetDeletedAt(t time.Time) {
  11278. m.deleted_at = &t
  11279. }
  11280. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  11281. func (m *EmployeeMutation) DeletedAt() (r time.Time, exists bool) {
  11282. v := m.deleted_at
  11283. if v == nil {
  11284. return
  11285. }
  11286. return *v, true
  11287. }
  11288. // OldDeletedAt returns the old "deleted_at" field's value of the Employee entity.
  11289. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11291. func (m *EmployeeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  11292. if !m.op.Is(OpUpdateOne) {
  11293. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  11294. }
  11295. if m.id == nil || m.oldValue == nil {
  11296. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  11297. }
  11298. oldValue, err := m.oldValue(ctx)
  11299. if err != nil {
  11300. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  11301. }
  11302. return oldValue.DeletedAt, nil
  11303. }
  11304. // ClearDeletedAt clears the value of the "deleted_at" field.
  11305. func (m *EmployeeMutation) ClearDeletedAt() {
  11306. m.deleted_at = nil
  11307. m.clearedFields[employee.FieldDeletedAt] = struct{}{}
  11308. }
  11309. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  11310. func (m *EmployeeMutation) DeletedAtCleared() bool {
  11311. _, ok := m.clearedFields[employee.FieldDeletedAt]
  11312. return ok
  11313. }
  11314. // ResetDeletedAt resets all changes to the "deleted_at" field.
  11315. func (m *EmployeeMutation) ResetDeletedAt() {
  11316. m.deleted_at = nil
  11317. delete(m.clearedFields, employee.FieldDeletedAt)
  11318. }
  11319. // SetTitle sets the "title" field.
  11320. func (m *EmployeeMutation) SetTitle(s string) {
  11321. m.title = &s
  11322. }
  11323. // Title returns the value of the "title" field in the mutation.
  11324. func (m *EmployeeMutation) Title() (r string, exists bool) {
  11325. v := m.title
  11326. if v == nil {
  11327. return
  11328. }
  11329. return *v, true
  11330. }
  11331. // OldTitle returns the old "title" field's value of the Employee entity.
  11332. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11333. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11334. func (m *EmployeeMutation) OldTitle(ctx context.Context) (v string, err error) {
  11335. if !m.op.Is(OpUpdateOne) {
  11336. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  11337. }
  11338. if m.id == nil || m.oldValue == nil {
  11339. return v, errors.New("OldTitle requires an ID field in the mutation")
  11340. }
  11341. oldValue, err := m.oldValue(ctx)
  11342. if err != nil {
  11343. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  11344. }
  11345. return oldValue.Title, nil
  11346. }
  11347. // ResetTitle resets all changes to the "title" field.
  11348. func (m *EmployeeMutation) ResetTitle() {
  11349. m.title = nil
  11350. }
  11351. // SetAvatar sets the "avatar" field.
  11352. func (m *EmployeeMutation) SetAvatar(s string) {
  11353. m.avatar = &s
  11354. }
  11355. // Avatar returns the value of the "avatar" field in the mutation.
  11356. func (m *EmployeeMutation) Avatar() (r string, exists bool) {
  11357. v := m.avatar
  11358. if v == nil {
  11359. return
  11360. }
  11361. return *v, true
  11362. }
  11363. // OldAvatar returns the old "avatar" field's value of the Employee entity.
  11364. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11366. func (m *EmployeeMutation) OldAvatar(ctx context.Context) (v string, err error) {
  11367. if !m.op.Is(OpUpdateOne) {
  11368. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  11369. }
  11370. if m.id == nil || m.oldValue == nil {
  11371. return v, errors.New("OldAvatar requires an ID field in the mutation")
  11372. }
  11373. oldValue, err := m.oldValue(ctx)
  11374. if err != nil {
  11375. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  11376. }
  11377. return oldValue.Avatar, nil
  11378. }
  11379. // ResetAvatar resets all changes to the "avatar" field.
  11380. func (m *EmployeeMutation) ResetAvatar() {
  11381. m.avatar = nil
  11382. }
  11383. // SetTags sets the "tags" field.
  11384. func (m *EmployeeMutation) SetTags(s string) {
  11385. m.tags = &s
  11386. }
  11387. // Tags returns the value of the "tags" field in the mutation.
  11388. func (m *EmployeeMutation) Tags() (r string, exists bool) {
  11389. v := m.tags
  11390. if v == nil {
  11391. return
  11392. }
  11393. return *v, true
  11394. }
  11395. // OldTags returns the old "tags" field's value of the Employee entity.
  11396. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11397. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11398. func (m *EmployeeMutation) OldTags(ctx context.Context) (v string, err error) {
  11399. if !m.op.Is(OpUpdateOne) {
  11400. return v, errors.New("OldTags is only allowed on UpdateOne operations")
  11401. }
  11402. if m.id == nil || m.oldValue == nil {
  11403. return v, errors.New("OldTags requires an ID field in the mutation")
  11404. }
  11405. oldValue, err := m.oldValue(ctx)
  11406. if err != nil {
  11407. return v, fmt.Errorf("querying old value for OldTags: %w", err)
  11408. }
  11409. return oldValue.Tags, nil
  11410. }
  11411. // ResetTags resets all changes to the "tags" field.
  11412. func (m *EmployeeMutation) ResetTags() {
  11413. m.tags = nil
  11414. }
  11415. // SetHireCount sets the "hire_count" field.
  11416. func (m *EmployeeMutation) SetHireCount(i int) {
  11417. m.hire_count = &i
  11418. m.addhire_count = nil
  11419. }
  11420. // HireCount returns the value of the "hire_count" field in the mutation.
  11421. func (m *EmployeeMutation) HireCount() (r int, exists bool) {
  11422. v := m.hire_count
  11423. if v == nil {
  11424. return
  11425. }
  11426. return *v, true
  11427. }
  11428. // OldHireCount returns the old "hire_count" field's value of the Employee entity.
  11429. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11431. func (m *EmployeeMutation) OldHireCount(ctx context.Context) (v int, err error) {
  11432. if !m.op.Is(OpUpdateOne) {
  11433. return v, errors.New("OldHireCount is only allowed on UpdateOne operations")
  11434. }
  11435. if m.id == nil || m.oldValue == nil {
  11436. return v, errors.New("OldHireCount requires an ID field in the mutation")
  11437. }
  11438. oldValue, err := m.oldValue(ctx)
  11439. if err != nil {
  11440. return v, fmt.Errorf("querying old value for OldHireCount: %w", err)
  11441. }
  11442. return oldValue.HireCount, nil
  11443. }
  11444. // AddHireCount adds i to the "hire_count" field.
  11445. func (m *EmployeeMutation) AddHireCount(i int) {
  11446. if m.addhire_count != nil {
  11447. *m.addhire_count += i
  11448. } else {
  11449. m.addhire_count = &i
  11450. }
  11451. }
  11452. // AddedHireCount returns the value that was added to the "hire_count" field in this mutation.
  11453. func (m *EmployeeMutation) AddedHireCount() (r int, exists bool) {
  11454. v := m.addhire_count
  11455. if v == nil {
  11456. return
  11457. }
  11458. return *v, true
  11459. }
  11460. // ResetHireCount resets all changes to the "hire_count" field.
  11461. func (m *EmployeeMutation) ResetHireCount() {
  11462. m.hire_count = nil
  11463. m.addhire_count = nil
  11464. }
  11465. // SetServiceCount sets the "service_count" field.
  11466. func (m *EmployeeMutation) SetServiceCount(i int) {
  11467. m.service_count = &i
  11468. m.addservice_count = nil
  11469. }
  11470. // ServiceCount returns the value of the "service_count" field in the mutation.
  11471. func (m *EmployeeMutation) ServiceCount() (r int, exists bool) {
  11472. v := m.service_count
  11473. if v == nil {
  11474. return
  11475. }
  11476. return *v, true
  11477. }
  11478. // OldServiceCount returns the old "service_count" field's value of the Employee entity.
  11479. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11480. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11481. func (m *EmployeeMutation) OldServiceCount(ctx context.Context) (v int, err error) {
  11482. if !m.op.Is(OpUpdateOne) {
  11483. return v, errors.New("OldServiceCount is only allowed on UpdateOne operations")
  11484. }
  11485. if m.id == nil || m.oldValue == nil {
  11486. return v, errors.New("OldServiceCount requires an ID field in the mutation")
  11487. }
  11488. oldValue, err := m.oldValue(ctx)
  11489. if err != nil {
  11490. return v, fmt.Errorf("querying old value for OldServiceCount: %w", err)
  11491. }
  11492. return oldValue.ServiceCount, nil
  11493. }
  11494. // AddServiceCount adds i to the "service_count" field.
  11495. func (m *EmployeeMutation) AddServiceCount(i int) {
  11496. if m.addservice_count != nil {
  11497. *m.addservice_count += i
  11498. } else {
  11499. m.addservice_count = &i
  11500. }
  11501. }
  11502. // AddedServiceCount returns the value that was added to the "service_count" field in this mutation.
  11503. func (m *EmployeeMutation) AddedServiceCount() (r int, exists bool) {
  11504. v := m.addservice_count
  11505. if v == nil {
  11506. return
  11507. }
  11508. return *v, true
  11509. }
  11510. // ResetServiceCount resets all changes to the "service_count" field.
  11511. func (m *EmployeeMutation) ResetServiceCount() {
  11512. m.service_count = nil
  11513. m.addservice_count = nil
  11514. }
  11515. // SetAchievementCount sets the "achievement_count" field.
  11516. func (m *EmployeeMutation) SetAchievementCount(i int) {
  11517. m.achievement_count = &i
  11518. m.addachievement_count = nil
  11519. }
  11520. // AchievementCount returns the value of the "achievement_count" field in the mutation.
  11521. func (m *EmployeeMutation) AchievementCount() (r int, exists bool) {
  11522. v := m.achievement_count
  11523. if v == nil {
  11524. return
  11525. }
  11526. return *v, true
  11527. }
  11528. // OldAchievementCount returns the old "achievement_count" field's value of the Employee entity.
  11529. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11530. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11531. func (m *EmployeeMutation) OldAchievementCount(ctx context.Context) (v int, err error) {
  11532. if !m.op.Is(OpUpdateOne) {
  11533. return v, errors.New("OldAchievementCount is only allowed on UpdateOne operations")
  11534. }
  11535. if m.id == nil || m.oldValue == nil {
  11536. return v, errors.New("OldAchievementCount requires an ID field in the mutation")
  11537. }
  11538. oldValue, err := m.oldValue(ctx)
  11539. if err != nil {
  11540. return v, fmt.Errorf("querying old value for OldAchievementCount: %w", err)
  11541. }
  11542. return oldValue.AchievementCount, nil
  11543. }
  11544. // AddAchievementCount adds i to the "achievement_count" field.
  11545. func (m *EmployeeMutation) AddAchievementCount(i int) {
  11546. if m.addachievement_count != nil {
  11547. *m.addachievement_count += i
  11548. } else {
  11549. m.addachievement_count = &i
  11550. }
  11551. }
  11552. // AddedAchievementCount returns the value that was added to the "achievement_count" field in this mutation.
  11553. func (m *EmployeeMutation) AddedAchievementCount() (r int, exists bool) {
  11554. v := m.addachievement_count
  11555. if v == nil {
  11556. return
  11557. }
  11558. return *v, true
  11559. }
  11560. // ResetAchievementCount resets all changes to the "achievement_count" field.
  11561. func (m *EmployeeMutation) ResetAchievementCount() {
  11562. m.achievement_count = nil
  11563. m.addachievement_count = nil
  11564. }
  11565. // SetIntro sets the "intro" field.
  11566. func (m *EmployeeMutation) SetIntro(s string) {
  11567. m.intro = &s
  11568. }
  11569. // Intro returns the value of the "intro" field in the mutation.
  11570. func (m *EmployeeMutation) Intro() (r string, exists bool) {
  11571. v := m.intro
  11572. if v == nil {
  11573. return
  11574. }
  11575. return *v, true
  11576. }
  11577. // OldIntro returns the old "intro" field's value of the Employee entity.
  11578. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11579. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11580. func (m *EmployeeMutation) OldIntro(ctx context.Context) (v string, err error) {
  11581. if !m.op.Is(OpUpdateOne) {
  11582. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  11583. }
  11584. if m.id == nil || m.oldValue == nil {
  11585. return v, errors.New("OldIntro requires an ID field in the mutation")
  11586. }
  11587. oldValue, err := m.oldValue(ctx)
  11588. if err != nil {
  11589. return v, fmt.Errorf("querying old value for OldIntro: %w", err)
  11590. }
  11591. return oldValue.Intro, nil
  11592. }
  11593. // ResetIntro resets all changes to the "intro" field.
  11594. func (m *EmployeeMutation) ResetIntro() {
  11595. m.intro = nil
  11596. }
  11597. // SetEstimate sets the "estimate" field.
  11598. func (m *EmployeeMutation) SetEstimate(s string) {
  11599. m.estimate = &s
  11600. }
  11601. // Estimate returns the value of the "estimate" field in the mutation.
  11602. func (m *EmployeeMutation) Estimate() (r string, exists bool) {
  11603. v := m.estimate
  11604. if v == nil {
  11605. return
  11606. }
  11607. return *v, true
  11608. }
  11609. // OldEstimate returns the old "estimate" field's value of the Employee entity.
  11610. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11611. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11612. func (m *EmployeeMutation) OldEstimate(ctx context.Context) (v string, err error) {
  11613. if !m.op.Is(OpUpdateOne) {
  11614. return v, errors.New("OldEstimate is only allowed on UpdateOne operations")
  11615. }
  11616. if m.id == nil || m.oldValue == nil {
  11617. return v, errors.New("OldEstimate requires an ID field in the mutation")
  11618. }
  11619. oldValue, err := m.oldValue(ctx)
  11620. if err != nil {
  11621. return v, fmt.Errorf("querying old value for OldEstimate: %w", err)
  11622. }
  11623. return oldValue.Estimate, nil
  11624. }
  11625. // ResetEstimate resets all changes to the "estimate" field.
  11626. func (m *EmployeeMutation) ResetEstimate() {
  11627. m.estimate = nil
  11628. }
  11629. // SetSkill sets the "skill" field.
  11630. func (m *EmployeeMutation) SetSkill(s string) {
  11631. m.skill = &s
  11632. }
  11633. // Skill returns the value of the "skill" field in the mutation.
  11634. func (m *EmployeeMutation) Skill() (r string, exists bool) {
  11635. v := m.skill
  11636. if v == nil {
  11637. return
  11638. }
  11639. return *v, true
  11640. }
  11641. // OldSkill returns the old "skill" field's value of the Employee entity.
  11642. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11643. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11644. func (m *EmployeeMutation) OldSkill(ctx context.Context) (v string, err error) {
  11645. if !m.op.Is(OpUpdateOne) {
  11646. return v, errors.New("OldSkill is only allowed on UpdateOne operations")
  11647. }
  11648. if m.id == nil || m.oldValue == nil {
  11649. return v, errors.New("OldSkill requires an ID field in the mutation")
  11650. }
  11651. oldValue, err := m.oldValue(ctx)
  11652. if err != nil {
  11653. return v, fmt.Errorf("querying old value for OldSkill: %w", err)
  11654. }
  11655. return oldValue.Skill, nil
  11656. }
  11657. // ResetSkill resets all changes to the "skill" field.
  11658. func (m *EmployeeMutation) ResetSkill() {
  11659. m.skill = nil
  11660. }
  11661. // SetAbilityType sets the "ability_type" field.
  11662. func (m *EmployeeMutation) SetAbilityType(s string) {
  11663. m.ability_type = &s
  11664. }
  11665. // AbilityType returns the value of the "ability_type" field in the mutation.
  11666. func (m *EmployeeMutation) AbilityType() (r string, exists bool) {
  11667. v := m.ability_type
  11668. if v == nil {
  11669. return
  11670. }
  11671. return *v, true
  11672. }
  11673. // OldAbilityType returns the old "ability_type" field's value of the Employee entity.
  11674. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11675. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11676. func (m *EmployeeMutation) OldAbilityType(ctx context.Context) (v string, err error) {
  11677. if !m.op.Is(OpUpdateOne) {
  11678. return v, errors.New("OldAbilityType is only allowed on UpdateOne operations")
  11679. }
  11680. if m.id == nil || m.oldValue == nil {
  11681. return v, errors.New("OldAbilityType requires an ID field in the mutation")
  11682. }
  11683. oldValue, err := m.oldValue(ctx)
  11684. if err != nil {
  11685. return v, fmt.Errorf("querying old value for OldAbilityType: %w", err)
  11686. }
  11687. return oldValue.AbilityType, nil
  11688. }
  11689. // ResetAbilityType resets all changes to the "ability_type" field.
  11690. func (m *EmployeeMutation) ResetAbilityType() {
  11691. m.ability_type = nil
  11692. }
  11693. // SetScene sets the "scene" field.
  11694. func (m *EmployeeMutation) SetScene(s string) {
  11695. m.scene = &s
  11696. }
  11697. // Scene returns the value of the "scene" field in the mutation.
  11698. func (m *EmployeeMutation) Scene() (r string, exists bool) {
  11699. v := m.scene
  11700. if v == nil {
  11701. return
  11702. }
  11703. return *v, true
  11704. }
  11705. // OldScene returns the old "scene" field's value of the Employee entity.
  11706. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11708. func (m *EmployeeMutation) OldScene(ctx context.Context) (v string, err error) {
  11709. if !m.op.Is(OpUpdateOne) {
  11710. return v, errors.New("OldScene is only allowed on UpdateOne operations")
  11711. }
  11712. if m.id == nil || m.oldValue == nil {
  11713. return v, errors.New("OldScene requires an ID field in the mutation")
  11714. }
  11715. oldValue, err := m.oldValue(ctx)
  11716. if err != nil {
  11717. return v, fmt.Errorf("querying old value for OldScene: %w", err)
  11718. }
  11719. return oldValue.Scene, nil
  11720. }
  11721. // ResetScene resets all changes to the "scene" field.
  11722. func (m *EmployeeMutation) ResetScene() {
  11723. m.scene = nil
  11724. }
  11725. // SetSwitchIn sets the "switch_in" field.
  11726. func (m *EmployeeMutation) SetSwitchIn(s string) {
  11727. m.switch_in = &s
  11728. }
  11729. // SwitchIn returns the value of the "switch_in" field in the mutation.
  11730. func (m *EmployeeMutation) SwitchIn() (r string, exists bool) {
  11731. v := m.switch_in
  11732. if v == nil {
  11733. return
  11734. }
  11735. return *v, true
  11736. }
  11737. // OldSwitchIn returns the old "switch_in" field's value of the Employee entity.
  11738. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11739. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11740. func (m *EmployeeMutation) OldSwitchIn(ctx context.Context) (v string, err error) {
  11741. if !m.op.Is(OpUpdateOne) {
  11742. return v, errors.New("OldSwitchIn is only allowed on UpdateOne operations")
  11743. }
  11744. if m.id == nil || m.oldValue == nil {
  11745. return v, errors.New("OldSwitchIn requires an ID field in the mutation")
  11746. }
  11747. oldValue, err := m.oldValue(ctx)
  11748. if err != nil {
  11749. return v, fmt.Errorf("querying old value for OldSwitchIn: %w", err)
  11750. }
  11751. return oldValue.SwitchIn, nil
  11752. }
  11753. // ResetSwitchIn resets all changes to the "switch_in" field.
  11754. func (m *EmployeeMutation) ResetSwitchIn() {
  11755. m.switch_in = nil
  11756. }
  11757. // SetVideoURL sets the "video_url" field.
  11758. func (m *EmployeeMutation) SetVideoURL(s string) {
  11759. m.video_url = &s
  11760. }
  11761. // VideoURL returns the value of the "video_url" field in the mutation.
  11762. func (m *EmployeeMutation) VideoURL() (r string, exists bool) {
  11763. v := m.video_url
  11764. if v == nil {
  11765. return
  11766. }
  11767. return *v, true
  11768. }
  11769. // OldVideoURL returns the old "video_url" field's value of the Employee entity.
  11770. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11771. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11772. func (m *EmployeeMutation) OldVideoURL(ctx context.Context) (v string, err error) {
  11773. if !m.op.Is(OpUpdateOne) {
  11774. return v, errors.New("OldVideoURL is only allowed on UpdateOne operations")
  11775. }
  11776. if m.id == nil || m.oldValue == nil {
  11777. return v, errors.New("OldVideoURL requires an ID field in the mutation")
  11778. }
  11779. oldValue, err := m.oldValue(ctx)
  11780. if err != nil {
  11781. return v, fmt.Errorf("querying old value for OldVideoURL: %w", err)
  11782. }
  11783. return oldValue.VideoURL, nil
  11784. }
  11785. // ResetVideoURL resets all changes to the "video_url" field.
  11786. func (m *EmployeeMutation) ResetVideoURL() {
  11787. m.video_url = nil
  11788. }
  11789. // SetOrganizationID sets the "organization_id" field.
  11790. func (m *EmployeeMutation) SetOrganizationID(u uint64) {
  11791. m.organization_id = &u
  11792. m.addorganization_id = nil
  11793. }
  11794. // OrganizationID returns the value of the "organization_id" field in the mutation.
  11795. func (m *EmployeeMutation) OrganizationID() (r uint64, exists bool) {
  11796. v := m.organization_id
  11797. if v == nil {
  11798. return
  11799. }
  11800. return *v, true
  11801. }
  11802. // OldOrganizationID returns the old "organization_id" field's value of the Employee entity.
  11803. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11805. func (m *EmployeeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  11806. if !m.op.Is(OpUpdateOne) {
  11807. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  11808. }
  11809. if m.id == nil || m.oldValue == nil {
  11810. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  11811. }
  11812. oldValue, err := m.oldValue(ctx)
  11813. if err != nil {
  11814. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  11815. }
  11816. return oldValue.OrganizationID, nil
  11817. }
  11818. // AddOrganizationID adds u to the "organization_id" field.
  11819. func (m *EmployeeMutation) AddOrganizationID(u int64) {
  11820. if m.addorganization_id != nil {
  11821. *m.addorganization_id += u
  11822. } else {
  11823. m.addorganization_id = &u
  11824. }
  11825. }
  11826. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  11827. func (m *EmployeeMutation) AddedOrganizationID() (r int64, exists bool) {
  11828. v := m.addorganization_id
  11829. if v == nil {
  11830. return
  11831. }
  11832. return *v, true
  11833. }
  11834. // ResetOrganizationID resets all changes to the "organization_id" field.
  11835. func (m *EmployeeMutation) ResetOrganizationID() {
  11836. m.organization_id = nil
  11837. m.addorganization_id = nil
  11838. }
  11839. // SetCategoryID sets the "category_id" field.
  11840. func (m *EmployeeMutation) SetCategoryID(u uint64) {
  11841. m.category_id = &u
  11842. m.addcategory_id = nil
  11843. }
  11844. // CategoryID returns the value of the "category_id" field in the mutation.
  11845. func (m *EmployeeMutation) CategoryID() (r uint64, exists bool) {
  11846. v := m.category_id
  11847. if v == nil {
  11848. return
  11849. }
  11850. return *v, true
  11851. }
  11852. // OldCategoryID returns the old "category_id" field's value of the Employee entity.
  11853. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11855. func (m *EmployeeMutation) OldCategoryID(ctx context.Context) (v uint64, err error) {
  11856. if !m.op.Is(OpUpdateOne) {
  11857. return v, errors.New("OldCategoryID is only allowed on UpdateOne operations")
  11858. }
  11859. if m.id == nil || m.oldValue == nil {
  11860. return v, errors.New("OldCategoryID requires an ID field in the mutation")
  11861. }
  11862. oldValue, err := m.oldValue(ctx)
  11863. if err != nil {
  11864. return v, fmt.Errorf("querying old value for OldCategoryID: %w", err)
  11865. }
  11866. return oldValue.CategoryID, nil
  11867. }
  11868. // AddCategoryID adds u to the "category_id" field.
  11869. func (m *EmployeeMutation) AddCategoryID(u int64) {
  11870. if m.addcategory_id != nil {
  11871. *m.addcategory_id += u
  11872. } else {
  11873. m.addcategory_id = &u
  11874. }
  11875. }
  11876. // AddedCategoryID returns the value that was added to the "category_id" field in this mutation.
  11877. func (m *EmployeeMutation) AddedCategoryID() (r int64, exists bool) {
  11878. v := m.addcategory_id
  11879. if v == nil {
  11880. return
  11881. }
  11882. return *v, true
  11883. }
  11884. // ResetCategoryID resets all changes to the "category_id" field.
  11885. func (m *EmployeeMutation) ResetCategoryID() {
  11886. m.category_id = nil
  11887. m.addcategory_id = nil
  11888. }
  11889. // SetAPIBase sets the "api_base" field.
  11890. func (m *EmployeeMutation) SetAPIBase(s string) {
  11891. m.api_base = &s
  11892. }
  11893. // APIBase returns the value of the "api_base" field in the mutation.
  11894. func (m *EmployeeMutation) APIBase() (r string, exists bool) {
  11895. v := m.api_base
  11896. if v == nil {
  11897. return
  11898. }
  11899. return *v, true
  11900. }
  11901. // OldAPIBase returns the old "api_base" field's value of the Employee entity.
  11902. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11904. func (m *EmployeeMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  11905. if !m.op.Is(OpUpdateOne) {
  11906. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  11907. }
  11908. if m.id == nil || m.oldValue == nil {
  11909. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  11910. }
  11911. oldValue, err := m.oldValue(ctx)
  11912. if err != nil {
  11913. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  11914. }
  11915. return oldValue.APIBase, nil
  11916. }
  11917. // ResetAPIBase resets all changes to the "api_base" field.
  11918. func (m *EmployeeMutation) ResetAPIBase() {
  11919. m.api_base = nil
  11920. }
  11921. // SetAPIKey sets the "api_key" field.
  11922. func (m *EmployeeMutation) SetAPIKey(s string) {
  11923. m.api_key = &s
  11924. }
  11925. // APIKey returns the value of the "api_key" field in the mutation.
  11926. func (m *EmployeeMutation) APIKey() (r string, exists bool) {
  11927. v := m.api_key
  11928. if v == nil {
  11929. return
  11930. }
  11931. return *v, true
  11932. }
  11933. // OldAPIKey returns the old "api_key" field's value of the Employee entity.
  11934. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11935. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11936. func (m *EmployeeMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  11937. if !m.op.Is(OpUpdateOne) {
  11938. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  11939. }
  11940. if m.id == nil || m.oldValue == nil {
  11941. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  11942. }
  11943. oldValue, err := m.oldValue(ctx)
  11944. if err != nil {
  11945. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  11946. }
  11947. return oldValue.APIKey, nil
  11948. }
  11949. // ResetAPIKey resets all changes to the "api_key" field.
  11950. func (m *EmployeeMutation) ResetAPIKey() {
  11951. m.api_key = nil
  11952. }
  11953. // SetAiInfo sets the "ai_info" field.
  11954. func (m *EmployeeMutation) SetAiInfo(s string) {
  11955. m.ai_info = &s
  11956. }
  11957. // AiInfo returns the value of the "ai_info" field in the mutation.
  11958. func (m *EmployeeMutation) AiInfo() (r string, exists bool) {
  11959. v := m.ai_info
  11960. if v == nil {
  11961. return
  11962. }
  11963. return *v, true
  11964. }
  11965. // OldAiInfo returns the old "ai_info" field's value of the Employee entity.
  11966. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  11967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  11968. func (m *EmployeeMutation) OldAiInfo(ctx context.Context) (v string, err error) {
  11969. if !m.op.Is(OpUpdateOne) {
  11970. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  11971. }
  11972. if m.id == nil || m.oldValue == nil {
  11973. return v, errors.New("OldAiInfo requires an ID field in the mutation")
  11974. }
  11975. oldValue, err := m.oldValue(ctx)
  11976. if err != nil {
  11977. return v, fmt.Errorf("querying old value for OldAiInfo: %w", err)
  11978. }
  11979. return oldValue.AiInfo, nil
  11980. }
  11981. // ClearAiInfo clears the value of the "ai_info" field.
  11982. func (m *EmployeeMutation) ClearAiInfo() {
  11983. m.ai_info = nil
  11984. m.clearedFields[employee.FieldAiInfo] = struct{}{}
  11985. }
  11986. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  11987. func (m *EmployeeMutation) AiInfoCleared() bool {
  11988. _, ok := m.clearedFields[employee.FieldAiInfo]
  11989. return ok
  11990. }
  11991. // ResetAiInfo resets all changes to the "ai_info" field.
  11992. func (m *EmployeeMutation) ResetAiInfo() {
  11993. m.ai_info = nil
  11994. delete(m.clearedFields, employee.FieldAiInfo)
  11995. }
  11996. // SetIsVip sets the "is_vip" field.
  11997. func (m *EmployeeMutation) SetIsVip(i int) {
  11998. m.is_vip = &i
  11999. m.addis_vip = nil
  12000. }
  12001. // IsVip returns the value of the "is_vip" field in the mutation.
  12002. func (m *EmployeeMutation) IsVip() (r int, exists bool) {
  12003. v := m.is_vip
  12004. if v == nil {
  12005. return
  12006. }
  12007. return *v, true
  12008. }
  12009. // OldIsVip returns the old "is_vip" 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) OldIsVip(ctx context.Context) (v int, err error) {
  12013. if !m.op.Is(OpUpdateOne) {
  12014. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  12015. }
  12016. if m.id == nil || m.oldValue == nil {
  12017. return v, errors.New("OldIsVip 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 OldIsVip: %w", err)
  12022. }
  12023. return oldValue.IsVip, nil
  12024. }
  12025. // AddIsVip adds i to the "is_vip" field.
  12026. func (m *EmployeeMutation) AddIsVip(i int) {
  12027. if m.addis_vip != nil {
  12028. *m.addis_vip += i
  12029. } else {
  12030. m.addis_vip = &i
  12031. }
  12032. }
  12033. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  12034. func (m *EmployeeMutation) AddedIsVip() (r int, exists bool) {
  12035. v := m.addis_vip
  12036. if v == nil {
  12037. return
  12038. }
  12039. return *v, true
  12040. }
  12041. // ResetIsVip resets all changes to the "is_vip" field.
  12042. func (m *EmployeeMutation) ResetIsVip() {
  12043. m.is_vip = nil
  12044. m.addis_vip = nil
  12045. }
  12046. // SetChatURL sets the "chat_url" field.
  12047. func (m *EmployeeMutation) SetChatURL(s string) {
  12048. m.chat_url = &s
  12049. }
  12050. // ChatURL returns the value of the "chat_url" field in the mutation.
  12051. func (m *EmployeeMutation) ChatURL() (r string, exists bool) {
  12052. v := m.chat_url
  12053. if v == nil {
  12054. return
  12055. }
  12056. return *v, true
  12057. }
  12058. // OldChatURL returns the old "chat_url" field's value of the Employee entity.
  12059. // If the Employee object wasn't provided to the builder, the object is fetched from the database.
  12060. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12061. func (m *EmployeeMutation) OldChatURL(ctx context.Context) (v string, err error) {
  12062. if !m.op.Is(OpUpdateOne) {
  12063. return v, errors.New("OldChatURL is only allowed on UpdateOne operations")
  12064. }
  12065. if m.id == nil || m.oldValue == nil {
  12066. return v, errors.New("OldChatURL requires an ID field in the mutation")
  12067. }
  12068. oldValue, err := m.oldValue(ctx)
  12069. if err != nil {
  12070. return v, fmt.Errorf("querying old value for OldChatURL: %w", err)
  12071. }
  12072. return oldValue.ChatURL, nil
  12073. }
  12074. // ResetChatURL resets all changes to the "chat_url" field.
  12075. func (m *EmployeeMutation) ResetChatURL() {
  12076. m.chat_url = nil
  12077. }
  12078. // AddEmWorkExperienceIDs adds the "em_work_experiences" edge to the WorkExperience entity by ids.
  12079. func (m *EmployeeMutation) AddEmWorkExperienceIDs(ids ...uint64) {
  12080. if m.em_work_experiences == nil {
  12081. m.em_work_experiences = make(map[uint64]struct{})
  12082. }
  12083. for i := range ids {
  12084. m.em_work_experiences[ids[i]] = struct{}{}
  12085. }
  12086. }
  12087. // ClearEmWorkExperiences clears the "em_work_experiences" edge to the WorkExperience entity.
  12088. func (m *EmployeeMutation) ClearEmWorkExperiences() {
  12089. m.clearedem_work_experiences = true
  12090. }
  12091. // EmWorkExperiencesCleared reports if the "em_work_experiences" edge to the WorkExperience entity was cleared.
  12092. func (m *EmployeeMutation) EmWorkExperiencesCleared() bool {
  12093. return m.clearedem_work_experiences
  12094. }
  12095. // RemoveEmWorkExperienceIDs removes the "em_work_experiences" edge to the WorkExperience entity by IDs.
  12096. func (m *EmployeeMutation) RemoveEmWorkExperienceIDs(ids ...uint64) {
  12097. if m.removedem_work_experiences == nil {
  12098. m.removedem_work_experiences = make(map[uint64]struct{})
  12099. }
  12100. for i := range ids {
  12101. delete(m.em_work_experiences, ids[i])
  12102. m.removedem_work_experiences[ids[i]] = struct{}{}
  12103. }
  12104. }
  12105. // RemovedEmWorkExperiences returns the removed IDs of the "em_work_experiences" edge to the WorkExperience entity.
  12106. func (m *EmployeeMutation) RemovedEmWorkExperiencesIDs() (ids []uint64) {
  12107. for id := range m.removedem_work_experiences {
  12108. ids = append(ids, id)
  12109. }
  12110. return
  12111. }
  12112. // EmWorkExperiencesIDs returns the "em_work_experiences" edge IDs in the mutation.
  12113. func (m *EmployeeMutation) EmWorkExperiencesIDs() (ids []uint64) {
  12114. for id := range m.em_work_experiences {
  12115. ids = append(ids, id)
  12116. }
  12117. return
  12118. }
  12119. // ResetEmWorkExperiences resets all changes to the "em_work_experiences" edge.
  12120. func (m *EmployeeMutation) ResetEmWorkExperiences() {
  12121. m.em_work_experiences = nil
  12122. m.clearedem_work_experiences = false
  12123. m.removedem_work_experiences = nil
  12124. }
  12125. // AddEmTutorialIDs adds the "em_tutorial" edge to the Tutorial entity by ids.
  12126. func (m *EmployeeMutation) AddEmTutorialIDs(ids ...uint64) {
  12127. if m.em_tutorial == nil {
  12128. m.em_tutorial = make(map[uint64]struct{})
  12129. }
  12130. for i := range ids {
  12131. m.em_tutorial[ids[i]] = struct{}{}
  12132. }
  12133. }
  12134. // ClearEmTutorial clears the "em_tutorial" edge to the Tutorial entity.
  12135. func (m *EmployeeMutation) ClearEmTutorial() {
  12136. m.clearedem_tutorial = true
  12137. }
  12138. // EmTutorialCleared reports if the "em_tutorial" edge to the Tutorial entity was cleared.
  12139. func (m *EmployeeMutation) EmTutorialCleared() bool {
  12140. return m.clearedem_tutorial
  12141. }
  12142. // RemoveEmTutorialIDs removes the "em_tutorial" edge to the Tutorial entity by IDs.
  12143. func (m *EmployeeMutation) RemoveEmTutorialIDs(ids ...uint64) {
  12144. if m.removedem_tutorial == nil {
  12145. m.removedem_tutorial = make(map[uint64]struct{})
  12146. }
  12147. for i := range ids {
  12148. delete(m.em_tutorial, ids[i])
  12149. m.removedem_tutorial[ids[i]] = struct{}{}
  12150. }
  12151. }
  12152. // RemovedEmTutorial returns the removed IDs of the "em_tutorial" edge to the Tutorial entity.
  12153. func (m *EmployeeMutation) RemovedEmTutorialIDs() (ids []uint64) {
  12154. for id := range m.removedem_tutorial {
  12155. ids = append(ids, id)
  12156. }
  12157. return
  12158. }
  12159. // EmTutorialIDs returns the "em_tutorial" edge IDs in the mutation.
  12160. func (m *EmployeeMutation) EmTutorialIDs() (ids []uint64) {
  12161. for id := range m.em_tutorial {
  12162. ids = append(ids, id)
  12163. }
  12164. return
  12165. }
  12166. // ResetEmTutorial resets all changes to the "em_tutorial" edge.
  12167. func (m *EmployeeMutation) ResetEmTutorial() {
  12168. m.em_tutorial = nil
  12169. m.clearedem_tutorial = false
  12170. m.removedem_tutorial = nil
  12171. }
  12172. // Where appends a list predicates to the EmployeeMutation builder.
  12173. func (m *EmployeeMutation) Where(ps ...predicate.Employee) {
  12174. m.predicates = append(m.predicates, ps...)
  12175. }
  12176. // WhereP appends storage-level predicates to the EmployeeMutation builder. Using this method,
  12177. // users can use type-assertion to append predicates that do not depend on any generated package.
  12178. func (m *EmployeeMutation) WhereP(ps ...func(*sql.Selector)) {
  12179. p := make([]predicate.Employee, len(ps))
  12180. for i := range ps {
  12181. p[i] = ps[i]
  12182. }
  12183. m.Where(p...)
  12184. }
  12185. // Op returns the operation name.
  12186. func (m *EmployeeMutation) Op() Op {
  12187. return m.op
  12188. }
  12189. // SetOp allows setting the mutation operation.
  12190. func (m *EmployeeMutation) SetOp(op Op) {
  12191. m.op = op
  12192. }
  12193. // Type returns the node type of this mutation (Employee).
  12194. func (m *EmployeeMutation) Type() string {
  12195. return m.typ
  12196. }
  12197. // Fields returns all fields that were changed during this mutation. Note that in
  12198. // order to get all numeric fields that were incremented/decremented, call
  12199. // AddedFields().
  12200. func (m *EmployeeMutation) Fields() []string {
  12201. fields := make([]string, 0, 23)
  12202. if m.created_at != nil {
  12203. fields = append(fields, employee.FieldCreatedAt)
  12204. }
  12205. if m.updated_at != nil {
  12206. fields = append(fields, employee.FieldUpdatedAt)
  12207. }
  12208. if m.deleted_at != nil {
  12209. fields = append(fields, employee.FieldDeletedAt)
  12210. }
  12211. if m.title != nil {
  12212. fields = append(fields, employee.FieldTitle)
  12213. }
  12214. if m.avatar != nil {
  12215. fields = append(fields, employee.FieldAvatar)
  12216. }
  12217. if m.tags != nil {
  12218. fields = append(fields, employee.FieldTags)
  12219. }
  12220. if m.hire_count != nil {
  12221. fields = append(fields, employee.FieldHireCount)
  12222. }
  12223. if m.service_count != nil {
  12224. fields = append(fields, employee.FieldServiceCount)
  12225. }
  12226. if m.achievement_count != nil {
  12227. fields = append(fields, employee.FieldAchievementCount)
  12228. }
  12229. if m.intro != nil {
  12230. fields = append(fields, employee.FieldIntro)
  12231. }
  12232. if m.estimate != nil {
  12233. fields = append(fields, employee.FieldEstimate)
  12234. }
  12235. if m.skill != nil {
  12236. fields = append(fields, employee.FieldSkill)
  12237. }
  12238. if m.ability_type != nil {
  12239. fields = append(fields, employee.FieldAbilityType)
  12240. }
  12241. if m.scene != nil {
  12242. fields = append(fields, employee.FieldScene)
  12243. }
  12244. if m.switch_in != nil {
  12245. fields = append(fields, employee.FieldSwitchIn)
  12246. }
  12247. if m.video_url != nil {
  12248. fields = append(fields, employee.FieldVideoURL)
  12249. }
  12250. if m.organization_id != nil {
  12251. fields = append(fields, employee.FieldOrganizationID)
  12252. }
  12253. if m.category_id != nil {
  12254. fields = append(fields, employee.FieldCategoryID)
  12255. }
  12256. if m.api_base != nil {
  12257. fields = append(fields, employee.FieldAPIBase)
  12258. }
  12259. if m.api_key != nil {
  12260. fields = append(fields, employee.FieldAPIKey)
  12261. }
  12262. if m.ai_info != nil {
  12263. fields = append(fields, employee.FieldAiInfo)
  12264. }
  12265. if m.is_vip != nil {
  12266. fields = append(fields, employee.FieldIsVip)
  12267. }
  12268. if m.chat_url != nil {
  12269. fields = append(fields, employee.FieldChatURL)
  12270. }
  12271. return fields
  12272. }
  12273. // Field returns the value of a field with the given name. The second boolean
  12274. // return value indicates that this field was not set, or was not defined in the
  12275. // schema.
  12276. func (m *EmployeeMutation) Field(name string) (ent.Value, bool) {
  12277. switch name {
  12278. case employee.FieldCreatedAt:
  12279. return m.CreatedAt()
  12280. case employee.FieldUpdatedAt:
  12281. return m.UpdatedAt()
  12282. case employee.FieldDeletedAt:
  12283. return m.DeletedAt()
  12284. case employee.FieldTitle:
  12285. return m.Title()
  12286. case employee.FieldAvatar:
  12287. return m.Avatar()
  12288. case employee.FieldTags:
  12289. return m.Tags()
  12290. case employee.FieldHireCount:
  12291. return m.HireCount()
  12292. case employee.FieldServiceCount:
  12293. return m.ServiceCount()
  12294. case employee.FieldAchievementCount:
  12295. return m.AchievementCount()
  12296. case employee.FieldIntro:
  12297. return m.Intro()
  12298. case employee.FieldEstimate:
  12299. return m.Estimate()
  12300. case employee.FieldSkill:
  12301. return m.Skill()
  12302. case employee.FieldAbilityType:
  12303. return m.AbilityType()
  12304. case employee.FieldScene:
  12305. return m.Scene()
  12306. case employee.FieldSwitchIn:
  12307. return m.SwitchIn()
  12308. case employee.FieldVideoURL:
  12309. return m.VideoURL()
  12310. case employee.FieldOrganizationID:
  12311. return m.OrganizationID()
  12312. case employee.FieldCategoryID:
  12313. return m.CategoryID()
  12314. case employee.FieldAPIBase:
  12315. return m.APIBase()
  12316. case employee.FieldAPIKey:
  12317. return m.APIKey()
  12318. case employee.FieldAiInfo:
  12319. return m.AiInfo()
  12320. case employee.FieldIsVip:
  12321. return m.IsVip()
  12322. case employee.FieldChatURL:
  12323. return m.ChatURL()
  12324. }
  12325. return nil, false
  12326. }
  12327. // OldField returns the old value of the field from the database. An error is
  12328. // returned if the mutation operation is not UpdateOne, or the query to the
  12329. // database failed.
  12330. func (m *EmployeeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  12331. switch name {
  12332. case employee.FieldCreatedAt:
  12333. return m.OldCreatedAt(ctx)
  12334. case employee.FieldUpdatedAt:
  12335. return m.OldUpdatedAt(ctx)
  12336. case employee.FieldDeletedAt:
  12337. return m.OldDeletedAt(ctx)
  12338. case employee.FieldTitle:
  12339. return m.OldTitle(ctx)
  12340. case employee.FieldAvatar:
  12341. return m.OldAvatar(ctx)
  12342. case employee.FieldTags:
  12343. return m.OldTags(ctx)
  12344. case employee.FieldHireCount:
  12345. return m.OldHireCount(ctx)
  12346. case employee.FieldServiceCount:
  12347. return m.OldServiceCount(ctx)
  12348. case employee.FieldAchievementCount:
  12349. return m.OldAchievementCount(ctx)
  12350. case employee.FieldIntro:
  12351. return m.OldIntro(ctx)
  12352. case employee.FieldEstimate:
  12353. return m.OldEstimate(ctx)
  12354. case employee.FieldSkill:
  12355. return m.OldSkill(ctx)
  12356. case employee.FieldAbilityType:
  12357. return m.OldAbilityType(ctx)
  12358. case employee.FieldScene:
  12359. return m.OldScene(ctx)
  12360. case employee.FieldSwitchIn:
  12361. return m.OldSwitchIn(ctx)
  12362. case employee.FieldVideoURL:
  12363. return m.OldVideoURL(ctx)
  12364. case employee.FieldOrganizationID:
  12365. return m.OldOrganizationID(ctx)
  12366. case employee.FieldCategoryID:
  12367. return m.OldCategoryID(ctx)
  12368. case employee.FieldAPIBase:
  12369. return m.OldAPIBase(ctx)
  12370. case employee.FieldAPIKey:
  12371. return m.OldAPIKey(ctx)
  12372. case employee.FieldAiInfo:
  12373. return m.OldAiInfo(ctx)
  12374. case employee.FieldIsVip:
  12375. return m.OldIsVip(ctx)
  12376. case employee.FieldChatURL:
  12377. return m.OldChatURL(ctx)
  12378. }
  12379. return nil, fmt.Errorf("unknown Employee field %s", name)
  12380. }
  12381. // SetField sets the value of a field with the given name. It returns an error if
  12382. // the field is not defined in the schema, or if the type mismatched the field
  12383. // type.
  12384. func (m *EmployeeMutation) SetField(name string, value ent.Value) error {
  12385. switch name {
  12386. case employee.FieldCreatedAt:
  12387. v, ok := value.(time.Time)
  12388. if !ok {
  12389. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12390. }
  12391. m.SetCreatedAt(v)
  12392. return nil
  12393. case employee.FieldUpdatedAt:
  12394. v, ok := value.(time.Time)
  12395. if !ok {
  12396. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12397. }
  12398. m.SetUpdatedAt(v)
  12399. return nil
  12400. case employee.FieldDeletedAt:
  12401. v, ok := value.(time.Time)
  12402. if !ok {
  12403. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12404. }
  12405. m.SetDeletedAt(v)
  12406. return nil
  12407. case employee.FieldTitle:
  12408. v, ok := value.(string)
  12409. if !ok {
  12410. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12411. }
  12412. m.SetTitle(v)
  12413. return nil
  12414. case employee.FieldAvatar:
  12415. v, ok := value.(string)
  12416. if !ok {
  12417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12418. }
  12419. m.SetAvatar(v)
  12420. return nil
  12421. case employee.FieldTags:
  12422. v, ok := value.(string)
  12423. if !ok {
  12424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12425. }
  12426. m.SetTags(v)
  12427. return nil
  12428. case employee.FieldHireCount:
  12429. v, ok := value.(int)
  12430. if !ok {
  12431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12432. }
  12433. m.SetHireCount(v)
  12434. return nil
  12435. case employee.FieldServiceCount:
  12436. v, ok := value.(int)
  12437. if !ok {
  12438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12439. }
  12440. m.SetServiceCount(v)
  12441. return nil
  12442. case employee.FieldAchievementCount:
  12443. v, ok := value.(int)
  12444. if !ok {
  12445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12446. }
  12447. m.SetAchievementCount(v)
  12448. return nil
  12449. case employee.FieldIntro:
  12450. v, ok := value.(string)
  12451. if !ok {
  12452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12453. }
  12454. m.SetIntro(v)
  12455. return nil
  12456. case employee.FieldEstimate:
  12457. v, ok := value.(string)
  12458. if !ok {
  12459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12460. }
  12461. m.SetEstimate(v)
  12462. return nil
  12463. case employee.FieldSkill:
  12464. v, ok := value.(string)
  12465. if !ok {
  12466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12467. }
  12468. m.SetSkill(v)
  12469. return nil
  12470. case employee.FieldAbilityType:
  12471. v, ok := value.(string)
  12472. if !ok {
  12473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12474. }
  12475. m.SetAbilityType(v)
  12476. return nil
  12477. case employee.FieldScene:
  12478. v, ok := value.(string)
  12479. if !ok {
  12480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12481. }
  12482. m.SetScene(v)
  12483. return nil
  12484. case employee.FieldSwitchIn:
  12485. v, ok := value.(string)
  12486. if !ok {
  12487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12488. }
  12489. m.SetSwitchIn(v)
  12490. return nil
  12491. case employee.FieldVideoURL:
  12492. v, ok := value.(string)
  12493. if !ok {
  12494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12495. }
  12496. m.SetVideoURL(v)
  12497. return nil
  12498. case employee.FieldOrganizationID:
  12499. v, ok := value.(uint64)
  12500. if !ok {
  12501. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12502. }
  12503. m.SetOrganizationID(v)
  12504. return nil
  12505. case employee.FieldCategoryID:
  12506. v, ok := value.(uint64)
  12507. if !ok {
  12508. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12509. }
  12510. m.SetCategoryID(v)
  12511. return nil
  12512. case employee.FieldAPIBase:
  12513. v, ok := value.(string)
  12514. if !ok {
  12515. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12516. }
  12517. m.SetAPIBase(v)
  12518. return nil
  12519. case employee.FieldAPIKey:
  12520. v, ok := value.(string)
  12521. if !ok {
  12522. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12523. }
  12524. m.SetAPIKey(v)
  12525. return nil
  12526. case employee.FieldAiInfo:
  12527. v, ok := value.(string)
  12528. if !ok {
  12529. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12530. }
  12531. m.SetAiInfo(v)
  12532. return nil
  12533. case employee.FieldIsVip:
  12534. v, ok := value.(int)
  12535. if !ok {
  12536. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12537. }
  12538. m.SetIsVip(v)
  12539. return nil
  12540. case employee.FieldChatURL:
  12541. v, ok := value.(string)
  12542. if !ok {
  12543. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12544. }
  12545. m.SetChatURL(v)
  12546. return nil
  12547. }
  12548. return fmt.Errorf("unknown Employee field %s", name)
  12549. }
  12550. // AddedFields returns all numeric fields that were incremented/decremented during
  12551. // this mutation.
  12552. func (m *EmployeeMutation) AddedFields() []string {
  12553. var fields []string
  12554. if m.addhire_count != nil {
  12555. fields = append(fields, employee.FieldHireCount)
  12556. }
  12557. if m.addservice_count != nil {
  12558. fields = append(fields, employee.FieldServiceCount)
  12559. }
  12560. if m.addachievement_count != nil {
  12561. fields = append(fields, employee.FieldAchievementCount)
  12562. }
  12563. if m.addorganization_id != nil {
  12564. fields = append(fields, employee.FieldOrganizationID)
  12565. }
  12566. if m.addcategory_id != nil {
  12567. fields = append(fields, employee.FieldCategoryID)
  12568. }
  12569. if m.addis_vip != nil {
  12570. fields = append(fields, employee.FieldIsVip)
  12571. }
  12572. return fields
  12573. }
  12574. // AddedField returns the numeric value that was incremented/decremented on a field
  12575. // with the given name. The second boolean return value indicates that this field
  12576. // was not set, or was not defined in the schema.
  12577. func (m *EmployeeMutation) AddedField(name string) (ent.Value, bool) {
  12578. switch name {
  12579. case employee.FieldHireCount:
  12580. return m.AddedHireCount()
  12581. case employee.FieldServiceCount:
  12582. return m.AddedServiceCount()
  12583. case employee.FieldAchievementCount:
  12584. return m.AddedAchievementCount()
  12585. case employee.FieldOrganizationID:
  12586. return m.AddedOrganizationID()
  12587. case employee.FieldCategoryID:
  12588. return m.AddedCategoryID()
  12589. case employee.FieldIsVip:
  12590. return m.AddedIsVip()
  12591. }
  12592. return nil, false
  12593. }
  12594. // AddField adds the value to the field with the given name. It returns an error if
  12595. // the field is not defined in the schema, or if the type mismatched the field
  12596. // type.
  12597. func (m *EmployeeMutation) AddField(name string, value ent.Value) error {
  12598. switch name {
  12599. case employee.FieldHireCount:
  12600. v, ok := value.(int)
  12601. if !ok {
  12602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12603. }
  12604. m.AddHireCount(v)
  12605. return nil
  12606. case employee.FieldServiceCount:
  12607. v, ok := value.(int)
  12608. if !ok {
  12609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12610. }
  12611. m.AddServiceCount(v)
  12612. return nil
  12613. case employee.FieldAchievementCount:
  12614. v, ok := value.(int)
  12615. if !ok {
  12616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12617. }
  12618. m.AddAchievementCount(v)
  12619. return nil
  12620. case employee.FieldOrganizationID:
  12621. v, ok := value.(int64)
  12622. if !ok {
  12623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12624. }
  12625. m.AddOrganizationID(v)
  12626. return nil
  12627. case employee.FieldCategoryID:
  12628. v, ok := value.(int64)
  12629. if !ok {
  12630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12631. }
  12632. m.AddCategoryID(v)
  12633. return nil
  12634. case employee.FieldIsVip:
  12635. v, ok := value.(int)
  12636. if !ok {
  12637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  12638. }
  12639. m.AddIsVip(v)
  12640. return nil
  12641. }
  12642. return fmt.Errorf("unknown Employee numeric field %s", name)
  12643. }
  12644. // ClearedFields returns all nullable fields that were cleared during this
  12645. // mutation.
  12646. func (m *EmployeeMutation) ClearedFields() []string {
  12647. var fields []string
  12648. if m.FieldCleared(employee.FieldDeletedAt) {
  12649. fields = append(fields, employee.FieldDeletedAt)
  12650. }
  12651. if m.FieldCleared(employee.FieldAiInfo) {
  12652. fields = append(fields, employee.FieldAiInfo)
  12653. }
  12654. return fields
  12655. }
  12656. // FieldCleared returns a boolean indicating if a field with the given name was
  12657. // cleared in this mutation.
  12658. func (m *EmployeeMutation) FieldCleared(name string) bool {
  12659. _, ok := m.clearedFields[name]
  12660. return ok
  12661. }
  12662. // ClearField clears the value of the field with the given name. It returns an
  12663. // error if the field is not defined in the schema.
  12664. func (m *EmployeeMutation) ClearField(name string) error {
  12665. switch name {
  12666. case employee.FieldDeletedAt:
  12667. m.ClearDeletedAt()
  12668. return nil
  12669. case employee.FieldAiInfo:
  12670. m.ClearAiInfo()
  12671. return nil
  12672. }
  12673. return fmt.Errorf("unknown Employee nullable field %s", name)
  12674. }
  12675. // ResetField resets all changes in the mutation for the field with the given name.
  12676. // It returns an error if the field is not defined in the schema.
  12677. func (m *EmployeeMutation) ResetField(name string) error {
  12678. switch name {
  12679. case employee.FieldCreatedAt:
  12680. m.ResetCreatedAt()
  12681. return nil
  12682. case employee.FieldUpdatedAt:
  12683. m.ResetUpdatedAt()
  12684. return nil
  12685. case employee.FieldDeletedAt:
  12686. m.ResetDeletedAt()
  12687. return nil
  12688. case employee.FieldTitle:
  12689. m.ResetTitle()
  12690. return nil
  12691. case employee.FieldAvatar:
  12692. m.ResetAvatar()
  12693. return nil
  12694. case employee.FieldTags:
  12695. m.ResetTags()
  12696. return nil
  12697. case employee.FieldHireCount:
  12698. m.ResetHireCount()
  12699. return nil
  12700. case employee.FieldServiceCount:
  12701. m.ResetServiceCount()
  12702. return nil
  12703. case employee.FieldAchievementCount:
  12704. m.ResetAchievementCount()
  12705. return nil
  12706. case employee.FieldIntro:
  12707. m.ResetIntro()
  12708. return nil
  12709. case employee.FieldEstimate:
  12710. m.ResetEstimate()
  12711. return nil
  12712. case employee.FieldSkill:
  12713. m.ResetSkill()
  12714. return nil
  12715. case employee.FieldAbilityType:
  12716. m.ResetAbilityType()
  12717. return nil
  12718. case employee.FieldScene:
  12719. m.ResetScene()
  12720. return nil
  12721. case employee.FieldSwitchIn:
  12722. m.ResetSwitchIn()
  12723. return nil
  12724. case employee.FieldVideoURL:
  12725. m.ResetVideoURL()
  12726. return nil
  12727. case employee.FieldOrganizationID:
  12728. m.ResetOrganizationID()
  12729. return nil
  12730. case employee.FieldCategoryID:
  12731. m.ResetCategoryID()
  12732. return nil
  12733. case employee.FieldAPIBase:
  12734. m.ResetAPIBase()
  12735. return nil
  12736. case employee.FieldAPIKey:
  12737. m.ResetAPIKey()
  12738. return nil
  12739. case employee.FieldAiInfo:
  12740. m.ResetAiInfo()
  12741. return nil
  12742. case employee.FieldIsVip:
  12743. m.ResetIsVip()
  12744. return nil
  12745. case employee.FieldChatURL:
  12746. m.ResetChatURL()
  12747. return nil
  12748. }
  12749. return fmt.Errorf("unknown Employee field %s", name)
  12750. }
  12751. // AddedEdges returns all edge names that were set/added in this mutation.
  12752. func (m *EmployeeMutation) AddedEdges() []string {
  12753. edges := make([]string, 0, 2)
  12754. if m.em_work_experiences != nil {
  12755. edges = append(edges, employee.EdgeEmWorkExperiences)
  12756. }
  12757. if m.em_tutorial != nil {
  12758. edges = append(edges, employee.EdgeEmTutorial)
  12759. }
  12760. return edges
  12761. }
  12762. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  12763. // name in this mutation.
  12764. func (m *EmployeeMutation) AddedIDs(name string) []ent.Value {
  12765. switch name {
  12766. case employee.EdgeEmWorkExperiences:
  12767. ids := make([]ent.Value, 0, len(m.em_work_experiences))
  12768. for id := range m.em_work_experiences {
  12769. ids = append(ids, id)
  12770. }
  12771. return ids
  12772. case employee.EdgeEmTutorial:
  12773. ids := make([]ent.Value, 0, len(m.em_tutorial))
  12774. for id := range m.em_tutorial {
  12775. ids = append(ids, id)
  12776. }
  12777. return ids
  12778. }
  12779. return nil
  12780. }
  12781. // RemovedEdges returns all edge names that were removed in this mutation.
  12782. func (m *EmployeeMutation) RemovedEdges() []string {
  12783. edges := make([]string, 0, 2)
  12784. if m.removedem_work_experiences != nil {
  12785. edges = append(edges, employee.EdgeEmWorkExperiences)
  12786. }
  12787. if m.removedem_tutorial != nil {
  12788. edges = append(edges, employee.EdgeEmTutorial)
  12789. }
  12790. return edges
  12791. }
  12792. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  12793. // the given name in this mutation.
  12794. func (m *EmployeeMutation) RemovedIDs(name string) []ent.Value {
  12795. switch name {
  12796. case employee.EdgeEmWorkExperiences:
  12797. ids := make([]ent.Value, 0, len(m.removedem_work_experiences))
  12798. for id := range m.removedem_work_experiences {
  12799. ids = append(ids, id)
  12800. }
  12801. return ids
  12802. case employee.EdgeEmTutorial:
  12803. ids := make([]ent.Value, 0, len(m.removedem_tutorial))
  12804. for id := range m.removedem_tutorial {
  12805. ids = append(ids, id)
  12806. }
  12807. return ids
  12808. }
  12809. return nil
  12810. }
  12811. // ClearedEdges returns all edge names that were cleared in this mutation.
  12812. func (m *EmployeeMutation) ClearedEdges() []string {
  12813. edges := make([]string, 0, 2)
  12814. if m.clearedem_work_experiences {
  12815. edges = append(edges, employee.EdgeEmWorkExperiences)
  12816. }
  12817. if m.clearedem_tutorial {
  12818. edges = append(edges, employee.EdgeEmTutorial)
  12819. }
  12820. return edges
  12821. }
  12822. // EdgeCleared returns a boolean which indicates if the edge with the given name
  12823. // was cleared in this mutation.
  12824. func (m *EmployeeMutation) EdgeCleared(name string) bool {
  12825. switch name {
  12826. case employee.EdgeEmWorkExperiences:
  12827. return m.clearedem_work_experiences
  12828. case employee.EdgeEmTutorial:
  12829. return m.clearedem_tutorial
  12830. }
  12831. return false
  12832. }
  12833. // ClearEdge clears the value of the edge with the given name. It returns an error
  12834. // if that edge is not defined in the schema.
  12835. func (m *EmployeeMutation) ClearEdge(name string) error {
  12836. switch name {
  12837. }
  12838. return fmt.Errorf("unknown Employee unique edge %s", name)
  12839. }
  12840. // ResetEdge resets all changes to the edge with the given name in this mutation.
  12841. // It returns an error if the edge is not defined in the schema.
  12842. func (m *EmployeeMutation) ResetEdge(name string) error {
  12843. switch name {
  12844. case employee.EdgeEmWorkExperiences:
  12845. m.ResetEmWorkExperiences()
  12846. return nil
  12847. case employee.EdgeEmTutorial:
  12848. m.ResetEmTutorial()
  12849. return nil
  12850. }
  12851. return fmt.Errorf("unknown Employee edge %s", name)
  12852. }
  12853. // EmployeeConfigMutation represents an operation that mutates the EmployeeConfig nodes in the graph.
  12854. type EmployeeConfigMutation struct {
  12855. config
  12856. op Op
  12857. typ string
  12858. id *uint64
  12859. created_at *time.Time
  12860. updated_at *time.Time
  12861. deleted_at *time.Time
  12862. stype *string
  12863. title *string
  12864. photo *string
  12865. organization_id *uint64
  12866. addorganization_id *int64
  12867. clearedFields map[string]struct{}
  12868. done bool
  12869. oldValue func(context.Context) (*EmployeeConfig, error)
  12870. predicates []predicate.EmployeeConfig
  12871. }
  12872. var _ ent.Mutation = (*EmployeeConfigMutation)(nil)
  12873. // employeeconfigOption allows management of the mutation configuration using functional options.
  12874. type employeeconfigOption func(*EmployeeConfigMutation)
  12875. // newEmployeeConfigMutation creates new mutation for the EmployeeConfig entity.
  12876. func newEmployeeConfigMutation(c config, op Op, opts ...employeeconfigOption) *EmployeeConfigMutation {
  12877. m := &EmployeeConfigMutation{
  12878. config: c,
  12879. op: op,
  12880. typ: TypeEmployeeConfig,
  12881. clearedFields: make(map[string]struct{}),
  12882. }
  12883. for _, opt := range opts {
  12884. opt(m)
  12885. }
  12886. return m
  12887. }
  12888. // withEmployeeConfigID sets the ID field of the mutation.
  12889. func withEmployeeConfigID(id uint64) employeeconfigOption {
  12890. return func(m *EmployeeConfigMutation) {
  12891. var (
  12892. err error
  12893. once sync.Once
  12894. value *EmployeeConfig
  12895. )
  12896. m.oldValue = func(ctx context.Context) (*EmployeeConfig, error) {
  12897. once.Do(func() {
  12898. if m.done {
  12899. err = errors.New("querying old values post mutation is not allowed")
  12900. } else {
  12901. value, err = m.Client().EmployeeConfig.Get(ctx, id)
  12902. }
  12903. })
  12904. return value, err
  12905. }
  12906. m.id = &id
  12907. }
  12908. }
  12909. // withEmployeeConfig sets the old EmployeeConfig of the mutation.
  12910. func withEmployeeConfig(node *EmployeeConfig) employeeconfigOption {
  12911. return func(m *EmployeeConfigMutation) {
  12912. m.oldValue = func(context.Context) (*EmployeeConfig, error) {
  12913. return node, nil
  12914. }
  12915. m.id = &node.ID
  12916. }
  12917. }
  12918. // Client returns a new `ent.Client` from the mutation. If the mutation was
  12919. // executed in a transaction (ent.Tx), a transactional client is returned.
  12920. func (m EmployeeConfigMutation) Client() *Client {
  12921. client := &Client{config: m.config}
  12922. client.init()
  12923. return client
  12924. }
  12925. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  12926. // it returns an error otherwise.
  12927. func (m EmployeeConfigMutation) Tx() (*Tx, error) {
  12928. if _, ok := m.driver.(*txDriver); !ok {
  12929. return nil, errors.New("ent: mutation is not running in a transaction")
  12930. }
  12931. tx := &Tx{config: m.config}
  12932. tx.init()
  12933. return tx, nil
  12934. }
  12935. // SetID sets the value of the id field. Note that this
  12936. // operation is only accepted on creation of EmployeeConfig entities.
  12937. func (m *EmployeeConfigMutation) SetID(id uint64) {
  12938. m.id = &id
  12939. }
  12940. // ID returns the ID value in the mutation. Note that the ID is only available
  12941. // if it was provided to the builder or after it was returned from the database.
  12942. func (m *EmployeeConfigMutation) ID() (id uint64, exists bool) {
  12943. if m.id == nil {
  12944. return
  12945. }
  12946. return *m.id, true
  12947. }
  12948. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  12949. // That means, if the mutation is applied within a transaction with an isolation level such
  12950. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  12951. // or updated by the mutation.
  12952. func (m *EmployeeConfigMutation) IDs(ctx context.Context) ([]uint64, error) {
  12953. switch {
  12954. case m.op.Is(OpUpdateOne | OpDeleteOne):
  12955. id, exists := m.ID()
  12956. if exists {
  12957. return []uint64{id}, nil
  12958. }
  12959. fallthrough
  12960. case m.op.Is(OpUpdate | OpDelete):
  12961. return m.Client().EmployeeConfig.Query().Where(m.predicates...).IDs(ctx)
  12962. default:
  12963. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  12964. }
  12965. }
  12966. // SetCreatedAt sets the "created_at" field.
  12967. func (m *EmployeeConfigMutation) SetCreatedAt(t time.Time) {
  12968. m.created_at = &t
  12969. }
  12970. // CreatedAt returns the value of the "created_at" field in the mutation.
  12971. func (m *EmployeeConfigMutation) CreatedAt() (r time.Time, exists bool) {
  12972. v := m.created_at
  12973. if v == nil {
  12974. return
  12975. }
  12976. return *v, true
  12977. }
  12978. // OldCreatedAt returns the old "created_at" field's value of the EmployeeConfig entity.
  12979. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  12980. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  12981. func (m *EmployeeConfigMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  12982. if !m.op.Is(OpUpdateOne) {
  12983. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  12984. }
  12985. if m.id == nil || m.oldValue == nil {
  12986. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  12987. }
  12988. oldValue, err := m.oldValue(ctx)
  12989. if err != nil {
  12990. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  12991. }
  12992. return oldValue.CreatedAt, nil
  12993. }
  12994. // ResetCreatedAt resets all changes to the "created_at" field.
  12995. func (m *EmployeeConfigMutation) ResetCreatedAt() {
  12996. m.created_at = nil
  12997. }
  12998. // SetUpdatedAt sets the "updated_at" field.
  12999. func (m *EmployeeConfigMutation) SetUpdatedAt(t time.Time) {
  13000. m.updated_at = &t
  13001. }
  13002. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13003. func (m *EmployeeConfigMutation) UpdatedAt() (r time.Time, exists bool) {
  13004. v := m.updated_at
  13005. if v == nil {
  13006. return
  13007. }
  13008. return *v, true
  13009. }
  13010. // OldUpdatedAt returns the old "updated_at" field's value of the EmployeeConfig entity.
  13011. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13012. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13013. func (m *EmployeeConfigMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13014. if !m.op.Is(OpUpdateOne) {
  13015. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13016. }
  13017. if m.id == nil || m.oldValue == nil {
  13018. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13019. }
  13020. oldValue, err := m.oldValue(ctx)
  13021. if err != nil {
  13022. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13023. }
  13024. return oldValue.UpdatedAt, nil
  13025. }
  13026. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13027. func (m *EmployeeConfigMutation) ResetUpdatedAt() {
  13028. m.updated_at = nil
  13029. }
  13030. // SetDeletedAt sets the "deleted_at" field.
  13031. func (m *EmployeeConfigMutation) SetDeletedAt(t time.Time) {
  13032. m.deleted_at = &t
  13033. }
  13034. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  13035. func (m *EmployeeConfigMutation) DeletedAt() (r time.Time, exists bool) {
  13036. v := m.deleted_at
  13037. if v == nil {
  13038. return
  13039. }
  13040. return *v, true
  13041. }
  13042. // OldDeletedAt returns the old "deleted_at" field's value of the EmployeeConfig entity.
  13043. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13044. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13045. func (m *EmployeeConfigMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  13046. if !m.op.Is(OpUpdateOne) {
  13047. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  13048. }
  13049. if m.id == nil || m.oldValue == nil {
  13050. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  13051. }
  13052. oldValue, err := m.oldValue(ctx)
  13053. if err != nil {
  13054. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  13055. }
  13056. return oldValue.DeletedAt, nil
  13057. }
  13058. // ClearDeletedAt clears the value of the "deleted_at" field.
  13059. func (m *EmployeeConfigMutation) ClearDeletedAt() {
  13060. m.deleted_at = nil
  13061. m.clearedFields[employeeconfig.FieldDeletedAt] = struct{}{}
  13062. }
  13063. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  13064. func (m *EmployeeConfigMutation) DeletedAtCleared() bool {
  13065. _, ok := m.clearedFields[employeeconfig.FieldDeletedAt]
  13066. return ok
  13067. }
  13068. // ResetDeletedAt resets all changes to the "deleted_at" field.
  13069. func (m *EmployeeConfigMutation) ResetDeletedAt() {
  13070. m.deleted_at = nil
  13071. delete(m.clearedFields, employeeconfig.FieldDeletedAt)
  13072. }
  13073. // SetStype sets the "stype" field.
  13074. func (m *EmployeeConfigMutation) SetStype(s string) {
  13075. m.stype = &s
  13076. }
  13077. // Stype returns the value of the "stype" field in the mutation.
  13078. func (m *EmployeeConfigMutation) Stype() (r string, exists bool) {
  13079. v := m.stype
  13080. if v == nil {
  13081. return
  13082. }
  13083. return *v, true
  13084. }
  13085. // OldStype returns the old "stype" field's value of the EmployeeConfig entity.
  13086. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13087. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13088. func (m *EmployeeConfigMutation) OldStype(ctx context.Context) (v string, err error) {
  13089. if !m.op.Is(OpUpdateOne) {
  13090. return v, errors.New("OldStype is only allowed on UpdateOne operations")
  13091. }
  13092. if m.id == nil || m.oldValue == nil {
  13093. return v, errors.New("OldStype requires an ID field in the mutation")
  13094. }
  13095. oldValue, err := m.oldValue(ctx)
  13096. if err != nil {
  13097. return v, fmt.Errorf("querying old value for OldStype: %w", err)
  13098. }
  13099. return oldValue.Stype, nil
  13100. }
  13101. // ResetStype resets all changes to the "stype" field.
  13102. func (m *EmployeeConfigMutation) ResetStype() {
  13103. m.stype = nil
  13104. }
  13105. // SetTitle sets the "title" field.
  13106. func (m *EmployeeConfigMutation) SetTitle(s string) {
  13107. m.title = &s
  13108. }
  13109. // Title returns the value of the "title" field in the mutation.
  13110. func (m *EmployeeConfigMutation) Title() (r string, exists bool) {
  13111. v := m.title
  13112. if v == nil {
  13113. return
  13114. }
  13115. return *v, true
  13116. }
  13117. // OldTitle returns the old "title" field's value of the EmployeeConfig entity.
  13118. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13120. func (m *EmployeeConfigMutation) OldTitle(ctx context.Context) (v string, err error) {
  13121. if !m.op.Is(OpUpdateOne) {
  13122. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  13123. }
  13124. if m.id == nil || m.oldValue == nil {
  13125. return v, errors.New("OldTitle requires an ID field in the mutation")
  13126. }
  13127. oldValue, err := m.oldValue(ctx)
  13128. if err != nil {
  13129. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  13130. }
  13131. return oldValue.Title, nil
  13132. }
  13133. // ResetTitle resets all changes to the "title" field.
  13134. func (m *EmployeeConfigMutation) ResetTitle() {
  13135. m.title = nil
  13136. }
  13137. // SetPhoto sets the "photo" field.
  13138. func (m *EmployeeConfigMutation) SetPhoto(s string) {
  13139. m.photo = &s
  13140. }
  13141. // Photo returns the value of the "photo" field in the mutation.
  13142. func (m *EmployeeConfigMutation) Photo() (r string, exists bool) {
  13143. v := m.photo
  13144. if v == nil {
  13145. return
  13146. }
  13147. return *v, true
  13148. }
  13149. // OldPhoto returns the old "photo" field's value of the EmployeeConfig entity.
  13150. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13151. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13152. func (m *EmployeeConfigMutation) OldPhoto(ctx context.Context) (v string, err error) {
  13153. if !m.op.Is(OpUpdateOne) {
  13154. return v, errors.New("OldPhoto is only allowed on UpdateOne operations")
  13155. }
  13156. if m.id == nil || m.oldValue == nil {
  13157. return v, errors.New("OldPhoto requires an ID field in the mutation")
  13158. }
  13159. oldValue, err := m.oldValue(ctx)
  13160. if err != nil {
  13161. return v, fmt.Errorf("querying old value for OldPhoto: %w", err)
  13162. }
  13163. return oldValue.Photo, nil
  13164. }
  13165. // ResetPhoto resets all changes to the "photo" field.
  13166. func (m *EmployeeConfigMutation) ResetPhoto() {
  13167. m.photo = nil
  13168. }
  13169. // SetOrganizationID sets the "organization_id" field.
  13170. func (m *EmployeeConfigMutation) SetOrganizationID(u uint64) {
  13171. m.organization_id = &u
  13172. m.addorganization_id = nil
  13173. }
  13174. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13175. func (m *EmployeeConfigMutation) OrganizationID() (r uint64, exists bool) {
  13176. v := m.organization_id
  13177. if v == nil {
  13178. return
  13179. }
  13180. return *v, true
  13181. }
  13182. // OldOrganizationID returns the old "organization_id" field's value of the EmployeeConfig entity.
  13183. // If the EmployeeConfig object wasn't provided to the builder, the object is fetched from the database.
  13184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13185. func (m *EmployeeConfigMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  13186. if !m.op.Is(OpUpdateOne) {
  13187. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  13188. }
  13189. if m.id == nil || m.oldValue == nil {
  13190. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  13191. }
  13192. oldValue, err := m.oldValue(ctx)
  13193. if err != nil {
  13194. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  13195. }
  13196. return oldValue.OrganizationID, nil
  13197. }
  13198. // AddOrganizationID adds u to the "organization_id" field.
  13199. func (m *EmployeeConfigMutation) AddOrganizationID(u int64) {
  13200. if m.addorganization_id != nil {
  13201. *m.addorganization_id += u
  13202. } else {
  13203. m.addorganization_id = &u
  13204. }
  13205. }
  13206. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  13207. func (m *EmployeeConfigMutation) AddedOrganizationID() (r int64, exists bool) {
  13208. v := m.addorganization_id
  13209. if v == nil {
  13210. return
  13211. }
  13212. return *v, true
  13213. }
  13214. // ClearOrganizationID clears the value of the "organization_id" field.
  13215. func (m *EmployeeConfigMutation) ClearOrganizationID() {
  13216. m.organization_id = nil
  13217. m.addorganization_id = nil
  13218. m.clearedFields[employeeconfig.FieldOrganizationID] = struct{}{}
  13219. }
  13220. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  13221. func (m *EmployeeConfigMutation) OrganizationIDCleared() bool {
  13222. _, ok := m.clearedFields[employeeconfig.FieldOrganizationID]
  13223. return ok
  13224. }
  13225. // ResetOrganizationID resets all changes to the "organization_id" field.
  13226. func (m *EmployeeConfigMutation) ResetOrganizationID() {
  13227. m.organization_id = nil
  13228. m.addorganization_id = nil
  13229. delete(m.clearedFields, employeeconfig.FieldOrganizationID)
  13230. }
  13231. // Where appends a list predicates to the EmployeeConfigMutation builder.
  13232. func (m *EmployeeConfigMutation) Where(ps ...predicate.EmployeeConfig) {
  13233. m.predicates = append(m.predicates, ps...)
  13234. }
  13235. // WhereP appends storage-level predicates to the EmployeeConfigMutation builder. Using this method,
  13236. // users can use type-assertion to append predicates that do not depend on any generated package.
  13237. func (m *EmployeeConfigMutation) WhereP(ps ...func(*sql.Selector)) {
  13238. p := make([]predicate.EmployeeConfig, len(ps))
  13239. for i := range ps {
  13240. p[i] = ps[i]
  13241. }
  13242. m.Where(p...)
  13243. }
  13244. // Op returns the operation name.
  13245. func (m *EmployeeConfigMutation) Op() Op {
  13246. return m.op
  13247. }
  13248. // SetOp allows setting the mutation operation.
  13249. func (m *EmployeeConfigMutation) SetOp(op Op) {
  13250. m.op = op
  13251. }
  13252. // Type returns the node type of this mutation (EmployeeConfig).
  13253. func (m *EmployeeConfigMutation) Type() string {
  13254. return m.typ
  13255. }
  13256. // Fields returns all fields that were changed during this mutation. Note that in
  13257. // order to get all numeric fields that were incremented/decremented, call
  13258. // AddedFields().
  13259. func (m *EmployeeConfigMutation) Fields() []string {
  13260. fields := make([]string, 0, 7)
  13261. if m.created_at != nil {
  13262. fields = append(fields, employeeconfig.FieldCreatedAt)
  13263. }
  13264. if m.updated_at != nil {
  13265. fields = append(fields, employeeconfig.FieldUpdatedAt)
  13266. }
  13267. if m.deleted_at != nil {
  13268. fields = append(fields, employeeconfig.FieldDeletedAt)
  13269. }
  13270. if m.stype != nil {
  13271. fields = append(fields, employeeconfig.FieldStype)
  13272. }
  13273. if m.title != nil {
  13274. fields = append(fields, employeeconfig.FieldTitle)
  13275. }
  13276. if m.photo != nil {
  13277. fields = append(fields, employeeconfig.FieldPhoto)
  13278. }
  13279. if m.organization_id != nil {
  13280. fields = append(fields, employeeconfig.FieldOrganizationID)
  13281. }
  13282. return fields
  13283. }
  13284. // Field returns the value of a field with the given name. The second boolean
  13285. // return value indicates that this field was not set, or was not defined in the
  13286. // schema.
  13287. func (m *EmployeeConfigMutation) Field(name string) (ent.Value, bool) {
  13288. switch name {
  13289. case employeeconfig.FieldCreatedAt:
  13290. return m.CreatedAt()
  13291. case employeeconfig.FieldUpdatedAt:
  13292. return m.UpdatedAt()
  13293. case employeeconfig.FieldDeletedAt:
  13294. return m.DeletedAt()
  13295. case employeeconfig.FieldStype:
  13296. return m.Stype()
  13297. case employeeconfig.FieldTitle:
  13298. return m.Title()
  13299. case employeeconfig.FieldPhoto:
  13300. return m.Photo()
  13301. case employeeconfig.FieldOrganizationID:
  13302. return m.OrganizationID()
  13303. }
  13304. return nil, false
  13305. }
  13306. // OldField returns the old value of the field from the database. An error is
  13307. // returned if the mutation operation is not UpdateOne, or the query to the
  13308. // database failed.
  13309. func (m *EmployeeConfigMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  13310. switch name {
  13311. case employeeconfig.FieldCreatedAt:
  13312. return m.OldCreatedAt(ctx)
  13313. case employeeconfig.FieldUpdatedAt:
  13314. return m.OldUpdatedAt(ctx)
  13315. case employeeconfig.FieldDeletedAt:
  13316. return m.OldDeletedAt(ctx)
  13317. case employeeconfig.FieldStype:
  13318. return m.OldStype(ctx)
  13319. case employeeconfig.FieldTitle:
  13320. return m.OldTitle(ctx)
  13321. case employeeconfig.FieldPhoto:
  13322. return m.OldPhoto(ctx)
  13323. case employeeconfig.FieldOrganizationID:
  13324. return m.OldOrganizationID(ctx)
  13325. }
  13326. return nil, fmt.Errorf("unknown EmployeeConfig field %s", name)
  13327. }
  13328. // SetField sets the value of a field with the given name. It returns an error if
  13329. // the field is not defined in the schema, or if the type mismatched the field
  13330. // type.
  13331. func (m *EmployeeConfigMutation) SetField(name string, value ent.Value) error {
  13332. switch name {
  13333. case employeeconfig.FieldCreatedAt:
  13334. v, ok := value.(time.Time)
  13335. if !ok {
  13336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13337. }
  13338. m.SetCreatedAt(v)
  13339. return nil
  13340. case employeeconfig.FieldUpdatedAt:
  13341. v, ok := value.(time.Time)
  13342. if !ok {
  13343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13344. }
  13345. m.SetUpdatedAt(v)
  13346. return nil
  13347. case employeeconfig.FieldDeletedAt:
  13348. v, ok := value.(time.Time)
  13349. if !ok {
  13350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13351. }
  13352. m.SetDeletedAt(v)
  13353. return nil
  13354. case employeeconfig.FieldStype:
  13355. v, ok := value.(string)
  13356. if !ok {
  13357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13358. }
  13359. m.SetStype(v)
  13360. return nil
  13361. case employeeconfig.FieldTitle:
  13362. v, ok := value.(string)
  13363. if !ok {
  13364. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13365. }
  13366. m.SetTitle(v)
  13367. return nil
  13368. case employeeconfig.FieldPhoto:
  13369. v, ok := value.(string)
  13370. if !ok {
  13371. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13372. }
  13373. m.SetPhoto(v)
  13374. return nil
  13375. case employeeconfig.FieldOrganizationID:
  13376. v, ok := value.(uint64)
  13377. if !ok {
  13378. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13379. }
  13380. m.SetOrganizationID(v)
  13381. return nil
  13382. }
  13383. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13384. }
  13385. // AddedFields returns all numeric fields that were incremented/decremented during
  13386. // this mutation.
  13387. func (m *EmployeeConfigMutation) AddedFields() []string {
  13388. var fields []string
  13389. if m.addorganization_id != nil {
  13390. fields = append(fields, employeeconfig.FieldOrganizationID)
  13391. }
  13392. return fields
  13393. }
  13394. // AddedField returns the numeric value that was incremented/decremented on a field
  13395. // with the given name. The second boolean return value indicates that this field
  13396. // was not set, or was not defined in the schema.
  13397. func (m *EmployeeConfigMutation) AddedField(name string) (ent.Value, bool) {
  13398. switch name {
  13399. case employeeconfig.FieldOrganizationID:
  13400. return m.AddedOrganizationID()
  13401. }
  13402. return nil, false
  13403. }
  13404. // AddField adds the value to the 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) AddField(name string, value ent.Value) error {
  13408. switch name {
  13409. case employeeconfig.FieldOrganizationID:
  13410. v, ok := value.(int64)
  13411. if !ok {
  13412. return fmt.Errorf("unexpected type %T for field %s", value, name)
  13413. }
  13414. m.AddOrganizationID(v)
  13415. return nil
  13416. }
  13417. return fmt.Errorf("unknown EmployeeConfig numeric field %s", name)
  13418. }
  13419. // ClearedFields returns all nullable fields that were cleared during this
  13420. // mutation.
  13421. func (m *EmployeeConfigMutation) ClearedFields() []string {
  13422. var fields []string
  13423. if m.FieldCleared(employeeconfig.FieldDeletedAt) {
  13424. fields = append(fields, employeeconfig.FieldDeletedAt)
  13425. }
  13426. if m.FieldCleared(employeeconfig.FieldOrganizationID) {
  13427. fields = append(fields, employeeconfig.FieldOrganizationID)
  13428. }
  13429. return fields
  13430. }
  13431. // FieldCleared returns a boolean indicating if a field with the given name was
  13432. // cleared in this mutation.
  13433. func (m *EmployeeConfigMutation) FieldCleared(name string) bool {
  13434. _, ok := m.clearedFields[name]
  13435. return ok
  13436. }
  13437. // ClearField clears the value of the field with the given name. It returns an
  13438. // error if the field is not defined in the schema.
  13439. func (m *EmployeeConfigMutation) ClearField(name string) error {
  13440. switch name {
  13441. case employeeconfig.FieldDeletedAt:
  13442. m.ClearDeletedAt()
  13443. return nil
  13444. case employeeconfig.FieldOrganizationID:
  13445. m.ClearOrganizationID()
  13446. return nil
  13447. }
  13448. return fmt.Errorf("unknown EmployeeConfig nullable field %s", name)
  13449. }
  13450. // ResetField resets all changes in the mutation for the field with the given name.
  13451. // It returns an error if the field is not defined in the schema.
  13452. func (m *EmployeeConfigMutation) ResetField(name string) error {
  13453. switch name {
  13454. case employeeconfig.FieldCreatedAt:
  13455. m.ResetCreatedAt()
  13456. return nil
  13457. case employeeconfig.FieldUpdatedAt:
  13458. m.ResetUpdatedAt()
  13459. return nil
  13460. case employeeconfig.FieldDeletedAt:
  13461. m.ResetDeletedAt()
  13462. return nil
  13463. case employeeconfig.FieldStype:
  13464. m.ResetStype()
  13465. return nil
  13466. case employeeconfig.FieldTitle:
  13467. m.ResetTitle()
  13468. return nil
  13469. case employeeconfig.FieldPhoto:
  13470. m.ResetPhoto()
  13471. return nil
  13472. case employeeconfig.FieldOrganizationID:
  13473. m.ResetOrganizationID()
  13474. return nil
  13475. }
  13476. return fmt.Errorf("unknown EmployeeConfig field %s", name)
  13477. }
  13478. // AddedEdges returns all edge names that were set/added in this mutation.
  13479. func (m *EmployeeConfigMutation) AddedEdges() []string {
  13480. edges := make([]string, 0, 0)
  13481. return edges
  13482. }
  13483. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  13484. // name in this mutation.
  13485. func (m *EmployeeConfigMutation) AddedIDs(name string) []ent.Value {
  13486. return nil
  13487. }
  13488. // RemovedEdges returns all edge names that were removed in this mutation.
  13489. func (m *EmployeeConfigMutation) RemovedEdges() []string {
  13490. edges := make([]string, 0, 0)
  13491. return edges
  13492. }
  13493. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  13494. // the given name in this mutation.
  13495. func (m *EmployeeConfigMutation) RemovedIDs(name string) []ent.Value {
  13496. return nil
  13497. }
  13498. // ClearedEdges returns all edge names that were cleared in this mutation.
  13499. func (m *EmployeeConfigMutation) ClearedEdges() []string {
  13500. edges := make([]string, 0, 0)
  13501. return edges
  13502. }
  13503. // EdgeCleared returns a boolean which indicates if the edge with the given name
  13504. // was cleared in this mutation.
  13505. func (m *EmployeeConfigMutation) EdgeCleared(name string) bool {
  13506. return false
  13507. }
  13508. // ClearEdge clears the value of the edge with the given name. It returns an error
  13509. // if that edge is not defined in the schema.
  13510. func (m *EmployeeConfigMutation) ClearEdge(name string) error {
  13511. return fmt.Errorf("unknown EmployeeConfig unique edge %s", name)
  13512. }
  13513. // ResetEdge resets all changes to the edge with the given name in this mutation.
  13514. // It returns an error if the edge is not defined in the schema.
  13515. func (m *EmployeeConfigMutation) ResetEdge(name string) error {
  13516. return fmt.Errorf("unknown EmployeeConfig edge %s", name)
  13517. }
  13518. // LabelMutation represents an operation that mutates the Label nodes in the graph.
  13519. type LabelMutation struct {
  13520. config
  13521. op Op
  13522. typ string
  13523. id *uint64
  13524. created_at *time.Time
  13525. updated_at *time.Time
  13526. status *uint8
  13527. addstatus *int8
  13528. _type *int
  13529. add_type *int
  13530. name *string
  13531. from *int
  13532. addfrom *int
  13533. mode *int
  13534. addmode *int
  13535. conditions *string
  13536. organization_id *uint64
  13537. addorganization_id *int64
  13538. clearedFields map[string]struct{}
  13539. label_relationships map[uint64]struct{}
  13540. removedlabel_relationships map[uint64]struct{}
  13541. clearedlabel_relationships bool
  13542. done bool
  13543. oldValue func(context.Context) (*Label, error)
  13544. predicates []predicate.Label
  13545. }
  13546. var _ ent.Mutation = (*LabelMutation)(nil)
  13547. // labelOption allows management of the mutation configuration using functional options.
  13548. type labelOption func(*LabelMutation)
  13549. // newLabelMutation creates new mutation for the Label entity.
  13550. func newLabelMutation(c config, op Op, opts ...labelOption) *LabelMutation {
  13551. m := &LabelMutation{
  13552. config: c,
  13553. op: op,
  13554. typ: TypeLabel,
  13555. clearedFields: make(map[string]struct{}),
  13556. }
  13557. for _, opt := range opts {
  13558. opt(m)
  13559. }
  13560. return m
  13561. }
  13562. // withLabelID sets the ID field of the mutation.
  13563. func withLabelID(id uint64) labelOption {
  13564. return func(m *LabelMutation) {
  13565. var (
  13566. err error
  13567. once sync.Once
  13568. value *Label
  13569. )
  13570. m.oldValue = func(ctx context.Context) (*Label, error) {
  13571. once.Do(func() {
  13572. if m.done {
  13573. err = errors.New("querying old values post mutation is not allowed")
  13574. } else {
  13575. value, err = m.Client().Label.Get(ctx, id)
  13576. }
  13577. })
  13578. return value, err
  13579. }
  13580. m.id = &id
  13581. }
  13582. }
  13583. // withLabel sets the old Label of the mutation.
  13584. func withLabel(node *Label) labelOption {
  13585. return func(m *LabelMutation) {
  13586. m.oldValue = func(context.Context) (*Label, error) {
  13587. return node, nil
  13588. }
  13589. m.id = &node.ID
  13590. }
  13591. }
  13592. // Client returns a new `ent.Client` from the mutation. If the mutation was
  13593. // executed in a transaction (ent.Tx), a transactional client is returned.
  13594. func (m LabelMutation) Client() *Client {
  13595. client := &Client{config: m.config}
  13596. client.init()
  13597. return client
  13598. }
  13599. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  13600. // it returns an error otherwise.
  13601. func (m LabelMutation) Tx() (*Tx, error) {
  13602. if _, ok := m.driver.(*txDriver); !ok {
  13603. return nil, errors.New("ent: mutation is not running in a transaction")
  13604. }
  13605. tx := &Tx{config: m.config}
  13606. tx.init()
  13607. return tx, nil
  13608. }
  13609. // SetID sets the value of the id field. Note that this
  13610. // operation is only accepted on creation of Label entities.
  13611. func (m *LabelMutation) SetID(id uint64) {
  13612. m.id = &id
  13613. }
  13614. // ID returns the ID value in the mutation. Note that the ID is only available
  13615. // if it was provided to the builder or after it was returned from the database.
  13616. func (m *LabelMutation) ID() (id uint64, exists bool) {
  13617. if m.id == nil {
  13618. return
  13619. }
  13620. return *m.id, true
  13621. }
  13622. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  13623. // That means, if the mutation is applied within a transaction with an isolation level such
  13624. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  13625. // or updated by the mutation.
  13626. func (m *LabelMutation) IDs(ctx context.Context) ([]uint64, error) {
  13627. switch {
  13628. case m.op.Is(OpUpdateOne | OpDeleteOne):
  13629. id, exists := m.ID()
  13630. if exists {
  13631. return []uint64{id}, nil
  13632. }
  13633. fallthrough
  13634. case m.op.Is(OpUpdate | OpDelete):
  13635. return m.Client().Label.Query().Where(m.predicates...).IDs(ctx)
  13636. default:
  13637. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  13638. }
  13639. }
  13640. // SetCreatedAt sets the "created_at" field.
  13641. func (m *LabelMutation) SetCreatedAt(t time.Time) {
  13642. m.created_at = &t
  13643. }
  13644. // CreatedAt returns the value of the "created_at" field in the mutation.
  13645. func (m *LabelMutation) CreatedAt() (r time.Time, exists bool) {
  13646. v := m.created_at
  13647. if v == nil {
  13648. return
  13649. }
  13650. return *v, true
  13651. }
  13652. // OldCreatedAt returns the old "created_at" field's value of the Label entity.
  13653. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13655. func (m *LabelMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  13656. if !m.op.Is(OpUpdateOne) {
  13657. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  13658. }
  13659. if m.id == nil || m.oldValue == nil {
  13660. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  13661. }
  13662. oldValue, err := m.oldValue(ctx)
  13663. if err != nil {
  13664. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  13665. }
  13666. return oldValue.CreatedAt, nil
  13667. }
  13668. // ResetCreatedAt resets all changes to the "created_at" field.
  13669. func (m *LabelMutation) ResetCreatedAt() {
  13670. m.created_at = nil
  13671. }
  13672. // SetUpdatedAt sets the "updated_at" field.
  13673. func (m *LabelMutation) SetUpdatedAt(t time.Time) {
  13674. m.updated_at = &t
  13675. }
  13676. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  13677. func (m *LabelMutation) UpdatedAt() (r time.Time, exists bool) {
  13678. v := m.updated_at
  13679. if v == nil {
  13680. return
  13681. }
  13682. return *v, true
  13683. }
  13684. // OldUpdatedAt returns the old "updated_at" field's value of the Label entity.
  13685. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13686. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13687. func (m *LabelMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  13688. if !m.op.Is(OpUpdateOne) {
  13689. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  13690. }
  13691. if m.id == nil || m.oldValue == nil {
  13692. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  13693. }
  13694. oldValue, err := m.oldValue(ctx)
  13695. if err != nil {
  13696. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  13697. }
  13698. return oldValue.UpdatedAt, nil
  13699. }
  13700. // ResetUpdatedAt resets all changes to the "updated_at" field.
  13701. func (m *LabelMutation) ResetUpdatedAt() {
  13702. m.updated_at = nil
  13703. }
  13704. // SetStatus sets the "status" field.
  13705. func (m *LabelMutation) SetStatus(u uint8) {
  13706. m.status = &u
  13707. m.addstatus = nil
  13708. }
  13709. // Status returns the value of the "status" field in the mutation.
  13710. func (m *LabelMutation) Status() (r uint8, exists bool) {
  13711. v := m.status
  13712. if v == nil {
  13713. return
  13714. }
  13715. return *v, true
  13716. }
  13717. // OldStatus returns the old "status" field's value of the Label entity.
  13718. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13719. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13720. func (m *LabelMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  13721. if !m.op.Is(OpUpdateOne) {
  13722. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  13723. }
  13724. if m.id == nil || m.oldValue == nil {
  13725. return v, errors.New("OldStatus requires an ID field in the mutation")
  13726. }
  13727. oldValue, err := m.oldValue(ctx)
  13728. if err != nil {
  13729. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  13730. }
  13731. return oldValue.Status, nil
  13732. }
  13733. // AddStatus adds u to the "status" field.
  13734. func (m *LabelMutation) AddStatus(u int8) {
  13735. if m.addstatus != nil {
  13736. *m.addstatus += u
  13737. } else {
  13738. m.addstatus = &u
  13739. }
  13740. }
  13741. // AddedStatus returns the value that was added to the "status" field in this mutation.
  13742. func (m *LabelMutation) AddedStatus() (r int8, exists bool) {
  13743. v := m.addstatus
  13744. if v == nil {
  13745. return
  13746. }
  13747. return *v, true
  13748. }
  13749. // ClearStatus clears the value of the "status" field.
  13750. func (m *LabelMutation) ClearStatus() {
  13751. m.status = nil
  13752. m.addstatus = nil
  13753. m.clearedFields[label.FieldStatus] = struct{}{}
  13754. }
  13755. // StatusCleared returns if the "status" field was cleared in this mutation.
  13756. func (m *LabelMutation) StatusCleared() bool {
  13757. _, ok := m.clearedFields[label.FieldStatus]
  13758. return ok
  13759. }
  13760. // ResetStatus resets all changes to the "status" field.
  13761. func (m *LabelMutation) ResetStatus() {
  13762. m.status = nil
  13763. m.addstatus = nil
  13764. delete(m.clearedFields, label.FieldStatus)
  13765. }
  13766. // SetType sets the "type" field.
  13767. func (m *LabelMutation) SetType(i int) {
  13768. m._type = &i
  13769. m.add_type = nil
  13770. }
  13771. // GetType returns the value of the "type" field in the mutation.
  13772. func (m *LabelMutation) GetType() (r int, exists bool) {
  13773. v := m._type
  13774. if v == nil {
  13775. return
  13776. }
  13777. return *v, true
  13778. }
  13779. // OldType returns the old "type" field's value of the Label entity.
  13780. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13781. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13782. func (m *LabelMutation) OldType(ctx context.Context) (v int, err error) {
  13783. if !m.op.Is(OpUpdateOne) {
  13784. return v, errors.New("OldType is only allowed on UpdateOne operations")
  13785. }
  13786. if m.id == nil || m.oldValue == nil {
  13787. return v, errors.New("OldType requires an ID field in the mutation")
  13788. }
  13789. oldValue, err := m.oldValue(ctx)
  13790. if err != nil {
  13791. return v, fmt.Errorf("querying old value for OldType: %w", err)
  13792. }
  13793. return oldValue.Type, nil
  13794. }
  13795. // AddType adds i to the "type" field.
  13796. func (m *LabelMutation) AddType(i int) {
  13797. if m.add_type != nil {
  13798. *m.add_type += i
  13799. } else {
  13800. m.add_type = &i
  13801. }
  13802. }
  13803. // AddedType returns the value that was added to the "type" field in this mutation.
  13804. func (m *LabelMutation) AddedType() (r int, exists bool) {
  13805. v := m.add_type
  13806. if v == nil {
  13807. return
  13808. }
  13809. return *v, true
  13810. }
  13811. // ResetType resets all changes to the "type" field.
  13812. func (m *LabelMutation) ResetType() {
  13813. m._type = nil
  13814. m.add_type = nil
  13815. }
  13816. // SetName sets the "name" field.
  13817. func (m *LabelMutation) SetName(s string) {
  13818. m.name = &s
  13819. }
  13820. // Name returns the value of the "name" field in the mutation.
  13821. func (m *LabelMutation) Name() (r string, exists bool) {
  13822. v := m.name
  13823. if v == nil {
  13824. return
  13825. }
  13826. return *v, true
  13827. }
  13828. // OldName returns the old "name" field's value of the Label entity.
  13829. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13831. func (m *LabelMutation) OldName(ctx context.Context) (v string, err error) {
  13832. if !m.op.Is(OpUpdateOne) {
  13833. return v, errors.New("OldName is only allowed on UpdateOne operations")
  13834. }
  13835. if m.id == nil || m.oldValue == nil {
  13836. return v, errors.New("OldName requires an ID field in the mutation")
  13837. }
  13838. oldValue, err := m.oldValue(ctx)
  13839. if err != nil {
  13840. return v, fmt.Errorf("querying old value for OldName: %w", err)
  13841. }
  13842. return oldValue.Name, nil
  13843. }
  13844. // ResetName resets all changes to the "name" field.
  13845. func (m *LabelMutation) ResetName() {
  13846. m.name = nil
  13847. }
  13848. // SetFrom sets the "from" field.
  13849. func (m *LabelMutation) SetFrom(i int) {
  13850. m.from = &i
  13851. m.addfrom = nil
  13852. }
  13853. // From returns the value of the "from" field in the mutation.
  13854. func (m *LabelMutation) From() (r int, exists bool) {
  13855. v := m.from
  13856. if v == nil {
  13857. return
  13858. }
  13859. return *v, true
  13860. }
  13861. // OldFrom returns the old "from" field's value of the Label entity.
  13862. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13864. func (m *LabelMutation) OldFrom(ctx context.Context) (v int, err error) {
  13865. if !m.op.Is(OpUpdateOne) {
  13866. return v, errors.New("OldFrom is only allowed on UpdateOne operations")
  13867. }
  13868. if m.id == nil || m.oldValue == nil {
  13869. return v, errors.New("OldFrom requires an ID field in the mutation")
  13870. }
  13871. oldValue, err := m.oldValue(ctx)
  13872. if err != nil {
  13873. return v, fmt.Errorf("querying old value for OldFrom: %w", err)
  13874. }
  13875. return oldValue.From, nil
  13876. }
  13877. // AddFrom adds i to the "from" field.
  13878. func (m *LabelMutation) AddFrom(i int) {
  13879. if m.addfrom != nil {
  13880. *m.addfrom += i
  13881. } else {
  13882. m.addfrom = &i
  13883. }
  13884. }
  13885. // AddedFrom returns the value that was added to the "from" field in this mutation.
  13886. func (m *LabelMutation) AddedFrom() (r int, exists bool) {
  13887. v := m.addfrom
  13888. if v == nil {
  13889. return
  13890. }
  13891. return *v, true
  13892. }
  13893. // ResetFrom resets all changes to the "from" field.
  13894. func (m *LabelMutation) ResetFrom() {
  13895. m.from = nil
  13896. m.addfrom = nil
  13897. }
  13898. // SetMode sets the "mode" field.
  13899. func (m *LabelMutation) SetMode(i int) {
  13900. m.mode = &i
  13901. m.addmode = nil
  13902. }
  13903. // Mode returns the value of the "mode" field in the mutation.
  13904. func (m *LabelMutation) Mode() (r int, exists bool) {
  13905. v := m.mode
  13906. if v == nil {
  13907. return
  13908. }
  13909. return *v, true
  13910. }
  13911. // OldMode returns the old "mode" field's value of the Label entity.
  13912. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13913. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13914. func (m *LabelMutation) OldMode(ctx context.Context) (v int, err error) {
  13915. if !m.op.Is(OpUpdateOne) {
  13916. return v, errors.New("OldMode is only allowed on UpdateOne operations")
  13917. }
  13918. if m.id == nil || m.oldValue == nil {
  13919. return v, errors.New("OldMode requires an ID field in the mutation")
  13920. }
  13921. oldValue, err := m.oldValue(ctx)
  13922. if err != nil {
  13923. return v, fmt.Errorf("querying old value for OldMode: %w", err)
  13924. }
  13925. return oldValue.Mode, nil
  13926. }
  13927. // AddMode adds i to the "mode" field.
  13928. func (m *LabelMutation) AddMode(i int) {
  13929. if m.addmode != nil {
  13930. *m.addmode += i
  13931. } else {
  13932. m.addmode = &i
  13933. }
  13934. }
  13935. // AddedMode returns the value that was added to the "mode" field in this mutation.
  13936. func (m *LabelMutation) AddedMode() (r int, exists bool) {
  13937. v := m.addmode
  13938. if v == nil {
  13939. return
  13940. }
  13941. return *v, true
  13942. }
  13943. // ResetMode resets all changes to the "mode" field.
  13944. func (m *LabelMutation) ResetMode() {
  13945. m.mode = nil
  13946. m.addmode = nil
  13947. }
  13948. // SetConditions sets the "conditions" field.
  13949. func (m *LabelMutation) SetConditions(s string) {
  13950. m.conditions = &s
  13951. }
  13952. // Conditions returns the value of the "conditions" field in the mutation.
  13953. func (m *LabelMutation) Conditions() (r string, exists bool) {
  13954. v := m.conditions
  13955. if v == nil {
  13956. return
  13957. }
  13958. return *v, true
  13959. }
  13960. // OldConditions returns the old "conditions" field's value of the Label entity.
  13961. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  13962. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  13963. func (m *LabelMutation) OldConditions(ctx context.Context) (v string, err error) {
  13964. if !m.op.Is(OpUpdateOne) {
  13965. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  13966. }
  13967. if m.id == nil || m.oldValue == nil {
  13968. return v, errors.New("OldConditions requires an ID field in the mutation")
  13969. }
  13970. oldValue, err := m.oldValue(ctx)
  13971. if err != nil {
  13972. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  13973. }
  13974. return oldValue.Conditions, nil
  13975. }
  13976. // ClearConditions clears the value of the "conditions" field.
  13977. func (m *LabelMutation) ClearConditions() {
  13978. m.conditions = nil
  13979. m.clearedFields[label.FieldConditions] = struct{}{}
  13980. }
  13981. // ConditionsCleared returns if the "conditions" field was cleared in this mutation.
  13982. func (m *LabelMutation) ConditionsCleared() bool {
  13983. _, ok := m.clearedFields[label.FieldConditions]
  13984. return ok
  13985. }
  13986. // ResetConditions resets all changes to the "conditions" field.
  13987. func (m *LabelMutation) ResetConditions() {
  13988. m.conditions = nil
  13989. delete(m.clearedFields, label.FieldConditions)
  13990. }
  13991. // SetOrganizationID sets the "organization_id" field.
  13992. func (m *LabelMutation) SetOrganizationID(u uint64) {
  13993. m.organization_id = &u
  13994. m.addorganization_id = nil
  13995. }
  13996. // OrganizationID returns the value of the "organization_id" field in the mutation.
  13997. func (m *LabelMutation) OrganizationID() (r uint64, exists bool) {
  13998. v := m.organization_id
  13999. if v == nil {
  14000. return
  14001. }
  14002. return *v, true
  14003. }
  14004. // OldOrganizationID returns the old "organization_id" field's value of the Label entity.
  14005. // If the Label object wasn't provided to the builder, the object is fetched from the database.
  14006. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14007. func (m *LabelMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14008. if !m.op.Is(OpUpdateOne) {
  14009. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14010. }
  14011. if m.id == nil || m.oldValue == nil {
  14012. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14013. }
  14014. oldValue, err := m.oldValue(ctx)
  14015. if err != nil {
  14016. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14017. }
  14018. return oldValue.OrganizationID, nil
  14019. }
  14020. // AddOrganizationID adds u to the "organization_id" field.
  14021. func (m *LabelMutation) AddOrganizationID(u int64) {
  14022. if m.addorganization_id != nil {
  14023. *m.addorganization_id += u
  14024. } else {
  14025. m.addorganization_id = &u
  14026. }
  14027. }
  14028. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14029. func (m *LabelMutation) AddedOrganizationID() (r int64, exists bool) {
  14030. v := m.addorganization_id
  14031. if v == nil {
  14032. return
  14033. }
  14034. return *v, true
  14035. }
  14036. // ClearOrganizationID clears the value of the "organization_id" field.
  14037. func (m *LabelMutation) ClearOrganizationID() {
  14038. m.organization_id = nil
  14039. m.addorganization_id = nil
  14040. m.clearedFields[label.FieldOrganizationID] = struct{}{}
  14041. }
  14042. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14043. func (m *LabelMutation) OrganizationIDCleared() bool {
  14044. _, ok := m.clearedFields[label.FieldOrganizationID]
  14045. return ok
  14046. }
  14047. // ResetOrganizationID resets all changes to the "organization_id" field.
  14048. func (m *LabelMutation) ResetOrganizationID() {
  14049. m.organization_id = nil
  14050. m.addorganization_id = nil
  14051. delete(m.clearedFields, label.FieldOrganizationID)
  14052. }
  14053. // AddLabelRelationshipIDs adds the "label_relationships" edge to the LabelRelationship entity by ids.
  14054. func (m *LabelMutation) AddLabelRelationshipIDs(ids ...uint64) {
  14055. if m.label_relationships == nil {
  14056. m.label_relationships = make(map[uint64]struct{})
  14057. }
  14058. for i := range ids {
  14059. m.label_relationships[ids[i]] = struct{}{}
  14060. }
  14061. }
  14062. // ClearLabelRelationships clears the "label_relationships" edge to the LabelRelationship entity.
  14063. func (m *LabelMutation) ClearLabelRelationships() {
  14064. m.clearedlabel_relationships = true
  14065. }
  14066. // LabelRelationshipsCleared reports if the "label_relationships" edge to the LabelRelationship entity was cleared.
  14067. func (m *LabelMutation) LabelRelationshipsCleared() bool {
  14068. return m.clearedlabel_relationships
  14069. }
  14070. // RemoveLabelRelationshipIDs removes the "label_relationships" edge to the LabelRelationship entity by IDs.
  14071. func (m *LabelMutation) RemoveLabelRelationshipIDs(ids ...uint64) {
  14072. if m.removedlabel_relationships == nil {
  14073. m.removedlabel_relationships = make(map[uint64]struct{})
  14074. }
  14075. for i := range ids {
  14076. delete(m.label_relationships, ids[i])
  14077. m.removedlabel_relationships[ids[i]] = struct{}{}
  14078. }
  14079. }
  14080. // RemovedLabelRelationships returns the removed IDs of the "label_relationships" edge to the LabelRelationship entity.
  14081. func (m *LabelMutation) RemovedLabelRelationshipsIDs() (ids []uint64) {
  14082. for id := range m.removedlabel_relationships {
  14083. ids = append(ids, id)
  14084. }
  14085. return
  14086. }
  14087. // LabelRelationshipsIDs returns the "label_relationships" edge IDs in the mutation.
  14088. func (m *LabelMutation) LabelRelationshipsIDs() (ids []uint64) {
  14089. for id := range m.label_relationships {
  14090. ids = append(ids, id)
  14091. }
  14092. return
  14093. }
  14094. // ResetLabelRelationships resets all changes to the "label_relationships" edge.
  14095. func (m *LabelMutation) ResetLabelRelationships() {
  14096. m.label_relationships = nil
  14097. m.clearedlabel_relationships = false
  14098. m.removedlabel_relationships = nil
  14099. }
  14100. // Where appends a list predicates to the LabelMutation builder.
  14101. func (m *LabelMutation) Where(ps ...predicate.Label) {
  14102. m.predicates = append(m.predicates, ps...)
  14103. }
  14104. // WhereP appends storage-level predicates to the LabelMutation builder. Using this method,
  14105. // users can use type-assertion to append predicates that do not depend on any generated package.
  14106. func (m *LabelMutation) WhereP(ps ...func(*sql.Selector)) {
  14107. p := make([]predicate.Label, len(ps))
  14108. for i := range ps {
  14109. p[i] = ps[i]
  14110. }
  14111. m.Where(p...)
  14112. }
  14113. // Op returns the operation name.
  14114. func (m *LabelMutation) Op() Op {
  14115. return m.op
  14116. }
  14117. // SetOp allows setting the mutation operation.
  14118. func (m *LabelMutation) SetOp(op Op) {
  14119. m.op = op
  14120. }
  14121. // Type returns the node type of this mutation (Label).
  14122. func (m *LabelMutation) Type() string {
  14123. return m.typ
  14124. }
  14125. // Fields returns all fields that were changed during this mutation. Note that in
  14126. // order to get all numeric fields that were incremented/decremented, call
  14127. // AddedFields().
  14128. func (m *LabelMutation) Fields() []string {
  14129. fields := make([]string, 0, 9)
  14130. if m.created_at != nil {
  14131. fields = append(fields, label.FieldCreatedAt)
  14132. }
  14133. if m.updated_at != nil {
  14134. fields = append(fields, label.FieldUpdatedAt)
  14135. }
  14136. if m.status != nil {
  14137. fields = append(fields, label.FieldStatus)
  14138. }
  14139. if m._type != nil {
  14140. fields = append(fields, label.FieldType)
  14141. }
  14142. if m.name != nil {
  14143. fields = append(fields, label.FieldName)
  14144. }
  14145. if m.from != nil {
  14146. fields = append(fields, label.FieldFrom)
  14147. }
  14148. if m.mode != nil {
  14149. fields = append(fields, label.FieldMode)
  14150. }
  14151. if m.conditions != nil {
  14152. fields = append(fields, label.FieldConditions)
  14153. }
  14154. if m.organization_id != nil {
  14155. fields = append(fields, label.FieldOrganizationID)
  14156. }
  14157. return fields
  14158. }
  14159. // Field returns the value of a field with the given name. The second boolean
  14160. // return value indicates that this field was not set, or was not defined in the
  14161. // schema.
  14162. func (m *LabelMutation) Field(name string) (ent.Value, bool) {
  14163. switch name {
  14164. case label.FieldCreatedAt:
  14165. return m.CreatedAt()
  14166. case label.FieldUpdatedAt:
  14167. return m.UpdatedAt()
  14168. case label.FieldStatus:
  14169. return m.Status()
  14170. case label.FieldType:
  14171. return m.GetType()
  14172. case label.FieldName:
  14173. return m.Name()
  14174. case label.FieldFrom:
  14175. return m.From()
  14176. case label.FieldMode:
  14177. return m.Mode()
  14178. case label.FieldConditions:
  14179. return m.Conditions()
  14180. case label.FieldOrganizationID:
  14181. return m.OrganizationID()
  14182. }
  14183. return nil, false
  14184. }
  14185. // OldField returns the old value of the field from the database. An error is
  14186. // returned if the mutation operation is not UpdateOne, or the query to the
  14187. // database failed.
  14188. func (m *LabelMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  14189. switch name {
  14190. case label.FieldCreatedAt:
  14191. return m.OldCreatedAt(ctx)
  14192. case label.FieldUpdatedAt:
  14193. return m.OldUpdatedAt(ctx)
  14194. case label.FieldStatus:
  14195. return m.OldStatus(ctx)
  14196. case label.FieldType:
  14197. return m.OldType(ctx)
  14198. case label.FieldName:
  14199. return m.OldName(ctx)
  14200. case label.FieldFrom:
  14201. return m.OldFrom(ctx)
  14202. case label.FieldMode:
  14203. return m.OldMode(ctx)
  14204. case label.FieldConditions:
  14205. return m.OldConditions(ctx)
  14206. case label.FieldOrganizationID:
  14207. return m.OldOrganizationID(ctx)
  14208. }
  14209. return nil, fmt.Errorf("unknown Label field %s", name)
  14210. }
  14211. // SetField sets the value of a field with the given name. It returns an error if
  14212. // the field is not defined in the schema, or if the type mismatched the field
  14213. // type.
  14214. func (m *LabelMutation) SetField(name string, value ent.Value) error {
  14215. switch name {
  14216. case label.FieldCreatedAt:
  14217. v, ok := value.(time.Time)
  14218. if !ok {
  14219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14220. }
  14221. m.SetCreatedAt(v)
  14222. return nil
  14223. case label.FieldUpdatedAt:
  14224. v, ok := value.(time.Time)
  14225. if !ok {
  14226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14227. }
  14228. m.SetUpdatedAt(v)
  14229. return nil
  14230. case label.FieldStatus:
  14231. v, ok := value.(uint8)
  14232. if !ok {
  14233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14234. }
  14235. m.SetStatus(v)
  14236. return nil
  14237. case label.FieldType:
  14238. v, ok := value.(int)
  14239. if !ok {
  14240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14241. }
  14242. m.SetType(v)
  14243. return nil
  14244. case label.FieldName:
  14245. v, ok := value.(string)
  14246. if !ok {
  14247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14248. }
  14249. m.SetName(v)
  14250. return nil
  14251. case label.FieldFrom:
  14252. v, ok := value.(int)
  14253. if !ok {
  14254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14255. }
  14256. m.SetFrom(v)
  14257. return nil
  14258. case label.FieldMode:
  14259. v, ok := value.(int)
  14260. if !ok {
  14261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14262. }
  14263. m.SetMode(v)
  14264. return nil
  14265. case label.FieldConditions:
  14266. v, ok := value.(string)
  14267. if !ok {
  14268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14269. }
  14270. m.SetConditions(v)
  14271. return nil
  14272. case label.FieldOrganizationID:
  14273. v, ok := value.(uint64)
  14274. if !ok {
  14275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14276. }
  14277. m.SetOrganizationID(v)
  14278. return nil
  14279. }
  14280. return fmt.Errorf("unknown Label field %s", name)
  14281. }
  14282. // AddedFields returns all numeric fields that were incremented/decremented during
  14283. // this mutation.
  14284. func (m *LabelMutation) AddedFields() []string {
  14285. var fields []string
  14286. if m.addstatus != nil {
  14287. fields = append(fields, label.FieldStatus)
  14288. }
  14289. if m.add_type != nil {
  14290. fields = append(fields, label.FieldType)
  14291. }
  14292. if m.addfrom != nil {
  14293. fields = append(fields, label.FieldFrom)
  14294. }
  14295. if m.addmode != nil {
  14296. fields = append(fields, label.FieldMode)
  14297. }
  14298. if m.addorganization_id != nil {
  14299. fields = append(fields, label.FieldOrganizationID)
  14300. }
  14301. return fields
  14302. }
  14303. // AddedField returns the numeric value that was incremented/decremented on a field
  14304. // with the given name. The second boolean return value indicates that this field
  14305. // was not set, or was not defined in the schema.
  14306. func (m *LabelMutation) AddedField(name string) (ent.Value, bool) {
  14307. switch name {
  14308. case label.FieldStatus:
  14309. return m.AddedStatus()
  14310. case label.FieldType:
  14311. return m.AddedType()
  14312. case label.FieldFrom:
  14313. return m.AddedFrom()
  14314. case label.FieldMode:
  14315. return m.AddedMode()
  14316. case label.FieldOrganizationID:
  14317. return m.AddedOrganizationID()
  14318. }
  14319. return nil, false
  14320. }
  14321. // AddField adds the value to the field with the given name. It returns an error if
  14322. // the field is not defined in the schema, or if the type mismatched the field
  14323. // type.
  14324. func (m *LabelMutation) AddField(name string, value ent.Value) error {
  14325. switch name {
  14326. case label.FieldStatus:
  14327. v, ok := value.(int8)
  14328. if !ok {
  14329. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14330. }
  14331. m.AddStatus(v)
  14332. return nil
  14333. case label.FieldType:
  14334. v, ok := value.(int)
  14335. if !ok {
  14336. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14337. }
  14338. m.AddType(v)
  14339. return nil
  14340. case label.FieldFrom:
  14341. v, ok := value.(int)
  14342. if !ok {
  14343. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14344. }
  14345. m.AddFrom(v)
  14346. return nil
  14347. case label.FieldMode:
  14348. v, ok := value.(int)
  14349. if !ok {
  14350. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14351. }
  14352. m.AddMode(v)
  14353. return nil
  14354. case label.FieldOrganizationID:
  14355. v, ok := value.(int64)
  14356. if !ok {
  14357. return fmt.Errorf("unexpected type %T for field %s", value, name)
  14358. }
  14359. m.AddOrganizationID(v)
  14360. return nil
  14361. }
  14362. return fmt.Errorf("unknown Label numeric field %s", name)
  14363. }
  14364. // ClearedFields returns all nullable fields that were cleared during this
  14365. // mutation.
  14366. func (m *LabelMutation) ClearedFields() []string {
  14367. var fields []string
  14368. if m.FieldCleared(label.FieldStatus) {
  14369. fields = append(fields, label.FieldStatus)
  14370. }
  14371. if m.FieldCleared(label.FieldConditions) {
  14372. fields = append(fields, label.FieldConditions)
  14373. }
  14374. if m.FieldCleared(label.FieldOrganizationID) {
  14375. fields = append(fields, label.FieldOrganizationID)
  14376. }
  14377. return fields
  14378. }
  14379. // FieldCleared returns a boolean indicating if a field with the given name was
  14380. // cleared in this mutation.
  14381. func (m *LabelMutation) FieldCleared(name string) bool {
  14382. _, ok := m.clearedFields[name]
  14383. return ok
  14384. }
  14385. // ClearField clears the value of the field with the given name. It returns an
  14386. // error if the field is not defined in the schema.
  14387. func (m *LabelMutation) ClearField(name string) error {
  14388. switch name {
  14389. case label.FieldStatus:
  14390. m.ClearStatus()
  14391. return nil
  14392. case label.FieldConditions:
  14393. m.ClearConditions()
  14394. return nil
  14395. case label.FieldOrganizationID:
  14396. m.ClearOrganizationID()
  14397. return nil
  14398. }
  14399. return fmt.Errorf("unknown Label nullable field %s", name)
  14400. }
  14401. // ResetField resets all changes in the mutation for the field with the given name.
  14402. // It returns an error if the field is not defined in the schema.
  14403. func (m *LabelMutation) ResetField(name string) error {
  14404. switch name {
  14405. case label.FieldCreatedAt:
  14406. m.ResetCreatedAt()
  14407. return nil
  14408. case label.FieldUpdatedAt:
  14409. m.ResetUpdatedAt()
  14410. return nil
  14411. case label.FieldStatus:
  14412. m.ResetStatus()
  14413. return nil
  14414. case label.FieldType:
  14415. m.ResetType()
  14416. return nil
  14417. case label.FieldName:
  14418. m.ResetName()
  14419. return nil
  14420. case label.FieldFrom:
  14421. m.ResetFrom()
  14422. return nil
  14423. case label.FieldMode:
  14424. m.ResetMode()
  14425. return nil
  14426. case label.FieldConditions:
  14427. m.ResetConditions()
  14428. return nil
  14429. case label.FieldOrganizationID:
  14430. m.ResetOrganizationID()
  14431. return nil
  14432. }
  14433. return fmt.Errorf("unknown Label field %s", name)
  14434. }
  14435. // AddedEdges returns all edge names that were set/added in this mutation.
  14436. func (m *LabelMutation) AddedEdges() []string {
  14437. edges := make([]string, 0, 1)
  14438. if m.label_relationships != nil {
  14439. edges = append(edges, label.EdgeLabelRelationships)
  14440. }
  14441. return edges
  14442. }
  14443. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  14444. // name in this mutation.
  14445. func (m *LabelMutation) AddedIDs(name string) []ent.Value {
  14446. switch name {
  14447. case label.EdgeLabelRelationships:
  14448. ids := make([]ent.Value, 0, len(m.label_relationships))
  14449. for id := range m.label_relationships {
  14450. ids = append(ids, id)
  14451. }
  14452. return ids
  14453. }
  14454. return nil
  14455. }
  14456. // RemovedEdges returns all edge names that were removed in this mutation.
  14457. func (m *LabelMutation) RemovedEdges() []string {
  14458. edges := make([]string, 0, 1)
  14459. if m.removedlabel_relationships != nil {
  14460. edges = append(edges, label.EdgeLabelRelationships)
  14461. }
  14462. return edges
  14463. }
  14464. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  14465. // the given name in this mutation.
  14466. func (m *LabelMutation) RemovedIDs(name string) []ent.Value {
  14467. switch name {
  14468. case label.EdgeLabelRelationships:
  14469. ids := make([]ent.Value, 0, len(m.removedlabel_relationships))
  14470. for id := range m.removedlabel_relationships {
  14471. ids = append(ids, id)
  14472. }
  14473. return ids
  14474. }
  14475. return nil
  14476. }
  14477. // ClearedEdges returns all edge names that were cleared in this mutation.
  14478. func (m *LabelMutation) ClearedEdges() []string {
  14479. edges := make([]string, 0, 1)
  14480. if m.clearedlabel_relationships {
  14481. edges = append(edges, label.EdgeLabelRelationships)
  14482. }
  14483. return edges
  14484. }
  14485. // EdgeCleared returns a boolean which indicates if the edge with the given name
  14486. // was cleared in this mutation.
  14487. func (m *LabelMutation) EdgeCleared(name string) bool {
  14488. switch name {
  14489. case label.EdgeLabelRelationships:
  14490. return m.clearedlabel_relationships
  14491. }
  14492. return false
  14493. }
  14494. // ClearEdge clears the value of the edge with the given name. It returns an error
  14495. // if that edge is not defined in the schema.
  14496. func (m *LabelMutation) ClearEdge(name string) error {
  14497. switch name {
  14498. }
  14499. return fmt.Errorf("unknown Label unique edge %s", name)
  14500. }
  14501. // ResetEdge resets all changes to the edge with the given name in this mutation.
  14502. // It returns an error if the edge is not defined in the schema.
  14503. func (m *LabelMutation) ResetEdge(name string) error {
  14504. switch name {
  14505. case label.EdgeLabelRelationships:
  14506. m.ResetLabelRelationships()
  14507. return nil
  14508. }
  14509. return fmt.Errorf("unknown Label edge %s", name)
  14510. }
  14511. // LabelRelationshipMutation represents an operation that mutates the LabelRelationship nodes in the graph.
  14512. type LabelRelationshipMutation struct {
  14513. config
  14514. op Op
  14515. typ string
  14516. id *uint64
  14517. created_at *time.Time
  14518. updated_at *time.Time
  14519. status *uint8
  14520. addstatus *int8
  14521. organization_id *uint64
  14522. addorganization_id *int64
  14523. clearedFields map[string]struct{}
  14524. contacts *uint64
  14525. clearedcontacts bool
  14526. labels *uint64
  14527. clearedlabels bool
  14528. done bool
  14529. oldValue func(context.Context) (*LabelRelationship, error)
  14530. predicates []predicate.LabelRelationship
  14531. }
  14532. var _ ent.Mutation = (*LabelRelationshipMutation)(nil)
  14533. // labelrelationshipOption allows management of the mutation configuration using functional options.
  14534. type labelrelationshipOption func(*LabelRelationshipMutation)
  14535. // newLabelRelationshipMutation creates new mutation for the LabelRelationship entity.
  14536. func newLabelRelationshipMutation(c config, op Op, opts ...labelrelationshipOption) *LabelRelationshipMutation {
  14537. m := &LabelRelationshipMutation{
  14538. config: c,
  14539. op: op,
  14540. typ: TypeLabelRelationship,
  14541. clearedFields: make(map[string]struct{}),
  14542. }
  14543. for _, opt := range opts {
  14544. opt(m)
  14545. }
  14546. return m
  14547. }
  14548. // withLabelRelationshipID sets the ID field of the mutation.
  14549. func withLabelRelationshipID(id uint64) labelrelationshipOption {
  14550. return func(m *LabelRelationshipMutation) {
  14551. var (
  14552. err error
  14553. once sync.Once
  14554. value *LabelRelationship
  14555. )
  14556. m.oldValue = func(ctx context.Context) (*LabelRelationship, error) {
  14557. once.Do(func() {
  14558. if m.done {
  14559. err = errors.New("querying old values post mutation is not allowed")
  14560. } else {
  14561. value, err = m.Client().LabelRelationship.Get(ctx, id)
  14562. }
  14563. })
  14564. return value, err
  14565. }
  14566. m.id = &id
  14567. }
  14568. }
  14569. // withLabelRelationship sets the old LabelRelationship of the mutation.
  14570. func withLabelRelationship(node *LabelRelationship) labelrelationshipOption {
  14571. return func(m *LabelRelationshipMutation) {
  14572. m.oldValue = func(context.Context) (*LabelRelationship, error) {
  14573. return node, nil
  14574. }
  14575. m.id = &node.ID
  14576. }
  14577. }
  14578. // Client returns a new `ent.Client` from the mutation. If the mutation was
  14579. // executed in a transaction (ent.Tx), a transactional client is returned.
  14580. func (m LabelRelationshipMutation) Client() *Client {
  14581. client := &Client{config: m.config}
  14582. client.init()
  14583. return client
  14584. }
  14585. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  14586. // it returns an error otherwise.
  14587. func (m LabelRelationshipMutation) Tx() (*Tx, error) {
  14588. if _, ok := m.driver.(*txDriver); !ok {
  14589. return nil, errors.New("ent: mutation is not running in a transaction")
  14590. }
  14591. tx := &Tx{config: m.config}
  14592. tx.init()
  14593. return tx, nil
  14594. }
  14595. // SetID sets the value of the id field. Note that this
  14596. // operation is only accepted on creation of LabelRelationship entities.
  14597. func (m *LabelRelationshipMutation) SetID(id uint64) {
  14598. m.id = &id
  14599. }
  14600. // ID returns the ID value in the mutation. Note that the ID is only available
  14601. // if it was provided to the builder or after it was returned from the database.
  14602. func (m *LabelRelationshipMutation) ID() (id uint64, exists bool) {
  14603. if m.id == nil {
  14604. return
  14605. }
  14606. return *m.id, true
  14607. }
  14608. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  14609. // That means, if the mutation is applied within a transaction with an isolation level such
  14610. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  14611. // or updated by the mutation.
  14612. func (m *LabelRelationshipMutation) IDs(ctx context.Context) ([]uint64, error) {
  14613. switch {
  14614. case m.op.Is(OpUpdateOne | OpDeleteOne):
  14615. id, exists := m.ID()
  14616. if exists {
  14617. return []uint64{id}, nil
  14618. }
  14619. fallthrough
  14620. case m.op.Is(OpUpdate | OpDelete):
  14621. return m.Client().LabelRelationship.Query().Where(m.predicates...).IDs(ctx)
  14622. default:
  14623. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  14624. }
  14625. }
  14626. // SetCreatedAt sets the "created_at" field.
  14627. func (m *LabelRelationshipMutation) SetCreatedAt(t time.Time) {
  14628. m.created_at = &t
  14629. }
  14630. // CreatedAt returns the value of the "created_at" field in the mutation.
  14631. func (m *LabelRelationshipMutation) CreatedAt() (r time.Time, exists bool) {
  14632. v := m.created_at
  14633. if v == nil {
  14634. return
  14635. }
  14636. return *v, true
  14637. }
  14638. // OldCreatedAt returns the old "created_at" field's value of the LabelRelationship entity.
  14639. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14640. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14641. func (m *LabelRelationshipMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  14642. if !m.op.Is(OpUpdateOne) {
  14643. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  14644. }
  14645. if m.id == nil || m.oldValue == nil {
  14646. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  14647. }
  14648. oldValue, err := m.oldValue(ctx)
  14649. if err != nil {
  14650. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  14651. }
  14652. return oldValue.CreatedAt, nil
  14653. }
  14654. // ResetCreatedAt resets all changes to the "created_at" field.
  14655. func (m *LabelRelationshipMutation) ResetCreatedAt() {
  14656. m.created_at = nil
  14657. }
  14658. // SetUpdatedAt sets the "updated_at" field.
  14659. func (m *LabelRelationshipMutation) SetUpdatedAt(t time.Time) {
  14660. m.updated_at = &t
  14661. }
  14662. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  14663. func (m *LabelRelationshipMutation) UpdatedAt() (r time.Time, exists bool) {
  14664. v := m.updated_at
  14665. if v == nil {
  14666. return
  14667. }
  14668. return *v, true
  14669. }
  14670. // OldUpdatedAt returns the old "updated_at" field's value of the LabelRelationship entity.
  14671. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14672. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14673. func (m *LabelRelationshipMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  14674. if !m.op.Is(OpUpdateOne) {
  14675. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  14676. }
  14677. if m.id == nil || m.oldValue == nil {
  14678. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  14679. }
  14680. oldValue, err := m.oldValue(ctx)
  14681. if err != nil {
  14682. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  14683. }
  14684. return oldValue.UpdatedAt, nil
  14685. }
  14686. // ResetUpdatedAt resets all changes to the "updated_at" field.
  14687. func (m *LabelRelationshipMutation) ResetUpdatedAt() {
  14688. m.updated_at = nil
  14689. }
  14690. // SetStatus sets the "status" field.
  14691. func (m *LabelRelationshipMutation) SetStatus(u uint8) {
  14692. m.status = &u
  14693. m.addstatus = nil
  14694. }
  14695. // Status returns the value of the "status" field in the mutation.
  14696. func (m *LabelRelationshipMutation) Status() (r uint8, exists bool) {
  14697. v := m.status
  14698. if v == nil {
  14699. return
  14700. }
  14701. return *v, true
  14702. }
  14703. // OldStatus returns the old "status" field's value of the LabelRelationship entity.
  14704. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14705. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14706. func (m *LabelRelationshipMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  14707. if !m.op.Is(OpUpdateOne) {
  14708. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  14709. }
  14710. if m.id == nil || m.oldValue == nil {
  14711. return v, errors.New("OldStatus requires an ID field in the mutation")
  14712. }
  14713. oldValue, err := m.oldValue(ctx)
  14714. if err != nil {
  14715. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  14716. }
  14717. return oldValue.Status, nil
  14718. }
  14719. // AddStatus adds u to the "status" field.
  14720. func (m *LabelRelationshipMutation) AddStatus(u int8) {
  14721. if m.addstatus != nil {
  14722. *m.addstatus += u
  14723. } else {
  14724. m.addstatus = &u
  14725. }
  14726. }
  14727. // AddedStatus returns the value that was added to the "status" field in this mutation.
  14728. func (m *LabelRelationshipMutation) AddedStatus() (r int8, exists bool) {
  14729. v := m.addstatus
  14730. if v == nil {
  14731. return
  14732. }
  14733. return *v, true
  14734. }
  14735. // ClearStatus clears the value of the "status" field.
  14736. func (m *LabelRelationshipMutation) ClearStatus() {
  14737. m.status = nil
  14738. m.addstatus = nil
  14739. m.clearedFields[labelrelationship.FieldStatus] = struct{}{}
  14740. }
  14741. // StatusCleared returns if the "status" field was cleared in this mutation.
  14742. func (m *LabelRelationshipMutation) StatusCleared() bool {
  14743. _, ok := m.clearedFields[labelrelationship.FieldStatus]
  14744. return ok
  14745. }
  14746. // ResetStatus resets all changes to the "status" field.
  14747. func (m *LabelRelationshipMutation) ResetStatus() {
  14748. m.status = nil
  14749. m.addstatus = nil
  14750. delete(m.clearedFields, labelrelationship.FieldStatus)
  14751. }
  14752. // SetLabelID sets the "label_id" field.
  14753. func (m *LabelRelationshipMutation) SetLabelID(u uint64) {
  14754. m.labels = &u
  14755. }
  14756. // LabelID returns the value of the "label_id" field in the mutation.
  14757. func (m *LabelRelationshipMutation) LabelID() (r uint64, exists bool) {
  14758. v := m.labels
  14759. if v == nil {
  14760. return
  14761. }
  14762. return *v, true
  14763. }
  14764. // OldLabelID returns the old "label_id" field's value of the LabelRelationship entity.
  14765. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14766. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14767. func (m *LabelRelationshipMutation) OldLabelID(ctx context.Context) (v uint64, err error) {
  14768. if !m.op.Is(OpUpdateOne) {
  14769. return v, errors.New("OldLabelID is only allowed on UpdateOne operations")
  14770. }
  14771. if m.id == nil || m.oldValue == nil {
  14772. return v, errors.New("OldLabelID requires an ID field in the mutation")
  14773. }
  14774. oldValue, err := m.oldValue(ctx)
  14775. if err != nil {
  14776. return v, fmt.Errorf("querying old value for OldLabelID: %w", err)
  14777. }
  14778. return oldValue.LabelID, nil
  14779. }
  14780. // ResetLabelID resets all changes to the "label_id" field.
  14781. func (m *LabelRelationshipMutation) ResetLabelID() {
  14782. m.labels = nil
  14783. }
  14784. // SetContactID sets the "contact_id" field.
  14785. func (m *LabelRelationshipMutation) SetContactID(u uint64) {
  14786. m.contacts = &u
  14787. }
  14788. // ContactID returns the value of the "contact_id" field in the mutation.
  14789. func (m *LabelRelationshipMutation) ContactID() (r uint64, exists bool) {
  14790. v := m.contacts
  14791. if v == nil {
  14792. return
  14793. }
  14794. return *v, true
  14795. }
  14796. // OldContactID returns the old "contact_id" field's value of the LabelRelationship entity.
  14797. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14799. func (m *LabelRelationshipMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  14800. if !m.op.Is(OpUpdateOne) {
  14801. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  14802. }
  14803. if m.id == nil || m.oldValue == nil {
  14804. return v, errors.New("OldContactID requires an ID field in the mutation")
  14805. }
  14806. oldValue, err := m.oldValue(ctx)
  14807. if err != nil {
  14808. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  14809. }
  14810. return oldValue.ContactID, nil
  14811. }
  14812. // ResetContactID resets all changes to the "contact_id" field.
  14813. func (m *LabelRelationshipMutation) ResetContactID() {
  14814. m.contacts = nil
  14815. }
  14816. // SetOrganizationID sets the "organization_id" field.
  14817. func (m *LabelRelationshipMutation) SetOrganizationID(u uint64) {
  14818. m.organization_id = &u
  14819. m.addorganization_id = nil
  14820. }
  14821. // OrganizationID returns the value of the "organization_id" field in the mutation.
  14822. func (m *LabelRelationshipMutation) OrganizationID() (r uint64, exists bool) {
  14823. v := m.organization_id
  14824. if v == nil {
  14825. return
  14826. }
  14827. return *v, true
  14828. }
  14829. // OldOrganizationID returns the old "organization_id" field's value of the LabelRelationship entity.
  14830. // If the LabelRelationship object wasn't provided to the builder, the object is fetched from the database.
  14831. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  14832. func (m *LabelRelationshipMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  14833. if !m.op.Is(OpUpdateOne) {
  14834. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  14835. }
  14836. if m.id == nil || m.oldValue == nil {
  14837. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  14838. }
  14839. oldValue, err := m.oldValue(ctx)
  14840. if err != nil {
  14841. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  14842. }
  14843. return oldValue.OrganizationID, nil
  14844. }
  14845. // AddOrganizationID adds u to the "organization_id" field.
  14846. func (m *LabelRelationshipMutation) AddOrganizationID(u int64) {
  14847. if m.addorganization_id != nil {
  14848. *m.addorganization_id += u
  14849. } else {
  14850. m.addorganization_id = &u
  14851. }
  14852. }
  14853. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  14854. func (m *LabelRelationshipMutation) AddedOrganizationID() (r int64, exists bool) {
  14855. v := m.addorganization_id
  14856. if v == nil {
  14857. return
  14858. }
  14859. return *v, true
  14860. }
  14861. // ClearOrganizationID clears the value of the "organization_id" field.
  14862. func (m *LabelRelationshipMutation) ClearOrganizationID() {
  14863. m.organization_id = nil
  14864. m.addorganization_id = nil
  14865. m.clearedFields[labelrelationship.FieldOrganizationID] = struct{}{}
  14866. }
  14867. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  14868. func (m *LabelRelationshipMutation) OrganizationIDCleared() bool {
  14869. _, ok := m.clearedFields[labelrelationship.FieldOrganizationID]
  14870. return ok
  14871. }
  14872. // ResetOrganizationID resets all changes to the "organization_id" field.
  14873. func (m *LabelRelationshipMutation) ResetOrganizationID() {
  14874. m.organization_id = nil
  14875. m.addorganization_id = nil
  14876. delete(m.clearedFields, labelrelationship.FieldOrganizationID)
  14877. }
  14878. // SetContactsID sets the "contacts" edge to the Contact entity by id.
  14879. func (m *LabelRelationshipMutation) SetContactsID(id uint64) {
  14880. m.contacts = &id
  14881. }
  14882. // ClearContacts clears the "contacts" edge to the Contact entity.
  14883. func (m *LabelRelationshipMutation) ClearContacts() {
  14884. m.clearedcontacts = true
  14885. m.clearedFields[labelrelationship.FieldContactID] = struct{}{}
  14886. }
  14887. // ContactsCleared reports if the "contacts" edge to the Contact entity was cleared.
  14888. func (m *LabelRelationshipMutation) ContactsCleared() bool {
  14889. return m.clearedcontacts
  14890. }
  14891. // ContactsID returns the "contacts" edge ID in the mutation.
  14892. func (m *LabelRelationshipMutation) ContactsID() (id uint64, exists bool) {
  14893. if m.contacts != nil {
  14894. return *m.contacts, true
  14895. }
  14896. return
  14897. }
  14898. // ContactsIDs returns the "contacts" edge IDs in the mutation.
  14899. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14900. // ContactsID instead. It exists only for internal usage by the builders.
  14901. func (m *LabelRelationshipMutation) ContactsIDs() (ids []uint64) {
  14902. if id := m.contacts; id != nil {
  14903. ids = append(ids, *id)
  14904. }
  14905. return
  14906. }
  14907. // ResetContacts resets all changes to the "contacts" edge.
  14908. func (m *LabelRelationshipMutation) ResetContacts() {
  14909. m.contacts = nil
  14910. m.clearedcontacts = false
  14911. }
  14912. // SetLabelsID sets the "labels" edge to the Label entity by id.
  14913. func (m *LabelRelationshipMutation) SetLabelsID(id uint64) {
  14914. m.labels = &id
  14915. }
  14916. // ClearLabels clears the "labels" edge to the Label entity.
  14917. func (m *LabelRelationshipMutation) ClearLabels() {
  14918. m.clearedlabels = true
  14919. m.clearedFields[labelrelationship.FieldLabelID] = struct{}{}
  14920. }
  14921. // LabelsCleared reports if the "labels" edge to the Label entity was cleared.
  14922. func (m *LabelRelationshipMutation) LabelsCleared() bool {
  14923. return m.clearedlabels
  14924. }
  14925. // LabelsID returns the "labels" edge ID in the mutation.
  14926. func (m *LabelRelationshipMutation) LabelsID() (id uint64, exists bool) {
  14927. if m.labels != nil {
  14928. return *m.labels, true
  14929. }
  14930. return
  14931. }
  14932. // LabelsIDs returns the "labels" edge IDs in the mutation.
  14933. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  14934. // LabelsID instead. It exists only for internal usage by the builders.
  14935. func (m *LabelRelationshipMutation) LabelsIDs() (ids []uint64) {
  14936. if id := m.labels; id != nil {
  14937. ids = append(ids, *id)
  14938. }
  14939. return
  14940. }
  14941. // ResetLabels resets all changes to the "labels" edge.
  14942. func (m *LabelRelationshipMutation) ResetLabels() {
  14943. m.labels = nil
  14944. m.clearedlabels = false
  14945. }
  14946. // Where appends a list predicates to the LabelRelationshipMutation builder.
  14947. func (m *LabelRelationshipMutation) Where(ps ...predicate.LabelRelationship) {
  14948. m.predicates = append(m.predicates, ps...)
  14949. }
  14950. // WhereP appends storage-level predicates to the LabelRelationshipMutation builder. Using this method,
  14951. // users can use type-assertion to append predicates that do not depend on any generated package.
  14952. func (m *LabelRelationshipMutation) WhereP(ps ...func(*sql.Selector)) {
  14953. p := make([]predicate.LabelRelationship, len(ps))
  14954. for i := range ps {
  14955. p[i] = ps[i]
  14956. }
  14957. m.Where(p...)
  14958. }
  14959. // Op returns the operation name.
  14960. func (m *LabelRelationshipMutation) Op() Op {
  14961. return m.op
  14962. }
  14963. // SetOp allows setting the mutation operation.
  14964. func (m *LabelRelationshipMutation) SetOp(op Op) {
  14965. m.op = op
  14966. }
  14967. // Type returns the node type of this mutation (LabelRelationship).
  14968. func (m *LabelRelationshipMutation) Type() string {
  14969. return m.typ
  14970. }
  14971. // Fields returns all fields that were changed during this mutation. Note that in
  14972. // order to get all numeric fields that were incremented/decremented, call
  14973. // AddedFields().
  14974. func (m *LabelRelationshipMutation) Fields() []string {
  14975. fields := make([]string, 0, 6)
  14976. if m.created_at != nil {
  14977. fields = append(fields, labelrelationship.FieldCreatedAt)
  14978. }
  14979. if m.updated_at != nil {
  14980. fields = append(fields, labelrelationship.FieldUpdatedAt)
  14981. }
  14982. if m.status != nil {
  14983. fields = append(fields, labelrelationship.FieldStatus)
  14984. }
  14985. if m.labels != nil {
  14986. fields = append(fields, labelrelationship.FieldLabelID)
  14987. }
  14988. if m.contacts != nil {
  14989. fields = append(fields, labelrelationship.FieldContactID)
  14990. }
  14991. if m.organization_id != nil {
  14992. fields = append(fields, labelrelationship.FieldOrganizationID)
  14993. }
  14994. return fields
  14995. }
  14996. // Field returns the value of a field with the given name. The second boolean
  14997. // return value indicates that this field was not set, or was not defined in the
  14998. // schema.
  14999. func (m *LabelRelationshipMutation) Field(name string) (ent.Value, bool) {
  15000. switch name {
  15001. case labelrelationship.FieldCreatedAt:
  15002. return m.CreatedAt()
  15003. case labelrelationship.FieldUpdatedAt:
  15004. return m.UpdatedAt()
  15005. case labelrelationship.FieldStatus:
  15006. return m.Status()
  15007. case labelrelationship.FieldLabelID:
  15008. return m.LabelID()
  15009. case labelrelationship.FieldContactID:
  15010. return m.ContactID()
  15011. case labelrelationship.FieldOrganizationID:
  15012. return m.OrganizationID()
  15013. }
  15014. return nil, false
  15015. }
  15016. // OldField returns the old value of the field from the database. An error is
  15017. // returned if the mutation operation is not UpdateOne, or the query to the
  15018. // database failed.
  15019. func (m *LabelRelationshipMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15020. switch name {
  15021. case labelrelationship.FieldCreatedAt:
  15022. return m.OldCreatedAt(ctx)
  15023. case labelrelationship.FieldUpdatedAt:
  15024. return m.OldUpdatedAt(ctx)
  15025. case labelrelationship.FieldStatus:
  15026. return m.OldStatus(ctx)
  15027. case labelrelationship.FieldLabelID:
  15028. return m.OldLabelID(ctx)
  15029. case labelrelationship.FieldContactID:
  15030. return m.OldContactID(ctx)
  15031. case labelrelationship.FieldOrganizationID:
  15032. return m.OldOrganizationID(ctx)
  15033. }
  15034. return nil, fmt.Errorf("unknown LabelRelationship field %s", name)
  15035. }
  15036. // SetField sets the value of a field with the given name. It returns an error if
  15037. // the field is not defined in the schema, or if the type mismatched the field
  15038. // type.
  15039. func (m *LabelRelationshipMutation) SetField(name string, value ent.Value) error {
  15040. switch name {
  15041. case labelrelationship.FieldCreatedAt:
  15042. v, ok := value.(time.Time)
  15043. if !ok {
  15044. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15045. }
  15046. m.SetCreatedAt(v)
  15047. return nil
  15048. case labelrelationship.FieldUpdatedAt:
  15049. v, ok := value.(time.Time)
  15050. if !ok {
  15051. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15052. }
  15053. m.SetUpdatedAt(v)
  15054. return nil
  15055. case labelrelationship.FieldStatus:
  15056. v, ok := value.(uint8)
  15057. if !ok {
  15058. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15059. }
  15060. m.SetStatus(v)
  15061. return nil
  15062. case labelrelationship.FieldLabelID:
  15063. v, ok := value.(uint64)
  15064. if !ok {
  15065. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15066. }
  15067. m.SetLabelID(v)
  15068. return nil
  15069. case labelrelationship.FieldContactID:
  15070. v, ok := value.(uint64)
  15071. if !ok {
  15072. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15073. }
  15074. m.SetContactID(v)
  15075. return nil
  15076. case labelrelationship.FieldOrganizationID:
  15077. v, ok := value.(uint64)
  15078. if !ok {
  15079. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15080. }
  15081. m.SetOrganizationID(v)
  15082. return nil
  15083. }
  15084. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15085. }
  15086. // AddedFields returns all numeric fields that were incremented/decremented during
  15087. // this mutation.
  15088. func (m *LabelRelationshipMutation) AddedFields() []string {
  15089. var fields []string
  15090. if m.addstatus != nil {
  15091. fields = append(fields, labelrelationship.FieldStatus)
  15092. }
  15093. if m.addorganization_id != nil {
  15094. fields = append(fields, labelrelationship.FieldOrganizationID)
  15095. }
  15096. return fields
  15097. }
  15098. // AddedField returns the numeric value that was incremented/decremented on a field
  15099. // with the given name. The second boolean return value indicates that this field
  15100. // was not set, or was not defined in the schema.
  15101. func (m *LabelRelationshipMutation) AddedField(name string) (ent.Value, bool) {
  15102. switch name {
  15103. case labelrelationship.FieldStatus:
  15104. return m.AddedStatus()
  15105. case labelrelationship.FieldOrganizationID:
  15106. return m.AddedOrganizationID()
  15107. }
  15108. return nil, false
  15109. }
  15110. // AddField adds the value to the field with the given name. It returns an error if
  15111. // the field is not defined in the schema, or if the type mismatched the field
  15112. // type.
  15113. func (m *LabelRelationshipMutation) AddField(name string, value ent.Value) error {
  15114. switch name {
  15115. case labelrelationship.FieldStatus:
  15116. v, ok := value.(int8)
  15117. if !ok {
  15118. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15119. }
  15120. m.AddStatus(v)
  15121. return nil
  15122. case labelrelationship.FieldOrganizationID:
  15123. v, ok := value.(int64)
  15124. if !ok {
  15125. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15126. }
  15127. m.AddOrganizationID(v)
  15128. return nil
  15129. }
  15130. return fmt.Errorf("unknown LabelRelationship numeric field %s", name)
  15131. }
  15132. // ClearedFields returns all nullable fields that were cleared during this
  15133. // mutation.
  15134. func (m *LabelRelationshipMutation) ClearedFields() []string {
  15135. var fields []string
  15136. if m.FieldCleared(labelrelationship.FieldStatus) {
  15137. fields = append(fields, labelrelationship.FieldStatus)
  15138. }
  15139. if m.FieldCleared(labelrelationship.FieldOrganizationID) {
  15140. fields = append(fields, labelrelationship.FieldOrganizationID)
  15141. }
  15142. return fields
  15143. }
  15144. // FieldCleared returns a boolean indicating if a field with the given name was
  15145. // cleared in this mutation.
  15146. func (m *LabelRelationshipMutation) FieldCleared(name string) bool {
  15147. _, ok := m.clearedFields[name]
  15148. return ok
  15149. }
  15150. // ClearField clears the value of the field with the given name. It returns an
  15151. // error if the field is not defined in the schema.
  15152. func (m *LabelRelationshipMutation) ClearField(name string) error {
  15153. switch name {
  15154. case labelrelationship.FieldStatus:
  15155. m.ClearStatus()
  15156. return nil
  15157. case labelrelationship.FieldOrganizationID:
  15158. m.ClearOrganizationID()
  15159. return nil
  15160. }
  15161. return fmt.Errorf("unknown LabelRelationship nullable field %s", name)
  15162. }
  15163. // ResetField resets all changes in the mutation for the field with the given name.
  15164. // It returns an error if the field is not defined in the schema.
  15165. func (m *LabelRelationshipMutation) ResetField(name string) error {
  15166. switch name {
  15167. case labelrelationship.FieldCreatedAt:
  15168. m.ResetCreatedAt()
  15169. return nil
  15170. case labelrelationship.FieldUpdatedAt:
  15171. m.ResetUpdatedAt()
  15172. return nil
  15173. case labelrelationship.FieldStatus:
  15174. m.ResetStatus()
  15175. return nil
  15176. case labelrelationship.FieldLabelID:
  15177. m.ResetLabelID()
  15178. return nil
  15179. case labelrelationship.FieldContactID:
  15180. m.ResetContactID()
  15181. return nil
  15182. case labelrelationship.FieldOrganizationID:
  15183. m.ResetOrganizationID()
  15184. return nil
  15185. }
  15186. return fmt.Errorf("unknown LabelRelationship field %s", name)
  15187. }
  15188. // AddedEdges returns all edge names that were set/added in this mutation.
  15189. func (m *LabelRelationshipMutation) AddedEdges() []string {
  15190. edges := make([]string, 0, 2)
  15191. if m.contacts != nil {
  15192. edges = append(edges, labelrelationship.EdgeContacts)
  15193. }
  15194. if m.labels != nil {
  15195. edges = append(edges, labelrelationship.EdgeLabels)
  15196. }
  15197. return edges
  15198. }
  15199. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  15200. // name in this mutation.
  15201. func (m *LabelRelationshipMutation) AddedIDs(name string) []ent.Value {
  15202. switch name {
  15203. case labelrelationship.EdgeContacts:
  15204. if id := m.contacts; id != nil {
  15205. return []ent.Value{*id}
  15206. }
  15207. case labelrelationship.EdgeLabels:
  15208. if id := m.labels; id != nil {
  15209. return []ent.Value{*id}
  15210. }
  15211. }
  15212. return nil
  15213. }
  15214. // RemovedEdges returns all edge names that were removed in this mutation.
  15215. func (m *LabelRelationshipMutation) RemovedEdges() []string {
  15216. edges := make([]string, 0, 2)
  15217. return edges
  15218. }
  15219. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  15220. // the given name in this mutation.
  15221. func (m *LabelRelationshipMutation) RemovedIDs(name string) []ent.Value {
  15222. return nil
  15223. }
  15224. // ClearedEdges returns all edge names that were cleared in this mutation.
  15225. func (m *LabelRelationshipMutation) ClearedEdges() []string {
  15226. edges := make([]string, 0, 2)
  15227. if m.clearedcontacts {
  15228. edges = append(edges, labelrelationship.EdgeContacts)
  15229. }
  15230. if m.clearedlabels {
  15231. edges = append(edges, labelrelationship.EdgeLabels)
  15232. }
  15233. return edges
  15234. }
  15235. // EdgeCleared returns a boolean which indicates if the edge with the given name
  15236. // was cleared in this mutation.
  15237. func (m *LabelRelationshipMutation) EdgeCleared(name string) bool {
  15238. switch name {
  15239. case labelrelationship.EdgeContacts:
  15240. return m.clearedcontacts
  15241. case labelrelationship.EdgeLabels:
  15242. return m.clearedlabels
  15243. }
  15244. return false
  15245. }
  15246. // ClearEdge clears the value of the edge with the given name. It returns an error
  15247. // if that edge is not defined in the schema.
  15248. func (m *LabelRelationshipMutation) ClearEdge(name string) error {
  15249. switch name {
  15250. case labelrelationship.EdgeContacts:
  15251. m.ClearContacts()
  15252. return nil
  15253. case labelrelationship.EdgeLabels:
  15254. m.ClearLabels()
  15255. return nil
  15256. }
  15257. return fmt.Errorf("unknown LabelRelationship unique edge %s", name)
  15258. }
  15259. // ResetEdge resets all changes to the edge with the given name in this mutation.
  15260. // It returns an error if the edge is not defined in the schema.
  15261. func (m *LabelRelationshipMutation) ResetEdge(name string) error {
  15262. switch name {
  15263. case labelrelationship.EdgeContacts:
  15264. m.ResetContacts()
  15265. return nil
  15266. case labelrelationship.EdgeLabels:
  15267. m.ResetLabels()
  15268. return nil
  15269. }
  15270. return fmt.Errorf("unknown LabelRelationship edge %s", name)
  15271. }
  15272. // LabelTaggingMutation represents an operation that mutates the LabelTagging nodes in the graph.
  15273. type LabelTaggingMutation struct {
  15274. config
  15275. op Op
  15276. typ string
  15277. id *uint64
  15278. created_at *time.Time
  15279. updated_at *time.Time
  15280. status *uint8
  15281. addstatus *int8
  15282. deleted_at *time.Time
  15283. organization_id *uint64
  15284. addorganization_id *int64
  15285. _type *int
  15286. add_type *int
  15287. conditions *string
  15288. action_label_add *[]uint64
  15289. appendaction_label_add []uint64
  15290. action_label_del *[]uint64
  15291. appendaction_label_del []uint64
  15292. clearedFields map[string]struct{}
  15293. done bool
  15294. oldValue func(context.Context) (*LabelTagging, error)
  15295. predicates []predicate.LabelTagging
  15296. }
  15297. var _ ent.Mutation = (*LabelTaggingMutation)(nil)
  15298. // labeltaggingOption allows management of the mutation configuration using functional options.
  15299. type labeltaggingOption func(*LabelTaggingMutation)
  15300. // newLabelTaggingMutation creates new mutation for the LabelTagging entity.
  15301. func newLabelTaggingMutation(c config, op Op, opts ...labeltaggingOption) *LabelTaggingMutation {
  15302. m := &LabelTaggingMutation{
  15303. config: c,
  15304. op: op,
  15305. typ: TypeLabelTagging,
  15306. clearedFields: make(map[string]struct{}),
  15307. }
  15308. for _, opt := range opts {
  15309. opt(m)
  15310. }
  15311. return m
  15312. }
  15313. // withLabelTaggingID sets the ID field of the mutation.
  15314. func withLabelTaggingID(id uint64) labeltaggingOption {
  15315. return func(m *LabelTaggingMutation) {
  15316. var (
  15317. err error
  15318. once sync.Once
  15319. value *LabelTagging
  15320. )
  15321. m.oldValue = func(ctx context.Context) (*LabelTagging, error) {
  15322. once.Do(func() {
  15323. if m.done {
  15324. err = errors.New("querying old values post mutation is not allowed")
  15325. } else {
  15326. value, err = m.Client().LabelTagging.Get(ctx, id)
  15327. }
  15328. })
  15329. return value, err
  15330. }
  15331. m.id = &id
  15332. }
  15333. }
  15334. // withLabelTagging sets the old LabelTagging of the mutation.
  15335. func withLabelTagging(node *LabelTagging) labeltaggingOption {
  15336. return func(m *LabelTaggingMutation) {
  15337. m.oldValue = func(context.Context) (*LabelTagging, error) {
  15338. return node, nil
  15339. }
  15340. m.id = &node.ID
  15341. }
  15342. }
  15343. // Client returns a new `ent.Client` from the mutation. If the mutation was
  15344. // executed in a transaction (ent.Tx), a transactional client is returned.
  15345. func (m LabelTaggingMutation) Client() *Client {
  15346. client := &Client{config: m.config}
  15347. client.init()
  15348. return client
  15349. }
  15350. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  15351. // it returns an error otherwise.
  15352. func (m LabelTaggingMutation) Tx() (*Tx, error) {
  15353. if _, ok := m.driver.(*txDriver); !ok {
  15354. return nil, errors.New("ent: mutation is not running in a transaction")
  15355. }
  15356. tx := &Tx{config: m.config}
  15357. tx.init()
  15358. return tx, nil
  15359. }
  15360. // SetID sets the value of the id field. Note that this
  15361. // operation is only accepted on creation of LabelTagging entities.
  15362. func (m *LabelTaggingMutation) SetID(id uint64) {
  15363. m.id = &id
  15364. }
  15365. // ID returns the ID value in the mutation. Note that the ID is only available
  15366. // if it was provided to the builder or after it was returned from the database.
  15367. func (m *LabelTaggingMutation) ID() (id uint64, exists bool) {
  15368. if m.id == nil {
  15369. return
  15370. }
  15371. return *m.id, true
  15372. }
  15373. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  15374. // That means, if the mutation is applied within a transaction with an isolation level such
  15375. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  15376. // or updated by the mutation.
  15377. func (m *LabelTaggingMutation) IDs(ctx context.Context) ([]uint64, error) {
  15378. switch {
  15379. case m.op.Is(OpUpdateOne | OpDeleteOne):
  15380. id, exists := m.ID()
  15381. if exists {
  15382. return []uint64{id}, nil
  15383. }
  15384. fallthrough
  15385. case m.op.Is(OpUpdate | OpDelete):
  15386. return m.Client().LabelTagging.Query().Where(m.predicates...).IDs(ctx)
  15387. default:
  15388. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  15389. }
  15390. }
  15391. // SetCreatedAt sets the "created_at" field.
  15392. func (m *LabelTaggingMutation) SetCreatedAt(t time.Time) {
  15393. m.created_at = &t
  15394. }
  15395. // CreatedAt returns the value of the "created_at" field in the mutation.
  15396. func (m *LabelTaggingMutation) CreatedAt() (r time.Time, exists bool) {
  15397. v := m.created_at
  15398. if v == nil {
  15399. return
  15400. }
  15401. return *v, true
  15402. }
  15403. // OldCreatedAt returns the old "created_at" field's value of the LabelTagging entity.
  15404. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15406. func (m *LabelTaggingMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  15407. if !m.op.Is(OpUpdateOne) {
  15408. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  15409. }
  15410. if m.id == nil || m.oldValue == nil {
  15411. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  15412. }
  15413. oldValue, err := m.oldValue(ctx)
  15414. if err != nil {
  15415. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  15416. }
  15417. return oldValue.CreatedAt, nil
  15418. }
  15419. // ResetCreatedAt resets all changes to the "created_at" field.
  15420. func (m *LabelTaggingMutation) ResetCreatedAt() {
  15421. m.created_at = nil
  15422. }
  15423. // SetUpdatedAt sets the "updated_at" field.
  15424. func (m *LabelTaggingMutation) SetUpdatedAt(t time.Time) {
  15425. m.updated_at = &t
  15426. }
  15427. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  15428. func (m *LabelTaggingMutation) UpdatedAt() (r time.Time, exists bool) {
  15429. v := m.updated_at
  15430. if v == nil {
  15431. return
  15432. }
  15433. return *v, true
  15434. }
  15435. // OldUpdatedAt returns the old "updated_at" field's value of the LabelTagging entity.
  15436. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15437. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15438. func (m *LabelTaggingMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  15439. if !m.op.Is(OpUpdateOne) {
  15440. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  15441. }
  15442. if m.id == nil || m.oldValue == nil {
  15443. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  15444. }
  15445. oldValue, err := m.oldValue(ctx)
  15446. if err != nil {
  15447. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  15448. }
  15449. return oldValue.UpdatedAt, nil
  15450. }
  15451. // ResetUpdatedAt resets all changes to the "updated_at" field.
  15452. func (m *LabelTaggingMutation) ResetUpdatedAt() {
  15453. m.updated_at = nil
  15454. }
  15455. // SetStatus sets the "status" field.
  15456. func (m *LabelTaggingMutation) SetStatus(u uint8) {
  15457. m.status = &u
  15458. m.addstatus = nil
  15459. }
  15460. // Status returns the value of the "status" field in the mutation.
  15461. func (m *LabelTaggingMutation) Status() (r uint8, exists bool) {
  15462. v := m.status
  15463. if v == nil {
  15464. return
  15465. }
  15466. return *v, true
  15467. }
  15468. // OldStatus returns the old "status" field's value of the LabelTagging entity.
  15469. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15470. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15471. func (m *LabelTaggingMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  15472. if !m.op.Is(OpUpdateOne) {
  15473. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  15474. }
  15475. if m.id == nil || m.oldValue == nil {
  15476. return v, errors.New("OldStatus requires an ID field in the mutation")
  15477. }
  15478. oldValue, err := m.oldValue(ctx)
  15479. if err != nil {
  15480. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  15481. }
  15482. return oldValue.Status, nil
  15483. }
  15484. // AddStatus adds u to the "status" field.
  15485. func (m *LabelTaggingMutation) AddStatus(u int8) {
  15486. if m.addstatus != nil {
  15487. *m.addstatus += u
  15488. } else {
  15489. m.addstatus = &u
  15490. }
  15491. }
  15492. // AddedStatus returns the value that was added to the "status" field in this mutation.
  15493. func (m *LabelTaggingMutation) AddedStatus() (r int8, exists bool) {
  15494. v := m.addstatus
  15495. if v == nil {
  15496. return
  15497. }
  15498. return *v, true
  15499. }
  15500. // ClearStatus clears the value of the "status" field.
  15501. func (m *LabelTaggingMutation) ClearStatus() {
  15502. m.status = nil
  15503. m.addstatus = nil
  15504. m.clearedFields[labeltagging.FieldStatus] = struct{}{}
  15505. }
  15506. // StatusCleared returns if the "status" field was cleared in this mutation.
  15507. func (m *LabelTaggingMutation) StatusCleared() bool {
  15508. _, ok := m.clearedFields[labeltagging.FieldStatus]
  15509. return ok
  15510. }
  15511. // ResetStatus resets all changes to the "status" field.
  15512. func (m *LabelTaggingMutation) ResetStatus() {
  15513. m.status = nil
  15514. m.addstatus = nil
  15515. delete(m.clearedFields, labeltagging.FieldStatus)
  15516. }
  15517. // SetDeletedAt sets the "deleted_at" field.
  15518. func (m *LabelTaggingMutation) SetDeletedAt(t time.Time) {
  15519. m.deleted_at = &t
  15520. }
  15521. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  15522. func (m *LabelTaggingMutation) DeletedAt() (r time.Time, exists bool) {
  15523. v := m.deleted_at
  15524. if v == nil {
  15525. return
  15526. }
  15527. return *v, true
  15528. }
  15529. // OldDeletedAt returns the old "deleted_at" field's value of the LabelTagging entity.
  15530. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15531. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15532. func (m *LabelTaggingMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  15533. if !m.op.Is(OpUpdateOne) {
  15534. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  15535. }
  15536. if m.id == nil || m.oldValue == nil {
  15537. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  15538. }
  15539. oldValue, err := m.oldValue(ctx)
  15540. if err != nil {
  15541. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  15542. }
  15543. return oldValue.DeletedAt, nil
  15544. }
  15545. // ClearDeletedAt clears the value of the "deleted_at" field.
  15546. func (m *LabelTaggingMutation) ClearDeletedAt() {
  15547. m.deleted_at = nil
  15548. m.clearedFields[labeltagging.FieldDeletedAt] = struct{}{}
  15549. }
  15550. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  15551. func (m *LabelTaggingMutation) DeletedAtCleared() bool {
  15552. _, ok := m.clearedFields[labeltagging.FieldDeletedAt]
  15553. return ok
  15554. }
  15555. // ResetDeletedAt resets all changes to the "deleted_at" field.
  15556. func (m *LabelTaggingMutation) ResetDeletedAt() {
  15557. m.deleted_at = nil
  15558. delete(m.clearedFields, labeltagging.FieldDeletedAt)
  15559. }
  15560. // SetOrganizationID sets the "organization_id" field.
  15561. func (m *LabelTaggingMutation) SetOrganizationID(u uint64) {
  15562. m.organization_id = &u
  15563. m.addorganization_id = nil
  15564. }
  15565. // OrganizationID returns the value of the "organization_id" field in the mutation.
  15566. func (m *LabelTaggingMutation) OrganizationID() (r uint64, exists bool) {
  15567. v := m.organization_id
  15568. if v == nil {
  15569. return
  15570. }
  15571. return *v, true
  15572. }
  15573. // OldOrganizationID returns the old "organization_id" field's value of the LabelTagging entity.
  15574. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15575. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15576. func (m *LabelTaggingMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  15577. if !m.op.Is(OpUpdateOne) {
  15578. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  15579. }
  15580. if m.id == nil || m.oldValue == nil {
  15581. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  15582. }
  15583. oldValue, err := m.oldValue(ctx)
  15584. if err != nil {
  15585. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  15586. }
  15587. return oldValue.OrganizationID, nil
  15588. }
  15589. // AddOrganizationID adds u to the "organization_id" field.
  15590. func (m *LabelTaggingMutation) AddOrganizationID(u int64) {
  15591. if m.addorganization_id != nil {
  15592. *m.addorganization_id += u
  15593. } else {
  15594. m.addorganization_id = &u
  15595. }
  15596. }
  15597. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  15598. func (m *LabelTaggingMutation) AddedOrganizationID() (r int64, exists bool) {
  15599. v := m.addorganization_id
  15600. if v == nil {
  15601. return
  15602. }
  15603. return *v, true
  15604. }
  15605. // ResetOrganizationID resets all changes to the "organization_id" field.
  15606. func (m *LabelTaggingMutation) ResetOrganizationID() {
  15607. m.organization_id = nil
  15608. m.addorganization_id = nil
  15609. }
  15610. // SetType sets the "type" field.
  15611. func (m *LabelTaggingMutation) SetType(i int) {
  15612. m._type = &i
  15613. m.add_type = nil
  15614. }
  15615. // GetType returns the value of the "type" field in the mutation.
  15616. func (m *LabelTaggingMutation) GetType() (r int, exists bool) {
  15617. v := m._type
  15618. if v == nil {
  15619. return
  15620. }
  15621. return *v, true
  15622. }
  15623. // OldType returns the old "type" field's value of the LabelTagging entity.
  15624. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15625. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15626. func (m *LabelTaggingMutation) OldType(ctx context.Context) (v int, err error) {
  15627. if !m.op.Is(OpUpdateOne) {
  15628. return v, errors.New("OldType is only allowed on UpdateOne operations")
  15629. }
  15630. if m.id == nil || m.oldValue == nil {
  15631. return v, errors.New("OldType requires an ID field in the mutation")
  15632. }
  15633. oldValue, err := m.oldValue(ctx)
  15634. if err != nil {
  15635. return v, fmt.Errorf("querying old value for OldType: %w", err)
  15636. }
  15637. return oldValue.Type, nil
  15638. }
  15639. // AddType adds i to the "type" field.
  15640. func (m *LabelTaggingMutation) AddType(i int) {
  15641. if m.add_type != nil {
  15642. *m.add_type += i
  15643. } else {
  15644. m.add_type = &i
  15645. }
  15646. }
  15647. // AddedType returns the value that was added to the "type" field in this mutation.
  15648. func (m *LabelTaggingMutation) AddedType() (r int, exists bool) {
  15649. v := m.add_type
  15650. if v == nil {
  15651. return
  15652. }
  15653. return *v, true
  15654. }
  15655. // ResetType resets all changes to the "type" field.
  15656. func (m *LabelTaggingMutation) ResetType() {
  15657. m._type = nil
  15658. m.add_type = nil
  15659. }
  15660. // SetConditions sets the "conditions" field.
  15661. func (m *LabelTaggingMutation) SetConditions(s string) {
  15662. m.conditions = &s
  15663. }
  15664. // Conditions returns the value of the "conditions" field in the mutation.
  15665. func (m *LabelTaggingMutation) Conditions() (r string, exists bool) {
  15666. v := m.conditions
  15667. if v == nil {
  15668. return
  15669. }
  15670. return *v, true
  15671. }
  15672. // OldConditions returns the old "conditions" field's value of the LabelTagging entity.
  15673. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15674. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15675. func (m *LabelTaggingMutation) OldConditions(ctx context.Context) (v string, err error) {
  15676. if !m.op.Is(OpUpdateOne) {
  15677. return v, errors.New("OldConditions is only allowed on UpdateOne operations")
  15678. }
  15679. if m.id == nil || m.oldValue == nil {
  15680. return v, errors.New("OldConditions requires an ID field in the mutation")
  15681. }
  15682. oldValue, err := m.oldValue(ctx)
  15683. if err != nil {
  15684. return v, fmt.Errorf("querying old value for OldConditions: %w", err)
  15685. }
  15686. return oldValue.Conditions, nil
  15687. }
  15688. // ResetConditions resets all changes to the "conditions" field.
  15689. func (m *LabelTaggingMutation) ResetConditions() {
  15690. m.conditions = nil
  15691. }
  15692. // SetActionLabelAdd sets the "action_label_add" field.
  15693. func (m *LabelTaggingMutation) SetActionLabelAdd(u []uint64) {
  15694. m.action_label_add = &u
  15695. m.appendaction_label_add = nil
  15696. }
  15697. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  15698. func (m *LabelTaggingMutation) ActionLabelAdd() (r []uint64, exists bool) {
  15699. v := m.action_label_add
  15700. if v == nil {
  15701. return
  15702. }
  15703. return *v, true
  15704. }
  15705. // OldActionLabelAdd returns the old "action_label_add" field's value of the LabelTagging entity.
  15706. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15707. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15708. func (m *LabelTaggingMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  15709. if !m.op.Is(OpUpdateOne) {
  15710. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  15711. }
  15712. if m.id == nil || m.oldValue == nil {
  15713. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  15714. }
  15715. oldValue, err := m.oldValue(ctx)
  15716. if err != nil {
  15717. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  15718. }
  15719. return oldValue.ActionLabelAdd, nil
  15720. }
  15721. // AppendActionLabelAdd adds u to the "action_label_add" field.
  15722. func (m *LabelTaggingMutation) AppendActionLabelAdd(u []uint64) {
  15723. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  15724. }
  15725. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  15726. func (m *LabelTaggingMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  15727. if len(m.appendaction_label_add) == 0 {
  15728. return nil, false
  15729. }
  15730. return m.appendaction_label_add, true
  15731. }
  15732. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  15733. func (m *LabelTaggingMutation) ClearActionLabelAdd() {
  15734. m.action_label_add = nil
  15735. m.appendaction_label_add = nil
  15736. m.clearedFields[labeltagging.FieldActionLabelAdd] = struct{}{}
  15737. }
  15738. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  15739. func (m *LabelTaggingMutation) ActionLabelAddCleared() bool {
  15740. _, ok := m.clearedFields[labeltagging.FieldActionLabelAdd]
  15741. return ok
  15742. }
  15743. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  15744. func (m *LabelTaggingMutation) ResetActionLabelAdd() {
  15745. m.action_label_add = nil
  15746. m.appendaction_label_add = nil
  15747. delete(m.clearedFields, labeltagging.FieldActionLabelAdd)
  15748. }
  15749. // SetActionLabelDel sets the "action_label_del" field.
  15750. func (m *LabelTaggingMutation) SetActionLabelDel(u []uint64) {
  15751. m.action_label_del = &u
  15752. m.appendaction_label_del = nil
  15753. }
  15754. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  15755. func (m *LabelTaggingMutation) ActionLabelDel() (r []uint64, exists bool) {
  15756. v := m.action_label_del
  15757. if v == nil {
  15758. return
  15759. }
  15760. return *v, true
  15761. }
  15762. // OldActionLabelDel returns the old "action_label_del" field's value of the LabelTagging entity.
  15763. // If the LabelTagging object wasn't provided to the builder, the object is fetched from the database.
  15764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  15765. func (m *LabelTaggingMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  15766. if !m.op.Is(OpUpdateOne) {
  15767. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  15768. }
  15769. if m.id == nil || m.oldValue == nil {
  15770. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  15771. }
  15772. oldValue, err := m.oldValue(ctx)
  15773. if err != nil {
  15774. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  15775. }
  15776. return oldValue.ActionLabelDel, nil
  15777. }
  15778. // AppendActionLabelDel adds u to the "action_label_del" field.
  15779. func (m *LabelTaggingMutation) AppendActionLabelDel(u []uint64) {
  15780. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  15781. }
  15782. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  15783. func (m *LabelTaggingMutation) AppendedActionLabelDel() ([]uint64, bool) {
  15784. if len(m.appendaction_label_del) == 0 {
  15785. return nil, false
  15786. }
  15787. return m.appendaction_label_del, true
  15788. }
  15789. // ClearActionLabelDel clears the value of the "action_label_del" field.
  15790. func (m *LabelTaggingMutation) ClearActionLabelDel() {
  15791. m.action_label_del = nil
  15792. m.appendaction_label_del = nil
  15793. m.clearedFields[labeltagging.FieldActionLabelDel] = struct{}{}
  15794. }
  15795. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  15796. func (m *LabelTaggingMutation) ActionLabelDelCleared() bool {
  15797. _, ok := m.clearedFields[labeltagging.FieldActionLabelDel]
  15798. return ok
  15799. }
  15800. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  15801. func (m *LabelTaggingMutation) ResetActionLabelDel() {
  15802. m.action_label_del = nil
  15803. m.appendaction_label_del = nil
  15804. delete(m.clearedFields, labeltagging.FieldActionLabelDel)
  15805. }
  15806. // Where appends a list predicates to the LabelTaggingMutation builder.
  15807. func (m *LabelTaggingMutation) Where(ps ...predicate.LabelTagging) {
  15808. m.predicates = append(m.predicates, ps...)
  15809. }
  15810. // WhereP appends storage-level predicates to the LabelTaggingMutation builder. Using this method,
  15811. // users can use type-assertion to append predicates that do not depend on any generated package.
  15812. func (m *LabelTaggingMutation) WhereP(ps ...func(*sql.Selector)) {
  15813. p := make([]predicate.LabelTagging, len(ps))
  15814. for i := range ps {
  15815. p[i] = ps[i]
  15816. }
  15817. m.Where(p...)
  15818. }
  15819. // Op returns the operation name.
  15820. func (m *LabelTaggingMutation) Op() Op {
  15821. return m.op
  15822. }
  15823. // SetOp allows setting the mutation operation.
  15824. func (m *LabelTaggingMutation) SetOp(op Op) {
  15825. m.op = op
  15826. }
  15827. // Type returns the node type of this mutation (LabelTagging).
  15828. func (m *LabelTaggingMutation) Type() string {
  15829. return m.typ
  15830. }
  15831. // Fields returns all fields that were changed during this mutation. Note that in
  15832. // order to get all numeric fields that were incremented/decremented, call
  15833. // AddedFields().
  15834. func (m *LabelTaggingMutation) Fields() []string {
  15835. fields := make([]string, 0, 9)
  15836. if m.created_at != nil {
  15837. fields = append(fields, labeltagging.FieldCreatedAt)
  15838. }
  15839. if m.updated_at != nil {
  15840. fields = append(fields, labeltagging.FieldUpdatedAt)
  15841. }
  15842. if m.status != nil {
  15843. fields = append(fields, labeltagging.FieldStatus)
  15844. }
  15845. if m.deleted_at != nil {
  15846. fields = append(fields, labeltagging.FieldDeletedAt)
  15847. }
  15848. if m.organization_id != nil {
  15849. fields = append(fields, labeltagging.FieldOrganizationID)
  15850. }
  15851. if m._type != nil {
  15852. fields = append(fields, labeltagging.FieldType)
  15853. }
  15854. if m.conditions != nil {
  15855. fields = append(fields, labeltagging.FieldConditions)
  15856. }
  15857. if m.action_label_add != nil {
  15858. fields = append(fields, labeltagging.FieldActionLabelAdd)
  15859. }
  15860. if m.action_label_del != nil {
  15861. fields = append(fields, labeltagging.FieldActionLabelDel)
  15862. }
  15863. return fields
  15864. }
  15865. // Field returns the value of a field with the given name. The second boolean
  15866. // return value indicates that this field was not set, or was not defined in the
  15867. // schema.
  15868. func (m *LabelTaggingMutation) Field(name string) (ent.Value, bool) {
  15869. switch name {
  15870. case labeltagging.FieldCreatedAt:
  15871. return m.CreatedAt()
  15872. case labeltagging.FieldUpdatedAt:
  15873. return m.UpdatedAt()
  15874. case labeltagging.FieldStatus:
  15875. return m.Status()
  15876. case labeltagging.FieldDeletedAt:
  15877. return m.DeletedAt()
  15878. case labeltagging.FieldOrganizationID:
  15879. return m.OrganizationID()
  15880. case labeltagging.FieldType:
  15881. return m.GetType()
  15882. case labeltagging.FieldConditions:
  15883. return m.Conditions()
  15884. case labeltagging.FieldActionLabelAdd:
  15885. return m.ActionLabelAdd()
  15886. case labeltagging.FieldActionLabelDel:
  15887. return m.ActionLabelDel()
  15888. }
  15889. return nil, false
  15890. }
  15891. // OldField returns the old value of the field from the database. An error is
  15892. // returned if the mutation operation is not UpdateOne, or the query to the
  15893. // database failed.
  15894. func (m *LabelTaggingMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  15895. switch name {
  15896. case labeltagging.FieldCreatedAt:
  15897. return m.OldCreatedAt(ctx)
  15898. case labeltagging.FieldUpdatedAt:
  15899. return m.OldUpdatedAt(ctx)
  15900. case labeltagging.FieldStatus:
  15901. return m.OldStatus(ctx)
  15902. case labeltagging.FieldDeletedAt:
  15903. return m.OldDeletedAt(ctx)
  15904. case labeltagging.FieldOrganizationID:
  15905. return m.OldOrganizationID(ctx)
  15906. case labeltagging.FieldType:
  15907. return m.OldType(ctx)
  15908. case labeltagging.FieldConditions:
  15909. return m.OldConditions(ctx)
  15910. case labeltagging.FieldActionLabelAdd:
  15911. return m.OldActionLabelAdd(ctx)
  15912. case labeltagging.FieldActionLabelDel:
  15913. return m.OldActionLabelDel(ctx)
  15914. }
  15915. return nil, fmt.Errorf("unknown LabelTagging field %s", name)
  15916. }
  15917. // SetField sets the value of a field with the given name. It returns an error if
  15918. // the field is not defined in the schema, or if the type mismatched the field
  15919. // type.
  15920. func (m *LabelTaggingMutation) SetField(name string, value ent.Value) error {
  15921. switch name {
  15922. case labeltagging.FieldCreatedAt:
  15923. v, ok := value.(time.Time)
  15924. if !ok {
  15925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15926. }
  15927. m.SetCreatedAt(v)
  15928. return nil
  15929. case labeltagging.FieldUpdatedAt:
  15930. v, ok := value.(time.Time)
  15931. if !ok {
  15932. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15933. }
  15934. m.SetUpdatedAt(v)
  15935. return nil
  15936. case labeltagging.FieldStatus:
  15937. v, ok := value.(uint8)
  15938. if !ok {
  15939. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15940. }
  15941. m.SetStatus(v)
  15942. return nil
  15943. case labeltagging.FieldDeletedAt:
  15944. v, ok := value.(time.Time)
  15945. if !ok {
  15946. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15947. }
  15948. m.SetDeletedAt(v)
  15949. return nil
  15950. case labeltagging.FieldOrganizationID:
  15951. v, ok := value.(uint64)
  15952. if !ok {
  15953. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15954. }
  15955. m.SetOrganizationID(v)
  15956. return nil
  15957. case labeltagging.FieldType:
  15958. v, ok := value.(int)
  15959. if !ok {
  15960. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15961. }
  15962. m.SetType(v)
  15963. return nil
  15964. case labeltagging.FieldConditions:
  15965. v, ok := value.(string)
  15966. if !ok {
  15967. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15968. }
  15969. m.SetConditions(v)
  15970. return nil
  15971. case labeltagging.FieldActionLabelAdd:
  15972. v, ok := value.([]uint64)
  15973. if !ok {
  15974. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15975. }
  15976. m.SetActionLabelAdd(v)
  15977. return nil
  15978. case labeltagging.FieldActionLabelDel:
  15979. v, ok := value.([]uint64)
  15980. if !ok {
  15981. return fmt.Errorf("unexpected type %T for field %s", value, name)
  15982. }
  15983. m.SetActionLabelDel(v)
  15984. return nil
  15985. }
  15986. return fmt.Errorf("unknown LabelTagging field %s", name)
  15987. }
  15988. // AddedFields returns all numeric fields that were incremented/decremented during
  15989. // this mutation.
  15990. func (m *LabelTaggingMutation) AddedFields() []string {
  15991. var fields []string
  15992. if m.addstatus != nil {
  15993. fields = append(fields, labeltagging.FieldStatus)
  15994. }
  15995. if m.addorganization_id != nil {
  15996. fields = append(fields, labeltagging.FieldOrganizationID)
  15997. }
  15998. if m.add_type != nil {
  15999. fields = append(fields, labeltagging.FieldType)
  16000. }
  16001. return fields
  16002. }
  16003. // AddedField returns the numeric value that was incremented/decremented on a field
  16004. // with the given name. The second boolean return value indicates that this field
  16005. // was not set, or was not defined in the schema.
  16006. func (m *LabelTaggingMutation) AddedField(name string) (ent.Value, bool) {
  16007. switch name {
  16008. case labeltagging.FieldStatus:
  16009. return m.AddedStatus()
  16010. case labeltagging.FieldOrganizationID:
  16011. return m.AddedOrganizationID()
  16012. case labeltagging.FieldType:
  16013. return m.AddedType()
  16014. }
  16015. return nil, false
  16016. }
  16017. // AddField adds the value to the field with the given name. It returns an error if
  16018. // the field is not defined in the schema, or if the type mismatched the field
  16019. // type.
  16020. func (m *LabelTaggingMutation) AddField(name string, value ent.Value) error {
  16021. switch name {
  16022. case labeltagging.FieldStatus:
  16023. v, ok := value.(int8)
  16024. if !ok {
  16025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16026. }
  16027. m.AddStatus(v)
  16028. return nil
  16029. case labeltagging.FieldOrganizationID:
  16030. v, ok := value.(int64)
  16031. if !ok {
  16032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16033. }
  16034. m.AddOrganizationID(v)
  16035. return nil
  16036. case labeltagging.FieldType:
  16037. v, ok := value.(int)
  16038. if !ok {
  16039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16040. }
  16041. m.AddType(v)
  16042. return nil
  16043. }
  16044. return fmt.Errorf("unknown LabelTagging numeric field %s", name)
  16045. }
  16046. // ClearedFields returns all nullable fields that were cleared during this
  16047. // mutation.
  16048. func (m *LabelTaggingMutation) ClearedFields() []string {
  16049. var fields []string
  16050. if m.FieldCleared(labeltagging.FieldStatus) {
  16051. fields = append(fields, labeltagging.FieldStatus)
  16052. }
  16053. if m.FieldCleared(labeltagging.FieldDeletedAt) {
  16054. fields = append(fields, labeltagging.FieldDeletedAt)
  16055. }
  16056. if m.FieldCleared(labeltagging.FieldActionLabelAdd) {
  16057. fields = append(fields, labeltagging.FieldActionLabelAdd)
  16058. }
  16059. if m.FieldCleared(labeltagging.FieldActionLabelDel) {
  16060. fields = append(fields, labeltagging.FieldActionLabelDel)
  16061. }
  16062. return fields
  16063. }
  16064. // FieldCleared returns a boolean indicating if a field with the given name was
  16065. // cleared in this mutation.
  16066. func (m *LabelTaggingMutation) FieldCleared(name string) bool {
  16067. _, ok := m.clearedFields[name]
  16068. return ok
  16069. }
  16070. // ClearField clears the value of the field with the given name. It returns an
  16071. // error if the field is not defined in the schema.
  16072. func (m *LabelTaggingMutation) ClearField(name string) error {
  16073. switch name {
  16074. case labeltagging.FieldStatus:
  16075. m.ClearStatus()
  16076. return nil
  16077. case labeltagging.FieldDeletedAt:
  16078. m.ClearDeletedAt()
  16079. return nil
  16080. case labeltagging.FieldActionLabelAdd:
  16081. m.ClearActionLabelAdd()
  16082. return nil
  16083. case labeltagging.FieldActionLabelDel:
  16084. m.ClearActionLabelDel()
  16085. return nil
  16086. }
  16087. return fmt.Errorf("unknown LabelTagging nullable field %s", name)
  16088. }
  16089. // ResetField resets all changes in the mutation for the field with the given name.
  16090. // It returns an error if the field is not defined in the schema.
  16091. func (m *LabelTaggingMutation) ResetField(name string) error {
  16092. switch name {
  16093. case labeltagging.FieldCreatedAt:
  16094. m.ResetCreatedAt()
  16095. return nil
  16096. case labeltagging.FieldUpdatedAt:
  16097. m.ResetUpdatedAt()
  16098. return nil
  16099. case labeltagging.FieldStatus:
  16100. m.ResetStatus()
  16101. return nil
  16102. case labeltagging.FieldDeletedAt:
  16103. m.ResetDeletedAt()
  16104. return nil
  16105. case labeltagging.FieldOrganizationID:
  16106. m.ResetOrganizationID()
  16107. return nil
  16108. case labeltagging.FieldType:
  16109. m.ResetType()
  16110. return nil
  16111. case labeltagging.FieldConditions:
  16112. m.ResetConditions()
  16113. return nil
  16114. case labeltagging.FieldActionLabelAdd:
  16115. m.ResetActionLabelAdd()
  16116. return nil
  16117. case labeltagging.FieldActionLabelDel:
  16118. m.ResetActionLabelDel()
  16119. return nil
  16120. }
  16121. return fmt.Errorf("unknown LabelTagging field %s", name)
  16122. }
  16123. // AddedEdges returns all edge names that were set/added in this mutation.
  16124. func (m *LabelTaggingMutation) AddedEdges() []string {
  16125. edges := make([]string, 0, 0)
  16126. return edges
  16127. }
  16128. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16129. // name in this mutation.
  16130. func (m *LabelTaggingMutation) AddedIDs(name string) []ent.Value {
  16131. return nil
  16132. }
  16133. // RemovedEdges returns all edge names that were removed in this mutation.
  16134. func (m *LabelTaggingMutation) RemovedEdges() []string {
  16135. edges := make([]string, 0, 0)
  16136. return edges
  16137. }
  16138. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16139. // the given name in this mutation.
  16140. func (m *LabelTaggingMutation) RemovedIDs(name string) []ent.Value {
  16141. return nil
  16142. }
  16143. // ClearedEdges returns all edge names that were cleared in this mutation.
  16144. func (m *LabelTaggingMutation) ClearedEdges() []string {
  16145. edges := make([]string, 0, 0)
  16146. return edges
  16147. }
  16148. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16149. // was cleared in this mutation.
  16150. func (m *LabelTaggingMutation) EdgeCleared(name string) bool {
  16151. return false
  16152. }
  16153. // ClearEdge clears the value of the edge with the given name. It returns an error
  16154. // if that edge is not defined in the schema.
  16155. func (m *LabelTaggingMutation) ClearEdge(name string) error {
  16156. return fmt.Errorf("unknown LabelTagging unique edge %s", name)
  16157. }
  16158. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16159. // It returns an error if the edge is not defined in the schema.
  16160. func (m *LabelTaggingMutation) ResetEdge(name string) error {
  16161. return fmt.Errorf("unknown LabelTagging edge %s", name)
  16162. }
  16163. // MessageMutation represents an operation that mutates the Message nodes in the graph.
  16164. type MessageMutation struct {
  16165. config
  16166. op Op
  16167. typ string
  16168. id *int
  16169. wx_wxid *string
  16170. wxid *string
  16171. content *string
  16172. clearedFields map[string]struct{}
  16173. done bool
  16174. oldValue func(context.Context) (*Message, error)
  16175. predicates []predicate.Message
  16176. }
  16177. var _ ent.Mutation = (*MessageMutation)(nil)
  16178. // messageOption allows management of the mutation configuration using functional options.
  16179. type messageOption func(*MessageMutation)
  16180. // newMessageMutation creates new mutation for the Message entity.
  16181. func newMessageMutation(c config, op Op, opts ...messageOption) *MessageMutation {
  16182. m := &MessageMutation{
  16183. config: c,
  16184. op: op,
  16185. typ: TypeMessage,
  16186. clearedFields: make(map[string]struct{}),
  16187. }
  16188. for _, opt := range opts {
  16189. opt(m)
  16190. }
  16191. return m
  16192. }
  16193. // withMessageID sets the ID field of the mutation.
  16194. func withMessageID(id int) messageOption {
  16195. return func(m *MessageMutation) {
  16196. var (
  16197. err error
  16198. once sync.Once
  16199. value *Message
  16200. )
  16201. m.oldValue = func(ctx context.Context) (*Message, error) {
  16202. once.Do(func() {
  16203. if m.done {
  16204. err = errors.New("querying old values post mutation is not allowed")
  16205. } else {
  16206. value, err = m.Client().Message.Get(ctx, id)
  16207. }
  16208. })
  16209. return value, err
  16210. }
  16211. m.id = &id
  16212. }
  16213. }
  16214. // withMessage sets the old Message of the mutation.
  16215. func withMessage(node *Message) messageOption {
  16216. return func(m *MessageMutation) {
  16217. m.oldValue = func(context.Context) (*Message, error) {
  16218. return node, nil
  16219. }
  16220. m.id = &node.ID
  16221. }
  16222. }
  16223. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16224. // executed in a transaction (ent.Tx), a transactional client is returned.
  16225. func (m MessageMutation) Client() *Client {
  16226. client := &Client{config: m.config}
  16227. client.init()
  16228. return client
  16229. }
  16230. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16231. // it returns an error otherwise.
  16232. func (m MessageMutation) Tx() (*Tx, error) {
  16233. if _, ok := m.driver.(*txDriver); !ok {
  16234. return nil, errors.New("ent: mutation is not running in a transaction")
  16235. }
  16236. tx := &Tx{config: m.config}
  16237. tx.init()
  16238. return tx, nil
  16239. }
  16240. // ID returns the ID value in the mutation. Note that the ID is only available
  16241. // if it was provided to the builder or after it was returned from the database.
  16242. func (m *MessageMutation) ID() (id int, exists bool) {
  16243. if m.id == nil {
  16244. return
  16245. }
  16246. return *m.id, true
  16247. }
  16248. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16249. // That means, if the mutation is applied within a transaction with an isolation level such
  16250. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16251. // or updated by the mutation.
  16252. func (m *MessageMutation) IDs(ctx context.Context) ([]int, error) {
  16253. switch {
  16254. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16255. id, exists := m.ID()
  16256. if exists {
  16257. return []int{id}, nil
  16258. }
  16259. fallthrough
  16260. case m.op.Is(OpUpdate | OpDelete):
  16261. return m.Client().Message.Query().Where(m.predicates...).IDs(ctx)
  16262. default:
  16263. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16264. }
  16265. }
  16266. // SetWxWxid sets the "wx_wxid" field.
  16267. func (m *MessageMutation) SetWxWxid(s string) {
  16268. m.wx_wxid = &s
  16269. }
  16270. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  16271. func (m *MessageMutation) WxWxid() (r string, exists bool) {
  16272. v := m.wx_wxid
  16273. if v == nil {
  16274. return
  16275. }
  16276. return *v, true
  16277. }
  16278. // OldWxWxid returns the old "wx_wxid" field's value of the Message entity.
  16279. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16280. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16281. func (m *MessageMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  16282. if !m.op.Is(OpUpdateOne) {
  16283. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  16284. }
  16285. if m.id == nil || m.oldValue == nil {
  16286. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  16287. }
  16288. oldValue, err := m.oldValue(ctx)
  16289. if err != nil {
  16290. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  16291. }
  16292. return oldValue.WxWxid, nil
  16293. }
  16294. // ClearWxWxid clears the value of the "wx_wxid" field.
  16295. func (m *MessageMutation) ClearWxWxid() {
  16296. m.wx_wxid = nil
  16297. m.clearedFields[message.FieldWxWxid] = struct{}{}
  16298. }
  16299. // WxWxidCleared returns if the "wx_wxid" field was cleared in this mutation.
  16300. func (m *MessageMutation) WxWxidCleared() bool {
  16301. _, ok := m.clearedFields[message.FieldWxWxid]
  16302. return ok
  16303. }
  16304. // ResetWxWxid resets all changes to the "wx_wxid" field.
  16305. func (m *MessageMutation) ResetWxWxid() {
  16306. m.wx_wxid = nil
  16307. delete(m.clearedFields, message.FieldWxWxid)
  16308. }
  16309. // SetWxid sets the "wxid" field.
  16310. func (m *MessageMutation) SetWxid(s string) {
  16311. m.wxid = &s
  16312. }
  16313. // Wxid returns the value of the "wxid" field in the mutation.
  16314. func (m *MessageMutation) Wxid() (r string, exists bool) {
  16315. v := m.wxid
  16316. if v == nil {
  16317. return
  16318. }
  16319. return *v, true
  16320. }
  16321. // OldWxid returns the old "wxid" field's value of the Message entity.
  16322. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16323. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16324. func (m *MessageMutation) OldWxid(ctx context.Context) (v string, err error) {
  16325. if !m.op.Is(OpUpdateOne) {
  16326. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  16327. }
  16328. if m.id == nil || m.oldValue == nil {
  16329. return v, errors.New("OldWxid requires an ID field in the mutation")
  16330. }
  16331. oldValue, err := m.oldValue(ctx)
  16332. if err != nil {
  16333. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  16334. }
  16335. return oldValue.Wxid, nil
  16336. }
  16337. // ResetWxid resets all changes to the "wxid" field.
  16338. func (m *MessageMutation) ResetWxid() {
  16339. m.wxid = nil
  16340. }
  16341. // SetContent sets the "content" field.
  16342. func (m *MessageMutation) SetContent(s string) {
  16343. m.content = &s
  16344. }
  16345. // Content returns the value of the "content" field in the mutation.
  16346. func (m *MessageMutation) Content() (r string, exists bool) {
  16347. v := m.content
  16348. if v == nil {
  16349. return
  16350. }
  16351. return *v, true
  16352. }
  16353. // OldContent returns the old "content" field's value of the Message entity.
  16354. // If the Message object wasn't provided to the builder, the object is fetched from the database.
  16355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16356. func (m *MessageMutation) OldContent(ctx context.Context) (v string, err error) {
  16357. if !m.op.Is(OpUpdateOne) {
  16358. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  16359. }
  16360. if m.id == nil || m.oldValue == nil {
  16361. return v, errors.New("OldContent requires an ID field in the mutation")
  16362. }
  16363. oldValue, err := m.oldValue(ctx)
  16364. if err != nil {
  16365. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  16366. }
  16367. return oldValue.Content, nil
  16368. }
  16369. // ResetContent resets all changes to the "content" field.
  16370. func (m *MessageMutation) ResetContent() {
  16371. m.content = nil
  16372. }
  16373. // Where appends a list predicates to the MessageMutation builder.
  16374. func (m *MessageMutation) Where(ps ...predicate.Message) {
  16375. m.predicates = append(m.predicates, ps...)
  16376. }
  16377. // WhereP appends storage-level predicates to the MessageMutation builder. Using this method,
  16378. // users can use type-assertion to append predicates that do not depend on any generated package.
  16379. func (m *MessageMutation) WhereP(ps ...func(*sql.Selector)) {
  16380. p := make([]predicate.Message, len(ps))
  16381. for i := range ps {
  16382. p[i] = ps[i]
  16383. }
  16384. m.Where(p...)
  16385. }
  16386. // Op returns the operation name.
  16387. func (m *MessageMutation) Op() Op {
  16388. return m.op
  16389. }
  16390. // SetOp allows setting the mutation operation.
  16391. func (m *MessageMutation) SetOp(op Op) {
  16392. m.op = op
  16393. }
  16394. // Type returns the node type of this mutation (Message).
  16395. func (m *MessageMutation) Type() string {
  16396. return m.typ
  16397. }
  16398. // Fields returns all fields that were changed during this mutation. Note that in
  16399. // order to get all numeric fields that were incremented/decremented, call
  16400. // AddedFields().
  16401. func (m *MessageMutation) Fields() []string {
  16402. fields := make([]string, 0, 3)
  16403. if m.wx_wxid != nil {
  16404. fields = append(fields, message.FieldWxWxid)
  16405. }
  16406. if m.wxid != nil {
  16407. fields = append(fields, message.FieldWxid)
  16408. }
  16409. if m.content != nil {
  16410. fields = append(fields, message.FieldContent)
  16411. }
  16412. return fields
  16413. }
  16414. // Field returns the value of a field with the given name. The second boolean
  16415. // return value indicates that this field was not set, or was not defined in the
  16416. // schema.
  16417. func (m *MessageMutation) Field(name string) (ent.Value, bool) {
  16418. switch name {
  16419. case message.FieldWxWxid:
  16420. return m.WxWxid()
  16421. case message.FieldWxid:
  16422. return m.Wxid()
  16423. case message.FieldContent:
  16424. return m.Content()
  16425. }
  16426. return nil, false
  16427. }
  16428. // OldField returns the old value of the field from the database. An error is
  16429. // returned if the mutation operation is not UpdateOne, or the query to the
  16430. // database failed.
  16431. func (m *MessageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  16432. switch name {
  16433. case message.FieldWxWxid:
  16434. return m.OldWxWxid(ctx)
  16435. case message.FieldWxid:
  16436. return m.OldWxid(ctx)
  16437. case message.FieldContent:
  16438. return m.OldContent(ctx)
  16439. }
  16440. return nil, fmt.Errorf("unknown Message field %s", name)
  16441. }
  16442. // SetField sets the value of a field with the given name. It returns an error if
  16443. // the field is not defined in the schema, or if the type mismatched the field
  16444. // type.
  16445. func (m *MessageMutation) SetField(name string, value ent.Value) error {
  16446. switch name {
  16447. case message.FieldWxWxid:
  16448. v, ok := value.(string)
  16449. if !ok {
  16450. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16451. }
  16452. m.SetWxWxid(v)
  16453. return nil
  16454. case message.FieldWxid:
  16455. v, ok := value.(string)
  16456. if !ok {
  16457. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16458. }
  16459. m.SetWxid(v)
  16460. return nil
  16461. case message.FieldContent:
  16462. v, ok := value.(string)
  16463. if !ok {
  16464. return fmt.Errorf("unexpected type %T for field %s", value, name)
  16465. }
  16466. m.SetContent(v)
  16467. return nil
  16468. }
  16469. return fmt.Errorf("unknown Message field %s", name)
  16470. }
  16471. // AddedFields returns all numeric fields that were incremented/decremented during
  16472. // this mutation.
  16473. func (m *MessageMutation) AddedFields() []string {
  16474. return nil
  16475. }
  16476. // AddedField returns the numeric value that was incremented/decremented on a field
  16477. // with the given name. The second boolean return value indicates that this field
  16478. // was not set, or was not defined in the schema.
  16479. func (m *MessageMutation) AddedField(name string) (ent.Value, bool) {
  16480. return nil, false
  16481. }
  16482. // AddField adds the value to the field with the given name. It returns an error if
  16483. // the field is not defined in the schema, or if the type mismatched the field
  16484. // type.
  16485. func (m *MessageMutation) AddField(name string, value ent.Value) error {
  16486. switch name {
  16487. }
  16488. return fmt.Errorf("unknown Message numeric field %s", name)
  16489. }
  16490. // ClearedFields returns all nullable fields that were cleared during this
  16491. // mutation.
  16492. func (m *MessageMutation) ClearedFields() []string {
  16493. var fields []string
  16494. if m.FieldCleared(message.FieldWxWxid) {
  16495. fields = append(fields, message.FieldWxWxid)
  16496. }
  16497. return fields
  16498. }
  16499. // FieldCleared returns a boolean indicating if a field with the given name was
  16500. // cleared in this mutation.
  16501. func (m *MessageMutation) FieldCleared(name string) bool {
  16502. _, ok := m.clearedFields[name]
  16503. return ok
  16504. }
  16505. // ClearField clears the value of the field with the given name. It returns an
  16506. // error if the field is not defined in the schema.
  16507. func (m *MessageMutation) ClearField(name string) error {
  16508. switch name {
  16509. case message.FieldWxWxid:
  16510. m.ClearWxWxid()
  16511. return nil
  16512. }
  16513. return fmt.Errorf("unknown Message nullable field %s", name)
  16514. }
  16515. // ResetField resets all changes in the mutation for the field with the given name.
  16516. // It returns an error if the field is not defined in the schema.
  16517. func (m *MessageMutation) ResetField(name string) error {
  16518. switch name {
  16519. case message.FieldWxWxid:
  16520. m.ResetWxWxid()
  16521. return nil
  16522. case message.FieldWxid:
  16523. m.ResetWxid()
  16524. return nil
  16525. case message.FieldContent:
  16526. m.ResetContent()
  16527. return nil
  16528. }
  16529. return fmt.Errorf("unknown Message field %s", name)
  16530. }
  16531. // AddedEdges returns all edge names that were set/added in this mutation.
  16532. func (m *MessageMutation) AddedEdges() []string {
  16533. edges := make([]string, 0, 0)
  16534. return edges
  16535. }
  16536. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  16537. // name in this mutation.
  16538. func (m *MessageMutation) AddedIDs(name string) []ent.Value {
  16539. return nil
  16540. }
  16541. // RemovedEdges returns all edge names that were removed in this mutation.
  16542. func (m *MessageMutation) RemovedEdges() []string {
  16543. edges := make([]string, 0, 0)
  16544. return edges
  16545. }
  16546. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  16547. // the given name in this mutation.
  16548. func (m *MessageMutation) RemovedIDs(name string) []ent.Value {
  16549. return nil
  16550. }
  16551. // ClearedEdges returns all edge names that were cleared in this mutation.
  16552. func (m *MessageMutation) ClearedEdges() []string {
  16553. edges := make([]string, 0, 0)
  16554. return edges
  16555. }
  16556. // EdgeCleared returns a boolean which indicates if the edge with the given name
  16557. // was cleared in this mutation.
  16558. func (m *MessageMutation) EdgeCleared(name string) bool {
  16559. return false
  16560. }
  16561. // ClearEdge clears the value of the edge with the given name. It returns an error
  16562. // if that edge is not defined in the schema.
  16563. func (m *MessageMutation) ClearEdge(name string) error {
  16564. return fmt.Errorf("unknown Message unique edge %s", name)
  16565. }
  16566. // ResetEdge resets all changes to the edge with the given name in this mutation.
  16567. // It returns an error if the edge is not defined in the schema.
  16568. func (m *MessageMutation) ResetEdge(name string) error {
  16569. return fmt.Errorf("unknown Message edge %s", name)
  16570. }
  16571. // MessageRecordsMutation represents an operation that mutates the MessageRecords nodes in the graph.
  16572. type MessageRecordsMutation struct {
  16573. config
  16574. op Op
  16575. typ string
  16576. id *uint64
  16577. created_at *time.Time
  16578. updated_at *time.Time
  16579. status *uint8
  16580. addstatus *int8
  16581. bot_wxid *string
  16582. contact_type *int
  16583. addcontact_type *int
  16584. contact_wxid *string
  16585. content_type *int
  16586. addcontent_type *int
  16587. content *string
  16588. meta *custom_types.Meta
  16589. error_detail *string
  16590. send_time *time.Time
  16591. source_type *int
  16592. addsource_type *int
  16593. organization_id *uint64
  16594. addorganization_id *int64
  16595. clearedFields map[string]struct{}
  16596. sop_stage *uint64
  16597. clearedsop_stage bool
  16598. sop_node *uint64
  16599. clearedsop_node bool
  16600. message_contact *uint64
  16601. clearedmessage_contact bool
  16602. done bool
  16603. oldValue func(context.Context) (*MessageRecords, error)
  16604. predicates []predicate.MessageRecords
  16605. }
  16606. var _ ent.Mutation = (*MessageRecordsMutation)(nil)
  16607. // messagerecordsOption allows management of the mutation configuration using functional options.
  16608. type messagerecordsOption func(*MessageRecordsMutation)
  16609. // newMessageRecordsMutation creates new mutation for the MessageRecords entity.
  16610. func newMessageRecordsMutation(c config, op Op, opts ...messagerecordsOption) *MessageRecordsMutation {
  16611. m := &MessageRecordsMutation{
  16612. config: c,
  16613. op: op,
  16614. typ: TypeMessageRecords,
  16615. clearedFields: make(map[string]struct{}),
  16616. }
  16617. for _, opt := range opts {
  16618. opt(m)
  16619. }
  16620. return m
  16621. }
  16622. // withMessageRecordsID sets the ID field of the mutation.
  16623. func withMessageRecordsID(id uint64) messagerecordsOption {
  16624. return func(m *MessageRecordsMutation) {
  16625. var (
  16626. err error
  16627. once sync.Once
  16628. value *MessageRecords
  16629. )
  16630. m.oldValue = func(ctx context.Context) (*MessageRecords, error) {
  16631. once.Do(func() {
  16632. if m.done {
  16633. err = errors.New("querying old values post mutation is not allowed")
  16634. } else {
  16635. value, err = m.Client().MessageRecords.Get(ctx, id)
  16636. }
  16637. })
  16638. return value, err
  16639. }
  16640. m.id = &id
  16641. }
  16642. }
  16643. // withMessageRecords sets the old MessageRecords of the mutation.
  16644. func withMessageRecords(node *MessageRecords) messagerecordsOption {
  16645. return func(m *MessageRecordsMutation) {
  16646. m.oldValue = func(context.Context) (*MessageRecords, error) {
  16647. return node, nil
  16648. }
  16649. m.id = &node.ID
  16650. }
  16651. }
  16652. // Client returns a new `ent.Client` from the mutation. If the mutation was
  16653. // executed in a transaction (ent.Tx), a transactional client is returned.
  16654. func (m MessageRecordsMutation) Client() *Client {
  16655. client := &Client{config: m.config}
  16656. client.init()
  16657. return client
  16658. }
  16659. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  16660. // it returns an error otherwise.
  16661. func (m MessageRecordsMutation) Tx() (*Tx, error) {
  16662. if _, ok := m.driver.(*txDriver); !ok {
  16663. return nil, errors.New("ent: mutation is not running in a transaction")
  16664. }
  16665. tx := &Tx{config: m.config}
  16666. tx.init()
  16667. return tx, nil
  16668. }
  16669. // SetID sets the value of the id field. Note that this
  16670. // operation is only accepted on creation of MessageRecords entities.
  16671. func (m *MessageRecordsMutation) SetID(id uint64) {
  16672. m.id = &id
  16673. }
  16674. // ID returns the ID value in the mutation. Note that the ID is only available
  16675. // if it was provided to the builder or after it was returned from the database.
  16676. func (m *MessageRecordsMutation) ID() (id uint64, exists bool) {
  16677. if m.id == nil {
  16678. return
  16679. }
  16680. return *m.id, true
  16681. }
  16682. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  16683. // That means, if the mutation is applied within a transaction with an isolation level such
  16684. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  16685. // or updated by the mutation.
  16686. func (m *MessageRecordsMutation) IDs(ctx context.Context) ([]uint64, error) {
  16687. switch {
  16688. case m.op.Is(OpUpdateOne | OpDeleteOne):
  16689. id, exists := m.ID()
  16690. if exists {
  16691. return []uint64{id}, nil
  16692. }
  16693. fallthrough
  16694. case m.op.Is(OpUpdate | OpDelete):
  16695. return m.Client().MessageRecords.Query().Where(m.predicates...).IDs(ctx)
  16696. default:
  16697. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  16698. }
  16699. }
  16700. // SetCreatedAt sets the "created_at" field.
  16701. func (m *MessageRecordsMutation) SetCreatedAt(t time.Time) {
  16702. m.created_at = &t
  16703. }
  16704. // CreatedAt returns the value of the "created_at" field in the mutation.
  16705. func (m *MessageRecordsMutation) CreatedAt() (r time.Time, exists bool) {
  16706. v := m.created_at
  16707. if v == nil {
  16708. return
  16709. }
  16710. return *v, true
  16711. }
  16712. // OldCreatedAt returns the old "created_at" field's value of the MessageRecords entity.
  16713. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16715. func (m *MessageRecordsMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  16716. if !m.op.Is(OpUpdateOne) {
  16717. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  16718. }
  16719. if m.id == nil || m.oldValue == nil {
  16720. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  16721. }
  16722. oldValue, err := m.oldValue(ctx)
  16723. if err != nil {
  16724. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  16725. }
  16726. return oldValue.CreatedAt, nil
  16727. }
  16728. // ResetCreatedAt resets all changes to the "created_at" field.
  16729. func (m *MessageRecordsMutation) ResetCreatedAt() {
  16730. m.created_at = nil
  16731. }
  16732. // SetUpdatedAt sets the "updated_at" field.
  16733. func (m *MessageRecordsMutation) SetUpdatedAt(t time.Time) {
  16734. m.updated_at = &t
  16735. }
  16736. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  16737. func (m *MessageRecordsMutation) UpdatedAt() (r time.Time, exists bool) {
  16738. v := m.updated_at
  16739. if v == nil {
  16740. return
  16741. }
  16742. return *v, true
  16743. }
  16744. // OldUpdatedAt returns the old "updated_at" field's value of the MessageRecords entity.
  16745. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16746. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16747. func (m *MessageRecordsMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  16748. if !m.op.Is(OpUpdateOne) {
  16749. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  16750. }
  16751. if m.id == nil || m.oldValue == nil {
  16752. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  16753. }
  16754. oldValue, err := m.oldValue(ctx)
  16755. if err != nil {
  16756. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  16757. }
  16758. return oldValue.UpdatedAt, nil
  16759. }
  16760. // ResetUpdatedAt resets all changes to the "updated_at" field.
  16761. func (m *MessageRecordsMutation) ResetUpdatedAt() {
  16762. m.updated_at = nil
  16763. }
  16764. // SetStatus sets the "status" field.
  16765. func (m *MessageRecordsMutation) SetStatus(u uint8) {
  16766. m.status = &u
  16767. m.addstatus = nil
  16768. }
  16769. // Status returns the value of the "status" field in the mutation.
  16770. func (m *MessageRecordsMutation) Status() (r uint8, exists bool) {
  16771. v := m.status
  16772. if v == nil {
  16773. return
  16774. }
  16775. return *v, true
  16776. }
  16777. // OldStatus returns the old "status" field's value of the MessageRecords entity.
  16778. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16780. func (m *MessageRecordsMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  16781. if !m.op.Is(OpUpdateOne) {
  16782. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  16783. }
  16784. if m.id == nil || m.oldValue == nil {
  16785. return v, errors.New("OldStatus requires an ID field in the mutation")
  16786. }
  16787. oldValue, err := m.oldValue(ctx)
  16788. if err != nil {
  16789. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  16790. }
  16791. return oldValue.Status, nil
  16792. }
  16793. // AddStatus adds u to the "status" field.
  16794. func (m *MessageRecordsMutation) AddStatus(u int8) {
  16795. if m.addstatus != nil {
  16796. *m.addstatus += u
  16797. } else {
  16798. m.addstatus = &u
  16799. }
  16800. }
  16801. // AddedStatus returns the value that was added to the "status" field in this mutation.
  16802. func (m *MessageRecordsMutation) AddedStatus() (r int8, exists bool) {
  16803. v := m.addstatus
  16804. if v == nil {
  16805. return
  16806. }
  16807. return *v, true
  16808. }
  16809. // ClearStatus clears the value of the "status" field.
  16810. func (m *MessageRecordsMutation) ClearStatus() {
  16811. m.status = nil
  16812. m.addstatus = nil
  16813. m.clearedFields[messagerecords.FieldStatus] = struct{}{}
  16814. }
  16815. // StatusCleared returns if the "status" field was cleared in this mutation.
  16816. func (m *MessageRecordsMutation) StatusCleared() bool {
  16817. _, ok := m.clearedFields[messagerecords.FieldStatus]
  16818. return ok
  16819. }
  16820. // ResetStatus resets all changes to the "status" field.
  16821. func (m *MessageRecordsMutation) ResetStatus() {
  16822. m.status = nil
  16823. m.addstatus = nil
  16824. delete(m.clearedFields, messagerecords.FieldStatus)
  16825. }
  16826. // SetBotWxid sets the "bot_wxid" field.
  16827. func (m *MessageRecordsMutation) SetBotWxid(s string) {
  16828. m.bot_wxid = &s
  16829. }
  16830. // BotWxid returns the value of the "bot_wxid" field in the mutation.
  16831. func (m *MessageRecordsMutation) BotWxid() (r string, exists bool) {
  16832. v := m.bot_wxid
  16833. if v == nil {
  16834. return
  16835. }
  16836. return *v, true
  16837. }
  16838. // OldBotWxid returns the old "bot_wxid" field's value of the MessageRecords entity.
  16839. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16840. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16841. func (m *MessageRecordsMutation) OldBotWxid(ctx context.Context) (v string, err error) {
  16842. if !m.op.Is(OpUpdateOne) {
  16843. return v, errors.New("OldBotWxid is only allowed on UpdateOne operations")
  16844. }
  16845. if m.id == nil || m.oldValue == nil {
  16846. return v, errors.New("OldBotWxid requires an ID field in the mutation")
  16847. }
  16848. oldValue, err := m.oldValue(ctx)
  16849. if err != nil {
  16850. return v, fmt.Errorf("querying old value for OldBotWxid: %w", err)
  16851. }
  16852. return oldValue.BotWxid, nil
  16853. }
  16854. // ResetBotWxid resets all changes to the "bot_wxid" field.
  16855. func (m *MessageRecordsMutation) ResetBotWxid() {
  16856. m.bot_wxid = nil
  16857. }
  16858. // SetContactID sets the "contact_id" field.
  16859. func (m *MessageRecordsMutation) SetContactID(u uint64) {
  16860. m.message_contact = &u
  16861. }
  16862. // ContactID returns the value of the "contact_id" field in the mutation.
  16863. func (m *MessageRecordsMutation) ContactID() (r uint64, exists bool) {
  16864. v := m.message_contact
  16865. if v == nil {
  16866. return
  16867. }
  16868. return *v, true
  16869. }
  16870. // OldContactID returns the old "contact_id" field's value of the MessageRecords entity.
  16871. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16872. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16873. func (m *MessageRecordsMutation) OldContactID(ctx context.Context) (v uint64, err error) {
  16874. if !m.op.Is(OpUpdateOne) {
  16875. return v, errors.New("OldContactID is only allowed on UpdateOne operations")
  16876. }
  16877. if m.id == nil || m.oldValue == nil {
  16878. return v, errors.New("OldContactID requires an ID field in the mutation")
  16879. }
  16880. oldValue, err := m.oldValue(ctx)
  16881. if err != nil {
  16882. return v, fmt.Errorf("querying old value for OldContactID: %w", err)
  16883. }
  16884. return oldValue.ContactID, nil
  16885. }
  16886. // ClearContactID clears the value of the "contact_id" field.
  16887. func (m *MessageRecordsMutation) ClearContactID() {
  16888. m.message_contact = nil
  16889. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  16890. }
  16891. // ContactIDCleared returns if the "contact_id" field was cleared in this mutation.
  16892. func (m *MessageRecordsMutation) ContactIDCleared() bool {
  16893. _, ok := m.clearedFields[messagerecords.FieldContactID]
  16894. return ok
  16895. }
  16896. // ResetContactID resets all changes to the "contact_id" field.
  16897. func (m *MessageRecordsMutation) ResetContactID() {
  16898. m.message_contact = nil
  16899. delete(m.clearedFields, messagerecords.FieldContactID)
  16900. }
  16901. // SetContactType sets the "contact_type" field.
  16902. func (m *MessageRecordsMutation) SetContactType(i int) {
  16903. m.contact_type = &i
  16904. m.addcontact_type = nil
  16905. }
  16906. // ContactType returns the value of the "contact_type" field in the mutation.
  16907. func (m *MessageRecordsMutation) ContactType() (r int, exists bool) {
  16908. v := m.contact_type
  16909. if v == nil {
  16910. return
  16911. }
  16912. return *v, true
  16913. }
  16914. // OldContactType returns the old "contact_type" 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) OldContactType(ctx context.Context) (v int, err error) {
  16918. if !m.op.Is(OpUpdateOne) {
  16919. return v, errors.New("OldContactType is only allowed on UpdateOne operations")
  16920. }
  16921. if m.id == nil || m.oldValue == nil {
  16922. return v, errors.New("OldContactType 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 OldContactType: %w", err)
  16927. }
  16928. return oldValue.ContactType, nil
  16929. }
  16930. // AddContactType adds i to the "contact_type" field.
  16931. func (m *MessageRecordsMutation) AddContactType(i int) {
  16932. if m.addcontact_type != nil {
  16933. *m.addcontact_type += i
  16934. } else {
  16935. m.addcontact_type = &i
  16936. }
  16937. }
  16938. // AddedContactType returns the value that was added to the "contact_type" field in this mutation.
  16939. func (m *MessageRecordsMutation) AddedContactType() (r int, exists bool) {
  16940. v := m.addcontact_type
  16941. if v == nil {
  16942. return
  16943. }
  16944. return *v, true
  16945. }
  16946. // ResetContactType resets all changes to the "contact_type" field.
  16947. func (m *MessageRecordsMutation) ResetContactType() {
  16948. m.contact_type = nil
  16949. m.addcontact_type = nil
  16950. }
  16951. // SetContactWxid sets the "contact_wxid" field.
  16952. func (m *MessageRecordsMutation) SetContactWxid(s string) {
  16953. m.contact_wxid = &s
  16954. }
  16955. // ContactWxid returns the value of the "contact_wxid" field in the mutation.
  16956. func (m *MessageRecordsMutation) ContactWxid() (r string, exists bool) {
  16957. v := m.contact_wxid
  16958. if v == nil {
  16959. return
  16960. }
  16961. return *v, true
  16962. }
  16963. // OldContactWxid returns the old "contact_wxid" field's value of the MessageRecords entity.
  16964. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16965. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16966. func (m *MessageRecordsMutation) OldContactWxid(ctx context.Context) (v string, err error) {
  16967. if !m.op.Is(OpUpdateOne) {
  16968. return v, errors.New("OldContactWxid is only allowed on UpdateOne operations")
  16969. }
  16970. if m.id == nil || m.oldValue == nil {
  16971. return v, errors.New("OldContactWxid requires an ID field in the mutation")
  16972. }
  16973. oldValue, err := m.oldValue(ctx)
  16974. if err != nil {
  16975. return v, fmt.Errorf("querying old value for OldContactWxid: %w", err)
  16976. }
  16977. return oldValue.ContactWxid, nil
  16978. }
  16979. // ResetContactWxid resets all changes to the "contact_wxid" field.
  16980. func (m *MessageRecordsMutation) ResetContactWxid() {
  16981. m.contact_wxid = nil
  16982. }
  16983. // SetContentType sets the "content_type" field.
  16984. func (m *MessageRecordsMutation) SetContentType(i int) {
  16985. m.content_type = &i
  16986. m.addcontent_type = nil
  16987. }
  16988. // ContentType returns the value of the "content_type" field in the mutation.
  16989. func (m *MessageRecordsMutation) ContentType() (r int, exists bool) {
  16990. v := m.content_type
  16991. if v == nil {
  16992. return
  16993. }
  16994. return *v, true
  16995. }
  16996. // OldContentType returns the old "content_type" field's value of the MessageRecords entity.
  16997. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  16998. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  16999. func (m *MessageRecordsMutation) OldContentType(ctx context.Context) (v int, err error) {
  17000. if !m.op.Is(OpUpdateOne) {
  17001. return v, errors.New("OldContentType is only allowed on UpdateOne operations")
  17002. }
  17003. if m.id == nil || m.oldValue == nil {
  17004. return v, errors.New("OldContentType requires an ID field in the mutation")
  17005. }
  17006. oldValue, err := m.oldValue(ctx)
  17007. if err != nil {
  17008. return v, fmt.Errorf("querying old value for OldContentType: %w", err)
  17009. }
  17010. return oldValue.ContentType, nil
  17011. }
  17012. // AddContentType adds i to the "content_type" field.
  17013. func (m *MessageRecordsMutation) AddContentType(i int) {
  17014. if m.addcontent_type != nil {
  17015. *m.addcontent_type += i
  17016. } else {
  17017. m.addcontent_type = &i
  17018. }
  17019. }
  17020. // AddedContentType returns the value that was added to the "content_type" field in this mutation.
  17021. func (m *MessageRecordsMutation) AddedContentType() (r int, exists bool) {
  17022. v := m.addcontent_type
  17023. if v == nil {
  17024. return
  17025. }
  17026. return *v, true
  17027. }
  17028. // ResetContentType resets all changes to the "content_type" field.
  17029. func (m *MessageRecordsMutation) ResetContentType() {
  17030. m.content_type = nil
  17031. m.addcontent_type = nil
  17032. }
  17033. // SetContent sets the "content" field.
  17034. func (m *MessageRecordsMutation) SetContent(s string) {
  17035. m.content = &s
  17036. }
  17037. // Content returns the value of the "content" field in the mutation.
  17038. func (m *MessageRecordsMutation) Content() (r string, exists bool) {
  17039. v := m.content
  17040. if v == nil {
  17041. return
  17042. }
  17043. return *v, true
  17044. }
  17045. // OldContent returns the old "content" field's value of the MessageRecords entity.
  17046. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17047. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17048. func (m *MessageRecordsMutation) OldContent(ctx context.Context) (v string, err error) {
  17049. if !m.op.Is(OpUpdateOne) {
  17050. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  17051. }
  17052. if m.id == nil || m.oldValue == nil {
  17053. return v, errors.New("OldContent requires an ID field in the mutation")
  17054. }
  17055. oldValue, err := m.oldValue(ctx)
  17056. if err != nil {
  17057. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  17058. }
  17059. return oldValue.Content, nil
  17060. }
  17061. // ResetContent resets all changes to the "content" field.
  17062. func (m *MessageRecordsMutation) ResetContent() {
  17063. m.content = nil
  17064. }
  17065. // SetMeta sets the "meta" field.
  17066. func (m *MessageRecordsMutation) SetMeta(ct custom_types.Meta) {
  17067. m.meta = &ct
  17068. }
  17069. // Meta returns the value of the "meta" field in the mutation.
  17070. func (m *MessageRecordsMutation) Meta() (r custom_types.Meta, exists bool) {
  17071. v := m.meta
  17072. if v == nil {
  17073. return
  17074. }
  17075. return *v, true
  17076. }
  17077. // OldMeta returns the old "meta" field's value of the MessageRecords entity.
  17078. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17079. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17080. func (m *MessageRecordsMutation) OldMeta(ctx context.Context) (v custom_types.Meta, err error) {
  17081. if !m.op.Is(OpUpdateOne) {
  17082. return v, errors.New("OldMeta is only allowed on UpdateOne operations")
  17083. }
  17084. if m.id == nil || m.oldValue == nil {
  17085. return v, errors.New("OldMeta requires an ID field in the mutation")
  17086. }
  17087. oldValue, err := m.oldValue(ctx)
  17088. if err != nil {
  17089. return v, fmt.Errorf("querying old value for OldMeta: %w", err)
  17090. }
  17091. return oldValue.Meta, nil
  17092. }
  17093. // ClearMeta clears the value of the "meta" field.
  17094. func (m *MessageRecordsMutation) ClearMeta() {
  17095. m.meta = nil
  17096. m.clearedFields[messagerecords.FieldMeta] = struct{}{}
  17097. }
  17098. // MetaCleared returns if the "meta" field was cleared in this mutation.
  17099. func (m *MessageRecordsMutation) MetaCleared() bool {
  17100. _, ok := m.clearedFields[messagerecords.FieldMeta]
  17101. return ok
  17102. }
  17103. // ResetMeta resets all changes to the "meta" field.
  17104. func (m *MessageRecordsMutation) ResetMeta() {
  17105. m.meta = nil
  17106. delete(m.clearedFields, messagerecords.FieldMeta)
  17107. }
  17108. // SetErrorDetail sets the "error_detail" field.
  17109. func (m *MessageRecordsMutation) SetErrorDetail(s string) {
  17110. m.error_detail = &s
  17111. }
  17112. // ErrorDetail returns the value of the "error_detail" field in the mutation.
  17113. func (m *MessageRecordsMutation) ErrorDetail() (r string, exists bool) {
  17114. v := m.error_detail
  17115. if v == nil {
  17116. return
  17117. }
  17118. return *v, true
  17119. }
  17120. // OldErrorDetail returns the old "error_detail" field's value of the MessageRecords entity.
  17121. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17123. func (m *MessageRecordsMutation) OldErrorDetail(ctx context.Context) (v string, err error) {
  17124. if !m.op.Is(OpUpdateOne) {
  17125. return v, errors.New("OldErrorDetail is only allowed on UpdateOne operations")
  17126. }
  17127. if m.id == nil || m.oldValue == nil {
  17128. return v, errors.New("OldErrorDetail requires an ID field in the mutation")
  17129. }
  17130. oldValue, err := m.oldValue(ctx)
  17131. if err != nil {
  17132. return v, fmt.Errorf("querying old value for OldErrorDetail: %w", err)
  17133. }
  17134. return oldValue.ErrorDetail, nil
  17135. }
  17136. // ResetErrorDetail resets all changes to the "error_detail" field.
  17137. func (m *MessageRecordsMutation) ResetErrorDetail() {
  17138. m.error_detail = nil
  17139. }
  17140. // SetSendTime sets the "send_time" field.
  17141. func (m *MessageRecordsMutation) SetSendTime(t time.Time) {
  17142. m.send_time = &t
  17143. }
  17144. // SendTime returns the value of the "send_time" field in the mutation.
  17145. func (m *MessageRecordsMutation) SendTime() (r time.Time, exists bool) {
  17146. v := m.send_time
  17147. if v == nil {
  17148. return
  17149. }
  17150. return *v, true
  17151. }
  17152. // OldSendTime returns the old "send_time" field's value of the MessageRecords entity.
  17153. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17154. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17155. func (m *MessageRecordsMutation) OldSendTime(ctx context.Context) (v time.Time, err error) {
  17156. if !m.op.Is(OpUpdateOne) {
  17157. return v, errors.New("OldSendTime is only allowed on UpdateOne operations")
  17158. }
  17159. if m.id == nil || m.oldValue == nil {
  17160. return v, errors.New("OldSendTime requires an ID field in the mutation")
  17161. }
  17162. oldValue, err := m.oldValue(ctx)
  17163. if err != nil {
  17164. return v, fmt.Errorf("querying old value for OldSendTime: %w", err)
  17165. }
  17166. return oldValue.SendTime, nil
  17167. }
  17168. // ClearSendTime clears the value of the "send_time" field.
  17169. func (m *MessageRecordsMutation) ClearSendTime() {
  17170. m.send_time = nil
  17171. m.clearedFields[messagerecords.FieldSendTime] = struct{}{}
  17172. }
  17173. // SendTimeCleared returns if the "send_time" field was cleared in this mutation.
  17174. func (m *MessageRecordsMutation) SendTimeCleared() bool {
  17175. _, ok := m.clearedFields[messagerecords.FieldSendTime]
  17176. return ok
  17177. }
  17178. // ResetSendTime resets all changes to the "send_time" field.
  17179. func (m *MessageRecordsMutation) ResetSendTime() {
  17180. m.send_time = nil
  17181. delete(m.clearedFields, messagerecords.FieldSendTime)
  17182. }
  17183. // SetSourceType sets the "source_type" field.
  17184. func (m *MessageRecordsMutation) SetSourceType(i int) {
  17185. m.source_type = &i
  17186. m.addsource_type = nil
  17187. }
  17188. // SourceType returns the value of the "source_type" field in the mutation.
  17189. func (m *MessageRecordsMutation) SourceType() (r int, exists bool) {
  17190. v := m.source_type
  17191. if v == nil {
  17192. return
  17193. }
  17194. return *v, true
  17195. }
  17196. // OldSourceType returns the old "source_type" 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) OldSourceType(ctx context.Context) (v int, err error) {
  17200. if !m.op.Is(OpUpdateOne) {
  17201. return v, errors.New("OldSourceType is only allowed on UpdateOne operations")
  17202. }
  17203. if m.id == nil || m.oldValue == nil {
  17204. return v, errors.New("OldSourceType 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 OldSourceType: %w", err)
  17209. }
  17210. return oldValue.SourceType, nil
  17211. }
  17212. // AddSourceType adds i to the "source_type" field.
  17213. func (m *MessageRecordsMutation) AddSourceType(i int) {
  17214. if m.addsource_type != nil {
  17215. *m.addsource_type += i
  17216. } else {
  17217. m.addsource_type = &i
  17218. }
  17219. }
  17220. // AddedSourceType returns the value that was added to the "source_type" field in this mutation.
  17221. func (m *MessageRecordsMutation) AddedSourceType() (r int, exists bool) {
  17222. v := m.addsource_type
  17223. if v == nil {
  17224. return
  17225. }
  17226. return *v, true
  17227. }
  17228. // ResetSourceType resets all changes to the "source_type" field.
  17229. func (m *MessageRecordsMutation) ResetSourceType() {
  17230. m.source_type = nil
  17231. m.addsource_type = nil
  17232. }
  17233. // SetSourceID sets the "source_id" field.
  17234. func (m *MessageRecordsMutation) SetSourceID(u uint64) {
  17235. m.sop_stage = &u
  17236. }
  17237. // SourceID returns the value of the "source_id" field in the mutation.
  17238. func (m *MessageRecordsMutation) SourceID() (r uint64, exists bool) {
  17239. v := m.sop_stage
  17240. if v == nil {
  17241. return
  17242. }
  17243. return *v, true
  17244. }
  17245. // OldSourceID returns the old "source_id" field's value of the MessageRecords entity.
  17246. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17247. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17248. func (m *MessageRecordsMutation) OldSourceID(ctx context.Context) (v uint64, err error) {
  17249. if !m.op.Is(OpUpdateOne) {
  17250. return v, errors.New("OldSourceID is only allowed on UpdateOne operations")
  17251. }
  17252. if m.id == nil || m.oldValue == nil {
  17253. return v, errors.New("OldSourceID requires an ID field in the mutation")
  17254. }
  17255. oldValue, err := m.oldValue(ctx)
  17256. if err != nil {
  17257. return v, fmt.Errorf("querying old value for OldSourceID: %w", err)
  17258. }
  17259. return oldValue.SourceID, nil
  17260. }
  17261. // ClearSourceID clears the value of the "source_id" field.
  17262. func (m *MessageRecordsMutation) ClearSourceID() {
  17263. m.sop_stage = nil
  17264. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17265. }
  17266. // SourceIDCleared returns if the "source_id" field was cleared in this mutation.
  17267. func (m *MessageRecordsMutation) SourceIDCleared() bool {
  17268. _, ok := m.clearedFields[messagerecords.FieldSourceID]
  17269. return ok
  17270. }
  17271. // ResetSourceID resets all changes to the "source_id" field.
  17272. func (m *MessageRecordsMutation) ResetSourceID() {
  17273. m.sop_stage = nil
  17274. delete(m.clearedFields, messagerecords.FieldSourceID)
  17275. }
  17276. // SetSubSourceID sets the "sub_source_id" field.
  17277. func (m *MessageRecordsMutation) SetSubSourceID(u uint64) {
  17278. m.sop_node = &u
  17279. }
  17280. // SubSourceID returns the value of the "sub_source_id" field in the mutation.
  17281. func (m *MessageRecordsMutation) SubSourceID() (r uint64, exists bool) {
  17282. v := m.sop_node
  17283. if v == nil {
  17284. return
  17285. }
  17286. return *v, true
  17287. }
  17288. // OldSubSourceID returns the old "sub_source_id" field's value of the MessageRecords entity.
  17289. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17290. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17291. func (m *MessageRecordsMutation) OldSubSourceID(ctx context.Context) (v uint64, err error) {
  17292. if !m.op.Is(OpUpdateOne) {
  17293. return v, errors.New("OldSubSourceID is only allowed on UpdateOne operations")
  17294. }
  17295. if m.id == nil || m.oldValue == nil {
  17296. return v, errors.New("OldSubSourceID requires an ID field in the mutation")
  17297. }
  17298. oldValue, err := m.oldValue(ctx)
  17299. if err != nil {
  17300. return v, fmt.Errorf("querying old value for OldSubSourceID: %w", err)
  17301. }
  17302. return oldValue.SubSourceID, nil
  17303. }
  17304. // ClearSubSourceID clears the value of the "sub_source_id" field.
  17305. func (m *MessageRecordsMutation) ClearSubSourceID() {
  17306. m.sop_node = nil
  17307. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17308. }
  17309. // SubSourceIDCleared returns if the "sub_source_id" field was cleared in this mutation.
  17310. func (m *MessageRecordsMutation) SubSourceIDCleared() bool {
  17311. _, ok := m.clearedFields[messagerecords.FieldSubSourceID]
  17312. return ok
  17313. }
  17314. // ResetSubSourceID resets all changes to the "sub_source_id" field.
  17315. func (m *MessageRecordsMutation) ResetSubSourceID() {
  17316. m.sop_node = nil
  17317. delete(m.clearedFields, messagerecords.FieldSubSourceID)
  17318. }
  17319. // SetOrganizationID sets the "organization_id" field.
  17320. func (m *MessageRecordsMutation) SetOrganizationID(u uint64) {
  17321. m.organization_id = &u
  17322. m.addorganization_id = nil
  17323. }
  17324. // OrganizationID returns the value of the "organization_id" field in the mutation.
  17325. func (m *MessageRecordsMutation) OrganizationID() (r uint64, exists bool) {
  17326. v := m.organization_id
  17327. if v == nil {
  17328. return
  17329. }
  17330. return *v, true
  17331. }
  17332. // OldOrganizationID returns the old "organization_id" field's value of the MessageRecords entity.
  17333. // If the MessageRecords object wasn't provided to the builder, the object is fetched from the database.
  17334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  17335. func (m *MessageRecordsMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  17336. if !m.op.Is(OpUpdateOne) {
  17337. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  17338. }
  17339. if m.id == nil || m.oldValue == nil {
  17340. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  17341. }
  17342. oldValue, err := m.oldValue(ctx)
  17343. if err != nil {
  17344. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  17345. }
  17346. return oldValue.OrganizationID, nil
  17347. }
  17348. // AddOrganizationID adds u to the "organization_id" field.
  17349. func (m *MessageRecordsMutation) AddOrganizationID(u int64) {
  17350. if m.addorganization_id != nil {
  17351. *m.addorganization_id += u
  17352. } else {
  17353. m.addorganization_id = &u
  17354. }
  17355. }
  17356. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  17357. func (m *MessageRecordsMutation) AddedOrganizationID() (r int64, exists bool) {
  17358. v := m.addorganization_id
  17359. if v == nil {
  17360. return
  17361. }
  17362. return *v, true
  17363. }
  17364. // ClearOrganizationID clears the value of the "organization_id" field.
  17365. func (m *MessageRecordsMutation) ClearOrganizationID() {
  17366. m.organization_id = nil
  17367. m.addorganization_id = nil
  17368. m.clearedFields[messagerecords.FieldOrganizationID] = struct{}{}
  17369. }
  17370. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  17371. func (m *MessageRecordsMutation) OrganizationIDCleared() bool {
  17372. _, ok := m.clearedFields[messagerecords.FieldOrganizationID]
  17373. return ok
  17374. }
  17375. // ResetOrganizationID resets all changes to the "organization_id" field.
  17376. func (m *MessageRecordsMutation) ResetOrganizationID() {
  17377. m.organization_id = nil
  17378. m.addorganization_id = nil
  17379. delete(m.clearedFields, messagerecords.FieldOrganizationID)
  17380. }
  17381. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  17382. func (m *MessageRecordsMutation) SetSopStageID(id uint64) {
  17383. m.sop_stage = &id
  17384. }
  17385. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  17386. func (m *MessageRecordsMutation) ClearSopStage() {
  17387. m.clearedsop_stage = true
  17388. m.clearedFields[messagerecords.FieldSourceID] = struct{}{}
  17389. }
  17390. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  17391. func (m *MessageRecordsMutation) SopStageCleared() bool {
  17392. return m.SourceIDCleared() || m.clearedsop_stage
  17393. }
  17394. // SopStageID returns the "sop_stage" edge ID in the mutation.
  17395. func (m *MessageRecordsMutation) SopStageID() (id uint64, exists bool) {
  17396. if m.sop_stage != nil {
  17397. return *m.sop_stage, true
  17398. }
  17399. return
  17400. }
  17401. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  17402. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17403. // SopStageID instead. It exists only for internal usage by the builders.
  17404. func (m *MessageRecordsMutation) SopStageIDs() (ids []uint64) {
  17405. if id := m.sop_stage; id != nil {
  17406. ids = append(ids, *id)
  17407. }
  17408. return
  17409. }
  17410. // ResetSopStage resets all changes to the "sop_stage" edge.
  17411. func (m *MessageRecordsMutation) ResetSopStage() {
  17412. m.sop_stage = nil
  17413. m.clearedsop_stage = false
  17414. }
  17415. // SetSopNodeID sets the "sop_node" edge to the SopNode entity by id.
  17416. func (m *MessageRecordsMutation) SetSopNodeID(id uint64) {
  17417. m.sop_node = &id
  17418. }
  17419. // ClearSopNode clears the "sop_node" edge to the SopNode entity.
  17420. func (m *MessageRecordsMutation) ClearSopNode() {
  17421. m.clearedsop_node = true
  17422. m.clearedFields[messagerecords.FieldSubSourceID] = struct{}{}
  17423. }
  17424. // SopNodeCleared reports if the "sop_node" edge to the SopNode entity was cleared.
  17425. func (m *MessageRecordsMutation) SopNodeCleared() bool {
  17426. return m.SubSourceIDCleared() || m.clearedsop_node
  17427. }
  17428. // SopNodeID returns the "sop_node" edge ID in the mutation.
  17429. func (m *MessageRecordsMutation) SopNodeID() (id uint64, exists bool) {
  17430. if m.sop_node != nil {
  17431. return *m.sop_node, true
  17432. }
  17433. return
  17434. }
  17435. // SopNodeIDs returns the "sop_node" edge IDs in the mutation.
  17436. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17437. // SopNodeID instead. It exists only for internal usage by the builders.
  17438. func (m *MessageRecordsMutation) SopNodeIDs() (ids []uint64) {
  17439. if id := m.sop_node; id != nil {
  17440. ids = append(ids, *id)
  17441. }
  17442. return
  17443. }
  17444. // ResetSopNode resets all changes to the "sop_node" edge.
  17445. func (m *MessageRecordsMutation) ResetSopNode() {
  17446. m.sop_node = nil
  17447. m.clearedsop_node = false
  17448. }
  17449. // SetMessageContactID sets the "message_contact" edge to the Contact entity by id.
  17450. func (m *MessageRecordsMutation) SetMessageContactID(id uint64) {
  17451. m.message_contact = &id
  17452. }
  17453. // ClearMessageContact clears the "message_contact" edge to the Contact entity.
  17454. func (m *MessageRecordsMutation) ClearMessageContact() {
  17455. m.clearedmessage_contact = true
  17456. m.clearedFields[messagerecords.FieldContactID] = struct{}{}
  17457. }
  17458. // MessageContactCleared reports if the "message_contact" edge to the Contact entity was cleared.
  17459. func (m *MessageRecordsMutation) MessageContactCleared() bool {
  17460. return m.ContactIDCleared() || m.clearedmessage_contact
  17461. }
  17462. // MessageContactID returns the "message_contact" edge ID in the mutation.
  17463. func (m *MessageRecordsMutation) MessageContactID() (id uint64, exists bool) {
  17464. if m.message_contact != nil {
  17465. return *m.message_contact, true
  17466. }
  17467. return
  17468. }
  17469. // MessageContactIDs returns the "message_contact" edge IDs in the mutation.
  17470. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  17471. // MessageContactID instead. It exists only for internal usage by the builders.
  17472. func (m *MessageRecordsMutation) MessageContactIDs() (ids []uint64) {
  17473. if id := m.message_contact; id != nil {
  17474. ids = append(ids, *id)
  17475. }
  17476. return
  17477. }
  17478. // ResetMessageContact resets all changes to the "message_contact" edge.
  17479. func (m *MessageRecordsMutation) ResetMessageContact() {
  17480. m.message_contact = nil
  17481. m.clearedmessage_contact = false
  17482. }
  17483. // Where appends a list predicates to the MessageRecordsMutation builder.
  17484. func (m *MessageRecordsMutation) Where(ps ...predicate.MessageRecords) {
  17485. m.predicates = append(m.predicates, ps...)
  17486. }
  17487. // WhereP appends storage-level predicates to the MessageRecordsMutation builder. Using this method,
  17488. // users can use type-assertion to append predicates that do not depend on any generated package.
  17489. func (m *MessageRecordsMutation) WhereP(ps ...func(*sql.Selector)) {
  17490. p := make([]predicate.MessageRecords, len(ps))
  17491. for i := range ps {
  17492. p[i] = ps[i]
  17493. }
  17494. m.Where(p...)
  17495. }
  17496. // Op returns the operation name.
  17497. func (m *MessageRecordsMutation) Op() Op {
  17498. return m.op
  17499. }
  17500. // SetOp allows setting the mutation operation.
  17501. func (m *MessageRecordsMutation) SetOp(op Op) {
  17502. m.op = op
  17503. }
  17504. // Type returns the node type of this mutation (MessageRecords).
  17505. func (m *MessageRecordsMutation) Type() string {
  17506. return m.typ
  17507. }
  17508. // Fields returns all fields that were changed during this mutation. Note that in
  17509. // order to get all numeric fields that were incremented/decremented, call
  17510. // AddedFields().
  17511. func (m *MessageRecordsMutation) Fields() []string {
  17512. fields := make([]string, 0, 16)
  17513. if m.created_at != nil {
  17514. fields = append(fields, messagerecords.FieldCreatedAt)
  17515. }
  17516. if m.updated_at != nil {
  17517. fields = append(fields, messagerecords.FieldUpdatedAt)
  17518. }
  17519. if m.status != nil {
  17520. fields = append(fields, messagerecords.FieldStatus)
  17521. }
  17522. if m.bot_wxid != nil {
  17523. fields = append(fields, messagerecords.FieldBotWxid)
  17524. }
  17525. if m.message_contact != nil {
  17526. fields = append(fields, messagerecords.FieldContactID)
  17527. }
  17528. if m.contact_type != nil {
  17529. fields = append(fields, messagerecords.FieldContactType)
  17530. }
  17531. if m.contact_wxid != nil {
  17532. fields = append(fields, messagerecords.FieldContactWxid)
  17533. }
  17534. if m.content_type != nil {
  17535. fields = append(fields, messagerecords.FieldContentType)
  17536. }
  17537. if m.content != nil {
  17538. fields = append(fields, messagerecords.FieldContent)
  17539. }
  17540. if m.meta != nil {
  17541. fields = append(fields, messagerecords.FieldMeta)
  17542. }
  17543. if m.error_detail != nil {
  17544. fields = append(fields, messagerecords.FieldErrorDetail)
  17545. }
  17546. if m.send_time != nil {
  17547. fields = append(fields, messagerecords.FieldSendTime)
  17548. }
  17549. if m.source_type != nil {
  17550. fields = append(fields, messagerecords.FieldSourceType)
  17551. }
  17552. if m.sop_stage != nil {
  17553. fields = append(fields, messagerecords.FieldSourceID)
  17554. }
  17555. if m.sop_node != nil {
  17556. fields = append(fields, messagerecords.FieldSubSourceID)
  17557. }
  17558. if m.organization_id != nil {
  17559. fields = append(fields, messagerecords.FieldOrganizationID)
  17560. }
  17561. return fields
  17562. }
  17563. // Field returns the value of a field with the given name. The second boolean
  17564. // return value indicates that this field was not set, or was not defined in the
  17565. // schema.
  17566. func (m *MessageRecordsMutation) Field(name string) (ent.Value, bool) {
  17567. switch name {
  17568. case messagerecords.FieldCreatedAt:
  17569. return m.CreatedAt()
  17570. case messagerecords.FieldUpdatedAt:
  17571. return m.UpdatedAt()
  17572. case messagerecords.FieldStatus:
  17573. return m.Status()
  17574. case messagerecords.FieldBotWxid:
  17575. return m.BotWxid()
  17576. case messagerecords.FieldContactID:
  17577. return m.ContactID()
  17578. case messagerecords.FieldContactType:
  17579. return m.ContactType()
  17580. case messagerecords.FieldContactWxid:
  17581. return m.ContactWxid()
  17582. case messagerecords.FieldContentType:
  17583. return m.ContentType()
  17584. case messagerecords.FieldContent:
  17585. return m.Content()
  17586. case messagerecords.FieldMeta:
  17587. return m.Meta()
  17588. case messagerecords.FieldErrorDetail:
  17589. return m.ErrorDetail()
  17590. case messagerecords.FieldSendTime:
  17591. return m.SendTime()
  17592. case messagerecords.FieldSourceType:
  17593. return m.SourceType()
  17594. case messagerecords.FieldSourceID:
  17595. return m.SourceID()
  17596. case messagerecords.FieldSubSourceID:
  17597. return m.SubSourceID()
  17598. case messagerecords.FieldOrganizationID:
  17599. return m.OrganizationID()
  17600. }
  17601. return nil, false
  17602. }
  17603. // OldField returns the old value of the field from the database. An error is
  17604. // returned if the mutation operation is not UpdateOne, or the query to the
  17605. // database failed.
  17606. func (m *MessageRecordsMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  17607. switch name {
  17608. case messagerecords.FieldCreatedAt:
  17609. return m.OldCreatedAt(ctx)
  17610. case messagerecords.FieldUpdatedAt:
  17611. return m.OldUpdatedAt(ctx)
  17612. case messagerecords.FieldStatus:
  17613. return m.OldStatus(ctx)
  17614. case messagerecords.FieldBotWxid:
  17615. return m.OldBotWxid(ctx)
  17616. case messagerecords.FieldContactID:
  17617. return m.OldContactID(ctx)
  17618. case messagerecords.FieldContactType:
  17619. return m.OldContactType(ctx)
  17620. case messagerecords.FieldContactWxid:
  17621. return m.OldContactWxid(ctx)
  17622. case messagerecords.FieldContentType:
  17623. return m.OldContentType(ctx)
  17624. case messagerecords.FieldContent:
  17625. return m.OldContent(ctx)
  17626. case messagerecords.FieldMeta:
  17627. return m.OldMeta(ctx)
  17628. case messagerecords.FieldErrorDetail:
  17629. return m.OldErrorDetail(ctx)
  17630. case messagerecords.FieldSendTime:
  17631. return m.OldSendTime(ctx)
  17632. case messagerecords.FieldSourceType:
  17633. return m.OldSourceType(ctx)
  17634. case messagerecords.FieldSourceID:
  17635. return m.OldSourceID(ctx)
  17636. case messagerecords.FieldSubSourceID:
  17637. return m.OldSubSourceID(ctx)
  17638. case messagerecords.FieldOrganizationID:
  17639. return m.OldOrganizationID(ctx)
  17640. }
  17641. return nil, fmt.Errorf("unknown MessageRecords field %s", name)
  17642. }
  17643. // SetField sets the value of a field with the given name. It returns an error if
  17644. // the field is not defined in the schema, or if the type mismatched the field
  17645. // type.
  17646. func (m *MessageRecordsMutation) SetField(name string, value ent.Value) error {
  17647. switch name {
  17648. case messagerecords.FieldCreatedAt:
  17649. v, ok := value.(time.Time)
  17650. if !ok {
  17651. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17652. }
  17653. m.SetCreatedAt(v)
  17654. return nil
  17655. case messagerecords.FieldUpdatedAt:
  17656. v, ok := value.(time.Time)
  17657. if !ok {
  17658. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17659. }
  17660. m.SetUpdatedAt(v)
  17661. return nil
  17662. case messagerecords.FieldStatus:
  17663. v, ok := value.(uint8)
  17664. if !ok {
  17665. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17666. }
  17667. m.SetStatus(v)
  17668. return nil
  17669. case messagerecords.FieldBotWxid:
  17670. v, ok := value.(string)
  17671. if !ok {
  17672. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17673. }
  17674. m.SetBotWxid(v)
  17675. return nil
  17676. case messagerecords.FieldContactID:
  17677. v, ok := value.(uint64)
  17678. if !ok {
  17679. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17680. }
  17681. m.SetContactID(v)
  17682. return nil
  17683. case messagerecords.FieldContactType:
  17684. v, ok := value.(int)
  17685. if !ok {
  17686. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17687. }
  17688. m.SetContactType(v)
  17689. return nil
  17690. case messagerecords.FieldContactWxid:
  17691. v, ok := value.(string)
  17692. if !ok {
  17693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17694. }
  17695. m.SetContactWxid(v)
  17696. return nil
  17697. case messagerecords.FieldContentType:
  17698. v, ok := value.(int)
  17699. if !ok {
  17700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17701. }
  17702. m.SetContentType(v)
  17703. return nil
  17704. case messagerecords.FieldContent:
  17705. v, ok := value.(string)
  17706. if !ok {
  17707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17708. }
  17709. m.SetContent(v)
  17710. return nil
  17711. case messagerecords.FieldMeta:
  17712. v, ok := value.(custom_types.Meta)
  17713. if !ok {
  17714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17715. }
  17716. m.SetMeta(v)
  17717. return nil
  17718. case messagerecords.FieldErrorDetail:
  17719. v, ok := value.(string)
  17720. if !ok {
  17721. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17722. }
  17723. m.SetErrorDetail(v)
  17724. return nil
  17725. case messagerecords.FieldSendTime:
  17726. v, ok := value.(time.Time)
  17727. if !ok {
  17728. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17729. }
  17730. m.SetSendTime(v)
  17731. return nil
  17732. case messagerecords.FieldSourceType:
  17733. v, ok := value.(int)
  17734. if !ok {
  17735. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17736. }
  17737. m.SetSourceType(v)
  17738. return nil
  17739. case messagerecords.FieldSourceID:
  17740. v, ok := value.(uint64)
  17741. if !ok {
  17742. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17743. }
  17744. m.SetSourceID(v)
  17745. return nil
  17746. case messagerecords.FieldSubSourceID:
  17747. v, ok := value.(uint64)
  17748. if !ok {
  17749. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17750. }
  17751. m.SetSubSourceID(v)
  17752. return nil
  17753. case messagerecords.FieldOrganizationID:
  17754. v, ok := value.(uint64)
  17755. if !ok {
  17756. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17757. }
  17758. m.SetOrganizationID(v)
  17759. return nil
  17760. }
  17761. return fmt.Errorf("unknown MessageRecords field %s", name)
  17762. }
  17763. // AddedFields returns all numeric fields that were incremented/decremented during
  17764. // this mutation.
  17765. func (m *MessageRecordsMutation) AddedFields() []string {
  17766. var fields []string
  17767. if m.addstatus != nil {
  17768. fields = append(fields, messagerecords.FieldStatus)
  17769. }
  17770. if m.addcontact_type != nil {
  17771. fields = append(fields, messagerecords.FieldContactType)
  17772. }
  17773. if m.addcontent_type != nil {
  17774. fields = append(fields, messagerecords.FieldContentType)
  17775. }
  17776. if m.addsource_type != nil {
  17777. fields = append(fields, messagerecords.FieldSourceType)
  17778. }
  17779. if m.addorganization_id != nil {
  17780. fields = append(fields, messagerecords.FieldOrganizationID)
  17781. }
  17782. return fields
  17783. }
  17784. // AddedField returns the numeric value that was incremented/decremented on a field
  17785. // with the given name. The second boolean return value indicates that this field
  17786. // was not set, or was not defined in the schema.
  17787. func (m *MessageRecordsMutation) AddedField(name string) (ent.Value, bool) {
  17788. switch name {
  17789. case messagerecords.FieldStatus:
  17790. return m.AddedStatus()
  17791. case messagerecords.FieldContactType:
  17792. return m.AddedContactType()
  17793. case messagerecords.FieldContentType:
  17794. return m.AddedContentType()
  17795. case messagerecords.FieldSourceType:
  17796. return m.AddedSourceType()
  17797. case messagerecords.FieldOrganizationID:
  17798. return m.AddedOrganizationID()
  17799. }
  17800. return nil, false
  17801. }
  17802. // AddField adds the value to the field with the given name. It returns an error if
  17803. // the field is not defined in the schema, or if the type mismatched the field
  17804. // type.
  17805. func (m *MessageRecordsMutation) AddField(name string, value ent.Value) error {
  17806. switch name {
  17807. case messagerecords.FieldStatus:
  17808. v, ok := value.(int8)
  17809. if !ok {
  17810. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17811. }
  17812. m.AddStatus(v)
  17813. return nil
  17814. case messagerecords.FieldContactType:
  17815. v, ok := value.(int)
  17816. if !ok {
  17817. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17818. }
  17819. m.AddContactType(v)
  17820. return nil
  17821. case messagerecords.FieldContentType:
  17822. v, ok := value.(int)
  17823. if !ok {
  17824. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17825. }
  17826. m.AddContentType(v)
  17827. return nil
  17828. case messagerecords.FieldSourceType:
  17829. v, ok := value.(int)
  17830. if !ok {
  17831. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17832. }
  17833. m.AddSourceType(v)
  17834. return nil
  17835. case messagerecords.FieldOrganizationID:
  17836. v, ok := value.(int64)
  17837. if !ok {
  17838. return fmt.Errorf("unexpected type %T for field %s", value, name)
  17839. }
  17840. m.AddOrganizationID(v)
  17841. return nil
  17842. }
  17843. return fmt.Errorf("unknown MessageRecords numeric field %s", name)
  17844. }
  17845. // ClearedFields returns all nullable fields that were cleared during this
  17846. // mutation.
  17847. func (m *MessageRecordsMutation) ClearedFields() []string {
  17848. var fields []string
  17849. if m.FieldCleared(messagerecords.FieldStatus) {
  17850. fields = append(fields, messagerecords.FieldStatus)
  17851. }
  17852. if m.FieldCleared(messagerecords.FieldContactID) {
  17853. fields = append(fields, messagerecords.FieldContactID)
  17854. }
  17855. if m.FieldCleared(messagerecords.FieldMeta) {
  17856. fields = append(fields, messagerecords.FieldMeta)
  17857. }
  17858. if m.FieldCleared(messagerecords.FieldSendTime) {
  17859. fields = append(fields, messagerecords.FieldSendTime)
  17860. }
  17861. if m.FieldCleared(messagerecords.FieldSourceID) {
  17862. fields = append(fields, messagerecords.FieldSourceID)
  17863. }
  17864. if m.FieldCleared(messagerecords.FieldSubSourceID) {
  17865. fields = append(fields, messagerecords.FieldSubSourceID)
  17866. }
  17867. if m.FieldCleared(messagerecords.FieldOrganizationID) {
  17868. fields = append(fields, messagerecords.FieldOrganizationID)
  17869. }
  17870. return fields
  17871. }
  17872. // FieldCleared returns a boolean indicating if a field with the given name was
  17873. // cleared in this mutation.
  17874. func (m *MessageRecordsMutation) FieldCleared(name string) bool {
  17875. _, ok := m.clearedFields[name]
  17876. return ok
  17877. }
  17878. // ClearField clears the value of the field with the given name. It returns an
  17879. // error if the field is not defined in the schema.
  17880. func (m *MessageRecordsMutation) ClearField(name string) error {
  17881. switch name {
  17882. case messagerecords.FieldStatus:
  17883. m.ClearStatus()
  17884. return nil
  17885. case messagerecords.FieldContactID:
  17886. m.ClearContactID()
  17887. return nil
  17888. case messagerecords.FieldMeta:
  17889. m.ClearMeta()
  17890. return nil
  17891. case messagerecords.FieldSendTime:
  17892. m.ClearSendTime()
  17893. return nil
  17894. case messagerecords.FieldSourceID:
  17895. m.ClearSourceID()
  17896. return nil
  17897. case messagerecords.FieldSubSourceID:
  17898. m.ClearSubSourceID()
  17899. return nil
  17900. case messagerecords.FieldOrganizationID:
  17901. m.ClearOrganizationID()
  17902. return nil
  17903. }
  17904. return fmt.Errorf("unknown MessageRecords nullable field %s", name)
  17905. }
  17906. // ResetField resets all changes in the mutation for the field with the given name.
  17907. // It returns an error if the field is not defined in the schema.
  17908. func (m *MessageRecordsMutation) ResetField(name string) error {
  17909. switch name {
  17910. case messagerecords.FieldCreatedAt:
  17911. m.ResetCreatedAt()
  17912. return nil
  17913. case messagerecords.FieldUpdatedAt:
  17914. m.ResetUpdatedAt()
  17915. return nil
  17916. case messagerecords.FieldStatus:
  17917. m.ResetStatus()
  17918. return nil
  17919. case messagerecords.FieldBotWxid:
  17920. m.ResetBotWxid()
  17921. return nil
  17922. case messagerecords.FieldContactID:
  17923. m.ResetContactID()
  17924. return nil
  17925. case messagerecords.FieldContactType:
  17926. m.ResetContactType()
  17927. return nil
  17928. case messagerecords.FieldContactWxid:
  17929. m.ResetContactWxid()
  17930. return nil
  17931. case messagerecords.FieldContentType:
  17932. m.ResetContentType()
  17933. return nil
  17934. case messagerecords.FieldContent:
  17935. m.ResetContent()
  17936. return nil
  17937. case messagerecords.FieldMeta:
  17938. m.ResetMeta()
  17939. return nil
  17940. case messagerecords.FieldErrorDetail:
  17941. m.ResetErrorDetail()
  17942. return nil
  17943. case messagerecords.FieldSendTime:
  17944. m.ResetSendTime()
  17945. return nil
  17946. case messagerecords.FieldSourceType:
  17947. m.ResetSourceType()
  17948. return nil
  17949. case messagerecords.FieldSourceID:
  17950. m.ResetSourceID()
  17951. return nil
  17952. case messagerecords.FieldSubSourceID:
  17953. m.ResetSubSourceID()
  17954. return nil
  17955. case messagerecords.FieldOrganizationID:
  17956. m.ResetOrganizationID()
  17957. return nil
  17958. }
  17959. return fmt.Errorf("unknown MessageRecords field %s", name)
  17960. }
  17961. // AddedEdges returns all edge names that were set/added in this mutation.
  17962. func (m *MessageRecordsMutation) AddedEdges() []string {
  17963. edges := make([]string, 0, 3)
  17964. if m.sop_stage != nil {
  17965. edges = append(edges, messagerecords.EdgeSopStage)
  17966. }
  17967. if m.sop_node != nil {
  17968. edges = append(edges, messagerecords.EdgeSopNode)
  17969. }
  17970. if m.message_contact != nil {
  17971. edges = append(edges, messagerecords.EdgeMessageContact)
  17972. }
  17973. return edges
  17974. }
  17975. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  17976. // name in this mutation.
  17977. func (m *MessageRecordsMutation) AddedIDs(name string) []ent.Value {
  17978. switch name {
  17979. case messagerecords.EdgeSopStage:
  17980. if id := m.sop_stage; id != nil {
  17981. return []ent.Value{*id}
  17982. }
  17983. case messagerecords.EdgeSopNode:
  17984. if id := m.sop_node; id != nil {
  17985. return []ent.Value{*id}
  17986. }
  17987. case messagerecords.EdgeMessageContact:
  17988. if id := m.message_contact; id != nil {
  17989. return []ent.Value{*id}
  17990. }
  17991. }
  17992. return nil
  17993. }
  17994. // RemovedEdges returns all edge names that were removed in this mutation.
  17995. func (m *MessageRecordsMutation) RemovedEdges() []string {
  17996. edges := make([]string, 0, 3)
  17997. return edges
  17998. }
  17999. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18000. // the given name in this mutation.
  18001. func (m *MessageRecordsMutation) RemovedIDs(name string) []ent.Value {
  18002. return nil
  18003. }
  18004. // ClearedEdges returns all edge names that were cleared in this mutation.
  18005. func (m *MessageRecordsMutation) ClearedEdges() []string {
  18006. edges := make([]string, 0, 3)
  18007. if m.clearedsop_stage {
  18008. edges = append(edges, messagerecords.EdgeSopStage)
  18009. }
  18010. if m.clearedsop_node {
  18011. edges = append(edges, messagerecords.EdgeSopNode)
  18012. }
  18013. if m.clearedmessage_contact {
  18014. edges = append(edges, messagerecords.EdgeMessageContact)
  18015. }
  18016. return edges
  18017. }
  18018. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18019. // was cleared in this mutation.
  18020. func (m *MessageRecordsMutation) EdgeCleared(name string) bool {
  18021. switch name {
  18022. case messagerecords.EdgeSopStage:
  18023. return m.clearedsop_stage
  18024. case messagerecords.EdgeSopNode:
  18025. return m.clearedsop_node
  18026. case messagerecords.EdgeMessageContact:
  18027. return m.clearedmessage_contact
  18028. }
  18029. return false
  18030. }
  18031. // ClearEdge clears the value of the edge with the given name. It returns an error
  18032. // if that edge is not defined in the schema.
  18033. func (m *MessageRecordsMutation) ClearEdge(name string) error {
  18034. switch name {
  18035. case messagerecords.EdgeSopStage:
  18036. m.ClearSopStage()
  18037. return nil
  18038. case messagerecords.EdgeSopNode:
  18039. m.ClearSopNode()
  18040. return nil
  18041. case messagerecords.EdgeMessageContact:
  18042. m.ClearMessageContact()
  18043. return nil
  18044. }
  18045. return fmt.Errorf("unknown MessageRecords unique edge %s", name)
  18046. }
  18047. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18048. // It returns an error if the edge is not defined in the schema.
  18049. func (m *MessageRecordsMutation) ResetEdge(name string) error {
  18050. switch name {
  18051. case messagerecords.EdgeSopStage:
  18052. m.ResetSopStage()
  18053. return nil
  18054. case messagerecords.EdgeSopNode:
  18055. m.ResetSopNode()
  18056. return nil
  18057. case messagerecords.EdgeMessageContact:
  18058. m.ResetMessageContact()
  18059. return nil
  18060. }
  18061. return fmt.Errorf("unknown MessageRecords edge %s", name)
  18062. }
  18063. // MsgMutation represents an operation that mutates the Msg nodes in the graph.
  18064. type MsgMutation struct {
  18065. config
  18066. op Op
  18067. typ string
  18068. id *uint64
  18069. created_at *time.Time
  18070. updated_at *time.Time
  18071. deleted_at *time.Time
  18072. status *uint8
  18073. addstatus *int8
  18074. fromwxid *string
  18075. toid *string
  18076. msgtype *int32
  18077. addmsgtype *int32
  18078. msg *string
  18079. batch_no *string
  18080. clearedFields map[string]struct{}
  18081. done bool
  18082. oldValue func(context.Context) (*Msg, error)
  18083. predicates []predicate.Msg
  18084. }
  18085. var _ ent.Mutation = (*MsgMutation)(nil)
  18086. // msgOption allows management of the mutation configuration using functional options.
  18087. type msgOption func(*MsgMutation)
  18088. // newMsgMutation creates new mutation for the Msg entity.
  18089. func newMsgMutation(c config, op Op, opts ...msgOption) *MsgMutation {
  18090. m := &MsgMutation{
  18091. config: c,
  18092. op: op,
  18093. typ: TypeMsg,
  18094. clearedFields: make(map[string]struct{}),
  18095. }
  18096. for _, opt := range opts {
  18097. opt(m)
  18098. }
  18099. return m
  18100. }
  18101. // withMsgID sets the ID field of the mutation.
  18102. func withMsgID(id uint64) msgOption {
  18103. return func(m *MsgMutation) {
  18104. var (
  18105. err error
  18106. once sync.Once
  18107. value *Msg
  18108. )
  18109. m.oldValue = func(ctx context.Context) (*Msg, error) {
  18110. once.Do(func() {
  18111. if m.done {
  18112. err = errors.New("querying old values post mutation is not allowed")
  18113. } else {
  18114. value, err = m.Client().Msg.Get(ctx, id)
  18115. }
  18116. })
  18117. return value, err
  18118. }
  18119. m.id = &id
  18120. }
  18121. }
  18122. // withMsg sets the old Msg of the mutation.
  18123. func withMsg(node *Msg) msgOption {
  18124. return func(m *MsgMutation) {
  18125. m.oldValue = func(context.Context) (*Msg, error) {
  18126. return node, nil
  18127. }
  18128. m.id = &node.ID
  18129. }
  18130. }
  18131. // Client returns a new `ent.Client` from the mutation. If the mutation was
  18132. // executed in a transaction (ent.Tx), a transactional client is returned.
  18133. func (m MsgMutation) Client() *Client {
  18134. client := &Client{config: m.config}
  18135. client.init()
  18136. return client
  18137. }
  18138. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  18139. // it returns an error otherwise.
  18140. func (m MsgMutation) Tx() (*Tx, error) {
  18141. if _, ok := m.driver.(*txDriver); !ok {
  18142. return nil, errors.New("ent: mutation is not running in a transaction")
  18143. }
  18144. tx := &Tx{config: m.config}
  18145. tx.init()
  18146. return tx, nil
  18147. }
  18148. // SetID sets the value of the id field. Note that this
  18149. // operation is only accepted on creation of Msg entities.
  18150. func (m *MsgMutation) SetID(id uint64) {
  18151. m.id = &id
  18152. }
  18153. // ID returns the ID value in the mutation. Note that the ID is only available
  18154. // if it was provided to the builder or after it was returned from the database.
  18155. func (m *MsgMutation) ID() (id uint64, exists bool) {
  18156. if m.id == nil {
  18157. return
  18158. }
  18159. return *m.id, true
  18160. }
  18161. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  18162. // That means, if the mutation is applied within a transaction with an isolation level such
  18163. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  18164. // or updated by the mutation.
  18165. func (m *MsgMutation) IDs(ctx context.Context) ([]uint64, error) {
  18166. switch {
  18167. case m.op.Is(OpUpdateOne | OpDeleteOne):
  18168. id, exists := m.ID()
  18169. if exists {
  18170. return []uint64{id}, nil
  18171. }
  18172. fallthrough
  18173. case m.op.Is(OpUpdate | OpDelete):
  18174. return m.Client().Msg.Query().Where(m.predicates...).IDs(ctx)
  18175. default:
  18176. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  18177. }
  18178. }
  18179. // SetCreatedAt sets the "created_at" field.
  18180. func (m *MsgMutation) SetCreatedAt(t time.Time) {
  18181. m.created_at = &t
  18182. }
  18183. // CreatedAt returns the value of the "created_at" field in the mutation.
  18184. func (m *MsgMutation) CreatedAt() (r time.Time, exists bool) {
  18185. v := m.created_at
  18186. if v == nil {
  18187. return
  18188. }
  18189. return *v, true
  18190. }
  18191. // OldCreatedAt returns the old "created_at" field's value of the Msg entity.
  18192. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18193. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18194. func (m *MsgMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  18195. if !m.op.Is(OpUpdateOne) {
  18196. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  18197. }
  18198. if m.id == nil || m.oldValue == nil {
  18199. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  18200. }
  18201. oldValue, err := m.oldValue(ctx)
  18202. if err != nil {
  18203. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  18204. }
  18205. return oldValue.CreatedAt, nil
  18206. }
  18207. // ResetCreatedAt resets all changes to the "created_at" field.
  18208. func (m *MsgMutation) ResetCreatedAt() {
  18209. m.created_at = nil
  18210. }
  18211. // SetUpdatedAt sets the "updated_at" field.
  18212. func (m *MsgMutation) SetUpdatedAt(t time.Time) {
  18213. m.updated_at = &t
  18214. }
  18215. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  18216. func (m *MsgMutation) UpdatedAt() (r time.Time, exists bool) {
  18217. v := m.updated_at
  18218. if v == nil {
  18219. return
  18220. }
  18221. return *v, true
  18222. }
  18223. // OldUpdatedAt returns the old "updated_at" field's value of the Msg entity.
  18224. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18226. func (m *MsgMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  18227. if !m.op.Is(OpUpdateOne) {
  18228. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  18229. }
  18230. if m.id == nil || m.oldValue == nil {
  18231. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  18232. }
  18233. oldValue, err := m.oldValue(ctx)
  18234. if err != nil {
  18235. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  18236. }
  18237. return oldValue.UpdatedAt, nil
  18238. }
  18239. // ResetUpdatedAt resets all changes to the "updated_at" field.
  18240. func (m *MsgMutation) ResetUpdatedAt() {
  18241. m.updated_at = nil
  18242. }
  18243. // SetDeletedAt sets the "deleted_at" field.
  18244. func (m *MsgMutation) SetDeletedAt(t time.Time) {
  18245. m.deleted_at = &t
  18246. }
  18247. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  18248. func (m *MsgMutation) DeletedAt() (r time.Time, exists bool) {
  18249. v := m.deleted_at
  18250. if v == nil {
  18251. return
  18252. }
  18253. return *v, true
  18254. }
  18255. // OldDeletedAt returns the old "deleted_at" field's value of the Msg entity.
  18256. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18257. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18258. func (m *MsgMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  18259. if !m.op.Is(OpUpdateOne) {
  18260. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  18261. }
  18262. if m.id == nil || m.oldValue == nil {
  18263. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  18264. }
  18265. oldValue, err := m.oldValue(ctx)
  18266. if err != nil {
  18267. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  18268. }
  18269. return oldValue.DeletedAt, nil
  18270. }
  18271. // ClearDeletedAt clears the value of the "deleted_at" field.
  18272. func (m *MsgMutation) ClearDeletedAt() {
  18273. m.deleted_at = nil
  18274. m.clearedFields[msg.FieldDeletedAt] = struct{}{}
  18275. }
  18276. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  18277. func (m *MsgMutation) DeletedAtCleared() bool {
  18278. _, ok := m.clearedFields[msg.FieldDeletedAt]
  18279. return ok
  18280. }
  18281. // ResetDeletedAt resets all changes to the "deleted_at" field.
  18282. func (m *MsgMutation) ResetDeletedAt() {
  18283. m.deleted_at = nil
  18284. delete(m.clearedFields, msg.FieldDeletedAt)
  18285. }
  18286. // SetStatus sets the "status" field.
  18287. func (m *MsgMutation) SetStatus(u uint8) {
  18288. m.status = &u
  18289. m.addstatus = nil
  18290. }
  18291. // Status returns the value of the "status" field in the mutation.
  18292. func (m *MsgMutation) Status() (r uint8, exists bool) {
  18293. v := m.status
  18294. if v == nil {
  18295. return
  18296. }
  18297. return *v, true
  18298. }
  18299. // OldStatus returns the old "status" 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) OldStatus(ctx context.Context) (v uint8, err error) {
  18303. if !m.op.Is(OpUpdateOne) {
  18304. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  18305. }
  18306. if m.id == nil || m.oldValue == nil {
  18307. return v, errors.New("OldStatus 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 OldStatus: %w", err)
  18312. }
  18313. return oldValue.Status, nil
  18314. }
  18315. // AddStatus adds u to the "status" field.
  18316. func (m *MsgMutation) AddStatus(u int8) {
  18317. if m.addstatus != nil {
  18318. *m.addstatus += u
  18319. } else {
  18320. m.addstatus = &u
  18321. }
  18322. }
  18323. // AddedStatus returns the value that was added to the "status" field in this mutation.
  18324. func (m *MsgMutation) AddedStatus() (r int8, exists bool) {
  18325. v := m.addstatus
  18326. if v == nil {
  18327. return
  18328. }
  18329. return *v, true
  18330. }
  18331. // ClearStatus clears the value of the "status" field.
  18332. func (m *MsgMutation) ClearStatus() {
  18333. m.status = nil
  18334. m.addstatus = nil
  18335. m.clearedFields[msg.FieldStatus] = struct{}{}
  18336. }
  18337. // StatusCleared returns if the "status" field was cleared in this mutation.
  18338. func (m *MsgMutation) StatusCleared() bool {
  18339. _, ok := m.clearedFields[msg.FieldStatus]
  18340. return ok
  18341. }
  18342. // ResetStatus resets all changes to the "status" field.
  18343. func (m *MsgMutation) ResetStatus() {
  18344. m.status = nil
  18345. m.addstatus = nil
  18346. delete(m.clearedFields, msg.FieldStatus)
  18347. }
  18348. // SetFromwxid sets the "fromwxid" field.
  18349. func (m *MsgMutation) SetFromwxid(s string) {
  18350. m.fromwxid = &s
  18351. }
  18352. // Fromwxid returns the value of the "fromwxid" field in the mutation.
  18353. func (m *MsgMutation) Fromwxid() (r string, exists bool) {
  18354. v := m.fromwxid
  18355. if v == nil {
  18356. return
  18357. }
  18358. return *v, true
  18359. }
  18360. // OldFromwxid returns the old "fromwxid" field's value of the Msg entity.
  18361. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18362. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18363. func (m *MsgMutation) OldFromwxid(ctx context.Context) (v string, err error) {
  18364. if !m.op.Is(OpUpdateOne) {
  18365. return v, errors.New("OldFromwxid is only allowed on UpdateOne operations")
  18366. }
  18367. if m.id == nil || m.oldValue == nil {
  18368. return v, errors.New("OldFromwxid requires an ID field in the mutation")
  18369. }
  18370. oldValue, err := m.oldValue(ctx)
  18371. if err != nil {
  18372. return v, fmt.Errorf("querying old value for OldFromwxid: %w", err)
  18373. }
  18374. return oldValue.Fromwxid, nil
  18375. }
  18376. // ClearFromwxid clears the value of the "fromwxid" field.
  18377. func (m *MsgMutation) ClearFromwxid() {
  18378. m.fromwxid = nil
  18379. m.clearedFields[msg.FieldFromwxid] = struct{}{}
  18380. }
  18381. // FromwxidCleared returns if the "fromwxid" field was cleared in this mutation.
  18382. func (m *MsgMutation) FromwxidCleared() bool {
  18383. _, ok := m.clearedFields[msg.FieldFromwxid]
  18384. return ok
  18385. }
  18386. // ResetFromwxid resets all changes to the "fromwxid" field.
  18387. func (m *MsgMutation) ResetFromwxid() {
  18388. m.fromwxid = nil
  18389. delete(m.clearedFields, msg.FieldFromwxid)
  18390. }
  18391. // SetToid sets the "toid" field.
  18392. func (m *MsgMutation) SetToid(s string) {
  18393. m.toid = &s
  18394. }
  18395. // Toid returns the value of the "toid" field in the mutation.
  18396. func (m *MsgMutation) Toid() (r string, exists bool) {
  18397. v := m.toid
  18398. if v == nil {
  18399. return
  18400. }
  18401. return *v, true
  18402. }
  18403. // OldToid returns the old "toid" field's value of the Msg entity.
  18404. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18405. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18406. func (m *MsgMutation) OldToid(ctx context.Context) (v string, err error) {
  18407. if !m.op.Is(OpUpdateOne) {
  18408. return v, errors.New("OldToid is only allowed on UpdateOne operations")
  18409. }
  18410. if m.id == nil || m.oldValue == nil {
  18411. return v, errors.New("OldToid requires an ID field in the mutation")
  18412. }
  18413. oldValue, err := m.oldValue(ctx)
  18414. if err != nil {
  18415. return v, fmt.Errorf("querying old value for OldToid: %w", err)
  18416. }
  18417. return oldValue.Toid, nil
  18418. }
  18419. // ClearToid clears the value of the "toid" field.
  18420. func (m *MsgMutation) ClearToid() {
  18421. m.toid = nil
  18422. m.clearedFields[msg.FieldToid] = struct{}{}
  18423. }
  18424. // ToidCleared returns if the "toid" field was cleared in this mutation.
  18425. func (m *MsgMutation) ToidCleared() bool {
  18426. _, ok := m.clearedFields[msg.FieldToid]
  18427. return ok
  18428. }
  18429. // ResetToid resets all changes to the "toid" field.
  18430. func (m *MsgMutation) ResetToid() {
  18431. m.toid = nil
  18432. delete(m.clearedFields, msg.FieldToid)
  18433. }
  18434. // SetMsgtype sets the "msgtype" field.
  18435. func (m *MsgMutation) SetMsgtype(i int32) {
  18436. m.msgtype = &i
  18437. m.addmsgtype = nil
  18438. }
  18439. // Msgtype returns the value of the "msgtype" field in the mutation.
  18440. func (m *MsgMutation) Msgtype() (r int32, exists bool) {
  18441. v := m.msgtype
  18442. if v == nil {
  18443. return
  18444. }
  18445. return *v, true
  18446. }
  18447. // OldMsgtype returns the old "msgtype" field's value of the Msg entity.
  18448. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18449. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18450. func (m *MsgMutation) OldMsgtype(ctx context.Context) (v int32, err error) {
  18451. if !m.op.Is(OpUpdateOne) {
  18452. return v, errors.New("OldMsgtype is only allowed on UpdateOne operations")
  18453. }
  18454. if m.id == nil || m.oldValue == nil {
  18455. return v, errors.New("OldMsgtype requires an ID field in the mutation")
  18456. }
  18457. oldValue, err := m.oldValue(ctx)
  18458. if err != nil {
  18459. return v, fmt.Errorf("querying old value for OldMsgtype: %w", err)
  18460. }
  18461. return oldValue.Msgtype, nil
  18462. }
  18463. // AddMsgtype adds i to the "msgtype" field.
  18464. func (m *MsgMutation) AddMsgtype(i int32) {
  18465. if m.addmsgtype != nil {
  18466. *m.addmsgtype += i
  18467. } else {
  18468. m.addmsgtype = &i
  18469. }
  18470. }
  18471. // AddedMsgtype returns the value that was added to the "msgtype" field in this mutation.
  18472. func (m *MsgMutation) AddedMsgtype() (r int32, exists bool) {
  18473. v := m.addmsgtype
  18474. if v == nil {
  18475. return
  18476. }
  18477. return *v, true
  18478. }
  18479. // ClearMsgtype clears the value of the "msgtype" field.
  18480. func (m *MsgMutation) ClearMsgtype() {
  18481. m.msgtype = nil
  18482. m.addmsgtype = nil
  18483. m.clearedFields[msg.FieldMsgtype] = struct{}{}
  18484. }
  18485. // MsgtypeCleared returns if the "msgtype" field was cleared in this mutation.
  18486. func (m *MsgMutation) MsgtypeCleared() bool {
  18487. _, ok := m.clearedFields[msg.FieldMsgtype]
  18488. return ok
  18489. }
  18490. // ResetMsgtype resets all changes to the "msgtype" field.
  18491. func (m *MsgMutation) ResetMsgtype() {
  18492. m.msgtype = nil
  18493. m.addmsgtype = nil
  18494. delete(m.clearedFields, msg.FieldMsgtype)
  18495. }
  18496. // SetMsg sets the "msg" field.
  18497. func (m *MsgMutation) SetMsg(s string) {
  18498. m.msg = &s
  18499. }
  18500. // Msg returns the value of the "msg" field in the mutation.
  18501. func (m *MsgMutation) Msg() (r string, exists bool) {
  18502. v := m.msg
  18503. if v == nil {
  18504. return
  18505. }
  18506. return *v, true
  18507. }
  18508. // OldMsg returns the old "msg" field's value of the Msg entity.
  18509. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18510. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18511. func (m *MsgMutation) OldMsg(ctx context.Context) (v string, err error) {
  18512. if !m.op.Is(OpUpdateOne) {
  18513. return v, errors.New("OldMsg is only allowed on UpdateOne operations")
  18514. }
  18515. if m.id == nil || m.oldValue == nil {
  18516. return v, errors.New("OldMsg requires an ID field in the mutation")
  18517. }
  18518. oldValue, err := m.oldValue(ctx)
  18519. if err != nil {
  18520. return v, fmt.Errorf("querying old value for OldMsg: %w", err)
  18521. }
  18522. return oldValue.Msg, nil
  18523. }
  18524. // ClearMsg clears the value of the "msg" field.
  18525. func (m *MsgMutation) ClearMsg() {
  18526. m.msg = nil
  18527. m.clearedFields[msg.FieldMsg] = struct{}{}
  18528. }
  18529. // MsgCleared returns if the "msg" field was cleared in this mutation.
  18530. func (m *MsgMutation) MsgCleared() bool {
  18531. _, ok := m.clearedFields[msg.FieldMsg]
  18532. return ok
  18533. }
  18534. // ResetMsg resets all changes to the "msg" field.
  18535. func (m *MsgMutation) ResetMsg() {
  18536. m.msg = nil
  18537. delete(m.clearedFields, msg.FieldMsg)
  18538. }
  18539. // SetBatchNo sets the "batch_no" field.
  18540. func (m *MsgMutation) SetBatchNo(s string) {
  18541. m.batch_no = &s
  18542. }
  18543. // BatchNo returns the value of the "batch_no" field in the mutation.
  18544. func (m *MsgMutation) BatchNo() (r string, exists bool) {
  18545. v := m.batch_no
  18546. if v == nil {
  18547. return
  18548. }
  18549. return *v, true
  18550. }
  18551. // OldBatchNo returns the old "batch_no" field's value of the Msg entity.
  18552. // If the Msg object wasn't provided to the builder, the object is fetched from the database.
  18553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  18554. func (m *MsgMutation) OldBatchNo(ctx context.Context) (v string, err error) {
  18555. if !m.op.Is(OpUpdateOne) {
  18556. return v, errors.New("OldBatchNo is only allowed on UpdateOne operations")
  18557. }
  18558. if m.id == nil || m.oldValue == nil {
  18559. return v, errors.New("OldBatchNo requires an ID field in the mutation")
  18560. }
  18561. oldValue, err := m.oldValue(ctx)
  18562. if err != nil {
  18563. return v, fmt.Errorf("querying old value for OldBatchNo: %w", err)
  18564. }
  18565. return oldValue.BatchNo, nil
  18566. }
  18567. // ClearBatchNo clears the value of the "batch_no" field.
  18568. func (m *MsgMutation) ClearBatchNo() {
  18569. m.batch_no = nil
  18570. m.clearedFields[msg.FieldBatchNo] = struct{}{}
  18571. }
  18572. // BatchNoCleared returns if the "batch_no" field was cleared in this mutation.
  18573. func (m *MsgMutation) BatchNoCleared() bool {
  18574. _, ok := m.clearedFields[msg.FieldBatchNo]
  18575. return ok
  18576. }
  18577. // ResetBatchNo resets all changes to the "batch_no" field.
  18578. func (m *MsgMutation) ResetBatchNo() {
  18579. m.batch_no = nil
  18580. delete(m.clearedFields, msg.FieldBatchNo)
  18581. }
  18582. // Where appends a list predicates to the MsgMutation builder.
  18583. func (m *MsgMutation) Where(ps ...predicate.Msg) {
  18584. m.predicates = append(m.predicates, ps...)
  18585. }
  18586. // WhereP appends storage-level predicates to the MsgMutation builder. Using this method,
  18587. // users can use type-assertion to append predicates that do not depend on any generated package.
  18588. func (m *MsgMutation) WhereP(ps ...func(*sql.Selector)) {
  18589. p := make([]predicate.Msg, len(ps))
  18590. for i := range ps {
  18591. p[i] = ps[i]
  18592. }
  18593. m.Where(p...)
  18594. }
  18595. // Op returns the operation name.
  18596. func (m *MsgMutation) Op() Op {
  18597. return m.op
  18598. }
  18599. // SetOp allows setting the mutation operation.
  18600. func (m *MsgMutation) SetOp(op Op) {
  18601. m.op = op
  18602. }
  18603. // Type returns the node type of this mutation (Msg).
  18604. func (m *MsgMutation) Type() string {
  18605. return m.typ
  18606. }
  18607. // Fields returns all fields that were changed during this mutation. Note that in
  18608. // order to get all numeric fields that were incremented/decremented, call
  18609. // AddedFields().
  18610. func (m *MsgMutation) Fields() []string {
  18611. fields := make([]string, 0, 9)
  18612. if m.created_at != nil {
  18613. fields = append(fields, msg.FieldCreatedAt)
  18614. }
  18615. if m.updated_at != nil {
  18616. fields = append(fields, msg.FieldUpdatedAt)
  18617. }
  18618. if m.deleted_at != nil {
  18619. fields = append(fields, msg.FieldDeletedAt)
  18620. }
  18621. if m.status != nil {
  18622. fields = append(fields, msg.FieldStatus)
  18623. }
  18624. if m.fromwxid != nil {
  18625. fields = append(fields, msg.FieldFromwxid)
  18626. }
  18627. if m.toid != nil {
  18628. fields = append(fields, msg.FieldToid)
  18629. }
  18630. if m.msgtype != nil {
  18631. fields = append(fields, msg.FieldMsgtype)
  18632. }
  18633. if m.msg != nil {
  18634. fields = append(fields, msg.FieldMsg)
  18635. }
  18636. if m.batch_no != nil {
  18637. fields = append(fields, msg.FieldBatchNo)
  18638. }
  18639. return fields
  18640. }
  18641. // Field returns the value of a field with the given name. The second boolean
  18642. // return value indicates that this field was not set, or was not defined in the
  18643. // schema.
  18644. func (m *MsgMutation) Field(name string) (ent.Value, bool) {
  18645. switch name {
  18646. case msg.FieldCreatedAt:
  18647. return m.CreatedAt()
  18648. case msg.FieldUpdatedAt:
  18649. return m.UpdatedAt()
  18650. case msg.FieldDeletedAt:
  18651. return m.DeletedAt()
  18652. case msg.FieldStatus:
  18653. return m.Status()
  18654. case msg.FieldFromwxid:
  18655. return m.Fromwxid()
  18656. case msg.FieldToid:
  18657. return m.Toid()
  18658. case msg.FieldMsgtype:
  18659. return m.Msgtype()
  18660. case msg.FieldMsg:
  18661. return m.Msg()
  18662. case msg.FieldBatchNo:
  18663. return m.BatchNo()
  18664. }
  18665. return nil, false
  18666. }
  18667. // OldField returns the old value of the field from the database. An error is
  18668. // returned if the mutation operation is not UpdateOne, or the query to the
  18669. // database failed.
  18670. func (m *MsgMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  18671. switch name {
  18672. case msg.FieldCreatedAt:
  18673. return m.OldCreatedAt(ctx)
  18674. case msg.FieldUpdatedAt:
  18675. return m.OldUpdatedAt(ctx)
  18676. case msg.FieldDeletedAt:
  18677. return m.OldDeletedAt(ctx)
  18678. case msg.FieldStatus:
  18679. return m.OldStatus(ctx)
  18680. case msg.FieldFromwxid:
  18681. return m.OldFromwxid(ctx)
  18682. case msg.FieldToid:
  18683. return m.OldToid(ctx)
  18684. case msg.FieldMsgtype:
  18685. return m.OldMsgtype(ctx)
  18686. case msg.FieldMsg:
  18687. return m.OldMsg(ctx)
  18688. case msg.FieldBatchNo:
  18689. return m.OldBatchNo(ctx)
  18690. }
  18691. return nil, fmt.Errorf("unknown Msg field %s", name)
  18692. }
  18693. // SetField sets the value of a field with the given name. It returns an error if
  18694. // the field is not defined in the schema, or if the type mismatched the field
  18695. // type.
  18696. func (m *MsgMutation) SetField(name string, value ent.Value) error {
  18697. switch name {
  18698. case msg.FieldCreatedAt:
  18699. v, ok := value.(time.Time)
  18700. if !ok {
  18701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18702. }
  18703. m.SetCreatedAt(v)
  18704. return nil
  18705. case msg.FieldUpdatedAt:
  18706. v, ok := value.(time.Time)
  18707. if !ok {
  18708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18709. }
  18710. m.SetUpdatedAt(v)
  18711. return nil
  18712. case msg.FieldDeletedAt:
  18713. v, ok := value.(time.Time)
  18714. if !ok {
  18715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18716. }
  18717. m.SetDeletedAt(v)
  18718. return nil
  18719. case msg.FieldStatus:
  18720. v, ok := value.(uint8)
  18721. if !ok {
  18722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18723. }
  18724. m.SetStatus(v)
  18725. return nil
  18726. case msg.FieldFromwxid:
  18727. v, ok := value.(string)
  18728. if !ok {
  18729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18730. }
  18731. m.SetFromwxid(v)
  18732. return nil
  18733. case msg.FieldToid:
  18734. v, ok := value.(string)
  18735. if !ok {
  18736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18737. }
  18738. m.SetToid(v)
  18739. return nil
  18740. case msg.FieldMsgtype:
  18741. v, ok := value.(int32)
  18742. if !ok {
  18743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18744. }
  18745. m.SetMsgtype(v)
  18746. return nil
  18747. case msg.FieldMsg:
  18748. v, ok := value.(string)
  18749. if !ok {
  18750. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18751. }
  18752. m.SetMsg(v)
  18753. return nil
  18754. case msg.FieldBatchNo:
  18755. v, ok := value.(string)
  18756. if !ok {
  18757. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18758. }
  18759. m.SetBatchNo(v)
  18760. return nil
  18761. }
  18762. return fmt.Errorf("unknown Msg field %s", name)
  18763. }
  18764. // AddedFields returns all numeric fields that were incremented/decremented during
  18765. // this mutation.
  18766. func (m *MsgMutation) AddedFields() []string {
  18767. var fields []string
  18768. if m.addstatus != nil {
  18769. fields = append(fields, msg.FieldStatus)
  18770. }
  18771. if m.addmsgtype != nil {
  18772. fields = append(fields, msg.FieldMsgtype)
  18773. }
  18774. return fields
  18775. }
  18776. // AddedField returns the numeric value that was incremented/decremented on a field
  18777. // with the given name. The second boolean return value indicates that this field
  18778. // was not set, or was not defined in the schema.
  18779. func (m *MsgMutation) AddedField(name string) (ent.Value, bool) {
  18780. switch name {
  18781. case msg.FieldStatus:
  18782. return m.AddedStatus()
  18783. case msg.FieldMsgtype:
  18784. return m.AddedMsgtype()
  18785. }
  18786. return nil, false
  18787. }
  18788. // AddField adds the value to the field with the given name. It returns an error if
  18789. // the field is not defined in the schema, or if the type mismatched the field
  18790. // type.
  18791. func (m *MsgMutation) AddField(name string, value ent.Value) error {
  18792. switch name {
  18793. case msg.FieldStatus:
  18794. v, ok := value.(int8)
  18795. if !ok {
  18796. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18797. }
  18798. m.AddStatus(v)
  18799. return nil
  18800. case msg.FieldMsgtype:
  18801. v, ok := value.(int32)
  18802. if !ok {
  18803. return fmt.Errorf("unexpected type %T for field %s", value, name)
  18804. }
  18805. m.AddMsgtype(v)
  18806. return nil
  18807. }
  18808. return fmt.Errorf("unknown Msg numeric field %s", name)
  18809. }
  18810. // ClearedFields returns all nullable fields that were cleared during this
  18811. // mutation.
  18812. func (m *MsgMutation) ClearedFields() []string {
  18813. var fields []string
  18814. if m.FieldCleared(msg.FieldDeletedAt) {
  18815. fields = append(fields, msg.FieldDeletedAt)
  18816. }
  18817. if m.FieldCleared(msg.FieldStatus) {
  18818. fields = append(fields, msg.FieldStatus)
  18819. }
  18820. if m.FieldCleared(msg.FieldFromwxid) {
  18821. fields = append(fields, msg.FieldFromwxid)
  18822. }
  18823. if m.FieldCleared(msg.FieldToid) {
  18824. fields = append(fields, msg.FieldToid)
  18825. }
  18826. if m.FieldCleared(msg.FieldMsgtype) {
  18827. fields = append(fields, msg.FieldMsgtype)
  18828. }
  18829. if m.FieldCleared(msg.FieldMsg) {
  18830. fields = append(fields, msg.FieldMsg)
  18831. }
  18832. if m.FieldCleared(msg.FieldBatchNo) {
  18833. fields = append(fields, msg.FieldBatchNo)
  18834. }
  18835. return fields
  18836. }
  18837. // FieldCleared returns a boolean indicating if a field with the given name was
  18838. // cleared in this mutation.
  18839. func (m *MsgMutation) FieldCleared(name string) bool {
  18840. _, ok := m.clearedFields[name]
  18841. return ok
  18842. }
  18843. // ClearField clears the value of the field with the given name. It returns an
  18844. // error if the field is not defined in the schema.
  18845. func (m *MsgMutation) ClearField(name string) error {
  18846. switch name {
  18847. case msg.FieldDeletedAt:
  18848. m.ClearDeletedAt()
  18849. return nil
  18850. case msg.FieldStatus:
  18851. m.ClearStatus()
  18852. return nil
  18853. case msg.FieldFromwxid:
  18854. m.ClearFromwxid()
  18855. return nil
  18856. case msg.FieldToid:
  18857. m.ClearToid()
  18858. return nil
  18859. case msg.FieldMsgtype:
  18860. m.ClearMsgtype()
  18861. return nil
  18862. case msg.FieldMsg:
  18863. m.ClearMsg()
  18864. return nil
  18865. case msg.FieldBatchNo:
  18866. m.ClearBatchNo()
  18867. return nil
  18868. }
  18869. return fmt.Errorf("unknown Msg nullable field %s", name)
  18870. }
  18871. // ResetField resets all changes in the mutation for the field with the given name.
  18872. // It returns an error if the field is not defined in the schema.
  18873. func (m *MsgMutation) ResetField(name string) error {
  18874. switch name {
  18875. case msg.FieldCreatedAt:
  18876. m.ResetCreatedAt()
  18877. return nil
  18878. case msg.FieldUpdatedAt:
  18879. m.ResetUpdatedAt()
  18880. return nil
  18881. case msg.FieldDeletedAt:
  18882. m.ResetDeletedAt()
  18883. return nil
  18884. case msg.FieldStatus:
  18885. m.ResetStatus()
  18886. return nil
  18887. case msg.FieldFromwxid:
  18888. m.ResetFromwxid()
  18889. return nil
  18890. case msg.FieldToid:
  18891. m.ResetToid()
  18892. return nil
  18893. case msg.FieldMsgtype:
  18894. m.ResetMsgtype()
  18895. return nil
  18896. case msg.FieldMsg:
  18897. m.ResetMsg()
  18898. return nil
  18899. case msg.FieldBatchNo:
  18900. m.ResetBatchNo()
  18901. return nil
  18902. }
  18903. return fmt.Errorf("unknown Msg field %s", name)
  18904. }
  18905. // AddedEdges returns all edge names that were set/added in this mutation.
  18906. func (m *MsgMutation) AddedEdges() []string {
  18907. edges := make([]string, 0, 0)
  18908. return edges
  18909. }
  18910. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  18911. // name in this mutation.
  18912. func (m *MsgMutation) AddedIDs(name string) []ent.Value {
  18913. return nil
  18914. }
  18915. // RemovedEdges returns all edge names that were removed in this mutation.
  18916. func (m *MsgMutation) RemovedEdges() []string {
  18917. edges := make([]string, 0, 0)
  18918. return edges
  18919. }
  18920. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  18921. // the given name in this mutation.
  18922. func (m *MsgMutation) RemovedIDs(name string) []ent.Value {
  18923. return nil
  18924. }
  18925. // ClearedEdges returns all edge names that were cleared in this mutation.
  18926. func (m *MsgMutation) ClearedEdges() []string {
  18927. edges := make([]string, 0, 0)
  18928. return edges
  18929. }
  18930. // EdgeCleared returns a boolean which indicates if the edge with the given name
  18931. // was cleared in this mutation.
  18932. func (m *MsgMutation) EdgeCleared(name string) bool {
  18933. return false
  18934. }
  18935. // ClearEdge clears the value of the edge with the given name. It returns an error
  18936. // if that edge is not defined in the schema.
  18937. func (m *MsgMutation) ClearEdge(name string) error {
  18938. return fmt.Errorf("unknown Msg unique edge %s", name)
  18939. }
  18940. // ResetEdge resets all changes to the edge with the given name in this mutation.
  18941. // It returns an error if the edge is not defined in the schema.
  18942. func (m *MsgMutation) ResetEdge(name string) error {
  18943. return fmt.Errorf("unknown Msg edge %s", name)
  18944. }
  18945. // PayRechargeMutation represents an operation that mutates the PayRecharge nodes in the graph.
  18946. type PayRechargeMutation struct {
  18947. config
  18948. op Op
  18949. typ string
  18950. id *uint64
  18951. created_at *time.Time
  18952. updated_at *time.Time
  18953. deleted_at *time.Time
  18954. user_id *string
  18955. number *float32
  18956. addnumber *float32
  18957. status *int
  18958. addstatus *int
  18959. money *float32
  18960. addmoney *float32
  18961. out_trade_no *string
  18962. organization_id *uint64
  18963. addorganization_id *int64
  18964. clearedFields map[string]struct{}
  18965. done bool
  18966. oldValue func(context.Context) (*PayRecharge, error)
  18967. predicates []predicate.PayRecharge
  18968. }
  18969. var _ ent.Mutation = (*PayRechargeMutation)(nil)
  18970. // payrechargeOption allows management of the mutation configuration using functional options.
  18971. type payrechargeOption func(*PayRechargeMutation)
  18972. // newPayRechargeMutation creates new mutation for the PayRecharge entity.
  18973. func newPayRechargeMutation(c config, op Op, opts ...payrechargeOption) *PayRechargeMutation {
  18974. m := &PayRechargeMutation{
  18975. config: c,
  18976. op: op,
  18977. typ: TypePayRecharge,
  18978. clearedFields: make(map[string]struct{}),
  18979. }
  18980. for _, opt := range opts {
  18981. opt(m)
  18982. }
  18983. return m
  18984. }
  18985. // withPayRechargeID sets the ID field of the mutation.
  18986. func withPayRechargeID(id uint64) payrechargeOption {
  18987. return func(m *PayRechargeMutation) {
  18988. var (
  18989. err error
  18990. once sync.Once
  18991. value *PayRecharge
  18992. )
  18993. m.oldValue = func(ctx context.Context) (*PayRecharge, error) {
  18994. once.Do(func() {
  18995. if m.done {
  18996. err = errors.New("querying old values post mutation is not allowed")
  18997. } else {
  18998. value, err = m.Client().PayRecharge.Get(ctx, id)
  18999. }
  19000. })
  19001. return value, err
  19002. }
  19003. m.id = &id
  19004. }
  19005. }
  19006. // withPayRecharge sets the old PayRecharge of the mutation.
  19007. func withPayRecharge(node *PayRecharge) payrechargeOption {
  19008. return func(m *PayRechargeMutation) {
  19009. m.oldValue = func(context.Context) (*PayRecharge, error) {
  19010. return node, nil
  19011. }
  19012. m.id = &node.ID
  19013. }
  19014. }
  19015. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19016. // executed in a transaction (ent.Tx), a transactional client is returned.
  19017. func (m PayRechargeMutation) Client() *Client {
  19018. client := &Client{config: m.config}
  19019. client.init()
  19020. return client
  19021. }
  19022. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19023. // it returns an error otherwise.
  19024. func (m PayRechargeMutation) Tx() (*Tx, error) {
  19025. if _, ok := m.driver.(*txDriver); !ok {
  19026. return nil, errors.New("ent: mutation is not running in a transaction")
  19027. }
  19028. tx := &Tx{config: m.config}
  19029. tx.init()
  19030. return tx, nil
  19031. }
  19032. // SetID sets the value of the id field. Note that this
  19033. // operation is only accepted on creation of PayRecharge entities.
  19034. func (m *PayRechargeMutation) SetID(id uint64) {
  19035. m.id = &id
  19036. }
  19037. // ID returns the ID value in the mutation. Note that the ID is only available
  19038. // if it was provided to the builder or after it was returned from the database.
  19039. func (m *PayRechargeMutation) ID() (id uint64, exists bool) {
  19040. if m.id == nil {
  19041. return
  19042. }
  19043. return *m.id, true
  19044. }
  19045. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19046. // That means, if the mutation is applied within a transaction with an isolation level such
  19047. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19048. // or updated by the mutation.
  19049. func (m *PayRechargeMutation) IDs(ctx context.Context) ([]uint64, error) {
  19050. switch {
  19051. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19052. id, exists := m.ID()
  19053. if exists {
  19054. return []uint64{id}, nil
  19055. }
  19056. fallthrough
  19057. case m.op.Is(OpUpdate | OpDelete):
  19058. return m.Client().PayRecharge.Query().Where(m.predicates...).IDs(ctx)
  19059. default:
  19060. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19061. }
  19062. }
  19063. // SetCreatedAt sets the "created_at" field.
  19064. func (m *PayRechargeMutation) SetCreatedAt(t time.Time) {
  19065. m.created_at = &t
  19066. }
  19067. // CreatedAt returns the value of the "created_at" field in the mutation.
  19068. func (m *PayRechargeMutation) CreatedAt() (r time.Time, exists bool) {
  19069. v := m.created_at
  19070. if v == nil {
  19071. return
  19072. }
  19073. return *v, true
  19074. }
  19075. // OldCreatedAt returns the old "created_at" field's value of the PayRecharge entity.
  19076. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19077. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19078. func (m *PayRechargeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19079. if !m.op.Is(OpUpdateOne) {
  19080. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19081. }
  19082. if m.id == nil || m.oldValue == nil {
  19083. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19084. }
  19085. oldValue, err := m.oldValue(ctx)
  19086. if err != nil {
  19087. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19088. }
  19089. return oldValue.CreatedAt, nil
  19090. }
  19091. // ResetCreatedAt resets all changes to the "created_at" field.
  19092. func (m *PayRechargeMutation) ResetCreatedAt() {
  19093. m.created_at = nil
  19094. }
  19095. // SetUpdatedAt sets the "updated_at" field.
  19096. func (m *PayRechargeMutation) SetUpdatedAt(t time.Time) {
  19097. m.updated_at = &t
  19098. }
  19099. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19100. func (m *PayRechargeMutation) UpdatedAt() (r time.Time, exists bool) {
  19101. v := m.updated_at
  19102. if v == nil {
  19103. return
  19104. }
  19105. return *v, true
  19106. }
  19107. // OldUpdatedAt returns the old "updated_at" field's value of the PayRecharge entity.
  19108. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19110. func (m *PayRechargeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  19111. if !m.op.Is(OpUpdateOne) {
  19112. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  19113. }
  19114. if m.id == nil || m.oldValue == nil {
  19115. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  19116. }
  19117. oldValue, err := m.oldValue(ctx)
  19118. if err != nil {
  19119. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  19120. }
  19121. return oldValue.UpdatedAt, nil
  19122. }
  19123. // ResetUpdatedAt resets all changes to the "updated_at" field.
  19124. func (m *PayRechargeMutation) ResetUpdatedAt() {
  19125. m.updated_at = nil
  19126. }
  19127. // SetDeletedAt sets the "deleted_at" field.
  19128. func (m *PayRechargeMutation) SetDeletedAt(t time.Time) {
  19129. m.deleted_at = &t
  19130. }
  19131. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  19132. func (m *PayRechargeMutation) DeletedAt() (r time.Time, exists bool) {
  19133. v := m.deleted_at
  19134. if v == nil {
  19135. return
  19136. }
  19137. return *v, true
  19138. }
  19139. // OldDeletedAt returns the old "deleted_at" field's value of the PayRecharge entity.
  19140. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19141. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19142. func (m *PayRechargeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  19143. if !m.op.Is(OpUpdateOne) {
  19144. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  19145. }
  19146. if m.id == nil || m.oldValue == nil {
  19147. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  19148. }
  19149. oldValue, err := m.oldValue(ctx)
  19150. if err != nil {
  19151. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  19152. }
  19153. return oldValue.DeletedAt, nil
  19154. }
  19155. // ClearDeletedAt clears the value of the "deleted_at" field.
  19156. func (m *PayRechargeMutation) ClearDeletedAt() {
  19157. m.deleted_at = nil
  19158. m.clearedFields[payrecharge.FieldDeletedAt] = struct{}{}
  19159. }
  19160. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  19161. func (m *PayRechargeMutation) DeletedAtCleared() bool {
  19162. _, ok := m.clearedFields[payrecharge.FieldDeletedAt]
  19163. return ok
  19164. }
  19165. // ResetDeletedAt resets all changes to the "deleted_at" field.
  19166. func (m *PayRechargeMutation) ResetDeletedAt() {
  19167. m.deleted_at = nil
  19168. delete(m.clearedFields, payrecharge.FieldDeletedAt)
  19169. }
  19170. // SetUserID sets the "user_id" field.
  19171. func (m *PayRechargeMutation) SetUserID(s string) {
  19172. m.user_id = &s
  19173. }
  19174. // UserID returns the value of the "user_id" field in the mutation.
  19175. func (m *PayRechargeMutation) UserID() (r string, exists bool) {
  19176. v := m.user_id
  19177. if v == nil {
  19178. return
  19179. }
  19180. return *v, true
  19181. }
  19182. // OldUserID returns the old "user_id" field's value of the PayRecharge entity.
  19183. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19184. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19185. func (m *PayRechargeMutation) OldUserID(ctx context.Context) (v string, err error) {
  19186. if !m.op.Is(OpUpdateOne) {
  19187. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  19188. }
  19189. if m.id == nil || m.oldValue == nil {
  19190. return v, errors.New("OldUserID requires an ID field in the mutation")
  19191. }
  19192. oldValue, err := m.oldValue(ctx)
  19193. if err != nil {
  19194. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  19195. }
  19196. return oldValue.UserID, nil
  19197. }
  19198. // ResetUserID resets all changes to the "user_id" field.
  19199. func (m *PayRechargeMutation) ResetUserID() {
  19200. m.user_id = nil
  19201. }
  19202. // SetNumber sets the "number" field.
  19203. func (m *PayRechargeMutation) SetNumber(f float32) {
  19204. m.number = &f
  19205. m.addnumber = nil
  19206. }
  19207. // Number returns the value of the "number" field in the mutation.
  19208. func (m *PayRechargeMutation) Number() (r float32, exists bool) {
  19209. v := m.number
  19210. if v == nil {
  19211. return
  19212. }
  19213. return *v, true
  19214. }
  19215. // OldNumber returns the old "number" 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) OldNumber(ctx context.Context) (v float32, err error) {
  19219. if !m.op.Is(OpUpdateOne) {
  19220. return v, errors.New("OldNumber is only allowed on UpdateOne operations")
  19221. }
  19222. if m.id == nil || m.oldValue == nil {
  19223. return v, errors.New("OldNumber 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 OldNumber: %w", err)
  19228. }
  19229. return oldValue.Number, nil
  19230. }
  19231. // AddNumber adds f to the "number" field.
  19232. func (m *PayRechargeMutation) AddNumber(f float32) {
  19233. if m.addnumber != nil {
  19234. *m.addnumber += f
  19235. } else {
  19236. m.addnumber = &f
  19237. }
  19238. }
  19239. // AddedNumber returns the value that was added to the "number" field in this mutation.
  19240. func (m *PayRechargeMutation) AddedNumber() (r float32, exists bool) {
  19241. v := m.addnumber
  19242. if v == nil {
  19243. return
  19244. }
  19245. return *v, true
  19246. }
  19247. // ResetNumber resets all changes to the "number" field.
  19248. func (m *PayRechargeMutation) ResetNumber() {
  19249. m.number = nil
  19250. m.addnumber = nil
  19251. }
  19252. // SetStatus sets the "status" field.
  19253. func (m *PayRechargeMutation) SetStatus(i int) {
  19254. m.status = &i
  19255. m.addstatus = nil
  19256. }
  19257. // Status returns the value of the "status" field in the mutation.
  19258. func (m *PayRechargeMutation) Status() (r int, exists bool) {
  19259. v := m.status
  19260. if v == nil {
  19261. return
  19262. }
  19263. return *v, true
  19264. }
  19265. // OldStatus returns the old "status" field's value of the PayRecharge entity.
  19266. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19267. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19268. func (m *PayRechargeMutation) OldStatus(ctx context.Context) (v int, err error) {
  19269. if !m.op.Is(OpUpdateOne) {
  19270. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  19271. }
  19272. if m.id == nil || m.oldValue == nil {
  19273. return v, errors.New("OldStatus requires an ID field in the mutation")
  19274. }
  19275. oldValue, err := m.oldValue(ctx)
  19276. if err != nil {
  19277. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  19278. }
  19279. return oldValue.Status, nil
  19280. }
  19281. // AddStatus adds i to the "status" field.
  19282. func (m *PayRechargeMutation) AddStatus(i int) {
  19283. if m.addstatus != nil {
  19284. *m.addstatus += i
  19285. } else {
  19286. m.addstatus = &i
  19287. }
  19288. }
  19289. // AddedStatus returns the value that was added to the "status" field in this mutation.
  19290. func (m *PayRechargeMutation) AddedStatus() (r int, exists bool) {
  19291. v := m.addstatus
  19292. if v == nil {
  19293. return
  19294. }
  19295. return *v, true
  19296. }
  19297. // ClearStatus clears the value of the "status" field.
  19298. func (m *PayRechargeMutation) ClearStatus() {
  19299. m.status = nil
  19300. m.addstatus = nil
  19301. m.clearedFields[payrecharge.FieldStatus] = struct{}{}
  19302. }
  19303. // StatusCleared returns if the "status" field was cleared in this mutation.
  19304. func (m *PayRechargeMutation) StatusCleared() bool {
  19305. _, ok := m.clearedFields[payrecharge.FieldStatus]
  19306. return ok
  19307. }
  19308. // ResetStatus resets all changes to the "status" field.
  19309. func (m *PayRechargeMutation) ResetStatus() {
  19310. m.status = nil
  19311. m.addstatus = nil
  19312. delete(m.clearedFields, payrecharge.FieldStatus)
  19313. }
  19314. // SetMoney sets the "money" field.
  19315. func (m *PayRechargeMutation) SetMoney(f float32) {
  19316. m.money = &f
  19317. m.addmoney = nil
  19318. }
  19319. // Money returns the value of the "money" field in the mutation.
  19320. func (m *PayRechargeMutation) Money() (r float32, exists bool) {
  19321. v := m.money
  19322. if v == nil {
  19323. return
  19324. }
  19325. return *v, true
  19326. }
  19327. // OldMoney returns the old "money" field's value of the PayRecharge entity.
  19328. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19329. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19330. func (m *PayRechargeMutation) OldMoney(ctx context.Context) (v float32, err error) {
  19331. if !m.op.Is(OpUpdateOne) {
  19332. return v, errors.New("OldMoney is only allowed on UpdateOne operations")
  19333. }
  19334. if m.id == nil || m.oldValue == nil {
  19335. return v, errors.New("OldMoney requires an ID field in the mutation")
  19336. }
  19337. oldValue, err := m.oldValue(ctx)
  19338. if err != nil {
  19339. return v, fmt.Errorf("querying old value for OldMoney: %w", err)
  19340. }
  19341. return oldValue.Money, nil
  19342. }
  19343. // AddMoney adds f to the "money" field.
  19344. func (m *PayRechargeMutation) AddMoney(f float32) {
  19345. if m.addmoney != nil {
  19346. *m.addmoney += f
  19347. } else {
  19348. m.addmoney = &f
  19349. }
  19350. }
  19351. // AddedMoney returns the value that was added to the "money" field in this mutation.
  19352. func (m *PayRechargeMutation) AddedMoney() (r float32, exists bool) {
  19353. v := m.addmoney
  19354. if v == nil {
  19355. return
  19356. }
  19357. return *v, true
  19358. }
  19359. // ClearMoney clears the value of the "money" field.
  19360. func (m *PayRechargeMutation) ClearMoney() {
  19361. m.money = nil
  19362. m.addmoney = nil
  19363. m.clearedFields[payrecharge.FieldMoney] = struct{}{}
  19364. }
  19365. // MoneyCleared returns if the "money" field was cleared in this mutation.
  19366. func (m *PayRechargeMutation) MoneyCleared() bool {
  19367. _, ok := m.clearedFields[payrecharge.FieldMoney]
  19368. return ok
  19369. }
  19370. // ResetMoney resets all changes to the "money" field.
  19371. func (m *PayRechargeMutation) ResetMoney() {
  19372. m.money = nil
  19373. m.addmoney = nil
  19374. delete(m.clearedFields, payrecharge.FieldMoney)
  19375. }
  19376. // SetOutTradeNo sets the "out_trade_no" field.
  19377. func (m *PayRechargeMutation) SetOutTradeNo(s string) {
  19378. m.out_trade_no = &s
  19379. }
  19380. // OutTradeNo returns the value of the "out_trade_no" field in the mutation.
  19381. func (m *PayRechargeMutation) OutTradeNo() (r string, exists bool) {
  19382. v := m.out_trade_no
  19383. if v == nil {
  19384. return
  19385. }
  19386. return *v, true
  19387. }
  19388. // OldOutTradeNo returns the old "out_trade_no" field's value of the PayRecharge entity.
  19389. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19391. func (m *PayRechargeMutation) OldOutTradeNo(ctx context.Context) (v string, err error) {
  19392. if !m.op.Is(OpUpdateOne) {
  19393. return v, errors.New("OldOutTradeNo is only allowed on UpdateOne operations")
  19394. }
  19395. if m.id == nil || m.oldValue == nil {
  19396. return v, errors.New("OldOutTradeNo requires an ID field in the mutation")
  19397. }
  19398. oldValue, err := m.oldValue(ctx)
  19399. if err != nil {
  19400. return v, fmt.Errorf("querying old value for OldOutTradeNo: %w", err)
  19401. }
  19402. return oldValue.OutTradeNo, nil
  19403. }
  19404. // ClearOutTradeNo clears the value of the "out_trade_no" field.
  19405. func (m *PayRechargeMutation) ClearOutTradeNo() {
  19406. m.out_trade_no = nil
  19407. m.clearedFields[payrecharge.FieldOutTradeNo] = struct{}{}
  19408. }
  19409. // OutTradeNoCleared returns if the "out_trade_no" field was cleared in this mutation.
  19410. func (m *PayRechargeMutation) OutTradeNoCleared() bool {
  19411. _, ok := m.clearedFields[payrecharge.FieldOutTradeNo]
  19412. return ok
  19413. }
  19414. // ResetOutTradeNo resets all changes to the "out_trade_no" field.
  19415. func (m *PayRechargeMutation) ResetOutTradeNo() {
  19416. m.out_trade_no = nil
  19417. delete(m.clearedFields, payrecharge.FieldOutTradeNo)
  19418. }
  19419. // SetOrganizationID sets the "organization_id" field.
  19420. func (m *PayRechargeMutation) SetOrganizationID(u uint64) {
  19421. m.organization_id = &u
  19422. m.addorganization_id = nil
  19423. }
  19424. // OrganizationID returns the value of the "organization_id" field in the mutation.
  19425. func (m *PayRechargeMutation) OrganizationID() (r uint64, exists bool) {
  19426. v := m.organization_id
  19427. if v == nil {
  19428. return
  19429. }
  19430. return *v, true
  19431. }
  19432. // OldOrganizationID returns the old "organization_id" field's value of the PayRecharge entity.
  19433. // If the PayRecharge object wasn't provided to the builder, the object is fetched from the database.
  19434. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19435. func (m *PayRechargeMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  19436. if !m.op.Is(OpUpdateOne) {
  19437. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  19438. }
  19439. if m.id == nil || m.oldValue == nil {
  19440. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  19441. }
  19442. oldValue, err := m.oldValue(ctx)
  19443. if err != nil {
  19444. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  19445. }
  19446. return oldValue.OrganizationID, nil
  19447. }
  19448. // AddOrganizationID adds u to the "organization_id" field.
  19449. func (m *PayRechargeMutation) AddOrganizationID(u int64) {
  19450. if m.addorganization_id != nil {
  19451. *m.addorganization_id += u
  19452. } else {
  19453. m.addorganization_id = &u
  19454. }
  19455. }
  19456. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  19457. func (m *PayRechargeMutation) AddedOrganizationID() (r int64, exists bool) {
  19458. v := m.addorganization_id
  19459. if v == nil {
  19460. return
  19461. }
  19462. return *v, true
  19463. }
  19464. // ResetOrganizationID resets all changes to the "organization_id" field.
  19465. func (m *PayRechargeMutation) ResetOrganizationID() {
  19466. m.organization_id = nil
  19467. m.addorganization_id = nil
  19468. }
  19469. // Where appends a list predicates to the PayRechargeMutation builder.
  19470. func (m *PayRechargeMutation) Where(ps ...predicate.PayRecharge) {
  19471. m.predicates = append(m.predicates, ps...)
  19472. }
  19473. // WhereP appends storage-level predicates to the PayRechargeMutation builder. Using this method,
  19474. // users can use type-assertion to append predicates that do not depend on any generated package.
  19475. func (m *PayRechargeMutation) WhereP(ps ...func(*sql.Selector)) {
  19476. p := make([]predicate.PayRecharge, len(ps))
  19477. for i := range ps {
  19478. p[i] = ps[i]
  19479. }
  19480. m.Where(p...)
  19481. }
  19482. // Op returns the operation name.
  19483. func (m *PayRechargeMutation) Op() Op {
  19484. return m.op
  19485. }
  19486. // SetOp allows setting the mutation operation.
  19487. func (m *PayRechargeMutation) SetOp(op Op) {
  19488. m.op = op
  19489. }
  19490. // Type returns the node type of this mutation (PayRecharge).
  19491. func (m *PayRechargeMutation) Type() string {
  19492. return m.typ
  19493. }
  19494. // Fields returns all fields that were changed during this mutation. Note that in
  19495. // order to get all numeric fields that were incremented/decremented, call
  19496. // AddedFields().
  19497. func (m *PayRechargeMutation) Fields() []string {
  19498. fields := make([]string, 0, 9)
  19499. if m.created_at != nil {
  19500. fields = append(fields, payrecharge.FieldCreatedAt)
  19501. }
  19502. if m.updated_at != nil {
  19503. fields = append(fields, payrecharge.FieldUpdatedAt)
  19504. }
  19505. if m.deleted_at != nil {
  19506. fields = append(fields, payrecharge.FieldDeletedAt)
  19507. }
  19508. if m.user_id != nil {
  19509. fields = append(fields, payrecharge.FieldUserID)
  19510. }
  19511. if m.number != nil {
  19512. fields = append(fields, payrecharge.FieldNumber)
  19513. }
  19514. if m.status != nil {
  19515. fields = append(fields, payrecharge.FieldStatus)
  19516. }
  19517. if m.money != nil {
  19518. fields = append(fields, payrecharge.FieldMoney)
  19519. }
  19520. if m.out_trade_no != nil {
  19521. fields = append(fields, payrecharge.FieldOutTradeNo)
  19522. }
  19523. if m.organization_id != nil {
  19524. fields = append(fields, payrecharge.FieldOrganizationID)
  19525. }
  19526. return fields
  19527. }
  19528. // Field returns the value of a field with the given name. The second boolean
  19529. // return value indicates that this field was not set, or was not defined in the
  19530. // schema.
  19531. func (m *PayRechargeMutation) Field(name string) (ent.Value, bool) {
  19532. switch name {
  19533. case payrecharge.FieldCreatedAt:
  19534. return m.CreatedAt()
  19535. case payrecharge.FieldUpdatedAt:
  19536. return m.UpdatedAt()
  19537. case payrecharge.FieldDeletedAt:
  19538. return m.DeletedAt()
  19539. case payrecharge.FieldUserID:
  19540. return m.UserID()
  19541. case payrecharge.FieldNumber:
  19542. return m.Number()
  19543. case payrecharge.FieldStatus:
  19544. return m.Status()
  19545. case payrecharge.FieldMoney:
  19546. return m.Money()
  19547. case payrecharge.FieldOutTradeNo:
  19548. return m.OutTradeNo()
  19549. case payrecharge.FieldOrganizationID:
  19550. return m.OrganizationID()
  19551. }
  19552. return nil, false
  19553. }
  19554. // OldField returns the old value of the field from the database. An error is
  19555. // returned if the mutation operation is not UpdateOne, or the query to the
  19556. // database failed.
  19557. func (m *PayRechargeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  19558. switch name {
  19559. case payrecharge.FieldCreatedAt:
  19560. return m.OldCreatedAt(ctx)
  19561. case payrecharge.FieldUpdatedAt:
  19562. return m.OldUpdatedAt(ctx)
  19563. case payrecharge.FieldDeletedAt:
  19564. return m.OldDeletedAt(ctx)
  19565. case payrecharge.FieldUserID:
  19566. return m.OldUserID(ctx)
  19567. case payrecharge.FieldNumber:
  19568. return m.OldNumber(ctx)
  19569. case payrecharge.FieldStatus:
  19570. return m.OldStatus(ctx)
  19571. case payrecharge.FieldMoney:
  19572. return m.OldMoney(ctx)
  19573. case payrecharge.FieldOutTradeNo:
  19574. return m.OldOutTradeNo(ctx)
  19575. case payrecharge.FieldOrganizationID:
  19576. return m.OldOrganizationID(ctx)
  19577. }
  19578. return nil, fmt.Errorf("unknown PayRecharge field %s", name)
  19579. }
  19580. // SetField sets the value of a field with the given name. It returns an error if
  19581. // the field is not defined in the schema, or if the type mismatched the field
  19582. // type.
  19583. func (m *PayRechargeMutation) SetField(name string, value ent.Value) error {
  19584. switch name {
  19585. case payrecharge.FieldCreatedAt:
  19586. v, ok := value.(time.Time)
  19587. if !ok {
  19588. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19589. }
  19590. m.SetCreatedAt(v)
  19591. return nil
  19592. case payrecharge.FieldUpdatedAt:
  19593. v, ok := value.(time.Time)
  19594. if !ok {
  19595. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19596. }
  19597. m.SetUpdatedAt(v)
  19598. return nil
  19599. case payrecharge.FieldDeletedAt:
  19600. v, ok := value.(time.Time)
  19601. if !ok {
  19602. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19603. }
  19604. m.SetDeletedAt(v)
  19605. return nil
  19606. case payrecharge.FieldUserID:
  19607. v, ok := value.(string)
  19608. if !ok {
  19609. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19610. }
  19611. m.SetUserID(v)
  19612. return nil
  19613. case payrecharge.FieldNumber:
  19614. v, ok := value.(float32)
  19615. if !ok {
  19616. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19617. }
  19618. m.SetNumber(v)
  19619. return nil
  19620. case payrecharge.FieldStatus:
  19621. v, ok := value.(int)
  19622. if !ok {
  19623. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19624. }
  19625. m.SetStatus(v)
  19626. return nil
  19627. case payrecharge.FieldMoney:
  19628. v, ok := value.(float32)
  19629. if !ok {
  19630. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19631. }
  19632. m.SetMoney(v)
  19633. return nil
  19634. case payrecharge.FieldOutTradeNo:
  19635. v, ok := value.(string)
  19636. if !ok {
  19637. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19638. }
  19639. m.SetOutTradeNo(v)
  19640. return nil
  19641. case payrecharge.FieldOrganizationID:
  19642. v, ok := value.(uint64)
  19643. if !ok {
  19644. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19645. }
  19646. m.SetOrganizationID(v)
  19647. return nil
  19648. }
  19649. return fmt.Errorf("unknown PayRecharge field %s", name)
  19650. }
  19651. // AddedFields returns all numeric fields that were incremented/decremented during
  19652. // this mutation.
  19653. func (m *PayRechargeMutation) AddedFields() []string {
  19654. var fields []string
  19655. if m.addnumber != nil {
  19656. fields = append(fields, payrecharge.FieldNumber)
  19657. }
  19658. if m.addstatus != nil {
  19659. fields = append(fields, payrecharge.FieldStatus)
  19660. }
  19661. if m.addmoney != nil {
  19662. fields = append(fields, payrecharge.FieldMoney)
  19663. }
  19664. if m.addorganization_id != nil {
  19665. fields = append(fields, payrecharge.FieldOrganizationID)
  19666. }
  19667. return fields
  19668. }
  19669. // AddedField returns the numeric value that was incremented/decremented on a field
  19670. // with the given name. The second boolean return value indicates that this field
  19671. // was not set, or was not defined in the schema.
  19672. func (m *PayRechargeMutation) AddedField(name string) (ent.Value, bool) {
  19673. switch name {
  19674. case payrecharge.FieldNumber:
  19675. return m.AddedNumber()
  19676. case payrecharge.FieldStatus:
  19677. return m.AddedStatus()
  19678. case payrecharge.FieldMoney:
  19679. return m.AddedMoney()
  19680. case payrecharge.FieldOrganizationID:
  19681. return m.AddedOrganizationID()
  19682. }
  19683. return nil, false
  19684. }
  19685. // AddField adds the value to the field with the given name. It returns an error if
  19686. // the field is not defined in the schema, or if the type mismatched the field
  19687. // type.
  19688. func (m *PayRechargeMutation) AddField(name string, value ent.Value) error {
  19689. switch name {
  19690. case payrecharge.FieldNumber:
  19691. v, ok := value.(float32)
  19692. if !ok {
  19693. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19694. }
  19695. m.AddNumber(v)
  19696. return nil
  19697. case payrecharge.FieldStatus:
  19698. v, ok := value.(int)
  19699. if !ok {
  19700. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19701. }
  19702. m.AddStatus(v)
  19703. return nil
  19704. case payrecharge.FieldMoney:
  19705. v, ok := value.(float32)
  19706. if !ok {
  19707. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19708. }
  19709. m.AddMoney(v)
  19710. return nil
  19711. case payrecharge.FieldOrganizationID:
  19712. v, ok := value.(int64)
  19713. if !ok {
  19714. return fmt.Errorf("unexpected type %T for field %s", value, name)
  19715. }
  19716. m.AddOrganizationID(v)
  19717. return nil
  19718. }
  19719. return fmt.Errorf("unknown PayRecharge numeric field %s", name)
  19720. }
  19721. // ClearedFields returns all nullable fields that were cleared during this
  19722. // mutation.
  19723. func (m *PayRechargeMutation) ClearedFields() []string {
  19724. var fields []string
  19725. if m.FieldCleared(payrecharge.FieldDeletedAt) {
  19726. fields = append(fields, payrecharge.FieldDeletedAt)
  19727. }
  19728. if m.FieldCleared(payrecharge.FieldStatus) {
  19729. fields = append(fields, payrecharge.FieldStatus)
  19730. }
  19731. if m.FieldCleared(payrecharge.FieldMoney) {
  19732. fields = append(fields, payrecharge.FieldMoney)
  19733. }
  19734. if m.FieldCleared(payrecharge.FieldOutTradeNo) {
  19735. fields = append(fields, payrecharge.FieldOutTradeNo)
  19736. }
  19737. return fields
  19738. }
  19739. // FieldCleared returns a boolean indicating if a field with the given name was
  19740. // cleared in this mutation.
  19741. func (m *PayRechargeMutation) FieldCleared(name string) bool {
  19742. _, ok := m.clearedFields[name]
  19743. return ok
  19744. }
  19745. // ClearField clears the value of the field with the given name. It returns an
  19746. // error if the field is not defined in the schema.
  19747. func (m *PayRechargeMutation) ClearField(name string) error {
  19748. switch name {
  19749. case payrecharge.FieldDeletedAt:
  19750. m.ClearDeletedAt()
  19751. return nil
  19752. case payrecharge.FieldStatus:
  19753. m.ClearStatus()
  19754. return nil
  19755. case payrecharge.FieldMoney:
  19756. m.ClearMoney()
  19757. return nil
  19758. case payrecharge.FieldOutTradeNo:
  19759. m.ClearOutTradeNo()
  19760. return nil
  19761. }
  19762. return fmt.Errorf("unknown PayRecharge nullable field %s", name)
  19763. }
  19764. // ResetField resets all changes in the mutation for the field with the given name.
  19765. // It returns an error if the field is not defined in the schema.
  19766. func (m *PayRechargeMutation) ResetField(name string) error {
  19767. switch name {
  19768. case payrecharge.FieldCreatedAt:
  19769. m.ResetCreatedAt()
  19770. return nil
  19771. case payrecharge.FieldUpdatedAt:
  19772. m.ResetUpdatedAt()
  19773. return nil
  19774. case payrecharge.FieldDeletedAt:
  19775. m.ResetDeletedAt()
  19776. return nil
  19777. case payrecharge.FieldUserID:
  19778. m.ResetUserID()
  19779. return nil
  19780. case payrecharge.FieldNumber:
  19781. m.ResetNumber()
  19782. return nil
  19783. case payrecharge.FieldStatus:
  19784. m.ResetStatus()
  19785. return nil
  19786. case payrecharge.FieldMoney:
  19787. m.ResetMoney()
  19788. return nil
  19789. case payrecharge.FieldOutTradeNo:
  19790. m.ResetOutTradeNo()
  19791. return nil
  19792. case payrecharge.FieldOrganizationID:
  19793. m.ResetOrganizationID()
  19794. return nil
  19795. }
  19796. return fmt.Errorf("unknown PayRecharge field %s", name)
  19797. }
  19798. // AddedEdges returns all edge names that were set/added in this mutation.
  19799. func (m *PayRechargeMutation) AddedEdges() []string {
  19800. edges := make([]string, 0, 0)
  19801. return edges
  19802. }
  19803. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  19804. // name in this mutation.
  19805. func (m *PayRechargeMutation) AddedIDs(name string) []ent.Value {
  19806. return nil
  19807. }
  19808. // RemovedEdges returns all edge names that were removed in this mutation.
  19809. func (m *PayRechargeMutation) RemovedEdges() []string {
  19810. edges := make([]string, 0, 0)
  19811. return edges
  19812. }
  19813. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  19814. // the given name in this mutation.
  19815. func (m *PayRechargeMutation) RemovedIDs(name string) []ent.Value {
  19816. return nil
  19817. }
  19818. // ClearedEdges returns all edge names that were cleared in this mutation.
  19819. func (m *PayRechargeMutation) ClearedEdges() []string {
  19820. edges := make([]string, 0, 0)
  19821. return edges
  19822. }
  19823. // EdgeCleared returns a boolean which indicates if the edge with the given name
  19824. // was cleared in this mutation.
  19825. func (m *PayRechargeMutation) EdgeCleared(name string) bool {
  19826. return false
  19827. }
  19828. // ClearEdge clears the value of the edge with the given name. It returns an error
  19829. // if that edge is not defined in the schema.
  19830. func (m *PayRechargeMutation) ClearEdge(name string) error {
  19831. return fmt.Errorf("unknown PayRecharge unique edge %s", name)
  19832. }
  19833. // ResetEdge resets all changes to the edge with the given name in this mutation.
  19834. // It returns an error if the edge is not defined in the schema.
  19835. func (m *PayRechargeMutation) ResetEdge(name string) error {
  19836. return fmt.Errorf("unknown PayRecharge edge %s", name)
  19837. }
  19838. // ServerMutation represents an operation that mutates the Server nodes in the graph.
  19839. type ServerMutation struct {
  19840. config
  19841. op Op
  19842. typ string
  19843. id *uint64
  19844. created_at *time.Time
  19845. updated_at *time.Time
  19846. status *uint8
  19847. addstatus *int8
  19848. deleted_at *time.Time
  19849. name *string
  19850. public_ip *string
  19851. private_ip *string
  19852. admin_port *string
  19853. clearedFields map[string]struct{}
  19854. wxs map[uint64]struct{}
  19855. removedwxs map[uint64]struct{}
  19856. clearedwxs bool
  19857. done bool
  19858. oldValue func(context.Context) (*Server, error)
  19859. predicates []predicate.Server
  19860. }
  19861. var _ ent.Mutation = (*ServerMutation)(nil)
  19862. // serverOption allows management of the mutation configuration using functional options.
  19863. type serverOption func(*ServerMutation)
  19864. // newServerMutation creates new mutation for the Server entity.
  19865. func newServerMutation(c config, op Op, opts ...serverOption) *ServerMutation {
  19866. m := &ServerMutation{
  19867. config: c,
  19868. op: op,
  19869. typ: TypeServer,
  19870. clearedFields: make(map[string]struct{}),
  19871. }
  19872. for _, opt := range opts {
  19873. opt(m)
  19874. }
  19875. return m
  19876. }
  19877. // withServerID sets the ID field of the mutation.
  19878. func withServerID(id uint64) serverOption {
  19879. return func(m *ServerMutation) {
  19880. var (
  19881. err error
  19882. once sync.Once
  19883. value *Server
  19884. )
  19885. m.oldValue = func(ctx context.Context) (*Server, error) {
  19886. once.Do(func() {
  19887. if m.done {
  19888. err = errors.New("querying old values post mutation is not allowed")
  19889. } else {
  19890. value, err = m.Client().Server.Get(ctx, id)
  19891. }
  19892. })
  19893. return value, err
  19894. }
  19895. m.id = &id
  19896. }
  19897. }
  19898. // withServer sets the old Server of the mutation.
  19899. func withServer(node *Server) serverOption {
  19900. return func(m *ServerMutation) {
  19901. m.oldValue = func(context.Context) (*Server, error) {
  19902. return node, nil
  19903. }
  19904. m.id = &node.ID
  19905. }
  19906. }
  19907. // Client returns a new `ent.Client` from the mutation. If the mutation was
  19908. // executed in a transaction (ent.Tx), a transactional client is returned.
  19909. func (m ServerMutation) Client() *Client {
  19910. client := &Client{config: m.config}
  19911. client.init()
  19912. return client
  19913. }
  19914. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  19915. // it returns an error otherwise.
  19916. func (m ServerMutation) Tx() (*Tx, error) {
  19917. if _, ok := m.driver.(*txDriver); !ok {
  19918. return nil, errors.New("ent: mutation is not running in a transaction")
  19919. }
  19920. tx := &Tx{config: m.config}
  19921. tx.init()
  19922. return tx, nil
  19923. }
  19924. // SetID sets the value of the id field. Note that this
  19925. // operation is only accepted on creation of Server entities.
  19926. func (m *ServerMutation) SetID(id uint64) {
  19927. m.id = &id
  19928. }
  19929. // ID returns the ID value in the mutation. Note that the ID is only available
  19930. // if it was provided to the builder or after it was returned from the database.
  19931. func (m *ServerMutation) ID() (id uint64, exists bool) {
  19932. if m.id == nil {
  19933. return
  19934. }
  19935. return *m.id, true
  19936. }
  19937. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  19938. // That means, if the mutation is applied within a transaction with an isolation level such
  19939. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  19940. // or updated by the mutation.
  19941. func (m *ServerMutation) IDs(ctx context.Context) ([]uint64, error) {
  19942. switch {
  19943. case m.op.Is(OpUpdateOne | OpDeleteOne):
  19944. id, exists := m.ID()
  19945. if exists {
  19946. return []uint64{id}, nil
  19947. }
  19948. fallthrough
  19949. case m.op.Is(OpUpdate | OpDelete):
  19950. return m.Client().Server.Query().Where(m.predicates...).IDs(ctx)
  19951. default:
  19952. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  19953. }
  19954. }
  19955. // SetCreatedAt sets the "created_at" field.
  19956. func (m *ServerMutation) SetCreatedAt(t time.Time) {
  19957. m.created_at = &t
  19958. }
  19959. // CreatedAt returns the value of the "created_at" field in the mutation.
  19960. func (m *ServerMutation) CreatedAt() (r time.Time, exists bool) {
  19961. v := m.created_at
  19962. if v == nil {
  19963. return
  19964. }
  19965. return *v, true
  19966. }
  19967. // OldCreatedAt returns the old "created_at" field's value of the Server entity.
  19968. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  19969. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  19970. func (m *ServerMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  19971. if !m.op.Is(OpUpdateOne) {
  19972. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  19973. }
  19974. if m.id == nil || m.oldValue == nil {
  19975. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  19976. }
  19977. oldValue, err := m.oldValue(ctx)
  19978. if err != nil {
  19979. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  19980. }
  19981. return oldValue.CreatedAt, nil
  19982. }
  19983. // ResetCreatedAt resets all changes to the "created_at" field.
  19984. func (m *ServerMutation) ResetCreatedAt() {
  19985. m.created_at = nil
  19986. }
  19987. // SetUpdatedAt sets the "updated_at" field.
  19988. func (m *ServerMutation) SetUpdatedAt(t time.Time) {
  19989. m.updated_at = &t
  19990. }
  19991. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  19992. func (m *ServerMutation) UpdatedAt() (r time.Time, exists bool) {
  19993. v := m.updated_at
  19994. if v == nil {
  19995. return
  19996. }
  19997. return *v, true
  19998. }
  19999. // OldUpdatedAt returns the old "updated_at" field's value of the Server entity.
  20000. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20001. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20002. func (m *ServerMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20003. if !m.op.Is(OpUpdateOne) {
  20004. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20005. }
  20006. if m.id == nil || m.oldValue == nil {
  20007. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20008. }
  20009. oldValue, err := m.oldValue(ctx)
  20010. if err != nil {
  20011. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20012. }
  20013. return oldValue.UpdatedAt, nil
  20014. }
  20015. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20016. func (m *ServerMutation) ResetUpdatedAt() {
  20017. m.updated_at = nil
  20018. }
  20019. // SetStatus sets the "status" field.
  20020. func (m *ServerMutation) SetStatus(u uint8) {
  20021. m.status = &u
  20022. m.addstatus = nil
  20023. }
  20024. // Status returns the value of the "status" field in the mutation.
  20025. func (m *ServerMutation) Status() (r uint8, exists bool) {
  20026. v := m.status
  20027. if v == nil {
  20028. return
  20029. }
  20030. return *v, true
  20031. }
  20032. // OldStatus returns the old "status" field's value of the Server entity.
  20033. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20034. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20035. func (m *ServerMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20036. if !m.op.Is(OpUpdateOne) {
  20037. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20038. }
  20039. if m.id == nil || m.oldValue == nil {
  20040. return v, errors.New("OldStatus requires an ID field in the mutation")
  20041. }
  20042. oldValue, err := m.oldValue(ctx)
  20043. if err != nil {
  20044. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20045. }
  20046. return oldValue.Status, nil
  20047. }
  20048. // AddStatus adds u to the "status" field.
  20049. func (m *ServerMutation) AddStatus(u int8) {
  20050. if m.addstatus != nil {
  20051. *m.addstatus += u
  20052. } else {
  20053. m.addstatus = &u
  20054. }
  20055. }
  20056. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20057. func (m *ServerMutation) AddedStatus() (r int8, exists bool) {
  20058. v := m.addstatus
  20059. if v == nil {
  20060. return
  20061. }
  20062. return *v, true
  20063. }
  20064. // ClearStatus clears the value of the "status" field.
  20065. func (m *ServerMutation) ClearStatus() {
  20066. m.status = nil
  20067. m.addstatus = nil
  20068. m.clearedFields[server.FieldStatus] = struct{}{}
  20069. }
  20070. // StatusCleared returns if the "status" field was cleared in this mutation.
  20071. func (m *ServerMutation) StatusCleared() bool {
  20072. _, ok := m.clearedFields[server.FieldStatus]
  20073. return ok
  20074. }
  20075. // ResetStatus resets all changes to the "status" field.
  20076. func (m *ServerMutation) ResetStatus() {
  20077. m.status = nil
  20078. m.addstatus = nil
  20079. delete(m.clearedFields, server.FieldStatus)
  20080. }
  20081. // SetDeletedAt sets the "deleted_at" field.
  20082. func (m *ServerMutation) SetDeletedAt(t time.Time) {
  20083. m.deleted_at = &t
  20084. }
  20085. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20086. func (m *ServerMutation) DeletedAt() (r time.Time, exists bool) {
  20087. v := m.deleted_at
  20088. if v == nil {
  20089. return
  20090. }
  20091. return *v, true
  20092. }
  20093. // OldDeletedAt returns the old "deleted_at" field's value of the Server entity.
  20094. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20095. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20096. func (m *ServerMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20097. if !m.op.Is(OpUpdateOne) {
  20098. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20099. }
  20100. if m.id == nil || m.oldValue == nil {
  20101. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20102. }
  20103. oldValue, err := m.oldValue(ctx)
  20104. if err != nil {
  20105. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20106. }
  20107. return oldValue.DeletedAt, nil
  20108. }
  20109. // ClearDeletedAt clears the value of the "deleted_at" field.
  20110. func (m *ServerMutation) ClearDeletedAt() {
  20111. m.deleted_at = nil
  20112. m.clearedFields[server.FieldDeletedAt] = struct{}{}
  20113. }
  20114. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20115. func (m *ServerMutation) DeletedAtCleared() bool {
  20116. _, ok := m.clearedFields[server.FieldDeletedAt]
  20117. return ok
  20118. }
  20119. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20120. func (m *ServerMutation) ResetDeletedAt() {
  20121. m.deleted_at = nil
  20122. delete(m.clearedFields, server.FieldDeletedAt)
  20123. }
  20124. // SetName sets the "name" field.
  20125. func (m *ServerMutation) SetName(s string) {
  20126. m.name = &s
  20127. }
  20128. // Name returns the value of the "name" field in the mutation.
  20129. func (m *ServerMutation) Name() (r string, exists bool) {
  20130. v := m.name
  20131. if v == nil {
  20132. return
  20133. }
  20134. return *v, true
  20135. }
  20136. // OldName returns the old "name" field's value of the Server entity.
  20137. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20138. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20139. func (m *ServerMutation) OldName(ctx context.Context) (v string, err error) {
  20140. if !m.op.Is(OpUpdateOne) {
  20141. return v, errors.New("OldName is only allowed on UpdateOne operations")
  20142. }
  20143. if m.id == nil || m.oldValue == nil {
  20144. return v, errors.New("OldName requires an ID field in the mutation")
  20145. }
  20146. oldValue, err := m.oldValue(ctx)
  20147. if err != nil {
  20148. return v, fmt.Errorf("querying old value for OldName: %w", err)
  20149. }
  20150. return oldValue.Name, nil
  20151. }
  20152. // ResetName resets all changes to the "name" field.
  20153. func (m *ServerMutation) ResetName() {
  20154. m.name = nil
  20155. }
  20156. // SetPublicIP sets the "public_ip" field.
  20157. func (m *ServerMutation) SetPublicIP(s string) {
  20158. m.public_ip = &s
  20159. }
  20160. // PublicIP returns the value of the "public_ip" field in the mutation.
  20161. func (m *ServerMutation) PublicIP() (r string, exists bool) {
  20162. v := m.public_ip
  20163. if v == nil {
  20164. return
  20165. }
  20166. return *v, true
  20167. }
  20168. // OldPublicIP returns the old "public_ip" field's value of the Server entity.
  20169. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20170. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20171. func (m *ServerMutation) OldPublicIP(ctx context.Context) (v string, err error) {
  20172. if !m.op.Is(OpUpdateOne) {
  20173. return v, errors.New("OldPublicIP is only allowed on UpdateOne operations")
  20174. }
  20175. if m.id == nil || m.oldValue == nil {
  20176. return v, errors.New("OldPublicIP requires an ID field in the mutation")
  20177. }
  20178. oldValue, err := m.oldValue(ctx)
  20179. if err != nil {
  20180. return v, fmt.Errorf("querying old value for OldPublicIP: %w", err)
  20181. }
  20182. return oldValue.PublicIP, nil
  20183. }
  20184. // ResetPublicIP resets all changes to the "public_ip" field.
  20185. func (m *ServerMutation) ResetPublicIP() {
  20186. m.public_ip = nil
  20187. }
  20188. // SetPrivateIP sets the "private_ip" field.
  20189. func (m *ServerMutation) SetPrivateIP(s string) {
  20190. m.private_ip = &s
  20191. }
  20192. // PrivateIP returns the value of the "private_ip" field in the mutation.
  20193. func (m *ServerMutation) PrivateIP() (r string, exists bool) {
  20194. v := m.private_ip
  20195. if v == nil {
  20196. return
  20197. }
  20198. return *v, true
  20199. }
  20200. // OldPrivateIP returns the old "private_ip" field's value of the Server entity.
  20201. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20202. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20203. func (m *ServerMutation) OldPrivateIP(ctx context.Context) (v string, err error) {
  20204. if !m.op.Is(OpUpdateOne) {
  20205. return v, errors.New("OldPrivateIP is only allowed on UpdateOne operations")
  20206. }
  20207. if m.id == nil || m.oldValue == nil {
  20208. return v, errors.New("OldPrivateIP requires an ID field in the mutation")
  20209. }
  20210. oldValue, err := m.oldValue(ctx)
  20211. if err != nil {
  20212. return v, fmt.Errorf("querying old value for OldPrivateIP: %w", err)
  20213. }
  20214. return oldValue.PrivateIP, nil
  20215. }
  20216. // ResetPrivateIP resets all changes to the "private_ip" field.
  20217. func (m *ServerMutation) ResetPrivateIP() {
  20218. m.private_ip = nil
  20219. }
  20220. // SetAdminPort sets the "admin_port" field.
  20221. func (m *ServerMutation) SetAdminPort(s string) {
  20222. m.admin_port = &s
  20223. }
  20224. // AdminPort returns the value of the "admin_port" field in the mutation.
  20225. func (m *ServerMutation) AdminPort() (r string, exists bool) {
  20226. v := m.admin_port
  20227. if v == nil {
  20228. return
  20229. }
  20230. return *v, true
  20231. }
  20232. // OldAdminPort returns the old "admin_port" field's value of the Server entity.
  20233. // If the Server object wasn't provided to the builder, the object is fetched from the database.
  20234. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20235. func (m *ServerMutation) OldAdminPort(ctx context.Context) (v string, err error) {
  20236. if !m.op.Is(OpUpdateOne) {
  20237. return v, errors.New("OldAdminPort is only allowed on UpdateOne operations")
  20238. }
  20239. if m.id == nil || m.oldValue == nil {
  20240. return v, errors.New("OldAdminPort requires an ID field in the mutation")
  20241. }
  20242. oldValue, err := m.oldValue(ctx)
  20243. if err != nil {
  20244. return v, fmt.Errorf("querying old value for OldAdminPort: %w", err)
  20245. }
  20246. return oldValue.AdminPort, nil
  20247. }
  20248. // ResetAdminPort resets all changes to the "admin_port" field.
  20249. func (m *ServerMutation) ResetAdminPort() {
  20250. m.admin_port = nil
  20251. }
  20252. // AddWxIDs adds the "wxs" edge to the Wx entity by ids.
  20253. func (m *ServerMutation) AddWxIDs(ids ...uint64) {
  20254. if m.wxs == nil {
  20255. m.wxs = make(map[uint64]struct{})
  20256. }
  20257. for i := range ids {
  20258. m.wxs[ids[i]] = struct{}{}
  20259. }
  20260. }
  20261. // ClearWxs clears the "wxs" edge to the Wx entity.
  20262. func (m *ServerMutation) ClearWxs() {
  20263. m.clearedwxs = true
  20264. }
  20265. // WxsCleared reports if the "wxs" edge to the Wx entity was cleared.
  20266. func (m *ServerMutation) WxsCleared() bool {
  20267. return m.clearedwxs
  20268. }
  20269. // RemoveWxIDs removes the "wxs" edge to the Wx entity by IDs.
  20270. func (m *ServerMutation) RemoveWxIDs(ids ...uint64) {
  20271. if m.removedwxs == nil {
  20272. m.removedwxs = make(map[uint64]struct{})
  20273. }
  20274. for i := range ids {
  20275. delete(m.wxs, ids[i])
  20276. m.removedwxs[ids[i]] = struct{}{}
  20277. }
  20278. }
  20279. // RemovedWxs returns the removed IDs of the "wxs" edge to the Wx entity.
  20280. func (m *ServerMutation) RemovedWxsIDs() (ids []uint64) {
  20281. for id := range m.removedwxs {
  20282. ids = append(ids, id)
  20283. }
  20284. return
  20285. }
  20286. // WxsIDs returns the "wxs" edge IDs in the mutation.
  20287. func (m *ServerMutation) WxsIDs() (ids []uint64) {
  20288. for id := range m.wxs {
  20289. ids = append(ids, id)
  20290. }
  20291. return
  20292. }
  20293. // ResetWxs resets all changes to the "wxs" edge.
  20294. func (m *ServerMutation) ResetWxs() {
  20295. m.wxs = nil
  20296. m.clearedwxs = false
  20297. m.removedwxs = nil
  20298. }
  20299. // Where appends a list predicates to the ServerMutation builder.
  20300. func (m *ServerMutation) Where(ps ...predicate.Server) {
  20301. m.predicates = append(m.predicates, ps...)
  20302. }
  20303. // WhereP appends storage-level predicates to the ServerMutation builder. Using this method,
  20304. // users can use type-assertion to append predicates that do not depend on any generated package.
  20305. func (m *ServerMutation) WhereP(ps ...func(*sql.Selector)) {
  20306. p := make([]predicate.Server, len(ps))
  20307. for i := range ps {
  20308. p[i] = ps[i]
  20309. }
  20310. m.Where(p...)
  20311. }
  20312. // Op returns the operation name.
  20313. func (m *ServerMutation) Op() Op {
  20314. return m.op
  20315. }
  20316. // SetOp allows setting the mutation operation.
  20317. func (m *ServerMutation) SetOp(op Op) {
  20318. m.op = op
  20319. }
  20320. // Type returns the node type of this mutation (Server).
  20321. func (m *ServerMutation) Type() string {
  20322. return m.typ
  20323. }
  20324. // Fields returns all fields that were changed during this mutation. Note that in
  20325. // order to get all numeric fields that were incremented/decremented, call
  20326. // AddedFields().
  20327. func (m *ServerMutation) Fields() []string {
  20328. fields := make([]string, 0, 8)
  20329. if m.created_at != nil {
  20330. fields = append(fields, server.FieldCreatedAt)
  20331. }
  20332. if m.updated_at != nil {
  20333. fields = append(fields, server.FieldUpdatedAt)
  20334. }
  20335. if m.status != nil {
  20336. fields = append(fields, server.FieldStatus)
  20337. }
  20338. if m.deleted_at != nil {
  20339. fields = append(fields, server.FieldDeletedAt)
  20340. }
  20341. if m.name != nil {
  20342. fields = append(fields, server.FieldName)
  20343. }
  20344. if m.public_ip != nil {
  20345. fields = append(fields, server.FieldPublicIP)
  20346. }
  20347. if m.private_ip != nil {
  20348. fields = append(fields, server.FieldPrivateIP)
  20349. }
  20350. if m.admin_port != nil {
  20351. fields = append(fields, server.FieldAdminPort)
  20352. }
  20353. return fields
  20354. }
  20355. // Field returns the value of a field with the given name. The second boolean
  20356. // return value indicates that this field was not set, or was not defined in the
  20357. // schema.
  20358. func (m *ServerMutation) Field(name string) (ent.Value, bool) {
  20359. switch name {
  20360. case server.FieldCreatedAt:
  20361. return m.CreatedAt()
  20362. case server.FieldUpdatedAt:
  20363. return m.UpdatedAt()
  20364. case server.FieldStatus:
  20365. return m.Status()
  20366. case server.FieldDeletedAt:
  20367. return m.DeletedAt()
  20368. case server.FieldName:
  20369. return m.Name()
  20370. case server.FieldPublicIP:
  20371. return m.PublicIP()
  20372. case server.FieldPrivateIP:
  20373. return m.PrivateIP()
  20374. case server.FieldAdminPort:
  20375. return m.AdminPort()
  20376. }
  20377. return nil, false
  20378. }
  20379. // OldField returns the old value of the field from the database. An error is
  20380. // returned if the mutation operation is not UpdateOne, or the query to the
  20381. // database failed.
  20382. func (m *ServerMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  20383. switch name {
  20384. case server.FieldCreatedAt:
  20385. return m.OldCreatedAt(ctx)
  20386. case server.FieldUpdatedAt:
  20387. return m.OldUpdatedAt(ctx)
  20388. case server.FieldStatus:
  20389. return m.OldStatus(ctx)
  20390. case server.FieldDeletedAt:
  20391. return m.OldDeletedAt(ctx)
  20392. case server.FieldName:
  20393. return m.OldName(ctx)
  20394. case server.FieldPublicIP:
  20395. return m.OldPublicIP(ctx)
  20396. case server.FieldPrivateIP:
  20397. return m.OldPrivateIP(ctx)
  20398. case server.FieldAdminPort:
  20399. return m.OldAdminPort(ctx)
  20400. }
  20401. return nil, fmt.Errorf("unknown Server field %s", name)
  20402. }
  20403. // SetField sets the value of a field with the given name. It returns an error if
  20404. // the field is not defined in the schema, or if the type mismatched the field
  20405. // type.
  20406. func (m *ServerMutation) SetField(name string, value ent.Value) error {
  20407. switch name {
  20408. case server.FieldCreatedAt:
  20409. v, ok := value.(time.Time)
  20410. if !ok {
  20411. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20412. }
  20413. m.SetCreatedAt(v)
  20414. return nil
  20415. case server.FieldUpdatedAt:
  20416. v, ok := value.(time.Time)
  20417. if !ok {
  20418. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20419. }
  20420. m.SetUpdatedAt(v)
  20421. return nil
  20422. case server.FieldStatus:
  20423. v, ok := value.(uint8)
  20424. if !ok {
  20425. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20426. }
  20427. m.SetStatus(v)
  20428. return nil
  20429. case server.FieldDeletedAt:
  20430. v, ok := value.(time.Time)
  20431. if !ok {
  20432. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20433. }
  20434. m.SetDeletedAt(v)
  20435. return nil
  20436. case server.FieldName:
  20437. v, ok := value.(string)
  20438. if !ok {
  20439. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20440. }
  20441. m.SetName(v)
  20442. return nil
  20443. case server.FieldPublicIP:
  20444. v, ok := value.(string)
  20445. if !ok {
  20446. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20447. }
  20448. m.SetPublicIP(v)
  20449. return nil
  20450. case server.FieldPrivateIP:
  20451. v, ok := value.(string)
  20452. if !ok {
  20453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20454. }
  20455. m.SetPrivateIP(v)
  20456. return nil
  20457. case server.FieldAdminPort:
  20458. v, ok := value.(string)
  20459. if !ok {
  20460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20461. }
  20462. m.SetAdminPort(v)
  20463. return nil
  20464. }
  20465. return fmt.Errorf("unknown Server field %s", name)
  20466. }
  20467. // AddedFields returns all numeric fields that were incremented/decremented during
  20468. // this mutation.
  20469. func (m *ServerMutation) AddedFields() []string {
  20470. var fields []string
  20471. if m.addstatus != nil {
  20472. fields = append(fields, server.FieldStatus)
  20473. }
  20474. return fields
  20475. }
  20476. // AddedField returns the numeric value that was incremented/decremented on a field
  20477. // with the given name. The second boolean return value indicates that this field
  20478. // was not set, or was not defined in the schema.
  20479. func (m *ServerMutation) AddedField(name string) (ent.Value, bool) {
  20480. switch name {
  20481. case server.FieldStatus:
  20482. return m.AddedStatus()
  20483. }
  20484. return nil, false
  20485. }
  20486. // AddField adds the value to the field with the given name. It returns an error if
  20487. // the field is not defined in the schema, or if the type mismatched the field
  20488. // type.
  20489. func (m *ServerMutation) AddField(name string, value ent.Value) error {
  20490. switch name {
  20491. case server.FieldStatus:
  20492. v, ok := value.(int8)
  20493. if !ok {
  20494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  20495. }
  20496. m.AddStatus(v)
  20497. return nil
  20498. }
  20499. return fmt.Errorf("unknown Server numeric field %s", name)
  20500. }
  20501. // ClearedFields returns all nullable fields that were cleared during this
  20502. // mutation.
  20503. func (m *ServerMutation) ClearedFields() []string {
  20504. var fields []string
  20505. if m.FieldCleared(server.FieldStatus) {
  20506. fields = append(fields, server.FieldStatus)
  20507. }
  20508. if m.FieldCleared(server.FieldDeletedAt) {
  20509. fields = append(fields, server.FieldDeletedAt)
  20510. }
  20511. return fields
  20512. }
  20513. // FieldCleared returns a boolean indicating if a field with the given name was
  20514. // cleared in this mutation.
  20515. func (m *ServerMutation) FieldCleared(name string) bool {
  20516. _, ok := m.clearedFields[name]
  20517. return ok
  20518. }
  20519. // ClearField clears the value of the field with the given name. It returns an
  20520. // error if the field is not defined in the schema.
  20521. func (m *ServerMutation) ClearField(name string) error {
  20522. switch name {
  20523. case server.FieldStatus:
  20524. m.ClearStatus()
  20525. return nil
  20526. case server.FieldDeletedAt:
  20527. m.ClearDeletedAt()
  20528. return nil
  20529. }
  20530. return fmt.Errorf("unknown Server nullable field %s", name)
  20531. }
  20532. // ResetField resets all changes in the mutation for the field with the given name.
  20533. // It returns an error if the field is not defined in the schema.
  20534. func (m *ServerMutation) ResetField(name string) error {
  20535. switch name {
  20536. case server.FieldCreatedAt:
  20537. m.ResetCreatedAt()
  20538. return nil
  20539. case server.FieldUpdatedAt:
  20540. m.ResetUpdatedAt()
  20541. return nil
  20542. case server.FieldStatus:
  20543. m.ResetStatus()
  20544. return nil
  20545. case server.FieldDeletedAt:
  20546. m.ResetDeletedAt()
  20547. return nil
  20548. case server.FieldName:
  20549. m.ResetName()
  20550. return nil
  20551. case server.FieldPublicIP:
  20552. m.ResetPublicIP()
  20553. return nil
  20554. case server.FieldPrivateIP:
  20555. m.ResetPrivateIP()
  20556. return nil
  20557. case server.FieldAdminPort:
  20558. m.ResetAdminPort()
  20559. return nil
  20560. }
  20561. return fmt.Errorf("unknown Server field %s", name)
  20562. }
  20563. // AddedEdges returns all edge names that were set/added in this mutation.
  20564. func (m *ServerMutation) AddedEdges() []string {
  20565. edges := make([]string, 0, 1)
  20566. if m.wxs != nil {
  20567. edges = append(edges, server.EdgeWxs)
  20568. }
  20569. return edges
  20570. }
  20571. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  20572. // name in this mutation.
  20573. func (m *ServerMutation) AddedIDs(name string) []ent.Value {
  20574. switch name {
  20575. case server.EdgeWxs:
  20576. ids := make([]ent.Value, 0, len(m.wxs))
  20577. for id := range m.wxs {
  20578. ids = append(ids, id)
  20579. }
  20580. return ids
  20581. }
  20582. return nil
  20583. }
  20584. // RemovedEdges returns all edge names that were removed in this mutation.
  20585. func (m *ServerMutation) RemovedEdges() []string {
  20586. edges := make([]string, 0, 1)
  20587. if m.removedwxs != nil {
  20588. edges = append(edges, server.EdgeWxs)
  20589. }
  20590. return edges
  20591. }
  20592. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  20593. // the given name in this mutation.
  20594. func (m *ServerMutation) RemovedIDs(name string) []ent.Value {
  20595. switch name {
  20596. case server.EdgeWxs:
  20597. ids := make([]ent.Value, 0, len(m.removedwxs))
  20598. for id := range m.removedwxs {
  20599. ids = append(ids, id)
  20600. }
  20601. return ids
  20602. }
  20603. return nil
  20604. }
  20605. // ClearedEdges returns all edge names that were cleared in this mutation.
  20606. func (m *ServerMutation) ClearedEdges() []string {
  20607. edges := make([]string, 0, 1)
  20608. if m.clearedwxs {
  20609. edges = append(edges, server.EdgeWxs)
  20610. }
  20611. return edges
  20612. }
  20613. // EdgeCleared returns a boolean which indicates if the edge with the given name
  20614. // was cleared in this mutation.
  20615. func (m *ServerMutation) EdgeCleared(name string) bool {
  20616. switch name {
  20617. case server.EdgeWxs:
  20618. return m.clearedwxs
  20619. }
  20620. return false
  20621. }
  20622. // ClearEdge clears the value of the edge with the given name. It returns an error
  20623. // if that edge is not defined in the schema.
  20624. func (m *ServerMutation) ClearEdge(name string) error {
  20625. switch name {
  20626. }
  20627. return fmt.Errorf("unknown Server unique edge %s", name)
  20628. }
  20629. // ResetEdge resets all changes to the edge with the given name in this mutation.
  20630. // It returns an error if the edge is not defined in the schema.
  20631. func (m *ServerMutation) ResetEdge(name string) error {
  20632. switch name {
  20633. case server.EdgeWxs:
  20634. m.ResetWxs()
  20635. return nil
  20636. }
  20637. return fmt.Errorf("unknown Server edge %s", name)
  20638. }
  20639. // SopNodeMutation represents an operation that mutates the SopNode nodes in the graph.
  20640. type SopNodeMutation struct {
  20641. config
  20642. op Op
  20643. typ string
  20644. id *uint64
  20645. created_at *time.Time
  20646. updated_at *time.Time
  20647. status *uint8
  20648. addstatus *int8
  20649. deleted_at *time.Time
  20650. parent_id *uint64
  20651. addparent_id *int64
  20652. name *string
  20653. condition_type *int
  20654. addcondition_type *int
  20655. condition_list *[]string
  20656. appendcondition_list []string
  20657. no_reply_condition *uint64
  20658. addno_reply_condition *int64
  20659. no_reply_unit *string
  20660. action_message *[]custom_types.Action
  20661. appendaction_message []custom_types.Action
  20662. action_label_add *[]uint64
  20663. appendaction_label_add []uint64
  20664. action_label_del *[]uint64
  20665. appendaction_label_del []uint64
  20666. action_forward **custom_types.ActionForward
  20667. clearedFields map[string]struct{}
  20668. sop_stage *uint64
  20669. clearedsop_stage bool
  20670. node_messages map[uint64]struct{}
  20671. removednode_messages map[uint64]struct{}
  20672. clearednode_messages bool
  20673. done bool
  20674. oldValue func(context.Context) (*SopNode, error)
  20675. predicates []predicate.SopNode
  20676. }
  20677. var _ ent.Mutation = (*SopNodeMutation)(nil)
  20678. // sopnodeOption allows management of the mutation configuration using functional options.
  20679. type sopnodeOption func(*SopNodeMutation)
  20680. // newSopNodeMutation creates new mutation for the SopNode entity.
  20681. func newSopNodeMutation(c config, op Op, opts ...sopnodeOption) *SopNodeMutation {
  20682. m := &SopNodeMutation{
  20683. config: c,
  20684. op: op,
  20685. typ: TypeSopNode,
  20686. clearedFields: make(map[string]struct{}),
  20687. }
  20688. for _, opt := range opts {
  20689. opt(m)
  20690. }
  20691. return m
  20692. }
  20693. // withSopNodeID sets the ID field of the mutation.
  20694. func withSopNodeID(id uint64) sopnodeOption {
  20695. return func(m *SopNodeMutation) {
  20696. var (
  20697. err error
  20698. once sync.Once
  20699. value *SopNode
  20700. )
  20701. m.oldValue = func(ctx context.Context) (*SopNode, error) {
  20702. once.Do(func() {
  20703. if m.done {
  20704. err = errors.New("querying old values post mutation is not allowed")
  20705. } else {
  20706. value, err = m.Client().SopNode.Get(ctx, id)
  20707. }
  20708. })
  20709. return value, err
  20710. }
  20711. m.id = &id
  20712. }
  20713. }
  20714. // withSopNode sets the old SopNode of the mutation.
  20715. func withSopNode(node *SopNode) sopnodeOption {
  20716. return func(m *SopNodeMutation) {
  20717. m.oldValue = func(context.Context) (*SopNode, error) {
  20718. return node, nil
  20719. }
  20720. m.id = &node.ID
  20721. }
  20722. }
  20723. // Client returns a new `ent.Client` from the mutation. If the mutation was
  20724. // executed in a transaction (ent.Tx), a transactional client is returned.
  20725. func (m SopNodeMutation) Client() *Client {
  20726. client := &Client{config: m.config}
  20727. client.init()
  20728. return client
  20729. }
  20730. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  20731. // it returns an error otherwise.
  20732. func (m SopNodeMutation) Tx() (*Tx, error) {
  20733. if _, ok := m.driver.(*txDriver); !ok {
  20734. return nil, errors.New("ent: mutation is not running in a transaction")
  20735. }
  20736. tx := &Tx{config: m.config}
  20737. tx.init()
  20738. return tx, nil
  20739. }
  20740. // SetID sets the value of the id field. Note that this
  20741. // operation is only accepted on creation of SopNode entities.
  20742. func (m *SopNodeMutation) SetID(id uint64) {
  20743. m.id = &id
  20744. }
  20745. // ID returns the ID value in the mutation. Note that the ID is only available
  20746. // if it was provided to the builder or after it was returned from the database.
  20747. func (m *SopNodeMutation) ID() (id uint64, exists bool) {
  20748. if m.id == nil {
  20749. return
  20750. }
  20751. return *m.id, true
  20752. }
  20753. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  20754. // That means, if the mutation is applied within a transaction with an isolation level such
  20755. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  20756. // or updated by the mutation.
  20757. func (m *SopNodeMutation) IDs(ctx context.Context) ([]uint64, error) {
  20758. switch {
  20759. case m.op.Is(OpUpdateOne | OpDeleteOne):
  20760. id, exists := m.ID()
  20761. if exists {
  20762. return []uint64{id}, nil
  20763. }
  20764. fallthrough
  20765. case m.op.Is(OpUpdate | OpDelete):
  20766. return m.Client().SopNode.Query().Where(m.predicates...).IDs(ctx)
  20767. default:
  20768. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  20769. }
  20770. }
  20771. // SetCreatedAt sets the "created_at" field.
  20772. func (m *SopNodeMutation) SetCreatedAt(t time.Time) {
  20773. m.created_at = &t
  20774. }
  20775. // CreatedAt returns the value of the "created_at" field in the mutation.
  20776. func (m *SopNodeMutation) CreatedAt() (r time.Time, exists bool) {
  20777. v := m.created_at
  20778. if v == nil {
  20779. return
  20780. }
  20781. return *v, true
  20782. }
  20783. // OldCreatedAt returns the old "created_at" field's value of the SopNode entity.
  20784. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20785. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20786. func (m *SopNodeMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  20787. if !m.op.Is(OpUpdateOne) {
  20788. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  20789. }
  20790. if m.id == nil || m.oldValue == nil {
  20791. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  20792. }
  20793. oldValue, err := m.oldValue(ctx)
  20794. if err != nil {
  20795. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  20796. }
  20797. return oldValue.CreatedAt, nil
  20798. }
  20799. // ResetCreatedAt resets all changes to the "created_at" field.
  20800. func (m *SopNodeMutation) ResetCreatedAt() {
  20801. m.created_at = nil
  20802. }
  20803. // SetUpdatedAt sets the "updated_at" field.
  20804. func (m *SopNodeMutation) SetUpdatedAt(t time.Time) {
  20805. m.updated_at = &t
  20806. }
  20807. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  20808. func (m *SopNodeMutation) UpdatedAt() (r time.Time, exists bool) {
  20809. v := m.updated_at
  20810. if v == nil {
  20811. return
  20812. }
  20813. return *v, true
  20814. }
  20815. // OldUpdatedAt returns the old "updated_at" field's value of the SopNode entity.
  20816. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20817. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20818. func (m *SopNodeMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  20819. if !m.op.Is(OpUpdateOne) {
  20820. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  20821. }
  20822. if m.id == nil || m.oldValue == nil {
  20823. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  20824. }
  20825. oldValue, err := m.oldValue(ctx)
  20826. if err != nil {
  20827. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  20828. }
  20829. return oldValue.UpdatedAt, nil
  20830. }
  20831. // ResetUpdatedAt resets all changes to the "updated_at" field.
  20832. func (m *SopNodeMutation) ResetUpdatedAt() {
  20833. m.updated_at = nil
  20834. }
  20835. // SetStatus sets the "status" field.
  20836. func (m *SopNodeMutation) SetStatus(u uint8) {
  20837. m.status = &u
  20838. m.addstatus = nil
  20839. }
  20840. // Status returns the value of the "status" field in the mutation.
  20841. func (m *SopNodeMutation) Status() (r uint8, exists bool) {
  20842. v := m.status
  20843. if v == nil {
  20844. return
  20845. }
  20846. return *v, true
  20847. }
  20848. // OldStatus returns the old "status" field's value of the SopNode entity.
  20849. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20850. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20851. func (m *SopNodeMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  20852. if !m.op.Is(OpUpdateOne) {
  20853. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  20854. }
  20855. if m.id == nil || m.oldValue == nil {
  20856. return v, errors.New("OldStatus requires an ID field in the mutation")
  20857. }
  20858. oldValue, err := m.oldValue(ctx)
  20859. if err != nil {
  20860. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  20861. }
  20862. return oldValue.Status, nil
  20863. }
  20864. // AddStatus adds u to the "status" field.
  20865. func (m *SopNodeMutation) AddStatus(u int8) {
  20866. if m.addstatus != nil {
  20867. *m.addstatus += u
  20868. } else {
  20869. m.addstatus = &u
  20870. }
  20871. }
  20872. // AddedStatus returns the value that was added to the "status" field in this mutation.
  20873. func (m *SopNodeMutation) AddedStatus() (r int8, exists bool) {
  20874. v := m.addstatus
  20875. if v == nil {
  20876. return
  20877. }
  20878. return *v, true
  20879. }
  20880. // ClearStatus clears the value of the "status" field.
  20881. func (m *SopNodeMutation) ClearStatus() {
  20882. m.status = nil
  20883. m.addstatus = nil
  20884. m.clearedFields[sopnode.FieldStatus] = struct{}{}
  20885. }
  20886. // StatusCleared returns if the "status" field was cleared in this mutation.
  20887. func (m *SopNodeMutation) StatusCleared() bool {
  20888. _, ok := m.clearedFields[sopnode.FieldStatus]
  20889. return ok
  20890. }
  20891. // ResetStatus resets all changes to the "status" field.
  20892. func (m *SopNodeMutation) ResetStatus() {
  20893. m.status = nil
  20894. m.addstatus = nil
  20895. delete(m.clearedFields, sopnode.FieldStatus)
  20896. }
  20897. // SetDeletedAt sets the "deleted_at" field.
  20898. func (m *SopNodeMutation) SetDeletedAt(t time.Time) {
  20899. m.deleted_at = &t
  20900. }
  20901. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  20902. func (m *SopNodeMutation) DeletedAt() (r time.Time, exists bool) {
  20903. v := m.deleted_at
  20904. if v == nil {
  20905. return
  20906. }
  20907. return *v, true
  20908. }
  20909. // OldDeletedAt returns the old "deleted_at" field's value of the SopNode entity.
  20910. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20911. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20912. func (m *SopNodeMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  20913. if !m.op.Is(OpUpdateOne) {
  20914. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  20915. }
  20916. if m.id == nil || m.oldValue == nil {
  20917. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  20918. }
  20919. oldValue, err := m.oldValue(ctx)
  20920. if err != nil {
  20921. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  20922. }
  20923. return oldValue.DeletedAt, nil
  20924. }
  20925. // ClearDeletedAt clears the value of the "deleted_at" field.
  20926. func (m *SopNodeMutation) ClearDeletedAt() {
  20927. m.deleted_at = nil
  20928. m.clearedFields[sopnode.FieldDeletedAt] = struct{}{}
  20929. }
  20930. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  20931. func (m *SopNodeMutation) DeletedAtCleared() bool {
  20932. _, ok := m.clearedFields[sopnode.FieldDeletedAt]
  20933. return ok
  20934. }
  20935. // ResetDeletedAt resets all changes to the "deleted_at" field.
  20936. func (m *SopNodeMutation) ResetDeletedAt() {
  20937. m.deleted_at = nil
  20938. delete(m.clearedFields, sopnode.FieldDeletedAt)
  20939. }
  20940. // SetStageID sets the "stage_id" field.
  20941. func (m *SopNodeMutation) SetStageID(u uint64) {
  20942. m.sop_stage = &u
  20943. }
  20944. // StageID returns the value of the "stage_id" field in the mutation.
  20945. func (m *SopNodeMutation) StageID() (r uint64, exists bool) {
  20946. v := m.sop_stage
  20947. if v == nil {
  20948. return
  20949. }
  20950. return *v, true
  20951. }
  20952. // OldStageID returns the old "stage_id" field's value of the SopNode entity.
  20953. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  20954. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  20955. func (m *SopNodeMutation) OldStageID(ctx context.Context) (v uint64, err error) {
  20956. if !m.op.Is(OpUpdateOne) {
  20957. return v, errors.New("OldStageID is only allowed on UpdateOne operations")
  20958. }
  20959. if m.id == nil || m.oldValue == nil {
  20960. return v, errors.New("OldStageID requires an ID field in the mutation")
  20961. }
  20962. oldValue, err := m.oldValue(ctx)
  20963. if err != nil {
  20964. return v, fmt.Errorf("querying old value for OldStageID: %w", err)
  20965. }
  20966. return oldValue.StageID, nil
  20967. }
  20968. // ResetStageID resets all changes to the "stage_id" field.
  20969. func (m *SopNodeMutation) ResetStageID() {
  20970. m.sop_stage = nil
  20971. }
  20972. // SetParentID sets the "parent_id" field.
  20973. func (m *SopNodeMutation) SetParentID(u uint64) {
  20974. m.parent_id = &u
  20975. m.addparent_id = nil
  20976. }
  20977. // ParentID returns the value of the "parent_id" field in the mutation.
  20978. func (m *SopNodeMutation) ParentID() (r uint64, exists bool) {
  20979. v := m.parent_id
  20980. if v == nil {
  20981. return
  20982. }
  20983. return *v, true
  20984. }
  20985. // OldParentID returns the old "parent_id" 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) OldParentID(ctx context.Context) (v uint64, err error) {
  20989. if !m.op.Is(OpUpdateOne) {
  20990. return v, errors.New("OldParentID is only allowed on UpdateOne operations")
  20991. }
  20992. if m.id == nil || m.oldValue == nil {
  20993. return v, errors.New("OldParentID 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 OldParentID: %w", err)
  20998. }
  20999. return oldValue.ParentID, nil
  21000. }
  21001. // AddParentID adds u to the "parent_id" field.
  21002. func (m *SopNodeMutation) AddParentID(u int64) {
  21003. if m.addparent_id != nil {
  21004. *m.addparent_id += u
  21005. } else {
  21006. m.addparent_id = &u
  21007. }
  21008. }
  21009. // AddedParentID returns the value that was added to the "parent_id" field in this mutation.
  21010. func (m *SopNodeMutation) AddedParentID() (r int64, exists bool) {
  21011. v := m.addparent_id
  21012. if v == nil {
  21013. return
  21014. }
  21015. return *v, true
  21016. }
  21017. // ResetParentID resets all changes to the "parent_id" field.
  21018. func (m *SopNodeMutation) ResetParentID() {
  21019. m.parent_id = nil
  21020. m.addparent_id = nil
  21021. }
  21022. // SetName sets the "name" field.
  21023. func (m *SopNodeMutation) SetName(s string) {
  21024. m.name = &s
  21025. }
  21026. // Name returns the value of the "name" field in the mutation.
  21027. func (m *SopNodeMutation) Name() (r string, exists bool) {
  21028. v := m.name
  21029. if v == nil {
  21030. return
  21031. }
  21032. return *v, true
  21033. }
  21034. // OldName returns the old "name" field's value of the SopNode entity.
  21035. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21036. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21037. func (m *SopNodeMutation) OldName(ctx context.Context) (v string, err error) {
  21038. if !m.op.Is(OpUpdateOne) {
  21039. return v, errors.New("OldName is only allowed on UpdateOne operations")
  21040. }
  21041. if m.id == nil || m.oldValue == nil {
  21042. return v, errors.New("OldName requires an ID field in the mutation")
  21043. }
  21044. oldValue, err := m.oldValue(ctx)
  21045. if err != nil {
  21046. return v, fmt.Errorf("querying old value for OldName: %w", err)
  21047. }
  21048. return oldValue.Name, nil
  21049. }
  21050. // ResetName resets all changes to the "name" field.
  21051. func (m *SopNodeMutation) ResetName() {
  21052. m.name = nil
  21053. }
  21054. // SetConditionType sets the "condition_type" field.
  21055. func (m *SopNodeMutation) SetConditionType(i int) {
  21056. m.condition_type = &i
  21057. m.addcondition_type = nil
  21058. }
  21059. // ConditionType returns the value of the "condition_type" field in the mutation.
  21060. func (m *SopNodeMutation) ConditionType() (r int, exists bool) {
  21061. v := m.condition_type
  21062. if v == nil {
  21063. return
  21064. }
  21065. return *v, true
  21066. }
  21067. // OldConditionType returns the old "condition_type" field's value of the SopNode entity.
  21068. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21069. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21070. func (m *SopNodeMutation) OldConditionType(ctx context.Context) (v int, err error) {
  21071. if !m.op.Is(OpUpdateOne) {
  21072. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  21073. }
  21074. if m.id == nil || m.oldValue == nil {
  21075. return v, errors.New("OldConditionType requires an ID field in the mutation")
  21076. }
  21077. oldValue, err := m.oldValue(ctx)
  21078. if err != nil {
  21079. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  21080. }
  21081. return oldValue.ConditionType, nil
  21082. }
  21083. // AddConditionType adds i to the "condition_type" field.
  21084. func (m *SopNodeMutation) AddConditionType(i int) {
  21085. if m.addcondition_type != nil {
  21086. *m.addcondition_type += i
  21087. } else {
  21088. m.addcondition_type = &i
  21089. }
  21090. }
  21091. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  21092. func (m *SopNodeMutation) AddedConditionType() (r int, exists bool) {
  21093. v := m.addcondition_type
  21094. if v == nil {
  21095. return
  21096. }
  21097. return *v, true
  21098. }
  21099. // ResetConditionType resets all changes to the "condition_type" field.
  21100. func (m *SopNodeMutation) ResetConditionType() {
  21101. m.condition_type = nil
  21102. m.addcondition_type = nil
  21103. }
  21104. // SetConditionList sets the "condition_list" field.
  21105. func (m *SopNodeMutation) SetConditionList(s []string) {
  21106. m.condition_list = &s
  21107. m.appendcondition_list = nil
  21108. }
  21109. // ConditionList returns the value of the "condition_list" field in the mutation.
  21110. func (m *SopNodeMutation) ConditionList() (r []string, exists bool) {
  21111. v := m.condition_list
  21112. if v == nil {
  21113. return
  21114. }
  21115. return *v, true
  21116. }
  21117. // OldConditionList returns the old "condition_list" field's value of the SopNode entity.
  21118. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21119. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21120. func (m *SopNodeMutation) OldConditionList(ctx context.Context) (v []string, err error) {
  21121. if !m.op.Is(OpUpdateOne) {
  21122. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  21123. }
  21124. if m.id == nil || m.oldValue == nil {
  21125. return v, errors.New("OldConditionList requires an ID field in the mutation")
  21126. }
  21127. oldValue, err := m.oldValue(ctx)
  21128. if err != nil {
  21129. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  21130. }
  21131. return oldValue.ConditionList, nil
  21132. }
  21133. // AppendConditionList adds s to the "condition_list" field.
  21134. func (m *SopNodeMutation) AppendConditionList(s []string) {
  21135. m.appendcondition_list = append(m.appendcondition_list, s...)
  21136. }
  21137. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  21138. func (m *SopNodeMutation) AppendedConditionList() ([]string, bool) {
  21139. if len(m.appendcondition_list) == 0 {
  21140. return nil, false
  21141. }
  21142. return m.appendcondition_list, true
  21143. }
  21144. // ClearConditionList clears the value of the "condition_list" field.
  21145. func (m *SopNodeMutation) ClearConditionList() {
  21146. m.condition_list = nil
  21147. m.appendcondition_list = nil
  21148. m.clearedFields[sopnode.FieldConditionList] = struct{}{}
  21149. }
  21150. // ConditionListCleared returns if the "condition_list" field was cleared in this mutation.
  21151. func (m *SopNodeMutation) ConditionListCleared() bool {
  21152. _, ok := m.clearedFields[sopnode.FieldConditionList]
  21153. return ok
  21154. }
  21155. // ResetConditionList resets all changes to the "condition_list" field.
  21156. func (m *SopNodeMutation) ResetConditionList() {
  21157. m.condition_list = nil
  21158. m.appendcondition_list = nil
  21159. delete(m.clearedFields, sopnode.FieldConditionList)
  21160. }
  21161. // SetNoReplyCondition sets the "no_reply_condition" field.
  21162. func (m *SopNodeMutation) SetNoReplyCondition(u uint64) {
  21163. m.no_reply_condition = &u
  21164. m.addno_reply_condition = nil
  21165. }
  21166. // NoReplyCondition returns the value of the "no_reply_condition" field in the mutation.
  21167. func (m *SopNodeMutation) NoReplyCondition() (r uint64, exists bool) {
  21168. v := m.no_reply_condition
  21169. if v == nil {
  21170. return
  21171. }
  21172. return *v, true
  21173. }
  21174. // OldNoReplyCondition returns the old "no_reply_condition" field's value of the SopNode entity.
  21175. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21176. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21177. func (m *SopNodeMutation) OldNoReplyCondition(ctx context.Context) (v uint64, err error) {
  21178. if !m.op.Is(OpUpdateOne) {
  21179. return v, errors.New("OldNoReplyCondition is only allowed on UpdateOne operations")
  21180. }
  21181. if m.id == nil || m.oldValue == nil {
  21182. return v, errors.New("OldNoReplyCondition requires an ID field in the mutation")
  21183. }
  21184. oldValue, err := m.oldValue(ctx)
  21185. if err != nil {
  21186. return v, fmt.Errorf("querying old value for OldNoReplyCondition: %w", err)
  21187. }
  21188. return oldValue.NoReplyCondition, nil
  21189. }
  21190. // AddNoReplyCondition adds u to the "no_reply_condition" field.
  21191. func (m *SopNodeMutation) AddNoReplyCondition(u int64) {
  21192. if m.addno_reply_condition != nil {
  21193. *m.addno_reply_condition += u
  21194. } else {
  21195. m.addno_reply_condition = &u
  21196. }
  21197. }
  21198. // AddedNoReplyCondition returns the value that was added to the "no_reply_condition" field in this mutation.
  21199. func (m *SopNodeMutation) AddedNoReplyCondition() (r int64, exists bool) {
  21200. v := m.addno_reply_condition
  21201. if v == nil {
  21202. return
  21203. }
  21204. return *v, true
  21205. }
  21206. // ResetNoReplyCondition resets all changes to the "no_reply_condition" field.
  21207. func (m *SopNodeMutation) ResetNoReplyCondition() {
  21208. m.no_reply_condition = nil
  21209. m.addno_reply_condition = nil
  21210. }
  21211. // SetNoReplyUnit sets the "no_reply_unit" field.
  21212. func (m *SopNodeMutation) SetNoReplyUnit(s string) {
  21213. m.no_reply_unit = &s
  21214. }
  21215. // NoReplyUnit returns the value of the "no_reply_unit" field in the mutation.
  21216. func (m *SopNodeMutation) NoReplyUnit() (r string, exists bool) {
  21217. v := m.no_reply_unit
  21218. if v == nil {
  21219. return
  21220. }
  21221. return *v, true
  21222. }
  21223. // OldNoReplyUnit returns the old "no_reply_unit" field's value of the SopNode entity.
  21224. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21225. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21226. func (m *SopNodeMutation) OldNoReplyUnit(ctx context.Context) (v string, err error) {
  21227. if !m.op.Is(OpUpdateOne) {
  21228. return v, errors.New("OldNoReplyUnit is only allowed on UpdateOne operations")
  21229. }
  21230. if m.id == nil || m.oldValue == nil {
  21231. return v, errors.New("OldNoReplyUnit requires an ID field in the mutation")
  21232. }
  21233. oldValue, err := m.oldValue(ctx)
  21234. if err != nil {
  21235. return v, fmt.Errorf("querying old value for OldNoReplyUnit: %w", err)
  21236. }
  21237. return oldValue.NoReplyUnit, nil
  21238. }
  21239. // ResetNoReplyUnit resets all changes to the "no_reply_unit" field.
  21240. func (m *SopNodeMutation) ResetNoReplyUnit() {
  21241. m.no_reply_unit = nil
  21242. }
  21243. // SetActionMessage sets the "action_message" field.
  21244. func (m *SopNodeMutation) SetActionMessage(ct []custom_types.Action) {
  21245. m.action_message = &ct
  21246. m.appendaction_message = nil
  21247. }
  21248. // ActionMessage returns the value of the "action_message" field in the mutation.
  21249. func (m *SopNodeMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  21250. v := m.action_message
  21251. if v == nil {
  21252. return
  21253. }
  21254. return *v, true
  21255. }
  21256. // OldActionMessage returns the old "action_message" field's value of the SopNode entity.
  21257. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21258. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21259. func (m *SopNodeMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  21260. if !m.op.Is(OpUpdateOne) {
  21261. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  21262. }
  21263. if m.id == nil || m.oldValue == nil {
  21264. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  21265. }
  21266. oldValue, err := m.oldValue(ctx)
  21267. if err != nil {
  21268. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  21269. }
  21270. return oldValue.ActionMessage, nil
  21271. }
  21272. // AppendActionMessage adds ct to the "action_message" field.
  21273. func (m *SopNodeMutation) AppendActionMessage(ct []custom_types.Action) {
  21274. m.appendaction_message = append(m.appendaction_message, ct...)
  21275. }
  21276. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  21277. func (m *SopNodeMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  21278. if len(m.appendaction_message) == 0 {
  21279. return nil, false
  21280. }
  21281. return m.appendaction_message, true
  21282. }
  21283. // ClearActionMessage clears the value of the "action_message" field.
  21284. func (m *SopNodeMutation) ClearActionMessage() {
  21285. m.action_message = nil
  21286. m.appendaction_message = nil
  21287. m.clearedFields[sopnode.FieldActionMessage] = struct{}{}
  21288. }
  21289. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  21290. func (m *SopNodeMutation) ActionMessageCleared() bool {
  21291. _, ok := m.clearedFields[sopnode.FieldActionMessage]
  21292. return ok
  21293. }
  21294. // ResetActionMessage resets all changes to the "action_message" field.
  21295. func (m *SopNodeMutation) ResetActionMessage() {
  21296. m.action_message = nil
  21297. m.appendaction_message = nil
  21298. delete(m.clearedFields, sopnode.FieldActionMessage)
  21299. }
  21300. // SetActionLabelAdd sets the "action_label_add" field.
  21301. func (m *SopNodeMutation) SetActionLabelAdd(u []uint64) {
  21302. m.action_label_add = &u
  21303. m.appendaction_label_add = nil
  21304. }
  21305. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  21306. func (m *SopNodeMutation) ActionLabelAdd() (r []uint64, exists bool) {
  21307. v := m.action_label_add
  21308. if v == nil {
  21309. return
  21310. }
  21311. return *v, true
  21312. }
  21313. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopNode entity.
  21314. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21315. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21316. func (m *SopNodeMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  21317. if !m.op.Is(OpUpdateOne) {
  21318. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  21319. }
  21320. if m.id == nil || m.oldValue == nil {
  21321. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  21322. }
  21323. oldValue, err := m.oldValue(ctx)
  21324. if err != nil {
  21325. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  21326. }
  21327. return oldValue.ActionLabelAdd, nil
  21328. }
  21329. // AppendActionLabelAdd adds u to the "action_label_add" field.
  21330. func (m *SopNodeMutation) AppendActionLabelAdd(u []uint64) {
  21331. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  21332. }
  21333. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  21334. func (m *SopNodeMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  21335. if len(m.appendaction_label_add) == 0 {
  21336. return nil, false
  21337. }
  21338. return m.appendaction_label_add, true
  21339. }
  21340. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  21341. func (m *SopNodeMutation) ClearActionLabelAdd() {
  21342. m.action_label_add = nil
  21343. m.appendaction_label_add = nil
  21344. m.clearedFields[sopnode.FieldActionLabelAdd] = struct{}{}
  21345. }
  21346. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  21347. func (m *SopNodeMutation) ActionLabelAddCleared() bool {
  21348. _, ok := m.clearedFields[sopnode.FieldActionLabelAdd]
  21349. return ok
  21350. }
  21351. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  21352. func (m *SopNodeMutation) ResetActionLabelAdd() {
  21353. m.action_label_add = nil
  21354. m.appendaction_label_add = nil
  21355. delete(m.clearedFields, sopnode.FieldActionLabelAdd)
  21356. }
  21357. // SetActionLabelDel sets the "action_label_del" field.
  21358. func (m *SopNodeMutation) SetActionLabelDel(u []uint64) {
  21359. m.action_label_del = &u
  21360. m.appendaction_label_del = nil
  21361. }
  21362. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  21363. func (m *SopNodeMutation) ActionLabelDel() (r []uint64, exists bool) {
  21364. v := m.action_label_del
  21365. if v == nil {
  21366. return
  21367. }
  21368. return *v, true
  21369. }
  21370. // OldActionLabelDel returns the old "action_label_del" field's value of the SopNode entity.
  21371. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21372. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21373. func (m *SopNodeMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  21374. if !m.op.Is(OpUpdateOne) {
  21375. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  21376. }
  21377. if m.id == nil || m.oldValue == nil {
  21378. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  21379. }
  21380. oldValue, err := m.oldValue(ctx)
  21381. if err != nil {
  21382. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  21383. }
  21384. return oldValue.ActionLabelDel, nil
  21385. }
  21386. // AppendActionLabelDel adds u to the "action_label_del" field.
  21387. func (m *SopNodeMutation) AppendActionLabelDel(u []uint64) {
  21388. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  21389. }
  21390. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  21391. func (m *SopNodeMutation) AppendedActionLabelDel() ([]uint64, bool) {
  21392. if len(m.appendaction_label_del) == 0 {
  21393. return nil, false
  21394. }
  21395. return m.appendaction_label_del, true
  21396. }
  21397. // ClearActionLabelDel clears the value of the "action_label_del" field.
  21398. func (m *SopNodeMutation) ClearActionLabelDel() {
  21399. m.action_label_del = nil
  21400. m.appendaction_label_del = nil
  21401. m.clearedFields[sopnode.FieldActionLabelDel] = struct{}{}
  21402. }
  21403. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  21404. func (m *SopNodeMutation) ActionLabelDelCleared() bool {
  21405. _, ok := m.clearedFields[sopnode.FieldActionLabelDel]
  21406. return ok
  21407. }
  21408. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  21409. func (m *SopNodeMutation) ResetActionLabelDel() {
  21410. m.action_label_del = nil
  21411. m.appendaction_label_del = nil
  21412. delete(m.clearedFields, sopnode.FieldActionLabelDel)
  21413. }
  21414. // SetActionForward sets the "action_forward" field.
  21415. func (m *SopNodeMutation) SetActionForward(ctf *custom_types.ActionForward) {
  21416. m.action_forward = &ctf
  21417. }
  21418. // ActionForward returns the value of the "action_forward" field in the mutation.
  21419. func (m *SopNodeMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  21420. v := m.action_forward
  21421. if v == nil {
  21422. return
  21423. }
  21424. return *v, true
  21425. }
  21426. // OldActionForward returns the old "action_forward" field's value of the SopNode entity.
  21427. // If the SopNode object wasn't provided to the builder, the object is fetched from the database.
  21428. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  21429. func (m *SopNodeMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  21430. if !m.op.Is(OpUpdateOne) {
  21431. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  21432. }
  21433. if m.id == nil || m.oldValue == nil {
  21434. return v, errors.New("OldActionForward requires an ID field in the mutation")
  21435. }
  21436. oldValue, err := m.oldValue(ctx)
  21437. if err != nil {
  21438. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  21439. }
  21440. return oldValue.ActionForward, nil
  21441. }
  21442. // ClearActionForward clears the value of the "action_forward" field.
  21443. func (m *SopNodeMutation) ClearActionForward() {
  21444. m.action_forward = nil
  21445. m.clearedFields[sopnode.FieldActionForward] = struct{}{}
  21446. }
  21447. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  21448. func (m *SopNodeMutation) ActionForwardCleared() bool {
  21449. _, ok := m.clearedFields[sopnode.FieldActionForward]
  21450. return ok
  21451. }
  21452. // ResetActionForward resets all changes to the "action_forward" field.
  21453. func (m *SopNodeMutation) ResetActionForward() {
  21454. m.action_forward = nil
  21455. delete(m.clearedFields, sopnode.FieldActionForward)
  21456. }
  21457. // SetSopStageID sets the "sop_stage" edge to the SopStage entity by id.
  21458. func (m *SopNodeMutation) SetSopStageID(id uint64) {
  21459. m.sop_stage = &id
  21460. }
  21461. // ClearSopStage clears the "sop_stage" edge to the SopStage entity.
  21462. func (m *SopNodeMutation) ClearSopStage() {
  21463. m.clearedsop_stage = true
  21464. m.clearedFields[sopnode.FieldStageID] = struct{}{}
  21465. }
  21466. // SopStageCleared reports if the "sop_stage" edge to the SopStage entity was cleared.
  21467. func (m *SopNodeMutation) SopStageCleared() bool {
  21468. return m.clearedsop_stage
  21469. }
  21470. // SopStageID returns the "sop_stage" edge ID in the mutation.
  21471. func (m *SopNodeMutation) SopStageID() (id uint64, exists bool) {
  21472. if m.sop_stage != nil {
  21473. return *m.sop_stage, true
  21474. }
  21475. return
  21476. }
  21477. // SopStageIDs returns the "sop_stage" edge IDs in the mutation.
  21478. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  21479. // SopStageID instead. It exists only for internal usage by the builders.
  21480. func (m *SopNodeMutation) SopStageIDs() (ids []uint64) {
  21481. if id := m.sop_stage; id != nil {
  21482. ids = append(ids, *id)
  21483. }
  21484. return
  21485. }
  21486. // ResetSopStage resets all changes to the "sop_stage" edge.
  21487. func (m *SopNodeMutation) ResetSopStage() {
  21488. m.sop_stage = nil
  21489. m.clearedsop_stage = false
  21490. }
  21491. // AddNodeMessageIDs adds the "node_messages" edge to the MessageRecords entity by ids.
  21492. func (m *SopNodeMutation) AddNodeMessageIDs(ids ...uint64) {
  21493. if m.node_messages == nil {
  21494. m.node_messages = make(map[uint64]struct{})
  21495. }
  21496. for i := range ids {
  21497. m.node_messages[ids[i]] = struct{}{}
  21498. }
  21499. }
  21500. // ClearNodeMessages clears the "node_messages" edge to the MessageRecords entity.
  21501. func (m *SopNodeMutation) ClearNodeMessages() {
  21502. m.clearednode_messages = true
  21503. }
  21504. // NodeMessagesCleared reports if the "node_messages" edge to the MessageRecords entity was cleared.
  21505. func (m *SopNodeMutation) NodeMessagesCleared() bool {
  21506. return m.clearednode_messages
  21507. }
  21508. // RemoveNodeMessageIDs removes the "node_messages" edge to the MessageRecords entity by IDs.
  21509. func (m *SopNodeMutation) RemoveNodeMessageIDs(ids ...uint64) {
  21510. if m.removednode_messages == nil {
  21511. m.removednode_messages = make(map[uint64]struct{})
  21512. }
  21513. for i := range ids {
  21514. delete(m.node_messages, ids[i])
  21515. m.removednode_messages[ids[i]] = struct{}{}
  21516. }
  21517. }
  21518. // RemovedNodeMessages returns the removed IDs of the "node_messages" edge to the MessageRecords entity.
  21519. func (m *SopNodeMutation) RemovedNodeMessagesIDs() (ids []uint64) {
  21520. for id := range m.removednode_messages {
  21521. ids = append(ids, id)
  21522. }
  21523. return
  21524. }
  21525. // NodeMessagesIDs returns the "node_messages" edge IDs in the mutation.
  21526. func (m *SopNodeMutation) NodeMessagesIDs() (ids []uint64) {
  21527. for id := range m.node_messages {
  21528. ids = append(ids, id)
  21529. }
  21530. return
  21531. }
  21532. // ResetNodeMessages resets all changes to the "node_messages" edge.
  21533. func (m *SopNodeMutation) ResetNodeMessages() {
  21534. m.node_messages = nil
  21535. m.clearednode_messages = false
  21536. m.removednode_messages = nil
  21537. }
  21538. // Where appends a list predicates to the SopNodeMutation builder.
  21539. func (m *SopNodeMutation) Where(ps ...predicate.SopNode) {
  21540. m.predicates = append(m.predicates, ps...)
  21541. }
  21542. // WhereP appends storage-level predicates to the SopNodeMutation builder. Using this method,
  21543. // users can use type-assertion to append predicates that do not depend on any generated package.
  21544. func (m *SopNodeMutation) WhereP(ps ...func(*sql.Selector)) {
  21545. p := make([]predicate.SopNode, len(ps))
  21546. for i := range ps {
  21547. p[i] = ps[i]
  21548. }
  21549. m.Where(p...)
  21550. }
  21551. // Op returns the operation name.
  21552. func (m *SopNodeMutation) Op() Op {
  21553. return m.op
  21554. }
  21555. // SetOp allows setting the mutation operation.
  21556. func (m *SopNodeMutation) SetOp(op Op) {
  21557. m.op = op
  21558. }
  21559. // Type returns the node type of this mutation (SopNode).
  21560. func (m *SopNodeMutation) Type() string {
  21561. return m.typ
  21562. }
  21563. // Fields returns all fields that were changed during this mutation. Note that in
  21564. // order to get all numeric fields that were incremented/decremented, call
  21565. // AddedFields().
  21566. func (m *SopNodeMutation) Fields() []string {
  21567. fields := make([]string, 0, 15)
  21568. if m.created_at != nil {
  21569. fields = append(fields, sopnode.FieldCreatedAt)
  21570. }
  21571. if m.updated_at != nil {
  21572. fields = append(fields, sopnode.FieldUpdatedAt)
  21573. }
  21574. if m.status != nil {
  21575. fields = append(fields, sopnode.FieldStatus)
  21576. }
  21577. if m.deleted_at != nil {
  21578. fields = append(fields, sopnode.FieldDeletedAt)
  21579. }
  21580. if m.sop_stage != nil {
  21581. fields = append(fields, sopnode.FieldStageID)
  21582. }
  21583. if m.parent_id != nil {
  21584. fields = append(fields, sopnode.FieldParentID)
  21585. }
  21586. if m.name != nil {
  21587. fields = append(fields, sopnode.FieldName)
  21588. }
  21589. if m.condition_type != nil {
  21590. fields = append(fields, sopnode.FieldConditionType)
  21591. }
  21592. if m.condition_list != nil {
  21593. fields = append(fields, sopnode.FieldConditionList)
  21594. }
  21595. if m.no_reply_condition != nil {
  21596. fields = append(fields, sopnode.FieldNoReplyCondition)
  21597. }
  21598. if m.no_reply_unit != nil {
  21599. fields = append(fields, sopnode.FieldNoReplyUnit)
  21600. }
  21601. if m.action_message != nil {
  21602. fields = append(fields, sopnode.FieldActionMessage)
  21603. }
  21604. if m.action_label_add != nil {
  21605. fields = append(fields, sopnode.FieldActionLabelAdd)
  21606. }
  21607. if m.action_label_del != nil {
  21608. fields = append(fields, sopnode.FieldActionLabelDel)
  21609. }
  21610. if m.action_forward != nil {
  21611. fields = append(fields, sopnode.FieldActionForward)
  21612. }
  21613. return fields
  21614. }
  21615. // Field returns the value of a field with the given name. The second boolean
  21616. // return value indicates that this field was not set, or was not defined in the
  21617. // schema.
  21618. func (m *SopNodeMutation) Field(name string) (ent.Value, bool) {
  21619. switch name {
  21620. case sopnode.FieldCreatedAt:
  21621. return m.CreatedAt()
  21622. case sopnode.FieldUpdatedAt:
  21623. return m.UpdatedAt()
  21624. case sopnode.FieldStatus:
  21625. return m.Status()
  21626. case sopnode.FieldDeletedAt:
  21627. return m.DeletedAt()
  21628. case sopnode.FieldStageID:
  21629. return m.StageID()
  21630. case sopnode.FieldParentID:
  21631. return m.ParentID()
  21632. case sopnode.FieldName:
  21633. return m.Name()
  21634. case sopnode.FieldConditionType:
  21635. return m.ConditionType()
  21636. case sopnode.FieldConditionList:
  21637. return m.ConditionList()
  21638. case sopnode.FieldNoReplyCondition:
  21639. return m.NoReplyCondition()
  21640. case sopnode.FieldNoReplyUnit:
  21641. return m.NoReplyUnit()
  21642. case sopnode.FieldActionMessage:
  21643. return m.ActionMessage()
  21644. case sopnode.FieldActionLabelAdd:
  21645. return m.ActionLabelAdd()
  21646. case sopnode.FieldActionLabelDel:
  21647. return m.ActionLabelDel()
  21648. case sopnode.FieldActionForward:
  21649. return m.ActionForward()
  21650. }
  21651. return nil, false
  21652. }
  21653. // OldField returns the old value of the field from the database. An error is
  21654. // returned if the mutation operation is not UpdateOne, or the query to the
  21655. // database failed.
  21656. func (m *SopNodeMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  21657. switch name {
  21658. case sopnode.FieldCreatedAt:
  21659. return m.OldCreatedAt(ctx)
  21660. case sopnode.FieldUpdatedAt:
  21661. return m.OldUpdatedAt(ctx)
  21662. case sopnode.FieldStatus:
  21663. return m.OldStatus(ctx)
  21664. case sopnode.FieldDeletedAt:
  21665. return m.OldDeletedAt(ctx)
  21666. case sopnode.FieldStageID:
  21667. return m.OldStageID(ctx)
  21668. case sopnode.FieldParentID:
  21669. return m.OldParentID(ctx)
  21670. case sopnode.FieldName:
  21671. return m.OldName(ctx)
  21672. case sopnode.FieldConditionType:
  21673. return m.OldConditionType(ctx)
  21674. case sopnode.FieldConditionList:
  21675. return m.OldConditionList(ctx)
  21676. case sopnode.FieldNoReplyCondition:
  21677. return m.OldNoReplyCondition(ctx)
  21678. case sopnode.FieldNoReplyUnit:
  21679. return m.OldNoReplyUnit(ctx)
  21680. case sopnode.FieldActionMessage:
  21681. return m.OldActionMessage(ctx)
  21682. case sopnode.FieldActionLabelAdd:
  21683. return m.OldActionLabelAdd(ctx)
  21684. case sopnode.FieldActionLabelDel:
  21685. return m.OldActionLabelDel(ctx)
  21686. case sopnode.FieldActionForward:
  21687. return m.OldActionForward(ctx)
  21688. }
  21689. return nil, fmt.Errorf("unknown SopNode field %s", name)
  21690. }
  21691. // SetField sets the value of a field with the given name. It returns an error if
  21692. // the field is not defined in the schema, or if the type mismatched the field
  21693. // type.
  21694. func (m *SopNodeMutation) SetField(name string, value ent.Value) error {
  21695. switch name {
  21696. case sopnode.FieldCreatedAt:
  21697. v, ok := value.(time.Time)
  21698. if !ok {
  21699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21700. }
  21701. m.SetCreatedAt(v)
  21702. return nil
  21703. case sopnode.FieldUpdatedAt:
  21704. v, ok := value.(time.Time)
  21705. if !ok {
  21706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21707. }
  21708. m.SetUpdatedAt(v)
  21709. return nil
  21710. case sopnode.FieldStatus:
  21711. v, ok := value.(uint8)
  21712. if !ok {
  21713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21714. }
  21715. m.SetStatus(v)
  21716. return nil
  21717. case sopnode.FieldDeletedAt:
  21718. v, ok := value.(time.Time)
  21719. if !ok {
  21720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21721. }
  21722. m.SetDeletedAt(v)
  21723. return nil
  21724. case sopnode.FieldStageID:
  21725. v, ok := value.(uint64)
  21726. if !ok {
  21727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21728. }
  21729. m.SetStageID(v)
  21730. return nil
  21731. case sopnode.FieldParentID:
  21732. v, ok := value.(uint64)
  21733. if !ok {
  21734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21735. }
  21736. m.SetParentID(v)
  21737. return nil
  21738. case sopnode.FieldName:
  21739. v, ok := value.(string)
  21740. if !ok {
  21741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21742. }
  21743. m.SetName(v)
  21744. return nil
  21745. case sopnode.FieldConditionType:
  21746. v, ok := value.(int)
  21747. if !ok {
  21748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21749. }
  21750. m.SetConditionType(v)
  21751. return nil
  21752. case sopnode.FieldConditionList:
  21753. v, ok := value.([]string)
  21754. if !ok {
  21755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21756. }
  21757. m.SetConditionList(v)
  21758. return nil
  21759. case sopnode.FieldNoReplyCondition:
  21760. v, ok := value.(uint64)
  21761. if !ok {
  21762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21763. }
  21764. m.SetNoReplyCondition(v)
  21765. return nil
  21766. case sopnode.FieldNoReplyUnit:
  21767. v, ok := value.(string)
  21768. if !ok {
  21769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21770. }
  21771. m.SetNoReplyUnit(v)
  21772. return nil
  21773. case sopnode.FieldActionMessage:
  21774. v, ok := value.([]custom_types.Action)
  21775. if !ok {
  21776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21777. }
  21778. m.SetActionMessage(v)
  21779. return nil
  21780. case sopnode.FieldActionLabelAdd:
  21781. v, ok := value.([]uint64)
  21782. if !ok {
  21783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21784. }
  21785. m.SetActionLabelAdd(v)
  21786. return nil
  21787. case sopnode.FieldActionLabelDel:
  21788. v, ok := value.([]uint64)
  21789. if !ok {
  21790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21791. }
  21792. m.SetActionLabelDel(v)
  21793. return nil
  21794. case sopnode.FieldActionForward:
  21795. v, ok := value.(*custom_types.ActionForward)
  21796. if !ok {
  21797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21798. }
  21799. m.SetActionForward(v)
  21800. return nil
  21801. }
  21802. return fmt.Errorf("unknown SopNode field %s", name)
  21803. }
  21804. // AddedFields returns all numeric fields that were incremented/decremented during
  21805. // this mutation.
  21806. func (m *SopNodeMutation) AddedFields() []string {
  21807. var fields []string
  21808. if m.addstatus != nil {
  21809. fields = append(fields, sopnode.FieldStatus)
  21810. }
  21811. if m.addparent_id != nil {
  21812. fields = append(fields, sopnode.FieldParentID)
  21813. }
  21814. if m.addcondition_type != nil {
  21815. fields = append(fields, sopnode.FieldConditionType)
  21816. }
  21817. if m.addno_reply_condition != nil {
  21818. fields = append(fields, sopnode.FieldNoReplyCondition)
  21819. }
  21820. return fields
  21821. }
  21822. // AddedField returns the numeric value that was incremented/decremented on a field
  21823. // with the given name. The second boolean return value indicates that this field
  21824. // was not set, or was not defined in the schema.
  21825. func (m *SopNodeMutation) AddedField(name string) (ent.Value, bool) {
  21826. switch name {
  21827. case sopnode.FieldStatus:
  21828. return m.AddedStatus()
  21829. case sopnode.FieldParentID:
  21830. return m.AddedParentID()
  21831. case sopnode.FieldConditionType:
  21832. return m.AddedConditionType()
  21833. case sopnode.FieldNoReplyCondition:
  21834. return m.AddedNoReplyCondition()
  21835. }
  21836. return nil, false
  21837. }
  21838. // AddField adds the value to the field with the given name. It returns an error if
  21839. // the field is not defined in the schema, or if the type mismatched the field
  21840. // type.
  21841. func (m *SopNodeMutation) AddField(name string, value ent.Value) error {
  21842. switch name {
  21843. case sopnode.FieldStatus:
  21844. v, ok := value.(int8)
  21845. if !ok {
  21846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21847. }
  21848. m.AddStatus(v)
  21849. return nil
  21850. case sopnode.FieldParentID:
  21851. v, ok := value.(int64)
  21852. if !ok {
  21853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21854. }
  21855. m.AddParentID(v)
  21856. return nil
  21857. case sopnode.FieldConditionType:
  21858. v, ok := value.(int)
  21859. if !ok {
  21860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21861. }
  21862. m.AddConditionType(v)
  21863. return nil
  21864. case sopnode.FieldNoReplyCondition:
  21865. v, ok := value.(int64)
  21866. if !ok {
  21867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  21868. }
  21869. m.AddNoReplyCondition(v)
  21870. return nil
  21871. }
  21872. return fmt.Errorf("unknown SopNode numeric field %s", name)
  21873. }
  21874. // ClearedFields returns all nullable fields that were cleared during this
  21875. // mutation.
  21876. func (m *SopNodeMutation) ClearedFields() []string {
  21877. var fields []string
  21878. if m.FieldCleared(sopnode.FieldStatus) {
  21879. fields = append(fields, sopnode.FieldStatus)
  21880. }
  21881. if m.FieldCleared(sopnode.FieldDeletedAt) {
  21882. fields = append(fields, sopnode.FieldDeletedAt)
  21883. }
  21884. if m.FieldCleared(sopnode.FieldConditionList) {
  21885. fields = append(fields, sopnode.FieldConditionList)
  21886. }
  21887. if m.FieldCleared(sopnode.FieldActionMessage) {
  21888. fields = append(fields, sopnode.FieldActionMessage)
  21889. }
  21890. if m.FieldCleared(sopnode.FieldActionLabelAdd) {
  21891. fields = append(fields, sopnode.FieldActionLabelAdd)
  21892. }
  21893. if m.FieldCleared(sopnode.FieldActionLabelDel) {
  21894. fields = append(fields, sopnode.FieldActionLabelDel)
  21895. }
  21896. if m.FieldCleared(sopnode.FieldActionForward) {
  21897. fields = append(fields, sopnode.FieldActionForward)
  21898. }
  21899. return fields
  21900. }
  21901. // FieldCleared returns a boolean indicating if a field with the given name was
  21902. // cleared in this mutation.
  21903. func (m *SopNodeMutation) FieldCleared(name string) bool {
  21904. _, ok := m.clearedFields[name]
  21905. return ok
  21906. }
  21907. // ClearField clears the value of the field with the given name. It returns an
  21908. // error if the field is not defined in the schema.
  21909. func (m *SopNodeMutation) ClearField(name string) error {
  21910. switch name {
  21911. case sopnode.FieldStatus:
  21912. m.ClearStatus()
  21913. return nil
  21914. case sopnode.FieldDeletedAt:
  21915. m.ClearDeletedAt()
  21916. return nil
  21917. case sopnode.FieldConditionList:
  21918. m.ClearConditionList()
  21919. return nil
  21920. case sopnode.FieldActionMessage:
  21921. m.ClearActionMessage()
  21922. return nil
  21923. case sopnode.FieldActionLabelAdd:
  21924. m.ClearActionLabelAdd()
  21925. return nil
  21926. case sopnode.FieldActionLabelDel:
  21927. m.ClearActionLabelDel()
  21928. return nil
  21929. case sopnode.FieldActionForward:
  21930. m.ClearActionForward()
  21931. return nil
  21932. }
  21933. return fmt.Errorf("unknown SopNode nullable field %s", name)
  21934. }
  21935. // ResetField resets all changes in the mutation for the field with the given name.
  21936. // It returns an error if the field is not defined in the schema.
  21937. func (m *SopNodeMutation) ResetField(name string) error {
  21938. switch name {
  21939. case sopnode.FieldCreatedAt:
  21940. m.ResetCreatedAt()
  21941. return nil
  21942. case sopnode.FieldUpdatedAt:
  21943. m.ResetUpdatedAt()
  21944. return nil
  21945. case sopnode.FieldStatus:
  21946. m.ResetStatus()
  21947. return nil
  21948. case sopnode.FieldDeletedAt:
  21949. m.ResetDeletedAt()
  21950. return nil
  21951. case sopnode.FieldStageID:
  21952. m.ResetStageID()
  21953. return nil
  21954. case sopnode.FieldParentID:
  21955. m.ResetParentID()
  21956. return nil
  21957. case sopnode.FieldName:
  21958. m.ResetName()
  21959. return nil
  21960. case sopnode.FieldConditionType:
  21961. m.ResetConditionType()
  21962. return nil
  21963. case sopnode.FieldConditionList:
  21964. m.ResetConditionList()
  21965. return nil
  21966. case sopnode.FieldNoReplyCondition:
  21967. m.ResetNoReplyCondition()
  21968. return nil
  21969. case sopnode.FieldNoReplyUnit:
  21970. m.ResetNoReplyUnit()
  21971. return nil
  21972. case sopnode.FieldActionMessage:
  21973. m.ResetActionMessage()
  21974. return nil
  21975. case sopnode.FieldActionLabelAdd:
  21976. m.ResetActionLabelAdd()
  21977. return nil
  21978. case sopnode.FieldActionLabelDel:
  21979. m.ResetActionLabelDel()
  21980. return nil
  21981. case sopnode.FieldActionForward:
  21982. m.ResetActionForward()
  21983. return nil
  21984. }
  21985. return fmt.Errorf("unknown SopNode field %s", name)
  21986. }
  21987. // AddedEdges returns all edge names that were set/added in this mutation.
  21988. func (m *SopNodeMutation) AddedEdges() []string {
  21989. edges := make([]string, 0, 2)
  21990. if m.sop_stage != nil {
  21991. edges = append(edges, sopnode.EdgeSopStage)
  21992. }
  21993. if m.node_messages != nil {
  21994. edges = append(edges, sopnode.EdgeNodeMessages)
  21995. }
  21996. return edges
  21997. }
  21998. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  21999. // name in this mutation.
  22000. func (m *SopNodeMutation) AddedIDs(name string) []ent.Value {
  22001. switch name {
  22002. case sopnode.EdgeSopStage:
  22003. if id := m.sop_stage; id != nil {
  22004. return []ent.Value{*id}
  22005. }
  22006. case sopnode.EdgeNodeMessages:
  22007. ids := make([]ent.Value, 0, len(m.node_messages))
  22008. for id := range m.node_messages {
  22009. ids = append(ids, id)
  22010. }
  22011. return ids
  22012. }
  22013. return nil
  22014. }
  22015. // RemovedEdges returns all edge names that were removed in this mutation.
  22016. func (m *SopNodeMutation) RemovedEdges() []string {
  22017. edges := make([]string, 0, 2)
  22018. if m.removednode_messages != nil {
  22019. edges = append(edges, sopnode.EdgeNodeMessages)
  22020. }
  22021. return edges
  22022. }
  22023. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  22024. // the given name in this mutation.
  22025. func (m *SopNodeMutation) RemovedIDs(name string) []ent.Value {
  22026. switch name {
  22027. case sopnode.EdgeNodeMessages:
  22028. ids := make([]ent.Value, 0, len(m.removednode_messages))
  22029. for id := range m.removednode_messages {
  22030. ids = append(ids, id)
  22031. }
  22032. return ids
  22033. }
  22034. return nil
  22035. }
  22036. // ClearedEdges returns all edge names that were cleared in this mutation.
  22037. func (m *SopNodeMutation) ClearedEdges() []string {
  22038. edges := make([]string, 0, 2)
  22039. if m.clearedsop_stage {
  22040. edges = append(edges, sopnode.EdgeSopStage)
  22041. }
  22042. if m.clearednode_messages {
  22043. edges = append(edges, sopnode.EdgeNodeMessages)
  22044. }
  22045. return edges
  22046. }
  22047. // EdgeCleared returns a boolean which indicates if the edge with the given name
  22048. // was cleared in this mutation.
  22049. func (m *SopNodeMutation) EdgeCleared(name string) bool {
  22050. switch name {
  22051. case sopnode.EdgeSopStage:
  22052. return m.clearedsop_stage
  22053. case sopnode.EdgeNodeMessages:
  22054. return m.clearednode_messages
  22055. }
  22056. return false
  22057. }
  22058. // ClearEdge clears the value of the edge with the given name. It returns an error
  22059. // if that edge is not defined in the schema.
  22060. func (m *SopNodeMutation) ClearEdge(name string) error {
  22061. switch name {
  22062. case sopnode.EdgeSopStage:
  22063. m.ClearSopStage()
  22064. return nil
  22065. }
  22066. return fmt.Errorf("unknown SopNode unique edge %s", name)
  22067. }
  22068. // ResetEdge resets all changes to the edge with the given name in this mutation.
  22069. // It returns an error if the edge is not defined in the schema.
  22070. func (m *SopNodeMutation) ResetEdge(name string) error {
  22071. switch name {
  22072. case sopnode.EdgeSopStage:
  22073. m.ResetSopStage()
  22074. return nil
  22075. case sopnode.EdgeNodeMessages:
  22076. m.ResetNodeMessages()
  22077. return nil
  22078. }
  22079. return fmt.Errorf("unknown SopNode edge %s", name)
  22080. }
  22081. // SopStageMutation represents an operation that mutates the SopStage nodes in the graph.
  22082. type SopStageMutation struct {
  22083. config
  22084. op Op
  22085. typ string
  22086. id *uint64
  22087. created_at *time.Time
  22088. updated_at *time.Time
  22089. status *uint8
  22090. addstatus *int8
  22091. deleted_at *time.Time
  22092. name *string
  22093. condition_type *int
  22094. addcondition_type *int
  22095. condition_operator *int
  22096. addcondition_operator *int
  22097. condition_list *[]custom_types.Condition
  22098. appendcondition_list []custom_types.Condition
  22099. action_message *[]custom_types.Action
  22100. appendaction_message []custom_types.Action
  22101. action_label_add *[]uint64
  22102. appendaction_label_add []uint64
  22103. action_label_del *[]uint64
  22104. appendaction_label_del []uint64
  22105. action_forward **custom_types.ActionForward
  22106. index_sort *int
  22107. addindex_sort *int
  22108. clearedFields map[string]struct{}
  22109. sop_task *uint64
  22110. clearedsop_task bool
  22111. stage_nodes map[uint64]struct{}
  22112. removedstage_nodes map[uint64]struct{}
  22113. clearedstage_nodes bool
  22114. stage_messages map[uint64]struct{}
  22115. removedstage_messages map[uint64]struct{}
  22116. clearedstage_messages bool
  22117. done bool
  22118. oldValue func(context.Context) (*SopStage, error)
  22119. predicates []predicate.SopStage
  22120. }
  22121. var _ ent.Mutation = (*SopStageMutation)(nil)
  22122. // sopstageOption allows management of the mutation configuration using functional options.
  22123. type sopstageOption func(*SopStageMutation)
  22124. // newSopStageMutation creates new mutation for the SopStage entity.
  22125. func newSopStageMutation(c config, op Op, opts ...sopstageOption) *SopStageMutation {
  22126. m := &SopStageMutation{
  22127. config: c,
  22128. op: op,
  22129. typ: TypeSopStage,
  22130. clearedFields: make(map[string]struct{}),
  22131. }
  22132. for _, opt := range opts {
  22133. opt(m)
  22134. }
  22135. return m
  22136. }
  22137. // withSopStageID sets the ID field of the mutation.
  22138. func withSopStageID(id uint64) sopstageOption {
  22139. return func(m *SopStageMutation) {
  22140. var (
  22141. err error
  22142. once sync.Once
  22143. value *SopStage
  22144. )
  22145. m.oldValue = func(ctx context.Context) (*SopStage, error) {
  22146. once.Do(func() {
  22147. if m.done {
  22148. err = errors.New("querying old values post mutation is not allowed")
  22149. } else {
  22150. value, err = m.Client().SopStage.Get(ctx, id)
  22151. }
  22152. })
  22153. return value, err
  22154. }
  22155. m.id = &id
  22156. }
  22157. }
  22158. // withSopStage sets the old SopStage of the mutation.
  22159. func withSopStage(node *SopStage) sopstageOption {
  22160. return func(m *SopStageMutation) {
  22161. m.oldValue = func(context.Context) (*SopStage, error) {
  22162. return node, nil
  22163. }
  22164. m.id = &node.ID
  22165. }
  22166. }
  22167. // Client returns a new `ent.Client` from the mutation. If the mutation was
  22168. // executed in a transaction (ent.Tx), a transactional client is returned.
  22169. func (m SopStageMutation) Client() *Client {
  22170. client := &Client{config: m.config}
  22171. client.init()
  22172. return client
  22173. }
  22174. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  22175. // it returns an error otherwise.
  22176. func (m SopStageMutation) Tx() (*Tx, error) {
  22177. if _, ok := m.driver.(*txDriver); !ok {
  22178. return nil, errors.New("ent: mutation is not running in a transaction")
  22179. }
  22180. tx := &Tx{config: m.config}
  22181. tx.init()
  22182. return tx, nil
  22183. }
  22184. // SetID sets the value of the id field. Note that this
  22185. // operation is only accepted on creation of SopStage entities.
  22186. func (m *SopStageMutation) SetID(id uint64) {
  22187. m.id = &id
  22188. }
  22189. // ID returns the ID value in the mutation. Note that the ID is only available
  22190. // if it was provided to the builder or after it was returned from the database.
  22191. func (m *SopStageMutation) ID() (id uint64, exists bool) {
  22192. if m.id == nil {
  22193. return
  22194. }
  22195. return *m.id, true
  22196. }
  22197. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  22198. // That means, if the mutation is applied within a transaction with an isolation level such
  22199. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  22200. // or updated by the mutation.
  22201. func (m *SopStageMutation) IDs(ctx context.Context) ([]uint64, error) {
  22202. switch {
  22203. case m.op.Is(OpUpdateOne | OpDeleteOne):
  22204. id, exists := m.ID()
  22205. if exists {
  22206. return []uint64{id}, nil
  22207. }
  22208. fallthrough
  22209. case m.op.Is(OpUpdate | OpDelete):
  22210. return m.Client().SopStage.Query().Where(m.predicates...).IDs(ctx)
  22211. default:
  22212. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  22213. }
  22214. }
  22215. // SetCreatedAt sets the "created_at" field.
  22216. func (m *SopStageMutation) SetCreatedAt(t time.Time) {
  22217. m.created_at = &t
  22218. }
  22219. // CreatedAt returns the value of the "created_at" field in the mutation.
  22220. func (m *SopStageMutation) CreatedAt() (r time.Time, exists bool) {
  22221. v := m.created_at
  22222. if v == nil {
  22223. return
  22224. }
  22225. return *v, true
  22226. }
  22227. // OldCreatedAt returns the old "created_at" field's value of the SopStage entity.
  22228. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22230. func (m *SopStageMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  22231. if !m.op.Is(OpUpdateOne) {
  22232. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  22233. }
  22234. if m.id == nil || m.oldValue == nil {
  22235. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  22236. }
  22237. oldValue, err := m.oldValue(ctx)
  22238. if err != nil {
  22239. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  22240. }
  22241. return oldValue.CreatedAt, nil
  22242. }
  22243. // ResetCreatedAt resets all changes to the "created_at" field.
  22244. func (m *SopStageMutation) ResetCreatedAt() {
  22245. m.created_at = nil
  22246. }
  22247. // SetUpdatedAt sets the "updated_at" field.
  22248. func (m *SopStageMutation) SetUpdatedAt(t time.Time) {
  22249. m.updated_at = &t
  22250. }
  22251. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  22252. func (m *SopStageMutation) UpdatedAt() (r time.Time, exists bool) {
  22253. v := m.updated_at
  22254. if v == nil {
  22255. return
  22256. }
  22257. return *v, true
  22258. }
  22259. // OldUpdatedAt returns the old "updated_at" field's value of the SopStage entity.
  22260. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22262. func (m *SopStageMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  22263. if !m.op.Is(OpUpdateOne) {
  22264. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  22265. }
  22266. if m.id == nil || m.oldValue == nil {
  22267. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  22268. }
  22269. oldValue, err := m.oldValue(ctx)
  22270. if err != nil {
  22271. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  22272. }
  22273. return oldValue.UpdatedAt, nil
  22274. }
  22275. // ResetUpdatedAt resets all changes to the "updated_at" field.
  22276. func (m *SopStageMutation) ResetUpdatedAt() {
  22277. m.updated_at = nil
  22278. }
  22279. // SetStatus sets the "status" field.
  22280. func (m *SopStageMutation) SetStatus(u uint8) {
  22281. m.status = &u
  22282. m.addstatus = nil
  22283. }
  22284. // Status returns the value of the "status" field in the mutation.
  22285. func (m *SopStageMutation) Status() (r uint8, exists bool) {
  22286. v := m.status
  22287. if v == nil {
  22288. return
  22289. }
  22290. return *v, true
  22291. }
  22292. // OldStatus returns the old "status" field's value of the SopStage entity.
  22293. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22294. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22295. func (m *SopStageMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  22296. if !m.op.Is(OpUpdateOne) {
  22297. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  22298. }
  22299. if m.id == nil || m.oldValue == nil {
  22300. return v, errors.New("OldStatus requires an ID field in the mutation")
  22301. }
  22302. oldValue, err := m.oldValue(ctx)
  22303. if err != nil {
  22304. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  22305. }
  22306. return oldValue.Status, nil
  22307. }
  22308. // AddStatus adds u to the "status" field.
  22309. func (m *SopStageMutation) AddStatus(u int8) {
  22310. if m.addstatus != nil {
  22311. *m.addstatus += u
  22312. } else {
  22313. m.addstatus = &u
  22314. }
  22315. }
  22316. // AddedStatus returns the value that was added to the "status" field in this mutation.
  22317. func (m *SopStageMutation) AddedStatus() (r int8, exists bool) {
  22318. v := m.addstatus
  22319. if v == nil {
  22320. return
  22321. }
  22322. return *v, true
  22323. }
  22324. // ClearStatus clears the value of the "status" field.
  22325. func (m *SopStageMutation) ClearStatus() {
  22326. m.status = nil
  22327. m.addstatus = nil
  22328. m.clearedFields[sopstage.FieldStatus] = struct{}{}
  22329. }
  22330. // StatusCleared returns if the "status" field was cleared in this mutation.
  22331. func (m *SopStageMutation) StatusCleared() bool {
  22332. _, ok := m.clearedFields[sopstage.FieldStatus]
  22333. return ok
  22334. }
  22335. // ResetStatus resets all changes to the "status" field.
  22336. func (m *SopStageMutation) ResetStatus() {
  22337. m.status = nil
  22338. m.addstatus = nil
  22339. delete(m.clearedFields, sopstage.FieldStatus)
  22340. }
  22341. // SetDeletedAt sets the "deleted_at" field.
  22342. func (m *SopStageMutation) SetDeletedAt(t time.Time) {
  22343. m.deleted_at = &t
  22344. }
  22345. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  22346. func (m *SopStageMutation) DeletedAt() (r time.Time, exists bool) {
  22347. v := m.deleted_at
  22348. if v == nil {
  22349. return
  22350. }
  22351. return *v, true
  22352. }
  22353. // OldDeletedAt returns the old "deleted_at" field's value of the SopStage entity.
  22354. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22355. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22356. func (m *SopStageMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  22357. if !m.op.Is(OpUpdateOne) {
  22358. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  22359. }
  22360. if m.id == nil || m.oldValue == nil {
  22361. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  22362. }
  22363. oldValue, err := m.oldValue(ctx)
  22364. if err != nil {
  22365. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  22366. }
  22367. return oldValue.DeletedAt, nil
  22368. }
  22369. // ClearDeletedAt clears the value of the "deleted_at" field.
  22370. func (m *SopStageMutation) ClearDeletedAt() {
  22371. m.deleted_at = nil
  22372. m.clearedFields[sopstage.FieldDeletedAt] = struct{}{}
  22373. }
  22374. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  22375. func (m *SopStageMutation) DeletedAtCleared() bool {
  22376. _, ok := m.clearedFields[sopstage.FieldDeletedAt]
  22377. return ok
  22378. }
  22379. // ResetDeletedAt resets all changes to the "deleted_at" field.
  22380. func (m *SopStageMutation) ResetDeletedAt() {
  22381. m.deleted_at = nil
  22382. delete(m.clearedFields, sopstage.FieldDeletedAt)
  22383. }
  22384. // SetTaskID sets the "task_id" field.
  22385. func (m *SopStageMutation) SetTaskID(u uint64) {
  22386. m.sop_task = &u
  22387. }
  22388. // TaskID returns the value of the "task_id" field in the mutation.
  22389. func (m *SopStageMutation) TaskID() (r uint64, exists bool) {
  22390. v := m.sop_task
  22391. if v == nil {
  22392. return
  22393. }
  22394. return *v, true
  22395. }
  22396. // OldTaskID returns the old "task_id" field's value of the SopStage entity.
  22397. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22399. func (m *SopStageMutation) OldTaskID(ctx context.Context) (v uint64, err error) {
  22400. if !m.op.Is(OpUpdateOne) {
  22401. return v, errors.New("OldTaskID is only allowed on UpdateOne operations")
  22402. }
  22403. if m.id == nil || m.oldValue == nil {
  22404. return v, errors.New("OldTaskID requires an ID field in the mutation")
  22405. }
  22406. oldValue, err := m.oldValue(ctx)
  22407. if err != nil {
  22408. return v, fmt.Errorf("querying old value for OldTaskID: %w", err)
  22409. }
  22410. return oldValue.TaskID, nil
  22411. }
  22412. // ResetTaskID resets all changes to the "task_id" field.
  22413. func (m *SopStageMutation) ResetTaskID() {
  22414. m.sop_task = nil
  22415. }
  22416. // SetName sets the "name" field.
  22417. func (m *SopStageMutation) SetName(s string) {
  22418. m.name = &s
  22419. }
  22420. // Name returns the value of the "name" field in the mutation.
  22421. func (m *SopStageMutation) Name() (r string, exists bool) {
  22422. v := m.name
  22423. if v == nil {
  22424. return
  22425. }
  22426. return *v, true
  22427. }
  22428. // OldName returns the old "name" field's value of the SopStage entity.
  22429. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22431. func (m *SopStageMutation) OldName(ctx context.Context) (v string, err error) {
  22432. if !m.op.Is(OpUpdateOne) {
  22433. return v, errors.New("OldName is only allowed on UpdateOne operations")
  22434. }
  22435. if m.id == nil || m.oldValue == nil {
  22436. return v, errors.New("OldName requires an ID field in the mutation")
  22437. }
  22438. oldValue, err := m.oldValue(ctx)
  22439. if err != nil {
  22440. return v, fmt.Errorf("querying old value for OldName: %w", err)
  22441. }
  22442. return oldValue.Name, nil
  22443. }
  22444. // ResetName resets all changes to the "name" field.
  22445. func (m *SopStageMutation) ResetName() {
  22446. m.name = nil
  22447. }
  22448. // SetConditionType sets the "condition_type" field.
  22449. func (m *SopStageMutation) SetConditionType(i int) {
  22450. m.condition_type = &i
  22451. m.addcondition_type = nil
  22452. }
  22453. // ConditionType returns the value of the "condition_type" field in the mutation.
  22454. func (m *SopStageMutation) ConditionType() (r int, exists bool) {
  22455. v := m.condition_type
  22456. if v == nil {
  22457. return
  22458. }
  22459. return *v, true
  22460. }
  22461. // OldConditionType returns the old "condition_type" field's value of the SopStage entity.
  22462. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22463. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22464. func (m *SopStageMutation) OldConditionType(ctx context.Context) (v int, err error) {
  22465. if !m.op.Is(OpUpdateOne) {
  22466. return v, errors.New("OldConditionType is only allowed on UpdateOne operations")
  22467. }
  22468. if m.id == nil || m.oldValue == nil {
  22469. return v, errors.New("OldConditionType requires an ID field in the mutation")
  22470. }
  22471. oldValue, err := m.oldValue(ctx)
  22472. if err != nil {
  22473. return v, fmt.Errorf("querying old value for OldConditionType: %w", err)
  22474. }
  22475. return oldValue.ConditionType, nil
  22476. }
  22477. // AddConditionType adds i to the "condition_type" field.
  22478. func (m *SopStageMutation) AddConditionType(i int) {
  22479. if m.addcondition_type != nil {
  22480. *m.addcondition_type += i
  22481. } else {
  22482. m.addcondition_type = &i
  22483. }
  22484. }
  22485. // AddedConditionType returns the value that was added to the "condition_type" field in this mutation.
  22486. func (m *SopStageMutation) AddedConditionType() (r int, exists bool) {
  22487. v := m.addcondition_type
  22488. if v == nil {
  22489. return
  22490. }
  22491. return *v, true
  22492. }
  22493. // ResetConditionType resets all changes to the "condition_type" field.
  22494. func (m *SopStageMutation) ResetConditionType() {
  22495. m.condition_type = nil
  22496. m.addcondition_type = nil
  22497. }
  22498. // SetConditionOperator sets the "condition_operator" field.
  22499. func (m *SopStageMutation) SetConditionOperator(i int) {
  22500. m.condition_operator = &i
  22501. m.addcondition_operator = nil
  22502. }
  22503. // ConditionOperator returns the value of the "condition_operator" field in the mutation.
  22504. func (m *SopStageMutation) ConditionOperator() (r int, exists bool) {
  22505. v := m.condition_operator
  22506. if v == nil {
  22507. return
  22508. }
  22509. return *v, true
  22510. }
  22511. // OldConditionOperator returns the old "condition_operator" field's value of the SopStage entity.
  22512. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22513. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22514. func (m *SopStageMutation) OldConditionOperator(ctx context.Context) (v int, err error) {
  22515. if !m.op.Is(OpUpdateOne) {
  22516. return v, errors.New("OldConditionOperator is only allowed on UpdateOne operations")
  22517. }
  22518. if m.id == nil || m.oldValue == nil {
  22519. return v, errors.New("OldConditionOperator requires an ID field in the mutation")
  22520. }
  22521. oldValue, err := m.oldValue(ctx)
  22522. if err != nil {
  22523. return v, fmt.Errorf("querying old value for OldConditionOperator: %w", err)
  22524. }
  22525. return oldValue.ConditionOperator, nil
  22526. }
  22527. // AddConditionOperator adds i to the "condition_operator" field.
  22528. func (m *SopStageMutation) AddConditionOperator(i int) {
  22529. if m.addcondition_operator != nil {
  22530. *m.addcondition_operator += i
  22531. } else {
  22532. m.addcondition_operator = &i
  22533. }
  22534. }
  22535. // AddedConditionOperator returns the value that was added to the "condition_operator" field in this mutation.
  22536. func (m *SopStageMutation) AddedConditionOperator() (r int, exists bool) {
  22537. v := m.addcondition_operator
  22538. if v == nil {
  22539. return
  22540. }
  22541. return *v, true
  22542. }
  22543. // ResetConditionOperator resets all changes to the "condition_operator" field.
  22544. func (m *SopStageMutation) ResetConditionOperator() {
  22545. m.condition_operator = nil
  22546. m.addcondition_operator = nil
  22547. }
  22548. // SetConditionList sets the "condition_list" field.
  22549. func (m *SopStageMutation) SetConditionList(ct []custom_types.Condition) {
  22550. m.condition_list = &ct
  22551. m.appendcondition_list = nil
  22552. }
  22553. // ConditionList returns the value of the "condition_list" field in the mutation.
  22554. func (m *SopStageMutation) ConditionList() (r []custom_types.Condition, exists bool) {
  22555. v := m.condition_list
  22556. if v == nil {
  22557. return
  22558. }
  22559. return *v, true
  22560. }
  22561. // OldConditionList returns the old "condition_list" field's value of the SopStage entity.
  22562. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22563. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22564. func (m *SopStageMutation) OldConditionList(ctx context.Context) (v []custom_types.Condition, err error) {
  22565. if !m.op.Is(OpUpdateOne) {
  22566. return v, errors.New("OldConditionList is only allowed on UpdateOne operations")
  22567. }
  22568. if m.id == nil || m.oldValue == nil {
  22569. return v, errors.New("OldConditionList requires an ID field in the mutation")
  22570. }
  22571. oldValue, err := m.oldValue(ctx)
  22572. if err != nil {
  22573. return v, fmt.Errorf("querying old value for OldConditionList: %w", err)
  22574. }
  22575. return oldValue.ConditionList, nil
  22576. }
  22577. // AppendConditionList adds ct to the "condition_list" field.
  22578. func (m *SopStageMutation) AppendConditionList(ct []custom_types.Condition) {
  22579. m.appendcondition_list = append(m.appendcondition_list, ct...)
  22580. }
  22581. // AppendedConditionList returns the list of values that were appended to the "condition_list" field in this mutation.
  22582. func (m *SopStageMutation) AppendedConditionList() ([]custom_types.Condition, bool) {
  22583. if len(m.appendcondition_list) == 0 {
  22584. return nil, false
  22585. }
  22586. return m.appendcondition_list, true
  22587. }
  22588. // ResetConditionList resets all changes to the "condition_list" field.
  22589. func (m *SopStageMutation) ResetConditionList() {
  22590. m.condition_list = nil
  22591. m.appendcondition_list = nil
  22592. }
  22593. // SetActionMessage sets the "action_message" field.
  22594. func (m *SopStageMutation) SetActionMessage(ct []custom_types.Action) {
  22595. m.action_message = &ct
  22596. m.appendaction_message = nil
  22597. }
  22598. // ActionMessage returns the value of the "action_message" field in the mutation.
  22599. func (m *SopStageMutation) ActionMessage() (r []custom_types.Action, exists bool) {
  22600. v := m.action_message
  22601. if v == nil {
  22602. return
  22603. }
  22604. return *v, true
  22605. }
  22606. // OldActionMessage returns the old "action_message" field's value of the SopStage entity.
  22607. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22608. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22609. func (m *SopStageMutation) OldActionMessage(ctx context.Context) (v []custom_types.Action, err error) {
  22610. if !m.op.Is(OpUpdateOne) {
  22611. return v, errors.New("OldActionMessage is only allowed on UpdateOne operations")
  22612. }
  22613. if m.id == nil || m.oldValue == nil {
  22614. return v, errors.New("OldActionMessage requires an ID field in the mutation")
  22615. }
  22616. oldValue, err := m.oldValue(ctx)
  22617. if err != nil {
  22618. return v, fmt.Errorf("querying old value for OldActionMessage: %w", err)
  22619. }
  22620. return oldValue.ActionMessage, nil
  22621. }
  22622. // AppendActionMessage adds ct to the "action_message" field.
  22623. func (m *SopStageMutation) AppendActionMessage(ct []custom_types.Action) {
  22624. m.appendaction_message = append(m.appendaction_message, ct...)
  22625. }
  22626. // AppendedActionMessage returns the list of values that were appended to the "action_message" field in this mutation.
  22627. func (m *SopStageMutation) AppendedActionMessage() ([]custom_types.Action, bool) {
  22628. if len(m.appendaction_message) == 0 {
  22629. return nil, false
  22630. }
  22631. return m.appendaction_message, true
  22632. }
  22633. // ClearActionMessage clears the value of the "action_message" field.
  22634. func (m *SopStageMutation) ClearActionMessage() {
  22635. m.action_message = nil
  22636. m.appendaction_message = nil
  22637. m.clearedFields[sopstage.FieldActionMessage] = struct{}{}
  22638. }
  22639. // ActionMessageCleared returns if the "action_message" field was cleared in this mutation.
  22640. func (m *SopStageMutation) ActionMessageCleared() bool {
  22641. _, ok := m.clearedFields[sopstage.FieldActionMessage]
  22642. return ok
  22643. }
  22644. // ResetActionMessage resets all changes to the "action_message" field.
  22645. func (m *SopStageMutation) ResetActionMessage() {
  22646. m.action_message = nil
  22647. m.appendaction_message = nil
  22648. delete(m.clearedFields, sopstage.FieldActionMessage)
  22649. }
  22650. // SetActionLabelAdd sets the "action_label_add" field.
  22651. func (m *SopStageMutation) SetActionLabelAdd(u []uint64) {
  22652. m.action_label_add = &u
  22653. m.appendaction_label_add = nil
  22654. }
  22655. // ActionLabelAdd returns the value of the "action_label_add" field in the mutation.
  22656. func (m *SopStageMutation) ActionLabelAdd() (r []uint64, exists bool) {
  22657. v := m.action_label_add
  22658. if v == nil {
  22659. return
  22660. }
  22661. return *v, true
  22662. }
  22663. // OldActionLabelAdd returns the old "action_label_add" field's value of the SopStage entity.
  22664. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22665. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22666. func (m *SopStageMutation) OldActionLabelAdd(ctx context.Context) (v []uint64, err error) {
  22667. if !m.op.Is(OpUpdateOne) {
  22668. return v, errors.New("OldActionLabelAdd is only allowed on UpdateOne operations")
  22669. }
  22670. if m.id == nil || m.oldValue == nil {
  22671. return v, errors.New("OldActionLabelAdd requires an ID field in the mutation")
  22672. }
  22673. oldValue, err := m.oldValue(ctx)
  22674. if err != nil {
  22675. return v, fmt.Errorf("querying old value for OldActionLabelAdd: %w", err)
  22676. }
  22677. return oldValue.ActionLabelAdd, nil
  22678. }
  22679. // AppendActionLabelAdd adds u to the "action_label_add" field.
  22680. func (m *SopStageMutation) AppendActionLabelAdd(u []uint64) {
  22681. m.appendaction_label_add = append(m.appendaction_label_add, u...)
  22682. }
  22683. // AppendedActionLabelAdd returns the list of values that were appended to the "action_label_add" field in this mutation.
  22684. func (m *SopStageMutation) AppendedActionLabelAdd() ([]uint64, bool) {
  22685. if len(m.appendaction_label_add) == 0 {
  22686. return nil, false
  22687. }
  22688. return m.appendaction_label_add, true
  22689. }
  22690. // ClearActionLabelAdd clears the value of the "action_label_add" field.
  22691. func (m *SopStageMutation) ClearActionLabelAdd() {
  22692. m.action_label_add = nil
  22693. m.appendaction_label_add = nil
  22694. m.clearedFields[sopstage.FieldActionLabelAdd] = struct{}{}
  22695. }
  22696. // ActionLabelAddCleared returns if the "action_label_add" field was cleared in this mutation.
  22697. func (m *SopStageMutation) ActionLabelAddCleared() bool {
  22698. _, ok := m.clearedFields[sopstage.FieldActionLabelAdd]
  22699. return ok
  22700. }
  22701. // ResetActionLabelAdd resets all changes to the "action_label_add" field.
  22702. func (m *SopStageMutation) ResetActionLabelAdd() {
  22703. m.action_label_add = nil
  22704. m.appendaction_label_add = nil
  22705. delete(m.clearedFields, sopstage.FieldActionLabelAdd)
  22706. }
  22707. // SetActionLabelDel sets the "action_label_del" field.
  22708. func (m *SopStageMutation) SetActionLabelDel(u []uint64) {
  22709. m.action_label_del = &u
  22710. m.appendaction_label_del = nil
  22711. }
  22712. // ActionLabelDel returns the value of the "action_label_del" field in the mutation.
  22713. func (m *SopStageMutation) ActionLabelDel() (r []uint64, exists bool) {
  22714. v := m.action_label_del
  22715. if v == nil {
  22716. return
  22717. }
  22718. return *v, true
  22719. }
  22720. // OldActionLabelDel returns the old "action_label_del" field's value of the SopStage entity.
  22721. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22722. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22723. func (m *SopStageMutation) OldActionLabelDel(ctx context.Context) (v []uint64, err error) {
  22724. if !m.op.Is(OpUpdateOne) {
  22725. return v, errors.New("OldActionLabelDel is only allowed on UpdateOne operations")
  22726. }
  22727. if m.id == nil || m.oldValue == nil {
  22728. return v, errors.New("OldActionLabelDel requires an ID field in the mutation")
  22729. }
  22730. oldValue, err := m.oldValue(ctx)
  22731. if err != nil {
  22732. return v, fmt.Errorf("querying old value for OldActionLabelDel: %w", err)
  22733. }
  22734. return oldValue.ActionLabelDel, nil
  22735. }
  22736. // AppendActionLabelDel adds u to the "action_label_del" field.
  22737. func (m *SopStageMutation) AppendActionLabelDel(u []uint64) {
  22738. m.appendaction_label_del = append(m.appendaction_label_del, u...)
  22739. }
  22740. // AppendedActionLabelDel returns the list of values that were appended to the "action_label_del" field in this mutation.
  22741. func (m *SopStageMutation) AppendedActionLabelDel() ([]uint64, bool) {
  22742. if len(m.appendaction_label_del) == 0 {
  22743. return nil, false
  22744. }
  22745. return m.appendaction_label_del, true
  22746. }
  22747. // ClearActionLabelDel clears the value of the "action_label_del" field.
  22748. func (m *SopStageMutation) ClearActionLabelDel() {
  22749. m.action_label_del = nil
  22750. m.appendaction_label_del = nil
  22751. m.clearedFields[sopstage.FieldActionLabelDel] = struct{}{}
  22752. }
  22753. // ActionLabelDelCleared returns if the "action_label_del" field was cleared in this mutation.
  22754. func (m *SopStageMutation) ActionLabelDelCleared() bool {
  22755. _, ok := m.clearedFields[sopstage.FieldActionLabelDel]
  22756. return ok
  22757. }
  22758. // ResetActionLabelDel resets all changes to the "action_label_del" field.
  22759. func (m *SopStageMutation) ResetActionLabelDel() {
  22760. m.action_label_del = nil
  22761. m.appendaction_label_del = nil
  22762. delete(m.clearedFields, sopstage.FieldActionLabelDel)
  22763. }
  22764. // SetActionForward sets the "action_forward" field.
  22765. func (m *SopStageMutation) SetActionForward(ctf *custom_types.ActionForward) {
  22766. m.action_forward = &ctf
  22767. }
  22768. // ActionForward returns the value of the "action_forward" field in the mutation.
  22769. func (m *SopStageMutation) ActionForward() (r *custom_types.ActionForward, exists bool) {
  22770. v := m.action_forward
  22771. if v == nil {
  22772. return
  22773. }
  22774. return *v, true
  22775. }
  22776. // OldActionForward returns the old "action_forward" field's value of the SopStage entity.
  22777. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22778. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22779. func (m *SopStageMutation) OldActionForward(ctx context.Context) (v *custom_types.ActionForward, err error) {
  22780. if !m.op.Is(OpUpdateOne) {
  22781. return v, errors.New("OldActionForward is only allowed on UpdateOne operations")
  22782. }
  22783. if m.id == nil || m.oldValue == nil {
  22784. return v, errors.New("OldActionForward requires an ID field in the mutation")
  22785. }
  22786. oldValue, err := m.oldValue(ctx)
  22787. if err != nil {
  22788. return v, fmt.Errorf("querying old value for OldActionForward: %w", err)
  22789. }
  22790. return oldValue.ActionForward, nil
  22791. }
  22792. // ClearActionForward clears the value of the "action_forward" field.
  22793. func (m *SopStageMutation) ClearActionForward() {
  22794. m.action_forward = nil
  22795. m.clearedFields[sopstage.FieldActionForward] = struct{}{}
  22796. }
  22797. // ActionForwardCleared returns if the "action_forward" field was cleared in this mutation.
  22798. func (m *SopStageMutation) ActionForwardCleared() bool {
  22799. _, ok := m.clearedFields[sopstage.FieldActionForward]
  22800. return ok
  22801. }
  22802. // ResetActionForward resets all changes to the "action_forward" field.
  22803. func (m *SopStageMutation) ResetActionForward() {
  22804. m.action_forward = nil
  22805. delete(m.clearedFields, sopstage.FieldActionForward)
  22806. }
  22807. // SetIndexSort sets the "index_sort" field.
  22808. func (m *SopStageMutation) SetIndexSort(i int) {
  22809. m.index_sort = &i
  22810. m.addindex_sort = nil
  22811. }
  22812. // IndexSort returns the value of the "index_sort" field in the mutation.
  22813. func (m *SopStageMutation) IndexSort() (r int, exists bool) {
  22814. v := m.index_sort
  22815. if v == nil {
  22816. return
  22817. }
  22818. return *v, true
  22819. }
  22820. // OldIndexSort returns the old "index_sort" field's value of the SopStage entity.
  22821. // If the SopStage object wasn't provided to the builder, the object is fetched from the database.
  22822. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  22823. func (m *SopStageMutation) OldIndexSort(ctx context.Context) (v int, err error) {
  22824. if !m.op.Is(OpUpdateOne) {
  22825. return v, errors.New("OldIndexSort is only allowed on UpdateOne operations")
  22826. }
  22827. if m.id == nil || m.oldValue == nil {
  22828. return v, errors.New("OldIndexSort requires an ID field in the mutation")
  22829. }
  22830. oldValue, err := m.oldValue(ctx)
  22831. if err != nil {
  22832. return v, fmt.Errorf("querying old value for OldIndexSort: %w", err)
  22833. }
  22834. return oldValue.IndexSort, nil
  22835. }
  22836. // AddIndexSort adds i to the "index_sort" field.
  22837. func (m *SopStageMutation) AddIndexSort(i int) {
  22838. if m.addindex_sort != nil {
  22839. *m.addindex_sort += i
  22840. } else {
  22841. m.addindex_sort = &i
  22842. }
  22843. }
  22844. // AddedIndexSort returns the value that was added to the "index_sort" field in this mutation.
  22845. func (m *SopStageMutation) AddedIndexSort() (r int, exists bool) {
  22846. v := m.addindex_sort
  22847. if v == nil {
  22848. return
  22849. }
  22850. return *v, true
  22851. }
  22852. // ClearIndexSort clears the value of the "index_sort" field.
  22853. func (m *SopStageMutation) ClearIndexSort() {
  22854. m.index_sort = nil
  22855. m.addindex_sort = nil
  22856. m.clearedFields[sopstage.FieldIndexSort] = struct{}{}
  22857. }
  22858. // IndexSortCleared returns if the "index_sort" field was cleared in this mutation.
  22859. func (m *SopStageMutation) IndexSortCleared() bool {
  22860. _, ok := m.clearedFields[sopstage.FieldIndexSort]
  22861. return ok
  22862. }
  22863. // ResetIndexSort resets all changes to the "index_sort" field.
  22864. func (m *SopStageMutation) ResetIndexSort() {
  22865. m.index_sort = nil
  22866. m.addindex_sort = nil
  22867. delete(m.clearedFields, sopstage.FieldIndexSort)
  22868. }
  22869. // SetSopTaskID sets the "sop_task" edge to the SopTask entity by id.
  22870. func (m *SopStageMutation) SetSopTaskID(id uint64) {
  22871. m.sop_task = &id
  22872. }
  22873. // ClearSopTask clears the "sop_task" edge to the SopTask entity.
  22874. func (m *SopStageMutation) ClearSopTask() {
  22875. m.clearedsop_task = true
  22876. m.clearedFields[sopstage.FieldTaskID] = struct{}{}
  22877. }
  22878. // SopTaskCleared reports if the "sop_task" edge to the SopTask entity was cleared.
  22879. func (m *SopStageMutation) SopTaskCleared() bool {
  22880. return m.clearedsop_task
  22881. }
  22882. // SopTaskID returns the "sop_task" edge ID in the mutation.
  22883. func (m *SopStageMutation) SopTaskID() (id uint64, exists bool) {
  22884. if m.sop_task != nil {
  22885. return *m.sop_task, true
  22886. }
  22887. return
  22888. }
  22889. // SopTaskIDs returns the "sop_task" edge IDs in the mutation.
  22890. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  22891. // SopTaskID instead. It exists only for internal usage by the builders.
  22892. func (m *SopStageMutation) SopTaskIDs() (ids []uint64) {
  22893. if id := m.sop_task; id != nil {
  22894. ids = append(ids, *id)
  22895. }
  22896. return
  22897. }
  22898. // ResetSopTask resets all changes to the "sop_task" edge.
  22899. func (m *SopStageMutation) ResetSopTask() {
  22900. m.sop_task = nil
  22901. m.clearedsop_task = false
  22902. }
  22903. // AddStageNodeIDs adds the "stage_nodes" edge to the SopNode entity by ids.
  22904. func (m *SopStageMutation) AddStageNodeIDs(ids ...uint64) {
  22905. if m.stage_nodes == nil {
  22906. m.stage_nodes = make(map[uint64]struct{})
  22907. }
  22908. for i := range ids {
  22909. m.stage_nodes[ids[i]] = struct{}{}
  22910. }
  22911. }
  22912. // ClearStageNodes clears the "stage_nodes" edge to the SopNode entity.
  22913. func (m *SopStageMutation) ClearStageNodes() {
  22914. m.clearedstage_nodes = true
  22915. }
  22916. // StageNodesCleared reports if the "stage_nodes" edge to the SopNode entity was cleared.
  22917. func (m *SopStageMutation) StageNodesCleared() bool {
  22918. return m.clearedstage_nodes
  22919. }
  22920. // RemoveStageNodeIDs removes the "stage_nodes" edge to the SopNode entity by IDs.
  22921. func (m *SopStageMutation) RemoveStageNodeIDs(ids ...uint64) {
  22922. if m.removedstage_nodes == nil {
  22923. m.removedstage_nodes = make(map[uint64]struct{})
  22924. }
  22925. for i := range ids {
  22926. delete(m.stage_nodes, ids[i])
  22927. m.removedstage_nodes[ids[i]] = struct{}{}
  22928. }
  22929. }
  22930. // RemovedStageNodes returns the removed IDs of the "stage_nodes" edge to the SopNode entity.
  22931. func (m *SopStageMutation) RemovedStageNodesIDs() (ids []uint64) {
  22932. for id := range m.removedstage_nodes {
  22933. ids = append(ids, id)
  22934. }
  22935. return
  22936. }
  22937. // StageNodesIDs returns the "stage_nodes" edge IDs in the mutation.
  22938. func (m *SopStageMutation) StageNodesIDs() (ids []uint64) {
  22939. for id := range m.stage_nodes {
  22940. ids = append(ids, id)
  22941. }
  22942. return
  22943. }
  22944. // ResetStageNodes resets all changes to the "stage_nodes" edge.
  22945. func (m *SopStageMutation) ResetStageNodes() {
  22946. m.stage_nodes = nil
  22947. m.clearedstage_nodes = false
  22948. m.removedstage_nodes = nil
  22949. }
  22950. // AddStageMessageIDs adds the "stage_messages" edge to the MessageRecords entity by ids.
  22951. func (m *SopStageMutation) AddStageMessageIDs(ids ...uint64) {
  22952. if m.stage_messages == nil {
  22953. m.stage_messages = make(map[uint64]struct{})
  22954. }
  22955. for i := range ids {
  22956. m.stage_messages[ids[i]] = struct{}{}
  22957. }
  22958. }
  22959. // ClearStageMessages clears the "stage_messages" edge to the MessageRecords entity.
  22960. func (m *SopStageMutation) ClearStageMessages() {
  22961. m.clearedstage_messages = true
  22962. }
  22963. // StageMessagesCleared reports if the "stage_messages" edge to the MessageRecords entity was cleared.
  22964. func (m *SopStageMutation) StageMessagesCleared() bool {
  22965. return m.clearedstage_messages
  22966. }
  22967. // RemoveStageMessageIDs removes the "stage_messages" edge to the MessageRecords entity by IDs.
  22968. func (m *SopStageMutation) RemoveStageMessageIDs(ids ...uint64) {
  22969. if m.removedstage_messages == nil {
  22970. m.removedstage_messages = make(map[uint64]struct{})
  22971. }
  22972. for i := range ids {
  22973. delete(m.stage_messages, ids[i])
  22974. m.removedstage_messages[ids[i]] = struct{}{}
  22975. }
  22976. }
  22977. // RemovedStageMessages returns the removed IDs of the "stage_messages" edge to the MessageRecords entity.
  22978. func (m *SopStageMutation) RemovedStageMessagesIDs() (ids []uint64) {
  22979. for id := range m.removedstage_messages {
  22980. ids = append(ids, id)
  22981. }
  22982. return
  22983. }
  22984. // StageMessagesIDs returns the "stage_messages" edge IDs in the mutation.
  22985. func (m *SopStageMutation) StageMessagesIDs() (ids []uint64) {
  22986. for id := range m.stage_messages {
  22987. ids = append(ids, id)
  22988. }
  22989. return
  22990. }
  22991. // ResetStageMessages resets all changes to the "stage_messages" edge.
  22992. func (m *SopStageMutation) ResetStageMessages() {
  22993. m.stage_messages = nil
  22994. m.clearedstage_messages = false
  22995. m.removedstage_messages = nil
  22996. }
  22997. // Where appends a list predicates to the SopStageMutation builder.
  22998. func (m *SopStageMutation) Where(ps ...predicate.SopStage) {
  22999. m.predicates = append(m.predicates, ps...)
  23000. }
  23001. // WhereP appends storage-level predicates to the SopStageMutation builder. Using this method,
  23002. // users can use type-assertion to append predicates that do not depend on any generated package.
  23003. func (m *SopStageMutation) WhereP(ps ...func(*sql.Selector)) {
  23004. p := make([]predicate.SopStage, len(ps))
  23005. for i := range ps {
  23006. p[i] = ps[i]
  23007. }
  23008. m.Where(p...)
  23009. }
  23010. // Op returns the operation name.
  23011. func (m *SopStageMutation) Op() Op {
  23012. return m.op
  23013. }
  23014. // SetOp allows setting the mutation operation.
  23015. func (m *SopStageMutation) SetOp(op Op) {
  23016. m.op = op
  23017. }
  23018. // Type returns the node type of this mutation (SopStage).
  23019. func (m *SopStageMutation) Type() string {
  23020. return m.typ
  23021. }
  23022. // Fields returns all fields that were changed during this mutation. Note that in
  23023. // order to get all numeric fields that were incremented/decremented, call
  23024. // AddedFields().
  23025. func (m *SopStageMutation) Fields() []string {
  23026. fields := make([]string, 0, 14)
  23027. if m.created_at != nil {
  23028. fields = append(fields, sopstage.FieldCreatedAt)
  23029. }
  23030. if m.updated_at != nil {
  23031. fields = append(fields, sopstage.FieldUpdatedAt)
  23032. }
  23033. if m.status != nil {
  23034. fields = append(fields, sopstage.FieldStatus)
  23035. }
  23036. if m.deleted_at != nil {
  23037. fields = append(fields, sopstage.FieldDeletedAt)
  23038. }
  23039. if m.sop_task != nil {
  23040. fields = append(fields, sopstage.FieldTaskID)
  23041. }
  23042. if m.name != nil {
  23043. fields = append(fields, sopstage.FieldName)
  23044. }
  23045. if m.condition_type != nil {
  23046. fields = append(fields, sopstage.FieldConditionType)
  23047. }
  23048. if m.condition_operator != nil {
  23049. fields = append(fields, sopstage.FieldConditionOperator)
  23050. }
  23051. if m.condition_list != nil {
  23052. fields = append(fields, sopstage.FieldConditionList)
  23053. }
  23054. if m.action_message != nil {
  23055. fields = append(fields, sopstage.FieldActionMessage)
  23056. }
  23057. if m.action_label_add != nil {
  23058. fields = append(fields, sopstage.FieldActionLabelAdd)
  23059. }
  23060. if m.action_label_del != nil {
  23061. fields = append(fields, sopstage.FieldActionLabelDel)
  23062. }
  23063. if m.action_forward != nil {
  23064. fields = append(fields, sopstage.FieldActionForward)
  23065. }
  23066. if m.index_sort != nil {
  23067. fields = append(fields, sopstage.FieldIndexSort)
  23068. }
  23069. return fields
  23070. }
  23071. // Field returns the value of a field with the given name. The second boolean
  23072. // return value indicates that this field was not set, or was not defined in the
  23073. // schema.
  23074. func (m *SopStageMutation) Field(name string) (ent.Value, bool) {
  23075. switch name {
  23076. case sopstage.FieldCreatedAt:
  23077. return m.CreatedAt()
  23078. case sopstage.FieldUpdatedAt:
  23079. return m.UpdatedAt()
  23080. case sopstage.FieldStatus:
  23081. return m.Status()
  23082. case sopstage.FieldDeletedAt:
  23083. return m.DeletedAt()
  23084. case sopstage.FieldTaskID:
  23085. return m.TaskID()
  23086. case sopstage.FieldName:
  23087. return m.Name()
  23088. case sopstage.FieldConditionType:
  23089. return m.ConditionType()
  23090. case sopstage.FieldConditionOperator:
  23091. return m.ConditionOperator()
  23092. case sopstage.FieldConditionList:
  23093. return m.ConditionList()
  23094. case sopstage.FieldActionMessage:
  23095. return m.ActionMessage()
  23096. case sopstage.FieldActionLabelAdd:
  23097. return m.ActionLabelAdd()
  23098. case sopstage.FieldActionLabelDel:
  23099. return m.ActionLabelDel()
  23100. case sopstage.FieldActionForward:
  23101. return m.ActionForward()
  23102. case sopstage.FieldIndexSort:
  23103. return m.IndexSort()
  23104. }
  23105. return nil, false
  23106. }
  23107. // OldField returns the old value of the field from the database. An error is
  23108. // returned if the mutation operation is not UpdateOne, or the query to the
  23109. // database failed.
  23110. func (m *SopStageMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  23111. switch name {
  23112. case sopstage.FieldCreatedAt:
  23113. return m.OldCreatedAt(ctx)
  23114. case sopstage.FieldUpdatedAt:
  23115. return m.OldUpdatedAt(ctx)
  23116. case sopstage.FieldStatus:
  23117. return m.OldStatus(ctx)
  23118. case sopstage.FieldDeletedAt:
  23119. return m.OldDeletedAt(ctx)
  23120. case sopstage.FieldTaskID:
  23121. return m.OldTaskID(ctx)
  23122. case sopstage.FieldName:
  23123. return m.OldName(ctx)
  23124. case sopstage.FieldConditionType:
  23125. return m.OldConditionType(ctx)
  23126. case sopstage.FieldConditionOperator:
  23127. return m.OldConditionOperator(ctx)
  23128. case sopstage.FieldConditionList:
  23129. return m.OldConditionList(ctx)
  23130. case sopstage.FieldActionMessage:
  23131. return m.OldActionMessage(ctx)
  23132. case sopstage.FieldActionLabelAdd:
  23133. return m.OldActionLabelAdd(ctx)
  23134. case sopstage.FieldActionLabelDel:
  23135. return m.OldActionLabelDel(ctx)
  23136. case sopstage.FieldActionForward:
  23137. return m.OldActionForward(ctx)
  23138. case sopstage.FieldIndexSort:
  23139. return m.OldIndexSort(ctx)
  23140. }
  23141. return nil, fmt.Errorf("unknown SopStage field %s", name)
  23142. }
  23143. // SetField sets the value of a field with the given name. It returns an error if
  23144. // the field is not defined in the schema, or if the type mismatched the field
  23145. // type.
  23146. func (m *SopStageMutation) SetField(name string, value ent.Value) error {
  23147. switch name {
  23148. case sopstage.FieldCreatedAt:
  23149. v, ok := value.(time.Time)
  23150. if !ok {
  23151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23152. }
  23153. m.SetCreatedAt(v)
  23154. return nil
  23155. case sopstage.FieldUpdatedAt:
  23156. v, ok := value.(time.Time)
  23157. if !ok {
  23158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23159. }
  23160. m.SetUpdatedAt(v)
  23161. return nil
  23162. case sopstage.FieldStatus:
  23163. v, ok := value.(uint8)
  23164. if !ok {
  23165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23166. }
  23167. m.SetStatus(v)
  23168. return nil
  23169. case sopstage.FieldDeletedAt:
  23170. v, ok := value.(time.Time)
  23171. if !ok {
  23172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23173. }
  23174. m.SetDeletedAt(v)
  23175. return nil
  23176. case sopstage.FieldTaskID:
  23177. v, ok := value.(uint64)
  23178. if !ok {
  23179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23180. }
  23181. m.SetTaskID(v)
  23182. return nil
  23183. case sopstage.FieldName:
  23184. v, ok := value.(string)
  23185. if !ok {
  23186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23187. }
  23188. m.SetName(v)
  23189. return nil
  23190. case sopstage.FieldConditionType:
  23191. v, ok := value.(int)
  23192. if !ok {
  23193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23194. }
  23195. m.SetConditionType(v)
  23196. return nil
  23197. case sopstage.FieldConditionOperator:
  23198. v, ok := value.(int)
  23199. if !ok {
  23200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23201. }
  23202. m.SetConditionOperator(v)
  23203. return nil
  23204. case sopstage.FieldConditionList:
  23205. v, ok := value.([]custom_types.Condition)
  23206. if !ok {
  23207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23208. }
  23209. m.SetConditionList(v)
  23210. return nil
  23211. case sopstage.FieldActionMessage:
  23212. v, ok := value.([]custom_types.Action)
  23213. if !ok {
  23214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23215. }
  23216. m.SetActionMessage(v)
  23217. return nil
  23218. case sopstage.FieldActionLabelAdd:
  23219. v, ok := value.([]uint64)
  23220. if !ok {
  23221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23222. }
  23223. m.SetActionLabelAdd(v)
  23224. return nil
  23225. case sopstage.FieldActionLabelDel:
  23226. v, ok := value.([]uint64)
  23227. if !ok {
  23228. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23229. }
  23230. m.SetActionLabelDel(v)
  23231. return nil
  23232. case sopstage.FieldActionForward:
  23233. v, ok := value.(*custom_types.ActionForward)
  23234. if !ok {
  23235. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23236. }
  23237. m.SetActionForward(v)
  23238. return nil
  23239. case sopstage.FieldIndexSort:
  23240. v, ok := value.(int)
  23241. if !ok {
  23242. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23243. }
  23244. m.SetIndexSort(v)
  23245. return nil
  23246. }
  23247. return fmt.Errorf("unknown SopStage field %s", name)
  23248. }
  23249. // AddedFields returns all numeric fields that were incremented/decremented during
  23250. // this mutation.
  23251. func (m *SopStageMutation) AddedFields() []string {
  23252. var fields []string
  23253. if m.addstatus != nil {
  23254. fields = append(fields, sopstage.FieldStatus)
  23255. }
  23256. if m.addcondition_type != nil {
  23257. fields = append(fields, sopstage.FieldConditionType)
  23258. }
  23259. if m.addcondition_operator != nil {
  23260. fields = append(fields, sopstage.FieldConditionOperator)
  23261. }
  23262. if m.addindex_sort != nil {
  23263. fields = append(fields, sopstage.FieldIndexSort)
  23264. }
  23265. return fields
  23266. }
  23267. // AddedField returns the numeric value that was incremented/decremented on a field
  23268. // with the given name. The second boolean return value indicates that this field
  23269. // was not set, or was not defined in the schema.
  23270. func (m *SopStageMutation) AddedField(name string) (ent.Value, bool) {
  23271. switch name {
  23272. case sopstage.FieldStatus:
  23273. return m.AddedStatus()
  23274. case sopstage.FieldConditionType:
  23275. return m.AddedConditionType()
  23276. case sopstage.FieldConditionOperator:
  23277. return m.AddedConditionOperator()
  23278. case sopstage.FieldIndexSort:
  23279. return m.AddedIndexSort()
  23280. }
  23281. return nil, false
  23282. }
  23283. // AddField adds the value to the field with the given name. It returns an error if
  23284. // the field is not defined in the schema, or if the type mismatched the field
  23285. // type.
  23286. func (m *SopStageMutation) AddField(name string, value ent.Value) error {
  23287. switch name {
  23288. case sopstage.FieldStatus:
  23289. v, ok := value.(int8)
  23290. if !ok {
  23291. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23292. }
  23293. m.AddStatus(v)
  23294. return nil
  23295. case sopstage.FieldConditionType:
  23296. v, ok := value.(int)
  23297. if !ok {
  23298. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23299. }
  23300. m.AddConditionType(v)
  23301. return nil
  23302. case sopstage.FieldConditionOperator:
  23303. v, ok := value.(int)
  23304. if !ok {
  23305. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23306. }
  23307. m.AddConditionOperator(v)
  23308. return nil
  23309. case sopstage.FieldIndexSort:
  23310. v, ok := value.(int)
  23311. if !ok {
  23312. return fmt.Errorf("unexpected type %T for field %s", value, name)
  23313. }
  23314. m.AddIndexSort(v)
  23315. return nil
  23316. }
  23317. return fmt.Errorf("unknown SopStage numeric field %s", name)
  23318. }
  23319. // ClearedFields returns all nullable fields that were cleared during this
  23320. // mutation.
  23321. func (m *SopStageMutation) ClearedFields() []string {
  23322. var fields []string
  23323. if m.FieldCleared(sopstage.FieldStatus) {
  23324. fields = append(fields, sopstage.FieldStatus)
  23325. }
  23326. if m.FieldCleared(sopstage.FieldDeletedAt) {
  23327. fields = append(fields, sopstage.FieldDeletedAt)
  23328. }
  23329. if m.FieldCleared(sopstage.FieldActionMessage) {
  23330. fields = append(fields, sopstage.FieldActionMessage)
  23331. }
  23332. if m.FieldCleared(sopstage.FieldActionLabelAdd) {
  23333. fields = append(fields, sopstage.FieldActionLabelAdd)
  23334. }
  23335. if m.FieldCleared(sopstage.FieldActionLabelDel) {
  23336. fields = append(fields, sopstage.FieldActionLabelDel)
  23337. }
  23338. if m.FieldCleared(sopstage.FieldActionForward) {
  23339. fields = append(fields, sopstage.FieldActionForward)
  23340. }
  23341. if m.FieldCleared(sopstage.FieldIndexSort) {
  23342. fields = append(fields, sopstage.FieldIndexSort)
  23343. }
  23344. return fields
  23345. }
  23346. // FieldCleared returns a boolean indicating if a field with the given name was
  23347. // cleared in this mutation.
  23348. func (m *SopStageMutation) FieldCleared(name string) bool {
  23349. _, ok := m.clearedFields[name]
  23350. return ok
  23351. }
  23352. // ClearField clears the value of the field with the given name. It returns an
  23353. // error if the field is not defined in the schema.
  23354. func (m *SopStageMutation) ClearField(name string) error {
  23355. switch name {
  23356. case sopstage.FieldStatus:
  23357. m.ClearStatus()
  23358. return nil
  23359. case sopstage.FieldDeletedAt:
  23360. m.ClearDeletedAt()
  23361. return nil
  23362. case sopstage.FieldActionMessage:
  23363. m.ClearActionMessage()
  23364. return nil
  23365. case sopstage.FieldActionLabelAdd:
  23366. m.ClearActionLabelAdd()
  23367. return nil
  23368. case sopstage.FieldActionLabelDel:
  23369. m.ClearActionLabelDel()
  23370. return nil
  23371. case sopstage.FieldActionForward:
  23372. m.ClearActionForward()
  23373. return nil
  23374. case sopstage.FieldIndexSort:
  23375. m.ClearIndexSort()
  23376. return nil
  23377. }
  23378. return fmt.Errorf("unknown SopStage nullable field %s", name)
  23379. }
  23380. // ResetField resets all changes in the mutation for the field with the given name.
  23381. // It returns an error if the field is not defined in the schema.
  23382. func (m *SopStageMutation) ResetField(name string) error {
  23383. switch name {
  23384. case sopstage.FieldCreatedAt:
  23385. m.ResetCreatedAt()
  23386. return nil
  23387. case sopstage.FieldUpdatedAt:
  23388. m.ResetUpdatedAt()
  23389. return nil
  23390. case sopstage.FieldStatus:
  23391. m.ResetStatus()
  23392. return nil
  23393. case sopstage.FieldDeletedAt:
  23394. m.ResetDeletedAt()
  23395. return nil
  23396. case sopstage.FieldTaskID:
  23397. m.ResetTaskID()
  23398. return nil
  23399. case sopstage.FieldName:
  23400. m.ResetName()
  23401. return nil
  23402. case sopstage.FieldConditionType:
  23403. m.ResetConditionType()
  23404. return nil
  23405. case sopstage.FieldConditionOperator:
  23406. m.ResetConditionOperator()
  23407. return nil
  23408. case sopstage.FieldConditionList:
  23409. m.ResetConditionList()
  23410. return nil
  23411. case sopstage.FieldActionMessage:
  23412. m.ResetActionMessage()
  23413. return nil
  23414. case sopstage.FieldActionLabelAdd:
  23415. m.ResetActionLabelAdd()
  23416. return nil
  23417. case sopstage.FieldActionLabelDel:
  23418. m.ResetActionLabelDel()
  23419. return nil
  23420. case sopstage.FieldActionForward:
  23421. m.ResetActionForward()
  23422. return nil
  23423. case sopstage.FieldIndexSort:
  23424. m.ResetIndexSort()
  23425. return nil
  23426. }
  23427. return fmt.Errorf("unknown SopStage field %s", name)
  23428. }
  23429. // AddedEdges returns all edge names that were set/added in this mutation.
  23430. func (m *SopStageMutation) AddedEdges() []string {
  23431. edges := make([]string, 0, 3)
  23432. if m.sop_task != nil {
  23433. edges = append(edges, sopstage.EdgeSopTask)
  23434. }
  23435. if m.stage_nodes != nil {
  23436. edges = append(edges, sopstage.EdgeStageNodes)
  23437. }
  23438. if m.stage_messages != nil {
  23439. edges = append(edges, sopstage.EdgeStageMessages)
  23440. }
  23441. return edges
  23442. }
  23443. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  23444. // name in this mutation.
  23445. func (m *SopStageMutation) AddedIDs(name string) []ent.Value {
  23446. switch name {
  23447. case sopstage.EdgeSopTask:
  23448. if id := m.sop_task; id != nil {
  23449. return []ent.Value{*id}
  23450. }
  23451. case sopstage.EdgeStageNodes:
  23452. ids := make([]ent.Value, 0, len(m.stage_nodes))
  23453. for id := range m.stage_nodes {
  23454. ids = append(ids, id)
  23455. }
  23456. return ids
  23457. case sopstage.EdgeStageMessages:
  23458. ids := make([]ent.Value, 0, len(m.stage_messages))
  23459. for id := range m.stage_messages {
  23460. ids = append(ids, id)
  23461. }
  23462. return ids
  23463. }
  23464. return nil
  23465. }
  23466. // RemovedEdges returns all edge names that were removed in this mutation.
  23467. func (m *SopStageMutation) RemovedEdges() []string {
  23468. edges := make([]string, 0, 3)
  23469. if m.removedstage_nodes != nil {
  23470. edges = append(edges, sopstage.EdgeStageNodes)
  23471. }
  23472. if m.removedstage_messages != nil {
  23473. edges = append(edges, sopstage.EdgeStageMessages)
  23474. }
  23475. return edges
  23476. }
  23477. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  23478. // the given name in this mutation.
  23479. func (m *SopStageMutation) RemovedIDs(name string) []ent.Value {
  23480. switch name {
  23481. case sopstage.EdgeStageNodes:
  23482. ids := make([]ent.Value, 0, len(m.removedstage_nodes))
  23483. for id := range m.removedstage_nodes {
  23484. ids = append(ids, id)
  23485. }
  23486. return ids
  23487. case sopstage.EdgeStageMessages:
  23488. ids := make([]ent.Value, 0, len(m.removedstage_messages))
  23489. for id := range m.removedstage_messages {
  23490. ids = append(ids, id)
  23491. }
  23492. return ids
  23493. }
  23494. return nil
  23495. }
  23496. // ClearedEdges returns all edge names that were cleared in this mutation.
  23497. func (m *SopStageMutation) ClearedEdges() []string {
  23498. edges := make([]string, 0, 3)
  23499. if m.clearedsop_task {
  23500. edges = append(edges, sopstage.EdgeSopTask)
  23501. }
  23502. if m.clearedstage_nodes {
  23503. edges = append(edges, sopstage.EdgeStageNodes)
  23504. }
  23505. if m.clearedstage_messages {
  23506. edges = append(edges, sopstage.EdgeStageMessages)
  23507. }
  23508. return edges
  23509. }
  23510. // EdgeCleared returns a boolean which indicates if the edge with the given name
  23511. // was cleared in this mutation.
  23512. func (m *SopStageMutation) EdgeCleared(name string) bool {
  23513. switch name {
  23514. case sopstage.EdgeSopTask:
  23515. return m.clearedsop_task
  23516. case sopstage.EdgeStageNodes:
  23517. return m.clearedstage_nodes
  23518. case sopstage.EdgeStageMessages:
  23519. return m.clearedstage_messages
  23520. }
  23521. return false
  23522. }
  23523. // ClearEdge clears the value of the edge with the given name. It returns an error
  23524. // if that edge is not defined in the schema.
  23525. func (m *SopStageMutation) ClearEdge(name string) error {
  23526. switch name {
  23527. case sopstage.EdgeSopTask:
  23528. m.ClearSopTask()
  23529. return nil
  23530. }
  23531. return fmt.Errorf("unknown SopStage unique edge %s", name)
  23532. }
  23533. // ResetEdge resets all changes to the edge with the given name in this mutation.
  23534. // It returns an error if the edge is not defined in the schema.
  23535. func (m *SopStageMutation) ResetEdge(name string) error {
  23536. switch name {
  23537. case sopstage.EdgeSopTask:
  23538. m.ResetSopTask()
  23539. return nil
  23540. case sopstage.EdgeStageNodes:
  23541. m.ResetStageNodes()
  23542. return nil
  23543. case sopstage.EdgeStageMessages:
  23544. m.ResetStageMessages()
  23545. return nil
  23546. }
  23547. return fmt.Errorf("unknown SopStage edge %s", name)
  23548. }
  23549. // SopTaskMutation represents an operation that mutates the SopTask nodes in the graph.
  23550. type SopTaskMutation struct {
  23551. config
  23552. op Op
  23553. typ string
  23554. id *uint64
  23555. created_at *time.Time
  23556. updated_at *time.Time
  23557. status *uint8
  23558. addstatus *int8
  23559. deleted_at *time.Time
  23560. name *string
  23561. bot_wxid_list *[]string
  23562. appendbot_wxid_list []string
  23563. _type *int
  23564. add_type *int
  23565. plan_start_time *time.Time
  23566. plan_end_time *time.Time
  23567. creator_id *string
  23568. organization_id *uint64
  23569. addorganization_id *int64
  23570. token *[]string
  23571. appendtoken []string
  23572. clearedFields map[string]struct{}
  23573. task_stages map[uint64]struct{}
  23574. removedtask_stages map[uint64]struct{}
  23575. clearedtask_stages bool
  23576. done bool
  23577. oldValue func(context.Context) (*SopTask, error)
  23578. predicates []predicate.SopTask
  23579. }
  23580. var _ ent.Mutation = (*SopTaskMutation)(nil)
  23581. // soptaskOption allows management of the mutation configuration using functional options.
  23582. type soptaskOption func(*SopTaskMutation)
  23583. // newSopTaskMutation creates new mutation for the SopTask entity.
  23584. func newSopTaskMutation(c config, op Op, opts ...soptaskOption) *SopTaskMutation {
  23585. m := &SopTaskMutation{
  23586. config: c,
  23587. op: op,
  23588. typ: TypeSopTask,
  23589. clearedFields: make(map[string]struct{}),
  23590. }
  23591. for _, opt := range opts {
  23592. opt(m)
  23593. }
  23594. return m
  23595. }
  23596. // withSopTaskID sets the ID field of the mutation.
  23597. func withSopTaskID(id uint64) soptaskOption {
  23598. return func(m *SopTaskMutation) {
  23599. var (
  23600. err error
  23601. once sync.Once
  23602. value *SopTask
  23603. )
  23604. m.oldValue = func(ctx context.Context) (*SopTask, error) {
  23605. once.Do(func() {
  23606. if m.done {
  23607. err = errors.New("querying old values post mutation is not allowed")
  23608. } else {
  23609. value, err = m.Client().SopTask.Get(ctx, id)
  23610. }
  23611. })
  23612. return value, err
  23613. }
  23614. m.id = &id
  23615. }
  23616. }
  23617. // withSopTask sets the old SopTask of the mutation.
  23618. func withSopTask(node *SopTask) soptaskOption {
  23619. return func(m *SopTaskMutation) {
  23620. m.oldValue = func(context.Context) (*SopTask, error) {
  23621. return node, nil
  23622. }
  23623. m.id = &node.ID
  23624. }
  23625. }
  23626. // Client returns a new `ent.Client` from the mutation. If the mutation was
  23627. // executed in a transaction (ent.Tx), a transactional client is returned.
  23628. func (m SopTaskMutation) Client() *Client {
  23629. client := &Client{config: m.config}
  23630. client.init()
  23631. return client
  23632. }
  23633. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  23634. // it returns an error otherwise.
  23635. func (m SopTaskMutation) Tx() (*Tx, error) {
  23636. if _, ok := m.driver.(*txDriver); !ok {
  23637. return nil, errors.New("ent: mutation is not running in a transaction")
  23638. }
  23639. tx := &Tx{config: m.config}
  23640. tx.init()
  23641. return tx, nil
  23642. }
  23643. // SetID sets the value of the id field. Note that this
  23644. // operation is only accepted on creation of SopTask entities.
  23645. func (m *SopTaskMutation) SetID(id uint64) {
  23646. m.id = &id
  23647. }
  23648. // ID returns the ID value in the mutation. Note that the ID is only available
  23649. // if it was provided to the builder or after it was returned from the database.
  23650. func (m *SopTaskMutation) ID() (id uint64, exists bool) {
  23651. if m.id == nil {
  23652. return
  23653. }
  23654. return *m.id, true
  23655. }
  23656. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  23657. // That means, if the mutation is applied within a transaction with an isolation level such
  23658. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  23659. // or updated by the mutation.
  23660. func (m *SopTaskMutation) IDs(ctx context.Context) ([]uint64, error) {
  23661. switch {
  23662. case m.op.Is(OpUpdateOne | OpDeleteOne):
  23663. id, exists := m.ID()
  23664. if exists {
  23665. return []uint64{id}, nil
  23666. }
  23667. fallthrough
  23668. case m.op.Is(OpUpdate | OpDelete):
  23669. return m.Client().SopTask.Query().Where(m.predicates...).IDs(ctx)
  23670. default:
  23671. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  23672. }
  23673. }
  23674. // SetCreatedAt sets the "created_at" field.
  23675. func (m *SopTaskMutation) SetCreatedAt(t time.Time) {
  23676. m.created_at = &t
  23677. }
  23678. // CreatedAt returns the value of the "created_at" field in the mutation.
  23679. func (m *SopTaskMutation) CreatedAt() (r time.Time, exists bool) {
  23680. v := m.created_at
  23681. if v == nil {
  23682. return
  23683. }
  23684. return *v, true
  23685. }
  23686. // OldCreatedAt returns the old "created_at" field's value of the SopTask entity.
  23687. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23688. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23689. func (m *SopTaskMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  23690. if !m.op.Is(OpUpdateOne) {
  23691. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  23692. }
  23693. if m.id == nil || m.oldValue == nil {
  23694. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  23695. }
  23696. oldValue, err := m.oldValue(ctx)
  23697. if err != nil {
  23698. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  23699. }
  23700. return oldValue.CreatedAt, nil
  23701. }
  23702. // ResetCreatedAt resets all changes to the "created_at" field.
  23703. func (m *SopTaskMutation) ResetCreatedAt() {
  23704. m.created_at = nil
  23705. }
  23706. // SetUpdatedAt sets the "updated_at" field.
  23707. func (m *SopTaskMutation) SetUpdatedAt(t time.Time) {
  23708. m.updated_at = &t
  23709. }
  23710. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  23711. func (m *SopTaskMutation) UpdatedAt() (r time.Time, exists bool) {
  23712. v := m.updated_at
  23713. if v == nil {
  23714. return
  23715. }
  23716. return *v, true
  23717. }
  23718. // OldUpdatedAt returns the old "updated_at" field's value of the SopTask entity.
  23719. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23720. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23721. func (m *SopTaskMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  23722. if !m.op.Is(OpUpdateOne) {
  23723. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  23724. }
  23725. if m.id == nil || m.oldValue == nil {
  23726. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  23727. }
  23728. oldValue, err := m.oldValue(ctx)
  23729. if err != nil {
  23730. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  23731. }
  23732. return oldValue.UpdatedAt, nil
  23733. }
  23734. // ResetUpdatedAt resets all changes to the "updated_at" field.
  23735. func (m *SopTaskMutation) ResetUpdatedAt() {
  23736. m.updated_at = nil
  23737. }
  23738. // SetStatus sets the "status" field.
  23739. func (m *SopTaskMutation) SetStatus(u uint8) {
  23740. m.status = &u
  23741. m.addstatus = nil
  23742. }
  23743. // Status returns the value of the "status" field in the mutation.
  23744. func (m *SopTaskMutation) Status() (r uint8, exists bool) {
  23745. v := m.status
  23746. if v == nil {
  23747. return
  23748. }
  23749. return *v, true
  23750. }
  23751. // OldStatus returns the old "status" field's value of the SopTask entity.
  23752. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23753. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23754. func (m *SopTaskMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  23755. if !m.op.Is(OpUpdateOne) {
  23756. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  23757. }
  23758. if m.id == nil || m.oldValue == nil {
  23759. return v, errors.New("OldStatus requires an ID field in the mutation")
  23760. }
  23761. oldValue, err := m.oldValue(ctx)
  23762. if err != nil {
  23763. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  23764. }
  23765. return oldValue.Status, nil
  23766. }
  23767. // AddStatus adds u to the "status" field.
  23768. func (m *SopTaskMutation) AddStatus(u int8) {
  23769. if m.addstatus != nil {
  23770. *m.addstatus += u
  23771. } else {
  23772. m.addstatus = &u
  23773. }
  23774. }
  23775. // AddedStatus returns the value that was added to the "status" field in this mutation.
  23776. func (m *SopTaskMutation) AddedStatus() (r int8, exists bool) {
  23777. v := m.addstatus
  23778. if v == nil {
  23779. return
  23780. }
  23781. return *v, true
  23782. }
  23783. // ClearStatus clears the value of the "status" field.
  23784. func (m *SopTaskMutation) ClearStatus() {
  23785. m.status = nil
  23786. m.addstatus = nil
  23787. m.clearedFields[soptask.FieldStatus] = struct{}{}
  23788. }
  23789. // StatusCleared returns if the "status" field was cleared in this mutation.
  23790. func (m *SopTaskMutation) StatusCleared() bool {
  23791. _, ok := m.clearedFields[soptask.FieldStatus]
  23792. return ok
  23793. }
  23794. // ResetStatus resets all changes to the "status" field.
  23795. func (m *SopTaskMutation) ResetStatus() {
  23796. m.status = nil
  23797. m.addstatus = nil
  23798. delete(m.clearedFields, soptask.FieldStatus)
  23799. }
  23800. // SetDeletedAt sets the "deleted_at" field.
  23801. func (m *SopTaskMutation) SetDeletedAt(t time.Time) {
  23802. m.deleted_at = &t
  23803. }
  23804. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  23805. func (m *SopTaskMutation) DeletedAt() (r time.Time, exists bool) {
  23806. v := m.deleted_at
  23807. if v == nil {
  23808. return
  23809. }
  23810. return *v, true
  23811. }
  23812. // OldDeletedAt returns the old "deleted_at" field's value of the SopTask entity.
  23813. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23815. func (m *SopTaskMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  23816. if !m.op.Is(OpUpdateOne) {
  23817. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  23818. }
  23819. if m.id == nil || m.oldValue == nil {
  23820. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  23821. }
  23822. oldValue, err := m.oldValue(ctx)
  23823. if err != nil {
  23824. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  23825. }
  23826. return oldValue.DeletedAt, nil
  23827. }
  23828. // ClearDeletedAt clears the value of the "deleted_at" field.
  23829. func (m *SopTaskMutation) ClearDeletedAt() {
  23830. m.deleted_at = nil
  23831. m.clearedFields[soptask.FieldDeletedAt] = struct{}{}
  23832. }
  23833. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  23834. func (m *SopTaskMutation) DeletedAtCleared() bool {
  23835. _, ok := m.clearedFields[soptask.FieldDeletedAt]
  23836. return ok
  23837. }
  23838. // ResetDeletedAt resets all changes to the "deleted_at" field.
  23839. func (m *SopTaskMutation) ResetDeletedAt() {
  23840. m.deleted_at = nil
  23841. delete(m.clearedFields, soptask.FieldDeletedAt)
  23842. }
  23843. // SetName sets the "name" field.
  23844. func (m *SopTaskMutation) SetName(s string) {
  23845. m.name = &s
  23846. }
  23847. // Name returns the value of the "name" field in the mutation.
  23848. func (m *SopTaskMutation) Name() (r string, exists bool) {
  23849. v := m.name
  23850. if v == nil {
  23851. return
  23852. }
  23853. return *v, true
  23854. }
  23855. // OldName returns the old "name" field's value of the SopTask entity.
  23856. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23857. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23858. func (m *SopTaskMutation) OldName(ctx context.Context) (v string, err error) {
  23859. if !m.op.Is(OpUpdateOne) {
  23860. return v, errors.New("OldName is only allowed on UpdateOne operations")
  23861. }
  23862. if m.id == nil || m.oldValue == nil {
  23863. return v, errors.New("OldName requires an ID field in the mutation")
  23864. }
  23865. oldValue, err := m.oldValue(ctx)
  23866. if err != nil {
  23867. return v, fmt.Errorf("querying old value for OldName: %w", err)
  23868. }
  23869. return oldValue.Name, nil
  23870. }
  23871. // ResetName resets all changes to the "name" field.
  23872. func (m *SopTaskMutation) ResetName() {
  23873. m.name = nil
  23874. }
  23875. // SetBotWxidList sets the "bot_wxid_list" field.
  23876. func (m *SopTaskMutation) SetBotWxidList(s []string) {
  23877. m.bot_wxid_list = &s
  23878. m.appendbot_wxid_list = nil
  23879. }
  23880. // BotWxidList returns the value of the "bot_wxid_list" field in the mutation.
  23881. func (m *SopTaskMutation) BotWxidList() (r []string, exists bool) {
  23882. v := m.bot_wxid_list
  23883. if v == nil {
  23884. return
  23885. }
  23886. return *v, true
  23887. }
  23888. // OldBotWxidList returns the old "bot_wxid_list" 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) OldBotWxidList(ctx context.Context) (v []string, err error) {
  23892. if !m.op.Is(OpUpdateOne) {
  23893. return v, errors.New("OldBotWxidList is only allowed on UpdateOne operations")
  23894. }
  23895. if m.id == nil || m.oldValue == nil {
  23896. return v, errors.New("OldBotWxidList 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 OldBotWxidList: %w", err)
  23901. }
  23902. return oldValue.BotWxidList, nil
  23903. }
  23904. // AppendBotWxidList adds s to the "bot_wxid_list" field.
  23905. func (m *SopTaskMutation) AppendBotWxidList(s []string) {
  23906. m.appendbot_wxid_list = append(m.appendbot_wxid_list, s...)
  23907. }
  23908. // AppendedBotWxidList returns the list of values that were appended to the "bot_wxid_list" field in this mutation.
  23909. func (m *SopTaskMutation) AppendedBotWxidList() ([]string, bool) {
  23910. if len(m.appendbot_wxid_list) == 0 {
  23911. return nil, false
  23912. }
  23913. return m.appendbot_wxid_list, true
  23914. }
  23915. // ClearBotWxidList clears the value of the "bot_wxid_list" field.
  23916. func (m *SopTaskMutation) ClearBotWxidList() {
  23917. m.bot_wxid_list = nil
  23918. m.appendbot_wxid_list = nil
  23919. m.clearedFields[soptask.FieldBotWxidList] = struct{}{}
  23920. }
  23921. // BotWxidListCleared returns if the "bot_wxid_list" field was cleared in this mutation.
  23922. func (m *SopTaskMutation) BotWxidListCleared() bool {
  23923. _, ok := m.clearedFields[soptask.FieldBotWxidList]
  23924. return ok
  23925. }
  23926. // ResetBotWxidList resets all changes to the "bot_wxid_list" field.
  23927. func (m *SopTaskMutation) ResetBotWxidList() {
  23928. m.bot_wxid_list = nil
  23929. m.appendbot_wxid_list = nil
  23930. delete(m.clearedFields, soptask.FieldBotWxidList)
  23931. }
  23932. // SetType sets the "type" field.
  23933. func (m *SopTaskMutation) SetType(i int) {
  23934. m._type = &i
  23935. m.add_type = nil
  23936. }
  23937. // GetType returns the value of the "type" field in the mutation.
  23938. func (m *SopTaskMutation) GetType() (r int, exists bool) {
  23939. v := m._type
  23940. if v == nil {
  23941. return
  23942. }
  23943. return *v, true
  23944. }
  23945. // OldType returns the old "type" field's value of the SopTask entity.
  23946. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23947. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23948. func (m *SopTaskMutation) OldType(ctx context.Context) (v int, err error) {
  23949. if !m.op.Is(OpUpdateOne) {
  23950. return v, errors.New("OldType is only allowed on UpdateOne operations")
  23951. }
  23952. if m.id == nil || m.oldValue == nil {
  23953. return v, errors.New("OldType requires an ID field in the mutation")
  23954. }
  23955. oldValue, err := m.oldValue(ctx)
  23956. if err != nil {
  23957. return v, fmt.Errorf("querying old value for OldType: %w", err)
  23958. }
  23959. return oldValue.Type, nil
  23960. }
  23961. // AddType adds i to the "type" field.
  23962. func (m *SopTaskMutation) AddType(i int) {
  23963. if m.add_type != nil {
  23964. *m.add_type += i
  23965. } else {
  23966. m.add_type = &i
  23967. }
  23968. }
  23969. // AddedType returns the value that was added to the "type" field in this mutation.
  23970. func (m *SopTaskMutation) AddedType() (r int, exists bool) {
  23971. v := m.add_type
  23972. if v == nil {
  23973. return
  23974. }
  23975. return *v, true
  23976. }
  23977. // ResetType resets all changes to the "type" field.
  23978. func (m *SopTaskMutation) ResetType() {
  23979. m._type = nil
  23980. m.add_type = nil
  23981. }
  23982. // SetPlanStartTime sets the "plan_start_time" field.
  23983. func (m *SopTaskMutation) SetPlanStartTime(t time.Time) {
  23984. m.plan_start_time = &t
  23985. }
  23986. // PlanStartTime returns the value of the "plan_start_time" field in the mutation.
  23987. func (m *SopTaskMutation) PlanStartTime() (r time.Time, exists bool) {
  23988. v := m.plan_start_time
  23989. if v == nil {
  23990. return
  23991. }
  23992. return *v, true
  23993. }
  23994. // OldPlanStartTime returns the old "plan_start_time" field's value of the SopTask entity.
  23995. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  23996. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  23997. func (m *SopTaskMutation) OldPlanStartTime(ctx context.Context) (v time.Time, err error) {
  23998. if !m.op.Is(OpUpdateOne) {
  23999. return v, errors.New("OldPlanStartTime is only allowed on UpdateOne operations")
  24000. }
  24001. if m.id == nil || m.oldValue == nil {
  24002. return v, errors.New("OldPlanStartTime requires an ID field in the mutation")
  24003. }
  24004. oldValue, err := m.oldValue(ctx)
  24005. if err != nil {
  24006. return v, fmt.Errorf("querying old value for OldPlanStartTime: %w", err)
  24007. }
  24008. return oldValue.PlanStartTime, nil
  24009. }
  24010. // ClearPlanStartTime clears the value of the "plan_start_time" field.
  24011. func (m *SopTaskMutation) ClearPlanStartTime() {
  24012. m.plan_start_time = nil
  24013. m.clearedFields[soptask.FieldPlanStartTime] = struct{}{}
  24014. }
  24015. // PlanStartTimeCleared returns if the "plan_start_time" field was cleared in this mutation.
  24016. func (m *SopTaskMutation) PlanStartTimeCleared() bool {
  24017. _, ok := m.clearedFields[soptask.FieldPlanStartTime]
  24018. return ok
  24019. }
  24020. // ResetPlanStartTime resets all changes to the "plan_start_time" field.
  24021. func (m *SopTaskMutation) ResetPlanStartTime() {
  24022. m.plan_start_time = nil
  24023. delete(m.clearedFields, soptask.FieldPlanStartTime)
  24024. }
  24025. // SetPlanEndTime sets the "plan_end_time" field.
  24026. func (m *SopTaskMutation) SetPlanEndTime(t time.Time) {
  24027. m.plan_end_time = &t
  24028. }
  24029. // PlanEndTime returns the value of the "plan_end_time" field in the mutation.
  24030. func (m *SopTaskMutation) PlanEndTime() (r time.Time, exists bool) {
  24031. v := m.plan_end_time
  24032. if v == nil {
  24033. return
  24034. }
  24035. return *v, true
  24036. }
  24037. // OldPlanEndTime returns the old "plan_end_time" field's value of the SopTask entity.
  24038. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24040. func (m *SopTaskMutation) OldPlanEndTime(ctx context.Context) (v time.Time, err error) {
  24041. if !m.op.Is(OpUpdateOne) {
  24042. return v, errors.New("OldPlanEndTime is only allowed on UpdateOne operations")
  24043. }
  24044. if m.id == nil || m.oldValue == nil {
  24045. return v, errors.New("OldPlanEndTime requires an ID field in the mutation")
  24046. }
  24047. oldValue, err := m.oldValue(ctx)
  24048. if err != nil {
  24049. return v, fmt.Errorf("querying old value for OldPlanEndTime: %w", err)
  24050. }
  24051. return oldValue.PlanEndTime, nil
  24052. }
  24053. // ClearPlanEndTime clears the value of the "plan_end_time" field.
  24054. func (m *SopTaskMutation) ClearPlanEndTime() {
  24055. m.plan_end_time = nil
  24056. m.clearedFields[soptask.FieldPlanEndTime] = struct{}{}
  24057. }
  24058. // PlanEndTimeCleared returns if the "plan_end_time" field was cleared in this mutation.
  24059. func (m *SopTaskMutation) PlanEndTimeCleared() bool {
  24060. _, ok := m.clearedFields[soptask.FieldPlanEndTime]
  24061. return ok
  24062. }
  24063. // ResetPlanEndTime resets all changes to the "plan_end_time" field.
  24064. func (m *SopTaskMutation) ResetPlanEndTime() {
  24065. m.plan_end_time = nil
  24066. delete(m.clearedFields, soptask.FieldPlanEndTime)
  24067. }
  24068. // SetCreatorID sets the "creator_id" field.
  24069. func (m *SopTaskMutation) SetCreatorID(s string) {
  24070. m.creator_id = &s
  24071. }
  24072. // CreatorID returns the value of the "creator_id" field in the mutation.
  24073. func (m *SopTaskMutation) CreatorID() (r string, exists bool) {
  24074. v := m.creator_id
  24075. if v == nil {
  24076. return
  24077. }
  24078. return *v, true
  24079. }
  24080. // OldCreatorID returns the old "creator_id" field's value of the SopTask entity.
  24081. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24082. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24083. func (m *SopTaskMutation) OldCreatorID(ctx context.Context) (v string, err error) {
  24084. if !m.op.Is(OpUpdateOne) {
  24085. return v, errors.New("OldCreatorID is only allowed on UpdateOne operations")
  24086. }
  24087. if m.id == nil || m.oldValue == nil {
  24088. return v, errors.New("OldCreatorID requires an ID field in the mutation")
  24089. }
  24090. oldValue, err := m.oldValue(ctx)
  24091. if err != nil {
  24092. return v, fmt.Errorf("querying old value for OldCreatorID: %w", err)
  24093. }
  24094. return oldValue.CreatorID, nil
  24095. }
  24096. // ClearCreatorID clears the value of the "creator_id" field.
  24097. func (m *SopTaskMutation) ClearCreatorID() {
  24098. m.creator_id = nil
  24099. m.clearedFields[soptask.FieldCreatorID] = struct{}{}
  24100. }
  24101. // CreatorIDCleared returns if the "creator_id" field was cleared in this mutation.
  24102. func (m *SopTaskMutation) CreatorIDCleared() bool {
  24103. _, ok := m.clearedFields[soptask.FieldCreatorID]
  24104. return ok
  24105. }
  24106. // ResetCreatorID resets all changes to the "creator_id" field.
  24107. func (m *SopTaskMutation) ResetCreatorID() {
  24108. m.creator_id = nil
  24109. delete(m.clearedFields, soptask.FieldCreatorID)
  24110. }
  24111. // SetOrganizationID sets the "organization_id" field.
  24112. func (m *SopTaskMutation) SetOrganizationID(u uint64) {
  24113. m.organization_id = &u
  24114. m.addorganization_id = nil
  24115. }
  24116. // OrganizationID returns the value of the "organization_id" field in the mutation.
  24117. func (m *SopTaskMutation) OrganizationID() (r uint64, exists bool) {
  24118. v := m.organization_id
  24119. if v == nil {
  24120. return
  24121. }
  24122. return *v, true
  24123. }
  24124. // OldOrganizationID returns the old "organization_id" field's value of the SopTask entity.
  24125. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24126. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24127. func (m *SopTaskMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  24128. if !m.op.Is(OpUpdateOne) {
  24129. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  24130. }
  24131. if m.id == nil || m.oldValue == nil {
  24132. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  24133. }
  24134. oldValue, err := m.oldValue(ctx)
  24135. if err != nil {
  24136. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  24137. }
  24138. return oldValue.OrganizationID, nil
  24139. }
  24140. // AddOrganizationID adds u to the "organization_id" field.
  24141. func (m *SopTaskMutation) AddOrganizationID(u int64) {
  24142. if m.addorganization_id != nil {
  24143. *m.addorganization_id += u
  24144. } else {
  24145. m.addorganization_id = &u
  24146. }
  24147. }
  24148. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  24149. func (m *SopTaskMutation) AddedOrganizationID() (r int64, exists bool) {
  24150. v := m.addorganization_id
  24151. if v == nil {
  24152. return
  24153. }
  24154. return *v, true
  24155. }
  24156. // ClearOrganizationID clears the value of the "organization_id" field.
  24157. func (m *SopTaskMutation) ClearOrganizationID() {
  24158. m.organization_id = nil
  24159. m.addorganization_id = nil
  24160. m.clearedFields[soptask.FieldOrganizationID] = struct{}{}
  24161. }
  24162. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  24163. func (m *SopTaskMutation) OrganizationIDCleared() bool {
  24164. _, ok := m.clearedFields[soptask.FieldOrganizationID]
  24165. return ok
  24166. }
  24167. // ResetOrganizationID resets all changes to the "organization_id" field.
  24168. func (m *SopTaskMutation) ResetOrganizationID() {
  24169. m.organization_id = nil
  24170. m.addorganization_id = nil
  24171. delete(m.clearedFields, soptask.FieldOrganizationID)
  24172. }
  24173. // SetToken sets the "token" field.
  24174. func (m *SopTaskMutation) SetToken(s []string) {
  24175. m.token = &s
  24176. m.appendtoken = nil
  24177. }
  24178. // Token returns the value of the "token" field in the mutation.
  24179. func (m *SopTaskMutation) Token() (r []string, exists bool) {
  24180. v := m.token
  24181. if v == nil {
  24182. return
  24183. }
  24184. return *v, true
  24185. }
  24186. // OldToken returns the old "token" field's value of the SopTask entity.
  24187. // If the SopTask object wasn't provided to the builder, the object is fetched from the database.
  24188. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24189. func (m *SopTaskMutation) OldToken(ctx context.Context) (v []string, err error) {
  24190. if !m.op.Is(OpUpdateOne) {
  24191. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  24192. }
  24193. if m.id == nil || m.oldValue == nil {
  24194. return v, errors.New("OldToken requires an ID field in the mutation")
  24195. }
  24196. oldValue, err := m.oldValue(ctx)
  24197. if err != nil {
  24198. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  24199. }
  24200. return oldValue.Token, nil
  24201. }
  24202. // AppendToken adds s to the "token" field.
  24203. func (m *SopTaskMutation) AppendToken(s []string) {
  24204. m.appendtoken = append(m.appendtoken, s...)
  24205. }
  24206. // AppendedToken returns the list of values that were appended to the "token" field in this mutation.
  24207. func (m *SopTaskMutation) AppendedToken() ([]string, bool) {
  24208. if len(m.appendtoken) == 0 {
  24209. return nil, false
  24210. }
  24211. return m.appendtoken, true
  24212. }
  24213. // ClearToken clears the value of the "token" field.
  24214. func (m *SopTaskMutation) ClearToken() {
  24215. m.token = nil
  24216. m.appendtoken = nil
  24217. m.clearedFields[soptask.FieldToken] = struct{}{}
  24218. }
  24219. // TokenCleared returns if the "token" field was cleared in this mutation.
  24220. func (m *SopTaskMutation) TokenCleared() bool {
  24221. _, ok := m.clearedFields[soptask.FieldToken]
  24222. return ok
  24223. }
  24224. // ResetToken resets all changes to the "token" field.
  24225. func (m *SopTaskMutation) ResetToken() {
  24226. m.token = nil
  24227. m.appendtoken = nil
  24228. delete(m.clearedFields, soptask.FieldToken)
  24229. }
  24230. // AddTaskStageIDs adds the "task_stages" edge to the SopStage entity by ids.
  24231. func (m *SopTaskMutation) AddTaskStageIDs(ids ...uint64) {
  24232. if m.task_stages == nil {
  24233. m.task_stages = make(map[uint64]struct{})
  24234. }
  24235. for i := range ids {
  24236. m.task_stages[ids[i]] = struct{}{}
  24237. }
  24238. }
  24239. // ClearTaskStages clears the "task_stages" edge to the SopStage entity.
  24240. func (m *SopTaskMutation) ClearTaskStages() {
  24241. m.clearedtask_stages = true
  24242. }
  24243. // TaskStagesCleared reports if the "task_stages" edge to the SopStage entity was cleared.
  24244. func (m *SopTaskMutation) TaskStagesCleared() bool {
  24245. return m.clearedtask_stages
  24246. }
  24247. // RemoveTaskStageIDs removes the "task_stages" edge to the SopStage entity by IDs.
  24248. func (m *SopTaskMutation) RemoveTaskStageIDs(ids ...uint64) {
  24249. if m.removedtask_stages == nil {
  24250. m.removedtask_stages = make(map[uint64]struct{})
  24251. }
  24252. for i := range ids {
  24253. delete(m.task_stages, ids[i])
  24254. m.removedtask_stages[ids[i]] = struct{}{}
  24255. }
  24256. }
  24257. // RemovedTaskStages returns the removed IDs of the "task_stages" edge to the SopStage entity.
  24258. func (m *SopTaskMutation) RemovedTaskStagesIDs() (ids []uint64) {
  24259. for id := range m.removedtask_stages {
  24260. ids = append(ids, id)
  24261. }
  24262. return
  24263. }
  24264. // TaskStagesIDs returns the "task_stages" edge IDs in the mutation.
  24265. func (m *SopTaskMutation) TaskStagesIDs() (ids []uint64) {
  24266. for id := range m.task_stages {
  24267. ids = append(ids, id)
  24268. }
  24269. return
  24270. }
  24271. // ResetTaskStages resets all changes to the "task_stages" edge.
  24272. func (m *SopTaskMutation) ResetTaskStages() {
  24273. m.task_stages = nil
  24274. m.clearedtask_stages = false
  24275. m.removedtask_stages = nil
  24276. }
  24277. // Where appends a list predicates to the SopTaskMutation builder.
  24278. func (m *SopTaskMutation) Where(ps ...predicate.SopTask) {
  24279. m.predicates = append(m.predicates, ps...)
  24280. }
  24281. // WhereP appends storage-level predicates to the SopTaskMutation builder. Using this method,
  24282. // users can use type-assertion to append predicates that do not depend on any generated package.
  24283. func (m *SopTaskMutation) WhereP(ps ...func(*sql.Selector)) {
  24284. p := make([]predicate.SopTask, len(ps))
  24285. for i := range ps {
  24286. p[i] = ps[i]
  24287. }
  24288. m.Where(p...)
  24289. }
  24290. // Op returns the operation name.
  24291. func (m *SopTaskMutation) Op() Op {
  24292. return m.op
  24293. }
  24294. // SetOp allows setting the mutation operation.
  24295. func (m *SopTaskMutation) SetOp(op Op) {
  24296. m.op = op
  24297. }
  24298. // Type returns the node type of this mutation (SopTask).
  24299. func (m *SopTaskMutation) Type() string {
  24300. return m.typ
  24301. }
  24302. // Fields returns all fields that were changed during this mutation. Note that in
  24303. // order to get all numeric fields that were incremented/decremented, call
  24304. // AddedFields().
  24305. func (m *SopTaskMutation) Fields() []string {
  24306. fields := make([]string, 0, 12)
  24307. if m.created_at != nil {
  24308. fields = append(fields, soptask.FieldCreatedAt)
  24309. }
  24310. if m.updated_at != nil {
  24311. fields = append(fields, soptask.FieldUpdatedAt)
  24312. }
  24313. if m.status != nil {
  24314. fields = append(fields, soptask.FieldStatus)
  24315. }
  24316. if m.deleted_at != nil {
  24317. fields = append(fields, soptask.FieldDeletedAt)
  24318. }
  24319. if m.name != nil {
  24320. fields = append(fields, soptask.FieldName)
  24321. }
  24322. if m.bot_wxid_list != nil {
  24323. fields = append(fields, soptask.FieldBotWxidList)
  24324. }
  24325. if m._type != nil {
  24326. fields = append(fields, soptask.FieldType)
  24327. }
  24328. if m.plan_start_time != nil {
  24329. fields = append(fields, soptask.FieldPlanStartTime)
  24330. }
  24331. if m.plan_end_time != nil {
  24332. fields = append(fields, soptask.FieldPlanEndTime)
  24333. }
  24334. if m.creator_id != nil {
  24335. fields = append(fields, soptask.FieldCreatorID)
  24336. }
  24337. if m.organization_id != nil {
  24338. fields = append(fields, soptask.FieldOrganizationID)
  24339. }
  24340. if m.token != nil {
  24341. fields = append(fields, soptask.FieldToken)
  24342. }
  24343. return fields
  24344. }
  24345. // Field returns the value of a field with the given name. The second boolean
  24346. // return value indicates that this field was not set, or was not defined in the
  24347. // schema.
  24348. func (m *SopTaskMutation) Field(name string) (ent.Value, bool) {
  24349. switch name {
  24350. case soptask.FieldCreatedAt:
  24351. return m.CreatedAt()
  24352. case soptask.FieldUpdatedAt:
  24353. return m.UpdatedAt()
  24354. case soptask.FieldStatus:
  24355. return m.Status()
  24356. case soptask.FieldDeletedAt:
  24357. return m.DeletedAt()
  24358. case soptask.FieldName:
  24359. return m.Name()
  24360. case soptask.FieldBotWxidList:
  24361. return m.BotWxidList()
  24362. case soptask.FieldType:
  24363. return m.GetType()
  24364. case soptask.FieldPlanStartTime:
  24365. return m.PlanStartTime()
  24366. case soptask.FieldPlanEndTime:
  24367. return m.PlanEndTime()
  24368. case soptask.FieldCreatorID:
  24369. return m.CreatorID()
  24370. case soptask.FieldOrganizationID:
  24371. return m.OrganizationID()
  24372. case soptask.FieldToken:
  24373. return m.Token()
  24374. }
  24375. return nil, false
  24376. }
  24377. // OldField returns the old value of the field from the database. An error is
  24378. // returned if the mutation operation is not UpdateOne, or the query to the
  24379. // database failed.
  24380. func (m *SopTaskMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  24381. switch name {
  24382. case soptask.FieldCreatedAt:
  24383. return m.OldCreatedAt(ctx)
  24384. case soptask.FieldUpdatedAt:
  24385. return m.OldUpdatedAt(ctx)
  24386. case soptask.FieldStatus:
  24387. return m.OldStatus(ctx)
  24388. case soptask.FieldDeletedAt:
  24389. return m.OldDeletedAt(ctx)
  24390. case soptask.FieldName:
  24391. return m.OldName(ctx)
  24392. case soptask.FieldBotWxidList:
  24393. return m.OldBotWxidList(ctx)
  24394. case soptask.FieldType:
  24395. return m.OldType(ctx)
  24396. case soptask.FieldPlanStartTime:
  24397. return m.OldPlanStartTime(ctx)
  24398. case soptask.FieldPlanEndTime:
  24399. return m.OldPlanEndTime(ctx)
  24400. case soptask.FieldCreatorID:
  24401. return m.OldCreatorID(ctx)
  24402. case soptask.FieldOrganizationID:
  24403. return m.OldOrganizationID(ctx)
  24404. case soptask.FieldToken:
  24405. return m.OldToken(ctx)
  24406. }
  24407. return nil, fmt.Errorf("unknown SopTask field %s", name)
  24408. }
  24409. // SetField sets the value of a field with the given name. It returns an error if
  24410. // the field is not defined in the schema, or if the type mismatched the field
  24411. // type.
  24412. func (m *SopTaskMutation) SetField(name string, value ent.Value) error {
  24413. switch name {
  24414. case soptask.FieldCreatedAt:
  24415. v, ok := value.(time.Time)
  24416. if !ok {
  24417. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24418. }
  24419. m.SetCreatedAt(v)
  24420. return nil
  24421. case soptask.FieldUpdatedAt:
  24422. v, ok := value.(time.Time)
  24423. if !ok {
  24424. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24425. }
  24426. m.SetUpdatedAt(v)
  24427. return nil
  24428. case soptask.FieldStatus:
  24429. v, ok := value.(uint8)
  24430. if !ok {
  24431. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24432. }
  24433. m.SetStatus(v)
  24434. return nil
  24435. case soptask.FieldDeletedAt:
  24436. v, ok := value.(time.Time)
  24437. if !ok {
  24438. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24439. }
  24440. m.SetDeletedAt(v)
  24441. return nil
  24442. case soptask.FieldName:
  24443. v, ok := value.(string)
  24444. if !ok {
  24445. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24446. }
  24447. m.SetName(v)
  24448. return nil
  24449. case soptask.FieldBotWxidList:
  24450. v, ok := value.([]string)
  24451. if !ok {
  24452. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24453. }
  24454. m.SetBotWxidList(v)
  24455. return nil
  24456. case soptask.FieldType:
  24457. v, ok := value.(int)
  24458. if !ok {
  24459. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24460. }
  24461. m.SetType(v)
  24462. return nil
  24463. case soptask.FieldPlanStartTime:
  24464. v, ok := value.(time.Time)
  24465. if !ok {
  24466. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24467. }
  24468. m.SetPlanStartTime(v)
  24469. return nil
  24470. case soptask.FieldPlanEndTime:
  24471. v, ok := value.(time.Time)
  24472. if !ok {
  24473. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24474. }
  24475. m.SetPlanEndTime(v)
  24476. return nil
  24477. case soptask.FieldCreatorID:
  24478. v, ok := value.(string)
  24479. if !ok {
  24480. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24481. }
  24482. m.SetCreatorID(v)
  24483. return nil
  24484. case soptask.FieldOrganizationID:
  24485. v, ok := value.(uint64)
  24486. if !ok {
  24487. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24488. }
  24489. m.SetOrganizationID(v)
  24490. return nil
  24491. case soptask.FieldToken:
  24492. v, ok := value.([]string)
  24493. if !ok {
  24494. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24495. }
  24496. m.SetToken(v)
  24497. return nil
  24498. }
  24499. return fmt.Errorf("unknown SopTask field %s", name)
  24500. }
  24501. // AddedFields returns all numeric fields that were incremented/decremented during
  24502. // this mutation.
  24503. func (m *SopTaskMutation) AddedFields() []string {
  24504. var fields []string
  24505. if m.addstatus != nil {
  24506. fields = append(fields, soptask.FieldStatus)
  24507. }
  24508. if m.add_type != nil {
  24509. fields = append(fields, soptask.FieldType)
  24510. }
  24511. if m.addorganization_id != nil {
  24512. fields = append(fields, soptask.FieldOrganizationID)
  24513. }
  24514. return fields
  24515. }
  24516. // AddedField returns the numeric value that was incremented/decremented on a field
  24517. // with the given name. The second boolean return value indicates that this field
  24518. // was not set, or was not defined in the schema.
  24519. func (m *SopTaskMutation) AddedField(name string) (ent.Value, bool) {
  24520. switch name {
  24521. case soptask.FieldStatus:
  24522. return m.AddedStatus()
  24523. case soptask.FieldType:
  24524. return m.AddedType()
  24525. case soptask.FieldOrganizationID:
  24526. return m.AddedOrganizationID()
  24527. }
  24528. return nil, false
  24529. }
  24530. // AddField adds the value to the field with the given name. It returns an error if
  24531. // the field is not defined in the schema, or if the type mismatched the field
  24532. // type.
  24533. func (m *SopTaskMutation) AddField(name string, value ent.Value) error {
  24534. switch name {
  24535. case soptask.FieldStatus:
  24536. v, ok := value.(int8)
  24537. if !ok {
  24538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24539. }
  24540. m.AddStatus(v)
  24541. return nil
  24542. case soptask.FieldType:
  24543. v, ok := value.(int)
  24544. if !ok {
  24545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24546. }
  24547. m.AddType(v)
  24548. return nil
  24549. case soptask.FieldOrganizationID:
  24550. v, ok := value.(int64)
  24551. if !ok {
  24552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  24553. }
  24554. m.AddOrganizationID(v)
  24555. return nil
  24556. }
  24557. return fmt.Errorf("unknown SopTask numeric field %s", name)
  24558. }
  24559. // ClearedFields returns all nullable fields that were cleared during this
  24560. // mutation.
  24561. func (m *SopTaskMutation) ClearedFields() []string {
  24562. var fields []string
  24563. if m.FieldCleared(soptask.FieldStatus) {
  24564. fields = append(fields, soptask.FieldStatus)
  24565. }
  24566. if m.FieldCleared(soptask.FieldDeletedAt) {
  24567. fields = append(fields, soptask.FieldDeletedAt)
  24568. }
  24569. if m.FieldCleared(soptask.FieldBotWxidList) {
  24570. fields = append(fields, soptask.FieldBotWxidList)
  24571. }
  24572. if m.FieldCleared(soptask.FieldPlanStartTime) {
  24573. fields = append(fields, soptask.FieldPlanStartTime)
  24574. }
  24575. if m.FieldCleared(soptask.FieldPlanEndTime) {
  24576. fields = append(fields, soptask.FieldPlanEndTime)
  24577. }
  24578. if m.FieldCleared(soptask.FieldCreatorID) {
  24579. fields = append(fields, soptask.FieldCreatorID)
  24580. }
  24581. if m.FieldCleared(soptask.FieldOrganizationID) {
  24582. fields = append(fields, soptask.FieldOrganizationID)
  24583. }
  24584. if m.FieldCleared(soptask.FieldToken) {
  24585. fields = append(fields, soptask.FieldToken)
  24586. }
  24587. return fields
  24588. }
  24589. // FieldCleared returns a boolean indicating if a field with the given name was
  24590. // cleared in this mutation.
  24591. func (m *SopTaskMutation) FieldCleared(name string) bool {
  24592. _, ok := m.clearedFields[name]
  24593. return ok
  24594. }
  24595. // ClearField clears the value of the field with the given name. It returns an
  24596. // error if the field is not defined in the schema.
  24597. func (m *SopTaskMutation) ClearField(name string) error {
  24598. switch name {
  24599. case soptask.FieldStatus:
  24600. m.ClearStatus()
  24601. return nil
  24602. case soptask.FieldDeletedAt:
  24603. m.ClearDeletedAt()
  24604. return nil
  24605. case soptask.FieldBotWxidList:
  24606. m.ClearBotWxidList()
  24607. return nil
  24608. case soptask.FieldPlanStartTime:
  24609. m.ClearPlanStartTime()
  24610. return nil
  24611. case soptask.FieldPlanEndTime:
  24612. m.ClearPlanEndTime()
  24613. return nil
  24614. case soptask.FieldCreatorID:
  24615. m.ClearCreatorID()
  24616. return nil
  24617. case soptask.FieldOrganizationID:
  24618. m.ClearOrganizationID()
  24619. return nil
  24620. case soptask.FieldToken:
  24621. m.ClearToken()
  24622. return nil
  24623. }
  24624. return fmt.Errorf("unknown SopTask nullable field %s", name)
  24625. }
  24626. // ResetField resets all changes in the mutation for the field with the given name.
  24627. // It returns an error if the field is not defined in the schema.
  24628. func (m *SopTaskMutation) ResetField(name string) error {
  24629. switch name {
  24630. case soptask.FieldCreatedAt:
  24631. m.ResetCreatedAt()
  24632. return nil
  24633. case soptask.FieldUpdatedAt:
  24634. m.ResetUpdatedAt()
  24635. return nil
  24636. case soptask.FieldStatus:
  24637. m.ResetStatus()
  24638. return nil
  24639. case soptask.FieldDeletedAt:
  24640. m.ResetDeletedAt()
  24641. return nil
  24642. case soptask.FieldName:
  24643. m.ResetName()
  24644. return nil
  24645. case soptask.FieldBotWxidList:
  24646. m.ResetBotWxidList()
  24647. return nil
  24648. case soptask.FieldType:
  24649. m.ResetType()
  24650. return nil
  24651. case soptask.FieldPlanStartTime:
  24652. m.ResetPlanStartTime()
  24653. return nil
  24654. case soptask.FieldPlanEndTime:
  24655. m.ResetPlanEndTime()
  24656. return nil
  24657. case soptask.FieldCreatorID:
  24658. m.ResetCreatorID()
  24659. return nil
  24660. case soptask.FieldOrganizationID:
  24661. m.ResetOrganizationID()
  24662. return nil
  24663. case soptask.FieldToken:
  24664. m.ResetToken()
  24665. return nil
  24666. }
  24667. return fmt.Errorf("unknown SopTask field %s", name)
  24668. }
  24669. // AddedEdges returns all edge names that were set/added in this mutation.
  24670. func (m *SopTaskMutation) AddedEdges() []string {
  24671. edges := make([]string, 0, 1)
  24672. if m.task_stages != nil {
  24673. edges = append(edges, soptask.EdgeTaskStages)
  24674. }
  24675. return edges
  24676. }
  24677. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  24678. // name in this mutation.
  24679. func (m *SopTaskMutation) AddedIDs(name string) []ent.Value {
  24680. switch name {
  24681. case soptask.EdgeTaskStages:
  24682. ids := make([]ent.Value, 0, len(m.task_stages))
  24683. for id := range m.task_stages {
  24684. ids = append(ids, id)
  24685. }
  24686. return ids
  24687. }
  24688. return nil
  24689. }
  24690. // RemovedEdges returns all edge names that were removed in this mutation.
  24691. func (m *SopTaskMutation) RemovedEdges() []string {
  24692. edges := make([]string, 0, 1)
  24693. if m.removedtask_stages != nil {
  24694. edges = append(edges, soptask.EdgeTaskStages)
  24695. }
  24696. return edges
  24697. }
  24698. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  24699. // the given name in this mutation.
  24700. func (m *SopTaskMutation) RemovedIDs(name string) []ent.Value {
  24701. switch name {
  24702. case soptask.EdgeTaskStages:
  24703. ids := make([]ent.Value, 0, len(m.removedtask_stages))
  24704. for id := range m.removedtask_stages {
  24705. ids = append(ids, id)
  24706. }
  24707. return ids
  24708. }
  24709. return nil
  24710. }
  24711. // ClearedEdges returns all edge names that were cleared in this mutation.
  24712. func (m *SopTaskMutation) ClearedEdges() []string {
  24713. edges := make([]string, 0, 1)
  24714. if m.clearedtask_stages {
  24715. edges = append(edges, soptask.EdgeTaskStages)
  24716. }
  24717. return edges
  24718. }
  24719. // EdgeCleared returns a boolean which indicates if the edge with the given name
  24720. // was cleared in this mutation.
  24721. func (m *SopTaskMutation) EdgeCleared(name string) bool {
  24722. switch name {
  24723. case soptask.EdgeTaskStages:
  24724. return m.clearedtask_stages
  24725. }
  24726. return false
  24727. }
  24728. // ClearEdge clears the value of the edge with the given name. It returns an error
  24729. // if that edge is not defined in the schema.
  24730. func (m *SopTaskMutation) ClearEdge(name string) error {
  24731. switch name {
  24732. }
  24733. return fmt.Errorf("unknown SopTask unique edge %s", name)
  24734. }
  24735. // ResetEdge resets all changes to the edge with the given name in this mutation.
  24736. // It returns an error if the edge is not defined in the schema.
  24737. func (m *SopTaskMutation) ResetEdge(name string) error {
  24738. switch name {
  24739. case soptask.EdgeTaskStages:
  24740. m.ResetTaskStages()
  24741. return nil
  24742. }
  24743. return fmt.Errorf("unknown SopTask edge %s", name)
  24744. }
  24745. // TokenMutation represents an operation that mutates the Token nodes in the graph.
  24746. type TokenMutation struct {
  24747. config
  24748. op Op
  24749. typ string
  24750. id *uint64
  24751. created_at *time.Time
  24752. updated_at *time.Time
  24753. deleted_at *time.Time
  24754. expire_at *time.Time
  24755. token *string
  24756. mac *string
  24757. organization_id *uint64
  24758. addorganization_id *int64
  24759. custom_agent_base *string
  24760. custom_agent_key *string
  24761. openai_base *string
  24762. openai_key *string
  24763. clearedFields map[string]struct{}
  24764. agent *uint64
  24765. clearedagent bool
  24766. done bool
  24767. oldValue func(context.Context) (*Token, error)
  24768. predicates []predicate.Token
  24769. }
  24770. var _ ent.Mutation = (*TokenMutation)(nil)
  24771. // tokenOption allows management of the mutation configuration using functional options.
  24772. type tokenOption func(*TokenMutation)
  24773. // newTokenMutation creates new mutation for the Token entity.
  24774. func newTokenMutation(c config, op Op, opts ...tokenOption) *TokenMutation {
  24775. m := &TokenMutation{
  24776. config: c,
  24777. op: op,
  24778. typ: TypeToken,
  24779. clearedFields: make(map[string]struct{}),
  24780. }
  24781. for _, opt := range opts {
  24782. opt(m)
  24783. }
  24784. return m
  24785. }
  24786. // withTokenID sets the ID field of the mutation.
  24787. func withTokenID(id uint64) tokenOption {
  24788. return func(m *TokenMutation) {
  24789. var (
  24790. err error
  24791. once sync.Once
  24792. value *Token
  24793. )
  24794. m.oldValue = func(ctx context.Context) (*Token, error) {
  24795. once.Do(func() {
  24796. if m.done {
  24797. err = errors.New("querying old values post mutation is not allowed")
  24798. } else {
  24799. value, err = m.Client().Token.Get(ctx, id)
  24800. }
  24801. })
  24802. return value, err
  24803. }
  24804. m.id = &id
  24805. }
  24806. }
  24807. // withToken sets the old Token of the mutation.
  24808. func withToken(node *Token) tokenOption {
  24809. return func(m *TokenMutation) {
  24810. m.oldValue = func(context.Context) (*Token, error) {
  24811. return node, nil
  24812. }
  24813. m.id = &node.ID
  24814. }
  24815. }
  24816. // Client returns a new `ent.Client` from the mutation. If the mutation was
  24817. // executed in a transaction (ent.Tx), a transactional client is returned.
  24818. func (m TokenMutation) Client() *Client {
  24819. client := &Client{config: m.config}
  24820. client.init()
  24821. return client
  24822. }
  24823. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  24824. // it returns an error otherwise.
  24825. func (m TokenMutation) Tx() (*Tx, error) {
  24826. if _, ok := m.driver.(*txDriver); !ok {
  24827. return nil, errors.New("ent: mutation is not running in a transaction")
  24828. }
  24829. tx := &Tx{config: m.config}
  24830. tx.init()
  24831. return tx, nil
  24832. }
  24833. // SetID sets the value of the id field. Note that this
  24834. // operation is only accepted on creation of Token entities.
  24835. func (m *TokenMutation) SetID(id uint64) {
  24836. m.id = &id
  24837. }
  24838. // ID returns the ID value in the mutation. Note that the ID is only available
  24839. // if it was provided to the builder or after it was returned from the database.
  24840. func (m *TokenMutation) ID() (id uint64, exists bool) {
  24841. if m.id == nil {
  24842. return
  24843. }
  24844. return *m.id, true
  24845. }
  24846. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  24847. // That means, if the mutation is applied within a transaction with an isolation level such
  24848. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  24849. // or updated by the mutation.
  24850. func (m *TokenMutation) IDs(ctx context.Context) ([]uint64, error) {
  24851. switch {
  24852. case m.op.Is(OpUpdateOne | OpDeleteOne):
  24853. id, exists := m.ID()
  24854. if exists {
  24855. return []uint64{id}, nil
  24856. }
  24857. fallthrough
  24858. case m.op.Is(OpUpdate | OpDelete):
  24859. return m.Client().Token.Query().Where(m.predicates...).IDs(ctx)
  24860. default:
  24861. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  24862. }
  24863. }
  24864. // SetCreatedAt sets the "created_at" field.
  24865. func (m *TokenMutation) SetCreatedAt(t time.Time) {
  24866. m.created_at = &t
  24867. }
  24868. // CreatedAt returns the value of the "created_at" field in the mutation.
  24869. func (m *TokenMutation) CreatedAt() (r time.Time, exists bool) {
  24870. v := m.created_at
  24871. if v == nil {
  24872. return
  24873. }
  24874. return *v, true
  24875. }
  24876. // OldCreatedAt returns the old "created_at" field's value of the Token entity.
  24877. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24878. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24879. func (m *TokenMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  24880. if !m.op.Is(OpUpdateOne) {
  24881. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  24882. }
  24883. if m.id == nil || m.oldValue == nil {
  24884. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  24885. }
  24886. oldValue, err := m.oldValue(ctx)
  24887. if err != nil {
  24888. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  24889. }
  24890. return oldValue.CreatedAt, nil
  24891. }
  24892. // ResetCreatedAt resets all changes to the "created_at" field.
  24893. func (m *TokenMutation) ResetCreatedAt() {
  24894. m.created_at = nil
  24895. }
  24896. // SetUpdatedAt sets the "updated_at" field.
  24897. func (m *TokenMutation) SetUpdatedAt(t time.Time) {
  24898. m.updated_at = &t
  24899. }
  24900. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  24901. func (m *TokenMutation) UpdatedAt() (r time.Time, exists bool) {
  24902. v := m.updated_at
  24903. if v == nil {
  24904. return
  24905. }
  24906. return *v, true
  24907. }
  24908. // OldUpdatedAt returns the old "updated_at" field's value of the Token entity.
  24909. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24910. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24911. func (m *TokenMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  24912. if !m.op.Is(OpUpdateOne) {
  24913. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  24914. }
  24915. if m.id == nil || m.oldValue == nil {
  24916. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  24917. }
  24918. oldValue, err := m.oldValue(ctx)
  24919. if err != nil {
  24920. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  24921. }
  24922. return oldValue.UpdatedAt, nil
  24923. }
  24924. // ResetUpdatedAt resets all changes to the "updated_at" field.
  24925. func (m *TokenMutation) ResetUpdatedAt() {
  24926. m.updated_at = nil
  24927. }
  24928. // SetDeletedAt sets the "deleted_at" field.
  24929. func (m *TokenMutation) SetDeletedAt(t time.Time) {
  24930. m.deleted_at = &t
  24931. }
  24932. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  24933. func (m *TokenMutation) DeletedAt() (r time.Time, exists bool) {
  24934. v := m.deleted_at
  24935. if v == nil {
  24936. return
  24937. }
  24938. return *v, true
  24939. }
  24940. // OldDeletedAt returns the old "deleted_at" field's value of the Token entity.
  24941. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24942. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24943. func (m *TokenMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  24944. if !m.op.Is(OpUpdateOne) {
  24945. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  24946. }
  24947. if m.id == nil || m.oldValue == nil {
  24948. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  24949. }
  24950. oldValue, err := m.oldValue(ctx)
  24951. if err != nil {
  24952. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  24953. }
  24954. return oldValue.DeletedAt, nil
  24955. }
  24956. // ClearDeletedAt clears the value of the "deleted_at" field.
  24957. func (m *TokenMutation) ClearDeletedAt() {
  24958. m.deleted_at = nil
  24959. m.clearedFields[token.FieldDeletedAt] = struct{}{}
  24960. }
  24961. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  24962. func (m *TokenMutation) DeletedAtCleared() bool {
  24963. _, ok := m.clearedFields[token.FieldDeletedAt]
  24964. return ok
  24965. }
  24966. // ResetDeletedAt resets all changes to the "deleted_at" field.
  24967. func (m *TokenMutation) ResetDeletedAt() {
  24968. m.deleted_at = nil
  24969. delete(m.clearedFields, token.FieldDeletedAt)
  24970. }
  24971. // SetExpireAt sets the "expire_at" field.
  24972. func (m *TokenMutation) SetExpireAt(t time.Time) {
  24973. m.expire_at = &t
  24974. }
  24975. // ExpireAt returns the value of the "expire_at" field in the mutation.
  24976. func (m *TokenMutation) ExpireAt() (r time.Time, exists bool) {
  24977. v := m.expire_at
  24978. if v == nil {
  24979. return
  24980. }
  24981. return *v, true
  24982. }
  24983. // OldExpireAt returns the old "expire_at" field's value of the Token entity.
  24984. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  24985. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  24986. func (m *TokenMutation) OldExpireAt(ctx context.Context) (v time.Time, err error) {
  24987. if !m.op.Is(OpUpdateOne) {
  24988. return v, errors.New("OldExpireAt is only allowed on UpdateOne operations")
  24989. }
  24990. if m.id == nil || m.oldValue == nil {
  24991. return v, errors.New("OldExpireAt requires an ID field in the mutation")
  24992. }
  24993. oldValue, err := m.oldValue(ctx)
  24994. if err != nil {
  24995. return v, fmt.Errorf("querying old value for OldExpireAt: %w", err)
  24996. }
  24997. return oldValue.ExpireAt, nil
  24998. }
  24999. // ClearExpireAt clears the value of the "expire_at" field.
  25000. func (m *TokenMutation) ClearExpireAt() {
  25001. m.expire_at = nil
  25002. m.clearedFields[token.FieldExpireAt] = struct{}{}
  25003. }
  25004. // ExpireAtCleared returns if the "expire_at" field was cleared in this mutation.
  25005. func (m *TokenMutation) ExpireAtCleared() bool {
  25006. _, ok := m.clearedFields[token.FieldExpireAt]
  25007. return ok
  25008. }
  25009. // ResetExpireAt resets all changes to the "expire_at" field.
  25010. func (m *TokenMutation) ResetExpireAt() {
  25011. m.expire_at = nil
  25012. delete(m.clearedFields, token.FieldExpireAt)
  25013. }
  25014. // SetToken sets the "token" field.
  25015. func (m *TokenMutation) SetToken(s string) {
  25016. m.token = &s
  25017. }
  25018. // Token returns the value of the "token" field in the mutation.
  25019. func (m *TokenMutation) Token() (r string, exists bool) {
  25020. v := m.token
  25021. if v == nil {
  25022. return
  25023. }
  25024. return *v, true
  25025. }
  25026. // OldToken returns the old "token" field's value of the Token entity.
  25027. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25028. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25029. func (m *TokenMutation) OldToken(ctx context.Context) (v string, err error) {
  25030. if !m.op.Is(OpUpdateOne) {
  25031. return v, errors.New("OldToken is only allowed on UpdateOne operations")
  25032. }
  25033. if m.id == nil || m.oldValue == nil {
  25034. return v, errors.New("OldToken requires an ID field in the mutation")
  25035. }
  25036. oldValue, err := m.oldValue(ctx)
  25037. if err != nil {
  25038. return v, fmt.Errorf("querying old value for OldToken: %w", err)
  25039. }
  25040. return oldValue.Token, nil
  25041. }
  25042. // ClearToken clears the value of the "token" field.
  25043. func (m *TokenMutation) ClearToken() {
  25044. m.token = nil
  25045. m.clearedFields[token.FieldToken] = struct{}{}
  25046. }
  25047. // TokenCleared returns if the "token" field was cleared in this mutation.
  25048. func (m *TokenMutation) TokenCleared() bool {
  25049. _, ok := m.clearedFields[token.FieldToken]
  25050. return ok
  25051. }
  25052. // ResetToken resets all changes to the "token" field.
  25053. func (m *TokenMutation) ResetToken() {
  25054. m.token = nil
  25055. delete(m.clearedFields, token.FieldToken)
  25056. }
  25057. // SetMAC sets the "mac" field.
  25058. func (m *TokenMutation) SetMAC(s string) {
  25059. m.mac = &s
  25060. }
  25061. // MAC returns the value of the "mac" field in the mutation.
  25062. func (m *TokenMutation) MAC() (r string, exists bool) {
  25063. v := m.mac
  25064. if v == nil {
  25065. return
  25066. }
  25067. return *v, true
  25068. }
  25069. // OldMAC returns the old "mac" field's value of the Token entity.
  25070. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25072. func (m *TokenMutation) OldMAC(ctx context.Context) (v string, err error) {
  25073. if !m.op.Is(OpUpdateOne) {
  25074. return v, errors.New("OldMAC is only allowed on UpdateOne operations")
  25075. }
  25076. if m.id == nil || m.oldValue == nil {
  25077. return v, errors.New("OldMAC requires an ID field in the mutation")
  25078. }
  25079. oldValue, err := m.oldValue(ctx)
  25080. if err != nil {
  25081. return v, fmt.Errorf("querying old value for OldMAC: %w", err)
  25082. }
  25083. return oldValue.MAC, nil
  25084. }
  25085. // ClearMAC clears the value of the "mac" field.
  25086. func (m *TokenMutation) ClearMAC() {
  25087. m.mac = nil
  25088. m.clearedFields[token.FieldMAC] = struct{}{}
  25089. }
  25090. // MACCleared returns if the "mac" field was cleared in this mutation.
  25091. func (m *TokenMutation) MACCleared() bool {
  25092. _, ok := m.clearedFields[token.FieldMAC]
  25093. return ok
  25094. }
  25095. // ResetMAC resets all changes to the "mac" field.
  25096. func (m *TokenMutation) ResetMAC() {
  25097. m.mac = nil
  25098. delete(m.clearedFields, token.FieldMAC)
  25099. }
  25100. // SetOrganizationID sets the "organization_id" field.
  25101. func (m *TokenMutation) SetOrganizationID(u uint64) {
  25102. m.organization_id = &u
  25103. m.addorganization_id = nil
  25104. }
  25105. // OrganizationID returns the value of the "organization_id" field in the mutation.
  25106. func (m *TokenMutation) OrganizationID() (r uint64, exists bool) {
  25107. v := m.organization_id
  25108. if v == nil {
  25109. return
  25110. }
  25111. return *v, true
  25112. }
  25113. // OldOrganizationID returns the old "organization_id" field's value of the Token entity.
  25114. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25115. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25116. func (m *TokenMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  25117. if !m.op.Is(OpUpdateOne) {
  25118. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  25119. }
  25120. if m.id == nil || m.oldValue == nil {
  25121. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  25122. }
  25123. oldValue, err := m.oldValue(ctx)
  25124. if err != nil {
  25125. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  25126. }
  25127. return oldValue.OrganizationID, nil
  25128. }
  25129. // AddOrganizationID adds u to the "organization_id" field.
  25130. func (m *TokenMutation) AddOrganizationID(u int64) {
  25131. if m.addorganization_id != nil {
  25132. *m.addorganization_id += u
  25133. } else {
  25134. m.addorganization_id = &u
  25135. }
  25136. }
  25137. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  25138. func (m *TokenMutation) AddedOrganizationID() (r int64, exists bool) {
  25139. v := m.addorganization_id
  25140. if v == nil {
  25141. return
  25142. }
  25143. return *v, true
  25144. }
  25145. // ResetOrganizationID resets all changes to the "organization_id" field.
  25146. func (m *TokenMutation) ResetOrganizationID() {
  25147. m.organization_id = nil
  25148. m.addorganization_id = nil
  25149. }
  25150. // SetAgentID sets the "agent_id" field.
  25151. func (m *TokenMutation) SetAgentID(u uint64) {
  25152. m.agent = &u
  25153. }
  25154. // AgentID returns the value of the "agent_id" field in the mutation.
  25155. func (m *TokenMutation) AgentID() (r uint64, exists bool) {
  25156. v := m.agent
  25157. if v == nil {
  25158. return
  25159. }
  25160. return *v, true
  25161. }
  25162. // OldAgentID returns the old "agent_id" field's value of the Token entity.
  25163. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25164. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25165. func (m *TokenMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  25166. if !m.op.Is(OpUpdateOne) {
  25167. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  25168. }
  25169. if m.id == nil || m.oldValue == nil {
  25170. return v, errors.New("OldAgentID requires an ID field in the mutation")
  25171. }
  25172. oldValue, err := m.oldValue(ctx)
  25173. if err != nil {
  25174. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  25175. }
  25176. return oldValue.AgentID, nil
  25177. }
  25178. // ResetAgentID resets all changes to the "agent_id" field.
  25179. func (m *TokenMutation) ResetAgentID() {
  25180. m.agent = nil
  25181. }
  25182. // SetCustomAgentBase sets the "custom_agent_base" field.
  25183. func (m *TokenMutation) SetCustomAgentBase(s string) {
  25184. m.custom_agent_base = &s
  25185. }
  25186. // CustomAgentBase returns the value of the "custom_agent_base" field in the mutation.
  25187. func (m *TokenMutation) CustomAgentBase() (r string, exists bool) {
  25188. v := m.custom_agent_base
  25189. if v == nil {
  25190. return
  25191. }
  25192. return *v, true
  25193. }
  25194. // OldCustomAgentBase returns the old "custom_agent_base" field's value of the Token entity.
  25195. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25196. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25197. func (m *TokenMutation) OldCustomAgentBase(ctx context.Context) (v string, err error) {
  25198. if !m.op.Is(OpUpdateOne) {
  25199. return v, errors.New("OldCustomAgentBase is only allowed on UpdateOne operations")
  25200. }
  25201. if m.id == nil || m.oldValue == nil {
  25202. return v, errors.New("OldCustomAgentBase requires an ID field in the mutation")
  25203. }
  25204. oldValue, err := m.oldValue(ctx)
  25205. if err != nil {
  25206. return v, fmt.Errorf("querying old value for OldCustomAgentBase: %w", err)
  25207. }
  25208. return oldValue.CustomAgentBase, nil
  25209. }
  25210. // ClearCustomAgentBase clears the value of the "custom_agent_base" field.
  25211. func (m *TokenMutation) ClearCustomAgentBase() {
  25212. m.custom_agent_base = nil
  25213. m.clearedFields[token.FieldCustomAgentBase] = struct{}{}
  25214. }
  25215. // CustomAgentBaseCleared returns if the "custom_agent_base" field was cleared in this mutation.
  25216. func (m *TokenMutation) CustomAgentBaseCleared() bool {
  25217. _, ok := m.clearedFields[token.FieldCustomAgentBase]
  25218. return ok
  25219. }
  25220. // ResetCustomAgentBase resets all changes to the "custom_agent_base" field.
  25221. func (m *TokenMutation) ResetCustomAgentBase() {
  25222. m.custom_agent_base = nil
  25223. delete(m.clearedFields, token.FieldCustomAgentBase)
  25224. }
  25225. // SetCustomAgentKey sets the "custom_agent_key" field.
  25226. func (m *TokenMutation) SetCustomAgentKey(s string) {
  25227. m.custom_agent_key = &s
  25228. }
  25229. // CustomAgentKey returns the value of the "custom_agent_key" field in the mutation.
  25230. func (m *TokenMutation) CustomAgentKey() (r string, exists bool) {
  25231. v := m.custom_agent_key
  25232. if v == nil {
  25233. return
  25234. }
  25235. return *v, true
  25236. }
  25237. // OldCustomAgentKey returns the old "custom_agent_key" field's value of the Token entity.
  25238. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25240. func (m *TokenMutation) OldCustomAgentKey(ctx context.Context) (v string, err error) {
  25241. if !m.op.Is(OpUpdateOne) {
  25242. return v, errors.New("OldCustomAgentKey is only allowed on UpdateOne operations")
  25243. }
  25244. if m.id == nil || m.oldValue == nil {
  25245. return v, errors.New("OldCustomAgentKey requires an ID field in the mutation")
  25246. }
  25247. oldValue, err := m.oldValue(ctx)
  25248. if err != nil {
  25249. return v, fmt.Errorf("querying old value for OldCustomAgentKey: %w", err)
  25250. }
  25251. return oldValue.CustomAgentKey, nil
  25252. }
  25253. // ClearCustomAgentKey clears the value of the "custom_agent_key" field.
  25254. func (m *TokenMutation) ClearCustomAgentKey() {
  25255. m.custom_agent_key = nil
  25256. m.clearedFields[token.FieldCustomAgentKey] = struct{}{}
  25257. }
  25258. // CustomAgentKeyCleared returns if the "custom_agent_key" field was cleared in this mutation.
  25259. func (m *TokenMutation) CustomAgentKeyCleared() bool {
  25260. _, ok := m.clearedFields[token.FieldCustomAgentKey]
  25261. return ok
  25262. }
  25263. // ResetCustomAgentKey resets all changes to the "custom_agent_key" field.
  25264. func (m *TokenMutation) ResetCustomAgentKey() {
  25265. m.custom_agent_key = nil
  25266. delete(m.clearedFields, token.FieldCustomAgentKey)
  25267. }
  25268. // SetOpenaiBase sets the "openai_base" field.
  25269. func (m *TokenMutation) SetOpenaiBase(s string) {
  25270. m.openai_base = &s
  25271. }
  25272. // OpenaiBase returns the value of the "openai_base" field in the mutation.
  25273. func (m *TokenMutation) OpenaiBase() (r string, exists bool) {
  25274. v := m.openai_base
  25275. if v == nil {
  25276. return
  25277. }
  25278. return *v, true
  25279. }
  25280. // OldOpenaiBase returns the old "openai_base" field's value of the Token entity.
  25281. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25282. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25283. func (m *TokenMutation) OldOpenaiBase(ctx context.Context) (v string, err error) {
  25284. if !m.op.Is(OpUpdateOne) {
  25285. return v, errors.New("OldOpenaiBase is only allowed on UpdateOne operations")
  25286. }
  25287. if m.id == nil || m.oldValue == nil {
  25288. return v, errors.New("OldOpenaiBase requires an ID field in the mutation")
  25289. }
  25290. oldValue, err := m.oldValue(ctx)
  25291. if err != nil {
  25292. return v, fmt.Errorf("querying old value for OldOpenaiBase: %w", err)
  25293. }
  25294. return oldValue.OpenaiBase, nil
  25295. }
  25296. // ClearOpenaiBase clears the value of the "openai_base" field.
  25297. func (m *TokenMutation) ClearOpenaiBase() {
  25298. m.openai_base = nil
  25299. m.clearedFields[token.FieldOpenaiBase] = struct{}{}
  25300. }
  25301. // OpenaiBaseCleared returns if the "openai_base" field was cleared in this mutation.
  25302. func (m *TokenMutation) OpenaiBaseCleared() bool {
  25303. _, ok := m.clearedFields[token.FieldOpenaiBase]
  25304. return ok
  25305. }
  25306. // ResetOpenaiBase resets all changes to the "openai_base" field.
  25307. func (m *TokenMutation) ResetOpenaiBase() {
  25308. m.openai_base = nil
  25309. delete(m.clearedFields, token.FieldOpenaiBase)
  25310. }
  25311. // SetOpenaiKey sets the "openai_key" field.
  25312. func (m *TokenMutation) SetOpenaiKey(s string) {
  25313. m.openai_key = &s
  25314. }
  25315. // OpenaiKey returns the value of the "openai_key" field in the mutation.
  25316. func (m *TokenMutation) OpenaiKey() (r string, exists bool) {
  25317. v := m.openai_key
  25318. if v == nil {
  25319. return
  25320. }
  25321. return *v, true
  25322. }
  25323. // OldOpenaiKey returns the old "openai_key" field's value of the Token entity.
  25324. // If the Token object wasn't provided to the builder, the object is fetched from the database.
  25325. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25326. func (m *TokenMutation) OldOpenaiKey(ctx context.Context) (v string, err error) {
  25327. if !m.op.Is(OpUpdateOne) {
  25328. return v, errors.New("OldOpenaiKey is only allowed on UpdateOne operations")
  25329. }
  25330. if m.id == nil || m.oldValue == nil {
  25331. return v, errors.New("OldOpenaiKey requires an ID field in the mutation")
  25332. }
  25333. oldValue, err := m.oldValue(ctx)
  25334. if err != nil {
  25335. return v, fmt.Errorf("querying old value for OldOpenaiKey: %w", err)
  25336. }
  25337. return oldValue.OpenaiKey, nil
  25338. }
  25339. // ClearOpenaiKey clears the value of the "openai_key" field.
  25340. func (m *TokenMutation) ClearOpenaiKey() {
  25341. m.openai_key = nil
  25342. m.clearedFields[token.FieldOpenaiKey] = struct{}{}
  25343. }
  25344. // OpenaiKeyCleared returns if the "openai_key" field was cleared in this mutation.
  25345. func (m *TokenMutation) OpenaiKeyCleared() bool {
  25346. _, ok := m.clearedFields[token.FieldOpenaiKey]
  25347. return ok
  25348. }
  25349. // ResetOpenaiKey resets all changes to the "openai_key" field.
  25350. func (m *TokenMutation) ResetOpenaiKey() {
  25351. m.openai_key = nil
  25352. delete(m.clearedFields, token.FieldOpenaiKey)
  25353. }
  25354. // ClearAgent clears the "agent" edge to the Agent entity.
  25355. func (m *TokenMutation) ClearAgent() {
  25356. m.clearedagent = true
  25357. m.clearedFields[token.FieldAgentID] = struct{}{}
  25358. }
  25359. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  25360. func (m *TokenMutation) AgentCleared() bool {
  25361. return m.clearedagent
  25362. }
  25363. // AgentIDs returns the "agent" edge IDs in the mutation.
  25364. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  25365. // AgentID instead. It exists only for internal usage by the builders.
  25366. func (m *TokenMutation) AgentIDs() (ids []uint64) {
  25367. if id := m.agent; id != nil {
  25368. ids = append(ids, *id)
  25369. }
  25370. return
  25371. }
  25372. // ResetAgent resets all changes to the "agent" edge.
  25373. func (m *TokenMutation) ResetAgent() {
  25374. m.agent = nil
  25375. m.clearedagent = false
  25376. }
  25377. // Where appends a list predicates to the TokenMutation builder.
  25378. func (m *TokenMutation) Where(ps ...predicate.Token) {
  25379. m.predicates = append(m.predicates, ps...)
  25380. }
  25381. // WhereP appends storage-level predicates to the TokenMutation builder. Using this method,
  25382. // users can use type-assertion to append predicates that do not depend on any generated package.
  25383. func (m *TokenMutation) WhereP(ps ...func(*sql.Selector)) {
  25384. p := make([]predicate.Token, len(ps))
  25385. for i := range ps {
  25386. p[i] = ps[i]
  25387. }
  25388. m.Where(p...)
  25389. }
  25390. // Op returns the operation name.
  25391. func (m *TokenMutation) Op() Op {
  25392. return m.op
  25393. }
  25394. // SetOp allows setting the mutation operation.
  25395. func (m *TokenMutation) SetOp(op Op) {
  25396. m.op = op
  25397. }
  25398. // Type returns the node type of this mutation (Token).
  25399. func (m *TokenMutation) Type() string {
  25400. return m.typ
  25401. }
  25402. // Fields returns all fields that were changed during this mutation. Note that in
  25403. // order to get all numeric fields that were incremented/decremented, call
  25404. // AddedFields().
  25405. func (m *TokenMutation) Fields() []string {
  25406. fields := make([]string, 0, 12)
  25407. if m.created_at != nil {
  25408. fields = append(fields, token.FieldCreatedAt)
  25409. }
  25410. if m.updated_at != nil {
  25411. fields = append(fields, token.FieldUpdatedAt)
  25412. }
  25413. if m.deleted_at != nil {
  25414. fields = append(fields, token.FieldDeletedAt)
  25415. }
  25416. if m.expire_at != nil {
  25417. fields = append(fields, token.FieldExpireAt)
  25418. }
  25419. if m.token != nil {
  25420. fields = append(fields, token.FieldToken)
  25421. }
  25422. if m.mac != nil {
  25423. fields = append(fields, token.FieldMAC)
  25424. }
  25425. if m.organization_id != nil {
  25426. fields = append(fields, token.FieldOrganizationID)
  25427. }
  25428. if m.agent != nil {
  25429. fields = append(fields, token.FieldAgentID)
  25430. }
  25431. if m.custom_agent_base != nil {
  25432. fields = append(fields, token.FieldCustomAgentBase)
  25433. }
  25434. if m.custom_agent_key != nil {
  25435. fields = append(fields, token.FieldCustomAgentKey)
  25436. }
  25437. if m.openai_base != nil {
  25438. fields = append(fields, token.FieldOpenaiBase)
  25439. }
  25440. if m.openai_key != nil {
  25441. fields = append(fields, token.FieldOpenaiKey)
  25442. }
  25443. return fields
  25444. }
  25445. // Field returns the value of a field with the given name. The second boolean
  25446. // return value indicates that this field was not set, or was not defined in the
  25447. // schema.
  25448. func (m *TokenMutation) Field(name string) (ent.Value, bool) {
  25449. switch name {
  25450. case token.FieldCreatedAt:
  25451. return m.CreatedAt()
  25452. case token.FieldUpdatedAt:
  25453. return m.UpdatedAt()
  25454. case token.FieldDeletedAt:
  25455. return m.DeletedAt()
  25456. case token.FieldExpireAt:
  25457. return m.ExpireAt()
  25458. case token.FieldToken:
  25459. return m.Token()
  25460. case token.FieldMAC:
  25461. return m.MAC()
  25462. case token.FieldOrganizationID:
  25463. return m.OrganizationID()
  25464. case token.FieldAgentID:
  25465. return m.AgentID()
  25466. case token.FieldCustomAgentBase:
  25467. return m.CustomAgentBase()
  25468. case token.FieldCustomAgentKey:
  25469. return m.CustomAgentKey()
  25470. case token.FieldOpenaiBase:
  25471. return m.OpenaiBase()
  25472. case token.FieldOpenaiKey:
  25473. return m.OpenaiKey()
  25474. }
  25475. return nil, false
  25476. }
  25477. // OldField returns the old value of the field from the database. An error is
  25478. // returned if the mutation operation is not UpdateOne, or the query to the
  25479. // database failed.
  25480. func (m *TokenMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  25481. switch name {
  25482. case token.FieldCreatedAt:
  25483. return m.OldCreatedAt(ctx)
  25484. case token.FieldUpdatedAt:
  25485. return m.OldUpdatedAt(ctx)
  25486. case token.FieldDeletedAt:
  25487. return m.OldDeletedAt(ctx)
  25488. case token.FieldExpireAt:
  25489. return m.OldExpireAt(ctx)
  25490. case token.FieldToken:
  25491. return m.OldToken(ctx)
  25492. case token.FieldMAC:
  25493. return m.OldMAC(ctx)
  25494. case token.FieldOrganizationID:
  25495. return m.OldOrganizationID(ctx)
  25496. case token.FieldAgentID:
  25497. return m.OldAgentID(ctx)
  25498. case token.FieldCustomAgentBase:
  25499. return m.OldCustomAgentBase(ctx)
  25500. case token.FieldCustomAgentKey:
  25501. return m.OldCustomAgentKey(ctx)
  25502. case token.FieldOpenaiBase:
  25503. return m.OldOpenaiBase(ctx)
  25504. case token.FieldOpenaiKey:
  25505. return m.OldOpenaiKey(ctx)
  25506. }
  25507. return nil, fmt.Errorf("unknown Token field %s", name)
  25508. }
  25509. // SetField sets the value of a field with the given name. It returns an error if
  25510. // the field is not defined in the schema, or if the type mismatched the field
  25511. // type.
  25512. func (m *TokenMutation) SetField(name string, value ent.Value) error {
  25513. switch name {
  25514. case token.FieldCreatedAt:
  25515. v, ok := value.(time.Time)
  25516. if !ok {
  25517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25518. }
  25519. m.SetCreatedAt(v)
  25520. return nil
  25521. case token.FieldUpdatedAt:
  25522. v, ok := value.(time.Time)
  25523. if !ok {
  25524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25525. }
  25526. m.SetUpdatedAt(v)
  25527. return nil
  25528. case token.FieldDeletedAt:
  25529. v, ok := value.(time.Time)
  25530. if !ok {
  25531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25532. }
  25533. m.SetDeletedAt(v)
  25534. return nil
  25535. case token.FieldExpireAt:
  25536. v, ok := value.(time.Time)
  25537. if !ok {
  25538. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25539. }
  25540. m.SetExpireAt(v)
  25541. return nil
  25542. case token.FieldToken:
  25543. v, ok := value.(string)
  25544. if !ok {
  25545. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25546. }
  25547. m.SetToken(v)
  25548. return nil
  25549. case token.FieldMAC:
  25550. v, ok := value.(string)
  25551. if !ok {
  25552. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25553. }
  25554. m.SetMAC(v)
  25555. return nil
  25556. case token.FieldOrganizationID:
  25557. v, ok := value.(uint64)
  25558. if !ok {
  25559. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25560. }
  25561. m.SetOrganizationID(v)
  25562. return nil
  25563. case token.FieldAgentID:
  25564. v, ok := value.(uint64)
  25565. if !ok {
  25566. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25567. }
  25568. m.SetAgentID(v)
  25569. return nil
  25570. case token.FieldCustomAgentBase:
  25571. v, ok := value.(string)
  25572. if !ok {
  25573. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25574. }
  25575. m.SetCustomAgentBase(v)
  25576. return nil
  25577. case token.FieldCustomAgentKey:
  25578. v, ok := value.(string)
  25579. if !ok {
  25580. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25581. }
  25582. m.SetCustomAgentKey(v)
  25583. return nil
  25584. case token.FieldOpenaiBase:
  25585. v, ok := value.(string)
  25586. if !ok {
  25587. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25588. }
  25589. m.SetOpenaiBase(v)
  25590. return nil
  25591. case token.FieldOpenaiKey:
  25592. v, ok := value.(string)
  25593. if !ok {
  25594. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25595. }
  25596. m.SetOpenaiKey(v)
  25597. return nil
  25598. }
  25599. return fmt.Errorf("unknown Token field %s", name)
  25600. }
  25601. // AddedFields returns all numeric fields that were incremented/decremented during
  25602. // this mutation.
  25603. func (m *TokenMutation) AddedFields() []string {
  25604. var fields []string
  25605. if m.addorganization_id != nil {
  25606. fields = append(fields, token.FieldOrganizationID)
  25607. }
  25608. return fields
  25609. }
  25610. // AddedField returns the numeric value that was incremented/decremented on a field
  25611. // with the given name. The second boolean return value indicates that this field
  25612. // was not set, or was not defined in the schema.
  25613. func (m *TokenMutation) AddedField(name string) (ent.Value, bool) {
  25614. switch name {
  25615. case token.FieldOrganizationID:
  25616. return m.AddedOrganizationID()
  25617. }
  25618. return nil, false
  25619. }
  25620. // AddField adds the value to the field with the given name. It returns an error if
  25621. // the field is not defined in the schema, or if the type mismatched the field
  25622. // type.
  25623. func (m *TokenMutation) AddField(name string, value ent.Value) error {
  25624. switch name {
  25625. case token.FieldOrganizationID:
  25626. v, ok := value.(int64)
  25627. if !ok {
  25628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  25629. }
  25630. m.AddOrganizationID(v)
  25631. return nil
  25632. }
  25633. return fmt.Errorf("unknown Token numeric field %s", name)
  25634. }
  25635. // ClearedFields returns all nullable fields that were cleared during this
  25636. // mutation.
  25637. func (m *TokenMutation) ClearedFields() []string {
  25638. var fields []string
  25639. if m.FieldCleared(token.FieldDeletedAt) {
  25640. fields = append(fields, token.FieldDeletedAt)
  25641. }
  25642. if m.FieldCleared(token.FieldExpireAt) {
  25643. fields = append(fields, token.FieldExpireAt)
  25644. }
  25645. if m.FieldCleared(token.FieldToken) {
  25646. fields = append(fields, token.FieldToken)
  25647. }
  25648. if m.FieldCleared(token.FieldMAC) {
  25649. fields = append(fields, token.FieldMAC)
  25650. }
  25651. if m.FieldCleared(token.FieldCustomAgentBase) {
  25652. fields = append(fields, token.FieldCustomAgentBase)
  25653. }
  25654. if m.FieldCleared(token.FieldCustomAgentKey) {
  25655. fields = append(fields, token.FieldCustomAgentKey)
  25656. }
  25657. if m.FieldCleared(token.FieldOpenaiBase) {
  25658. fields = append(fields, token.FieldOpenaiBase)
  25659. }
  25660. if m.FieldCleared(token.FieldOpenaiKey) {
  25661. fields = append(fields, token.FieldOpenaiKey)
  25662. }
  25663. return fields
  25664. }
  25665. // FieldCleared returns a boolean indicating if a field with the given name was
  25666. // cleared in this mutation.
  25667. func (m *TokenMutation) FieldCleared(name string) bool {
  25668. _, ok := m.clearedFields[name]
  25669. return ok
  25670. }
  25671. // ClearField clears the value of the field with the given name. It returns an
  25672. // error if the field is not defined in the schema.
  25673. func (m *TokenMutation) ClearField(name string) error {
  25674. switch name {
  25675. case token.FieldDeletedAt:
  25676. m.ClearDeletedAt()
  25677. return nil
  25678. case token.FieldExpireAt:
  25679. m.ClearExpireAt()
  25680. return nil
  25681. case token.FieldToken:
  25682. m.ClearToken()
  25683. return nil
  25684. case token.FieldMAC:
  25685. m.ClearMAC()
  25686. return nil
  25687. case token.FieldCustomAgentBase:
  25688. m.ClearCustomAgentBase()
  25689. return nil
  25690. case token.FieldCustomAgentKey:
  25691. m.ClearCustomAgentKey()
  25692. return nil
  25693. case token.FieldOpenaiBase:
  25694. m.ClearOpenaiBase()
  25695. return nil
  25696. case token.FieldOpenaiKey:
  25697. m.ClearOpenaiKey()
  25698. return nil
  25699. }
  25700. return fmt.Errorf("unknown Token nullable field %s", name)
  25701. }
  25702. // ResetField resets all changes in the mutation for the field with the given name.
  25703. // It returns an error if the field is not defined in the schema.
  25704. func (m *TokenMutation) ResetField(name string) error {
  25705. switch name {
  25706. case token.FieldCreatedAt:
  25707. m.ResetCreatedAt()
  25708. return nil
  25709. case token.FieldUpdatedAt:
  25710. m.ResetUpdatedAt()
  25711. return nil
  25712. case token.FieldDeletedAt:
  25713. m.ResetDeletedAt()
  25714. return nil
  25715. case token.FieldExpireAt:
  25716. m.ResetExpireAt()
  25717. return nil
  25718. case token.FieldToken:
  25719. m.ResetToken()
  25720. return nil
  25721. case token.FieldMAC:
  25722. m.ResetMAC()
  25723. return nil
  25724. case token.FieldOrganizationID:
  25725. m.ResetOrganizationID()
  25726. return nil
  25727. case token.FieldAgentID:
  25728. m.ResetAgentID()
  25729. return nil
  25730. case token.FieldCustomAgentBase:
  25731. m.ResetCustomAgentBase()
  25732. return nil
  25733. case token.FieldCustomAgentKey:
  25734. m.ResetCustomAgentKey()
  25735. return nil
  25736. case token.FieldOpenaiBase:
  25737. m.ResetOpenaiBase()
  25738. return nil
  25739. case token.FieldOpenaiKey:
  25740. m.ResetOpenaiKey()
  25741. return nil
  25742. }
  25743. return fmt.Errorf("unknown Token field %s", name)
  25744. }
  25745. // AddedEdges returns all edge names that were set/added in this mutation.
  25746. func (m *TokenMutation) AddedEdges() []string {
  25747. edges := make([]string, 0, 1)
  25748. if m.agent != nil {
  25749. edges = append(edges, token.EdgeAgent)
  25750. }
  25751. return edges
  25752. }
  25753. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  25754. // name in this mutation.
  25755. func (m *TokenMutation) AddedIDs(name string) []ent.Value {
  25756. switch name {
  25757. case token.EdgeAgent:
  25758. if id := m.agent; id != nil {
  25759. return []ent.Value{*id}
  25760. }
  25761. }
  25762. return nil
  25763. }
  25764. // RemovedEdges returns all edge names that were removed in this mutation.
  25765. func (m *TokenMutation) RemovedEdges() []string {
  25766. edges := make([]string, 0, 1)
  25767. return edges
  25768. }
  25769. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  25770. // the given name in this mutation.
  25771. func (m *TokenMutation) RemovedIDs(name string) []ent.Value {
  25772. return nil
  25773. }
  25774. // ClearedEdges returns all edge names that were cleared in this mutation.
  25775. func (m *TokenMutation) ClearedEdges() []string {
  25776. edges := make([]string, 0, 1)
  25777. if m.clearedagent {
  25778. edges = append(edges, token.EdgeAgent)
  25779. }
  25780. return edges
  25781. }
  25782. // EdgeCleared returns a boolean which indicates if the edge with the given name
  25783. // was cleared in this mutation.
  25784. func (m *TokenMutation) EdgeCleared(name string) bool {
  25785. switch name {
  25786. case token.EdgeAgent:
  25787. return m.clearedagent
  25788. }
  25789. return false
  25790. }
  25791. // ClearEdge clears the value of the edge with the given name. It returns an error
  25792. // if that edge is not defined in the schema.
  25793. func (m *TokenMutation) ClearEdge(name string) error {
  25794. switch name {
  25795. case token.EdgeAgent:
  25796. m.ClearAgent()
  25797. return nil
  25798. }
  25799. return fmt.Errorf("unknown Token unique edge %s", name)
  25800. }
  25801. // ResetEdge resets all changes to the edge with the given name in this mutation.
  25802. // It returns an error if the edge is not defined in the schema.
  25803. func (m *TokenMutation) ResetEdge(name string) error {
  25804. switch name {
  25805. case token.EdgeAgent:
  25806. m.ResetAgent()
  25807. return nil
  25808. }
  25809. return fmt.Errorf("unknown Token edge %s", name)
  25810. }
  25811. // TutorialMutation represents an operation that mutates the Tutorial nodes in the graph.
  25812. type TutorialMutation struct {
  25813. config
  25814. op Op
  25815. typ string
  25816. id *uint64
  25817. created_at *time.Time
  25818. updated_at *time.Time
  25819. deleted_at *time.Time
  25820. index *int
  25821. addindex *int
  25822. title *string
  25823. content *string
  25824. organization_id *uint64
  25825. addorganization_id *int64
  25826. clearedFields map[string]struct{}
  25827. employee *uint64
  25828. clearedemployee bool
  25829. done bool
  25830. oldValue func(context.Context) (*Tutorial, error)
  25831. predicates []predicate.Tutorial
  25832. }
  25833. var _ ent.Mutation = (*TutorialMutation)(nil)
  25834. // tutorialOption allows management of the mutation configuration using functional options.
  25835. type tutorialOption func(*TutorialMutation)
  25836. // newTutorialMutation creates new mutation for the Tutorial entity.
  25837. func newTutorialMutation(c config, op Op, opts ...tutorialOption) *TutorialMutation {
  25838. m := &TutorialMutation{
  25839. config: c,
  25840. op: op,
  25841. typ: TypeTutorial,
  25842. clearedFields: make(map[string]struct{}),
  25843. }
  25844. for _, opt := range opts {
  25845. opt(m)
  25846. }
  25847. return m
  25848. }
  25849. // withTutorialID sets the ID field of the mutation.
  25850. func withTutorialID(id uint64) tutorialOption {
  25851. return func(m *TutorialMutation) {
  25852. var (
  25853. err error
  25854. once sync.Once
  25855. value *Tutorial
  25856. )
  25857. m.oldValue = func(ctx context.Context) (*Tutorial, error) {
  25858. once.Do(func() {
  25859. if m.done {
  25860. err = errors.New("querying old values post mutation is not allowed")
  25861. } else {
  25862. value, err = m.Client().Tutorial.Get(ctx, id)
  25863. }
  25864. })
  25865. return value, err
  25866. }
  25867. m.id = &id
  25868. }
  25869. }
  25870. // withTutorial sets the old Tutorial of the mutation.
  25871. func withTutorial(node *Tutorial) tutorialOption {
  25872. return func(m *TutorialMutation) {
  25873. m.oldValue = func(context.Context) (*Tutorial, error) {
  25874. return node, nil
  25875. }
  25876. m.id = &node.ID
  25877. }
  25878. }
  25879. // Client returns a new `ent.Client` from the mutation. If the mutation was
  25880. // executed in a transaction (ent.Tx), a transactional client is returned.
  25881. func (m TutorialMutation) Client() *Client {
  25882. client := &Client{config: m.config}
  25883. client.init()
  25884. return client
  25885. }
  25886. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  25887. // it returns an error otherwise.
  25888. func (m TutorialMutation) Tx() (*Tx, error) {
  25889. if _, ok := m.driver.(*txDriver); !ok {
  25890. return nil, errors.New("ent: mutation is not running in a transaction")
  25891. }
  25892. tx := &Tx{config: m.config}
  25893. tx.init()
  25894. return tx, nil
  25895. }
  25896. // SetID sets the value of the id field. Note that this
  25897. // operation is only accepted on creation of Tutorial entities.
  25898. func (m *TutorialMutation) SetID(id uint64) {
  25899. m.id = &id
  25900. }
  25901. // ID returns the ID value in the mutation. Note that the ID is only available
  25902. // if it was provided to the builder or after it was returned from the database.
  25903. func (m *TutorialMutation) ID() (id uint64, exists bool) {
  25904. if m.id == nil {
  25905. return
  25906. }
  25907. return *m.id, true
  25908. }
  25909. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  25910. // That means, if the mutation is applied within a transaction with an isolation level such
  25911. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  25912. // or updated by the mutation.
  25913. func (m *TutorialMutation) IDs(ctx context.Context) ([]uint64, error) {
  25914. switch {
  25915. case m.op.Is(OpUpdateOne | OpDeleteOne):
  25916. id, exists := m.ID()
  25917. if exists {
  25918. return []uint64{id}, nil
  25919. }
  25920. fallthrough
  25921. case m.op.Is(OpUpdate | OpDelete):
  25922. return m.Client().Tutorial.Query().Where(m.predicates...).IDs(ctx)
  25923. default:
  25924. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  25925. }
  25926. }
  25927. // SetCreatedAt sets the "created_at" field.
  25928. func (m *TutorialMutation) SetCreatedAt(t time.Time) {
  25929. m.created_at = &t
  25930. }
  25931. // CreatedAt returns the value of the "created_at" field in the mutation.
  25932. func (m *TutorialMutation) CreatedAt() (r time.Time, exists bool) {
  25933. v := m.created_at
  25934. if v == nil {
  25935. return
  25936. }
  25937. return *v, true
  25938. }
  25939. // OldCreatedAt returns the old "created_at" field's value of the Tutorial entity.
  25940. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25941. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25942. func (m *TutorialMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  25943. if !m.op.Is(OpUpdateOne) {
  25944. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  25945. }
  25946. if m.id == nil || m.oldValue == nil {
  25947. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  25948. }
  25949. oldValue, err := m.oldValue(ctx)
  25950. if err != nil {
  25951. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  25952. }
  25953. return oldValue.CreatedAt, nil
  25954. }
  25955. // ResetCreatedAt resets all changes to the "created_at" field.
  25956. func (m *TutorialMutation) ResetCreatedAt() {
  25957. m.created_at = nil
  25958. }
  25959. // SetUpdatedAt sets the "updated_at" field.
  25960. func (m *TutorialMutation) SetUpdatedAt(t time.Time) {
  25961. m.updated_at = &t
  25962. }
  25963. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  25964. func (m *TutorialMutation) UpdatedAt() (r time.Time, exists bool) {
  25965. v := m.updated_at
  25966. if v == nil {
  25967. return
  25968. }
  25969. return *v, true
  25970. }
  25971. // OldUpdatedAt returns the old "updated_at" field's value of the Tutorial entity.
  25972. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  25973. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  25974. func (m *TutorialMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  25975. if !m.op.Is(OpUpdateOne) {
  25976. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  25977. }
  25978. if m.id == nil || m.oldValue == nil {
  25979. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  25980. }
  25981. oldValue, err := m.oldValue(ctx)
  25982. if err != nil {
  25983. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  25984. }
  25985. return oldValue.UpdatedAt, nil
  25986. }
  25987. // ResetUpdatedAt resets all changes to the "updated_at" field.
  25988. func (m *TutorialMutation) ResetUpdatedAt() {
  25989. m.updated_at = nil
  25990. }
  25991. // SetDeletedAt sets the "deleted_at" field.
  25992. func (m *TutorialMutation) SetDeletedAt(t time.Time) {
  25993. m.deleted_at = &t
  25994. }
  25995. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  25996. func (m *TutorialMutation) DeletedAt() (r time.Time, exists bool) {
  25997. v := m.deleted_at
  25998. if v == nil {
  25999. return
  26000. }
  26001. return *v, true
  26002. }
  26003. // OldDeletedAt returns the old "deleted_at" field's value of the Tutorial entity.
  26004. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26005. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26006. func (m *TutorialMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  26007. if !m.op.Is(OpUpdateOne) {
  26008. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  26009. }
  26010. if m.id == nil || m.oldValue == nil {
  26011. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  26012. }
  26013. oldValue, err := m.oldValue(ctx)
  26014. if err != nil {
  26015. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  26016. }
  26017. return oldValue.DeletedAt, nil
  26018. }
  26019. // ClearDeletedAt clears the value of the "deleted_at" field.
  26020. func (m *TutorialMutation) ClearDeletedAt() {
  26021. m.deleted_at = nil
  26022. m.clearedFields[tutorial.FieldDeletedAt] = struct{}{}
  26023. }
  26024. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  26025. func (m *TutorialMutation) DeletedAtCleared() bool {
  26026. _, ok := m.clearedFields[tutorial.FieldDeletedAt]
  26027. return ok
  26028. }
  26029. // ResetDeletedAt resets all changes to the "deleted_at" field.
  26030. func (m *TutorialMutation) ResetDeletedAt() {
  26031. m.deleted_at = nil
  26032. delete(m.clearedFields, tutorial.FieldDeletedAt)
  26033. }
  26034. // SetEmployeeID sets the "employee_id" field.
  26035. func (m *TutorialMutation) SetEmployeeID(u uint64) {
  26036. m.employee = &u
  26037. }
  26038. // EmployeeID returns the value of the "employee_id" field in the mutation.
  26039. func (m *TutorialMutation) EmployeeID() (r uint64, exists bool) {
  26040. v := m.employee
  26041. if v == nil {
  26042. return
  26043. }
  26044. return *v, true
  26045. }
  26046. // OldEmployeeID returns the old "employee_id" field's value of the Tutorial entity.
  26047. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26048. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26049. func (m *TutorialMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  26050. if !m.op.Is(OpUpdateOne) {
  26051. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  26052. }
  26053. if m.id == nil || m.oldValue == nil {
  26054. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  26055. }
  26056. oldValue, err := m.oldValue(ctx)
  26057. if err != nil {
  26058. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  26059. }
  26060. return oldValue.EmployeeID, nil
  26061. }
  26062. // ResetEmployeeID resets all changes to the "employee_id" field.
  26063. func (m *TutorialMutation) ResetEmployeeID() {
  26064. m.employee = nil
  26065. }
  26066. // SetIndex sets the "index" field.
  26067. func (m *TutorialMutation) SetIndex(i int) {
  26068. m.index = &i
  26069. m.addindex = nil
  26070. }
  26071. // Index returns the value of the "index" field in the mutation.
  26072. func (m *TutorialMutation) Index() (r int, exists bool) {
  26073. v := m.index
  26074. if v == nil {
  26075. return
  26076. }
  26077. return *v, true
  26078. }
  26079. // OldIndex returns the old "index" 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) OldIndex(ctx context.Context) (v int, err error) {
  26083. if !m.op.Is(OpUpdateOne) {
  26084. return v, errors.New("OldIndex is only allowed on UpdateOne operations")
  26085. }
  26086. if m.id == nil || m.oldValue == nil {
  26087. return v, errors.New("OldIndex 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 OldIndex: %w", err)
  26092. }
  26093. return oldValue.Index, nil
  26094. }
  26095. // AddIndex adds i to the "index" field.
  26096. func (m *TutorialMutation) AddIndex(i int) {
  26097. if m.addindex != nil {
  26098. *m.addindex += i
  26099. } else {
  26100. m.addindex = &i
  26101. }
  26102. }
  26103. // AddedIndex returns the value that was added to the "index" field in this mutation.
  26104. func (m *TutorialMutation) AddedIndex() (r int, exists bool) {
  26105. v := m.addindex
  26106. if v == nil {
  26107. return
  26108. }
  26109. return *v, true
  26110. }
  26111. // ResetIndex resets all changes to the "index" field.
  26112. func (m *TutorialMutation) ResetIndex() {
  26113. m.index = nil
  26114. m.addindex = nil
  26115. }
  26116. // SetTitle sets the "title" field.
  26117. func (m *TutorialMutation) SetTitle(s string) {
  26118. m.title = &s
  26119. }
  26120. // Title returns the value of the "title" field in the mutation.
  26121. func (m *TutorialMutation) Title() (r string, exists bool) {
  26122. v := m.title
  26123. if v == nil {
  26124. return
  26125. }
  26126. return *v, true
  26127. }
  26128. // OldTitle returns the old "title" field's value of the Tutorial entity.
  26129. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26130. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26131. func (m *TutorialMutation) OldTitle(ctx context.Context) (v string, err error) {
  26132. if !m.op.Is(OpUpdateOne) {
  26133. return v, errors.New("OldTitle is only allowed on UpdateOne operations")
  26134. }
  26135. if m.id == nil || m.oldValue == nil {
  26136. return v, errors.New("OldTitle requires an ID field in the mutation")
  26137. }
  26138. oldValue, err := m.oldValue(ctx)
  26139. if err != nil {
  26140. return v, fmt.Errorf("querying old value for OldTitle: %w", err)
  26141. }
  26142. return oldValue.Title, nil
  26143. }
  26144. // ResetTitle resets all changes to the "title" field.
  26145. func (m *TutorialMutation) ResetTitle() {
  26146. m.title = nil
  26147. }
  26148. // SetContent sets the "content" field.
  26149. func (m *TutorialMutation) SetContent(s string) {
  26150. m.content = &s
  26151. }
  26152. // Content returns the value of the "content" field in the mutation.
  26153. func (m *TutorialMutation) Content() (r string, exists bool) {
  26154. v := m.content
  26155. if v == nil {
  26156. return
  26157. }
  26158. return *v, true
  26159. }
  26160. // OldContent returns the old "content" field's value of the Tutorial entity.
  26161. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26162. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26163. func (m *TutorialMutation) OldContent(ctx context.Context) (v string, err error) {
  26164. if !m.op.Is(OpUpdateOne) {
  26165. return v, errors.New("OldContent is only allowed on UpdateOne operations")
  26166. }
  26167. if m.id == nil || m.oldValue == nil {
  26168. return v, errors.New("OldContent requires an ID field in the mutation")
  26169. }
  26170. oldValue, err := m.oldValue(ctx)
  26171. if err != nil {
  26172. return v, fmt.Errorf("querying old value for OldContent: %w", err)
  26173. }
  26174. return oldValue.Content, nil
  26175. }
  26176. // ResetContent resets all changes to the "content" field.
  26177. func (m *TutorialMutation) ResetContent() {
  26178. m.content = nil
  26179. }
  26180. // SetOrganizationID sets the "organization_id" field.
  26181. func (m *TutorialMutation) SetOrganizationID(u uint64) {
  26182. m.organization_id = &u
  26183. m.addorganization_id = nil
  26184. }
  26185. // OrganizationID returns the value of the "organization_id" field in the mutation.
  26186. func (m *TutorialMutation) OrganizationID() (r uint64, exists bool) {
  26187. v := m.organization_id
  26188. if v == nil {
  26189. return
  26190. }
  26191. return *v, true
  26192. }
  26193. // OldOrganizationID returns the old "organization_id" field's value of the Tutorial entity.
  26194. // If the Tutorial object wasn't provided to the builder, the object is fetched from the database.
  26195. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26196. func (m *TutorialMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  26197. if !m.op.Is(OpUpdateOne) {
  26198. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  26199. }
  26200. if m.id == nil || m.oldValue == nil {
  26201. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  26202. }
  26203. oldValue, err := m.oldValue(ctx)
  26204. if err != nil {
  26205. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  26206. }
  26207. return oldValue.OrganizationID, nil
  26208. }
  26209. // AddOrganizationID adds u to the "organization_id" field.
  26210. func (m *TutorialMutation) AddOrganizationID(u int64) {
  26211. if m.addorganization_id != nil {
  26212. *m.addorganization_id += u
  26213. } else {
  26214. m.addorganization_id = &u
  26215. }
  26216. }
  26217. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  26218. func (m *TutorialMutation) AddedOrganizationID() (r int64, exists bool) {
  26219. v := m.addorganization_id
  26220. if v == nil {
  26221. return
  26222. }
  26223. return *v, true
  26224. }
  26225. // ResetOrganizationID resets all changes to the "organization_id" field.
  26226. func (m *TutorialMutation) ResetOrganizationID() {
  26227. m.organization_id = nil
  26228. m.addorganization_id = nil
  26229. }
  26230. // ClearEmployee clears the "employee" edge to the Employee entity.
  26231. func (m *TutorialMutation) ClearEmployee() {
  26232. m.clearedemployee = true
  26233. m.clearedFields[tutorial.FieldEmployeeID] = struct{}{}
  26234. }
  26235. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  26236. func (m *TutorialMutation) EmployeeCleared() bool {
  26237. return m.clearedemployee
  26238. }
  26239. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  26240. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  26241. // EmployeeID instead. It exists only for internal usage by the builders.
  26242. func (m *TutorialMutation) EmployeeIDs() (ids []uint64) {
  26243. if id := m.employee; id != nil {
  26244. ids = append(ids, *id)
  26245. }
  26246. return
  26247. }
  26248. // ResetEmployee resets all changes to the "employee" edge.
  26249. func (m *TutorialMutation) ResetEmployee() {
  26250. m.employee = nil
  26251. m.clearedemployee = false
  26252. }
  26253. // Where appends a list predicates to the TutorialMutation builder.
  26254. func (m *TutorialMutation) Where(ps ...predicate.Tutorial) {
  26255. m.predicates = append(m.predicates, ps...)
  26256. }
  26257. // WhereP appends storage-level predicates to the TutorialMutation builder. Using this method,
  26258. // users can use type-assertion to append predicates that do not depend on any generated package.
  26259. func (m *TutorialMutation) WhereP(ps ...func(*sql.Selector)) {
  26260. p := make([]predicate.Tutorial, len(ps))
  26261. for i := range ps {
  26262. p[i] = ps[i]
  26263. }
  26264. m.Where(p...)
  26265. }
  26266. // Op returns the operation name.
  26267. func (m *TutorialMutation) Op() Op {
  26268. return m.op
  26269. }
  26270. // SetOp allows setting the mutation operation.
  26271. func (m *TutorialMutation) SetOp(op Op) {
  26272. m.op = op
  26273. }
  26274. // Type returns the node type of this mutation (Tutorial).
  26275. func (m *TutorialMutation) Type() string {
  26276. return m.typ
  26277. }
  26278. // Fields returns all fields that were changed during this mutation. Note that in
  26279. // order to get all numeric fields that were incremented/decremented, call
  26280. // AddedFields().
  26281. func (m *TutorialMutation) Fields() []string {
  26282. fields := make([]string, 0, 8)
  26283. if m.created_at != nil {
  26284. fields = append(fields, tutorial.FieldCreatedAt)
  26285. }
  26286. if m.updated_at != nil {
  26287. fields = append(fields, tutorial.FieldUpdatedAt)
  26288. }
  26289. if m.deleted_at != nil {
  26290. fields = append(fields, tutorial.FieldDeletedAt)
  26291. }
  26292. if m.employee != nil {
  26293. fields = append(fields, tutorial.FieldEmployeeID)
  26294. }
  26295. if m.index != nil {
  26296. fields = append(fields, tutorial.FieldIndex)
  26297. }
  26298. if m.title != nil {
  26299. fields = append(fields, tutorial.FieldTitle)
  26300. }
  26301. if m.content != nil {
  26302. fields = append(fields, tutorial.FieldContent)
  26303. }
  26304. if m.organization_id != nil {
  26305. fields = append(fields, tutorial.FieldOrganizationID)
  26306. }
  26307. return fields
  26308. }
  26309. // Field returns the value of a field with the given name. The second boolean
  26310. // return value indicates that this field was not set, or was not defined in the
  26311. // schema.
  26312. func (m *TutorialMutation) Field(name string) (ent.Value, bool) {
  26313. switch name {
  26314. case tutorial.FieldCreatedAt:
  26315. return m.CreatedAt()
  26316. case tutorial.FieldUpdatedAt:
  26317. return m.UpdatedAt()
  26318. case tutorial.FieldDeletedAt:
  26319. return m.DeletedAt()
  26320. case tutorial.FieldEmployeeID:
  26321. return m.EmployeeID()
  26322. case tutorial.FieldIndex:
  26323. return m.Index()
  26324. case tutorial.FieldTitle:
  26325. return m.Title()
  26326. case tutorial.FieldContent:
  26327. return m.Content()
  26328. case tutorial.FieldOrganizationID:
  26329. return m.OrganizationID()
  26330. }
  26331. return nil, false
  26332. }
  26333. // OldField returns the old value of the field from the database. An error is
  26334. // returned if the mutation operation is not UpdateOne, or the query to the
  26335. // database failed.
  26336. func (m *TutorialMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  26337. switch name {
  26338. case tutorial.FieldCreatedAt:
  26339. return m.OldCreatedAt(ctx)
  26340. case tutorial.FieldUpdatedAt:
  26341. return m.OldUpdatedAt(ctx)
  26342. case tutorial.FieldDeletedAt:
  26343. return m.OldDeletedAt(ctx)
  26344. case tutorial.FieldEmployeeID:
  26345. return m.OldEmployeeID(ctx)
  26346. case tutorial.FieldIndex:
  26347. return m.OldIndex(ctx)
  26348. case tutorial.FieldTitle:
  26349. return m.OldTitle(ctx)
  26350. case tutorial.FieldContent:
  26351. return m.OldContent(ctx)
  26352. case tutorial.FieldOrganizationID:
  26353. return m.OldOrganizationID(ctx)
  26354. }
  26355. return nil, fmt.Errorf("unknown Tutorial field %s", name)
  26356. }
  26357. // SetField sets the value of a field with the given name. It returns an error if
  26358. // the field is not defined in the schema, or if the type mismatched the field
  26359. // type.
  26360. func (m *TutorialMutation) SetField(name string, value ent.Value) error {
  26361. switch name {
  26362. case tutorial.FieldCreatedAt:
  26363. v, ok := value.(time.Time)
  26364. if !ok {
  26365. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26366. }
  26367. m.SetCreatedAt(v)
  26368. return nil
  26369. case tutorial.FieldUpdatedAt:
  26370. v, ok := value.(time.Time)
  26371. if !ok {
  26372. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26373. }
  26374. m.SetUpdatedAt(v)
  26375. return nil
  26376. case tutorial.FieldDeletedAt:
  26377. v, ok := value.(time.Time)
  26378. if !ok {
  26379. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26380. }
  26381. m.SetDeletedAt(v)
  26382. return nil
  26383. case tutorial.FieldEmployeeID:
  26384. v, ok := value.(uint64)
  26385. if !ok {
  26386. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26387. }
  26388. m.SetEmployeeID(v)
  26389. return nil
  26390. case tutorial.FieldIndex:
  26391. v, ok := value.(int)
  26392. if !ok {
  26393. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26394. }
  26395. m.SetIndex(v)
  26396. return nil
  26397. case tutorial.FieldTitle:
  26398. v, ok := value.(string)
  26399. if !ok {
  26400. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26401. }
  26402. m.SetTitle(v)
  26403. return nil
  26404. case tutorial.FieldContent:
  26405. v, ok := value.(string)
  26406. if !ok {
  26407. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26408. }
  26409. m.SetContent(v)
  26410. return nil
  26411. case tutorial.FieldOrganizationID:
  26412. v, ok := value.(uint64)
  26413. if !ok {
  26414. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26415. }
  26416. m.SetOrganizationID(v)
  26417. return nil
  26418. }
  26419. return fmt.Errorf("unknown Tutorial field %s", name)
  26420. }
  26421. // AddedFields returns all numeric fields that were incremented/decremented during
  26422. // this mutation.
  26423. func (m *TutorialMutation) AddedFields() []string {
  26424. var fields []string
  26425. if m.addindex != nil {
  26426. fields = append(fields, tutorial.FieldIndex)
  26427. }
  26428. if m.addorganization_id != nil {
  26429. fields = append(fields, tutorial.FieldOrganizationID)
  26430. }
  26431. return fields
  26432. }
  26433. // AddedField returns the numeric value that was incremented/decremented on a field
  26434. // with the given name. The second boolean return value indicates that this field
  26435. // was not set, or was not defined in the schema.
  26436. func (m *TutorialMutation) AddedField(name string) (ent.Value, bool) {
  26437. switch name {
  26438. case tutorial.FieldIndex:
  26439. return m.AddedIndex()
  26440. case tutorial.FieldOrganizationID:
  26441. return m.AddedOrganizationID()
  26442. }
  26443. return nil, false
  26444. }
  26445. // AddField adds the value to the field with the given name. It returns an error if
  26446. // the field is not defined in the schema, or if the type mismatched the field
  26447. // type.
  26448. func (m *TutorialMutation) AddField(name string, value ent.Value) error {
  26449. switch name {
  26450. case tutorial.FieldIndex:
  26451. v, ok := value.(int)
  26452. if !ok {
  26453. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26454. }
  26455. m.AddIndex(v)
  26456. return nil
  26457. case tutorial.FieldOrganizationID:
  26458. v, ok := value.(int64)
  26459. if !ok {
  26460. return fmt.Errorf("unexpected type %T for field %s", value, name)
  26461. }
  26462. m.AddOrganizationID(v)
  26463. return nil
  26464. }
  26465. return fmt.Errorf("unknown Tutorial numeric field %s", name)
  26466. }
  26467. // ClearedFields returns all nullable fields that were cleared during this
  26468. // mutation.
  26469. func (m *TutorialMutation) ClearedFields() []string {
  26470. var fields []string
  26471. if m.FieldCleared(tutorial.FieldDeletedAt) {
  26472. fields = append(fields, tutorial.FieldDeletedAt)
  26473. }
  26474. return fields
  26475. }
  26476. // FieldCleared returns a boolean indicating if a field with the given name was
  26477. // cleared in this mutation.
  26478. func (m *TutorialMutation) FieldCleared(name string) bool {
  26479. _, ok := m.clearedFields[name]
  26480. return ok
  26481. }
  26482. // ClearField clears the value of the field with the given name. It returns an
  26483. // error if the field is not defined in the schema.
  26484. func (m *TutorialMutation) ClearField(name string) error {
  26485. switch name {
  26486. case tutorial.FieldDeletedAt:
  26487. m.ClearDeletedAt()
  26488. return nil
  26489. }
  26490. return fmt.Errorf("unknown Tutorial nullable field %s", name)
  26491. }
  26492. // ResetField resets all changes in the mutation for the field with the given name.
  26493. // It returns an error if the field is not defined in the schema.
  26494. func (m *TutorialMutation) ResetField(name string) error {
  26495. switch name {
  26496. case tutorial.FieldCreatedAt:
  26497. m.ResetCreatedAt()
  26498. return nil
  26499. case tutorial.FieldUpdatedAt:
  26500. m.ResetUpdatedAt()
  26501. return nil
  26502. case tutorial.FieldDeletedAt:
  26503. m.ResetDeletedAt()
  26504. return nil
  26505. case tutorial.FieldEmployeeID:
  26506. m.ResetEmployeeID()
  26507. return nil
  26508. case tutorial.FieldIndex:
  26509. m.ResetIndex()
  26510. return nil
  26511. case tutorial.FieldTitle:
  26512. m.ResetTitle()
  26513. return nil
  26514. case tutorial.FieldContent:
  26515. m.ResetContent()
  26516. return nil
  26517. case tutorial.FieldOrganizationID:
  26518. m.ResetOrganizationID()
  26519. return nil
  26520. }
  26521. return fmt.Errorf("unknown Tutorial field %s", name)
  26522. }
  26523. // AddedEdges returns all edge names that were set/added in this mutation.
  26524. func (m *TutorialMutation) AddedEdges() []string {
  26525. edges := make([]string, 0, 1)
  26526. if m.employee != nil {
  26527. edges = append(edges, tutorial.EdgeEmployee)
  26528. }
  26529. return edges
  26530. }
  26531. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  26532. // name in this mutation.
  26533. func (m *TutorialMutation) AddedIDs(name string) []ent.Value {
  26534. switch name {
  26535. case tutorial.EdgeEmployee:
  26536. if id := m.employee; id != nil {
  26537. return []ent.Value{*id}
  26538. }
  26539. }
  26540. return nil
  26541. }
  26542. // RemovedEdges returns all edge names that were removed in this mutation.
  26543. func (m *TutorialMutation) RemovedEdges() []string {
  26544. edges := make([]string, 0, 1)
  26545. return edges
  26546. }
  26547. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  26548. // the given name in this mutation.
  26549. func (m *TutorialMutation) RemovedIDs(name string) []ent.Value {
  26550. return nil
  26551. }
  26552. // ClearedEdges returns all edge names that were cleared in this mutation.
  26553. func (m *TutorialMutation) ClearedEdges() []string {
  26554. edges := make([]string, 0, 1)
  26555. if m.clearedemployee {
  26556. edges = append(edges, tutorial.EdgeEmployee)
  26557. }
  26558. return edges
  26559. }
  26560. // EdgeCleared returns a boolean which indicates if the edge with the given name
  26561. // was cleared in this mutation.
  26562. func (m *TutorialMutation) EdgeCleared(name string) bool {
  26563. switch name {
  26564. case tutorial.EdgeEmployee:
  26565. return m.clearedemployee
  26566. }
  26567. return false
  26568. }
  26569. // ClearEdge clears the value of the edge with the given name. It returns an error
  26570. // if that edge is not defined in the schema.
  26571. func (m *TutorialMutation) ClearEdge(name string) error {
  26572. switch name {
  26573. case tutorial.EdgeEmployee:
  26574. m.ClearEmployee()
  26575. return nil
  26576. }
  26577. return fmt.Errorf("unknown Tutorial unique edge %s", name)
  26578. }
  26579. // ResetEdge resets all changes to the edge with the given name in this mutation.
  26580. // It returns an error if the edge is not defined in the schema.
  26581. func (m *TutorialMutation) ResetEdge(name string) error {
  26582. switch name {
  26583. case tutorial.EdgeEmployee:
  26584. m.ResetEmployee()
  26585. return nil
  26586. }
  26587. return fmt.Errorf("unknown Tutorial edge %s", name)
  26588. }
  26589. // UsageDetailMutation represents an operation that mutates the UsageDetail nodes in the graph.
  26590. type UsageDetailMutation struct {
  26591. config
  26592. op Op
  26593. typ string
  26594. id *uint64
  26595. created_at *time.Time
  26596. updated_at *time.Time
  26597. status *uint8
  26598. addstatus *int8
  26599. _type *int
  26600. add_type *int
  26601. bot_id *string
  26602. receiver_id *string
  26603. app *int
  26604. addapp *int
  26605. session_id *uint64
  26606. addsession_id *int64
  26607. request *string
  26608. response *string
  26609. original_data *custom_types.OriginalData
  26610. total_tokens *uint64
  26611. addtotal_tokens *int64
  26612. prompt_tokens *uint64
  26613. addprompt_tokens *int64
  26614. completion_tokens *uint64
  26615. addcompletion_tokens *int64
  26616. organization_id *uint64
  26617. addorganization_id *int64
  26618. clearedFields map[string]struct{}
  26619. done bool
  26620. oldValue func(context.Context) (*UsageDetail, error)
  26621. predicates []predicate.UsageDetail
  26622. }
  26623. var _ ent.Mutation = (*UsageDetailMutation)(nil)
  26624. // usagedetailOption allows management of the mutation configuration using functional options.
  26625. type usagedetailOption func(*UsageDetailMutation)
  26626. // newUsageDetailMutation creates new mutation for the UsageDetail entity.
  26627. func newUsageDetailMutation(c config, op Op, opts ...usagedetailOption) *UsageDetailMutation {
  26628. m := &UsageDetailMutation{
  26629. config: c,
  26630. op: op,
  26631. typ: TypeUsageDetail,
  26632. clearedFields: make(map[string]struct{}),
  26633. }
  26634. for _, opt := range opts {
  26635. opt(m)
  26636. }
  26637. return m
  26638. }
  26639. // withUsageDetailID sets the ID field of the mutation.
  26640. func withUsageDetailID(id uint64) usagedetailOption {
  26641. return func(m *UsageDetailMutation) {
  26642. var (
  26643. err error
  26644. once sync.Once
  26645. value *UsageDetail
  26646. )
  26647. m.oldValue = func(ctx context.Context) (*UsageDetail, error) {
  26648. once.Do(func() {
  26649. if m.done {
  26650. err = errors.New("querying old values post mutation is not allowed")
  26651. } else {
  26652. value, err = m.Client().UsageDetail.Get(ctx, id)
  26653. }
  26654. })
  26655. return value, err
  26656. }
  26657. m.id = &id
  26658. }
  26659. }
  26660. // withUsageDetail sets the old UsageDetail of the mutation.
  26661. func withUsageDetail(node *UsageDetail) usagedetailOption {
  26662. return func(m *UsageDetailMutation) {
  26663. m.oldValue = func(context.Context) (*UsageDetail, error) {
  26664. return node, nil
  26665. }
  26666. m.id = &node.ID
  26667. }
  26668. }
  26669. // Client returns a new `ent.Client` from the mutation. If the mutation was
  26670. // executed in a transaction (ent.Tx), a transactional client is returned.
  26671. func (m UsageDetailMutation) Client() *Client {
  26672. client := &Client{config: m.config}
  26673. client.init()
  26674. return client
  26675. }
  26676. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  26677. // it returns an error otherwise.
  26678. func (m UsageDetailMutation) Tx() (*Tx, error) {
  26679. if _, ok := m.driver.(*txDriver); !ok {
  26680. return nil, errors.New("ent: mutation is not running in a transaction")
  26681. }
  26682. tx := &Tx{config: m.config}
  26683. tx.init()
  26684. return tx, nil
  26685. }
  26686. // SetID sets the value of the id field. Note that this
  26687. // operation is only accepted on creation of UsageDetail entities.
  26688. func (m *UsageDetailMutation) SetID(id uint64) {
  26689. m.id = &id
  26690. }
  26691. // ID returns the ID value in the mutation. Note that the ID is only available
  26692. // if it was provided to the builder or after it was returned from the database.
  26693. func (m *UsageDetailMutation) ID() (id uint64, exists bool) {
  26694. if m.id == nil {
  26695. return
  26696. }
  26697. return *m.id, true
  26698. }
  26699. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  26700. // That means, if the mutation is applied within a transaction with an isolation level such
  26701. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  26702. // or updated by the mutation.
  26703. func (m *UsageDetailMutation) IDs(ctx context.Context) ([]uint64, error) {
  26704. switch {
  26705. case m.op.Is(OpUpdateOne | OpDeleteOne):
  26706. id, exists := m.ID()
  26707. if exists {
  26708. return []uint64{id}, nil
  26709. }
  26710. fallthrough
  26711. case m.op.Is(OpUpdate | OpDelete):
  26712. return m.Client().UsageDetail.Query().Where(m.predicates...).IDs(ctx)
  26713. default:
  26714. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  26715. }
  26716. }
  26717. // SetCreatedAt sets the "created_at" field.
  26718. func (m *UsageDetailMutation) SetCreatedAt(t time.Time) {
  26719. m.created_at = &t
  26720. }
  26721. // CreatedAt returns the value of the "created_at" field in the mutation.
  26722. func (m *UsageDetailMutation) CreatedAt() (r time.Time, exists bool) {
  26723. v := m.created_at
  26724. if v == nil {
  26725. return
  26726. }
  26727. return *v, true
  26728. }
  26729. // OldCreatedAt returns the old "created_at" field's value of the UsageDetail entity.
  26730. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26731. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26732. func (m *UsageDetailMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  26733. if !m.op.Is(OpUpdateOne) {
  26734. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  26735. }
  26736. if m.id == nil || m.oldValue == nil {
  26737. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  26738. }
  26739. oldValue, err := m.oldValue(ctx)
  26740. if err != nil {
  26741. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  26742. }
  26743. return oldValue.CreatedAt, nil
  26744. }
  26745. // ResetCreatedAt resets all changes to the "created_at" field.
  26746. func (m *UsageDetailMutation) ResetCreatedAt() {
  26747. m.created_at = nil
  26748. }
  26749. // SetUpdatedAt sets the "updated_at" field.
  26750. func (m *UsageDetailMutation) SetUpdatedAt(t time.Time) {
  26751. m.updated_at = &t
  26752. }
  26753. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  26754. func (m *UsageDetailMutation) UpdatedAt() (r time.Time, exists bool) {
  26755. v := m.updated_at
  26756. if v == nil {
  26757. return
  26758. }
  26759. return *v, true
  26760. }
  26761. // OldUpdatedAt returns the old "updated_at" field's value of the UsageDetail entity.
  26762. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26763. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26764. func (m *UsageDetailMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  26765. if !m.op.Is(OpUpdateOne) {
  26766. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  26767. }
  26768. if m.id == nil || m.oldValue == nil {
  26769. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  26770. }
  26771. oldValue, err := m.oldValue(ctx)
  26772. if err != nil {
  26773. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  26774. }
  26775. return oldValue.UpdatedAt, nil
  26776. }
  26777. // ResetUpdatedAt resets all changes to the "updated_at" field.
  26778. func (m *UsageDetailMutation) ResetUpdatedAt() {
  26779. m.updated_at = nil
  26780. }
  26781. // SetStatus sets the "status" field.
  26782. func (m *UsageDetailMutation) SetStatus(u uint8) {
  26783. m.status = &u
  26784. m.addstatus = nil
  26785. }
  26786. // Status returns the value of the "status" field in the mutation.
  26787. func (m *UsageDetailMutation) Status() (r uint8, exists bool) {
  26788. v := m.status
  26789. if v == nil {
  26790. return
  26791. }
  26792. return *v, true
  26793. }
  26794. // OldStatus returns the old "status" field's value of the UsageDetail entity.
  26795. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26796. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26797. func (m *UsageDetailMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  26798. if !m.op.Is(OpUpdateOne) {
  26799. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  26800. }
  26801. if m.id == nil || m.oldValue == nil {
  26802. return v, errors.New("OldStatus requires an ID field in the mutation")
  26803. }
  26804. oldValue, err := m.oldValue(ctx)
  26805. if err != nil {
  26806. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  26807. }
  26808. return oldValue.Status, nil
  26809. }
  26810. // AddStatus adds u to the "status" field.
  26811. func (m *UsageDetailMutation) AddStatus(u int8) {
  26812. if m.addstatus != nil {
  26813. *m.addstatus += u
  26814. } else {
  26815. m.addstatus = &u
  26816. }
  26817. }
  26818. // AddedStatus returns the value that was added to the "status" field in this mutation.
  26819. func (m *UsageDetailMutation) AddedStatus() (r int8, exists bool) {
  26820. v := m.addstatus
  26821. if v == nil {
  26822. return
  26823. }
  26824. return *v, true
  26825. }
  26826. // ClearStatus clears the value of the "status" field.
  26827. func (m *UsageDetailMutation) ClearStatus() {
  26828. m.status = nil
  26829. m.addstatus = nil
  26830. m.clearedFields[usagedetail.FieldStatus] = struct{}{}
  26831. }
  26832. // StatusCleared returns if the "status" field was cleared in this mutation.
  26833. func (m *UsageDetailMutation) StatusCleared() bool {
  26834. _, ok := m.clearedFields[usagedetail.FieldStatus]
  26835. return ok
  26836. }
  26837. // ResetStatus resets all changes to the "status" field.
  26838. func (m *UsageDetailMutation) ResetStatus() {
  26839. m.status = nil
  26840. m.addstatus = nil
  26841. delete(m.clearedFields, usagedetail.FieldStatus)
  26842. }
  26843. // SetType sets the "type" field.
  26844. func (m *UsageDetailMutation) SetType(i int) {
  26845. m._type = &i
  26846. m.add_type = nil
  26847. }
  26848. // GetType returns the value of the "type" field in the mutation.
  26849. func (m *UsageDetailMutation) GetType() (r int, exists bool) {
  26850. v := m._type
  26851. if v == nil {
  26852. return
  26853. }
  26854. return *v, true
  26855. }
  26856. // OldType returns the old "type" field's value of the UsageDetail entity.
  26857. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26858. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26859. func (m *UsageDetailMutation) OldType(ctx context.Context) (v int, err error) {
  26860. if !m.op.Is(OpUpdateOne) {
  26861. return v, errors.New("OldType is only allowed on UpdateOne operations")
  26862. }
  26863. if m.id == nil || m.oldValue == nil {
  26864. return v, errors.New("OldType requires an ID field in the mutation")
  26865. }
  26866. oldValue, err := m.oldValue(ctx)
  26867. if err != nil {
  26868. return v, fmt.Errorf("querying old value for OldType: %w", err)
  26869. }
  26870. return oldValue.Type, nil
  26871. }
  26872. // AddType adds i to the "type" field.
  26873. func (m *UsageDetailMutation) AddType(i int) {
  26874. if m.add_type != nil {
  26875. *m.add_type += i
  26876. } else {
  26877. m.add_type = &i
  26878. }
  26879. }
  26880. // AddedType returns the value that was added to the "type" field in this mutation.
  26881. func (m *UsageDetailMutation) AddedType() (r int, exists bool) {
  26882. v := m.add_type
  26883. if v == nil {
  26884. return
  26885. }
  26886. return *v, true
  26887. }
  26888. // ClearType clears the value of the "type" field.
  26889. func (m *UsageDetailMutation) ClearType() {
  26890. m._type = nil
  26891. m.add_type = nil
  26892. m.clearedFields[usagedetail.FieldType] = struct{}{}
  26893. }
  26894. // TypeCleared returns if the "type" field was cleared in this mutation.
  26895. func (m *UsageDetailMutation) TypeCleared() bool {
  26896. _, ok := m.clearedFields[usagedetail.FieldType]
  26897. return ok
  26898. }
  26899. // ResetType resets all changes to the "type" field.
  26900. func (m *UsageDetailMutation) ResetType() {
  26901. m._type = nil
  26902. m.add_type = nil
  26903. delete(m.clearedFields, usagedetail.FieldType)
  26904. }
  26905. // SetBotID sets the "bot_id" field.
  26906. func (m *UsageDetailMutation) SetBotID(s string) {
  26907. m.bot_id = &s
  26908. }
  26909. // BotID returns the value of the "bot_id" field in the mutation.
  26910. func (m *UsageDetailMutation) BotID() (r string, exists bool) {
  26911. v := m.bot_id
  26912. if v == nil {
  26913. return
  26914. }
  26915. return *v, true
  26916. }
  26917. // OldBotID returns the old "bot_id" field's value of the UsageDetail entity.
  26918. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26919. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26920. func (m *UsageDetailMutation) OldBotID(ctx context.Context) (v string, err error) {
  26921. if !m.op.Is(OpUpdateOne) {
  26922. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  26923. }
  26924. if m.id == nil || m.oldValue == nil {
  26925. return v, errors.New("OldBotID requires an ID field in the mutation")
  26926. }
  26927. oldValue, err := m.oldValue(ctx)
  26928. if err != nil {
  26929. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  26930. }
  26931. return oldValue.BotID, nil
  26932. }
  26933. // ResetBotID resets all changes to the "bot_id" field.
  26934. func (m *UsageDetailMutation) ResetBotID() {
  26935. m.bot_id = nil
  26936. }
  26937. // SetReceiverID sets the "receiver_id" field.
  26938. func (m *UsageDetailMutation) SetReceiverID(s string) {
  26939. m.receiver_id = &s
  26940. }
  26941. // ReceiverID returns the value of the "receiver_id" field in the mutation.
  26942. func (m *UsageDetailMutation) ReceiverID() (r string, exists bool) {
  26943. v := m.receiver_id
  26944. if v == nil {
  26945. return
  26946. }
  26947. return *v, true
  26948. }
  26949. // OldReceiverID returns the old "receiver_id" field's value of the UsageDetail entity.
  26950. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26952. func (m *UsageDetailMutation) OldReceiverID(ctx context.Context) (v string, err error) {
  26953. if !m.op.Is(OpUpdateOne) {
  26954. return v, errors.New("OldReceiverID is only allowed on UpdateOne operations")
  26955. }
  26956. if m.id == nil || m.oldValue == nil {
  26957. return v, errors.New("OldReceiverID requires an ID field in the mutation")
  26958. }
  26959. oldValue, err := m.oldValue(ctx)
  26960. if err != nil {
  26961. return v, fmt.Errorf("querying old value for OldReceiverID: %w", err)
  26962. }
  26963. return oldValue.ReceiverID, nil
  26964. }
  26965. // ResetReceiverID resets all changes to the "receiver_id" field.
  26966. func (m *UsageDetailMutation) ResetReceiverID() {
  26967. m.receiver_id = nil
  26968. }
  26969. // SetApp sets the "app" field.
  26970. func (m *UsageDetailMutation) SetApp(i int) {
  26971. m.app = &i
  26972. m.addapp = nil
  26973. }
  26974. // App returns the value of the "app" field in the mutation.
  26975. func (m *UsageDetailMutation) App() (r int, exists bool) {
  26976. v := m.app
  26977. if v == nil {
  26978. return
  26979. }
  26980. return *v, true
  26981. }
  26982. // OldApp returns the old "app" field's value of the UsageDetail entity.
  26983. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  26984. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  26985. func (m *UsageDetailMutation) OldApp(ctx context.Context) (v int, err error) {
  26986. if !m.op.Is(OpUpdateOne) {
  26987. return v, errors.New("OldApp is only allowed on UpdateOne operations")
  26988. }
  26989. if m.id == nil || m.oldValue == nil {
  26990. return v, errors.New("OldApp requires an ID field in the mutation")
  26991. }
  26992. oldValue, err := m.oldValue(ctx)
  26993. if err != nil {
  26994. return v, fmt.Errorf("querying old value for OldApp: %w", err)
  26995. }
  26996. return oldValue.App, nil
  26997. }
  26998. // AddApp adds i to the "app" field.
  26999. func (m *UsageDetailMutation) AddApp(i int) {
  27000. if m.addapp != nil {
  27001. *m.addapp += i
  27002. } else {
  27003. m.addapp = &i
  27004. }
  27005. }
  27006. // AddedApp returns the value that was added to the "app" field in this mutation.
  27007. func (m *UsageDetailMutation) AddedApp() (r int, exists bool) {
  27008. v := m.addapp
  27009. if v == nil {
  27010. return
  27011. }
  27012. return *v, true
  27013. }
  27014. // ClearApp clears the value of the "app" field.
  27015. func (m *UsageDetailMutation) ClearApp() {
  27016. m.app = nil
  27017. m.addapp = nil
  27018. m.clearedFields[usagedetail.FieldApp] = struct{}{}
  27019. }
  27020. // AppCleared returns if the "app" field was cleared in this mutation.
  27021. func (m *UsageDetailMutation) AppCleared() bool {
  27022. _, ok := m.clearedFields[usagedetail.FieldApp]
  27023. return ok
  27024. }
  27025. // ResetApp resets all changes to the "app" field.
  27026. func (m *UsageDetailMutation) ResetApp() {
  27027. m.app = nil
  27028. m.addapp = nil
  27029. delete(m.clearedFields, usagedetail.FieldApp)
  27030. }
  27031. // SetSessionID sets the "session_id" field.
  27032. func (m *UsageDetailMutation) SetSessionID(u uint64) {
  27033. m.session_id = &u
  27034. m.addsession_id = nil
  27035. }
  27036. // SessionID returns the value of the "session_id" field in the mutation.
  27037. func (m *UsageDetailMutation) SessionID() (r uint64, exists bool) {
  27038. v := m.session_id
  27039. if v == nil {
  27040. return
  27041. }
  27042. return *v, true
  27043. }
  27044. // OldSessionID returns the old "session_id" field's value of the UsageDetail entity.
  27045. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27046. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27047. func (m *UsageDetailMutation) OldSessionID(ctx context.Context) (v uint64, err error) {
  27048. if !m.op.Is(OpUpdateOne) {
  27049. return v, errors.New("OldSessionID is only allowed on UpdateOne operations")
  27050. }
  27051. if m.id == nil || m.oldValue == nil {
  27052. return v, errors.New("OldSessionID requires an ID field in the mutation")
  27053. }
  27054. oldValue, err := m.oldValue(ctx)
  27055. if err != nil {
  27056. return v, fmt.Errorf("querying old value for OldSessionID: %w", err)
  27057. }
  27058. return oldValue.SessionID, nil
  27059. }
  27060. // AddSessionID adds u to the "session_id" field.
  27061. func (m *UsageDetailMutation) AddSessionID(u int64) {
  27062. if m.addsession_id != nil {
  27063. *m.addsession_id += u
  27064. } else {
  27065. m.addsession_id = &u
  27066. }
  27067. }
  27068. // AddedSessionID returns the value that was added to the "session_id" field in this mutation.
  27069. func (m *UsageDetailMutation) AddedSessionID() (r int64, exists bool) {
  27070. v := m.addsession_id
  27071. if v == nil {
  27072. return
  27073. }
  27074. return *v, true
  27075. }
  27076. // ClearSessionID clears the value of the "session_id" field.
  27077. func (m *UsageDetailMutation) ClearSessionID() {
  27078. m.session_id = nil
  27079. m.addsession_id = nil
  27080. m.clearedFields[usagedetail.FieldSessionID] = struct{}{}
  27081. }
  27082. // SessionIDCleared returns if the "session_id" field was cleared in this mutation.
  27083. func (m *UsageDetailMutation) SessionIDCleared() bool {
  27084. _, ok := m.clearedFields[usagedetail.FieldSessionID]
  27085. return ok
  27086. }
  27087. // ResetSessionID resets all changes to the "session_id" field.
  27088. func (m *UsageDetailMutation) ResetSessionID() {
  27089. m.session_id = nil
  27090. m.addsession_id = nil
  27091. delete(m.clearedFields, usagedetail.FieldSessionID)
  27092. }
  27093. // SetRequest sets the "request" field.
  27094. func (m *UsageDetailMutation) SetRequest(s string) {
  27095. m.request = &s
  27096. }
  27097. // Request returns the value of the "request" field in the mutation.
  27098. func (m *UsageDetailMutation) Request() (r string, exists bool) {
  27099. v := m.request
  27100. if v == nil {
  27101. return
  27102. }
  27103. return *v, true
  27104. }
  27105. // OldRequest returns the old "request" field's value of the UsageDetail entity.
  27106. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27107. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27108. func (m *UsageDetailMutation) OldRequest(ctx context.Context) (v string, err error) {
  27109. if !m.op.Is(OpUpdateOne) {
  27110. return v, errors.New("OldRequest is only allowed on UpdateOne operations")
  27111. }
  27112. if m.id == nil || m.oldValue == nil {
  27113. return v, errors.New("OldRequest requires an ID field in the mutation")
  27114. }
  27115. oldValue, err := m.oldValue(ctx)
  27116. if err != nil {
  27117. return v, fmt.Errorf("querying old value for OldRequest: %w", err)
  27118. }
  27119. return oldValue.Request, nil
  27120. }
  27121. // ResetRequest resets all changes to the "request" field.
  27122. func (m *UsageDetailMutation) ResetRequest() {
  27123. m.request = nil
  27124. }
  27125. // SetResponse sets the "response" field.
  27126. func (m *UsageDetailMutation) SetResponse(s string) {
  27127. m.response = &s
  27128. }
  27129. // Response returns the value of the "response" field in the mutation.
  27130. func (m *UsageDetailMutation) Response() (r string, exists bool) {
  27131. v := m.response
  27132. if v == nil {
  27133. return
  27134. }
  27135. return *v, true
  27136. }
  27137. // OldResponse returns the old "response" field's value of the UsageDetail entity.
  27138. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27139. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27140. func (m *UsageDetailMutation) OldResponse(ctx context.Context) (v string, err error) {
  27141. if !m.op.Is(OpUpdateOne) {
  27142. return v, errors.New("OldResponse is only allowed on UpdateOne operations")
  27143. }
  27144. if m.id == nil || m.oldValue == nil {
  27145. return v, errors.New("OldResponse requires an ID field in the mutation")
  27146. }
  27147. oldValue, err := m.oldValue(ctx)
  27148. if err != nil {
  27149. return v, fmt.Errorf("querying old value for OldResponse: %w", err)
  27150. }
  27151. return oldValue.Response, nil
  27152. }
  27153. // ResetResponse resets all changes to the "response" field.
  27154. func (m *UsageDetailMutation) ResetResponse() {
  27155. m.response = nil
  27156. }
  27157. // SetOriginalData sets the "original_data" field.
  27158. func (m *UsageDetailMutation) SetOriginalData(ctd custom_types.OriginalData) {
  27159. m.original_data = &ctd
  27160. }
  27161. // OriginalData returns the value of the "original_data" field in the mutation.
  27162. func (m *UsageDetailMutation) OriginalData() (r custom_types.OriginalData, exists bool) {
  27163. v := m.original_data
  27164. if v == nil {
  27165. return
  27166. }
  27167. return *v, true
  27168. }
  27169. // OldOriginalData returns the old "original_data" field's value of the UsageDetail entity.
  27170. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27171. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27172. func (m *UsageDetailMutation) OldOriginalData(ctx context.Context) (v custom_types.OriginalData, err error) {
  27173. if !m.op.Is(OpUpdateOne) {
  27174. return v, errors.New("OldOriginalData is only allowed on UpdateOne operations")
  27175. }
  27176. if m.id == nil || m.oldValue == nil {
  27177. return v, errors.New("OldOriginalData requires an ID field in the mutation")
  27178. }
  27179. oldValue, err := m.oldValue(ctx)
  27180. if err != nil {
  27181. return v, fmt.Errorf("querying old value for OldOriginalData: %w", err)
  27182. }
  27183. return oldValue.OriginalData, nil
  27184. }
  27185. // ResetOriginalData resets all changes to the "original_data" field.
  27186. func (m *UsageDetailMutation) ResetOriginalData() {
  27187. m.original_data = nil
  27188. }
  27189. // SetTotalTokens sets the "total_tokens" field.
  27190. func (m *UsageDetailMutation) SetTotalTokens(u uint64) {
  27191. m.total_tokens = &u
  27192. m.addtotal_tokens = nil
  27193. }
  27194. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  27195. func (m *UsageDetailMutation) TotalTokens() (r uint64, exists bool) {
  27196. v := m.total_tokens
  27197. if v == nil {
  27198. return
  27199. }
  27200. return *v, true
  27201. }
  27202. // OldTotalTokens returns the old "total_tokens" field's value of the UsageDetail entity.
  27203. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27204. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27205. func (m *UsageDetailMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  27206. if !m.op.Is(OpUpdateOne) {
  27207. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  27208. }
  27209. if m.id == nil || m.oldValue == nil {
  27210. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  27211. }
  27212. oldValue, err := m.oldValue(ctx)
  27213. if err != nil {
  27214. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  27215. }
  27216. return oldValue.TotalTokens, nil
  27217. }
  27218. // AddTotalTokens adds u to the "total_tokens" field.
  27219. func (m *UsageDetailMutation) AddTotalTokens(u int64) {
  27220. if m.addtotal_tokens != nil {
  27221. *m.addtotal_tokens += u
  27222. } else {
  27223. m.addtotal_tokens = &u
  27224. }
  27225. }
  27226. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  27227. func (m *UsageDetailMutation) AddedTotalTokens() (r int64, exists bool) {
  27228. v := m.addtotal_tokens
  27229. if v == nil {
  27230. return
  27231. }
  27232. return *v, true
  27233. }
  27234. // ClearTotalTokens clears the value of the "total_tokens" field.
  27235. func (m *UsageDetailMutation) ClearTotalTokens() {
  27236. m.total_tokens = nil
  27237. m.addtotal_tokens = nil
  27238. m.clearedFields[usagedetail.FieldTotalTokens] = struct{}{}
  27239. }
  27240. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  27241. func (m *UsageDetailMutation) TotalTokensCleared() bool {
  27242. _, ok := m.clearedFields[usagedetail.FieldTotalTokens]
  27243. return ok
  27244. }
  27245. // ResetTotalTokens resets all changes to the "total_tokens" field.
  27246. func (m *UsageDetailMutation) ResetTotalTokens() {
  27247. m.total_tokens = nil
  27248. m.addtotal_tokens = nil
  27249. delete(m.clearedFields, usagedetail.FieldTotalTokens)
  27250. }
  27251. // SetPromptTokens sets the "prompt_tokens" field.
  27252. func (m *UsageDetailMutation) SetPromptTokens(u uint64) {
  27253. m.prompt_tokens = &u
  27254. m.addprompt_tokens = nil
  27255. }
  27256. // PromptTokens returns the value of the "prompt_tokens" field in the mutation.
  27257. func (m *UsageDetailMutation) PromptTokens() (r uint64, exists bool) {
  27258. v := m.prompt_tokens
  27259. if v == nil {
  27260. return
  27261. }
  27262. return *v, true
  27263. }
  27264. // OldPromptTokens returns the old "prompt_tokens" field's value of the UsageDetail entity.
  27265. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27267. func (m *UsageDetailMutation) OldPromptTokens(ctx context.Context) (v uint64, err error) {
  27268. if !m.op.Is(OpUpdateOne) {
  27269. return v, errors.New("OldPromptTokens is only allowed on UpdateOne operations")
  27270. }
  27271. if m.id == nil || m.oldValue == nil {
  27272. return v, errors.New("OldPromptTokens requires an ID field in the mutation")
  27273. }
  27274. oldValue, err := m.oldValue(ctx)
  27275. if err != nil {
  27276. return v, fmt.Errorf("querying old value for OldPromptTokens: %w", err)
  27277. }
  27278. return oldValue.PromptTokens, nil
  27279. }
  27280. // AddPromptTokens adds u to the "prompt_tokens" field.
  27281. func (m *UsageDetailMutation) AddPromptTokens(u int64) {
  27282. if m.addprompt_tokens != nil {
  27283. *m.addprompt_tokens += u
  27284. } else {
  27285. m.addprompt_tokens = &u
  27286. }
  27287. }
  27288. // AddedPromptTokens returns the value that was added to the "prompt_tokens" field in this mutation.
  27289. func (m *UsageDetailMutation) AddedPromptTokens() (r int64, exists bool) {
  27290. v := m.addprompt_tokens
  27291. if v == nil {
  27292. return
  27293. }
  27294. return *v, true
  27295. }
  27296. // ClearPromptTokens clears the value of the "prompt_tokens" field.
  27297. func (m *UsageDetailMutation) ClearPromptTokens() {
  27298. m.prompt_tokens = nil
  27299. m.addprompt_tokens = nil
  27300. m.clearedFields[usagedetail.FieldPromptTokens] = struct{}{}
  27301. }
  27302. // PromptTokensCleared returns if the "prompt_tokens" field was cleared in this mutation.
  27303. func (m *UsageDetailMutation) PromptTokensCleared() bool {
  27304. _, ok := m.clearedFields[usagedetail.FieldPromptTokens]
  27305. return ok
  27306. }
  27307. // ResetPromptTokens resets all changes to the "prompt_tokens" field.
  27308. func (m *UsageDetailMutation) ResetPromptTokens() {
  27309. m.prompt_tokens = nil
  27310. m.addprompt_tokens = nil
  27311. delete(m.clearedFields, usagedetail.FieldPromptTokens)
  27312. }
  27313. // SetCompletionTokens sets the "completion_tokens" field.
  27314. func (m *UsageDetailMutation) SetCompletionTokens(u uint64) {
  27315. m.completion_tokens = &u
  27316. m.addcompletion_tokens = nil
  27317. }
  27318. // CompletionTokens returns the value of the "completion_tokens" field in the mutation.
  27319. func (m *UsageDetailMutation) CompletionTokens() (r uint64, exists bool) {
  27320. v := m.completion_tokens
  27321. if v == nil {
  27322. return
  27323. }
  27324. return *v, true
  27325. }
  27326. // OldCompletionTokens returns the old "completion_tokens" field's value of the UsageDetail entity.
  27327. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27328. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27329. func (m *UsageDetailMutation) OldCompletionTokens(ctx context.Context) (v uint64, err error) {
  27330. if !m.op.Is(OpUpdateOne) {
  27331. return v, errors.New("OldCompletionTokens is only allowed on UpdateOne operations")
  27332. }
  27333. if m.id == nil || m.oldValue == nil {
  27334. return v, errors.New("OldCompletionTokens requires an ID field in the mutation")
  27335. }
  27336. oldValue, err := m.oldValue(ctx)
  27337. if err != nil {
  27338. return v, fmt.Errorf("querying old value for OldCompletionTokens: %w", err)
  27339. }
  27340. return oldValue.CompletionTokens, nil
  27341. }
  27342. // AddCompletionTokens adds u to the "completion_tokens" field.
  27343. func (m *UsageDetailMutation) AddCompletionTokens(u int64) {
  27344. if m.addcompletion_tokens != nil {
  27345. *m.addcompletion_tokens += u
  27346. } else {
  27347. m.addcompletion_tokens = &u
  27348. }
  27349. }
  27350. // AddedCompletionTokens returns the value that was added to the "completion_tokens" field in this mutation.
  27351. func (m *UsageDetailMutation) AddedCompletionTokens() (r int64, exists bool) {
  27352. v := m.addcompletion_tokens
  27353. if v == nil {
  27354. return
  27355. }
  27356. return *v, true
  27357. }
  27358. // ClearCompletionTokens clears the value of the "completion_tokens" field.
  27359. func (m *UsageDetailMutation) ClearCompletionTokens() {
  27360. m.completion_tokens = nil
  27361. m.addcompletion_tokens = nil
  27362. m.clearedFields[usagedetail.FieldCompletionTokens] = struct{}{}
  27363. }
  27364. // CompletionTokensCleared returns if the "completion_tokens" field was cleared in this mutation.
  27365. func (m *UsageDetailMutation) CompletionTokensCleared() bool {
  27366. _, ok := m.clearedFields[usagedetail.FieldCompletionTokens]
  27367. return ok
  27368. }
  27369. // ResetCompletionTokens resets all changes to the "completion_tokens" field.
  27370. func (m *UsageDetailMutation) ResetCompletionTokens() {
  27371. m.completion_tokens = nil
  27372. m.addcompletion_tokens = nil
  27373. delete(m.clearedFields, usagedetail.FieldCompletionTokens)
  27374. }
  27375. // SetOrganizationID sets the "organization_id" field.
  27376. func (m *UsageDetailMutation) SetOrganizationID(u uint64) {
  27377. m.organization_id = &u
  27378. m.addorganization_id = nil
  27379. }
  27380. // OrganizationID returns the value of the "organization_id" field in the mutation.
  27381. func (m *UsageDetailMutation) OrganizationID() (r uint64, exists bool) {
  27382. v := m.organization_id
  27383. if v == nil {
  27384. return
  27385. }
  27386. return *v, true
  27387. }
  27388. // OldOrganizationID returns the old "organization_id" field's value of the UsageDetail entity.
  27389. // If the UsageDetail object wasn't provided to the builder, the object is fetched from the database.
  27390. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  27391. func (m *UsageDetailMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  27392. if !m.op.Is(OpUpdateOne) {
  27393. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  27394. }
  27395. if m.id == nil || m.oldValue == nil {
  27396. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  27397. }
  27398. oldValue, err := m.oldValue(ctx)
  27399. if err != nil {
  27400. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  27401. }
  27402. return oldValue.OrganizationID, nil
  27403. }
  27404. // AddOrganizationID adds u to the "organization_id" field.
  27405. func (m *UsageDetailMutation) AddOrganizationID(u int64) {
  27406. if m.addorganization_id != nil {
  27407. *m.addorganization_id += u
  27408. } else {
  27409. m.addorganization_id = &u
  27410. }
  27411. }
  27412. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  27413. func (m *UsageDetailMutation) AddedOrganizationID() (r int64, exists bool) {
  27414. v := m.addorganization_id
  27415. if v == nil {
  27416. return
  27417. }
  27418. return *v, true
  27419. }
  27420. // ClearOrganizationID clears the value of the "organization_id" field.
  27421. func (m *UsageDetailMutation) ClearOrganizationID() {
  27422. m.organization_id = nil
  27423. m.addorganization_id = nil
  27424. m.clearedFields[usagedetail.FieldOrganizationID] = struct{}{}
  27425. }
  27426. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  27427. func (m *UsageDetailMutation) OrganizationIDCleared() bool {
  27428. _, ok := m.clearedFields[usagedetail.FieldOrganizationID]
  27429. return ok
  27430. }
  27431. // ResetOrganizationID resets all changes to the "organization_id" field.
  27432. func (m *UsageDetailMutation) ResetOrganizationID() {
  27433. m.organization_id = nil
  27434. m.addorganization_id = nil
  27435. delete(m.clearedFields, usagedetail.FieldOrganizationID)
  27436. }
  27437. // Where appends a list predicates to the UsageDetailMutation builder.
  27438. func (m *UsageDetailMutation) Where(ps ...predicate.UsageDetail) {
  27439. m.predicates = append(m.predicates, ps...)
  27440. }
  27441. // WhereP appends storage-level predicates to the UsageDetailMutation builder. Using this method,
  27442. // users can use type-assertion to append predicates that do not depend on any generated package.
  27443. func (m *UsageDetailMutation) WhereP(ps ...func(*sql.Selector)) {
  27444. p := make([]predicate.UsageDetail, len(ps))
  27445. for i := range ps {
  27446. p[i] = ps[i]
  27447. }
  27448. m.Where(p...)
  27449. }
  27450. // Op returns the operation name.
  27451. func (m *UsageDetailMutation) Op() Op {
  27452. return m.op
  27453. }
  27454. // SetOp allows setting the mutation operation.
  27455. func (m *UsageDetailMutation) SetOp(op Op) {
  27456. m.op = op
  27457. }
  27458. // Type returns the node type of this mutation (UsageDetail).
  27459. func (m *UsageDetailMutation) Type() string {
  27460. return m.typ
  27461. }
  27462. // Fields returns all fields that were changed during this mutation. Note that in
  27463. // order to get all numeric fields that were incremented/decremented, call
  27464. // AddedFields().
  27465. func (m *UsageDetailMutation) Fields() []string {
  27466. fields := make([]string, 0, 15)
  27467. if m.created_at != nil {
  27468. fields = append(fields, usagedetail.FieldCreatedAt)
  27469. }
  27470. if m.updated_at != nil {
  27471. fields = append(fields, usagedetail.FieldUpdatedAt)
  27472. }
  27473. if m.status != nil {
  27474. fields = append(fields, usagedetail.FieldStatus)
  27475. }
  27476. if m._type != nil {
  27477. fields = append(fields, usagedetail.FieldType)
  27478. }
  27479. if m.bot_id != nil {
  27480. fields = append(fields, usagedetail.FieldBotID)
  27481. }
  27482. if m.receiver_id != nil {
  27483. fields = append(fields, usagedetail.FieldReceiverID)
  27484. }
  27485. if m.app != nil {
  27486. fields = append(fields, usagedetail.FieldApp)
  27487. }
  27488. if m.session_id != nil {
  27489. fields = append(fields, usagedetail.FieldSessionID)
  27490. }
  27491. if m.request != nil {
  27492. fields = append(fields, usagedetail.FieldRequest)
  27493. }
  27494. if m.response != nil {
  27495. fields = append(fields, usagedetail.FieldResponse)
  27496. }
  27497. if m.original_data != nil {
  27498. fields = append(fields, usagedetail.FieldOriginalData)
  27499. }
  27500. if m.total_tokens != nil {
  27501. fields = append(fields, usagedetail.FieldTotalTokens)
  27502. }
  27503. if m.prompt_tokens != nil {
  27504. fields = append(fields, usagedetail.FieldPromptTokens)
  27505. }
  27506. if m.completion_tokens != nil {
  27507. fields = append(fields, usagedetail.FieldCompletionTokens)
  27508. }
  27509. if m.organization_id != nil {
  27510. fields = append(fields, usagedetail.FieldOrganizationID)
  27511. }
  27512. return fields
  27513. }
  27514. // Field returns the value of a field with the given name. The second boolean
  27515. // return value indicates that this field was not set, or was not defined in the
  27516. // schema.
  27517. func (m *UsageDetailMutation) Field(name string) (ent.Value, bool) {
  27518. switch name {
  27519. case usagedetail.FieldCreatedAt:
  27520. return m.CreatedAt()
  27521. case usagedetail.FieldUpdatedAt:
  27522. return m.UpdatedAt()
  27523. case usagedetail.FieldStatus:
  27524. return m.Status()
  27525. case usagedetail.FieldType:
  27526. return m.GetType()
  27527. case usagedetail.FieldBotID:
  27528. return m.BotID()
  27529. case usagedetail.FieldReceiverID:
  27530. return m.ReceiverID()
  27531. case usagedetail.FieldApp:
  27532. return m.App()
  27533. case usagedetail.FieldSessionID:
  27534. return m.SessionID()
  27535. case usagedetail.FieldRequest:
  27536. return m.Request()
  27537. case usagedetail.FieldResponse:
  27538. return m.Response()
  27539. case usagedetail.FieldOriginalData:
  27540. return m.OriginalData()
  27541. case usagedetail.FieldTotalTokens:
  27542. return m.TotalTokens()
  27543. case usagedetail.FieldPromptTokens:
  27544. return m.PromptTokens()
  27545. case usagedetail.FieldCompletionTokens:
  27546. return m.CompletionTokens()
  27547. case usagedetail.FieldOrganizationID:
  27548. return m.OrganizationID()
  27549. }
  27550. return nil, false
  27551. }
  27552. // OldField returns the old value of the field from the database. An error is
  27553. // returned if the mutation operation is not UpdateOne, or the query to the
  27554. // database failed.
  27555. func (m *UsageDetailMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  27556. switch name {
  27557. case usagedetail.FieldCreatedAt:
  27558. return m.OldCreatedAt(ctx)
  27559. case usagedetail.FieldUpdatedAt:
  27560. return m.OldUpdatedAt(ctx)
  27561. case usagedetail.FieldStatus:
  27562. return m.OldStatus(ctx)
  27563. case usagedetail.FieldType:
  27564. return m.OldType(ctx)
  27565. case usagedetail.FieldBotID:
  27566. return m.OldBotID(ctx)
  27567. case usagedetail.FieldReceiverID:
  27568. return m.OldReceiverID(ctx)
  27569. case usagedetail.FieldApp:
  27570. return m.OldApp(ctx)
  27571. case usagedetail.FieldSessionID:
  27572. return m.OldSessionID(ctx)
  27573. case usagedetail.FieldRequest:
  27574. return m.OldRequest(ctx)
  27575. case usagedetail.FieldResponse:
  27576. return m.OldResponse(ctx)
  27577. case usagedetail.FieldOriginalData:
  27578. return m.OldOriginalData(ctx)
  27579. case usagedetail.FieldTotalTokens:
  27580. return m.OldTotalTokens(ctx)
  27581. case usagedetail.FieldPromptTokens:
  27582. return m.OldPromptTokens(ctx)
  27583. case usagedetail.FieldCompletionTokens:
  27584. return m.OldCompletionTokens(ctx)
  27585. case usagedetail.FieldOrganizationID:
  27586. return m.OldOrganizationID(ctx)
  27587. }
  27588. return nil, fmt.Errorf("unknown UsageDetail field %s", name)
  27589. }
  27590. // SetField sets the value of a field with the given name. It returns an error if
  27591. // the field is not defined in the schema, or if the type mismatched the field
  27592. // type.
  27593. func (m *UsageDetailMutation) SetField(name string, value ent.Value) error {
  27594. switch name {
  27595. case usagedetail.FieldCreatedAt:
  27596. v, ok := value.(time.Time)
  27597. if !ok {
  27598. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27599. }
  27600. m.SetCreatedAt(v)
  27601. return nil
  27602. case usagedetail.FieldUpdatedAt:
  27603. v, ok := value.(time.Time)
  27604. if !ok {
  27605. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27606. }
  27607. m.SetUpdatedAt(v)
  27608. return nil
  27609. case usagedetail.FieldStatus:
  27610. v, ok := value.(uint8)
  27611. if !ok {
  27612. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27613. }
  27614. m.SetStatus(v)
  27615. return nil
  27616. case usagedetail.FieldType:
  27617. v, ok := value.(int)
  27618. if !ok {
  27619. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27620. }
  27621. m.SetType(v)
  27622. return nil
  27623. case usagedetail.FieldBotID:
  27624. v, ok := value.(string)
  27625. if !ok {
  27626. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27627. }
  27628. m.SetBotID(v)
  27629. return nil
  27630. case usagedetail.FieldReceiverID:
  27631. v, ok := value.(string)
  27632. if !ok {
  27633. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27634. }
  27635. m.SetReceiverID(v)
  27636. return nil
  27637. case usagedetail.FieldApp:
  27638. v, ok := value.(int)
  27639. if !ok {
  27640. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27641. }
  27642. m.SetApp(v)
  27643. return nil
  27644. case usagedetail.FieldSessionID:
  27645. v, ok := value.(uint64)
  27646. if !ok {
  27647. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27648. }
  27649. m.SetSessionID(v)
  27650. return nil
  27651. case usagedetail.FieldRequest:
  27652. v, ok := value.(string)
  27653. if !ok {
  27654. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27655. }
  27656. m.SetRequest(v)
  27657. return nil
  27658. case usagedetail.FieldResponse:
  27659. v, ok := value.(string)
  27660. if !ok {
  27661. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27662. }
  27663. m.SetResponse(v)
  27664. return nil
  27665. case usagedetail.FieldOriginalData:
  27666. v, ok := value.(custom_types.OriginalData)
  27667. if !ok {
  27668. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27669. }
  27670. m.SetOriginalData(v)
  27671. return nil
  27672. case usagedetail.FieldTotalTokens:
  27673. v, ok := value.(uint64)
  27674. if !ok {
  27675. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27676. }
  27677. m.SetTotalTokens(v)
  27678. return nil
  27679. case usagedetail.FieldPromptTokens:
  27680. v, ok := value.(uint64)
  27681. if !ok {
  27682. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27683. }
  27684. m.SetPromptTokens(v)
  27685. return nil
  27686. case usagedetail.FieldCompletionTokens:
  27687. v, ok := value.(uint64)
  27688. if !ok {
  27689. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27690. }
  27691. m.SetCompletionTokens(v)
  27692. return nil
  27693. case usagedetail.FieldOrganizationID:
  27694. v, ok := value.(uint64)
  27695. if !ok {
  27696. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27697. }
  27698. m.SetOrganizationID(v)
  27699. return nil
  27700. }
  27701. return fmt.Errorf("unknown UsageDetail field %s", name)
  27702. }
  27703. // AddedFields returns all numeric fields that were incremented/decremented during
  27704. // this mutation.
  27705. func (m *UsageDetailMutation) AddedFields() []string {
  27706. var fields []string
  27707. if m.addstatus != nil {
  27708. fields = append(fields, usagedetail.FieldStatus)
  27709. }
  27710. if m.add_type != nil {
  27711. fields = append(fields, usagedetail.FieldType)
  27712. }
  27713. if m.addapp != nil {
  27714. fields = append(fields, usagedetail.FieldApp)
  27715. }
  27716. if m.addsession_id != nil {
  27717. fields = append(fields, usagedetail.FieldSessionID)
  27718. }
  27719. if m.addtotal_tokens != nil {
  27720. fields = append(fields, usagedetail.FieldTotalTokens)
  27721. }
  27722. if m.addprompt_tokens != nil {
  27723. fields = append(fields, usagedetail.FieldPromptTokens)
  27724. }
  27725. if m.addcompletion_tokens != nil {
  27726. fields = append(fields, usagedetail.FieldCompletionTokens)
  27727. }
  27728. if m.addorganization_id != nil {
  27729. fields = append(fields, usagedetail.FieldOrganizationID)
  27730. }
  27731. return fields
  27732. }
  27733. // AddedField returns the numeric value that was incremented/decremented on a field
  27734. // with the given name. The second boolean return value indicates that this field
  27735. // was not set, or was not defined in the schema.
  27736. func (m *UsageDetailMutation) AddedField(name string) (ent.Value, bool) {
  27737. switch name {
  27738. case usagedetail.FieldStatus:
  27739. return m.AddedStatus()
  27740. case usagedetail.FieldType:
  27741. return m.AddedType()
  27742. case usagedetail.FieldApp:
  27743. return m.AddedApp()
  27744. case usagedetail.FieldSessionID:
  27745. return m.AddedSessionID()
  27746. case usagedetail.FieldTotalTokens:
  27747. return m.AddedTotalTokens()
  27748. case usagedetail.FieldPromptTokens:
  27749. return m.AddedPromptTokens()
  27750. case usagedetail.FieldCompletionTokens:
  27751. return m.AddedCompletionTokens()
  27752. case usagedetail.FieldOrganizationID:
  27753. return m.AddedOrganizationID()
  27754. }
  27755. return nil, false
  27756. }
  27757. // AddField adds the value to the field with the given name. It returns an error if
  27758. // the field is not defined in the schema, or if the type mismatched the field
  27759. // type.
  27760. func (m *UsageDetailMutation) AddField(name string, value ent.Value) error {
  27761. switch name {
  27762. case usagedetail.FieldStatus:
  27763. v, ok := value.(int8)
  27764. if !ok {
  27765. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27766. }
  27767. m.AddStatus(v)
  27768. return nil
  27769. case usagedetail.FieldType:
  27770. v, ok := value.(int)
  27771. if !ok {
  27772. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27773. }
  27774. m.AddType(v)
  27775. return nil
  27776. case usagedetail.FieldApp:
  27777. v, ok := value.(int)
  27778. if !ok {
  27779. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27780. }
  27781. m.AddApp(v)
  27782. return nil
  27783. case usagedetail.FieldSessionID:
  27784. v, ok := value.(int64)
  27785. if !ok {
  27786. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27787. }
  27788. m.AddSessionID(v)
  27789. return nil
  27790. case usagedetail.FieldTotalTokens:
  27791. v, ok := value.(int64)
  27792. if !ok {
  27793. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27794. }
  27795. m.AddTotalTokens(v)
  27796. return nil
  27797. case usagedetail.FieldPromptTokens:
  27798. v, ok := value.(int64)
  27799. if !ok {
  27800. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27801. }
  27802. m.AddPromptTokens(v)
  27803. return nil
  27804. case usagedetail.FieldCompletionTokens:
  27805. v, ok := value.(int64)
  27806. if !ok {
  27807. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27808. }
  27809. m.AddCompletionTokens(v)
  27810. return nil
  27811. case usagedetail.FieldOrganizationID:
  27812. v, ok := value.(int64)
  27813. if !ok {
  27814. return fmt.Errorf("unexpected type %T for field %s", value, name)
  27815. }
  27816. m.AddOrganizationID(v)
  27817. return nil
  27818. }
  27819. return fmt.Errorf("unknown UsageDetail numeric field %s", name)
  27820. }
  27821. // ClearedFields returns all nullable fields that were cleared during this
  27822. // mutation.
  27823. func (m *UsageDetailMutation) ClearedFields() []string {
  27824. var fields []string
  27825. if m.FieldCleared(usagedetail.FieldStatus) {
  27826. fields = append(fields, usagedetail.FieldStatus)
  27827. }
  27828. if m.FieldCleared(usagedetail.FieldType) {
  27829. fields = append(fields, usagedetail.FieldType)
  27830. }
  27831. if m.FieldCleared(usagedetail.FieldApp) {
  27832. fields = append(fields, usagedetail.FieldApp)
  27833. }
  27834. if m.FieldCleared(usagedetail.FieldSessionID) {
  27835. fields = append(fields, usagedetail.FieldSessionID)
  27836. }
  27837. if m.FieldCleared(usagedetail.FieldTotalTokens) {
  27838. fields = append(fields, usagedetail.FieldTotalTokens)
  27839. }
  27840. if m.FieldCleared(usagedetail.FieldPromptTokens) {
  27841. fields = append(fields, usagedetail.FieldPromptTokens)
  27842. }
  27843. if m.FieldCleared(usagedetail.FieldCompletionTokens) {
  27844. fields = append(fields, usagedetail.FieldCompletionTokens)
  27845. }
  27846. if m.FieldCleared(usagedetail.FieldOrganizationID) {
  27847. fields = append(fields, usagedetail.FieldOrganizationID)
  27848. }
  27849. return fields
  27850. }
  27851. // FieldCleared returns a boolean indicating if a field with the given name was
  27852. // cleared in this mutation.
  27853. func (m *UsageDetailMutation) FieldCleared(name string) bool {
  27854. _, ok := m.clearedFields[name]
  27855. return ok
  27856. }
  27857. // ClearField clears the value of the field with the given name. It returns an
  27858. // error if the field is not defined in the schema.
  27859. func (m *UsageDetailMutation) ClearField(name string) error {
  27860. switch name {
  27861. case usagedetail.FieldStatus:
  27862. m.ClearStatus()
  27863. return nil
  27864. case usagedetail.FieldType:
  27865. m.ClearType()
  27866. return nil
  27867. case usagedetail.FieldApp:
  27868. m.ClearApp()
  27869. return nil
  27870. case usagedetail.FieldSessionID:
  27871. m.ClearSessionID()
  27872. return nil
  27873. case usagedetail.FieldTotalTokens:
  27874. m.ClearTotalTokens()
  27875. return nil
  27876. case usagedetail.FieldPromptTokens:
  27877. m.ClearPromptTokens()
  27878. return nil
  27879. case usagedetail.FieldCompletionTokens:
  27880. m.ClearCompletionTokens()
  27881. return nil
  27882. case usagedetail.FieldOrganizationID:
  27883. m.ClearOrganizationID()
  27884. return nil
  27885. }
  27886. return fmt.Errorf("unknown UsageDetail nullable field %s", name)
  27887. }
  27888. // ResetField resets all changes in the mutation for the field with the given name.
  27889. // It returns an error if the field is not defined in the schema.
  27890. func (m *UsageDetailMutation) ResetField(name string) error {
  27891. switch name {
  27892. case usagedetail.FieldCreatedAt:
  27893. m.ResetCreatedAt()
  27894. return nil
  27895. case usagedetail.FieldUpdatedAt:
  27896. m.ResetUpdatedAt()
  27897. return nil
  27898. case usagedetail.FieldStatus:
  27899. m.ResetStatus()
  27900. return nil
  27901. case usagedetail.FieldType:
  27902. m.ResetType()
  27903. return nil
  27904. case usagedetail.FieldBotID:
  27905. m.ResetBotID()
  27906. return nil
  27907. case usagedetail.FieldReceiverID:
  27908. m.ResetReceiverID()
  27909. return nil
  27910. case usagedetail.FieldApp:
  27911. m.ResetApp()
  27912. return nil
  27913. case usagedetail.FieldSessionID:
  27914. m.ResetSessionID()
  27915. return nil
  27916. case usagedetail.FieldRequest:
  27917. m.ResetRequest()
  27918. return nil
  27919. case usagedetail.FieldResponse:
  27920. m.ResetResponse()
  27921. return nil
  27922. case usagedetail.FieldOriginalData:
  27923. m.ResetOriginalData()
  27924. return nil
  27925. case usagedetail.FieldTotalTokens:
  27926. m.ResetTotalTokens()
  27927. return nil
  27928. case usagedetail.FieldPromptTokens:
  27929. m.ResetPromptTokens()
  27930. return nil
  27931. case usagedetail.FieldCompletionTokens:
  27932. m.ResetCompletionTokens()
  27933. return nil
  27934. case usagedetail.FieldOrganizationID:
  27935. m.ResetOrganizationID()
  27936. return nil
  27937. }
  27938. return fmt.Errorf("unknown UsageDetail field %s", name)
  27939. }
  27940. // AddedEdges returns all edge names that were set/added in this mutation.
  27941. func (m *UsageDetailMutation) AddedEdges() []string {
  27942. edges := make([]string, 0, 0)
  27943. return edges
  27944. }
  27945. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  27946. // name in this mutation.
  27947. func (m *UsageDetailMutation) AddedIDs(name string) []ent.Value {
  27948. return nil
  27949. }
  27950. // RemovedEdges returns all edge names that were removed in this mutation.
  27951. func (m *UsageDetailMutation) RemovedEdges() []string {
  27952. edges := make([]string, 0, 0)
  27953. return edges
  27954. }
  27955. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  27956. // the given name in this mutation.
  27957. func (m *UsageDetailMutation) RemovedIDs(name string) []ent.Value {
  27958. return nil
  27959. }
  27960. // ClearedEdges returns all edge names that were cleared in this mutation.
  27961. func (m *UsageDetailMutation) ClearedEdges() []string {
  27962. edges := make([]string, 0, 0)
  27963. return edges
  27964. }
  27965. // EdgeCleared returns a boolean which indicates if the edge with the given name
  27966. // was cleared in this mutation.
  27967. func (m *UsageDetailMutation) EdgeCleared(name string) bool {
  27968. return false
  27969. }
  27970. // ClearEdge clears the value of the edge with the given name. It returns an error
  27971. // if that edge is not defined in the schema.
  27972. func (m *UsageDetailMutation) ClearEdge(name string) error {
  27973. return fmt.Errorf("unknown UsageDetail unique edge %s", name)
  27974. }
  27975. // ResetEdge resets all changes to the edge with the given name in this mutation.
  27976. // It returns an error if the edge is not defined in the schema.
  27977. func (m *UsageDetailMutation) ResetEdge(name string) error {
  27978. return fmt.Errorf("unknown UsageDetail edge %s", name)
  27979. }
  27980. // UsageStatisticDayMutation represents an operation that mutates the UsageStatisticDay nodes in the graph.
  27981. type UsageStatisticDayMutation struct {
  27982. config
  27983. op Op
  27984. typ string
  27985. id *uint64
  27986. created_at *time.Time
  27987. updated_at *time.Time
  27988. status *uint8
  27989. addstatus *int8
  27990. deleted_at *time.Time
  27991. addtime *uint64
  27992. addaddtime *int64
  27993. _type *int
  27994. add_type *int
  27995. bot_id *string
  27996. organization_id *uint64
  27997. addorganization_id *int64
  27998. ai_response *uint64
  27999. addai_response *int64
  28000. sop_run *uint64
  28001. addsop_run *int64
  28002. total_friend *uint64
  28003. addtotal_friend *int64
  28004. total_group *uint64
  28005. addtotal_group *int64
  28006. account_balance *uint64
  28007. addaccount_balance *int64
  28008. consume_token *uint64
  28009. addconsume_token *int64
  28010. active_user *uint64
  28011. addactive_user *int64
  28012. new_user *int64
  28013. addnew_user *int64
  28014. label_dist *[]custom_types.LabelDist
  28015. appendlabel_dist []custom_types.LabelDist
  28016. clearedFields map[string]struct{}
  28017. done bool
  28018. oldValue func(context.Context) (*UsageStatisticDay, error)
  28019. predicates []predicate.UsageStatisticDay
  28020. }
  28021. var _ ent.Mutation = (*UsageStatisticDayMutation)(nil)
  28022. // usagestatisticdayOption allows management of the mutation configuration using functional options.
  28023. type usagestatisticdayOption func(*UsageStatisticDayMutation)
  28024. // newUsageStatisticDayMutation creates new mutation for the UsageStatisticDay entity.
  28025. func newUsageStatisticDayMutation(c config, op Op, opts ...usagestatisticdayOption) *UsageStatisticDayMutation {
  28026. m := &UsageStatisticDayMutation{
  28027. config: c,
  28028. op: op,
  28029. typ: TypeUsageStatisticDay,
  28030. clearedFields: make(map[string]struct{}),
  28031. }
  28032. for _, opt := range opts {
  28033. opt(m)
  28034. }
  28035. return m
  28036. }
  28037. // withUsageStatisticDayID sets the ID field of the mutation.
  28038. func withUsageStatisticDayID(id uint64) usagestatisticdayOption {
  28039. return func(m *UsageStatisticDayMutation) {
  28040. var (
  28041. err error
  28042. once sync.Once
  28043. value *UsageStatisticDay
  28044. )
  28045. m.oldValue = func(ctx context.Context) (*UsageStatisticDay, error) {
  28046. once.Do(func() {
  28047. if m.done {
  28048. err = errors.New("querying old values post mutation is not allowed")
  28049. } else {
  28050. value, err = m.Client().UsageStatisticDay.Get(ctx, id)
  28051. }
  28052. })
  28053. return value, err
  28054. }
  28055. m.id = &id
  28056. }
  28057. }
  28058. // withUsageStatisticDay sets the old UsageStatisticDay of the mutation.
  28059. func withUsageStatisticDay(node *UsageStatisticDay) usagestatisticdayOption {
  28060. return func(m *UsageStatisticDayMutation) {
  28061. m.oldValue = func(context.Context) (*UsageStatisticDay, error) {
  28062. return node, nil
  28063. }
  28064. m.id = &node.ID
  28065. }
  28066. }
  28067. // Client returns a new `ent.Client` from the mutation. If the mutation was
  28068. // executed in a transaction (ent.Tx), a transactional client is returned.
  28069. func (m UsageStatisticDayMutation) Client() *Client {
  28070. client := &Client{config: m.config}
  28071. client.init()
  28072. return client
  28073. }
  28074. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  28075. // it returns an error otherwise.
  28076. func (m UsageStatisticDayMutation) Tx() (*Tx, error) {
  28077. if _, ok := m.driver.(*txDriver); !ok {
  28078. return nil, errors.New("ent: mutation is not running in a transaction")
  28079. }
  28080. tx := &Tx{config: m.config}
  28081. tx.init()
  28082. return tx, nil
  28083. }
  28084. // SetID sets the value of the id field. Note that this
  28085. // operation is only accepted on creation of UsageStatisticDay entities.
  28086. func (m *UsageStatisticDayMutation) SetID(id uint64) {
  28087. m.id = &id
  28088. }
  28089. // ID returns the ID value in the mutation. Note that the ID is only available
  28090. // if it was provided to the builder or after it was returned from the database.
  28091. func (m *UsageStatisticDayMutation) ID() (id uint64, exists bool) {
  28092. if m.id == nil {
  28093. return
  28094. }
  28095. return *m.id, true
  28096. }
  28097. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  28098. // That means, if the mutation is applied within a transaction with an isolation level such
  28099. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  28100. // or updated by the mutation.
  28101. func (m *UsageStatisticDayMutation) IDs(ctx context.Context) ([]uint64, error) {
  28102. switch {
  28103. case m.op.Is(OpUpdateOne | OpDeleteOne):
  28104. id, exists := m.ID()
  28105. if exists {
  28106. return []uint64{id}, nil
  28107. }
  28108. fallthrough
  28109. case m.op.Is(OpUpdate | OpDelete):
  28110. return m.Client().UsageStatisticDay.Query().Where(m.predicates...).IDs(ctx)
  28111. default:
  28112. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  28113. }
  28114. }
  28115. // SetCreatedAt sets the "created_at" field.
  28116. func (m *UsageStatisticDayMutation) SetCreatedAt(t time.Time) {
  28117. m.created_at = &t
  28118. }
  28119. // CreatedAt returns the value of the "created_at" field in the mutation.
  28120. func (m *UsageStatisticDayMutation) CreatedAt() (r time.Time, exists bool) {
  28121. v := m.created_at
  28122. if v == nil {
  28123. return
  28124. }
  28125. return *v, true
  28126. }
  28127. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticDay entity.
  28128. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28129. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28130. func (m *UsageStatisticDayMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  28131. if !m.op.Is(OpUpdateOne) {
  28132. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  28133. }
  28134. if m.id == nil || m.oldValue == nil {
  28135. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  28136. }
  28137. oldValue, err := m.oldValue(ctx)
  28138. if err != nil {
  28139. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  28140. }
  28141. return oldValue.CreatedAt, nil
  28142. }
  28143. // ResetCreatedAt resets all changes to the "created_at" field.
  28144. func (m *UsageStatisticDayMutation) ResetCreatedAt() {
  28145. m.created_at = nil
  28146. }
  28147. // SetUpdatedAt sets the "updated_at" field.
  28148. func (m *UsageStatisticDayMutation) SetUpdatedAt(t time.Time) {
  28149. m.updated_at = &t
  28150. }
  28151. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  28152. func (m *UsageStatisticDayMutation) UpdatedAt() (r time.Time, exists bool) {
  28153. v := m.updated_at
  28154. if v == nil {
  28155. return
  28156. }
  28157. return *v, true
  28158. }
  28159. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticDay entity.
  28160. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28162. func (m *UsageStatisticDayMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  28163. if !m.op.Is(OpUpdateOne) {
  28164. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  28165. }
  28166. if m.id == nil || m.oldValue == nil {
  28167. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  28168. }
  28169. oldValue, err := m.oldValue(ctx)
  28170. if err != nil {
  28171. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  28172. }
  28173. return oldValue.UpdatedAt, nil
  28174. }
  28175. // ResetUpdatedAt resets all changes to the "updated_at" field.
  28176. func (m *UsageStatisticDayMutation) ResetUpdatedAt() {
  28177. m.updated_at = nil
  28178. }
  28179. // SetStatus sets the "status" field.
  28180. func (m *UsageStatisticDayMutation) SetStatus(u uint8) {
  28181. m.status = &u
  28182. m.addstatus = nil
  28183. }
  28184. // Status returns the value of the "status" field in the mutation.
  28185. func (m *UsageStatisticDayMutation) Status() (r uint8, exists bool) {
  28186. v := m.status
  28187. if v == nil {
  28188. return
  28189. }
  28190. return *v, true
  28191. }
  28192. // OldStatus returns the old "status" field's value of the UsageStatisticDay entity.
  28193. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28194. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28195. func (m *UsageStatisticDayMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  28196. if !m.op.Is(OpUpdateOne) {
  28197. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  28198. }
  28199. if m.id == nil || m.oldValue == nil {
  28200. return v, errors.New("OldStatus requires an ID field in the mutation")
  28201. }
  28202. oldValue, err := m.oldValue(ctx)
  28203. if err != nil {
  28204. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  28205. }
  28206. return oldValue.Status, nil
  28207. }
  28208. // AddStatus adds u to the "status" field.
  28209. func (m *UsageStatisticDayMutation) AddStatus(u int8) {
  28210. if m.addstatus != nil {
  28211. *m.addstatus += u
  28212. } else {
  28213. m.addstatus = &u
  28214. }
  28215. }
  28216. // AddedStatus returns the value that was added to the "status" field in this mutation.
  28217. func (m *UsageStatisticDayMutation) AddedStatus() (r int8, exists bool) {
  28218. v := m.addstatus
  28219. if v == nil {
  28220. return
  28221. }
  28222. return *v, true
  28223. }
  28224. // ClearStatus clears the value of the "status" field.
  28225. func (m *UsageStatisticDayMutation) ClearStatus() {
  28226. m.status = nil
  28227. m.addstatus = nil
  28228. m.clearedFields[usagestatisticday.FieldStatus] = struct{}{}
  28229. }
  28230. // StatusCleared returns if the "status" field was cleared in this mutation.
  28231. func (m *UsageStatisticDayMutation) StatusCleared() bool {
  28232. _, ok := m.clearedFields[usagestatisticday.FieldStatus]
  28233. return ok
  28234. }
  28235. // ResetStatus resets all changes to the "status" field.
  28236. func (m *UsageStatisticDayMutation) ResetStatus() {
  28237. m.status = nil
  28238. m.addstatus = nil
  28239. delete(m.clearedFields, usagestatisticday.FieldStatus)
  28240. }
  28241. // SetDeletedAt sets the "deleted_at" field.
  28242. func (m *UsageStatisticDayMutation) SetDeletedAt(t time.Time) {
  28243. m.deleted_at = &t
  28244. }
  28245. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  28246. func (m *UsageStatisticDayMutation) DeletedAt() (r time.Time, exists bool) {
  28247. v := m.deleted_at
  28248. if v == nil {
  28249. return
  28250. }
  28251. return *v, true
  28252. }
  28253. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticDay entity.
  28254. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28255. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28256. func (m *UsageStatisticDayMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  28257. if !m.op.Is(OpUpdateOne) {
  28258. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  28259. }
  28260. if m.id == nil || m.oldValue == nil {
  28261. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  28262. }
  28263. oldValue, err := m.oldValue(ctx)
  28264. if err != nil {
  28265. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  28266. }
  28267. return oldValue.DeletedAt, nil
  28268. }
  28269. // ClearDeletedAt clears the value of the "deleted_at" field.
  28270. func (m *UsageStatisticDayMutation) ClearDeletedAt() {
  28271. m.deleted_at = nil
  28272. m.clearedFields[usagestatisticday.FieldDeletedAt] = struct{}{}
  28273. }
  28274. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  28275. func (m *UsageStatisticDayMutation) DeletedAtCleared() bool {
  28276. _, ok := m.clearedFields[usagestatisticday.FieldDeletedAt]
  28277. return ok
  28278. }
  28279. // ResetDeletedAt resets all changes to the "deleted_at" field.
  28280. func (m *UsageStatisticDayMutation) ResetDeletedAt() {
  28281. m.deleted_at = nil
  28282. delete(m.clearedFields, usagestatisticday.FieldDeletedAt)
  28283. }
  28284. // SetAddtime sets the "addtime" field.
  28285. func (m *UsageStatisticDayMutation) SetAddtime(u uint64) {
  28286. m.addtime = &u
  28287. m.addaddtime = nil
  28288. }
  28289. // Addtime returns the value of the "addtime" field in the mutation.
  28290. func (m *UsageStatisticDayMutation) Addtime() (r uint64, exists bool) {
  28291. v := m.addtime
  28292. if v == nil {
  28293. return
  28294. }
  28295. return *v, true
  28296. }
  28297. // OldAddtime returns the old "addtime" field's value of the UsageStatisticDay entity.
  28298. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28299. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28300. func (m *UsageStatisticDayMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  28301. if !m.op.Is(OpUpdateOne) {
  28302. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  28303. }
  28304. if m.id == nil || m.oldValue == nil {
  28305. return v, errors.New("OldAddtime requires an ID field in the mutation")
  28306. }
  28307. oldValue, err := m.oldValue(ctx)
  28308. if err != nil {
  28309. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  28310. }
  28311. return oldValue.Addtime, nil
  28312. }
  28313. // AddAddtime adds u to the "addtime" field.
  28314. func (m *UsageStatisticDayMutation) AddAddtime(u int64) {
  28315. if m.addaddtime != nil {
  28316. *m.addaddtime += u
  28317. } else {
  28318. m.addaddtime = &u
  28319. }
  28320. }
  28321. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  28322. func (m *UsageStatisticDayMutation) AddedAddtime() (r int64, exists bool) {
  28323. v := m.addaddtime
  28324. if v == nil {
  28325. return
  28326. }
  28327. return *v, true
  28328. }
  28329. // ResetAddtime resets all changes to the "addtime" field.
  28330. func (m *UsageStatisticDayMutation) ResetAddtime() {
  28331. m.addtime = nil
  28332. m.addaddtime = nil
  28333. }
  28334. // SetType sets the "type" field.
  28335. func (m *UsageStatisticDayMutation) SetType(i int) {
  28336. m._type = &i
  28337. m.add_type = nil
  28338. }
  28339. // GetType returns the value of the "type" field in the mutation.
  28340. func (m *UsageStatisticDayMutation) GetType() (r int, exists bool) {
  28341. v := m._type
  28342. if v == nil {
  28343. return
  28344. }
  28345. return *v, true
  28346. }
  28347. // OldType returns the old "type" field's value of the UsageStatisticDay entity.
  28348. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28350. func (m *UsageStatisticDayMutation) OldType(ctx context.Context) (v int, err error) {
  28351. if !m.op.Is(OpUpdateOne) {
  28352. return v, errors.New("OldType is only allowed on UpdateOne operations")
  28353. }
  28354. if m.id == nil || m.oldValue == nil {
  28355. return v, errors.New("OldType requires an ID field in the mutation")
  28356. }
  28357. oldValue, err := m.oldValue(ctx)
  28358. if err != nil {
  28359. return v, fmt.Errorf("querying old value for OldType: %w", err)
  28360. }
  28361. return oldValue.Type, nil
  28362. }
  28363. // AddType adds i to the "type" field.
  28364. func (m *UsageStatisticDayMutation) AddType(i int) {
  28365. if m.add_type != nil {
  28366. *m.add_type += i
  28367. } else {
  28368. m.add_type = &i
  28369. }
  28370. }
  28371. // AddedType returns the value that was added to the "type" field in this mutation.
  28372. func (m *UsageStatisticDayMutation) AddedType() (r int, exists bool) {
  28373. v := m.add_type
  28374. if v == nil {
  28375. return
  28376. }
  28377. return *v, true
  28378. }
  28379. // ResetType resets all changes to the "type" field.
  28380. func (m *UsageStatisticDayMutation) ResetType() {
  28381. m._type = nil
  28382. m.add_type = nil
  28383. }
  28384. // SetBotID sets the "bot_id" field.
  28385. func (m *UsageStatisticDayMutation) SetBotID(s string) {
  28386. m.bot_id = &s
  28387. }
  28388. // BotID returns the value of the "bot_id" field in the mutation.
  28389. func (m *UsageStatisticDayMutation) BotID() (r string, exists bool) {
  28390. v := m.bot_id
  28391. if v == nil {
  28392. return
  28393. }
  28394. return *v, true
  28395. }
  28396. // OldBotID returns the old "bot_id" field's value of the UsageStatisticDay entity.
  28397. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28399. func (m *UsageStatisticDayMutation) OldBotID(ctx context.Context) (v string, err error) {
  28400. if !m.op.Is(OpUpdateOne) {
  28401. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  28402. }
  28403. if m.id == nil || m.oldValue == nil {
  28404. return v, errors.New("OldBotID requires an ID field in the mutation")
  28405. }
  28406. oldValue, err := m.oldValue(ctx)
  28407. if err != nil {
  28408. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  28409. }
  28410. return oldValue.BotID, nil
  28411. }
  28412. // ClearBotID clears the value of the "bot_id" field.
  28413. func (m *UsageStatisticDayMutation) ClearBotID() {
  28414. m.bot_id = nil
  28415. m.clearedFields[usagestatisticday.FieldBotID] = struct{}{}
  28416. }
  28417. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  28418. func (m *UsageStatisticDayMutation) BotIDCleared() bool {
  28419. _, ok := m.clearedFields[usagestatisticday.FieldBotID]
  28420. return ok
  28421. }
  28422. // ResetBotID resets all changes to the "bot_id" field.
  28423. func (m *UsageStatisticDayMutation) ResetBotID() {
  28424. m.bot_id = nil
  28425. delete(m.clearedFields, usagestatisticday.FieldBotID)
  28426. }
  28427. // SetOrganizationID sets the "organization_id" field.
  28428. func (m *UsageStatisticDayMutation) SetOrganizationID(u uint64) {
  28429. m.organization_id = &u
  28430. m.addorganization_id = nil
  28431. }
  28432. // OrganizationID returns the value of the "organization_id" field in the mutation.
  28433. func (m *UsageStatisticDayMutation) OrganizationID() (r uint64, exists bool) {
  28434. v := m.organization_id
  28435. if v == nil {
  28436. return
  28437. }
  28438. return *v, true
  28439. }
  28440. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticDay entity.
  28441. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28442. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28443. func (m *UsageStatisticDayMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  28444. if !m.op.Is(OpUpdateOne) {
  28445. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  28446. }
  28447. if m.id == nil || m.oldValue == nil {
  28448. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  28449. }
  28450. oldValue, err := m.oldValue(ctx)
  28451. if err != nil {
  28452. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  28453. }
  28454. return oldValue.OrganizationID, nil
  28455. }
  28456. // AddOrganizationID adds u to the "organization_id" field.
  28457. func (m *UsageStatisticDayMutation) AddOrganizationID(u int64) {
  28458. if m.addorganization_id != nil {
  28459. *m.addorganization_id += u
  28460. } else {
  28461. m.addorganization_id = &u
  28462. }
  28463. }
  28464. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  28465. func (m *UsageStatisticDayMutation) AddedOrganizationID() (r int64, exists bool) {
  28466. v := m.addorganization_id
  28467. if v == nil {
  28468. return
  28469. }
  28470. return *v, true
  28471. }
  28472. // ClearOrganizationID clears the value of the "organization_id" field.
  28473. func (m *UsageStatisticDayMutation) ClearOrganizationID() {
  28474. m.organization_id = nil
  28475. m.addorganization_id = nil
  28476. m.clearedFields[usagestatisticday.FieldOrganizationID] = struct{}{}
  28477. }
  28478. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  28479. func (m *UsageStatisticDayMutation) OrganizationIDCleared() bool {
  28480. _, ok := m.clearedFields[usagestatisticday.FieldOrganizationID]
  28481. return ok
  28482. }
  28483. // ResetOrganizationID resets all changes to the "organization_id" field.
  28484. func (m *UsageStatisticDayMutation) ResetOrganizationID() {
  28485. m.organization_id = nil
  28486. m.addorganization_id = nil
  28487. delete(m.clearedFields, usagestatisticday.FieldOrganizationID)
  28488. }
  28489. // SetAiResponse sets the "ai_response" field.
  28490. func (m *UsageStatisticDayMutation) SetAiResponse(u uint64) {
  28491. m.ai_response = &u
  28492. m.addai_response = nil
  28493. }
  28494. // AiResponse returns the value of the "ai_response" field in the mutation.
  28495. func (m *UsageStatisticDayMutation) AiResponse() (r uint64, exists bool) {
  28496. v := m.ai_response
  28497. if v == nil {
  28498. return
  28499. }
  28500. return *v, true
  28501. }
  28502. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticDay entity.
  28503. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28504. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28505. func (m *UsageStatisticDayMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  28506. if !m.op.Is(OpUpdateOne) {
  28507. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  28508. }
  28509. if m.id == nil || m.oldValue == nil {
  28510. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  28511. }
  28512. oldValue, err := m.oldValue(ctx)
  28513. if err != nil {
  28514. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  28515. }
  28516. return oldValue.AiResponse, nil
  28517. }
  28518. // AddAiResponse adds u to the "ai_response" field.
  28519. func (m *UsageStatisticDayMutation) AddAiResponse(u int64) {
  28520. if m.addai_response != nil {
  28521. *m.addai_response += u
  28522. } else {
  28523. m.addai_response = &u
  28524. }
  28525. }
  28526. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  28527. func (m *UsageStatisticDayMutation) AddedAiResponse() (r int64, exists bool) {
  28528. v := m.addai_response
  28529. if v == nil {
  28530. return
  28531. }
  28532. return *v, true
  28533. }
  28534. // ResetAiResponse resets all changes to the "ai_response" field.
  28535. func (m *UsageStatisticDayMutation) ResetAiResponse() {
  28536. m.ai_response = nil
  28537. m.addai_response = nil
  28538. }
  28539. // SetSopRun sets the "sop_run" field.
  28540. func (m *UsageStatisticDayMutation) SetSopRun(u uint64) {
  28541. m.sop_run = &u
  28542. m.addsop_run = nil
  28543. }
  28544. // SopRun returns the value of the "sop_run" field in the mutation.
  28545. func (m *UsageStatisticDayMutation) SopRun() (r uint64, exists bool) {
  28546. v := m.sop_run
  28547. if v == nil {
  28548. return
  28549. }
  28550. return *v, true
  28551. }
  28552. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticDay entity.
  28553. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28554. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28555. func (m *UsageStatisticDayMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  28556. if !m.op.Is(OpUpdateOne) {
  28557. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  28558. }
  28559. if m.id == nil || m.oldValue == nil {
  28560. return v, errors.New("OldSopRun requires an ID field in the mutation")
  28561. }
  28562. oldValue, err := m.oldValue(ctx)
  28563. if err != nil {
  28564. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  28565. }
  28566. return oldValue.SopRun, nil
  28567. }
  28568. // AddSopRun adds u to the "sop_run" field.
  28569. func (m *UsageStatisticDayMutation) AddSopRun(u int64) {
  28570. if m.addsop_run != nil {
  28571. *m.addsop_run += u
  28572. } else {
  28573. m.addsop_run = &u
  28574. }
  28575. }
  28576. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  28577. func (m *UsageStatisticDayMutation) AddedSopRun() (r int64, exists bool) {
  28578. v := m.addsop_run
  28579. if v == nil {
  28580. return
  28581. }
  28582. return *v, true
  28583. }
  28584. // ResetSopRun resets all changes to the "sop_run" field.
  28585. func (m *UsageStatisticDayMutation) ResetSopRun() {
  28586. m.sop_run = nil
  28587. m.addsop_run = nil
  28588. }
  28589. // SetTotalFriend sets the "total_friend" field.
  28590. func (m *UsageStatisticDayMutation) SetTotalFriend(u uint64) {
  28591. m.total_friend = &u
  28592. m.addtotal_friend = nil
  28593. }
  28594. // TotalFriend returns the value of the "total_friend" field in the mutation.
  28595. func (m *UsageStatisticDayMutation) TotalFriend() (r uint64, exists bool) {
  28596. v := m.total_friend
  28597. if v == nil {
  28598. return
  28599. }
  28600. return *v, true
  28601. }
  28602. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticDay entity.
  28603. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28604. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28605. func (m *UsageStatisticDayMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  28606. if !m.op.Is(OpUpdateOne) {
  28607. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  28608. }
  28609. if m.id == nil || m.oldValue == nil {
  28610. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  28611. }
  28612. oldValue, err := m.oldValue(ctx)
  28613. if err != nil {
  28614. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  28615. }
  28616. return oldValue.TotalFriend, nil
  28617. }
  28618. // AddTotalFriend adds u to the "total_friend" field.
  28619. func (m *UsageStatisticDayMutation) AddTotalFriend(u int64) {
  28620. if m.addtotal_friend != nil {
  28621. *m.addtotal_friend += u
  28622. } else {
  28623. m.addtotal_friend = &u
  28624. }
  28625. }
  28626. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  28627. func (m *UsageStatisticDayMutation) AddedTotalFriend() (r int64, exists bool) {
  28628. v := m.addtotal_friend
  28629. if v == nil {
  28630. return
  28631. }
  28632. return *v, true
  28633. }
  28634. // ResetTotalFriend resets all changes to the "total_friend" field.
  28635. func (m *UsageStatisticDayMutation) ResetTotalFriend() {
  28636. m.total_friend = nil
  28637. m.addtotal_friend = nil
  28638. }
  28639. // SetTotalGroup sets the "total_group" field.
  28640. func (m *UsageStatisticDayMutation) SetTotalGroup(u uint64) {
  28641. m.total_group = &u
  28642. m.addtotal_group = nil
  28643. }
  28644. // TotalGroup returns the value of the "total_group" field in the mutation.
  28645. func (m *UsageStatisticDayMutation) TotalGroup() (r uint64, exists bool) {
  28646. v := m.total_group
  28647. if v == nil {
  28648. return
  28649. }
  28650. return *v, true
  28651. }
  28652. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticDay entity.
  28653. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28654. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28655. func (m *UsageStatisticDayMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  28656. if !m.op.Is(OpUpdateOne) {
  28657. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  28658. }
  28659. if m.id == nil || m.oldValue == nil {
  28660. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  28661. }
  28662. oldValue, err := m.oldValue(ctx)
  28663. if err != nil {
  28664. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  28665. }
  28666. return oldValue.TotalGroup, nil
  28667. }
  28668. // AddTotalGroup adds u to the "total_group" field.
  28669. func (m *UsageStatisticDayMutation) AddTotalGroup(u int64) {
  28670. if m.addtotal_group != nil {
  28671. *m.addtotal_group += u
  28672. } else {
  28673. m.addtotal_group = &u
  28674. }
  28675. }
  28676. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  28677. func (m *UsageStatisticDayMutation) AddedTotalGroup() (r int64, exists bool) {
  28678. v := m.addtotal_group
  28679. if v == nil {
  28680. return
  28681. }
  28682. return *v, true
  28683. }
  28684. // ResetTotalGroup resets all changes to the "total_group" field.
  28685. func (m *UsageStatisticDayMutation) ResetTotalGroup() {
  28686. m.total_group = nil
  28687. m.addtotal_group = nil
  28688. }
  28689. // SetAccountBalance sets the "account_balance" field.
  28690. func (m *UsageStatisticDayMutation) SetAccountBalance(u uint64) {
  28691. m.account_balance = &u
  28692. m.addaccount_balance = nil
  28693. }
  28694. // AccountBalance returns the value of the "account_balance" field in the mutation.
  28695. func (m *UsageStatisticDayMutation) AccountBalance() (r uint64, exists bool) {
  28696. v := m.account_balance
  28697. if v == nil {
  28698. return
  28699. }
  28700. return *v, true
  28701. }
  28702. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticDay entity.
  28703. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28704. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28705. func (m *UsageStatisticDayMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  28706. if !m.op.Is(OpUpdateOne) {
  28707. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  28708. }
  28709. if m.id == nil || m.oldValue == nil {
  28710. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  28711. }
  28712. oldValue, err := m.oldValue(ctx)
  28713. if err != nil {
  28714. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  28715. }
  28716. return oldValue.AccountBalance, nil
  28717. }
  28718. // AddAccountBalance adds u to the "account_balance" field.
  28719. func (m *UsageStatisticDayMutation) AddAccountBalance(u int64) {
  28720. if m.addaccount_balance != nil {
  28721. *m.addaccount_balance += u
  28722. } else {
  28723. m.addaccount_balance = &u
  28724. }
  28725. }
  28726. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  28727. func (m *UsageStatisticDayMutation) AddedAccountBalance() (r int64, exists bool) {
  28728. v := m.addaccount_balance
  28729. if v == nil {
  28730. return
  28731. }
  28732. return *v, true
  28733. }
  28734. // ResetAccountBalance resets all changes to the "account_balance" field.
  28735. func (m *UsageStatisticDayMutation) ResetAccountBalance() {
  28736. m.account_balance = nil
  28737. m.addaccount_balance = nil
  28738. }
  28739. // SetConsumeToken sets the "consume_token" field.
  28740. func (m *UsageStatisticDayMutation) SetConsumeToken(u uint64) {
  28741. m.consume_token = &u
  28742. m.addconsume_token = nil
  28743. }
  28744. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  28745. func (m *UsageStatisticDayMutation) ConsumeToken() (r uint64, exists bool) {
  28746. v := m.consume_token
  28747. if v == nil {
  28748. return
  28749. }
  28750. return *v, true
  28751. }
  28752. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticDay entity.
  28753. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28754. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28755. func (m *UsageStatisticDayMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  28756. if !m.op.Is(OpUpdateOne) {
  28757. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  28758. }
  28759. if m.id == nil || m.oldValue == nil {
  28760. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  28761. }
  28762. oldValue, err := m.oldValue(ctx)
  28763. if err != nil {
  28764. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  28765. }
  28766. return oldValue.ConsumeToken, nil
  28767. }
  28768. // AddConsumeToken adds u to the "consume_token" field.
  28769. func (m *UsageStatisticDayMutation) AddConsumeToken(u int64) {
  28770. if m.addconsume_token != nil {
  28771. *m.addconsume_token += u
  28772. } else {
  28773. m.addconsume_token = &u
  28774. }
  28775. }
  28776. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  28777. func (m *UsageStatisticDayMutation) AddedConsumeToken() (r int64, exists bool) {
  28778. v := m.addconsume_token
  28779. if v == nil {
  28780. return
  28781. }
  28782. return *v, true
  28783. }
  28784. // ResetConsumeToken resets all changes to the "consume_token" field.
  28785. func (m *UsageStatisticDayMutation) ResetConsumeToken() {
  28786. m.consume_token = nil
  28787. m.addconsume_token = nil
  28788. }
  28789. // SetActiveUser sets the "active_user" field.
  28790. func (m *UsageStatisticDayMutation) SetActiveUser(u uint64) {
  28791. m.active_user = &u
  28792. m.addactive_user = nil
  28793. }
  28794. // ActiveUser returns the value of the "active_user" field in the mutation.
  28795. func (m *UsageStatisticDayMutation) ActiveUser() (r uint64, exists bool) {
  28796. v := m.active_user
  28797. if v == nil {
  28798. return
  28799. }
  28800. return *v, true
  28801. }
  28802. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticDay entity.
  28803. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28804. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28805. func (m *UsageStatisticDayMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  28806. if !m.op.Is(OpUpdateOne) {
  28807. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  28808. }
  28809. if m.id == nil || m.oldValue == nil {
  28810. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  28811. }
  28812. oldValue, err := m.oldValue(ctx)
  28813. if err != nil {
  28814. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  28815. }
  28816. return oldValue.ActiveUser, nil
  28817. }
  28818. // AddActiveUser adds u to the "active_user" field.
  28819. func (m *UsageStatisticDayMutation) AddActiveUser(u int64) {
  28820. if m.addactive_user != nil {
  28821. *m.addactive_user += u
  28822. } else {
  28823. m.addactive_user = &u
  28824. }
  28825. }
  28826. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  28827. func (m *UsageStatisticDayMutation) AddedActiveUser() (r int64, exists bool) {
  28828. v := m.addactive_user
  28829. if v == nil {
  28830. return
  28831. }
  28832. return *v, true
  28833. }
  28834. // ResetActiveUser resets all changes to the "active_user" field.
  28835. func (m *UsageStatisticDayMutation) ResetActiveUser() {
  28836. m.active_user = nil
  28837. m.addactive_user = nil
  28838. }
  28839. // SetNewUser sets the "new_user" field.
  28840. func (m *UsageStatisticDayMutation) SetNewUser(i int64) {
  28841. m.new_user = &i
  28842. m.addnew_user = nil
  28843. }
  28844. // NewUser returns the value of the "new_user" field in the mutation.
  28845. func (m *UsageStatisticDayMutation) NewUser() (r int64, exists bool) {
  28846. v := m.new_user
  28847. if v == nil {
  28848. return
  28849. }
  28850. return *v, true
  28851. }
  28852. // OldNewUser returns the old "new_user" field's value of the UsageStatisticDay entity.
  28853. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28855. func (m *UsageStatisticDayMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  28856. if !m.op.Is(OpUpdateOne) {
  28857. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  28858. }
  28859. if m.id == nil || m.oldValue == nil {
  28860. return v, errors.New("OldNewUser requires an ID field in the mutation")
  28861. }
  28862. oldValue, err := m.oldValue(ctx)
  28863. if err != nil {
  28864. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  28865. }
  28866. return oldValue.NewUser, nil
  28867. }
  28868. // AddNewUser adds i to the "new_user" field.
  28869. func (m *UsageStatisticDayMutation) AddNewUser(i int64) {
  28870. if m.addnew_user != nil {
  28871. *m.addnew_user += i
  28872. } else {
  28873. m.addnew_user = &i
  28874. }
  28875. }
  28876. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  28877. func (m *UsageStatisticDayMutation) AddedNewUser() (r int64, exists bool) {
  28878. v := m.addnew_user
  28879. if v == nil {
  28880. return
  28881. }
  28882. return *v, true
  28883. }
  28884. // ResetNewUser resets all changes to the "new_user" field.
  28885. func (m *UsageStatisticDayMutation) ResetNewUser() {
  28886. m.new_user = nil
  28887. m.addnew_user = nil
  28888. }
  28889. // SetLabelDist sets the "label_dist" field.
  28890. func (m *UsageStatisticDayMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  28891. m.label_dist = &ctd
  28892. m.appendlabel_dist = nil
  28893. }
  28894. // LabelDist returns the value of the "label_dist" field in the mutation.
  28895. func (m *UsageStatisticDayMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  28896. v := m.label_dist
  28897. if v == nil {
  28898. return
  28899. }
  28900. return *v, true
  28901. }
  28902. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticDay entity.
  28903. // If the UsageStatisticDay object wasn't provided to the builder, the object is fetched from the database.
  28904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  28905. func (m *UsageStatisticDayMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  28906. if !m.op.Is(OpUpdateOne) {
  28907. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  28908. }
  28909. if m.id == nil || m.oldValue == nil {
  28910. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  28911. }
  28912. oldValue, err := m.oldValue(ctx)
  28913. if err != nil {
  28914. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  28915. }
  28916. return oldValue.LabelDist, nil
  28917. }
  28918. // AppendLabelDist adds ctd to the "label_dist" field.
  28919. func (m *UsageStatisticDayMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  28920. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  28921. }
  28922. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  28923. func (m *UsageStatisticDayMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  28924. if len(m.appendlabel_dist) == 0 {
  28925. return nil, false
  28926. }
  28927. return m.appendlabel_dist, true
  28928. }
  28929. // ResetLabelDist resets all changes to the "label_dist" field.
  28930. func (m *UsageStatisticDayMutation) ResetLabelDist() {
  28931. m.label_dist = nil
  28932. m.appendlabel_dist = nil
  28933. }
  28934. // Where appends a list predicates to the UsageStatisticDayMutation builder.
  28935. func (m *UsageStatisticDayMutation) Where(ps ...predicate.UsageStatisticDay) {
  28936. m.predicates = append(m.predicates, ps...)
  28937. }
  28938. // WhereP appends storage-level predicates to the UsageStatisticDayMutation builder. Using this method,
  28939. // users can use type-assertion to append predicates that do not depend on any generated package.
  28940. func (m *UsageStatisticDayMutation) WhereP(ps ...func(*sql.Selector)) {
  28941. p := make([]predicate.UsageStatisticDay, len(ps))
  28942. for i := range ps {
  28943. p[i] = ps[i]
  28944. }
  28945. m.Where(p...)
  28946. }
  28947. // Op returns the operation name.
  28948. func (m *UsageStatisticDayMutation) Op() Op {
  28949. return m.op
  28950. }
  28951. // SetOp allows setting the mutation operation.
  28952. func (m *UsageStatisticDayMutation) SetOp(op Op) {
  28953. m.op = op
  28954. }
  28955. // Type returns the node type of this mutation (UsageStatisticDay).
  28956. func (m *UsageStatisticDayMutation) Type() string {
  28957. return m.typ
  28958. }
  28959. // Fields returns all fields that were changed during this mutation. Note that in
  28960. // order to get all numeric fields that were incremented/decremented, call
  28961. // AddedFields().
  28962. func (m *UsageStatisticDayMutation) Fields() []string {
  28963. fields := make([]string, 0, 17)
  28964. if m.created_at != nil {
  28965. fields = append(fields, usagestatisticday.FieldCreatedAt)
  28966. }
  28967. if m.updated_at != nil {
  28968. fields = append(fields, usagestatisticday.FieldUpdatedAt)
  28969. }
  28970. if m.status != nil {
  28971. fields = append(fields, usagestatisticday.FieldStatus)
  28972. }
  28973. if m.deleted_at != nil {
  28974. fields = append(fields, usagestatisticday.FieldDeletedAt)
  28975. }
  28976. if m.addtime != nil {
  28977. fields = append(fields, usagestatisticday.FieldAddtime)
  28978. }
  28979. if m._type != nil {
  28980. fields = append(fields, usagestatisticday.FieldType)
  28981. }
  28982. if m.bot_id != nil {
  28983. fields = append(fields, usagestatisticday.FieldBotID)
  28984. }
  28985. if m.organization_id != nil {
  28986. fields = append(fields, usagestatisticday.FieldOrganizationID)
  28987. }
  28988. if m.ai_response != nil {
  28989. fields = append(fields, usagestatisticday.FieldAiResponse)
  28990. }
  28991. if m.sop_run != nil {
  28992. fields = append(fields, usagestatisticday.FieldSopRun)
  28993. }
  28994. if m.total_friend != nil {
  28995. fields = append(fields, usagestatisticday.FieldTotalFriend)
  28996. }
  28997. if m.total_group != nil {
  28998. fields = append(fields, usagestatisticday.FieldTotalGroup)
  28999. }
  29000. if m.account_balance != nil {
  29001. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29002. }
  29003. if m.consume_token != nil {
  29004. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29005. }
  29006. if m.active_user != nil {
  29007. fields = append(fields, usagestatisticday.FieldActiveUser)
  29008. }
  29009. if m.new_user != nil {
  29010. fields = append(fields, usagestatisticday.FieldNewUser)
  29011. }
  29012. if m.label_dist != nil {
  29013. fields = append(fields, usagestatisticday.FieldLabelDist)
  29014. }
  29015. return fields
  29016. }
  29017. // Field returns the value of a field with the given name. The second boolean
  29018. // return value indicates that this field was not set, or was not defined in the
  29019. // schema.
  29020. func (m *UsageStatisticDayMutation) Field(name string) (ent.Value, bool) {
  29021. switch name {
  29022. case usagestatisticday.FieldCreatedAt:
  29023. return m.CreatedAt()
  29024. case usagestatisticday.FieldUpdatedAt:
  29025. return m.UpdatedAt()
  29026. case usagestatisticday.FieldStatus:
  29027. return m.Status()
  29028. case usagestatisticday.FieldDeletedAt:
  29029. return m.DeletedAt()
  29030. case usagestatisticday.FieldAddtime:
  29031. return m.Addtime()
  29032. case usagestatisticday.FieldType:
  29033. return m.GetType()
  29034. case usagestatisticday.FieldBotID:
  29035. return m.BotID()
  29036. case usagestatisticday.FieldOrganizationID:
  29037. return m.OrganizationID()
  29038. case usagestatisticday.FieldAiResponse:
  29039. return m.AiResponse()
  29040. case usagestatisticday.FieldSopRun:
  29041. return m.SopRun()
  29042. case usagestatisticday.FieldTotalFriend:
  29043. return m.TotalFriend()
  29044. case usagestatisticday.FieldTotalGroup:
  29045. return m.TotalGroup()
  29046. case usagestatisticday.FieldAccountBalance:
  29047. return m.AccountBalance()
  29048. case usagestatisticday.FieldConsumeToken:
  29049. return m.ConsumeToken()
  29050. case usagestatisticday.FieldActiveUser:
  29051. return m.ActiveUser()
  29052. case usagestatisticday.FieldNewUser:
  29053. return m.NewUser()
  29054. case usagestatisticday.FieldLabelDist:
  29055. return m.LabelDist()
  29056. }
  29057. return nil, false
  29058. }
  29059. // OldField returns the old value of the field from the database. An error is
  29060. // returned if the mutation operation is not UpdateOne, or the query to the
  29061. // database failed.
  29062. func (m *UsageStatisticDayMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  29063. switch name {
  29064. case usagestatisticday.FieldCreatedAt:
  29065. return m.OldCreatedAt(ctx)
  29066. case usagestatisticday.FieldUpdatedAt:
  29067. return m.OldUpdatedAt(ctx)
  29068. case usagestatisticday.FieldStatus:
  29069. return m.OldStatus(ctx)
  29070. case usagestatisticday.FieldDeletedAt:
  29071. return m.OldDeletedAt(ctx)
  29072. case usagestatisticday.FieldAddtime:
  29073. return m.OldAddtime(ctx)
  29074. case usagestatisticday.FieldType:
  29075. return m.OldType(ctx)
  29076. case usagestatisticday.FieldBotID:
  29077. return m.OldBotID(ctx)
  29078. case usagestatisticday.FieldOrganizationID:
  29079. return m.OldOrganizationID(ctx)
  29080. case usagestatisticday.FieldAiResponse:
  29081. return m.OldAiResponse(ctx)
  29082. case usagestatisticday.FieldSopRun:
  29083. return m.OldSopRun(ctx)
  29084. case usagestatisticday.FieldTotalFriend:
  29085. return m.OldTotalFriend(ctx)
  29086. case usagestatisticday.FieldTotalGroup:
  29087. return m.OldTotalGroup(ctx)
  29088. case usagestatisticday.FieldAccountBalance:
  29089. return m.OldAccountBalance(ctx)
  29090. case usagestatisticday.FieldConsumeToken:
  29091. return m.OldConsumeToken(ctx)
  29092. case usagestatisticday.FieldActiveUser:
  29093. return m.OldActiveUser(ctx)
  29094. case usagestatisticday.FieldNewUser:
  29095. return m.OldNewUser(ctx)
  29096. case usagestatisticday.FieldLabelDist:
  29097. return m.OldLabelDist(ctx)
  29098. }
  29099. return nil, fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29100. }
  29101. // SetField sets the value of a field with the given name. It returns an error if
  29102. // the field is not defined in the schema, or if the type mismatched the field
  29103. // type.
  29104. func (m *UsageStatisticDayMutation) SetField(name string, value ent.Value) error {
  29105. switch name {
  29106. case usagestatisticday.FieldCreatedAt:
  29107. v, ok := value.(time.Time)
  29108. if !ok {
  29109. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29110. }
  29111. m.SetCreatedAt(v)
  29112. return nil
  29113. case usagestatisticday.FieldUpdatedAt:
  29114. v, ok := value.(time.Time)
  29115. if !ok {
  29116. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29117. }
  29118. m.SetUpdatedAt(v)
  29119. return nil
  29120. case usagestatisticday.FieldStatus:
  29121. v, ok := value.(uint8)
  29122. if !ok {
  29123. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29124. }
  29125. m.SetStatus(v)
  29126. return nil
  29127. case usagestatisticday.FieldDeletedAt:
  29128. v, ok := value.(time.Time)
  29129. if !ok {
  29130. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29131. }
  29132. m.SetDeletedAt(v)
  29133. return nil
  29134. case usagestatisticday.FieldAddtime:
  29135. v, ok := value.(uint64)
  29136. if !ok {
  29137. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29138. }
  29139. m.SetAddtime(v)
  29140. return nil
  29141. case usagestatisticday.FieldType:
  29142. v, ok := value.(int)
  29143. if !ok {
  29144. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29145. }
  29146. m.SetType(v)
  29147. return nil
  29148. case usagestatisticday.FieldBotID:
  29149. v, ok := value.(string)
  29150. if !ok {
  29151. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29152. }
  29153. m.SetBotID(v)
  29154. return nil
  29155. case usagestatisticday.FieldOrganizationID:
  29156. v, ok := value.(uint64)
  29157. if !ok {
  29158. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29159. }
  29160. m.SetOrganizationID(v)
  29161. return nil
  29162. case usagestatisticday.FieldAiResponse:
  29163. v, ok := value.(uint64)
  29164. if !ok {
  29165. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29166. }
  29167. m.SetAiResponse(v)
  29168. return nil
  29169. case usagestatisticday.FieldSopRun:
  29170. v, ok := value.(uint64)
  29171. if !ok {
  29172. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29173. }
  29174. m.SetSopRun(v)
  29175. return nil
  29176. case usagestatisticday.FieldTotalFriend:
  29177. v, ok := value.(uint64)
  29178. if !ok {
  29179. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29180. }
  29181. m.SetTotalFriend(v)
  29182. return nil
  29183. case usagestatisticday.FieldTotalGroup:
  29184. v, ok := value.(uint64)
  29185. if !ok {
  29186. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29187. }
  29188. m.SetTotalGroup(v)
  29189. return nil
  29190. case usagestatisticday.FieldAccountBalance:
  29191. v, ok := value.(uint64)
  29192. if !ok {
  29193. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29194. }
  29195. m.SetAccountBalance(v)
  29196. return nil
  29197. case usagestatisticday.FieldConsumeToken:
  29198. v, ok := value.(uint64)
  29199. if !ok {
  29200. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29201. }
  29202. m.SetConsumeToken(v)
  29203. return nil
  29204. case usagestatisticday.FieldActiveUser:
  29205. v, ok := value.(uint64)
  29206. if !ok {
  29207. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29208. }
  29209. m.SetActiveUser(v)
  29210. return nil
  29211. case usagestatisticday.FieldNewUser:
  29212. v, ok := value.(int64)
  29213. if !ok {
  29214. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29215. }
  29216. m.SetNewUser(v)
  29217. return nil
  29218. case usagestatisticday.FieldLabelDist:
  29219. v, ok := value.([]custom_types.LabelDist)
  29220. if !ok {
  29221. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29222. }
  29223. m.SetLabelDist(v)
  29224. return nil
  29225. }
  29226. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29227. }
  29228. // AddedFields returns all numeric fields that were incremented/decremented during
  29229. // this mutation.
  29230. func (m *UsageStatisticDayMutation) AddedFields() []string {
  29231. var fields []string
  29232. if m.addstatus != nil {
  29233. fields = append(fields, usagestatisticday.FieldStatus)
  29234. }
  29235. if m.addaddtime != nil {
  29236. fields = append(fields, usagestatisticday.FieldAddtime)
  29237. }
  29238. if m.add_type != nil {
  29239. fields = append(fields, usagestatisticday.FieldType)
  29240. }
  29241. if m.addorganization_id != nil {
  29242. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29243. }
  29244. if m.addai_response != nil {
  29245. fields = append(fields, usagestatisticday.FieldAiResponse)
  29246. }
  29247. if m.addsop_run != nil {
  29248. fields = append(fields, usagestatisticday.FieldSopRun)
  29249. }
  29250. if m.addtotal_friend != nil {
  29251. fields = append(fields, usagestatisticday.FieldTotalFriend)
  29252. }
  29253. if m.addtotal_group != nil {
  29254. fields = append(fields, usagestatisticday.FieldTotalGroup)
  29255. }
  29256. if m.addaccount_balance != nil {
  29257. fields = append(fields, usagestatisticday.FieldAccountBalance)
  29258. }
  29259. if m.addconsume_token != nil {
  29260. fields = append(fields, usagestatisticday.FieldConsumeToken)
  29261. }
  29262. if m.addactive_user != nil {
  29263. fields = append(fields, usagestatisticday.FieldActiveUser)
  29264. }
  29265. if m.addnew_user != nil {
  29266. fields = append(fields, usagestatisticday.FieldNewUser)
  29267. }
  29268. return fields
  29269. }
  29270. // AddedField returns the numeric value that was incremented/decremented on a field
  29271. // with the given name. The second boolean return value indicates that this field
  29272. // was not set, or was not defined in the schema.
  29273. func (m *UsageStatisticDayMutation) AddedField(name string) (ent.Value, bool) {
  29274. switch name {
  29275. case usagestatisticday.FieldStatus:
  29276. return m.AddedStatus()
  29277. case usagestatisticday.FieldAddtime:
  29278. return m.AddedAddtime()
  29279. case usagestatisticday.FieldType:
  29280. return m.AddedType()
  29281. case usagestatisticday.FieldOrganizationID:
  29282. return m.AddedOrganizationID()
  29283. case usagestatisticday.FieldAiResponse:
  29284. return m.AddedAiResponse()
  29285. case usagestatisticday.FieldSopRun:
  29286. return m.AddedSopRun()
  29287. case usagestatisticday.FieldTotalFriend:
  29288. return m.AddedTotalFriend()
  29289. case usagestatisticday.FieldTotalGroup:
  29290. return m.AddedTotalGroup()
  29291. case usagestatisticday.FieldAccountBalance:
  29292. return m.AddedAccountBalance()
  29293. case usagestatisticday.FieldConsumeToken:
  29294. return m.AddedConsumeToken()
  29295. case usagestatisticday.FieldActiveUser:
  29296. return m.AddedActiveUser()
  29297. case usagestatisticday.FieldNewUser:
  29298. return m.AddedNewUser()
  29299. }
  29300. return nil, false
  29301. }
  29302. // AddField adds the value to the field with the given name. It returns an error if
  29303. // the field is not defined in the schema, or if the type mismatched the field
  29304. // type.
  29305. func (m *UsageStatisticDayMutation) AddField(name string, value ent.Value) error {
  29306. switch name {
  29307. case usagestatisticday.FieldStatus:
  29308. v, ok := value.(int8)
  29309. if !ok {
  29310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29311. }
  29312. m.AddStatus(v)
  29313. return nil
  29314. case usagestatisticday.FieldAddtime:
  29315. v, ok := value.(int64)
  29316. if !ok {
  29317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29318. }
  29319. m.AddAddtime(v)
  29320. return nil
  29321. case usagestatisticday.FieldType:
  29322. v, ok := value.(int)
  29323. if !ok {
  29324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29325. }
  29326. m.AddType(v)
  29327. return nil
  29328. case usagestatisticday.FieldOrganizationID:
  29329. v, ok := value.(int64)
  29330. if !ok {
  29331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29332. }
  29333. m.AddOrganizationID(v)
  29334. return nil
  29335. case usagestatisticday.FieldAiResponse:
  29336. v, ok := value.(int64)
  29337. if !ok {
  29338. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29339. }
  29340. m.AddAiResponse(v)
  29341. return nil
  29342. case usagestatisticday.FieldSopRun:
  29343. v, ok := value.(int64)
  29344. if !ok {
  29345. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29346. }
  29347. m.AddSopRun(v)
  29348. return nil
  29349. case usagestatisticday.FieldTotalFriend:
  29350. v, ok := value.(int64)
  29351. if !ok {
  29352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29353. }
  29354. m.AddTotalFriend(v)
  29355. return nil
  29356. case usagestatisticday.FieldTotalGroup:
  29357. v, ok := value.(int64)
  29358. if !ok {
  29359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29360. }
  29361. m.AddTotalGroup(v)
  29362. return nil
  29363. case usagestatisticday.FieldAccountBalance:
  29364. v, ok := value.(int64)
  29365. if !ok {
  29366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29367. }
  29368. m.AddAccountBalance(v)
  29369. return nil
  29370. case usagestatisticday.FieldConsumeToken:
  29371. v, ok := value.(int64)
  29372. if !ok {
  29373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29374. }
  29375. m.AddConsumeToken(v)
  29376. return nil
  29377. case usagestatisticday.FieldActiveUser:
  29378. v, ok := value.(int64)
  29379. if !ok {
  29380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29381. }
  29382. m.AddActiveUser(v)
  29383. return nil
  29384. case usagestatisticday.FieldNewUser:
  29385. v, ok := value.(int64)
  29386. if !ok {
  29387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  29388. }
  29389. m.AddNewUser(v)
  29390. return nil
  29391. }
  29392. return fmt.Errorf("unknown UsageStatisticDay numeric field %s", name)
  29393. }
  29394. // ClearedFields returns all nullable fields that were cleared during this
  29395. // mutation.
  29396. func (m *UsageStatisticDayMutation) ClearedFields() []string {
  29397. var fields []string
  29398. if m.FieldCleared(usagestatisticday.FieldStatus) {
  29399. fields = append(fields, usagestatisticday.FieldStatus)
  29400. }
  29401. if m.FieldCleared(usagestatisticday.FieldDeletedAt) {
  29402. fields = append(fields, usagestatisticday.FieldDeletedAt)
  29403. }
  29404. if m.FieldCleared(usagestatisticday.FieldBotID) {
  29405. fields = append(fields, usagestatisticday.FieldBotID)
  29406. }
  29407. if m.FieldCleared(usagestatisticday.FieldOrganizationID) {
  29408. fields = append(fields, usagestatisticday.FieldOrganizationID)
  29409. }
  29410. return fields
  29411. }
  29412. // FieldCleared returns a boolean indicating if a field with the given name was
  29413. // cleared in this mutation.
  29414. func (m *UsageStatisticDayMutation) FieldCleared(name string) bool {
  29415. _, ok := m.clearedFields[name]
  29416. return ok
  29417. }
  29418. // ClearField clears the value of the field with the given name. It returns an
  29419. // error if the field is not defined in the schema.
  29420. func (m *UsageStatisticDayMutation) ClearField(name string) error {
  29421. switch name {
  29422. case usagestatisticday.FieldStatus:
  29423. m.ClearStatus()
  29424. return nil
  29425. case usagestatisticday.FieldDeletedAt:
  29426. m.ClearDeletedAt()
  29427. return nil
  29428. case usagestatisticday.FieldBotID:
  29429. m.ClearBotID()
  29430. return nil
  29431. case usagestatisticday.FieldOrganizationID:
  29432. m.ClearOrganizationID()
  29433. return nil
  29434. }
  29435. return fmt.Errorf("unknown UsageStatisticDay nullable field %s", name)
  29436. }
  29437. // ResetField resets all changes in the mutation for the field with the given name.
  29438. // It returns an error if the field is not defined in the schema.
  29439. func (m *UsageStatisticDayMutation) ResetField(name string) error {
  29440. switch name {
  29441. case usagestatisticday.FieldCreatedAt:
  29442. m.ResetCreatedAt()
  29443. return nil
  29444. case usagestatisticday.FieldUpdatedAt:
  29445. m.ResetUpdatedAt()
  29446. return nil
  29447. case usagestatisticday.FieldStatus:
  29448. m.ResetStatus()
  29449. return nil
  29450. case usagestatisticday.FieldDeletedAt:
  29451. m.ResetDeletedAt()
  29452. return nil
  29453. case usagestatisticday.FieldAddtime:
  29454. m.ResetAddtime()
  29455. return nil
  29456. case usagestatisticday.FieldType:
  29457. m.ResetType()
  29458. return nil
  29459. case usagestatisticday.FieldBotID:
  29460. m.ResetBotID()
  29461. return nil
  29462. case usagestatisticday.FieldOrganizationID:
  29463. m.ResetOrganizationID()
  29464. return nil
  29465. case usagestatisticday.FieldAiResponse:
  29466. m.ResetAiResponse()
  29467. return nil
  29468. case usagestatisticday.FieldSopRun:
  29469. m.ResetSopRun()
  29470. return nil
  29471. case usagestatisticday.FieldTotalFriend:
  29472. m.ResetTotalFriend()
  29473. return nil
  29474. case usagestatisticday.FieldTotalGroup:
  29475. m.ResetTotalGroup()
  29476. return nil
  29477. case usagestatisticday.FieldAccountBalance:
  29478. m.ResetAccountBalance()
  29479. return nil
  29480. case usagestatisticday.FieldConsumeToken:
  29481. m.ResetConsumeToken()
  29482. return nil
  29483. case usagestatisticday.FieldActiveUser:
  29484. m.ResetActiveUser()
  29485. return nil
  29486. case usagestatisticday.FieldNewUser:
  29487. m.ResetNewUser()
  29488. return nil
  29489. case usagestatisticday.FieldLabelDist:
  29490. m.ResetLabelDist()
  29491. return nil
  29492. }
  29493. return fmt.Errorf("unknown UsageStatisticDay field %s", name)
  29494. }
  29495. // AddedEdges returns all edge names that were set/added in this mutation.
  29496. func (m *UsageStatisticDayMutation) AddedEdges() []string {
  29497. edges := make([]string, 0, 0)
  29498. return edges
  29499. }
  29500. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  29501. // name in this mutation.
  29502. func (m *UsageStatisticDayMutation) AddedIDs(name string) []ent.Value {
  29503. return nil
  29504. }
  29505. // RemovedEdges returns all edge names that were removed in this mutation.
  29506. func (m *UsageStatisticDayMutation) RemovedEdges() []string {
  29507. edges := make([]string, 0, 0)
  29508. return edges
  29509. }
  29510. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  29511. // the given name in this mutation.
  29512. func (m *UsageStatisticDayMutation) RemovedIDs(name string) []ent.Value {
  29513. return nil
  29514. }
  29515. // ClearedEdges returns all edge names that were cleared in this mutation.
  29516. func (m *UsageStatisticDayMutation) ClearedEdges() []string {
  29517. edges := make([]string, 0, 0)
  29518. return edges
  29519. }
  29520. // EdgeCleared returns a boolean which indicates if the edge with the given name
  29521. // was cleared in this mutation.
  29522. func (m *UsageStatisticDayMutation) EdgeCleared(name string) bool {
  29523. return false
  29524. }
  29525. // ClearEdge clears the value of the edge with the given name. It returns an error
  29526. // if that edge is not defined in the schema.
  29527. func (m *UsageStatisticDayMutation) ClearEdge(name string) error {
  29528. return fmt.Errorf("unknown UsageStatisticDay unique edge %s", name)
  29529. }
  29530. // ResetEdge resets all changes to the edge with the given name in this mutation.
  29531. // It returns an error if the edge is not defined in the schema.
  29532. func (m *UsageStatisticDayMutation) ResetEdge(name string) error {
  29533. return fmt.Errorf("unknown UsageStatisticDay edge %s", name)
  29534. }
  29535. // UsageStatisticHourMutation represents an operation that mutates the UsageStatisticHour nodes in the graph.
  29536. type UsageStatisticHourMutation struct {
  29537. config
  29538. op Op
  29539. typ string
  29540. id *uint64
  29541. created_at *time.Time
  29542. updated_at *time.Time
  29543. status *uint8
  29544. addstatus *int8
  29545. deleted_at *time.Time
  29546. addtime *uint64
  29547. addaddtime *int64
  29548. _type *int
  29549. add_type *int
  29550. bot_id *string
  29551. organization_id *uint64
  29552. addorganization_id *int64
  29553. ai_response *uint64
  29554. addai_response *int64
  29555. sop_run *uint64
  29556. addsop_run *int64
  29557. total_friend *uint64
  29558. addtotal_friend *int64
  29559. total_group *uint64
  29560. addtotal_group *int64
  29561. account_balance *uint64
  29562. addaccount_balance *int64
  29563. consume_token *uint64
  29564. addconsume_token *int64
  29565. active_user *uint64
  29566. addactive_user *int64
  29567. new_user *int64
  29568. addnew_user *int64
  29569. label_dist *[]custom_types.LabelDist
  29570. appendlabel_dist []custom_types.LabelDist
  29571. clearedFields map[string]struct{}
  29572. done bool
  29573. oldValue func(context.Context) (*UsageStatisticHour, error)
  29574. predicates []predicate.UsageStatisticHour
  29575. }
  29576. var _ ent.Mutation = (*UsageStatisticHourMutation)(nil)
  29577. // usagestatistichourOption allows management of the mutation configuration using functional options.
  29578. type usagestatistichourOption func(*UsageStatisticHourMutation)
  29579. // newUsageStatisticHourMutation creates new mutation for the UsageStatisticHour entity.
  29580. func newUsageStatisticHourMutation(c config, op Op, opts ...usagestatistichourOption) *UsageStatisticHourMutation {
  29581. m := &UsageStatisticHourMutation{
  29582. config: c,
  29583. op: op,
  29584. typ: TypeUsageStatisticHour,
  29585. clearedFields: make(map[string]struct{}),
  29586. }
  29587. for _, opt := range opts {
  29588. opt(m)
  29589. }
  29590. return m
  29591. }
  29592. // withUsageStatisticHourID sets the ID field of the mutation.
  29593. func withUsageStatisticHourID(id uint64) usagestatistichourOption {
  29594. return func(m *UsageStatisticHourMutation) {
  29595. var (
  29596. err error
  29597. once sync.Once
  29598. value *UsageStatisticHour
  29599. )
  29600. m.oldValue = func(ctx context.Context) (*UsageStatisticHour, error) {
  29601. once.Do(func() {
  29602. if m.done {
  29603. err = errors.New("querying old values post mutation is not allowed")
  29604. } else {
  29605. value, err = m.Client().UsageStatisticHour.Get(ctx, id)
  29606. }
  29607. })
  29608. return value, err
  29609. }
  29610. m.id = &id
  29611. }
  29612. }
  29613. // withUsageStatisticHour sets the old UsageStatisticHour of the mutation.
  29614. func withUsageStatisticHour(node *UsageStatisticHour) usagestatistichourOption {
  29615. return func(m *UsageStatisticHourMutation) {
  29616. m.oldValue = func(context.Context) (*UsageStatisticHour, error) {
  29617. return node, nil
  29618. }
  29619. m.id = &node.ID
  29620. }
  29621. }
  29622. // Client returns a new `ent.Client` from the mutation. If the mutation was
  29623. // executed in a transaction (ent.Tx), a transactional client is returned.
  29624. func (m UsageStatisticHourMutation) Client() *Client {
  29625. client := &Client{config: m.config}
  29626. client.init()
  29627. return client
  29628. }
  29629. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  29630. // it returns an error otherwise.
  29631. func (m UsageStatisticHourMutation) Tx() (*Tx, error) {
  29632. if _, ok := m.driver.(*txDriver); !ok {
  29633. return nil, errors.New("ent: mutation is not running in a transaction")
  29634. }
  29635. tx := &Tx{config: m.config}
  29636. tx.init()
  29637. return tx, nil
  29638. }
  29639. // SetID sets the value of the id field. Note that this
  29640. // operation is only accepted on creation of UsageStatisticHour entities.
  29641. func (m *UsageStatisticHourMutation) SetID(id uint64) {
  29642. m.id = &id
  29643. }
  29644. // ID returns the ID value in the mutation. Note that the ID is only available
  29645. // if it was provided to the builder or after it was returned from the database.
  29646. func (m *UsageStatisticHourMutation) ID() (id uint64, exists bool) {
  29647. if m.id == nil {
  29648. return
  29649. }
  29650. return *m.id, true
  29651. }
  29652. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  29653. // That means, if the mutation is applied within a transaction with an isolation level such
  29654. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  29655. // or updated by the mutation.
  29656. func (m *UsageStatisticHourMutation) IDs(ctx context.Context) ([]uint64, error) {
  29657. switch {
  29658. case m.op.Is(OpUpdateOne | OpDeleteOne):
  29659. id, exists := m.ID()
  29660. if exists {
  29661. return []uint64{id}, nil
  29662. }
  29663. fallthrough
  29664. case m.op.Is(OpUpdate | OpDelete):
  29665. return m.Client().UsageStatisticHour.Query().Where(m.predicates...).IDs(ctx)
  29666. default:
  29667. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  29668. }
  29669. }
  29670. // SetCreatedAt sets the "created_at" field.
  29671. func (m *UsageStatisticHourMutation) SetCreatedAt(t time.Time) {
  29672. m.created_at = &t
  29673. }
  29674. // CreatedAt returns the value of the "created_at" field in the mutation.
  29675. func (m *UsageStatisticHourMutation) CreatedAt() (r time.Time, exists bool) {
  29676. v := m.created_at
  29677. if v == nil {
  29678. return
  29679. }
  29680. return *v, true
  29681. }
  29682. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticHour entity.
  29683. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29684. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29685. func (m *UsageStatisticHourMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  29686. if !m.op.Is(OpUpdateOne) {
  29687. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  29688. }
  29689. if m.id == nil || m.oldValue == nil {
  29690. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  29691. }
  29692. oldValue, err := m.oldValue(ctx)
  29693. if err != nil {
  29694. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  29695. }
  29696. return oldValue.CreatedAt, nil
  29697. }
  29698. // ResetCreatedAt resets all changes to the "created_at" field.
  29699. func (m *UsageStatisticHourMutation) ResetCreatedAt() {
  29700. m.created_at = nil
  29701. }
  29702. // SetUpdatedAt sets the "updated_at" field.
  29703. func (m *UsageStatisticHourMutation) SetUpdatedAt(t time.Time) {
  29704. m.updated_at = &t
  29705. }
  29706. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  29707. func (m *UsageStatisticHourMutation) UpdatedAt() (r time.Time, exists bool) {
  29708. v := m.updated_at
  29709. if v == nil {
  29710. return
  29711. }
  29712. return *v, true
  29713. }
  29714. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticHour entity.
  29715. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29716. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29717. func (m *UsageStatisticHourMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  29718. if !m.op.Is(OpUpdateOne) {
  29719. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  29720. }
  29721. if m.id == nil || m.oldValue == nil {
  29722. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  29723. }
  29724. oldValue, err := m.oldValue(ctx)
  29725. if err != nil {
  29726. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  29727. }
  29728. return oldValue.UpdatedAt, nil
  29729. }
  29730. // ResetUpdatedAt resets all changes to the "updated_at" field.
  29731. func (m *UsageStatisticHourMutation) ResetUpdatedAt() {
  29732. m.updated_at = nil
  29733. }
  29734. // SetStatus sets the "status" field.
  29735. func (m *UsageStatisticHourMutation) SetStatus(u uint8) {
  29736. m.status = &u
  29737. m.addstatus = nil
  29738. }
  29739. // Status returns the value of the "status" field in the mutation.
  29740. func (m *UsageStatisticHourMutation) Status() (r uint8, exists bool) {
  29741. v := m.status
  29742. if v == nil {
  29743. return
  29744. }
  29745. return *v, true
  29746. }
  29747. // OldStatus returns the old "status" field's value of the UsageStatisticHour entity.
  29748. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29749. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29750. func (m *UsageStatisticHourMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  29751. if !m.op.Is(OpUpdateOne) {
  29752. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  29753. }
  29754. if m.id == nil || m.oldValue == nil {
  29755. return v, errors.New("OldStatus requires an ID field in the mutation")
  29756. }
  29757. oldValue, err := m.oldValue(ctx)
  29758. if err != nil {
  29759. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  29760. }
  29761. return oldValue.Status, nil
  29762. }
  29763. // AddStatus adds u to the "status" field.
  29764. func (m *UsageStatisticHourMutation) AddStatus(u int8) {
  29765. if m.addstatus != nil {
  29766. *m.addstatus += u
  29767. } else {
  29768. m.addstatus = &u
  29769. }
  29770. }
  29771. // AddedStatus returns the value that was added to the "status" field in this mutation.
  29772. func (m *UsageStatisticHourMutation) AddedStatus() (r int8, exists bool) {
  29773. v := m.addstatus
  29774. if v == nil {
  29775. return
  29776. }
  29777. return *v, true
  29778. }
  29779. // ClearStatus clears the value of the "status" field.
  29780. func (m *UsageStatisticHourMutation) ClearStatus() {
  29781. m.status = nil
  29782. m.addstatus = nil
  29783. m.clearedFields[usagestatistichour.FieldStatus] = struct{}{}
  29784. }
  29785. // StatusCleared returns if the "status" field was cleared in this mutation.
  29786. func (m *UsageStatisticHourMutation) StatusCleared() bool {
  29787. _, ok := m.clearedFields[usagestatistichour.FieldStatus]
  29788. return ok
  29789. }
  29790. // ResetStatus resets all changes to the "status" field.
  29791. func (m *UsageStatisticHourMutation) ResetStatus() {
  29792. m.status = nil
  29793. m.addstatus = nil
  29794. delete(m.clearedFields, usagestatistichour.FieldStatus)
  29795. }
  29796. // SetDeletedAt sets the "deleted_at" field.
  29797. func (m *UsageStatisticHourMutation) SetDeletedAt(t time.Time) {
  29798. m.deleted_at = &t
  29799. }
  29800. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  29801. func (m *UsageStatisticHourMutation) DeletedAt() (r time.Time, exists bool) {
  29802. v := m.deleted_at
  29803. if v == nil {
  29804. return
  29805. }
  29806. return *v, true
  29807. }
  29808. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticHour entity.
  29809. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29810. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29811. func (m *UsageStatisticHourMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  29812. if !m.op.Is(OpUpdateOne) {
  29813. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  29814. }
  29815. if m.id == nil || m.oldValue == nil {
  29816. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  29817. }
  29818. oldValue, err := m.oldValue(ctx)
  29819. if err != nil {
  29820. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  29821. }
  29822. return oldValue.DeletedAt, nil
  29823. }
  29824. // ClearDeletedAt clears the value of the "deleted_at" field.
  29825. func (m *UsageStatisticHourMutation) ClearDeletedAt() {
  29826. m.deleted_at = nil
  29827. m.clearedFields[usagestatistichour.FieldDeletedAt] = struct{}{}
  29828. }
  29829. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  29830. func (m *UsageStatisticHourMutation) DeletedAtCleared() bool {
  29831. _, ok := m.clearedFields[usagestatistichour.FieldDeletedAt]
  29832. return ok
  29833. }
  29834. // ResetDeletedAt resets all changes to the "deleted_at" field.
  29835. func (m *UsageStatisticHourMutation) ResetDeletedAt() {
  29836. m.deleted_at = nil
  29837. delete(m.clearedFields, usagestatistichour.FieldDeletedAt)
  29838. }
  29839. // SetAddtime sets the "addtime" field.
  29840. func (m *UsageStatisticHourMutation) SetAddtime(u uint64) {
  29841. m.addtime = &u
  29842. m.addaddtime = nil
  29843. }
  29844. // Addtime returns the value of the "addtime" field in the mutation.
  29845. func (m *UsageStatisticHourMutation) Addtime() (r uint64, exists bool) {
  29846. v := m.addtime
  29847. if v == nil {
  29848. return
  29849. }
  29850. return *v, true
  29851. }
  29852. // OldAddtime returns the old "addtime" field's value of the UsageStatisticHour entity.
  29853. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29854. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29855. func (m *UsageStatisticHourMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  29856. if !m.op.Is(OpUpdateOne) {
  29857. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  29858. }
  29859. if m.id == nil || m.oldValue == nil {
  29860. return v, errors.New("OldAddtime requires an ID field in the mutation")
  29861. }
  29862. oldValue, err := m.oldValue(ctx)
  29863. if err != nil {
  29864. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  29865. }
  29866. return oldValue.Addtime, nil
  29867. }
  29868. // AddAddtime adds u to the "addtime" field.
  29869. func (m *UsageStatisticHourMutation) AddAddtime(u int64) {
  29870. if m.addaddtime != nil {
  29871. *m.addaddtime += u
  29872. } else {
  29873. m.addaddtime = &u
  29874. }
  29875. }
  29876. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  29877. func (m *UsageStatisticHourMutation) AddedAddtime() (r int64, exists bool) {
  29878. v := m.addaddtime
  29879. if v == nil {
  29880. return
  29881. }
  29882. return *v, true
  29883. }
  29884. // ResetAddtime resets all changes to the "addtime" field.
  29885. func (m *UsageStatisticHourMutation) ResetAddtime() {
  29886. m.addtime = nil
  29887. m.addaddtime = nil
  29888. }
  29889. // SetType sets the "type" field.
  29890. func (m *UsageStatisticHourMutation) SetType(i int) {
  29891. m._type = &i
  29892. m.add_type = nil
  29893. }
  29894. // GetType returns the value of the "type" field in the mutation.
  29895. func (m *UsageStatisticHourMutation) GetType() (r int, exists bool) {
  29896. v := m._type
  29897. if v == nil {
  29898. return
  29899. }
  29900. return *v, true
  29901. }
  29902. // OldType returns the old "type" field's value of the UsageStatisticHour entity.
  29903. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29904. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29905. func (m *UsageStatisticHourMutation) OldType(ctx context.Context) (v int, err error) {
  29906. if !m.op.Is(OpUpdateOne) {
  29907. return v, errors.New("OldType is only allowed on UpdateOne operations")
  29908. }
  29909. if m.id == nil || m.oldValue == nil {
  29910. return v, errors.New("OldType requires an ID field in the mutation")
  29911. }
  29912. oldValue, err := m.oldValue(ctx)
  29913. if err != nil {
  29914. return v, fmt.Errorf("querying old value for OldType: %w", err)
  29915. }
  29916. return oldValue.Type, nil
  29917. }
  29918. // AddType adds i to the "type" field.
  29919. func (m *UsageStatisticHourMutation) AddType(i int) {
  29920. if m.add_type != nil {
  29921. *m.add_type += i
  29922. } else {
  29923. m.add_type = &i
  29924. }
  29925. }
  29926. // AddedType returns the value that was added to the "type" field in this mutation.
  29927. func (m *UsageStatisticHourMutation) AddedType() (r int, exists bool) {
  29928. v := m.add_type
  29929. if v == nil {
  29930. return
  29931. }
  29932. return *v, true
  29933. }
  29934. // ResetType resets all changes to the "type" field.
  29935. func (m *UsageStatisticHourMutation) ResetType() {
  29936. m._type = nil
  29937. m.add_type = nil
  29938. }
  29939. // SetBotID sets the "bot_id" field.
  29940. func (m *UsageStatisticHourMutation) SetBotID(s string) {
  29941. m.bot_id = &s
  29942. }
  29943. // BotID returns the value of the "bot_id" field in the mutation.
  29944. func (m *UsageStatisticHourMutation) BotID() (r string, exists bool) {
  29945. v := m.bot_id
  29946. if v == nil {
  29947. return
  29948. }
  29949. return *v, true
  29950. }
  29951. // OldBotID returns the old "bot_id" field's value of the UsageStatisticHour entity.
  29952. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29953. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29954. func (m *UsageStatisticHourMutation) OldBotID(ctx context.Context) (v string, err error) {
  29955. if !m.op.Is(OpUpdateOne) {
  29956. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  29957. }
  29958. if m.id == nil || m.oldValue == nil {
  29959. return v, errors.New("OldBotID requires an ID field in the mutation")
  29960. }
  29961. oldValue, err := m.oldValue(ctx)
  29962. if err != nil {
  29963. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  29964. }
  29965. return oldValue.BotID, nil
  29966. }
  29967. // ClearBotID clears the value of the "bot_id" field.
  29968. func (m *UsageStatisticHourMutation) ClearBotID() {
  29969. m.bot_id = nil
  29970. m.clearedFields[usagestatistichour.FieldBotID] = struct{}{}
  29971. }
  29972. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  29973. func (m *UsageStatisticHourMutation) BotIDCleared() bool {
  29974. _, ok := m.clearedFields[usagestatistichour.FieldBotID]
  29975. return ok
  29976. }
  29977. // ResetBotID resets all changes to the "bot_id" field.
  29978. func (m *UsageStatisticHourMutation) ResetBotID() {
  29979. m.bot_id = nil
  29980. delete(m.clearedFields, usagestatistichour.FieldBotID)
  29981. }
  29982. // SetOrganizationID sets the "organization_id" field.
  29983. func (m *UsageStatisticHourMutation) SetOrganizationID(u uint64) {
  29984. m.organization_id = &u
  29985. m.addorganization_id = nil
  29986. }
  29987. // OrganizationID returns the value of the "organization_id" field in the mutation.
  29988. func (m *UsageStatisticHourMutation) OrganizationID() (r uint64, exists bool) {
  29989. v := m.organization_id
  29990. if v == nil {
  29991. return
  29992. }
  29993. return *v, true
  29994. }
  29995. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticHour entity.
  29996. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  29997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  29998. func (m *UsageStatisticHourMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  29999. if !m.op.Is(OpUpdateOne) {
  30000. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  30001. }
  30002. if m.id == nil || m.oldValue == nil {
  30003. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  30004. }
  30005. oldValue, err := m.oldValue(ctx)
  30006. if err != nil {
  30007. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  30008. }
  30009. return oldValue.OrganizationID, nil
  30010. }
  30011. // AddOrganizationID adds u to the "organization_id" field.
  30012. func (m *UsageStatisticHourMutation) AddOrganizationID(u int64) {
  30013. if m.addorganization_id != nil {
  30014. *m.addorganization_id += u
  30015. } else {
  30016. m.addorganization_id = &u
  30017. }
  30018. }
  30019. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  30020. func (m *UsageStatisticHourMutation) AddedOrganizationID() (r int64, exists bool) {
  30021. v := m.addorganization_id
  30022. if v == nil {
  30023. return
  30024. }
  30025. return *v, true
  30026. }
  30027. // ClearOrganizationID clears the value of the "organization_id" field.
  30028. func (m *UsageStatisticHourMutation) ClearOrganizationID() {
  30029. m.organization_id = nil
  30030. m.addorganization_id = nil
  30031. m.clearedFields[usagestatistichour.FieldOrganizationID] = struct{}{}
  30032. }
  30033. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  30034. func (m *UsageStatisticHourMutation) OrganizationIDCleared() bool {
  30035. _, ok := m.clearedFields[usagestatistichour.FieldOrganizationID]
  30036. return ok
  30037. }
  30038. // ResetOrganizationID resets all changes to the "organization_id" field.
  30039. func (m *UsageStatisticHourMutation) ResetOrganizationID() {
  30040. m.organization_id = nil
  30041. m.addorganization_id = nil
  30042. delete(m.clearedFields, usagestatistichour.FieldOrganizationID)
  30043. }
  30044. // SetAiResponse sets the "ai_response" field.
  30045. func (m *UsageStatisticHourMutation) SetAiResponse(u uint64) {
  30046. m.ai_response = &u
  30047. m.addai_response = nil
  30048. }
  30049. // AiResponse returns the value of the "ai_response" field in the mutation.
  30050. func (m *UsageStatisticHourMutation) AiResponse() (r uint64, exists bool) {
  30051. v := m.ai_response
  30052. if v == nil {
  30053. return
  30054. }
  30055. return *v, true
  30056. }
  30057. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticHour entity.
  30058. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30059. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30060. func (m *UsageStatisticHourMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  30061. if !m.op.Is(OpUpdateOne) {
  30062. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  30063. }
  30064. if m.id == nil || m.oldValue == nil {
  30065. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  30066. }
  30067. oldValue, err := m.oldValue(ctx)
  30068. if err != nil {
  30069. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  30070. }
  30071. return oldValue.AiResponse, nil
  30072. }
  30073. // AddAiResponse adds u to the "ai_response" field.
  30074. func (m *UsageStatisticHourMutation) AddAiResponse(u int64) {
  30075. if m.addai_response != nil {
  30076. *m.addai_response += u
  30077. } else {
  30078. m.addai_response = &u
  30079. }
  30080. }
  30081. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  30082. func (m *UsageStatisticHourMutation) AddedAiResponse() (r int64, exists bool) {
  30083. v := m.addai_response
  30084. if v == nil {
  30085. return
  30086. }
  30087. return *v, true
  30088. }
  30089. // ResetAiResponse resets all changes to the "ai_response" field.
  30090. func (m *UsageStatisticHourMutation) ResetAiResponse() {
  30091. m.ai_response = nil
  30092. m.addai_response = nil
  30093. }
  30094. // SetSopRun sets the "sop_run" field.
  30095. func (m *UsageStatisticHourMutation) SetSopRun(u uint64) {
  30096. m.sop_run = &u
  30097. m.addsop_run = nil
  30098. }
  30099. // SopRun returns the value of the "sop_run" field in the mutation.
  30100. func (m *UsageStatisticHourMutation) SopRun() (r uint64, exists bool) {
  30101. v := m.sop_run
  30102. if v == nil {
  30103. return
  30104. }
  30105. return *v, true
  30106. }
  30107. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticHour entity.
  30108. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30109. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30110. func (m *UsageStatisticHourMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  30111. if !m.op.Is(OpUpdateOne) {
  30112. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  30113. }
  30114. if m.id == nil || m.oldValue == nil {
  30115. return v, errors.New("OldSopRun requires an ID field in the mutation")
  30116. }
  30117. oldValue, err := m.oldValue(ctx)
  30118. if err != nil {
  30119. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  30120. }
  30121. return oldValue.SopRun, nil
  30122. }
  30123. // AddSopRun adds u to the "sop_run" field.
  30124. func (m *UsageStatisticHourMutation) AddSopRun(u int64) {
  30125. if m.addsop_run != nil {
  30126. *m.addsop_run += u
  30127. } else {
  30128. m.addsop_run = &u
  30129. }
  30130. }
  30131. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  30132. func (m *UsageStatisticHourMutation) AddedSopRun() (r int64, exists bool) {
  30133. v := m.addsop_run
  30134. if v == nil {
  30135. return
  30136. }
  30137. return *v, true
  30138. }
  30139. // ResetSopRun resets all changes to the "sop_run" field.
  30140. func (m *UsageStatisticHourMutation) ResetSopRun() {
  30141. m.sop_run = nil
  30142. m.addsop_run = nil
  30143. }
  30144. // SetTotalFriend sets the "total_friend" field.
  30145. func (m *UsageStatisticHourMutation) SetTotalFriend(u uint64) {
  30146. m.total_friend = &u
  30147. m.addtotal_friend = nil
  30148. }
  30149. // TotalFriend returns the value of the "total_friend" field in the mutation.
  30150. func (m *UsageStatisticHourMutation) TotalFriend() (r uint64, exists bool) {
  30151. v := m.total_friend
  30152. if v == nil {
  30153. return
  30154. }
  30155. return *v, true
  30156. }
  30157. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticHour entity.
  30158. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30159. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30160. func (m *UsageStatisticHourMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  30161. if !m.op.Is(OpUpdateOne) {
  30162. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  30163. }
  30164. if m.id == nil || m.oldValue == nil {
  30165. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  30166. }
  30167. oldValue, err := m.oldValue(ctx)
  30168. if err != nil {
  30169. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  30170. }
  30171. return oldValue.TotalFriend, nil
  30172. }
  30173. // AddTotalFriend adds u to the "total_friend" field.
  30174. func (m *UsageStatisticHourMutation) AddTotalFriend(u int64) {
  30175. if m.addtotal_friend != nil {
  30176. *m.addtotal_friend += u
  30177. } else {
  30178. m.addtotal_friend = &u
  30179. }
  30180. }
  30181. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  30182. func (m *UsageStatisticHourMutation) AddedTotalFriend() (r int64, exists bool) {
  30183. v := m.addtotal_friend
  30184. if v == nil {
  30185. return
  30186. }
  30187. return *v, true
  30188. }
  30189. // ResetTotalFriend resets all changes to the "total_friend" field.
  30190. func (m *UsageStatisticHourMutation) ResetTotalFriend() {
  30191. m.total_friend = nil
  30192. m.addtotal_friend = nil
  30193. }
  30194. // SetTotalGroup sets the "total_group" field.
  30195. func (m *UsageStatisticHourMutation) SetTotalGroup(u uint64) {
  30196. m.total_group = &u
  30197. m.addtotal_group = nil
  30198. }
  30199. // TotalGroup returns the value of the "total_group" field in the mutation.
  30200. func (m *UsageStatisticHourMutation) TotalGroup() (r uint64, exists bool) {
  30201. v := m.total_group
  30202. if v == nil {
  30203. return
  30204. }
  30205. return *v, true
  30206. }
  30207. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticHour entity.
  30208. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30209. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30210. func (m *UsageStatisticHourMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  30211. if !m.op.Is(OpUpdateOne) {
  30212. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  30213. }
  30214. if m.id == nil || m.oldValue == nil {
  30215. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  30216. }
  30217. oldValue, err := m.oldValue(ctx)
  30218. if err != nil {
  30219. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  30220. }
  30221. return oldValue.TotalGroup, nil
  30222. }
  30223. // AddTotalGroup adds u to the "total_group" field.
  30224. func (m *UsageStatisticHourMutation) AddTotalGroup(u int64) {
  30225. if m.addtotal_group != nil {
  30226. *m.addtotal_group += u
  30227. } else {
  30228. m.addtotal_group = &u
  30229. }
  30230. }
  30231. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  30232. func (m *UsageStatisticHourMutation) AddedTotalGroup() (r int64, exists bool) {
  30233. v := m.addtotal_group
  30234. if v == nil {
  30235. return
  30236. }
  30237. return *v, true
  30238. }
  30239. // ResetTotalGroup resets all changes to the "total_group" field.
  30240. func (m *UsageStatisticHourMutation) ResetTotalGroup() {
  30241. m.total_group = nil
  30242. m.addtotal_group = nil
  30243. }
  30244. // SetAccountBalance sets the "account_balance" field.
  30245. func (m *UsageStatisticHourMutation) SetAccountBalance(u uint64) {
  30246. m.account_balance = &u
  30247. m.addaccount_balance = nil
  30248. }
  30249. // AccountBalance returns the value of the "account_balance" field in the mutation.
  30250. func (m *UsageStatisticHourMutation) AccountBalance() (r uint64, exists bool) {
  30251. v := m.account_balance
  30252. if v == nil {
  30253. return
  30254. }
  30255. return *v, true
  30256. }
  30257. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticHour entity.
  30258. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30259. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30260. func (m *UsageStatisticHourMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  30261. if !m.op.Is(OpUpdateOne) {
  30262. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  30263. }
  30264. if m.id == nil || m.oldValue == nil {
  30265. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  30266. }
  30267. oldValue, err := m.oldValue(ctx)
  30268. if err != nil {
  30269. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  30270. }
  30271. return oldValue.AccountBalance, nil
  30272. }
  30273. // AddAccountBalance adds u to the "account_balance" field.
  30274. func (m *UsageStatisticHourMutation) AddAccountBalance(u int64) {
  30275. if m.addaccount_balance != nil {
  30276. *m.addaccount_balance += u
  30277. } else {
  30278. m.addaccount_balance = &u
  30279. }
  30280. }
  30281. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  30282. func (m *UsageStatisticHourMutation) AddedAccountBalance() (r int64, exists bool) {
  30283. v := m.addaccount_balance
  30284. if v == nil {
  30285. return
  30286. }
  30287. return *v, true
  30288. }
  30289. // ResetAccountBalance resets all changes to the "account_balance" field.
  30290. func (m *UsageStatisticHourMutation) ResetAccountBalance() {
  30291. m.account_balance = nil
  30292. m.addaccount_balance = nil
  30293. }
  30294. // SetConsumeToken sets the "consume_token" field.
  30295. func (m *UsageStatisticHourMutation) SetConsumeToken(u uint64) {
  30296. m.consume_token = &u
  30297. m.addconsume_token = nil
  30298. }
  30299. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  30300. func (m *UsageStatisticHourMutation) ConsumeToken() (r uint64, exists bool) {
  30301. v := m.consume_token
  30302. if v == nil {
  30303. return
  30304. }
  30305. return *v, true
  30306. }
  30307. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticHour entity.
  30308. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30310. func (m *UsageStatisticHourMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  30311. if !m.op.Is(OpUpdateOne) {
  30312. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  30313. }
  30314. if m.id == nil || m.oldValue == nil {
  30315. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  30316. }
  30317. oldValue, err := m.oldValue(ctx)
  30318. if err != nil {
  30319. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  30320. }
  30321. return oldValue.ConsumeToken, nil
  30322. }
  30323. // AddConsumeToken adds u to the "consume_token" field.
  30324. func (m *UsageStatisticHourMutation) AddConsumeToken(u int64) {
  30325. if m.addconsume_token != nil {
  30326. *m.addconsume_token += u
  30327. } else {
  30328. m.addconsume_token = &u
  30329. }
  30330. }
  30331. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  30332. func (m *UsageStatisticHourMutation) AddedConsumeToken() (r int64, exists bool) {
  30333. v := m.addconsume_token
  30334. if v == nil {
  30335. return
  30336. }
  30337. return *v, true
  30338. }
  30339. // ResetConsumeToken resets all changes to the "consume_token" field.
  30340. func (m *UsageStatisticHourMutation) ResetConsumeToken() {
  30341. m.consume_token = nil
  30342. m.addconsume_token = nil
  30343. }
  30344. // SetActiveUser sets the "active_user" field.
  30345. func (m *UsageStatisticHourMutation) SetActiveUser(u uint64) {
  30346. m.active_user = &u
  30347. m.addactive_user = nil
  30348. }
  30349. // ActiveUser returns the value of the "active_user" field in the mutation.
  30350. func (m *UsageStatisticHourMutation) ActiveUser() (r uint64, exists bool) {
  30351. v := m.active_user
  30352. if v == nil {
  30353. return
  30354. }
  30355. return *v, true
  30356. }
  30357. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticHour entity.
  30358. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30359. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30360. func (m *UsageStatisticHourMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  30361. if !m.op.Is(OpUpdateOne) {
  30362. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  30363. }
  30364. if m.id == nil || m.oldValue == nil {
  30365. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  30366. }
  30367. oldValue, err := m.oldValue(ctx)
  30368. if err != nil {
  30369. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  30370. }
  30371. return oldValue.ActiveUser, nil
  30372. }
  30373. // AddActiveUser adds u to the "active_user" field.
  30374. func (m *UsageStatisticHourMutation) AddActiveUser(u int64) {
  30375. if m.addactive_user != nil {
  30376. *m.addactive_user += u
  30377. } else {
  30378. m.addactive_user = &u
  30379. }
  30380. }
  30381. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  30382. func (m *UsageStatisticHourMutation) AddedActiveUser() (r int64, exists bool) {
  30383. v := m.addactive_user
  30384. if v == nil {
  30385. return
  30386. }
  30387. return *v, true
  30388. }
  30389. // ResetActiveUser resets all changes to the "active_user" field.
  30390. func (m *UsageStatisticHourMutation) ResetActiveUser() {
  30391. m.active_user = nil
  30392. m.addactive_user = nil
  30393. }
  30394. // SetNewUser sets the "new_user" field.
  30395. func (m *UsageStatisticHourMutation) SetNewUser(i int64) {
  30396. m.new_user = &i
  30397. m.addnew_user = nil
  30398. }
  30399. // NewUser returns the value of the "new_user" field in the mutation.
  30400. func (m *UsageStatisticHourMutation) NewUser() (r int64, exists bool) {
  30401. v := m.new_user
  30402. if v == nil {
  30403. return
  30404. }
  30405. return *v, true
  30406. }
  30407. // OldNewUser returns the old "new_user" field's value of the UsageStatisticHour entity.
  30408. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30410. func (m *UsageStatisticHourMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  30411. if !m.op.Is(OpUpdateOne) {
  30412. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  30413. }
  30414. if m.id == nil || m.oldValue == nil {
  30415. return v, errors.New("OldNewUser requires an ID field in the mutation")
  30416. }
  30417. oldValue, err := m.oldValue(ctx)
  30418. if err != nil {
  30419. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  30420. }
  30421. return oldValue.NewUser, nil
  30422. }
  30423. // AddNewUser adds i to the "new_user" field.
  30424. func (m *UsageStatisticHourMutation) AddNewUser(i int64) {
  30425. if m.addnew_user != nil {
  30426. *m.addnew_user += i
  30427. } else {
  30428. m.addnew_user = &i
  30429. }
  30430. }
  30431. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  30432. func (m *UsageStatisticHourMutation) AddedNewUser() (r int64, exists bool) {
  30433. v := m.addnew_user
  30434. if v == nil {
  30435. return
  30436. }
  30437. return *v, true
  30438. }
  30439. // ResetNewUser resets all changes to the "new_user" field.
  30440. func (m *UsageStatisticHourMutation) ResetNewUser() {
  30441. m.new_user = nil
  30442. m.addnew_user = nil
  30443. }
  30444. // SetLabelDist sets the "label_dist" field.
  30445. func (m *UsageStatisticHourMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  30446. m.label_dist = &ctd
  30447. m.appendlabel_dist = nil
  30448. }
  30449. // LabelDist returns the value of the "label_dist" field in the mutation.
  30450. func (m *UsageStatisticHourMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  30451. v := m.label_dist
  30452. if v == nil {
  30453. return
  30454. }
  30455. return *v, true
  30456. }
  30457. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticHour entity.
  30458. // If the UsageStatisticHour object wasn't provided to the builder, the object is fetched from the database.
  30459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  30460. func (m *UsageStatisticHourMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  30461. if !m.op.Is(OpUpdateOne) {
  30462. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  30463. }
  30464. if m.id == nil || m.oldValue == nil {
  30465. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  30466. }
  30467. oldValue, err := m.oldValue(ctx)
  30468. if err != nil {
  30469. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  30470. }
  30471. return oldValue.LabelDist, nil
  30472. }
  30473. // AppendLabelDist adds ctd to the "label_dist" field.
  30474. func (m *UsageStatisticHourMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  30475. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  30476. }
  30477. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  30478. func (m *UsageStatisticHourMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  30479. if len(m.appendlabel_dist) == 0 {
  30480. return nil, false
  30481. }
  30482. return m.appendlabel_dist, true
  30483. }
  30484. // ResetLabelDist resets all changes to the "label_dist" field.
  30485. func (m *UsageStatisticHourMutation) ResetLabelDist() {
  30486. m.label_dist = nil
  30487. m.appendlabel_dist = nil
  30488. }
  30489. // Where appends a list predicates to the UsageStatisticHourMutation builder.
  30490. func (m *UsageStatisticHourMutation) Where(ps ...predicate.UsageStatisticHour) {
  30491. m.predicates = append(m.predicates, ps...)
  30492. }
  30493. // WhereP appends storage-level predicates to the UsageStatisticHourMutation builder. Using this method,
  30494. // users can use type-assertion to append predicates that do not depend on any generated package.
  30495. func (m *UsageStatisticHourMutation) WhereP(ps ...func(*sql.Selector)) {
  30496. p := make([]predicate.UsageStatisticHour, len(ps))
  30497. for i := range ps {
  30498. p[i] = ps[i]
  30499. }
  30500. m.Where(p...)
  30501. }
  30502. // Op returns the operation name.
  30503. func (m *UsageStatisticHourMutation) Op() Op {
  30504. return m.op
  30505. }
  30506. // SetOp allows setting the mutation operation.
  30507. func (m *UsageStatisticHourMutation) SetOp(op Op) {
  30508. m.op = op
  30509. }
  30510. // Type returns the node type of this mutation (UsageStatisticHour).
  30511. func (m *UsageStatisticHourMutation) Type() string {
  30512. return m.typ
  30513. }
  30514. // Fields returns all fields that were changed during this mutation. Note that in
  30515. // order to get all numeric fields that were incremented/decremented, call
  30516. // AddedFields().
  30517. func (m *UsageStatisticHourMutation) Fields() []string {
  30518. fields := make([]string, 0, 17)
  30519. if m.created_at != nil {
  30520. fields = append(fields, usagestatistichour.FieldCreatedAt)
  30521. }
  30522. if m.updated_at != nil {
  30523. fields = append(fields, usagestatistichour.FieldUpdatedAt)
  30524. }
  30525. if m.status != nil {
  30526. fields = append(fields, usagestatistichour.FieldStatus)
  30527. }
  30528. if m.deleted_at != nil {
  30529. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30530. }
  30531. if m.addtime != nil {
  30532. fields = append(fields, usagestatistichour.FieldAddtime)
  30533. }
  30534. if m._type != nil {
  30535. fields = append(fields, usagestatistichour.FieldType)
  30536. }
  30537. if m.bot_id != nil {
  30538. fields = append(fields, usagestatistichour.FieldBotID)
  30539. }
  30540. if m.organization_id != nil {
  30541. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30542. }
  30543. if m.ai_response != nil {
  30544. fields = append(fields, usagestatistichour.FieldAiResponse)
  30545. }
  30546. if m.sop_run != nil {
  30547. fields = append(fields, usagestatistichour.FieldSopRun)
  30548. }
  30549. if m.total_friend != nil {
  30550. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30551. }
  30552. if m.total_group != nil {
  30553. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30554. }
  30555. if m.account_balance != nil {
  30556. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30557. }
  30558. if m.consume_token != nil {
  30559. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30560. }
  30561. if m.active_user != nil {
  30562. fields = append(fields, usagestatistichour.FieldActiveUser)
  30563. }
  30564. if m.new_user != nil {
  30565. fields = append(fields, usagestatistichour.FieldNewUser)
  30566. }
  30567. if m.label_dist != nil {
  30568. fields = append(fields, usagestatistichour.FieldLabelDist)
  30569. }
  30570. return fields
  30571. }
  30572. // Field returns the value of a field with the given name. The second boolean
  30573. // return value indicates that this field was not set, or was not defined in the
  30574. // schema.
  30575. func (m *UsageStatisticHourMutation) Field(name string) (ent.Value, bool) {
  30576. switch name {
  30577. case usagestatistichour.FieldCreatedAt:
  30578. return m.CreatedAt()
  30579. case usagestatistichour.FieldUpdatedAt:
  30580. return m.UpdatedAt()
  30581. case usagestatistichour.FieldStatus:
  30582. return m.Status()
  30583. case usagestatistichour.FieldDeletedAt:
  30584. return m.DeletedAt()
  30585. case usagestatistichour.FieldAddtime:
  30586. return m.Addtime()
  30587. case usagestatistichour.FieldType:
  30588. return m.GetType()
  30589. case usagestatistichour.FieldBotID:
  30590. return m.BotID()
  30591. case usagestatistichour.FieldOrganizationID:
  30592. return m.OrganizationID()
  30593. case usagestatistichour.FieldAiResponse:
  30594. return m.AiResponse()
  30595. case usagestatistichour.FieldSopRun:
  30596. return m.SopRun()
  30597. case usagestatistichour.FieldTotalFriend:
  30598. return m.TotalFriend()
  30599. case usagestatistichour.FieldTotalGroup:
  30600. return m.TotalGroup()
  30601. case usagestatistichour.FieldAccountBalance:
  30602. return m.AccountBalance()
  30603. case usagestatistichour.FieldConsumeToken:
  30604. return m.ConsumeToken()
  30605. case usagestatistichour.FieldActiveUser:
  30606. return m.ActiveUser()
  30607. case usagestatistichour.FieldNewUser:
  30608. return m.NewUser()
  30609. case usagestatistichour.FieldLabelDist:
  30610. return m.LabelDist()
  30611. }
  30612. return nil, false
  30613. }
  30614. // OldField returns the old value of the field from the database. An error is
  30615. // returned if the mutation operation is not UpdateOne, or the query to the
  30616. // database failed.
  30617. func (m *UsageStatisticHourMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  30618. switch name {
  30619. case usagestatistichour.FieldCreatedAt:
  30620. return m.OldCreatedAt(ctx)
  30621. case usagestatistichour.FieldUpdatedAt:
  30622. return m.OldUpdatedAt(ctx)
  30623. case usagestatistichour.FieldStatus:
  30624. return m.OldStatus(ctx)
  30625. case usagestatistichour.FieldDeletedAt:
  30626. return m.OldDeletedAt(ctx)
  30627. case usagestatistichour.FieldAddtime:
  30628. return m.OldAddtime(ctx)
  30629. case usagestatistichour.FieldType:
  30630. return m.OldType(ctx)
  30631. case usagestatistichour.FieldBotID:
  30632. return m.OldBotID(ctx)
  30633. case usagestatistichour.FieldOrganizationID:
  30634. return m.OldOrganizationID(ctx)
  30635. case usagestatistichour.FieldAiResponse:
  30636. return m.OldAiResponse(ctx)
  30637. case usagestatistichour.FieldSopRun:
  30638. return m.OldSopRun(ctx)
  30639. case usagestatistichour.FieldTotalFriend:
  30640. return m.OldTotalFriend(ctx)
  30641. case usagestatistichour.FieldTotalGroup:
  30642. return m.OldTotalGroup(ctx)
  30643. case usagestatistichour.FieldAccountBalance:
  30644. return m.OldAccountBalance(ctx)
  30645. case usagestatistichour.FieldConsumeToken:
  30646. return m.OldConsumeToken(ctx)
  30647. case usagestatistichour.FieldActiveUser:
  30648. return m.OldActiveUser(ctx)
  30649. case usagestatistichour.FieldNewUser:
  30650. return m.OldNewUser(ctx)
  30651. case usagestatistichour.FieldLabelDist:
  30652. return m.OldLabelDist(ctx)
  30653. }
  30654. return nil, fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30655. }
  30656. // SetField sets the value of a field with the given name. It returns an error if
  30657. // the field is not defined in the schema, or if the type mismatched the field
  30658. // type.
  30659. func (m *UsageStatisticHourMutation) SetField(name string, value ent.Value) error {
  30660. switch name {
  30661. case usagestatistichour.FieldCreatedAt:
  30662. v, ok := value.(time.Time)
  30663. if !ok {
  30664. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30665. }
  30666. m.SetCreatedAt(v)
  30667. return nil
  30668. case usagestatistichour.FieldUpdatedAt:
  30669. v, ok := value.(time.Time)
  30670. if !ok {
  30671. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30672. }
  30673. m.SetUpdatedAt(v)
  30674. return nil
  30675. case usagestatistichour.FieldStatus:
  30676. v, ok := value.(uint8)
  30677. if !ok {
  30678. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30679. }
  30680. m.SetStatus(v)
  30681. return nil
  30682. case usagestatistichour.FieldDeletedAt:
  30683. v, ok := value.(time.Time)
  30684. if !ok {
  30685. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30686. }
  30687. m.SetDeletedAt(v)
  30688. return nil
  30689. case usagestatistichour.FieldAddtime:
  30690. v, ok := value.(uint64)
  30691. if !ok {
  30692. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30693. }
  30694. m.SetAddtime(v)
  30695. return nil
  30696. case usagestatistichour.FieldType:
  30697. v, ok := value.(int)
  30698. if !ok {
  30699. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30700. }
  30701. m.SetType(v)
  30702. return nil
  30703. case usagestatistichour.FieldBotID:
  30704. v, ok := value.(string)
  30705. if !ok {
  30706. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30707. }
  30708. m.SetBotID(v)
  30709. return nil
  30710. case usagestatistichour.FieldOrganizationID:
  30711. v, ok := value.(uint64)
  30712. if !ok {
  30713. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30714. }
  30715. m.SetOrganizationID(v)
  30716. return nil
  30717. case usagestatistichour.FieldAiResponse:
  30718. v, ok := value.(uint64)
  30719. if !ok {
  30720. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30721. }
  30722. m.SetAiResponse(v)
  30723. return nil
  30724. case usagestatistichour.FieldSopRun:
  30725. v, ok := value.(uint64)
  30726. if !ok {
  30727. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30728. }
  30729. m.SetSopRun(v)
  30730. return nil
  30731. case usagestatistichour.FieldTotalFriend:
  30732. v, ok := value.(uint64)
  30733. if !ok {
  30734. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30735. }
  30736. m.SetTotalFriend(v)
  30737. return nil
  30738. case usagestatistichour.FieldTotalGroup:
  30739. v, ok := value.(uint64)
  30740. if !ok {
  30741. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30742. }
  30743. m.SetTotalGroup(v)
  30744. return nil
  30745. case usagestatistichour.FieldAccountBalance:
  30746. v, ok := value.(uint64)
  30747. if !ok {
  30748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30749. }
  30750. m.SetAccountBalance(v)
  30751. return nil
  30752. case usagestatistichour.FieldConsumeToken:
  30753. v, ok := value.(uint64)
  30754. if !ok {
  30755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30756. }
  30757. m.SetConsumeToken(v)
  30758. return nil
  30759. case usagestatistichour.FieldActiveUser:
  30760. v, ok := value.(uint64)
  30761. if !ok {
  30762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30763. }
  30764. m.SetActiveUser(v)
  30765. return nil
  30766. case usagestatistichour.FieldNewUser:
  30767. v, ok := value.(int64)
  30768. if !ok {
  30769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30770. }
  30771. m.SetNewUser(v)
  30772. return nil
  30773. case usagestatistichour.FieldLabelDist:
  30774. v, ok := value.([]custom_types.LabelDist)
  30775. if !ok {
  30776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30777. }
  30778. m.SetLabelDist(v)
  30779. return nil
  30780. }
  30781. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  30782. }
  30783. // AddedFields returns all numeric fields that were incremented/decremented during
  30784. // this mutation.
  30785. func (m *UsageStatisticHourMutation) AddedFields() []string {
  30786. var fields []string
  30787. if m.addstatus != nil {
  30788. fields = append(fields, usagestatistichour.FieldStatus)
  30789. }
  30790. if m.addaddtime != nil {
  30791. fields = append(fields, usagestatistichour.FieldAddtime)
  30792. }
  30793. if m.add_type != nil {
  30794. fields = append(fields, usagestatistichour.FieldType)
  30795. }
  30796. if m.addorganization_id != nil {
  30797. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30798. }
  30799. if m.addai_response != nil {
  30800. fields = append(fields, usagestatistichour.FieldAiResponse)
  30801. }
  30802. if m.addsop_run != nil {
  30803. fields = append(fields, usagestatistichour.FieldSopRun)
  30804. }
  30805. if m.addtotal_friend != nil {
  30806. fields = append(fields, usagestatistichour.FieldTotalFriend)
  30807. }
  30808. if m.addtotal_group != nil {
  30809. fields = append(fields, usagestatistichour.FieldTotalGroup)
  30810. }
  30811. if m.addaccount_balance != nil {
  30812. fields = append(fields, usagestatistichour.FieldAccountBalance)
  30813. }
  30814. if m.addconsume_token != nil {
  30815. fields = append(fields, usagestatistichour.FieldConsumeToken)
  30816. }
  30817. if m.addactive_user != nil {
  30818. fields = append(fields, usagestatistichour.FieldActiveUser)
  30819. }
  30820. if m.addnew_user != nil {
  30821. fields = append(fields, usagestatistichour.FieldNewUser)
  30822. }
  30823. return fields
  30824. }
  30825. // AddedField returns the numeric value that was incremented/decremented on a field
  30826. // with the given name. The second boolean return value indicates that this field
  30827. // was not set, or was not defined in the schema.
  30828. func (m *UsageStatisticHourMutation) AddedField(name string) (ent.Value, bool) {
  30829. switch name {
  30830. case usagestatistichour.FieldStatus:
  30831. return m.AddedStatus()
  30832. case usagestatistichour.FieldAddtime:
  30833. return m.AddedAddtime()
  30834. case usagestatistichour.FieldType:
  30835. return m.AddedType()
  30836. case usagestatistichour.FieldOrganizationID:
  30837. return m.AddedOrganizationID()
  30838. case usagestatistichour.FieldAiResponse:
  30839. return m.AddedAiResponse()
  30840. case usagestatistichour.FieldSopRun:
  30841. return m.AddedSopRun()
  30842. case usagestatistichour.FieldTotalFriend:
  30843. return m.AddedTotalFriend()
  30844. case usagestatistichour.FieldTotalGroup:
  30845. return m.AddedTotalGroup()
  30846. case usagestatistichour.FieldAccountBalance:
  30847. return m.AddedAccountBalance()
  30848. case usagestatistichour.FieldConsumeToken:
  30849. return m.AddedConsumeToken()
  30850. case usagestatistichour.FieldActiveUser:
  30851. return m.AddedActiveUser()
  30852. case usagestatistichour.FieldNewUser:
  30853. return m.AddedNewUser()
  30854. }
  30855. return nil, false
  30856. }
  30857. // AddField adds the value to the field with the given name. It returns an error if
  30858. // the field is not defined in the schema, or if the type mismatched the field
  30859. // type.
  30860. func (m *UsageStatisticHourMutation) AddField(name string, value ent.Value) error {
  30861. switch name {
  30862. case usagestatistichour.FieldStatus:
  30863. v, ok := value.(int8)
  30864. if !ok {
  30865. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30866. }
  30867. m.AddStatus(v)
  30868. return nil
  30869. case usagestatistichour.FieldAddtime:
  30870. v, ok := value.(int64)
  30871. if !ok {
  30872. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30873. }
  30874. m.AddAddtime(v)
  30875. return nil
  30876. case usagestatistichour.FieldType:
  30877. v, ok := value.(int)
  30878. if !ok {
  30879. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30880. }
  30881. m.AddType(v)
  30882. return nil
  30883. case usagestatistichour.FieldOrganizationID:
  30884. v, ok := value.(int64)
  30885. if !ok {
  30886. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30887. }
  30888. m.AddOrganizationID(v)
  30889. return nil
  30890. case usagestatistichour.FieldAiResponse:
  30891. v, ok := value.(int64)
  30892. if !ok {
  30893. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30894. }
  30895. m.AddAiResponse(v)
  30896. return nil
  30897. case usagestatistichour.FieldSopRun:
  30898. v, ok := value.(int64)
  30899. if !ok {
  30900. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30901. }
  30902. m.AddSopRun(v)
  30903. return nil
  30904. case usagestatistichour.FieldTotalFriend:
  30905. v, ok := value.(int64)
  30906. if !ok {
  30907. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30908. }
  30909. m.AddTotalFriend(v)
  30910. return nil
  30911. case usagestatistichour.FieldTotalGroup:
  30912. v, ok := value.(int64)
  30913. if !ok {
  30914. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30915. }
  30916. m.AddTotalGroup(v)
  30917. return nil
  30918. case usagestatistichour.FieldAccountBalance:
  30919. v, ok := value.(int64)
  30920. if !ok {
  30921. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30922. }
  30923. m.AddAccountBalance(v)
  30924. return nil
  30925. case usagestatistichour.FieldConsumeToken:
  30926. v, ok := value.(int64)
  30927. if !ok {
  30928. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30929. }
  30930. m.AddConsumeToken(v)
  30931. return nil
  30932. case usagestatistichour.FieldActiveUser:
  30933. v, ok := value.(int64)
  30934. if !ok {
  30935. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30936. }
  30937. m.AddActiveUser(v)
  30938. return nil
  30939. case usagestatistichour.FieldNewUser:
  30940. v, ok := value.(int64)
  30941. if !ok {
  30942. return fmt.Errorf("unexpected type %T for field %s", value, name)
  30943. }
  30944. m.AddNewUser(v)
  30945. return nil
  30946. }
  30947. return fmt.Errorf("unknown UsageStatisticHour numeric field %s", name)
  30948. }
  30949. // ClearedFields returns all nullable fields that were cleared during this
  30950. // mutation.
  30951. func (m *UsageStatisticHourMutation) ClearedFields() []string {
  30952. var fields []string
  30953. if m.FieldCleared(usagestatistichour.FieldStatus) {
  30954. fields = append(fields, usagestatistichour.FieldStatus)
  30955. }
  30956. if m.FieldCleared(usagestatistichour.FieldDeletedAt) {
  30957. fields = append(fields, usagestatistichour.FieldDeletedAt)
  30958. }
  30959. if m.FieldCleared(usagestatistichour.FieldBotID) {
  30960. fields = append(fields, usagestatistichour.FieldBotID)
  30961. }
  30962. if m.FieldCleared(usagestatistichour.FieldOrganizationID) {
  30963. fields = append(fields, usagestatistichour.FieldOrganizationID)
  30964. }
  30965. return fields
  30966. }
  30967. // FieldCleared returns a boolean indicating if a field with the given name was
  30968. // cleared in this mutation.
  30969. func (m *UsageStatisticHourMutation) FieldCleared(name string) bool {
  30970. _, ok := m.clearedFields[name]
  30971. return ok
  30972. }
  30973. // ClearField clears the value of the field with the given name. It returns an
  30974. // error if the field is not defined in the schema.
  30975. func (m *UsageStatisticHourMutation) ClearField(name string) error {
  30976. switch name {
  30977. case usagestatistichour.FieldStatus:
  30978. m.ClearStatus()
  30979. return nil
  30980. case usagestatistichour.FieldDeletedAt:
  30981. m.ClearDeletedAt()
  30982. return nil
  30983. case usagestatistichour.FieldBotID:
  30984. m.ClearBotID()
  30985. return nil
  30986. case usagestatistichour.FieldOrganizationID:
  30987. m.ClearOrganizationID()
  30988. return nil
  30989. }
  30990. return fmt.Errorf("unknown UsageStatisticHour nullable field %s", name)
  30991. }
  30992. // ResetField resets all changes in the mutation for the field with the given name.
  30993. // It returns an error if the field is not defined in the schema.
  30994. func (m *UsageStatisticHourMutation) ResetField(name string) error {
  30995. switch name {
  30996. case usagestatistichour.FieldCreatedAt:
  30997. m.ResetCreatedAt()
  30998. return nil
  30999. case usagestatistichour.FieldUpdatedAt:
  31000. m.ResetUpdatedAt()
  31001. return nil
  31002. case usagestatistichour.FieldStatus:
  31003. m.ResetStatus()
  31004. return nil
  31005. case usagestatistichour.FieldDeletedAt:
  31006. m.ResetDeletedAt()
  31007. return nil
  31008. case usagestatistichour.FieldAddtime:
  31009. m.ResetAddtime()
  31010. return nil
  31011. case usagestatistichour.FieldType:
  31012. m.ResetType()
  31013. return nil
  31014. case usagestatistichour.FieldBotID:
  31015. m.ResetBotID()
  31016. return nil
  31017. case usagestatistichour.FieldOrganizationID:
  31018. m.ResetOrganizationID()
  31019. return nil
  31020. case usagestatistichour.FieldAiResponse:
  31021. m.ResetAiResponse()
  31022. return nil
  31023. case usagestatistichour.FieldSopRun:
  31024. m.ResetSopRun()
  31025. return nil
  31026. case usagestatistichour.FieldTotalFriend:
  31027. m.ResetTotalFriend()
  31028. return nil
  31029. case usagestatistichour.FieldTotalGroup:
  31030. m.ResetTotalGroup()
  31031. return nil
  31032. case usagestatistichour.FieldAccountBalance:
  31033. m.ResetAccountBalance()
  31034. return nil
  31035. case usagestatistichour.FieldConsumeToken:
  31036. m.ResetConsumeToken()
  31037. return nil
  31038. case usagestatistichour.FieldActiveUser:
  31039. m.ResetActiveUser()
  31040. return nil
  31041. case usagestatistichour.FieldNewUser:
  31042. m.ResetNewUser()
  31043. return nil
  31044. case usagestatistichour.FieldLabelDist:
  31045. m.ResetLabelDist()
  31046. return nil
  31047. }
  31048. return fmt.Errorf("unknown UsageStatisticHour field %s", name)
  31049. }
  31050. // AddedEdges returns all edge names that were set/added in this mutation.
  31051. func (m *UsageStatisticHourMutation) AddedEdges() []string {
  31052. edges := make([]string, 0, 0)
  31053. return edges
  31054. }
  31055. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  31056. // name in this mutation.
  31057. func (m *UsageStatisticHourMutation) AddedIDs(name string) []ent.Value {
  31058. return nil
  31059. }
  31060. // RemovedEdges returns all edge names that were removed in this mutation.
  31061. func (m *UsageStatisticHourMutation) RemovedEdges() []string {
  31062. edges := make([]string, 0, 0)
  31063. return edges
  31064. }
  31065. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  31066. // the given name in this mutation.
  31067. func (m *UsageStatisticHourMutation) RemovedIDs(name string) []ent.Value {
  31068. return nil
  31069. }
  31070. // ClearedEdges returns all edge names that were cleared in this mutation.
  31071. func (m *UsageStatisticHourMutation) ClearedEdges() []string {
  31072. edges := make([]string, 0, 0)
  31073. return edges
  31074. }
  31075. // EdgeCleared returns a boolean which indicates if the edge with the given name
  31076. // was cleared in this mutation.
  31077. func (m *UsageStatisticHourMutation) EdgeCleared(name string) bool {
  31078. return false
  31079. }
  31080. // ClearEdge clears the value of the edge with the given name. It returns an error
  31081. // if that edge is not defined in the schema.
  31082. func (m *UsageStatisticHourMutation) ClearEdge(name string) error {
  31083. return fmt.Errorf("unknown UsageStatisticHour unique edge %s", name)
  31084. }
  31085. // ResetEdge resets all changes to the edge with the given name in this mutation.
  31086. // It returns an error if the edge is not defined in the schema.
  31087. func (m *UsageStatisticHourMutation) ResetEdge(name string) error {
  31088. return fmt.Errorf("unknown UsageStatisticHour edge %s", name)
  31089. }
  31090. // UsageStatisticMonthMutation represents an operation that mutates the UsageStatisticMonth nodes in the graph.
  31091. type UsageStatisticMonthMutation struct {
  31092. config
  31093. op Op
  31094. typ string
  31095. id *uint64
  31096. created_at *time.Time
  31097. updated_at *time.Time
  31098. status *uint8
  31099. addstatus *int8
  31100. deleted_at *time.Time
  31101. addtime *uint64
  31102. addaddtime *int64
  31103. _type *int
  31104. add_type *int
  31105. bot_id *string
  31106. organization_id *uint64
  31107. addorganization_id *int64
  31108. ai_response *uint64
  31109. addai_response *int64
  31110. sop_run *uint64
  31111. addsop_run *int64
  31112. total_friend *uint64
  31113. addtotal_friend *int64
  31114. total_group *uint64
  31115. addtotal_group *int64
  31116. account_balance *uint64
  31117. addaccount_balance *int64
  31118. consume_token *uint64
  31119. addconsume_token *int64
  31120. active_user *uint64
  31121. addactive_user *int64
  31122. new_user *int64
  31123. addnew_user *int64
  31124. label_dist *[]custom_types.LabelDist
  31125. appendlabel_dist []custom_types.LabelDist
  31126. clearedFields map[string]struct{}
  31127. done bool
  31128. oldValue func(context.Context) (*UsageStatisticMonth, error)
  31129. predicates []predicate.UsageStatisticMonth
  31130. }
  31131. var _ ent.Mutation = (*UsageStatisticMonthMutation)(nil)
  31132. // usagestatisticmonthOption allows management of the mutation configuration using functional options.
  31133. type usagestatisticmonthOption func(*UsageStatisticMonthMutation)
  31134. // newUsageStatisticMonthMutation creates new mutation for the UsageStatisticMonth entity.
  31135. func newUsageStatisticMonthMutation(c config, op Op, opts ...usagestatisticmonthOption) *UsageStatisticMonthMutation {
  31136. m := &UsageStatisticMonthMutation{
  31137. config: c,
  31138. op: op,
  31139. typ: TypeUsageStatisticMonth,
  31140. clearedFields: make(map[string]struct{}),
  31141. }
  31142. for _, opt := range opts {
  31143. opt(m)
  31144. }
  31145. return m
  31146. }
  31147. // withUsageStatisticMonthID sets the ID field of the mutation.
  31148. func withUsageStatisticMonthID(id uint64) usagestatisticmonthOption {
  31149. return func(m *UsageStatisticMonthMutation) {
  31150. var (
  31151. err error
  31152. once sync.Once
  31153. value *UsageStatisticMonth
  31154. )
  31155. m.oldValue = func(ctx context.Context) (*UsageStatisticMonth, error) {
  31156. once.Do(func() {
  31157. if m.done {
  31158. err = errors.New("querying old values post mutation is not allowed")
  31159. } else {
  31160. value, err = m.Client().UsageStatisticMonth.Get(ctx, id)
  31161. }
  31162. })
  31163. return value, err
  31164. }
  31165. m.id = &id
  31166. }
  31167. }
  31168. // withUsageStatisticMonth sets the old UsageStatisticMonth of the mutation.
  31169. func withUsageStatisticMonth(node *UsageStatisticMonth) usagestatisticmonthOption {
  31170. return func(m *UsageStatisticMonthMutation) {
  31171. m.oldValue = func(context.Context) (*UsageStatisticMonth, error) {
  31172. return node, nil
  31173. }
  31174. m.id = &node.ID
  31175. }
  31176. }
  31177. // Client returns a new `ent.Client` from the mutation. If the mutation was
  31178. // executed in a transaction (ent.Tx), a transactional client is returned.
  31179. func (m UsageStatisticMonthMutation) Client() *Client {
  31180. client := &Client{config: m.config}
  31181. client.init()
  31182. return client
  31183. }
  31184. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  31185. // it returns an error otherwise.
  31186. func (m UsageStatisticMonthMutation) Tx() (*Tx, error) {
  31187. if _, ok := m.driver.(*txDriver); !ok {
  31188. return nil, errors.New("ent: mutation is not running in a transaction")
  31189. }
  31190. tx := &Tx{config: m.config}
  31191. tx.init()
  31192. return tx, nil
  31193. }
  31194. // SetID sets the value of the id field. Note that this
  31195. // operation is only accepted on creation of UsageStatisticMonth entities.
  31196. func (m *UsageStatisticMonthMutation) SetID(id uint64) {
  31197. m.id = &id
  31198. }
  31199. // ID returns the ID value in the mutation. Note that the ID is only available
  31200. // if it was provided to the builder or after it was returned from the database.
  31201. func (m *UsageStatisticMonthMutation) ID() (id uint64, exists bool) {
  31202. if m.id == nil {
  31203. return
  31204. }
  31205. return *m.id, true
  31206. }
  31207. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  31208. // That means, if the mutation is applied within a transaction with an isolation level such
  31209. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  31210. // or updated by the mutation.
  31211. func (m *UsageStatisticMonthMutation) IDs(ctx context.Context) ([]uint64, error) {
  31212. switch {
  31213. case m.op.Is(OpUpdateOne | OpDeleteOne):
  31214. id, exists := m.ID()
  31215. if exists {
  31216. return []uint64{id}, nil
  31217. }
  31218. fallthrough
  31219. case m.op.Is(OpUpdate | OpDelete):
  31220. return m.Client().UsageStatisticMonth.Query().Where(m.predicates...).IDs(ctx)
  31221. default:
  31222. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  31223. }
  31224. }
  31225. // SetCreatedAt sets the "created_at" field.
  31226. func (m *UsageStatisticMonthMutation) SetCreatedAt(t time.Time) {
  31227. m.created_at = &t
  31228. }
  31229. // CreatedAt returns the value of the "created_at" field in the mutation.
  31230. func (m *UsageStatisticMonthMutation) CreatedAt() (r time.Time, exists bool) {
  31231. v := m.created_at
  31232. if v == nil {
  31233. return
  31234. }
  31235. return *v, true
  31236. }
  31237. // OldCreatedAt returns the old "created_at" field's value of the UsageStatisticMonth entity.
  31238. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31239. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31240. func (m *UsageStatisticMonthMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  31241. if !m.op.Is(OpUpdateOne) {
  31242. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  31243. }
  31244. if m.id == nil || m.oldValue == nil {
  31245. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  31246. }
  31247. oldValue, err := m.oldValue(ctx)
  31248. if err != nil {
  31249. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  31250. }
  31251. return oldValue.CreatedAt, nil
  31252. }
  31253. // ResetCreatedAt resets all changes to the "created_at" field.
  31254. func (m *UsageStatisticMonthMutation) ResetCreatedAt() {
  31255. m.created_at = nil
  31256. }
  31257. // SetUpdatedAt sets the "updated_at" field.
  31258. func (m *UsageStatisticMonthMutation) SetUpdatedAt(t time.Time) {
  31259. m.updated_at = &t
  31260. }
  31261. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  31262. func (m *UsageStatisticMonthMutation) UpdatedAt() (r time.Time, exists bool) {
  31263. v := m.updated_at
  31264. if v == nil {
  31265. return
  31266. }
  31267. return *v, true
  31268. }
  31269. // OldUpdatedAt returns the old "updated_at" field's value of the UsageStatisticMonth entity.
  31270. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31271. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31272. func (m *UsageStatisticMonthMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  31273. if !m.op.Is(OpUpdateOne) {
  31274. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  31275. }
  31276. if m.id == nil || m.oldValue == nil {
  31277. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  31278. }
  31279. oldValue, err := m.oldValue(ctx)
  31280. if err != nil {
  31281. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  31282. }
  31283. return oldValue.UpdatedAt, nil
  31284. }
  31285. // ResetUpdatedAt resets all changes to the "updated_at" field.
  31286. func (m *UsageStatisticMonthMutation) ResetUpdatedAt() {
  31287. m.updated_at = nil
  31288. }
  31289. // SetStatus sets the "status" field.
  31290. func (m *UsageStatisticMonthMutation) SetStatus(u uint8) {
  31291. m.status = &u
  31292. m.addstatus = nil
  31293. }
  31294. // Status returns the value of the "status" field in the mutation.
  31295. func (m *UsageStatisticMonthMutation) Status() (r uint8, exists bool) {
  31296. v := m.status
  31297. if v == nil {
  31298. return
  31299. }
  31300. return *v, true
  31301. }
  31302. // OldStatus returns the old "status" field's value of the UsageStatisticMonth entity.
  31303. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31304. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31305. func (m *UsageStatisticMonthMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  31306. if !m.op.Is(OpUpdateOne) {
  31307. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  31308. }
  31309. if m.id == nil || m.oldValue == nil {
  31310. return v, errors.New("OldStatus requires an ID field in the mutation")
  31311. }
  31312. oldValue, err := m.oldValue(ctx)
  31313. if err != nil {
  31314. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  31315. }
  31316. return oldValue.Status, nil
  31317. }
  31318. // AddStatus adds u to the "status" field.
  31319. func (m *UsageStatisticMonthMutation) AddStatus(u int8) {
  31320. if m.addstatus != nil {
  31321. *m.addstatus += u
  31322. } else {
  31323. m.addstatus = &u
  31324. }
  31325. }
  31326. // AddedStatus returns the value that was added to the "status" field in this mutation.
  31327. func (m *UsageStatisticMonthMutation) AddedStatus() (r int8, exists bool) {
  31328. v := m.addstatus
  31329. if v == nil {
  31330. return
  31331. }
  31332. return *v, true
  31333. }
  31334. // ClearStatus clears the value of the "status" field.
  31335. func (m *UsageStatisticMonthMutation) ClearStatus() {
  31336. m.status = nil
  31337. m.addstatus = nil
  31338. m.clearedFields[usagestatisticmonth.FieldStatus] = struct{}{}
  31339. }
  31340. // StatusCleared returns if the "status" field was cleared in this mutation.
  31341. func (m *UsageStatisticMonthMutation) StatusCleared() bool {
  31342. _, ok := m.clearedFields[usagestatisticmonth.FieldStatus]
  31343. return ok
  31344. }
  31345. // ResetStatus resets all changes to the "status" field.
  31346. func (m *UsageStatisticMonthMutation) ResetStatus() {
  31347. m.status = nil
  31348. m.addstatus = nil
  31349. delete(m.clearedFields, usagestatisticmonth.FieldStatus)
  31350. }
  31351. // SetDeletedAt sets the "deleted_at" field.
  31352. func (m *UsageStatisticMonthMutation) SetDeletedAt(t time.Time) {
  31353. m.deleted_at = &t
  31354. }
  31355. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  31356. func (m *UsageStatisticMonthMutation) DeletedAt() (r time.Time, exists bool) {
  31357. v := m.deleted_at
  31358. if v == nil {
  31359. return
  31360. }
  31361. return *v, true
  31362. }
  31363. // OldDeletedAt returns the old "deleted_at" field's value of the UsageStatisticMonth entity.
  31364. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31365. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31366. func (m *UsageStatisticMonthMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  31367. if !m.op.Is(OpUpdateOne) {
  31368. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  31369. }
  31370. if m.id == nil || m.oldValue == nil {
  31371. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  31372. }
  31373. oldValue, err := m.oldValue(ctx)
  31374. if err != nil {
  31375. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  31376. }
  31377. return oldValue.DeletedAt, nil
  31378. }
  31379. // ClearDeletedAt clears the value of the "deleted_at" field.
  31380. func (m *UsageStatisticMonthMutation) ClearDeletedAt() {
  31381. m.deleted_at = nil
  31382. m.clearedFields[usagestatisticmonth.FieldDeletedAt] = struct{}{}
  31383. }
  31384. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  31385. func (m *UsageStatisticMonthMutation) DeletedAtCleared() bool {
  31386. _, ok := m.clearedFields[usagestatisticmonth.FieldDeletedAt]
  31387. return ok
  31388. }
  31389. // ResetDeletedAt resets all changes to the "deleted_at" field.
  31390. func (m *UsageStatisticMonthMutation) ResetDeletedAt() {
  31391. m.deleted_at = nil
  31392. delete(m.clearedFields, usagestatisticmonth.FieldDeletedAt)
  31393. }
  31394. // SetAddtime sets the "addtime" field.
  31395. func (m *UsageStatisticMonthMutation) SetAddtime(u uint64) {
  31396. m.addtime = &u
  31397. m.addaddtime = nil
  31398. }
  31399. // Addtime returns the value of the "addtime" field in the mutation.
  31400. func (m *UsageStatisticMonthMutation) Addtime() (r uint64, exists bool) {
  31401. v := m.addtime
  31402. if v == nil {
  31403. return
  31404. }
  31405. return *v, true
  31406. }
  31407. // OldAddtime returns the old "addtime" field's value of the UsageStatisticMonth entity.
  31408. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31409. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31410. func (m *UsageStatisticMonthMutation) OldAddtime(ctx context.Context) (v uint64, err error) {
  31411. if !m.op.Is(OpUpdateOne) {
  31412. return v, errors.New("OldAddtime is only allowed on UpdateOne operations")
  31413. }
  31414. if m.id == nil || m.oldValue == nil {
  31415. return v, errors.New("OldAddtime requires an ID field in the mutation")
  31416. }
  31417. oldValue, err := m.oldValue(ctx)
  31418. if err != nil {
  31419. return v, fmt.Errorf("querying old value for OldAddtime: %w", err)
  31420. }
  31421. return oldValue.Addtime, nil
  31422. }
  31423. // AddAddtime adds u to the "addtime" field.
  31424. func (m *UsageStatisticMonthMutation) AddAddtime(u int64) {
  31425. if m.addaddtime != nil {
  31426. *m.addaddtime += u
  31427. } else {
  31428. m.addaddtime = &u
  31429. }
  31430. }
  31431. // AddedAddtime returns the value that was added to the "addtime" field in this mutation.
  31432. func (m *UsageStatisticMonthMutation) AddedAddtime() (r int64, exists bool) {
  31433. v := m.addaddtime
  31434. if v == nil {
  31435. return
  31436. }
  31437. return *v, true
  31438. }
  31439. // ResetAddtime resets all changes to the "addtime" field.
  31440. func (m *UsageStatisticMonthMutation) ResetAddtime() {
  31441. m.addtime = nil
  31442. m.addaddtime = nil
  31443. }
  31444. // SetType sets the "type" field.
  31445. func (m *UsageStatisticMonthMutation) SetType(i int) {
  31446. m._type = &i
  31447. m.add_type = nil
  31448. }
  31449. // GetType returns the value of the "type" field in the mutation.
  31450. func (m *UsageStatisticMonthMutation) GetType() (r int, exists bool) {
  31451. v := m._type
  31452. if v == nil {
  31453. return
  31454. }
  31455. return *v, true
  31456. }
  31457. // OldType returns the old "type" field's value of the UsageStatisticMonth entity.
  31458. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31459. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31460. func (m *UsageStatisticMonthMutation) OldType(ctx context.Context) (v int, err error) {
  31461. if !m.op.Is(OpUpdateOne) {
  31462. return v, errors.New("OldType is only allowed on UpdateOne operations")
  31463. }
  31464. if m.id == nil || m.oldValue == nil {
  31465. return v, errors.New("OldType requires an ID field in the mutation")
  31466. }
  31467. oldValue, err := m.oldValue(ctx)
  31468. if err != nil {
  31469. return v, fmt.Errorf("querying old value for OldType: %w", err)
  31470. }
  31471. return oldValue.Type, nil
  31472. }
  31473. // AddType adds i to the "type" field.
  31474. func (m *UsageStatisticMonthMutation) AddType(i int) {
  31475. if m.add_type != nil {
  31476. *m.add_type += i
  31477. } else {
  31478. m.add_type = &i
  31479. }
  31480. }
  31481. // AddedType returns the value that was added to the "type" field in this mutation.
  31482. func (m *UsageStatisticMonthMutation) AddedType() (r int, exists bool) {
  31483. v := m.add_type
  31484. if v == nil {
  31485. return
  31486. }
  31487. return *v, true
  31488. }
  31489. // ResetType resets all changes to the "type" field.
  31490. func (m *UsageStatisticMonthMutation) ResetType() {
  31491. m._type = nil
  31492. m.add_type = nil
  31493. }
  31494. // SetBotID sets the "bot_id" field.
  31495. func (m *UsageStatisticMonthMutation) SetBotID(s string) {
  31496. m.bot_id = &s
  31497. }
  31498. // BotID returns the value of the "bot_id" field in the mutation.
  31499. func (m *UsageStatisticMonthMutation) BotID() (r string, exists bool) {
  31500. v := m.bot_id
  31501. if v == nil {
  31502. return
  31503. }
  31504. return *v, true
  31505. }
  31506. // OldBotID returns the old "bot_id" field's value of the UsageStatisticMonth entity.
  31507. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31508. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31509. func (m *UsageStatisticMonthMutation) OldBotID(ctx context.Context) (v string, err error) {
  31510. if !m.op.Is(OpUpdateOne) {
  31511. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  31512. }
  31513. if m.id == nil || m.oldValue == nil {
  31514. return v, errors.New("OldBotID requires an ID field in the mutation")
  31515. }
  31516. oldValue, err := m.oldValue(ctx)
  31517. if err != nil {
  31518. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  31519. }
  31520. return oldValue.BotID, nil
  31521. }
  31522. // ClearBotID clears the value of the "bot_id" field.
  31523. func (m *UsageStatisticMonthMutation) ClearBotID() {
  31524. m.bot_id = nil
  31525. m.clearedFields[usagestatisticmonth.FieldBotID] = struct{}{}
  31526. }
  31527. // BotIDCleared returns if the "bot_id" field was cleared in this mutation.
  31528. func (m *UsageStatisticMonthMutation) BotIDCleared() bool {
  31529. _, ok := m.clearedFields[usagestatisticmonth.FieldBotID]
  31530. return ok
  31531. }
  31532. // ResetBotID resets all changes to the "bot_id" field.
  31533. func (m *UsageStatisticMonthMutation) ResetBotID() {
  31534. m.bot_id = nil
  31535. delete(m.clearedFields, usagestatisticmonth.FieldBotID)
  31536. }
  31537. // SetOrganizationID sets the "organization_id" field.
  31538. func (m *UsageStatisticMonthMutation) SetOrganizationID(u uint64) {
  31539. m.organization_id = &u
  31540. m.addorganization_id = nil
  31541. }
  31542. // OrganizationID returns the value of the "organization_id" field in the mutation.
  31543. func (m *UsageStatisticMonthMutation) OrganizationID() (r uint64, exists bool) {
  31544. v := m.organization_id
  31545. if v == nil {
  31546. return
  31547. }
  31548. return *v, true
  31549. }
  31550. // OldOrganizationID returns the old "organization_id" field's value of the UsageStatisticMonth entity.
  31551. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31552. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31553. func (m *UsageStatisticMonthMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  31554. if !m.op.Is(OpUpdateOne) {
  31555. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  31556. }
  31557. if m.id == nil || m.oldValue == nil {
  31558. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  31559. }
  31560. oldValue, err := m.oldValue(ctx)
  31561. if err != nil {
  31562. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  31563. }
  31564. return oldValue.OrganizationID, nil
  31565. }
  31566. // AddOrganizationID adds u to the "organization_id" field.
  31567. func (m *UsageStatisticMonthMutation) AddOrganizationID(u int64) {
  31568. if m.addorganization_id != nil {
  31569. *m.addorganization_id += u
  31570. } else {
  31571. m.addorganization_id = &u
  31572. }
  31573. }
  31574. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  31575. func (m *UsageStatisticMonthMutation) AddedOrganizationID() (r int64, exists bool) {
  31576. v := m.addorganization_id
  31577. if v == nil {
  31578. return
  31579. }
  31580. return *v, true
  31581. }
  31582. // ClearOrganizationID clears the value of the "organization_id" field.
  31583. func (m *UsageStatisticMonthMutation) ClearOrganizationID() {
  31584. m.organization_id = nil
  31585. m.addorganization_id = nil
  31586. m.clearedFields[usagestatisticmonth.FieldOrganizationID] = struct{}{}
  31587. }
  31588. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  31589. func (m *UsageStatisticMonthMutation) OrganizationIDCleared() bool {
  31590. _, ok := m.clearedFields[usagestatisticmonth.FieldOrganizationID]
  31591. return ok
  31592. }
  31593. // ResetOrganizationID resets all changes to the "organization_id" field.
  31594. func (m *UsageStatisticMonthMutation) ResetOrganizationID() {
  31595. m.organization_id = nil
  31596. m.addorganization_id = nil
  31597. delete(m.clearedFields, usagestatisticmonth.FieldOrganizationID)
  31598. }
  31599. // SetAiResponse sets the "ai_response" field.
  31600. func (m *UsageStatisticMonthMutation) SetAiResponse(u uint64) {
  31601. m.ai_response = &u
  31602. m.addai_response = nil
  31603. }
  31604. // AiResponse returns the value of the "ai_response" field in the mutation.
  31605. func (m *UsageStatisticMonthMutation) AiResponse() (r uint64, exists bool) {
  31606. v := m.ai_response
  31607. if v == nil {
  31608. return
  31609. }
  31610. return *v, true
  31611. }
  31612. // OldAiResponse returns the old "ai_response" field's value of the UsageStatisticMonth entity.
  31613. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31614. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31615. func (m *UsageStatisticMonthMutation) OldAiResponse(ctx context.Context) (v uint64, err error) {
  31616. if !m.op.Is(OpUpdateOne) {
  31617. return v, errors.New("OldAiResponse is only allowed on UpdateOne operations")
  31618. }
  31619. if m.id == nil || m.oldValue == nil {
  31620. return v, errors.New("OldAiResponse requires an ID field in the mutation")
  31621. }
  31622. oldValue, err := m.oldValue(ctx)
  31623. if err != nil {
  31624. return v, fmt.Errorf("querying old value for OldAiResponse: %w", err)
  31625. }
  31626. return oldValue.AiResponse, nil
  31627. }
  31628. // AddAiResponse adds u to the "ai_response" field.
  31629. func (m *UsageStatisticMonthMutation) AddAiResponse(u int64) {
  31630. if m.addai_response != nil {
  31631. *m.addai_response += u
  31632. } else {
  31633. m.addai_response = &u
  31634. }
  31635. }
  31636. // AddedAiResponse returns the value that was added to the "ai_response" field in this mutation.
  31637. func (m *UsageStatisticMonthMutation) AddedAiResponse() (r int64, exists bool) {
  31638. v := m.addai_response
  31639. if v == nil {
  31640. return
  31641. }
  31642. return *v, true
  31643. }
  31644. // ResetAiResponse resets all changes to the "ai_response" field.
  31645. func (m *UsageStatisticMonthMutation) ResetAiResponse() {
  31646. m.ai_response = nil
  31647. m.addai_response = nil
  31648. }
  31649. // SetSopRun sets the "sop_run" field.
  31650. func (m *UsageStatisticMonthMutation) SetSopRun(u uint64) {
  31651. m.sop_run = &u
  31652. m.addsop_run = nil
  31653. }
  31654. // SopRun returns the value of the "sop_run" field in the mutation.
  31655. func (m *UsageStatisticMonthMutation) SopRun() (r uint64, exists bool) {
  31656. v := m.sop_run
  31657. if v == nil {
  31658. return
  31659. }
  31660. return *v, true
  31661. }
  31662. // OldSopRun returns the old "sop_run" field's value of the UsageStatisticMonth entity.
  31663. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31664. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31665. func (m *UsageStatisticMonthMutation) OldSopRun(ctx context.Context) (v uint64, err error) {
  31666. if !m.op.Is(OpUpdateOne) {
  31667. return v, errors.New("OldSopRun is only allowed on UpdateOne operations")
  31668. }
  31669. if m.id == nil || m.oldValue == nil {
  31670. return v, errors.New("OldSopRun requires an ID field in the mutation")
  31671. }
  31672. oldValue, err := m.oldValue(ctx)
  31673. if err != nil {
  31674. return v, fmt.Errorf("querying old value for OldSopRun: %w", err)
  31675. }
  31676. return oldValue.SopRun, nil
  31677. }
  31678. // AddSopRun adds u to the "sop_run" field.
  31679. func (m *UsageStatisticMonthMutation) AddSopRun(u int64) {
  31680. if m.addsop_run != nil {
  31681. *m.addsop_run += u
  31682. } else {
  31683. m.addsop_run = &u
  31684. }
  31685. }
  31686. // AddedSopRun returns the value that was added to the "sop_run" field in this mutation.
  31687. func (m *UsageStatisticMonthMutation) AddedSopRun() (r int64, exists bool) {
  31688. v := m.addsop_run
  31689. if v == nil {
  31690. return
  31691. }
  31692. return *v, true
  31693. }
  31694. // ResetSopRun resets all changes to the "sop_run" field.
  31695. func (m *UsageStatisticMonthMutation) ResetSopRun() {
  31696. m.sop_run = nil
  31697. m.addsop_run = nil
  31698. }
  31699. // SetTotalFriend sets the "total_friend" field.
  31700. func (m *UsageStatisticMonthMutation) SetTotalFriend(u uint64) {
  31701. m.total_friend = &u
  31702. m.addtotal_friend = nil
  31703. }
  31704. // TotalFriend returns the value of the "total_friend" field in the mutation.
  31705. func (m *UsageStatisticMonthMutation) TotalFriend() (r uint64, exists bool) {
  31706. v := m.total_friend
  31707. if v == nil {
  31708. return
  31709. }
  31710. return *v, true
  31711. }
  31712. // OldTotalFriend returns the old "total_friend" field's value of the UsageStatisticMonth entity.
  31713. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31714. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31715. func (m *UsageStatisticMonthMutation) OldTotalFriend(ctx context.Context) (v uint64, err error) {
  31716. if !m.op.Is(OpUpdateOne) {
  31717. return v, errors.New("OldTotalFriend is only allowed on UpdateOne operations")
  31718. }
  31719. if m.id == nil || m.oldValue == nil {
  31720. return v, errors.New("OldTotalFriend requires an ID field in the mutation")
  31721. }
  31722. oldValue, err := m.oldValue(ctx)
  31723. if err != nil {
  31724. return v, fmt.Errorf("querying old value for OldTotalFriend: %w", err)
  31725. }
  31726. return oldValue.TotalFriend, nil
  31727. }
  31728. // AddTotalFriend adds u to the "total_friend" field.
  31729. func (m *UsageStatisticMonthMutation) AddTotalFriend(u int64) {
  31730. if m.addtotal_friend != nil {
  31731. *m.addtotal_friend += u
  31732. } else {
  31733. m.addtotal_friend = &u
  31734. }
  31735. }
  31736. // AddedTotalFriend returns the value that was added to the "total_friend" field in this mutation.
  31737. func (m *UsageStatisticMonthMutation) AddedTotalFriend() (r int64, exists bool) {
  31738. v := m.addtotal_friend
  31739. if v == nil {
  31740. return
  31741. }
  31742. return *v, true
  31743. }
  31744. // ResetTotalFriend resets all changes to the "total_friend" field.
  31745. func (m *UsageStatisticMonthMutation) ResetTotalFriend() {
  31746. m.total_friend = nil
  31747. m.addtotal_friend = nil
  31748. }
  31749. // SetTotalGroup sets the "total_group" field.
  31750. func (m *UsageStatisticMonthMutation) SetTotalGroup(u uint64) {
  31751. m.total_group = &u
  31752. m.addtotal_group = nil
  31753. }
  31754. // TotalGroup returns the value of the "total_group" field in the mutation.
  31755. func (m *UsageStatisticMonthMutation) TotalGroup() (r uint64, exists bool) {
  31756. v := m.total_group
  31757. if v == nil {
  31758. return
  31759. }
  31760. return *v, true
  31761. }
  31762. // OldTotalGroup returns the old "total_group" field's value of the UsageStatisticMonth entity.
  31763. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31764. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31765. func (m *UsageStatisticMonthMutation) OldTotalGroup(ctx context.Context) (v uint64, err error) {
  31766. if !m.op.Is(OpUpdateOne) {
  31767. return v, errors.New("OldTotalGroup is only allowed on UpdateOne operations")
  31768. }
  31769. if m.id == nil || m.oldValue == nil {
  31770. return v, errors.New("OldTotalGroup requires an ID field in the mutation")
  31771. }
  31772. oldValue, err := m.oldValue(ctx)
  31773. if err != nil {
  31774. return v, fmt.Errorf("querying old value for OldTotalGroup: %w", err)
  31775. }
  31776. return oldValue.TotalGroup, nil
  31777. }
  31778. // AddTotalGroup adds u to the "total_group" field.
  31779. func (m *UsageStatisticMonthMutation) AddTotalGroup(u int64) {
  31780. if m.addtotal_group != nil {
  31781. *m.addtotal_group += u
  31782. } else {
  31783. m.addtotal_group = &u
  31784. }
  31785. }
  31786. // AddedTotalGroup returns the value that was added to the "total_group" field in this mutation.
  31787. func (m *UsageStatisticMonthMutation) AddedTotalGroup() (r int64, exists bool) {
  31788. v := m.addtotal_group
  31789. if v == nil {
  31790. return
  31791. }
  31792. return *v, true
  31793. }
  31794. // ResetTotalGroup resets all changes to the "total_group" field.
  31795. func (m *UsageStatisticMonthMutation) ResetTotalGroup() {
  31796. m.total_group = nil
  31797. m.addtotal_group = nil
  31798. }
  31799. // SetAccountBalance sets the "account_balance" field.
  31800. func (m *UsageStatisticMonthMutation) SetAccountBalance(u uint64) {
  31801. m.account_balance = &u
  31802. m.addaccount_balance = nil
  31803. }
  31804. // AccountBalance returns the value of the "account_balance" field in the mutation.
  31805. func (m *UsageStatisticMonthMutation) AccountBalance() (r uint64, exists bool) {
  31806. v := m.account_balance
  31807. if v == nil {
  31808. return
  31809. }
  31810. return *v, true
  31811. }
  31812. // OldAccountBalance returns the old "account_balance" field's value of the UsageStatisticMonth entity.
  31813. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31815. func (m *UsageStatisticMonthMutation) OldAccountBalance(ctx context.Context) (v uint64, err error) {
  31816. if !m.op.Is(OpUpdateOne) {
  31817. return v, errors.New("OldAccountBalance is only allowed on UpdateOne operations")
  31818. }
  31819. if m.id == nil || m.oldValue == nil {
  31820. return v, errors.New("OldAccountBalance requires an ID field in the mutation")
  31821. }
  31822. oldValue, err := m.oldValue(ctx)
  31823. if err != nil {
  31824. return v, fmt.Errorf("querying old value for OldAccountBalance: %w", err)
  31825. }
  31826. return oldValue.AccountBalance, nil
  31827. }
  31828. // AddAccountBalance adds u to the "account_balance" field.
  31829. func (m *UsageStatisticMonthMutation) AddAccountBalance(u int64) {
  31830. if m.addaccount_balance != nil {
  31831. *m.addaccount_balance += u
  31832. } else {
  31833. m.addaccount_balance = &u
  31834. }
  31835. }
  31836. // AddedAccountBalance returns the value that was added to the "account_balance" field in this mutation.
  31837. func (m *UsageStatisticMonthMutation) AddedAccountBalance() (r int64, exists bool) {
  31838. v := m.addaccount_balance
  31839. if v == nil {
  31840. return
  31841. }
  31842. return *v, true
  31843. }
  31844. // ResetAccountBalance resets all changes to the "account_balance" field.
  31845. func (m *UsageStatisticMonthMutation) ResetAccountBalance() {
  31846. m.account_balance = nil
  31847. m.addaccount_balance = nil
  31848. }
  31849. // SetConsumeToken sets the "consume_token" field.
  31850. func (m *UsageStatisticMonthMutation) SetConsumeToken(u uint64) {
  31851. m.consume_token = &u
  31852. m.addconsume_token = nil
  31853. }
  31854. // ConsumeToken returns the value of the "consume_token" field in the mutation.
  31855. func (m *UsageStatisticMonthMutation) ConsumeToken() (r uint64, exists bool) {
  31856. v := m.consume_token
  31857. if v == nil {
  31858. return
  31859. }
  31860. return *v, true
  31861. }
  31862. // OldConsumeToken returns the old "consume_token" field's value of the UsageStatisticMonth entity.
  31863. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31864. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31865. func (m *UsageStatisticMonthMutation) OldConsumeToken(ctx context.Context) (v uint64, err error) {
  31866. if !m.op.Is(OpUpdateOne) {
  31867. return v, errors.New("OldConsumeToken is only allowed on UpdateOne operations")
  31868. }
  31869. if m.id == nil || m.oldValue == nil {
  31870. return v, errors.New("OldConsumeToken requires an ID field in the mutation")
  31871. }
  31872. oldValue, err := m.oldValue(ctx)
  31873. if err != nil {
  31874. return v, fmt.Errorf("querying old value for OldConsumeToken: %w", err)
  31875. }
  31876. return oldValue.ConsumeToken, nil
  31877. }
  31878. // AddConsumeToken adds u to the "consume_token" field.
  31879. func (m *UsageStatisticMonthMutation) AddConsumeToken(u int64) {
  31880. if m.addconsume_token != nil {
  31881. *m.addconsume_token += u
  31882. } else {
  31883. m.addconsume_token = &u
  31884. }
  31885. }
  31886. // AddedConsumeToken returns the value that was added to the "consume_token" field in this mutation.
  31887. func (m *UsageStatisticMonthMutation) AddedConsumeToken() (r int64, exists bool) {
  31888. v := m.addconsume_token
  31889. if v == nil {
  31890. return
  31891. }
  31892. return *v, true
  31893. }
  31894. // ResetConsumeToken resets all changes to the "consume_token" field.
  31895. func (m *UsageStatisticMonthMutation) ResetConsumeToken() {
  31896. m.consume_token = nil
  31897. m.addconsume_token = nil
  31898. }
  31899. // SetActiveUser sets the "active_user" field.
  31900. func (m *UsageStatisticMonthMutation) SetActiveUser(u uint64) {
  31901. m.active_user = &u
  31902. m.addactive_user = nil
  31903. }
  31904. // ActiveUser returns the value of the "active_user" field in the mutation.
  31905. func (m *UsageStatisticMonthMutation) ActiveUser() (r uint64, exists bool) {
  31906. v := m.active_user
  31907. if v == nil {
  31908. return
  31909. }
  31910. return *v, true
  31911. }
  31912. // OldActiveUser returns the old "active_user" field's value of the UsageStatisticMonth entity.
  31913. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31914. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31915. func (m *UsageStatisticMonthMutation) OldActiveUser(ctx context.Context) (v uint64, err error) {
  31916. if !m.op.Is(OpUpdateOne) {
  31917. return v, errors.New("OldActiveUser is only allowed on UpdateOne operations")
  31918. }
  31919. if m.id == nil || m.oldValue == nil {
  31920. return v, errors.New("OldActiveUser requires an ID field in the mutation")
  31921. }
  31922. oldValue, err := m.oldValue(ctx)
  31923. if err != nil {
  31924. return v, fmt.Errorf("querying old value for OldActiveUser: %w", err)
  31925. }
  31926. return oldValue.ActiveUser, nil
  31927. }
  31928. // AddActiveUser adds u to the "active_user" field.
  31929. func (m *UsageStatisticMonthMutation) AddActiveUser(u int64) {
  31930. if m.addactive_user != nil {
  31931. *m.addactive_user += u
  31932. } else {
  31933. m.addactive_user = &u
  31934. }
  31935. }
  31936. // AddedActiveUser returns the value that was added to the "active_user" field in this mutation.
  31937. func (m *UsageStatisticMonthMutation) AddedActiveUser() (r int64, exists bool) {
  31938. v := m.addactive_user
  31939. if v == nil {
  31940. return
  31941. }
  31942. return *v, true
  31943. }
  31944. // ResetActiveUser resets all changes to the "active_user" field.
  31945. func (m *UsageStatisticMonthMutation) ResetActiveUser() {
  31946. m.active_user = nil
  31947. m.addactive_user = nil
  31948. }
  31949. // SetNewUser sets the "new_user" field.
  31950. func (m *UsageStatisticMonthMutation) SetNewUser(i int64) {
  31951. m.new_user = &i
  31952. m.addnew_user = nil
  31953. }
  31954. // NewUser returns the value of the "new_user" field in the mutation.
  31955. func (m *UsageStatisticMonthMutation) NewUser() (r int64, exists bool) {
  31956. v := m.new_user
  31957. if v == nil {
  31958. return
  31959. }
  31960. return *v, true
  31961. }
  31962. // OldNewUser returns the old "new_user" field's value of the UsageStatisticMonth entity.
  31963. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  31964. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  31965. func (m *UsageStatisticMonthMutation) OldNewUser(ctx context.Context) (v int64, err error) {
  31966. if !m.op.Is(OpUpdateOne) {
  31967. return v, errors.New("OldNewUser is only allowed on UpdateOne operations")
  31968. }
  31969. if m.id == nil || m.oldValue == nil {
  31970. return v, errors.New("OldNewUser requires an ID field in the mutation")
  31971. }
  31972. oldValue, err := m.oldValue(ctx)
  31973. if err != nil {
  31974. return v, fmt.Errorf("querying old value for OldNewUser: %w", err)
  31975. }
  31976. return oldValue.NewUser, nil
  31977. }
  31978. // AddNewUser adds i to the "new_user" field.
  31979. func (m *UsageStatisticMonthMutation) AddNewUser(i int64) {
  31980. if m.addnew_user != nil {
  31981. *m.addnew_user += i
  31982. } else {
  31983. m.addnew_user = &i
  31984. }
  31985. }
  31986. // AddedNewUser returns the value that was added to the "new_user" field in this mutation.
  31987. func (m *UsageStatisticMonthMutation) AddedNewUser() (r int64, exists bool) {
  31988. v := m.addnew_user
  31989. if v == nil {
  31990. return
  31991. }
  31992. return *v, true
  31993. }
  31994. // ResetNewUser resets all changes to the "new_user" field.
  31995. func (m *UsageStatisticMonthMutation) ResetNewUser() {
  31996. m.new_user = nil
  31997. m.addnew_user = nil
  31998. }
  31999. // SetLabelDist sets the "label_dist" field.
  32000. func (m *UsageStatisticMonthMutation) SetLabelDist(ctd []custom_types.LabelDist) {
  32001. m.label_dist = &ctd
  32002. m.appendlabel_dist = nil
  32003. }
  32004. // LabelDist returns the value of the "label_dist" field in the mutation.
  32005. func (m *UsageStatisticMonthMutation) LabelDist() (r []custom_types.LabelDist, exists bool) {
  32006. v := m.label_dist
  32007. if v == nil {
  32008. return
  32009. }
  32010. return *v, true
  32011. }
  32012. // OldLabelDist returns the old "label_dist" field's value of the UsageStatisticMonth entity.
  32013. // If the UsageStatisticMonth object wasn't provided to the builder, the object is fetched from the database.
  32014. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32015. func (m *UsageStatisticMonthMutation) OldLabelDist(ctx context.Context) (v []custom_types.LabelDist, err error) {
  32016. if !m.op.Is(OpUpdateOne) {
  32017. return v, errors.New("OldLabelDist is only allowed on UpdateOne operations")
  32018. }
  32019. if m.id == nil || m.oldValue == nil {
  32020. return v, errors.New("OldLabelDist requires an ID field in the mutation")
  32021. }
  32022. oldValue, err := m.oldValue(ctx)
  32023. if err != nil {
  32024. return v, fmt.Errorf("querying old value for OldLabelDist: %w", err)
  32025. }
  32026. return oldValue.LabelDist, nil
  32027. }
  32028. // AppendLabelDist adds ctd to the "label_dist" field.
  32029. func (m *UsageStatisticMonthMutation) AppendLabelDist(ctd []custom_types.LabelDist) {
  32030. m.appendlabel_dist = append(m.appendlabel_dist, ctd...)
  32031. }
  32032. // AppendedLabelDist returns the list of values that were appended to the "label_dist" field in this mutation.
  32033. func (m *UsageStatisticMonthMutation) AppendedLabelDist() ([]custom_types.LabelDist, bool) {
  32034. if len(m.appendlabel_dist) == 0 {
  32035. return nil, false
  32036. }
  32037. return m.appendlabel_dist, true
  32038. }
  32039. // ResetLabelDist resets all changes to the "label_dist" field.
  32040. func (m *UsageStatisticMonthMutation) ResetLabelDist() {
  32041. m.label_dist = nil
  32042. m.appendlabel_dist = nil
  32043. }
  32044. // Where appends a list predicates to the UsageStatisticMonthMutation builder.
  32045. func (m *UsageStatisticMonthMutation) Where(ps ...predicate.UsageStatisticMonth) {
  32046. m.predicates = append(m.predicates, ps...)
  32047. }
  32048. // WhereP appends storage-level predicates to the UsageStatisticMonthMutation builder. Using this method,
  32049. // users can use type-assertion to append predicates that do not depend on any generated package.
  32050. func (m *UsageStatisticMonthMutation) WhereP(ps ...func(*sql.Selector)) {
  32051. p := make([]predicate.UsageStatisticMonth, len(ps))
  32052. for i := range ps {
  32053. p[i] = ps[i]
  32054. }
  32055. m.Where(p...)
  32056. }
  32057. // Op returns the operation name.
  32058. func (m *UsageStatisticMonthMutation) Op() Op {
  32059. return m.op
  32060. }
  32061. // SetOp allows setting the mutation operation.
  32062. func (m *UsageStatisticMonthMutation) SetOp(op Op) {
  32063. m.op = op
  32064. }
  32065. // Type returns the node type of this mutation (UsageStatisticMonth).
  32066. func (m *UsageStatisticMonthMutation) Type() string {
  32067. return m.typ
  32068. }
  32069. // Fields returns all fields that were changed during this mutation. Note that in
  32070. // order to get all numeric fields that were incremented/decremented, call
  32071. // AddedFields().
  32072. func (m *UsageStatisticMonthMutation) Fields() []string {
  32073. fields := make([]string, 0, 17)
  32074. if m.created_at != nil {
  32075. fields = append(fields, usagestatisticmonth.FieldCreatedAt)
  32076. }
  32077. if m.updated_at != nil {
  32078. fields = append(fields, usagestatisticmonth.FieldUpdatedAt)
  32079. }
  32080. if m.status != nil {
  32081. fields = append(fields, usagestatisticmonth.FieldStatus)
  32082. }
  32083. if m.deleted_at != nil {
  32084. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32085. }
  32086. if m.addtime != nil {
  32087. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32088. }
  32089. if m._type != nil {
  32090. fields = append(fields, usagestatisticmonth.FieldType)
  32091. }
  32092. if m.bot_id != nil {
  32093. fields = append(fields, usagestatisticmonth.FieldBotID)
  32094. }
  32095. if m.organization_id != nil {
  32096. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32097. }
  32098. if m.ai_response != nil {
  32099. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32100. }
  32101. if m.sop_run != nil {
  32102. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32103. }
  32104. if m.total_friend != nil {
  32105. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32106. }
  32107. if m.total_group != nil {
  32108. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32109. }
  32110. if m.account_balance != nil {
  32111. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32112. }
  32113. if m.consume_token != nil {
  32114. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32115. }
  32116. if m.active_user != nil {
  32117. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32118. }
  32119. if m.new_user != nil {
  32120. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32121. }
  32122. if m.label_dist != nil {
  32123. fields = append(fields, usagestatisticmonth.FieldLabelDist)
  32124. }
  32125. return fields
  32126. }
  32127. // Field returns the value of a field with the given name. The second boolean
  32128. // return value indicates that this field was not set, or was not defined in the
  32129. // schema.
  32130. func (m *UsageStatisticMonthMutation) Field(name string) (ent.Value, bool) {
  32131. switch name {
  32132. case usagestatisticmonth.FieldCreatedAt:
  32133. return m.CreatedAt()
  32134. case usagestatisticmonth.FieldUpdatedAt:
  32135. return m.UpdatedAt()
  32136. case usagestatisticmonth.FieldStatus:
  32137. return m.Status()
  32138. case usagestatisticmonth.FieldDeletedAt:
  32139. return m.DeletedAt()
  32140. case usagestatisticmonth.FieldAddtime:
  32141. return m.Addtime()
  32142. case usagestatisticmonth.FieldType:
  32143. return m.GetType()
  32144. case usagestatisticmonth.FieldBotID:
  32145. return m.BotID()
  32146. case usagestatisticmonth.FieldOrganizationID:
  32147. return m.OrganizationID()
  32148. case usagestatisticmonth.FieldAiResponse:
  32149. return m.AiResponse()
  32150. case usagestatisticmonth.FieldSopRun:
  32151. return m.SopRun()
  32152. case usagestatisticmonth.FieldTotalFriend:
  32153. return m.TotalFriend()
  32154. case usagestatisticmonth.FieldTotalGroup:
  32155. return m.TotalGroup()
  32156. case usagestatisticmonth.FieldAccountBalance:
  32157. return m.AccountBalance()
  32158. case usagestatisticmonth.FieldConsumeToken:
  32159. return m.ConsumeToken()
  32160. case usagestatisticmonth.FieldActiveUser:
  32161. return m.ActiveUser()
  32162. case usagestatisticmonth.FieldNewUser:
  32163. return m.NewUser()
  32164. case usagestatisticmonth.FieldLabelDist:
  32165. return m.LabelDist()
  32166. }
  32167. return nil, false
  32168. }
  32169. // OldField returns the old value of the field from the database. An error is
  32170. // returned if the mutation operation is not UpdateOne, or the query to the
  32171. // database failed.
  32172. func (m *UsageStatisticMonthMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  32173. switch name {
  32174. case usagestatisticmonth.FieldCreatedAt:
  32175. return m.OldCreatedAt(ctx)
  32176. case usagestatisticmonth.FieldUpdatedAt:
  32177. return m.OldUpdatedAt(ctx)
  32178. case usagestatisticmonth.FieldStatus:
  32179. return m.OldStatus(ctx)
  32180. case usagestatisticmonth.FieldDeletedAt:
  32181. return m.OldDeletedAt(ctx)
  32182. case usagestatisticmonth.FieldAddtime:
  32183. return m.OldAddtime(ctx)
  32184. case usagestatisticmonth.FieldType:
  32185. return m.OldType(ctx)
  32186. case usagestatisticmonth.FieldBotID:
  32187. return m.OldBotID(ctx)
  32188. case usagestatisticmonth.FieldOrganizationID:
  32189. return m.OldOrganizationID(ctx)
  32190. case usagestatisticmonth.FieldAiResponse:
  32191. return m.OldAiResponse(ctx)
  32192. case usagestatisticmonth.FieldSopRun:
  32193. return m.OldSopRun(ctx)
  32194. case usagestatisticmonth.FieldTotalFriend:
  32195. return m.OldTotalFriend(ctx)
  32196. case usagestatisticmonth.FieldTotalGroup:
  32197. return m.OldTotalGroup(ctx)
  32198. case usagestatisticmonth.FieldAccountBalance:
  32199. return m.OldAccountBalance(ctx)
  32200. case usagestatisticmonth.FieldConsumeToken:
  32201. return m.OldConsumeToken(ctx)
  32202. case usagestatisticmonth.FieldActiveUser:
  32203. return m.OldActiveUser(ctx)
  32204. case usagestatisticmonth.FieldNewUser:
  32205. return m.OldNewUser(ctx)
  32206. case usagestatisticmonth.FieldLabelDist:
  32207. return m.OldLabelDist(ctx)
  32208. }
  32209. return nil, fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32210. }
  32211. // SetField sets the value of a field with the given name. It returns an error if
  32212. // the field is not defined in the schema, or if the type mismatched the field
  32213. // type.
  32214. func (m *UsageStatisticMonthMutation) SetField(name string, value ent.Value) error {
  32215. switch name {
  32216. case usagestatisticmonth.FieldCreatedAt:
  32217. v, ok := value.(time.Time)
  32218. if !ok {
  32219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32220. }
  32221. m.SetCreatedAt(v)
  32222. return nil
  32223. case usagestatisticmonth.FieldUpdatedAt:
  32224. v, ok := value.(time.Time)
  32225. if !ok {
  32226. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32227. }
  32228. m.SetUpdatedAt(v)
  32229. return nil
  32230. case usagestatisticmonth.FieldStatus:
  32231. v, ok := value.(uint8)
  32232. if !ok {
  32233. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32234. }
  32235. m.SetStatus(v)
  32236. return nil
  32237. case usagestatisticmonth.FieldDeletedAt:
  32238. v, ok := value.(time.Time)
  32239. if !ok {
  32240. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32241. }
  32242. m.SetDeletedAt(v)
  32243. return nil
  32244. case usagestatisticmonth.FieldAddtime:
  32245. v, ok := value.(uint64)
  32246. if !ok {
  32247. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32248. }
  32249. m.SetAddtime(v)
  32250. return nil
  32251. case usagestatisticmonth.FieldType:
  32252. v, ok := value.(int)
  32253. if !ok {
  32254. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32255. }
  32256. m.SetType(v)
  32257. return nil
  32258. case usagestatisticmonth.FieldBotID:
  32259. v, ok := value.(string)
  32260. if !ok {
  32261. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32262. }
  32263. m.SetBotID(v)
  32264. return nil
  32265. case usagestatisticmonth.FieldOrganizationID:
  32266. v, ok := value.(uint64)
  32267. if !ok {
  32268. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32269. }
  32270. m.SetOrganizationID(v)
  32271. return nil
  32272. case usagestatisticmonth.FieldAiResponse:
  32273. v, ok := value.(uint64)
  32274. if !ok {
  32275. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32276. }
  32277. m.SetAiResponse(v)
  32278. return nil
  32279. case usagestatisticmonth.FieldSopRun:
  32280. v, ok := value.(uint64)
  32281. if !ok {
  32282. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32283. }
  32284. m.SetSopRun(v)
  32285. return nil
  32286. case usagestatisticmonth.FieldTotalFriend:
  32287. v, ok := value.(uint64)
  32288. if !ok {
  32289. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32290. }
  32291. m.SetTotalFriend(v)
  32292. return nil
  32293. case usagestatisticmonth.FieldTotalGroup:
  32294. v, ok := value.(uint64)
  32295. if !ok {
  32296. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32297. }
  32298. m.SetTotalGroup(v)
  32299. return nil
  32300. case usagestatisticmonth.FieldAccountBalance:
  32301. v, ok := value.(uint64)
  32302. if !ok {
  32303. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32304. }
  32305. m.SetAccountBalance(v)
  32306. return nil
  32307. case usagestatisticmonth.FieldConsumeToken:
  32308. v, ok := value.(uint64)
  32309. if !ok {
  32310. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32311. }
  32312. m.SetConsumeToken(v)
  32313. return nil
  32314. case usagestatisticmonth.FieldActiveUser:
  32315. v, ok := value.(uint64)
  32316. if !ok {
  32317. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32318. }
  32319. m.SetActiveUser(v)
  32320. return nil
  32321. case usagestatisticmonth.FieldNewUser:
  32322. v, ok := value.(int64)
  32323. if !ok {
  32324. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32325. }
  32326. m.SetNewUser(v)
  32327. return nil
  32328. case usagestatisticmonth.FieldLabelDist:
  32329. v, ok := value.([]custom_types.LabelDist)
  32330. if !ok {
  32331. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32332. }
  32333. m.SetLabelDist(v)
  32334. return nil
  32335. }
  32336. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32337. }
  32338. // AddedFields returns all numeric fields that were incremented/decremented during
  32339. // this mutation.
  32340. func (m *UsageStatisticMonthMutation) AddedFields() []string {
  32341. var fields []string
  32342. if m.addstatus != nil {
  32343. fields = append(fields, usagestatisticmonth.FieldStatus)
  32344. }
  32345. if m.addaddtime != nil {
  32346. fields = append(fields, usagestatisticmonth.FieldAddtime)
  32347. }
  32348. if m.add_type != nil {
  32349. fields = append(fields, usagestatisticmonth.FieldType)
  32350. }
  32351. if m.addorganization_id != nil {
  32352. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32353. }
  32354. if m.addai_response != nil {
  32355. fields = append(fields, usagestatisticmonth.FieldAiResponse)
  32356. }
  32357. if m.addsop_run != nil {
  32358. fields = append(fields, usagestatisticmonth.FieldSopRun)
  32359. }
  32360. if m.addtotal_friend != nil {
  32361. fields = append(fields, usagestatisticmonth.FieldTotalFriend)
  32362. }
  32363. if m.addtotal_group != nil {
  32364. fields = append(fields, usagestatisticmonth.FieldTotalGroup)
  32365. }
  32366. if m.addaccount_balance != nil {
  32367. fields = append(fields, usagestatisticmonth.FieldAccountBalance)
  32368. }
  32369. if m.addconsume_token != nil {
  32370. fields = append(fields, usagestatisticmonth.FieldConsumeToken)
  32371. }
  32372. if m.addactive_user != nil {
  32373. fields = append(fields, usagestatisticmonth.FieldActiveUser)
  32374. }
  32375. if m.addnew_user != nil {
  32376. fields = append(fields, usagestatisticmonth.FieldNewUser)
  32377. }
  32378. return fields
  32379. }
  32380. // AddedField returns the numeric value that was incremented/decremented on a field
  32381. // with the given name. The second boolean return value indicates that this field
  32382. // was not set, or was not defined in the schema.
  32383. func (m *UsageStatisticMonthMutation) AddedField(name string) (ent.Value, bool) {
  32384. switch name {
  32385. case usagestatisticmonth.FieldStatus:
  32386. return m.AddedStatus()
  32387. case usagestatisticmonth.FieldAddtime:
  32388. return m.AddedAddtime()
  32389. case usagestatisticmonth.FieldType:
  32390. return m.AddedType()
  32391. case usagestatisticmonth.FieldOrganizationID:
  32392. return m.AddedOrganizationID()
  32393. case usagestatisticmonth.FieldAiResponse:
  32394. return m.AddedAiResponse()
  32395. case usagestatisticmonth.FieldSopRun:
  32396. return m.AddedSopRun()
  32397. case usagestatisticmonth.FieldTotalFriend:
  32398. return m.AddedTotalFriend()
  32399. case usagestatisticmonth.FieldTotalGroup:
  32400. return m.AddedTotalGroup()
  32401. case usagestatisticmonth.FieldAccountBalance:
  32402. return m.AddedAccountBalance()
  32403. case usagestatisticmonth.FieldConsumeToken:
  32404. return m.AddedConsumeToken()
  32405. case usagestatisticmonth.FieldActiveUser:
  32406. return m.AddedActiveUser()
  32407. case usagestatisticmonth.FieldNewUser:
  32408. return m.AddedNewUser()
  32409. }
  32410. return nil, false
  32411. }
  32412. // AddField adds the value to the field with the given name. It returns an error if
  32413. // the field is not defined in the schema, or if the type mismatched the field
  32414. // type.
  32415. func (m *UsageStatisticMonthMutation) AddField(name string, value ent.Value) error {
  32416. switch name {
  32417. case usagestatisticmonth.FieldStatus:
  32418. v, ok := value.(int8)
  32419. if !ok {
  32420. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32421. }
  32422. m.AddStatus(v)
  32423. return nil
  32424. case usagestatisticmonth.FieldAddtime:
  32425. v, ok := value.(int64)
  32426. if !ok {
  32427. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32428. }
  32429. m.AddAddtime(v)
  32430. return nil
  32431. case usagestatisticmonth.FieldType:
  32432. v, ok := value.(int)
  32433. if !ok {
  32434. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32435. }
  32436. m.AddType(v)
  32437. return nil
  32438. case usagestatisticmonth.FieldOrganizationID:
  32439. v, ok := value.(int64)
  32440. if !ok {
  32441. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32442. }
  32443. m.AddOrganizationID(v)
  32444. return nil
  32445. case usagestatisticmonth.FieldAiResponse:
  32446. v, ok := value.(int64)
  32447. if !ok {
  32448. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32449. }
  32450. m.AddAiResponse(v)
  32451. return nil
  32452. case usagestatisticmonth.FieldSopRun:
  32453. v, ok := value.(int64)
  32454. if !ok {
  32455. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32456. }
  32457. m.AddSopRun(v)
  32458. return nil
  32459. case usagestatisticmonth.FieldTotalFriend:
  32460. v, ok := value.(int64)
  32461. if !ok {
  32462. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32463. }
  32464. m.AddTotalFriend(v)
  32465. return nil
  32466. case usagestatisticmonth.FieldTotalGroup:
  32467. v, ok := value.(int64)
  32468. if !ok {
  32469. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32470. }
  32471. m.AddTotalGroup(v)
  32472. return nil
  32473. case usagestatisticmonth.FieldAccountBalance:
  32474. v, ok := value.(int64)
  32475. if !ok {
  32476. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32477. }
  32478. m.AddAccountBalance(v)
  32479. return nil
  32480. case usagestatisticmonth.FieldConsumeToken:
  32481. v, ok := value.(int64)
  32482. if !ok {
  32483. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32484. }
  32485. m.AddConsumeToken(v)
  32486. return nil
  32487. case usagestatisticmonth.FieldActiveUser:
  32488. v, ok := value.(int64)
  32489. if !ok {
  32490. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32491. }
  32492. m.AddActiveUser(v)
  32493. return nil
  32494. case usagestatisticmonth.FieldNewUser:
  32495. v, ok := value.(int64)
  32496. if !ok {
  32497. return fmt.Errorf("unexpected type %T for field %s", value, name)
  32498. }
  32499. m.AddNewUser(v)
  32500. return nil
  32501. }
  32502. return fmt.Errorf("unknown UsageStatisticMonth numeric field %s", name)
  32503. }
  32504. // ClearedFields returns all nullable fields that were cleared during this
  32505. // mutation.
  32506. func (m *UsageStatisticMonthMutation) ClearedFields() []string {
  32507. var fields []string
  32508. if m.FieldCleared(usagestatisticmonth.FieldStatus) {
  32509. fields = append(fields, usagestatisticmonth.FieldStatus)
  32510. }
  32511. if m.FieldCleared(usagestatisticmonth.FieldDeletedAt) {
  32512. fields = append(fields, usagestatisticmonth.FieldDeletedAt)
  32513. }
  32514. if m.FieldCleared(usagestatisticmonth.FieldBotID) {
  32515. fields = append(fields, usagestatisticmonth.FieldBotID)
  32516. }
  32517. if m.FieldCleared(usagestatisticmonth.FieldOrganizationID) {
  32518. fields = append(fields, usagestatisticmonth.FieldOrganizationID)
  32519. }
  32520. return fields
  32521. }
  32522. // FieldCleared returns a boolean indicating if a field with the given name was
  32523. // cleared in this mutation.
  32524. func (m *UsageStatisticMonthMutation) FieldCleared(name string) bool {
  32525. _, ok := m.clearedFields[name]
  32526. return ok
  32527. }
  32528. // ClearField clears the value of the field with the given name. It returns an
  32529. // error if the field is not defined in the schema.
  32530. func (m *UsageStatisticMonthMutation) ClearField(name string) error {
  32531. switch name {
  32532. case usagestatisticmonth.FieldStatus:
  32533. m.ClearStatus()
  32534. return nil
  32535. case usagestatisticmonth.FieldDeletedAt:
  32536. m.ClearDeletedAt()
  32537. return nil
  32538. case usagestatisticmonth.FieldBotID:
  32539. m.ClearBotID()
  32540. return nil
  32541. case usagestatisticmonth.FieldOrganizationID:
  32542. m.ClearOrganizationID()
  32543. return nil
  32544. }
  32545. return fmt.Errorf("unknown UsageStatisticMonth nullable field %s", name)
  32546. }
  32547. // ResetField resets all changes in the mutation for the field with the given name.
  32548. // It returns an error if the field is not defined in the schema.
  32549. func (m *UsageStatisticMonthMutation) ResetField(name string) error {
  32550. switch name {
  32551. case usagestatisticmonth.FieldCreatedAt:
  32552. m.ResetCreatedAt()
  32553. return nil
  32554. case usagestatisticmonth.FieldUpdatedAt:
  32555. m.ResetUpdatedAt()
  32556. return nil
  32557. case usagestatisticmonth.FieldStatus:
  32558. m.ResetStatus()
  32559. return nil
  32560. case usagestatisticmonth.FieldDeletedAt:
  32561. m.ResetDeletedAt()
  32562. return nil
  32563. case usagestatisticmonth.FieldAddtime:
  32564. m.ResetAddtime()
  32565. return nil
  32566. case usagestatisticmonth.FieldType:
  32567. m.ResetType()
  32568. return nil
  32569. case usagestatisticmonth.FieldBotID:
  32570. m.ResetBotID()
  32571. return nil
  32572. case usagestatisticmonth.FieldOrganizationID:
  32573. m.ResetOrganizationID()
  32574. return nil
  32575. case usagestatisticmonth.FieldAiResponse:
  32576. m.ResetAiResponse()
  32577. return nil
  32578. case usagestatisticmonth.FieldSopRun:
  32579. m.ResetSopRun()
  32580. return nil
  32581. case usagestatisticmonth.FieldTotalFriend:
  32582. m.ResetTotalFriend()
  32583. return nil
  32584. case usagestatisticmonth.FieldTotalGroup:
  32585. m.ResetTotalGroup()
  32586. return nil
  32587. case usagestatisticmonth.FieldAccountBalance:
  32588. m.ResetAccountBalance()
  32589. return nil
  32590. case usagestatisticmonth.FieldConsumeToken:
  32591. m.ResetConsumeToken()
  32592. return nil
  32593. case usagestatisticmonth.FieldActiveUser:
  32594. m.ResetActiveUser()
  32595. return nil
  32596. case usagestatisticmonth.FieldNewUser:
  32597. m.ResetNewUser()
  32598. return nil
  32599. case usagestatisticmonth.FieldLabelDist:
  32600. m.ResetLabelDist()
  32601. return nil
  32602. }
  32603. return fmt.Errorf("unknown UsageStatisticMonth field %s", name)
  32604. }
  32605. // AddedEdges returns all edge names that were set/added in this mutation.
  32606. func (m *UsageStatisticMonthMutation) AddedEdges() []string {
  32607. edges := make([]string, 0, 0)
  32608. return edges
  32609. }
  32610. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  32611. // name in this mutation.
  32612. func (m *UsageStatisticMonthMutation) AddedIDs(name string) []ent.Value {
  32613. return nil
  32614. }
  32615. // RemovedEdges returns all edge names that were removed in this mutation.
  32616. func (m *UsageStatisticMonthMutation) RemovedEdges() []string {
  32617. edges := make([]string, 0, 0)
  32618. return edges
  32619. }
  32620. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  32621. // the given name in this mutation.
  32622. func (m *UsageStatisticMonthMutation) RemovedIDs(name string) []ent.Value {
  32623. return nil
  32624. }
  32625. // ClearedEdges returns all edge names that were cleared in this mutation.
  32626. func (m *UsageStatisticMonthMutation) ClearedEdges() []string {
  32627. edges := make([]string, 0, 0)
  32628. return edges
  32629. }
  32630. // EdgeCleared returns a boolean which indicates if the edge with the given name
  32631. // was cleared in this mutation.
  32632. func (m *UsageStatisticMonthMutation) EdgeCleared(name string) bool {
  32633. return false
  32634. }
  32635. // ClearEdge clears the value of the edge with the given name. It returns an error
  32636. // if that edge is not defined in the schema.
  32637. func (m *UsageStatisticMonthMutation) ClearEdge(name string) error {
  32638. return fmt.Errorf("unknown UsageStatisticMonth unique edge %s", name)
  32639. }
  32640. // ResetEdge resets all changes to the edge with the given name in this mutation.
  32641. // It returns an error if the edge is not defined in the schema.
  32642. func (m *UsageStatisticMonthMutation) ResetEdge(name string) error {
  32643. return fmt.Errorf("unknown UsageStatisticMonth edge %s", name)
  32644. }
  32645. // UsageTotalMutation represents an operation that mutates the UsageTotal nodes in the graph.
  32646. type UsageTotalMutation struct {
  32647. config
  32648. op Op
  32649. typ string
  32650. id *uint64
  32651. created_at *time.Time
  32652. updated_at *time.Time
  32653. status *uint8
  32654. addstatus *int8
  32655. _type *int
  32656. add_type *int
  32657. bot_id *string
  32658. total_tokens *uint64
  32659. addtotal_tokens *int64
  32660. start_index *uint64
  32661. addstart_index *int64
  32662. end_index *uint64
  32663. addend_index *int64
  32664. organization_id *uint64
  32665. addorganization_id *int64
  32666. clearedFields map[string]struct{}
  32667. done bool
  32668. oldValue func(context.Context) (*UsageTotal, error)
  32669. predicates []predicate.UsageTotal
  32670. }
  32671. var _ ent.Mutation = (*UsageTotalMutation)(nil)
  32672. // usagetotalOption allows management of the mutation configuration using functional options.
  32673. type usagetotalOption func(*UsageTotalMutation)
  32674. // newUsageTotalMutation creates new mutation for the UsageTotal entity.
  32675. func newUsageTotalMutation(c config, op Op, opts ...usagetotalOption) *UsageTotalMutation {
  32676. m := &UsageTotalMutation{
  32677. config: c,
  32678. op: op,
  32679. typ: TypeUsageTotal,
  32680. clearedFields: make(map[string]struct{}),
  32681. }
  32682. for _, opt := range opts {
  32683. opt(m)
  32684. }
  32685. return m
  32686. }
  32687. // withUsageTotalID sets the ID field of the mutation.
  32688. func withUsageTotalID(id uint64) usagetotalOption {
  32689. return func(m *UsageTotalMutation) {
  32690. var (
  32691. err error
  32692. once sync.Once
  32693. value *UsageTotal
  32694. )
  32695. m.oldValue = func(ctx context.Context) (*UsageTotal, error) {
  32696. once.Do(func() {
  32697. if m.done {
  32698. err = errors.New("querying old values post mutation is not allowed")
  32699. } else {
  32700. value, err = m.Client().UsageTotal.Get(ctx, id)
  32701. }
  32702. })
  32703. return value, err
  32704. }
  32705. m.id = &id
  32706. }
  32707. }
  32708. // withUsageTotal sets the old UsageTotal of the mutation.
  32709. func withUsageTotal(node *UsageTotal) usagetotalOption {
  32710. return func(m *UsageTotalMutation) {
  32711. m.oldValue = func(context.Context) (*UsageTotal, error) {
  32712. return node, nil
  32713. }
  32714. m.id = &node.ID
  32715. }
  32716. }
  32717. // Client returns a new `ent.Client` from the mutation. If the mutation was
  32718. // executed in a transaction (ent.Tx), a transactional client is returned.
  32719. func (m UsageTotalMutation) Client() *Client {
  32720. client := &Client{config: m.config}
  32721. client.init()
  32722. return client
  32723. }
  32724. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  32725. // it returns an error otherwise.
  32726. func (m UsageTotalMutation) Tx() (*Tx, error) {
  32727. if _, ok := m.driver.(*txDriver); !ok {
  32728. return nil, errors.New("ent: mutation is not running in a transaction")
  32729. }
  32730. tx := &Tx{config: m.config}
  32731. tx.init()
  32732. return tx, nil
  32733. }
  32734. // SetID sets the value of the id field. Note that this
  32735. // operation is only accepted on creation of UsageTotal entities.
  32736. func (m *UsageTotalMutation) SetID(id uint64) {
  32737. m.id = &id
  32738. }
  32739. // ID returns the ID value in the mutation. Note that the ID is only available
  32740. // if it was provided to the builder or after it was returned from the database.
  32741. func (m *UsageTotalMutation) ID() (id uint64, exists bool) {
  32742. if m.id == nil {
  32743. return
  32744. }
  32745. return *m.id, true
  32746. }
  32747. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  32748. // That means, if the mutation is applied within a transaction with an isolation level such
  32749. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  32750. // or updated by the mutation.
  32751. func (m *UsageTotalMutation) IDs(ctx context.Context) ([]uint64, error) {
  32752. switch {
  32753. case m.op.Is(OpUpdateOne | OpDeleteOne):
  32754. id, exists := m.ID()
  32755. if exists {
  32756. return []uint64{id}, nil
  32757. }
  32758. fallthrough
  32759. case m.op.Is(OpUpdate | OpDelete):
  32760. return m.Client().UsageTotal.Query().Where(m.predicates...).IDs(ctx)
  32761. default:
  32762. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  32763. }
  32764. }
  32765. // SetCreatedAt sets the "created_at" field.
  32766. func (m *UsageTotalMutation) SetCreatedAt(t time.Time) {
  32767. m.created_at = &t
  32768. }
  32769. // CreatedAt returns the value of the "created_at" field in the mutation.
  32770. func (m *UsageTotalMutation) CreatedAt() (r time.Time, exists bool) {
  32771. v := m.created_at
  32772. if v == nil {
  32773. return
  32774. }
  32775. return *v, true
  32776. }
  32777. // OldCreatedAt returns the old "created_at" field's value of the UsageTotal entity.
  32778. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32779. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32780. func (m *UsageTotalMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  32781. if !m.op.Is(OpUpdateOne) {
  32782. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  32783. }
  32784. if m.id == nil || m.oldValue == nil {
  32785. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  32786. }
  32787. oldValue, err := m.oldValue(ctx)
  32788. if err != nil {
  32789. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  32790. }
  32791. return oldValue.CreatedAt, nil
  32792. }
  32793. // ResetCreatedAt resets all changes to the "created_at" field.
  32794. func (m *UsageTotalMutation) ResetCreatedAt() {
  32795. m.created_at = nil
  32796. }
  32797. // SetUpdatedAt sets the "updated_at" field.
  32798. func (m *UsageTotalMutation) SetUpdatedAt(t time.Time) {
  32799. m.updated_at = &t
  32800. }
  32801. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  32802. func (m *UsageTotalMutation) UpdatedAt() (r time.Time, exists bool) {
  32803. v := m.updated_at
  32804. if v == nil {
  32805. return
  32806. }
  32807. return *v, true
  32808. }
  32809. // OldUpdatedAt returns the old "updated_at" field's value of the UsageTotal entity.
  32810. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32811. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32812. func (m *UsageTotalMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  32813. if !m.op.Is(OpUpdateOne) {
  32814. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  32815. }
  32816. if m.id == nil || m.oldValue == nil {
  32817. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  32818. }
  32819. oldValue, err := m.oldValue(ctx)
  32820. if err != nil {
  32821. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  32822. }
  32823. return oldValue.UpdatedAt, nil
  32824. }
  32825. // ResetUpdatedAt resets all changes to the "updated_at" field.
  32826. func (m *UsageTotalMutation) ResetUpdatedAt() {
  32827. m.updated_at = nil
  32828. }
  32829. // SetStatus sets the "status" field.
  32830. func (m *UsageTotalMutation) SetStatus(u uint8) {
  32831. m.status = &u
  32832. m.addstatus = nil
  32833. }
  32834. // Status returns the value of the "status" field in the mutation.
  32835. func (m *UsageTotalMutation) Status() (r uint8, exists bool) {
  32836. v := m.status
  32837. if v == nil {
  32838. return
  32839. }
  32840. return *v, true
  32841. }
  32842. // OldStatus returns the old "status" field's value of the UsageTotal entity.
  32843. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32844. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32845. func (m *UsageTotalMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  32846. if !m.op.Is(OpUpdateOne) {
  32847. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  32848. }
  32849. if m.id == nil || m.oldValue == nil {
  32850. return v, errors.New("OldStatus requires an ID field in the mutation")
  32851. }
  32852. oldValue, err := m.oldValue(ctx)
  32853. if err != nil {
  32854. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  32855. }
  32856. return oldValue.Status, nil
  32857. }
  32858. // AddStatus adds u to the "status" field.
  32859. func (m *UsageTotalMutation) AddStatus(u int8) {
  32860. if m.addstatus != nil {
  32861. *m.addstatus += u
  32862. } else {
  32863. m.addstatus = &u
  32864. }
  32865. }
  32866. // AddedStatus returns the value that was added to the "status" field in this mutation.
  32867. func (m *UsageTotalMutation) AddedStatus() (r int8, exists bool) {
  32868. v := m.addstatus
  32869. if v == nil {
  32870. return
  32871. }
  32872. return *v, true
  32873. }
  32874. // ClearStatus clears the value of the "status" field.
  32875. func (m *UsageTotalMutation) ClearStatus() {
  32876. m.status = nil
  32877. m.addstatus = nil
  32878. m.clearedFields[usagetotal.FieldStatus] = struct{}{}
  32879. }
  32880. // StatusCleared returns if the "status" field was cleared in this mutation.
  32881. func (m *UsageTotalMutation) StatusCleared() bool {
  32882. _, ok := m.clearedFields[usagetotal.FieldStatus]
  32883. return ok
  32884. }
  32885. // ResetStatus resets all changes to the "status" field.
  32886. func (m *UsageTotalMutation) ResetStatus() {
  32887. m.status = nil
  32888. m.addstatus = nil
  32889. delete(m.clearedFields, usagetotal.FieldStatus)
  32890. }
  32891. // SetType sets the "type" field.
  32892. func (m *UsageTotalMutation) SetType(i int) {
  32893. m._type = &i
  32894. m.add_type = nil
  32895. }
  32896. // GetType returns the value of the "type" field in the mutation.
  32897. func (m *UsageTotalMutation) GetType() (r int, exists bool) {
  32898. v := m._type
  32899. if v == nil {
  32900. return
  32901. }
  32902. return *v, true
  32903. }
  32904. // OldType returns the old "type" field's value of the UsageTotal entity.
  32905. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32906. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32907. func (m *UsageTotalMutation) OldType(ctx context.Context) (v int, err error) {
  32908. if !m.op.Is(OpUpdateOne) {
  32909. return v, errors.New("OldType is only allowed on UpdateOne operations")
  32910. }
  32911. if m.id == nil || m.oldValue == nil {
  32912. return v, errors.New("OldType requires an ID field in the mutation")
  32913. }
  32914. oldValue, err := m.oldValue(ctx)
  32915. if err != nil {
  32916. return v, fmt.Errorf("querying old value for OldType: %w", err)
  32917. }
  32918. return oldValue.Type, nil
  32919. }
  32920. // AddType adds i to the "type" field.
  32921. func (m *UsageTotalMutation) AddType(i int) {
  32922. if m.add_type != nil {
  32923. *m.add_type += i
  32924. } else {
  32925. m.add_type = &i
  32926. }
  32927. }
  32928. // AddedType returns the value that was added to the "type" field in this mutation.
  32929. func (m *UsageTotalMutation) AddedType() (r int, exists bool) {
  32930. v := m.add_type
  32931. if v == nil {
  32932. return
  32933. }
  32934. return *v, true
  32935. }
  32936. // ClearType clears the value of the "type" field.
  32937. func (m *UsageTotalMutation) ClearType() {
  32938. m._type = nil
  32939. m.add_type = nil
  32940. m.clearedFields[usagetotal.FieldType] = struct{}{}
  32941. }
  32942. // TypeCleared returns if the "type" field was cleared in this mutation.
  32943. func (m *UsageTotalMutation) TypeCleared() bool {
  32944. _, ok := m.clearedFields[usagetotal.FieldType]
  32945. return ok
  32946. }
  32947. // ResetType resets all changes to the "type" field.
  32948. func (m *UsageTotalMutation) ResetType() {
  32949. m._type = nil
  32950. m.add_type = nil
  32951. delete(m.clearedFields, usagetotal.FieldType)
  32952. }
  32953. // SetBotID sets the "bot_id" field.
  32954. func (m *UsageTotalMutation) SetBotID(s string) {
  32955. m.bot_id = &s
  32956. }
  32957. // BotID returns the value of the "bot_id" field in the mutation.
  32958. func (m *UsageTotalMutation) BotID() (r string, exists bool) {
  32959. v := m.bot_id
  32960. if v == nil {
  32961. return
  32962. }
  32963. return *v, true
  32964. }
  32965. // OldBotID returns the old "bot_id" field's value of the UsageTotal entity.
  32966. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  32967. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  32968. func (m *UsageTotalMutation) OldBotID(ctx context.Context) (v string, err error) {
  32969. if !m.op.Is(OpUpdateOne) {
  32970. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  32971. }
  32972. if m.id == nil || m.oldValue == nil {
  32973. return v, errors.New("OldBotID requires an ID field in the mutation")
  32974. }
  32975. oldValue, err := m.oldValue(ctx)
  32976. if err != nil {
  32977. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  32978. }
  32979. return oldValue.BotID, nil
  32980. }
  32981. // ResetBotID resets all changes to the "bot_id" field.
  32982. func (m *UsageTotalMutation) ResetBotID() {
  32983. m.bot_id = nil
  32984. }
  32985. // SetTotalTokens sets the "total_tokens" field.
  32986. func (m *UsageTotalMutation) SetTotalTokens(u uint64) {
  32987. m.total_tokens = &u
  32988. m.addtotal_tokens = nil
  32989. }
  32990. // TotalTokens returns the value of the "total_tokens" field in the mutation.
  32991. func (m *UsageTotalMutation) TotalTokens() (r uint64, exists bool) {
  32992. v := m.total_tokens
  32993. if v == nil {
  32994. return
  32995. }
  32996. return *v, true
  32997. }
  32998. // OldTotalTokens returns the old "total_tokens" field's value of the UsageTotal entity.
  32999. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33000. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33001. func (m *UsageTotalMutation) OldTotalTokens(ctx context.Context) (v uint64, err error) {
  33002. if !m.op.Is(OpUpdateOne) {
  33003. return v, errors.New("OldTotalTokens is only allowed on UpdateOne operations")
  33004. }
  33005. if m.id == nil || m.oldValue == nil {
  33006. return v, errors.New("OldTotalTokens requires an ID field in the mutation")
  33007. }
  33008. oldValue, err := m.oldValue(ctx)
  33009. if err != nil {
  33010. return v, fmt.Errorf("querying old value for OldTotalTokens: %w", err)
  33011. }
  33012. return oldValue.TotalTokens, nil
  33013. }
  33014. // AddTotalTokens adds u to the "total_tokens" field.
  33015. func (m *UsageTotalMutation) AddTotalTokens(u int64) {
  33016. if m.addtotal_tokens != nil {
  33017. *m.addtotal_tokens += u
  33018. } else {
  33019. m.addtotal_tokens = &u
  33020. }
  33021. }
  33022. // AddedTotalTokens returns the value that was added to the "total_tokens" field in this mutation.
  33023. func (m *UsageTotalMutation) AddedTotalTokens() (r int64, exists bool) {
  33024. v := m.addtotal_tokens
  33025. if v == nil {
  33026. return
  33027. }
  33028. return *v, true
  33029. }
  33030. // ClearTotalTokens clears the value of the "total_tokens" field.
  33031. func (m *UsageTotalMutation) ClearTotalTokens() {
  33032. m.total_tokens = nil
  33033. m.addtotal_tokens = nil
  33034. m.clearedFields[usagetotal.FieldTotalTokens] = struct{}{}
  33035. }
  33036. // TotalTokensCleared returns if the "total_tokens" field was cleared in this mutation.
  33037. func (m *UsageTotalMutation) TotalTokensCleared() bool {
  33038. _, ok := m.clearedFields[usagetotal.FieldTotalTokens]
  33039. return ok
  33040. }
  33041. // ResetTotalTokens resets all changes to the "total_tokens" field.
  33042. func (m *UsageTotalMutation) ResetTotalTokens() {
  33043. m.total_tokens = nil
  33044. m.addtotal_tokens = nil
  33045. delete(m.clearedFields, usagetotal.FieldTotalTokens)
  33046. }
  33047. // SetStartIndex sets the "start_index" field.
  33048. func (m *UsageTotalMutation) SetStartIndex(u uint64) {
  33049. m.start_index = &u
  33050. m.addstart_index = nil
  33051. }
  33052. // StartIndex returns the value of the "start_index" field in the mutation.
  33053. func (m *UsageTotalMutation) StartIndex() (r uint64, exists bool) {
  33054. v := m.start_index
  33055. if v == nil {
  33056. return
  33057. }
  33058. return *v, true
  33059. }
  33060. // OldStartIndex returns the old "start_index" field's value of the UsageTotal entity.
  33061. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33062. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33063. func (m *UsageTotalMutation) OldStartIndex(ctx context.Context) (v uint64, err error) {
  33064. if !m.op.Is(OpUpdateOne) {
  33065. return v, errors.New("OldStartIndex is only allowed on UpdateOne operations")
  33066. }
  33067. if m.id == nil || m.oldValue == nil {
  33068. return v, errors.New("OldStartIndex requires an ID field in the mutation")
  33069. }
  33070. oldValue, err := m.oldValue(ctx)
  33071. if err != nil {
  33072. return v, fmt.Errorf("querying old value for OldStartIndex: %w", err)
  33073. }
  33074. return oldValue.StartIndex, nil
  33075. }
  33076. // AddStartIndex adds u to the "start_index" field.
  33077. func (m *UsageTotalMutation) AddStartIndex(u int64) {
  33078. if m.addstart_index != nil {
  33079. *m.addstart_index += u
  33080. } else {
  33081. m.addstart_index = &u
  33082. }
  33083. }
  33084. // AddedStartIndex returns the value that was added to the "start_index" field in this mutation.
  33085. func (m *UsageTotalMutation) AddedStartIndex() (r int64, exists bool) {
  33086. v := m.addstart_index
  33087. if v == nil {
  33088. return
  33089. }
  33090. return *v, true
  33091. }
  33092. // ClearStartIndex clears the value of the "start_index" field.
  33093. func (m *UsageTotalMutation) ClearStartIndex() {
  33094. m.start_index = nil
  33095. m.addstart_index = nil
  33096. m.clearedFields[usagetotal.FieldStartIndex] = struct{}{}
  33097. }
  33098. // StartIndexCleared returns if the "start_index" field was cleared in this mutation.
  33099. func (m *UsageTotalMutation) StartIndexCleared() bool {
  33100. _, ok := m.clearedFields[usagetotal.FieldStartIndex]
  33101. return ok
  33102. }
  33103. // ResetStartIndex resets all changes to the "start_index" field.
  33104. func (m *UsageTotalMutation) ResetStartIndex() {
  33105. m.start_index = nil
  33106. m.addstart_index = nil
  33107. delete(m.clearedFields, usagetotal.FieldStartIndex)
  33108. }
  33109. // SetEndIndex sets the "end_index" field.
  33110. func (m *UsageTotalMutation) SetEndIndex(u uint64) {
  33111. m.end_index = &u
  33112. m.addend_index = nil
  33113. }
  33114. // EndIndex returns the value of the "end_index" field in the mutation.
  33115. func (m *UsageTotalMutation) EndIndex() (r uint64, exists bool) {
  33116. v := m.end_index
  33117. if v == nil {
  33118. return
  33119. }
  33120. return *v, true
  33121. }
  33122. // OldEndIndex returns the old "end_index" field's value of the UsageTotal entity.
  33123. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33124. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33125. func (m *UsageTotalMutation) OldEndIndex(ctx context.Context) (v uint64, err error) {
  33126. if !m.op.Is(OpUpdateOne) {
  33127. return v, errors.New("OldEndIndex is only allowed on UpdateOne operations")
  33128. }
  33129. if m.id == nil || m.oldValue == nil {
  33130. return v, errors.New("OldEndIndex requires an ID field in the mutation")
  33131. }
  33132. oldValue, err := m.oldValue(ctx)
  33133. if err != nil {
  33134. return v, fmt.Errorf("querying old value for OldEndIndex: %w", err)
  33135. }
  33136. return oldValue.EndIndex, nil
  33137. }
  33138. // AddEndIndex adds u to the "end_index" field.
  33139. func (m *UsageTotalMutation) AddEndIndex(u int64) {
  33140. if m.addend_index != nil {
  33141. *m.addend_index += u
  33142. } else {
  33143. m.addend_index = &u
  33144. }
  33145. }
  33146. // AddedEndIndex returns the value that was added to the "end_index" field in this mutation.
  33147. func (m *UsageTotalMutation) AddedEndIndex() (r int64, exists bool) {
  33148. v := m.addend_index
  33149. if v == nil {
  33150. return
  33151. }
  33152. return *v, true
  33153. }
  33154. // ClearEndIndex clears the value of the "end_index" field.
  33155. func (m *UsageTotalMutation) ClearEndIndex() {
  33156. m.end_index = nil
  33157. m.addend_index = nil
  33158. m.clearedFields[usagetotal.FieldEndIndex] = struct{}{}
  33159. }
  33160. // EndIndexCleared returns if the "end_index" field was cleared in this mutation.
  33161. func (m *UsageTotalMutation) EndIndexCleared() bool {
  33162. _, ok := m.clearedFields[usagetotal.FieldEndIndex]
  33163. return ok
  33164. }
  33165. // ResetEndIndex resets all changes to the "end_index" field.
  33166. func (m *UsageTotalMutation) ResetEndIndex() {
  33167. m.end_index = nil
  33168. m.addend_index = nil
  33169. delete(m.clearedFields, usagetotal.FieldEndIndex)
  33170. }
  33171. // SetOrganizationID sets the "organization_id" field.
  33172. func (m *UsageTotalMutation) SetOrganizationID(u uint64) {
  33173. m.organization_id = &u
  33174. m.addorganization_id = nil
  33175. }
  33176. // OrganizationID returns the value of the "organization_id" field in the mutation.
  33177. func (m *UsageTotalMutation) OrganizationID() (r uint64, exists bool) {
  33178. v := m.organization_id
  33179. if v == nil {
  33180. return
  33181. }
  33182. return *v, true
  33183. }
  33184. // OldOrganizationID returns the old "organization_id" field's value of the UsageTotal entity.
  33185. // If the UsageTotal object wasn't provided to the builder, the object is fetched from the database.
  33186. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33187. func (m *UsageTotalMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  33188. if !m.op.Is(OpUpdateOne) {
  33189. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  33190. }
  33191. if m.id == nil || m.oldValue == nil {
  33192. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  33193. }
  33194. oldValue, err := m.oldValue(ctx)
  33195. if err != nil {
  33196. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  33197. }
  33198. return oldValue.OrganizationID, nil
  33199. }
  33200. // AddOrganizationID adds u to the "organization_id" field.
  33201. func (m *UsageTotalMutation) AddOrganizationID(u int64) {
  33202. if m.addorganization_id != nil {
  33203. *m.addorganization_id += u
  33204. } else {
  33205. m.addorganization_id = &u
  33206. }
  33207. }
  33208. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  33209. func (m *UsageTotalMutation) AddedOrganizationID() (r int64, exists bool) {
  33210. v := m.addorganization_id
  33211. if v == nil {
  33212. return
  33213. }
  33214. return *v, true
  33215. }
  33216. // ClearOrganizationID clears the value of the "organization_id" field.
  33217. func (m *UsageTotalMutation) ClearOrganizationID() {
  33218. m.organization_id = nil
  33219. m.addorganization_id = nil
  33220. m.clearedFields[usagetotal.FieldOrganizationID] = struct{}{}
  33221. }
  33222. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  33223. func (m *UsageTotalMutation) OrganizationIDCleared() bool {
  33224. _, ok := m.clearedFields[usagetotal.FieldOrganizationID]
  33225. return ok
  33226. }
  33227. // ResetOrganizationID resets all changes to the "organization_id" field.
  33228. func (m *UsageTotalMutation) ResetOrganizationID() {
  33229. m.organization_id = nil
  33230. m.addorganization_id = nil
  33231. delete(m.clearedFields, usagetotal.FieldOrganizationID)
  33232. }
  33233. // Where appends a list predicates to the UsageTotalMutation builder.
  33234. func (m *UsageTotalMutation) Where(ps ...predicate.UsageTotal) {
  33235. m.predicates = append(m.predicates, ps...)
  33236. }
  33237. // WhereP appends storage-level predicates to the UsageTotalMutation builder. Using this method,
  33238. // users can use type-assertion to append predicates that do not depend on any generated package.
  33239. func (m *UsageTotalMutation) WhereP(ps ...func(*sql.Selector)) {
  33240. p := make([]predicate.UsageTotal, len(ps))
  33241. for i := range ps {
  33242. p[i] = ps[i]
  33243. }
  33244. m.Where(p...)
  33245. }
  33246. // Op returns the operation name.
  33247. func (m *UsageTotalMutation) Op() Op {
  33248. return m.op
  33249. }
  33250. // SetOp allows setting the mutation operation.
  33251. func (m *UsageTotalMutation) SetOp(op Op) {
  33252. m.op = op
  33253. }
  33254. // Type returns the node type of this mutation (UsageTotal).
  33255. func (m *UsageTotalMutation) Type() string {
  33256. return m.typ
  33257. }
  33258. // Fields returns all fields that were changed during this mutation. Note that in
  33259. // order to get all numeric fields that were incremented/decremented, call
  33260. // AddedFields().
  33261. func (m *UsageTotalMutation) Fields() []string {
  33262. fields := make([]string, 0, 9)
  33263. if m.created_at != nil {
  33264. fields = append(fields, usagetotal.FieldCreatedAt)
  33265. }
  33266. if m.updated_at != nil {
  33267. fields = append(fields, usagetotal.FieldUpdatedAt)
  33268. }
  33269. if m.status != nil {
  33270. fields = append(fields, usagetotal.FieldStatus)
  33271. }
  33272. if m._type != nil {
  33273. fields = append(fields, usagetotal.FieldType)
  33274. }
  33275. if m.bot_id != nil {
  33276. fields = append(fields, usagetotal.FieldBotID)
  33277. }
  33278. if m.total_tokens != nil {
  33279. fields = append(fields, usagetotal.FieldTotalTokens)
  33280. }
  33281. if m.start_index != nil {
  33282. fields = append(fields, usagetotal.FieldStartIndex)
  33283. }
  33284. if m.end_index != nil {
  33285. fields = append(fields, usagetotal.FieldEndIndex)
  33286. }
  33287. if m.organization_id != nil {
  33288. fields = append(fields, usagetotal.FieldOrganizationID)
  33289. }
  33290. return fields
  33291. }
  33292. // Field returns the value of a field with the given name. The second boolean
  33293. // return value indicates that this field was not set, or was not defined in the
  33294. // schema.
  33295. func (m *UsageTotalMutation) Field(name string) (ent.Value, bool) {
  33296. switch name {
  33297. case usagetotal.FieldCreatedAt:
  33298. return m.CreatedAt()
  33299. case usagetotal.FieldUpdatedAt:
  33300. return m.UpdatedAt()
  33301. case usagetotal.FieldStatus:
  33302. return m.Status()
  33303. case usagetotal.FieldType:
  33304. return m.GetType()
  33305. case usagetotal.FieldBotID:
  33306. return m.BotID()
  33307. case usagetotal.FieldTotalTokens:
  33308. return m.TotalTokens()
  33309. case usagetotal.FieldStartIndex:
  33310. return m.StartIndex()
  33311. case usagetotal.FieldEndIndex:
  33312. return m.EndIndex()
  33313. case usagetotal.FieldOrganizationID:
  33314. return m.OrganizationID()
  33315. }
  33316. return nil, false
  33317. }
  33318. // OldField returns the old value of the field from the database. An error is
  33319. // returned if the mutation operation is not UpdateOne, or the query to the
  33320. // database failed.
  33321. func (m *UsageTotalMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  33322. switch name {
  33323. case usagetotal.FieldCreatedAt:
  33324. return m.OldCreatedAt(ctx)
  33325. case usagetotal.FieldUpdatedAt:
  33326. return m.OldUpdatedAt(ctx)
  33327. case usagetotal.FieldStatus:
  33328. return m.OldStatus(ctx)
  33329. case usagetotal.FieldType:
  33330. return m.OldType(ctx)
  33331. case usagetotal.FieldBotID:
  33332. return m.OldBotID(ctx)
  33333. case usagetotal.FieldTotalTokens:
  33334. return m.OldTotalTokens(ctx)
  33335. case usagetotal.FieldStartIndex:
  33336. return m.OldStartIndex(ctx)
  33337. case usagetotal.FieldEndIndex:
  33338. return m.OldEndIndex(ctx)
  33339. case usagetotal.FieldOrganizationID:
  33340. return m.OldOrganizationID(ctx)
  33341. }
  33342. return nil, fmt.Errorf("unknown UsageTotal field %s", name)
  33343. }
  33344. // SetField sets the value of a field with the given name. It returns an error if
  33345. // the field is not defined in the schema, or if the type mismatched the field
  33346. // type.
  33347. func (m *UsageTotalMutation) SetField(name string, value ent.Value) error {
  33348. switch name {
  33349. case usagetotal.FieldCreatedAt:
  33350. v, ok := value.(time.Time)
  33351. if !ok {
  33352. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33353. }
  33354. m.SetCreatedAt(v)
  33355. return nil
  33356. case usagetotal.FieldUpdatedAt:
  33357. v, ok := value.(time.Time)
  33358. if !ok {
  33359. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33360. }
  33361. m.SetUpdatedAt(v)
  33362. return nil
  33363. case usagetotal.FieldStatus:
  33364. v, ok := value.(uint8)
  33365. if !ok {
  33366. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33367. }
  33368. m.SetStatus(v)
  33369. return nil
  33370. case usagetotal.FieldType:
  33371. v, ok := value.(int)
  33372. if !ok {
  33373. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33374. }
  33375. m.SetType(v)
  33376. return nil
  33377. case usagetotal.FieldBotID:
  33378. v, ok := value.(string)
  33379. if !ok {
  33380. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33381. }
  33382. m.SetBotID(v)
  33383. return nil
  33384. case usagetotal.FieldTotalTokens:
  33385. v, ok := value.(uint64)
  33386. if !ok {
  33387. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33388. }
  33389. m.SetTotalTokens(v)
  33390. return nil
  33391. case usagetotal.FieldStartIndex:
  33392. v, ok := value.(uint64)
  33393. if !ok {
  33394. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33395. }
  33396. m.SetStartIndex(v)
  33397. return nil
  33398. case usagetotal.FieldEndIndex:
  33399. v, ok := value.(uint64)
  33400. if !ok {
  33401. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33402. }
  33403. m.SetEndIndex(v)
  33404. return nil
  33405. case usagetotal.FieldOrganizationID:
  33406. v, ok := value.(uint64)
  33407. if !ok {
  33408. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33409. }
  33410. m.SetOrganizationID(v)
  33411. return nil
  33412. }
  33413. return fmt.Errorf("unknown UsageTotal field %s", name)
  33414. }
  33415. // AddedFields returns all numeric fields that were incremented/decremented during
  33416. // this mutation.
  33417. func (m *UsageTotalMutation) AddedFields() []string {
  33418. var fields []string
  33419. if m.addstatus != nil {
  33420. fields = append(fields, usagetotal.FieldStatus)
  33421. }
  33422. if m.add_type != nil {
  33423. fields = append(fields, usagetotal.FieldType)
  33424. }
  33425. if m.addtotal_tokens != nil {
  33426. fields = append(fields, usagetotal.FieldTotalTokens)
  33427. }
  33428. if m.addstart_index != nil {
  33429. fields = append(fields, usagetotal.FieldStartIndex)
  33430. }
  33431. if m.addend_index != nil {
  33432. fields = append(fields, usagetotal.FieldEndIndex)
  33433. }
  33434. if m.addorganization_id != nil {
  33435. fields = append(fields, usagetotal.FieldOrganizationID)
  33436. }
  33437. return fields
  33438. }
  33439. // AddedField returns the numeric value that was incremented/decremented on a field
  33440. // with the given name. The second boolean return value indicates that this field
  33441. // was not set, or was not defined in the schema.
  33442. func (m *UsageTotalMutation) AddedField(name string) (ent.Value, bool) {
  33443. switch name {
  33444. case usagetotal.FieldStatus:
  33445. return m.AddedStatus()
  33446. case usagetotal.FieldType:
  33447. return m.AddedType()
  33448. case usagetotal.FieldTotalTokens:
  33449. return m.AddedTotalTokens()
  33450. case usagetotal.FieldStartIndex:
  33451. return m.AddedStartIndex()
  33452. case usagetotal.FieldEndIndex:
  33453. return m.AddedEndIndex()
  33454. case usagetotal.FieldOrganizationID:
  33455. return m.AddedOrganizationID()
  33456. }
  33457. return nil, false
  33458. }
  33459. // AddField adds the value to the field with the given name. It returns an error if
  33460. // the field is not defined in the schema, or if the type mismatched the field
  33461. // type.
  33462. func (m *UsageTotalMutation) AddField(name string, value ent.Value) error {
  33463. switch name {
  33464. case usagetotal.FieldStatus:
  33465. v, ok := value.(int8)
  33466. if !ok {
  33467. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33468. }
  33469. m.AddStatus(v)
  33470. return nil
  33471. case usagetotal.FieldType:
  33472. v, ok := value.(int)
  33473. if !ok {
  33474. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33475. }
  33476. m.AddType(v)
  33477. return nil
  33478. case usagetotal.FieldTotalTokens:
  33479. v, ok := value.(int64)
  33480. if !ok {
  33481. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33482. }
  33483. m.AddTotalTokens(v)
  33484. return nil
  33485. case usagetotal.FieldStartIndex:
  33486. v, ok := value.(int64)
  33487. if !ok {
  33488. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33489. }
  33490. m.AddStartIndex(v)
  33491. return nil
  33492. case usagetotal.FieldEndIndex:
  33493. v, ok := value.(int64)
  33494. if !ok {
  33495. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33496. }
  33497. m.AddEndIndex(v)
  33498. return nil
  33499. case usagetotal.FieldOrganizationID:
  33500. v, ok := value.(int64)
  33501. if !ok {
  33502. return fmt.Errorf("unexpected type %T for field %s", value, name)
  33503. }
  33504. m.AddOrganizationID(v)
  33505. return nil
  33506. }
  33507. return fmt.Errorf("unknown UsageTotal numeric field %s", name)
  33508. }
  33509. // ClearedFields returns all nullable fields that were cleared during this
  33510. // mutation.
  33511. func (m *UsageTotalMutation) ClearedFields() []string {
  33512. var fields []string
  33513. if m.FieldCleared(usagetotal.FieldStatus) {
  33514. fields = append(fields, usagetotal.FieldStatus)
  33515. }
  33516. if m.FieldCleared(usagetotal.FieldType) {
  33517. fields = append(fields, usagetotal.FieldType)
  33518. }
  33519. if m.FieldCleared(usagetotal.FieldTotalTokens) {
  33520. fields = append(fields, usagetotal.FieldTotalTokens)
  33521. }
  33522. if m.FieldCleared(usagetotal.FieldStartIndex) {
  33523. fields = append(fields, usagetotal.FieldStartIndex)
  33524. }
  33525. if m.FieldCleared(usagetotal.FieldEndIndex) {
  33526. fields = append(fields, usagetotal.FieldEndIndex)
  33527. }
  33528. if m.FieldCleared(usagetotal.FieldOrganizationID) {
  33529. fields = append(fields, usagetotal.FieldOrganizationID)
  33530. }
  33531. return fields
  33532. }
  33533. // FieldCleared returns a boolean indicating if a field with the given name was
  33534. // cleared in this mutation.
  33535. func (m *UsageTotalMutation) FieldCleared(name string) bool {
  33536. _, ok := m.clearedFields[name]
  33537. return ok
  33538. }
  33539. // ClearField clears the value of the field with the given name. It returns an
  33540. // error if the field is not defined in the schema.
  33541. func (m *UsageTotalMutation) ClearField(name string) error {
  33542. switch name {
  33543. case usagetotal.FieldStatus:
  33544. m.ClearStatus()
  33545. return nil
  33546. case usagetotal.FieldType:
  33547. m.ClearType()
  33548. return nil
  33549. case usagetotal.FieldTotalTokens:
  33550. m.ClearTotalTokens()
  33551. return nil
  33552. case usagetotal.FieldStartIndex:
  33553. m.ClearStartIndex()
  33554. return nil
  33555. case usagetotal.FieldEndIndex:
  33556. m.ClearEndIndex()
  33557. return nil
  33558. case usagetotal.FieldOrganizationID:
  33559. m.ClearOrganizationID()
  33560. return nil
  33561. }
  33562. return fmt.Errorf("unknown UsageTotal nullable field %s", name)
  33563. }
  33564. // ResetField resets all changes in the mutation for the field with the given name.
  33565. // It returns an error if the field is not defined in the schema.
  33566. func (m *UsageTotalMutation) ResetField(name string) error {
  33567. switch name {
  33568. case usagetotal.FieldCreatedAt:
  33569. m.ResetCreatedAt()
  33570. return nil
  33571. case usagetotal.FieldUpdatedAt:
  33572. m.ResetUpdatedAt()
  33573. return nil
  33574. case usagetotal.FieldStatus:
  33575. m.ResetStatus()
  33576. return nil
  33577. case usagetotal.FieldType:
  33578. m.ResetType()
  33579. return nil
  33580. case usagetotal.FieldBotID:
  33581. m.ResetBotID()
  33582. return nil
  33583. case usagetotal.FieldTotalTokens:
  33584. m.ResetTotalTokens()
  33585. return nil
  33586. case usagetotal.FieldStartIndex:
  33587. m.ResetStartIndex()
  33588. return nil
  33589. case usagetotal.FieldEndIndex:
  33590. m.ResetEndIndex()
  33591. return nil
  33592. case usagetotal.FieldOrganizationID:
  33593. m.ResetOrganizationID()
  33594. return nil
  33595. }
  33596. return fmt.Errorf("unknown UsageTotal field %s", name)
  33597. }
  33598. // AddedEdges returns all edge names that were set/added in this mutation.
  33599. func (m *UsageTotalMutation) AddedEdges() []string {
  33600. edges := make([]string, 0, 0)
  33601. return edges
  33602. }
  33603. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  33604. // name in this mutation.
  33605. func (m *UsageTotalMutation) AddedIDs(name string) []ent.Value {
  33606. return nil
  33607. }
  33608. // RemovedEdges returns all edge names that were removed in this mutation.
  33609. func (m *UsageTotalMutation) RemovedEdges() []string {
  33610. edges := make([]string, 0, 0)
  33611. return edges
  33612. }
  33613. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  33614. // the given name in this mutation.
  33615. func (m *UsageTotalMutation) RemovedIDs(name string) []ent.Value {
  33616. return nil
  33617. }
  33618. // ClearedEdges returns all edge names that were cleared in this mutation.
  33619. func (m *UsageTotalMutation) ClearedEdges() []string {
  33620. edges := make([]string, 0, 0)
  33621. return edges
  33622. }
  33623. // EdgeCleared returns a boolean which indicates if the edge with the given name
  33624. // was cleared in this mutation.
  33625. func (m *UsageTotalMutation) EdgeCleared(name string) bool {
  33626. return false
  33627. }
  33628. // ClearEdge clears the value of the edge with the given name. It returns an error
  33629. // if that edge is not defined in the schema.
  33630. func (m *UsageTotalMutation) ClearEdge(name string) error {
  33631. return fmt.Errorf("unknown UsageTotal unique edge %s", name)
  33632. }
  33633. // ResetEdge resets all changes to the edge with the given name in this mutation.
  33634. // It returns an error if the edge is not defined in the schema.
  33635. func (m *UsageTotalMutation) ResetEdge(name string) error {
  33636. return fmt.Errorf("unknown UsageTotal edge %s", name)
  33637. }
  33638. // WhatsappMutation represents an operation that mutates the Whatsapp nodes in the graph.
  33639. type WhatsappMutation struct {
  33640. config
  33641. op Op
  33642. typ string
  33643. id *uint64
  33644. created_at *time.Time
  33645. updated_at *time.Time
  33646. status *uint8
  33647. addstatus *int8
  33648. deleted_at *time.Time
  33649. ak *string
  33650. sk *string
  33651. callback *string
  33652. account *string
  33653. nickname *string
  33654. phone *string
  33655. organization_id *uint64
  33656. addorganization_id *int64
  33657. agent_id *uint64
  33658. addagent_id *int64
  33659. api_base *string
  33660. api_key *string
  33661. allow_list *[]string
  33662. appendallow_list []string
  33663. group_allow_list *[]string
  33664. appendgroup_allow_list []string
  33665. block_list *[]string
  33666. appendblock_list []string
  33667. group_block_list *[]string
  33668. appendgroup_block_list []string
  33669. clearedFields map[string]struct{}
  33670. done bool
  33671. oldValue func(context.Context) (*Whatsapp, error)
  33672. predicates []predicate.Whatsapp
  33673. }
  33674. var _ ent.Mutation = (*WhatsappMutation)(nil)
  33675. // whatsappOption allows management of the mutation configuration using functional options.
  33676. type whatsappOption func(*WhatsappMutation)
  33677. // newWhatsappMutation creates new mutation for the Whatsapp entity.
  33678. func newWhatsappMutation(c config, op Op, opts ...whatsappOption) *WhatsappMutation {
  33679. m := &WhatsappMutation{
  33680. config: c,
  33681. op: op,
  33682. typ: TypeWhatsapp,
  33683. clearedFields: make(map[string]struct{}),
  33684. }
  33685. for _, opt := range opts {
  33686. opt(m)
  33687. }
  33688. return m
  33689. }
  33690. // withWhatsappID sets the ID field of the mutation.
  33691. func withWhatsappID(id uint64) whatsappOption {
  33692. return func(m *WhatsappMutation) {
  33693. var (
  33694. err error
  33695. once sync.Once
  33696. value *Whatsapp
  33697. )
  33698. m.oldValue = func(ctx context.Context) (*Whatsapp, error) {
  33699. once.Do(func() {
  33700. if m.done {
  33701. err = errors.New("querying old values post mutation is not allowed")
  33702. } else {
  33703. value, err = m.Client().Whatsapp.Get(ctx, id)
  33704. }
  33705. })
  33706. return value, err
  33707. }
  33708. m.id = &id
  33709. }
  33710. }
  33711. // withWhatsapp sets the old Whatsapp of the mutation.
  33712. func withWhatsapp(node *Whatsapp) whatsappOption {
  33713. return func(m *WhatsappMutation) {
  33714. m.oldValue = func(context.Context) (*Whatsapp, error) {
  33715. return node, nil
  33716. }
  33717. m.id = &node.ID
  33718. }
  33719. }
  33720. // Client returns a new `ent.Client` from the mutation. If the mutation was
  33721. // executed in a transaction (ent.Tx), a transactional client is returned.
  33722. func (m WhatsappMutation) Client() *Client {
  33723. client := &Client{config: m.config}
  33724. client.init()
  33725. return client
  33726. }
  33727. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  33728. // it returns an error otherwise.
  33729. func (m WhatsappMutation) Tx() (*Tx, error) {
  33730. if _, ok := m.driver.(*txDriver); !ok {
  33731. return nil, errors.New("ent: mutation is not running in a transaction")
  33732. }
  33733. tx := &Tx{config: m.config}
  33734. tx.init()
  33735. return tx, nil
  33736. }
  33737. // SetID sets the value of the id field. Note that this
  33738. // operation is only accepted on creation of Whatsapp entities.
  33739. func (m *WhatsappMutation) SetID(id uint64) {
  33740. m.id = &id
  33741. }
  33742. // ID returns the ID value in the mutation. Note that the ID is only available
  33743. // if it was provided to the builder or after it was returned from the database.
  33744. func (m *WhatsappMutation) ID() (id uint64, exists bool) {
  33745. if m.id == nil {
  33746. return
  33747. }
  33748. return *m.id, true
  33749. }
  33750. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  33751. // That means, if the mutation is applied within a transaction with an isolation level such
  33752. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  33753. // or updated by the mutation.
  33754. func (m *WhatsappMutation) IDs(ctx context.Context) ([]uint64, error) {
  33755. switch {
  33756. case m.op.Is(OpUpdateOne | OpDeleteOne):
  33757. id, exists := m.ID()
  33758. if exists {
  33759. return []uint64{id}, nil
  33760. }
  33761. fallthrough
  33762. case m.op.Is(OpUpdate | OpDelete):
  33763. return m.Client().Whatsapp.Query().Where(m.predicates...).IDs(ctx)
  33764. default:
  33765. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  33766. }
  33767. }
  33768. // SetCreatedAt sets the "created_at" field.
  33769. func (m *WhatsappMutation) SetCreatedAt(t time.Time) {
  33770. m.created_at = &t
  33771. }
  33772. // CreatedAt returns the value of the "created_at" field in the mutation.
  33773. func (m *WhatsappMutation) CreatedAt() (r time.Time, exists bool) {
  33774. v := m.created_at
  33775. if v == nil {
  33776. return
  33777. }
  33778. return *v, true
  33779. }
  33780. // OldCreatedAt returns the old "created_at" field's value of the Whatsapp entity.
  33781. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33782. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33783. func (m *WhatsappMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  33784. if !m.op.Is(OpUpdateOne) {
  33785. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  33786. }
  33787. if m.id == nil || m.oldValue == nil {
  33788. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  33789. }
  33790. oldValue, err := m.oldValue(ctx)
  33791. if err != nil {
  33792. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  33793. }
  33794. return oldValue.CreatedAt, nil
  33795. }
  33796. // ResetCreatedAt resets all changes to the "created_at" field.
  33797. func (m *WhatsappMutation) ResetCreatedAt() {
  33798. m.created_at = nil
  33799. }
  33800. // SetUpdatedAt sets the "updated_at" field.
  33801. func (m *WhatsappMutation) SetUpdatedAt(t time.Time) {
  33802. m.updated_at = &t
  33803. }
  33804. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  33805. func (m *WhatsappMutation) UpdatedAt() (r time.Time, exists bool) {
  33806. v := m.updated_at
  33807. if v == nil {
  33808. return
  33809. }
  33810. return *v, true
  33811. }
  33812. // OldUpdatedAt returns the old "updated_at" field's value of the Whatsapp entity.
  33813. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33814. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33815. func (m *WhatsappMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  33816. if !m.op.Is(OpUpdateOne) {
  33817. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  33818. }
  33819. if m.id == nil || m.oldValue == nil {
  33820. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  33821. }
  33822. oldValue, err := m.oldValue(ctx)
  33823. if err != nil {
  33824. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  33825. }
  33826. return oldValue.UpdatedAt, nil
  33827. }
  33828. // ResetUpdatedAt resets all changes to the "updated_at" field.
  33829. func (m *WhatsappMutation) ResetUpdatedAt() {
  33830. m.updated_at = nil
  33831. }
  33832. // SetStatus sets the "status" field.
  33833. func (m *WhatsappMutation) SetStatus(u uint8) {
  33834. m.status = &u
  33835. m.addstatus = nil
  33836. }
  33837. // Status returns the value of the "status" field in the mutation.
  33838. func (m *WhatsappMutation) Status() (r uint8, exists bool) {
  33839. v := m.status
  33840. if v == nil {
  33841. return
  33842. }
  33843. return *v, true
  33844. }
  33845. // OldStatus returns the old "status" field's value of the Whatsapp entity.
  33846. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33847. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33848. func (m *WhatsappMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  33849. if !m.op.Is(OpUpdateOne) {
  33850. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  33851. }
  33852. if m.id == nil || m.oldValue == nil {
  33853. return v, errors.New("OldStatus requires an ID field in the mutation")
  33854. }
  33855. oldValue, err := m.oldValue(ctx)
  33856. if err != nil {
  33857. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  33858. }
  33859. return oldValue.Status, nil
  33860. }
  33861. // AddStatus adds u to the "status" field.
  33862. func (m *WhatsappMutation) AddStatus(u int8) {
  33863. if m.addstatus != nil {
  33864. *m.addstatus += u
  33865. } else {
  33866. m.addstatus = &u
  33867. }
  33868. }
  33869. // AddedStatus returns the value that was added to the "status" field in this mutation.
  33870. func (m *WhatsappMutation) AddedStatus() (r int8, exists bool) {
  33871. v := m.addstatus
  33872. if v == nil {
  33873. return
  33874. }
  33875. return *v, true
  33876. }
  33877. // ClearStatus clears the value of the "status" field.
  33878. func (m *WhatsappMutation) ClearStatus() {
  33879. m.status = nil
  33880. m.addstatus = nil
  33881. m.clearedFields[whatsapp.FieldStatus] = struct{}{}
  33882. }
  33883. // StatusCleared returns if the "status" field was cleared in this mutation.
  33884. func (m *WhatsappMutation) StatusCleared() bool {
  33885. _, ok := m.clearedFields[whatsapp.FieldStatus]
  33886. return ok
  33887. }
  33888. // ResetStatus resets all changes to the "status" field.
  33889. func (m *WhatsappMutation) ResetStatus() {
  33890. m.status = nil
  33891. m.addstatus = nil
  33892. delete(m.clearedFields, whatsapp.FieldStatus)
  33893. }
  33894. // SetDeletedAt sets the "deleted_at" field.
  33895. func (m *WhatsappMutation) SetDeletedAt(t time.Time) {
  33896. m.deleted_at = &t
  33897. }
  33898. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  33899. func (m *WhatsappMutation) DeletedAt() (r time.Time, exists bool) {
  33900. v := m.deleted_at
  33901. if v == nil {
  33902. return
  33903. }
  33904. return *v, true
  33905. }
  33906. // OldDeletedAt returns the old "deleted_at" field's value of the Whatsapp entity.
  33907. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33908. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33909. func (m *WhatsappMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  33910. if !m.op.Is(OpUpdateOne) {
  33911. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  33912. }
  33913. if m.id == nil || m.oldValue == nil {
  33914. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  33915. }
  33916. oldValue, err := m.oldValue(ctx)
  33917. if err != nil {
  33918. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  33919. }
  33920. return oldValue.DeletedAt, nil
  33921. }
  33922. // ClearDeletedAt clears the value of the "deleted_at" field.
  33923. func (m *WhatsappMutation) ClearDeletedAt() {
  33924. m.deleted_at = nil
  33925. m.clearedFields[whatsapp.FieldDeletedAt] = struct{}{}
  33926. }
  33927. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  33928. func (m *WhatsappMutation) DeletedAtCleared() bool {
  33929. _, ok := m.clearedFields[whatsapp.FieldDeletedAt]
  33930. return ok
  33931. }
  33932. // ResetDeletedAt resets all changes to the "deleted_at" field.
  33933. func (m *WhatsappMutation) ResetDeletedAt() {
  33934. m.deleted_at = nil
  33935. delete(m.clearedFields, whatsapp.FieldDeletedAt)
  33936. }
  33937. // SetAk sets the "ak" field.
  33938. func (m *WhatsappMutation) SetAk(s string) {
  33939. m.ak = &s
  33940. }
  33941. // Ak returns the value of the "ak" field in the mutation.
  33942. func (m *WhatsappMutation) Ak() (r string, exists bool) {
  33943. v := m.ak
  33944. if v == nil {
  33945. return
  33946. }
  33947. return *v, true
  33948. }
  33949. // OldAk returns the old "ak" field's value of the Whatsapp entity.
  33950. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33951. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33952. func (m *WhatsappMutation) OldAk(ctx context.Context) (v string, err error) {
  33953. if !m.op.Is(OpUpdateOne) {
  33954. return v, errors.New("OldAk is only allowed on UpdateOne operations")
  33955. }
  33956. if m.id == nil || m.oldValue == nil {
  33957. return v, errors.New("OldAk requires an ID field in the mutation")
  33958. }
  33959. oldValue, err := m.oldValue(ctx)
  33960. if err != nil {
  33961. return v, fmt.Errorf("querying old value for OldAk: %w", err)
  33962. }
  33963. return oldValue.Ak, nil
  33964. }
  33965. // ClearAk clears the value of the "ak" field.
  33966. func (m *WhatsappMutation) ClearAk() {
  33967. m.ak = nil
  33968. m.clearedFields[whatsapp.FieldAk] = struct{}{}
  33969. }
  33970. // AkCleared returns if the "ak" field was cleared in this mutation.
  33971. func (m *WhatsappMutation) AkCleared() bool {
  33972. _, ok := m.clearedFields[whatsapp.FieldAk]
  33973. return ok
  33974. }
  33975. // ResetAk resets all changes to the "ak" field.
  33976. func (m *WhatsappMutation) ResetAk() {
  33977. m.ak = nil
  33978. delete(m.clearedFields, whatsapp.FieldAk)
  33979. }
  33980. // SetSk sets the "sk" field.
  33981. func (m *WhatsappMutation) SetSk(s string) {
  33982. m.sk = &s
  33983. }
  33984. // Sk returns the value of the "sk" field in the mutation.
  33985. func (m *WhatsappMutation) Sk() (r string, exists bool) {
  33986. v := m.sk
  33987. if v == nil {
  33988. return
  33989. }
  33990. return *v, true
  33991. }
  33992. // OldSk returns the old "sk" field's value of the Whatsapp entity.
  33993. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  33994. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  33995. func (m *WhatsappMutation) OldSk(ctx context.Context) (v string, err error) {
  33996. if !m.op.Is(OpUpdateOne) {
  33997. return v, errors.New("OldSk is only allowed on UpdateOne operations")
  33998. }
  33999. if m.id == nil || m.oldValue == nil {
  34000. return v, errors.New("OldSk requires an ID field in the mutation")
  34001. }
  34002. oldValue, err := m.oldValue(ctx)
  34003. if err != nil {
  34004. return v, fmt.Errorf("querying old value for OldSk: %w", err)
  34005. }
  34006. return oldValue.Sk, nil
  34007. }
  34008. // ResetSk resets all changes to the "sk" field.
  34009. func (m *WhatsappMutation) ResetSk() {
  34010. m.sk = nil
  34011. }
  34012. // SetCallback sets the "callback" field.
  34013. func (m *WhatsappMutation) SetCallback(s string) {
  34014. m.callback = &s
  34015. }
  34016. // Callback returns the value of the "callback" field in the mutation.
  34017. func (m *WhatsappMutation) Callback() (r string, exists bool) {
  34018. v := m.callback
  34019. if v == nil {
  34020. return
  34021. }
  34022. return *v, true
  34023. }
  34024. // OldCallback returns the old "callback" field's value of the Whatsapp entity.
  34025. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34026. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34027. func (m *WhatsappMutation) OldCallback(ctx context.Context) (v string, err error) {
  34028. if !m.op.Is(OpUpdateOne) {
  34029. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  34030. }
  34031. if m.id == nil || m.oldValue == nil {
  34032. return v, errors.New("OldCallback requires an ID field in the mutation")
  34033. }
  34034. oldValue, err := m.oldValue(ctx)
  34035. if err != nil {
  34036. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  34037. }
  34038. return oldValue.Callback, nil
  34039. }
  34040. // ResetCallback resets all changes to the "callback" field.
  34041. func (m *WhatsappMutation) ResetCallback() {
  34042. m.callback = nil
  34043. }
  34044. // SetAccount sets the "account" field.
  34045. func (m *WhatsappMutation) SetAccount(s string) {
  34046. m.account = &s
  34047. }
  34048. // Account returns the value of the "account" field in the mutation.
  34049. func (m *WhatsappMutation) Account() (r string, exists bool) {
  34050. v := m.account
  34051. if v == nil {
  34052. return
  34053. }
  34054. return *v, true
  34055. }
  34056. // OldAccount returns the old "account" field's value of the Whatsapp entity.
  34057. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34058. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34059. func (m *WhatsappMutation) OldAccount(ctx context.Context) (v string, err error) {
  34060. if !m.op.Is(OpUpdateOne) {
  34061. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  34062. }
  34063. if m.id == nil || m.oldValue == nil {
  34064. return v, errors.New("OldAccount requires an ID field in the mutation")
  34065. }
  34066. oldValue, err := m.oldValue(ctx)
  34067. if err != nil {
  34068. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  34069. }
  34070. return oldValue.Account, nil
  34071. }
  34072. // ResetAccount resets all changes to the "account" field.
  34073. func (m *WhatsappMutation) ResetAccount() {
  34074. m.account = nil
  34075. }
  34076. // SetNickname sets the "nickname" field.
  34077. func (m *WhatsappMutation) SetNickname(s string) {
  34078. m.nickname = &s
  34079. }
  34080. // Nickname returns the value of the "nickname" field in the mutation.
  34081. func (m *WhatsappMutation) Nickname() (r string, exists bool) {
  34082. v := m.nickname
  34083. if v == nil {
  34084. return
  34085. }
  34086. return *v, true
  34087. }
  34088. // OldNickname returns the old "nickname" field's value of the Whatsapp entity.
  34089. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34090. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34091. func (m *WhatsappMutation) OldNickname(ctx context.Context) (v string, err error) {
  34092. if !m.op.Is(OpUpdateOne) {
  34093. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  34094. }
  34095. if m.id == nil || m.oldValue == nil {
  34096. return v, errors.New("OldNickname requires an ID field in the mutation")
  34097. }
  34098. oldValue, err := m.oldValue(ctx)
  34099. if err != nil {
  34100. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  34101. }
  34102. return oldValue.Nickname, nil
  34103. }
  34104. // ResetNickname resets all changes to the "nickname" field.
  34105. func (m *WhatsappMutation) ResetNickname() {
  34106. m.nickname = nil
  34107. }
  34108. // SetPhone sets the "phone" field.
  34109. func (m *WhatsappMutation) SetPhone(s string) {
  34110. m.phone = &s
  34111. }
  34112. // Phone returns the value of the "phone" field in the mutation.
  34113. func (m *WhatsappMutation) Phone() (r string, exists bool) {
  34114. v := m.phone
  34115. if v == nil {
  34116. return
  34117. }
  34118. return *v, true
  34119. }
  34120. // OldPhone returns the old "phone" field's value of the Whatsapp entity.
  34121. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34122. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34123. func (m *WhatsappMutation) OldPhone(ctx context.Context) (v string, err error) {
  34124. if !m.op.Is(OpUpdateOne) {
  34125. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  34126. }
  34127. if m.id == nil || m.oldValue == nil {
  34128. return v, errors.New("OldPhone requires an ID field in the mutation")
  34129. }
  34130. oldValue, err := m.oldValue(ctx)
  34131. if err != nil {
  34132. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  34133. }
  34134. return oldValue.Phone, nil
  34135. }
  34136. // ResetPhone resets all changes to the "phone" field.
  34137. func (m *WhatsappMutation) ResetPhone() {
  34138. m.phone = nil
  34139. }
  34140. // SetOrganizationID sets the "organization_id" field.
  34141. func (m *WhatsappMutation) SetOrganizationID(u uint64) {
  34142. m.organization_id = &u
  34143. m.addorganization_id = nil
  34144. }
  34145. // OrganizationID returns the value of the "organization_id" field in the mutation.
  34146. func (m *WhatsappMutation) OrganizationID() (r uint64, exists bool) {
  34147. v := m.organization_id
  34148. if v == nil {
  34149. return
  34150. }
  34151. return *v, true
  34152. }
  34153. // OldOrganizationID returns the old "organization_id" field's value of the Whatsapp entity.
  34154. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34155. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34156. func (m *WhatsappMutation) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  34157. if !m.op.Is(OpUpdateOne) {
  34158. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  34159. }
  34160. if m.id == nil || m.oldValue == nil {
  34161. return v, errors.New("OldOrganizationID requires an ID field in the mutation")
  34162. }
  34163. oldValue, err := m.oldValue(ctx)
  34164. if err != nil {
  34165. return v, fmt.Errorf("querying old value for OldOrganizationID: %w", err)
  34166. }
  34167. return oldValue.OrganizationID, nil
  34168. }
  34169. // AddOrganizationID adds u to the "organization_id" field.
  34170. func (m *WhatsappMutation) AddOrganizationID(u int64) {
  34171. if m.addorganization_id != nil {
  34172. *m.addorganization_id += u
  34173. } else {
  34174. m.addorganization_id = &u
  34175. }
  34176. }
  34177. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  34178. func (m *WhatsappMutation) AddedOrganizationID() (r int64, exists bool) {
  34179. v := m.addorganization_id
  34180. if v == nil {
  34181. return
  34182. }
  34183. return *v, true
  34184. }
  34185. // ClearOrganizationID clears the value of the "organization_id" field.
  34186. func (m *WhatsappMutation) ClearOrganizationID() {
  34187. m.organization_id = nil
  34188. m.addorganization_id = nil
  34189. m.clearedFields[whatsapp.FieldOrganizationID] = struct{}{}
  34190. }
  34191. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  34192. func (m *WhatsappMutation) OrganizationIDCleared() bool {
  34193. _, ok := m.clearedFields[whatsapp.FieldOrganizationID]
  34194. return ok
  34195. }
  34196. // ResetOrganizationID resets all changes to the "organization_id" field.
  34197. func (m *WhatsappMutation) ResetOrganizationID() {
  34198. m.organization_id = nil
  34199. m.addorganization_id = nil
  34200. delete(m.clearedFields, whatsapp.FieldOrganizationID)
  34201. }
  34202. // SetAgentID sets the "agent_id" field.
  34203. func (m *WhatsappMutation) SetAgentID(u uint64) {
  34204. m.agent_id = &u
  34205. m.addagent_id = nil
  34206. }
  34207. // AgentID returns the value of the "agent_id" field in the mutation.
  34208. func (m *WhatsappMutation) AgentID() (r uint64, exists bool) {
  34209. v := m.agent_id
  34210. if v == nil {
  34211. return
  34212. }
  34213. return *v, true
  34214. }
  34215. // OldAgentID returns the old "agent_id" field's value of the Whatsapp entity.
  34216. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34217. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34218. func (m *WhatsappMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  34219. if !m.op.Is(OpUpdateOne) {
  34220. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  34221. }
  34222. if m.id == nil || m.oldValue == nil {
  34223. return v, errors.New("OldAgentID requires an ID field in the mutation")
  34224. }
  34225. oldValue, err := m.oldValue(ctx)
  34226. if err != nil {
  34227. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  34228. }
  34229. return oldValue.AgentID, nil
  34230. }
  34231. // AddAgentID adds u to the "agent_id" field.
  34232. func (m *WhatsappMutation) AddAgentID(u int64) {
  34233. if m.addagent_id != nil {
  34234. *m.addagent_id += u
  34235. } else {
  34236. m.addagent_id = &u
  34237. }
  34238. }
  34239. // AddedAgentID returns the value that was added to the "agent_id" field in this mutation.
  34240. func (m *WhatsappMutation) AddedAgentID() (r int64, exists bool) {
  34241. v := m.addagent_id
  34242. if v == nil {
  34243. return
  34244. }
  34245. return *v, true
  34246. }
  34247. // ResetAgentID resets all changes to the "agent_id" field.
  34248. func (m *WhatsappMutation) ResetAgentID() {
  34249. m.agent_id = nil
  34250. m.addagent_id = nil
  34251. }
  34252. // SetAPIBase sets the "api_base" field.
  34253. func (m *WhatsappMutation) SetAPIBase(s string) {
  34254. m.api_base = &s
  34255. }
  34256. // APIBase returns the value of the "api_base" field in the mutation.
  34257. func (m *WhatsappMutation) APIBase() (r string, exists bool) {
  34258. v := m.api_base
  34259. if v == nil {
  34260. return
  34261. }
  34262. return *v, true
  34263. }
  34264. // OldAPIBase returns the old "api_base" field's value of the Whatsapp entity.
  34265. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34266. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34267. func (m *WhatsappMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  34268. if !m.op.Is(OpUpdateOne) {
  34269. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  34270. }
  34271. if m.id == nil || m.oldValue == nil {
  34272. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  34273. }
  34274. oldValue, err := m.oldValue(ctx)
  34275. if err != nil {
  34276. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  34277. }
  34278. return oldValue.APIBase, nil
  34279. }
  34280. // ClearAPIBase clears the value of the "api_base" field.
  34281. func (m *WhatsappMutation) ClearAPIBase() {
  34282. m.api_base = nil
  34283. m.clearedFields[whatsapp.FieldAPIBase] = struct{}{}
  34284. }
  34285. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  34286. func (m *WhatsappMutation) APIBaseCleared() bool {
  34287. _, ok := m.clearedFields[whatsapp.FieldAPIBase]
  34288. return ok
  34289. }
  34290. // ResetAPIBase resets all changes to the "api_base" field.
  34291. func (m *WhatsappMutation) ResetAPIBase() {
  34292. m.api_base = nil
  34293. delete(m.clearedFields, whatsapp.FieldAPIBase)
  34294. }
  34295. // SetAPIKey sets the "api_key" field.
  34296. func (m *WhatsappMutation) SetAPIKey(s string) {
  34297. m.api_key = &s
  34298. }
  34299. // APIKey returns the value of the "api_key" field in the mutation.
  34300. func (m *WhatsappMutation) APIKey() (r string, exists bool) {
  34301. v := m.api_key
  34302. if v == nil {
  34303. return
  34304. }
  34305. return *v, true
  34306. }
  34307. // OldAPIKey returns the old "api_key" field's value of the Whatsapp entity.
  34308. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34309. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34310. func (m *WhatsappMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  34311. if !m.op.Is(OpUpdateOne) {
  34312. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  34313. }
  34314. if m.id == nil || m.oldValue == nil {
  34315. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  34316. }
  34317. oldValue, err := m.oldValue(ctx)
  34318. if err != nil {
  34319. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  34320. }
  34321. return oldValue.APIKey, nil
  34322. }
  34323. // ClearAPIKey clears the value of the "api_key" field.
  34324. func (m *WhatsappMutation) ClearAPIKey() {
  34325. m.api_key = nil
  34326. m.clearedFields[whatsapp.FieldAPIKey] = struct{}{}
  34327. }
  34328. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  34329. func (m *WhatsappMutation) APIKeyCleared() bool {
  34330. _, ok := m.clearedFields[whatsapp.FieldAPIKey]
  34331. return ok
  34332. }
  34333. // ResetAPIKey resets all changes to the "api_key" field.
  34334. func (m *WhatsappMutation) ResetAPIKey() {
  34335. m.api_key = nil
  34336. delete(m.clearedFields, whatsapp.FieldAPIKey)
  34337. }
  34338. // SetAllowList sets the "allow_list" field.
  34339. func (m *WhatsappMutation) SetAllowList(s []string) {
  34340. m.allow_list = &s
  34341. m.appendallow_list = nil
  34342. }
  34343. // AllowList returns the value of the "allow_list" field in the mutation.
  34344. func (m *WhatsappMutation) AllowList() (r []string, exists bool) {
  34345. v := m.allow_list
  34346. if v == nil {
  34347. return
  34348. }
  34349. return *v, true
  34350. }
  34351. // OldAllowList returns the old "allow_list" field's value of the Whatsapp entity.
  34352. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34353. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34354. func (m *WhatsappMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  34355. if !m.op.Is(OpUpdateOne) {
  34356. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  34357. }
  34358. if m.id == nil || m.oldValue == nil {
  34359. return v, errors.New("OldAllowList requires an ID field in the mutation")
  34360. }
  34361. oldValue, err := m.oldValue(ctx)
  34362. if err != nil {
  34363. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  34364. }
  34365. return oldValue.AllowList, nil
  34366. }
  34367. // AppendAllowList adds s to the "allow_list" field.
  34368. func (m *WhatsappMutation) AppendAllowList(s []string) {
  34369. m.appendallow_list = append(m.appendallow_list, s...)
  34370. }
  34371. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  34372. func (m *WhatsappMutation) AppendedAllowList() ([]string, bool) {
  34373. if len(m.appendallow_list) == 0 {
  34374. return nil, false
  34375. }
  34376. return m.appendallow_list, true
  34377. }
  34378. // ClearAllowList clears the value of the "allow_list" field.
  34379. func (m *WhatsappMutation) ClearAllowList() {
  34380. m.allow_list = nil
  34381. m.appendallow_list = nil
  34382. m.clearedFields[whatsapp.FieldAllowList] = struct{}{}
  34383. }
  34384. // AllowListCleared returns if the "allow_list" field was cleared in this mutation.
  34385. func (m *WhatsappMutation) AllowListCleared() bool {
  34386. _, ok := m.clearedFields[whatsapp.FieldAllowList]
  34387. return ok
  34388. }
  34389. // ResetAllowList resets all changes to the "allow_list" field.
  34390. func (m *WhatsappMutation) ResetAllowList() {
  34391. m.allow_list = nil
  34392. m.appendallow_list = nil
  34393. delete(m.clearedFields, whatsapp.FieldAllowList)
  34394. }
  34395. // SetGroupAllowList sets the "group_allow_list" field.
  34396. func (m *WhatsappMutation) SetGroupAllowList(s []string) {
  34397. m.group_allow_list = &s
  34398. m.appendgroup_allow_list = nil
  34399. }
  34400. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  34401. func (m *WhatsappMutation) GroupAllowList() (r []string, exists bool) {
  34402. v := m.group_allow_list
  34403. if v == nil {
  34404. return
  34405. }
  34406. return *v, true
  34407. }
  34408. // OldGroupAllowList returns the old "group_allow_list" field's value of the Whatsapp entity.
  34409. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34410. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34411. func (m *WhatsappMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  34412. if !m.op.Is(OpUpdateOne) {
  34413. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  34414. }
  34415. if m.id == nil || m.oldValue == nil {
  34416. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  34417. }
  34418. oldValue, err := m.oldValue(ctx)
  34419. if err != nil {
  34420. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  34421. }
  34422. return oldValue.GroupAllowList, nil
  34423. }
  34424. // AppendGroupAllowList adds s to the "group_allow_list" field.
  34425. func (m *WhatsappMutation) AppendGroupAllowList(s []string) {
  34426. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  34427. }
  34428. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  34429. func (m *WhatsappMutation) AppendedGroupAllowList() ([]string, bool) {
  34430. if len(m.appendgroup_allow_list) == 0 {
  34431. return nil, false
  34432. }
  34433. return m.appendgroup_allow_list, true
  34434. }
  34435. // ClearGroupAllowList clears the value of the "group_allow_list" field.
  34436. func (m *WhatsappMutation) ClearGroupAllowList() {
  34437. m.group_allow_list = nil
  34438. m.appendgroup_allow_list = nil
  34439. m.clearedFields[whatsapp.FieldGroupAllowList] = struct{}{}
  34440. }
  34441. // GroupAllowListCleared returns if the "group_allow_list" field was cleared in this mutation.
  34442. func (m *WhatsappMutation) GroupAllowListCleared() bool {
  34443. _, ok := m.clearedFields[whatsapp.FieldGroupAllowList]
  34444. return ok
  34445. }
  34446. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  34447. func (m *WhatsappMutation) ResetGroupAllowList() {
  34448. m.group_allow_list = nil
  34449. m.appendgroup_allow_list = nil
  34450. delete(m.clearedFields, whatsapp.FieldGroupAllowList)
  34451. }
  34452. // SetBlockList sets the "block_list" field.
  34453. func (m *WhatsappMutation) SetBlockList(s []string) {
  34454. m.block_list = &s
  34455. m.appendblock_list = nil
  34456. }
  34457. // BlockList returns the value of the "block_list" field in the mutation.
  34458. func (m *WhatsappMutation) BlockList() (r []string, exists bool) {
  34459. v := m.block_list
  34460. if v == nil {
  34461. return
  34462. }
  34463. return *v, true
  34464. }
  34465. // OldBlockList returns the old "block_list" field's value of the Whatsapp entity.
  34466. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34468. func (m *WhatsappMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  34469. if !m.op.Is(OpUpdateOne) {
  34470. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  34471. }
  34472. if m.id == nil || m.oldValue == nil {
  34473. return v, errors.New("OldBlockList requires an ID field in the mutation")
  34474. }
  34475. oldValue, err := m.oldValue(ctx)
  34476. if err != nil {
  34477. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  34478. }
  34479. return oldValue.BlockList, nil
  34480. }
  34481. // AppendBlockList adds s to the "block_list" field.
  34482. func (m *WhatsappMutation) AppendBlockList(s []string) {
  34483. m.appendblock_list = append(m.appendblock_list, s...)
  34484. }
  34485. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  34486. func (m *WhatsappMutation) AppendedBlockList() ([]string, bool) {
  34487. if len(m.appendblock_list) == 0 {
  34488. return nil, false
  34489. }
  34490. return m.appendblock_list, true
  34491. }
  34492. // ClearBlockList clears the value of the "block_list" field.
  34493. func (m *WhatsappMutation) ClearBlockList() {
  34494. m.block_list = nil
  34495. m.appendblock_list = nil
  34496. m.clearedFields[whatsapp.FieldBlockList] = struct{}{}
  34497. }
  34498. // BlockListCleared returns if the "block_list" field was cleared in this mutation.
  34499. func (m *WhatsappMutation) BlockListCleared() bool {
  34500. _, ok := m.clearedFields[whatsapp.FieldBlockList]
  34501. return ok
  34502. }
  34503. // ResetBlockList resets all changes to the "block_list" field.
  34504. func (m *WhatsappMutation) ResetBlockList() {
  34505. m.block_list = nil
  34506. m.appendblock_list = nil
  34507. delete(m.clearedFields, whatsapp.FieldBlockList)
  34508. }
  34509. // SetGroupBlockList sets the "group_block_list" field.
  34510. func (m *WhatsappMutation) SetGroupBlockList(s []string) {
  34511. m.group_block_list = &s
  34512. m.appendgroup_block_list = nil
  34513. }
  34514. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  34515. func (m *WhatsappMutation) GroupBlockList() (r []string, exists bool) {
  34516. v := m.group_block_list
  34517. if v == nil {
  34518. return
  34519. }
  34520. return *v, true
  34521. }
  34522. // OldGroupBlockList returns the old "group_block_list" field's value of the Whatsapp entity.
  34523. // If the Whatsapp object wasn't provided to the builder, the object is fetched from the database.
  34524. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  34525. func (m *WhatsappMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  34526. if !m.op.Is(OpUpdateOne) {
  34527. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  34528. }
  34529. if m.id == nil || m.oldValue == nil {
  34530. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  34531. }
  34532. oldValue, err := m.oldValue(ctx)
  34533. if err != nil {
  34534. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  34535. }
  34536. return oldValue.GroupBlockList, nil
  34537. }
  34538. // AppendGroupBlockList adds s to the "group_block_list" field.
  34539. func (m *WhatsappMutation) AppendGroupBlockList(s []string) {
  34540. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  34541. }
  34542. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  34543. func (m *WhatsappMutation) AppendedGroupBlockList() ([]string, bool) {
  34544. if len(m.appendgroup_block_list) == 0 {
  34545. return nil, false
  34546. }
  34547. return m.appendgroup_block_list, true
  34548. }
  34549. // ClearGroupBlockList clears the value of the "group_block_list" field.
  34550. func (m *WhatsappMutation) ClearGroupBlockList() {
  34551. m.group_block_list = nil
  34552. m.appendgroup_block_list = nil
  34553. m.clearedFields[whatsapp.FieldGroupBlockList] = struct{}{}
  34554. }
  34555. // GroupBlockListCleared returns if the "group_block_list" field was cleared in this mutation.
  34556. func (m *WhatsappMutation) GroupBlockListCleared() bool {
  34557. _, ok := m.clearedFields[whatsapp.FieldGroupBlockList]
  34558. return ok
  34559. }
  34560. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  34561. func (m *WhatsappMutation) ResetGroupBlockList() {
  34562. m.group_block_list = nil
  34563. m.appendgroup_block_list = nil
  34564. delete(m.clearedFields, whatsapp.FieldGroupBlockList)
  34565. }
  34566. // Where appends a list predicates to the WhatsappMutation builder.
  34567. func (m *WhatsappMutation) Where(ps ...predicate.Whatsapp) {
  34568. m.predicates = append(m.predicates, ps...)
  34569. }
  34570. // WhereP appends storage-level predicates to the WhatsappMutation builder. Using this method,
  34571. // users can use type-assertion to append predicates that do not depend on any generated package.
  34572. func (m *WhatsappMutation) WhereP(ps ...func(*sql.Selector)) {
  34573. p := make([]predicate.Whatsapp, len(ps))
  34574. for i := range ps {
  34575. p[i] = ps[i]
  34576. }
  34577. m.Where(p...)
  34578. }
  34579. // Op returns the operation name.
  34580. func (m *WhatsappMutation) Op() Op {
  34581. return m.op
  34582. }
  34583. // SetOp allows setting the mutation operation.
  34584. func (m *WhatsappMutation) SetOp(op Op) {
  34585. m.op = op
  34586. }
  34587. // Type returns the node type of this mutation (Whatsapp).
  34588. func (m *WhatsappMutation) Type() string {
  34589. return m.typ
  34590. }
  34591. // Fields returns all fields that were changed during this mutation. Note that in
  34592. // order to get all numeric fields that were incremented/decremented, call
  34593. // AddedFields().
  34594. func (m *WhatsappMutation) Fields() []string {
  34595. fields := make([]string, 0, 18)
  34596. if m.created_at != nil {
  34597. fields = append(fields, whatsapp.FieldCreatedAt)
  34598. }
  34599. if m.updated_at != nil {
  34600. fields = append(fields, whatsapp.FieldUpdatedAt)
  34601. }
  34602. if m.status != nil {
  34603. fields = append(fields, whatsapp.FieldStatus)
  34604. }
  34605. if m.deleted_at != nil {
  34606. fields = append(fields, whatsapp.FieldDeletedAt)
  34607. }
  34608. if m.ak != nil {
  34609. fields = append(fields, whatsapp.FieldAk)
  34610. }
  34611. if m.sk != nil {
  34612. fields = append(fields, whatsapp.FieldSk)
  34613. }
  34614. if m.callback != nil {
  34615. fields = append(fields, whatsapp.FieldCallback)
  34616. }
  34617. if m.account != nil {
  34618. fields = append(fields, whatsapp.FieldAccount)
  34619. }
  34620. if m.nickname != nil {
  34621. fields = append(fields, whatsapp.FieldNickname)
  34622. }
  34623. if m.phone != nil {
  34624. fields = append(fields, whatsapp.FieldPhone)
  34625. }
  34626. if m.organization_id != nil {
  34627. fields = append(fields, whatsapp.FieldOrganizationID)
  34628. }
  34629. if m.agent_id != nil {
  34630. fields = append(fields, whatsapp.FieldAgentID)
  34631. }
  34632. if m.api_base != nil {
  34633. fields = append(fields, whatsapp.FieldAPIBase)
  34634. }
  34635. if m.api_key != nil {
  34636. fields = append(fields, whatsapp.FieldAPIKey)
  34637. }
  34638. if m.allow_list != nil {
  34639. fields = append(fields, whatsapp.FieldAllowList)
  34640. }
  34641. if m.group_allow_list != nil {
  34642. fields = append(fields, whatsapp.FieldGroupAllowList)
  34643. }
  34644. if m.block_list != nil {
  34645. fields = append(fields, whatsapp.FieldBlockList)
  34646. }
  34647. if m.group_block_list != nil {
  34648. fields = append(fields, whatsapp.FieldGroupBlockList)
  34649. }
  34650. return fields
  34651. }
  34652. // Field returns the value of a field with the given name. The second boolean
  34653. // return value indicates that this field was not set, or was not defined in the
  34654. // schema.
  34655. func (m *WhatsappMutation) Field(name string) (ent.Value, bool) {
  34656. switch name {
  34657. case whatsapp.FieldCreatedAt:
  34658. return m.CreatedAt()
  34659. case whatsapp.FieldUpdatedAt:
  34660. return m.UpdatedAt()
  34661. case whatsapp.FieldStatus:
  34662. return m.Status()
  34663. case whatsapp.FieldDeletedAt:
  34664. return m.DeletedAt()
  34665. case whatsapp.FieldAk:
  34666. return m.Ak()
  34667. case whatsapp.FieldSk:
  34668. return m.Sk()
  34669. case whatsapp.FieldCallback:
  34670. return m.Callback()
  34671. case whatsapp.FieldAccount:
  34672. return m.Account()
  34673. case whatsapp.FieldNickname:
  34674. return m.Nickname()
  34675. case whatsapp.FieldPhone:
  34676. return m.Phone()
  34677. case whatsapp.FieldOrganizationID:
  34678. return m.OrganizationID()
  34679. case whatsapp.FieldAgentID:
  34680. return m.AgentID()
  34681. case whatsapp.FieldAPIBase:
  34682. return m.APIBase()
  34683. case whatsapp.FieldAPIKey:
  34684. return m.APIKey()
  34685. case whatsapp.FieldAllowList:
  34686. return m.AllowList()
  34687. case whatsapp.FieldGroupAllowList:
  34688. return m.GroupAllowList()
  34689. case whatsapp.FieldBlockList:
  34690. return m.BlockList()
  34691. case whatsapp.FieldGroupBlockList:
  34692. return m.GroupBlockList()
  34693. }
  34694. return nil, false
  34695. }
  34696. // OldField returns the old value of the field from the database. An error is
  34697. // returned if the mutation operation is not UpdateOne, or the query to the
  34698. // database failed.
  34699. func (m *WhatsappMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  34700. switch name {
  34701. case whatsapp.FieldCreatedAt:
  34702. return m.OldCreatedAt(ctx)
  34703. case whatsapp.FieldUpdatedAt:
  34704. return m.OldUpdatedAt(ctx)
  34705. case whatsapp.FieldStatus:
  34706. return m.OldStatus(ctx)
  34707. case whatsapp.FieldDeletedAt:
  34708. return m.OldDeletedAt(ctx)
  34709. case whatsapp.FieldAk:
  34710. return m.OldAk(ctx)
  34711. case whatsapp.FieldSk:
  34712. return m.OldSk(ctx)
  34713. case whatsapp.FieldCallback:
  34714. return m.OldCallback(ctx)
  34715. case whatsapp.FieldAccount:
  34716. return m.OldAccount(ctx)
  34717. case whatsapp.FieldNickname:
  34718. return m.OldNickname(ctx)
  34719. case whatsapp.FieldPhone:
  34720. return m.OldPhone(ctx)
  34721. case whatsapp.FieldOrganizationID:
  34722. return m.OldOrganizationID(ctx)
  34723. case whatsapp.FieldAgentID:
  34724. return m.OldAgentID(ctx)
  34725. case whatsapp.FieldAPIBase:
  34726. return m.OldAPIBase(ctx)
  34727. case whatsapp.FieldAPIKey:
  34728. return m.OldAPIKey(ctx)
  34729. case whatsapp.FieldAllowList:
  34730. return m.OldAllowList(ctx)
  34731. case whatsapp.FieldGroupAllowList:
  34732. return m.OldGroupAllowList(ctx)
  34733. case whatsapp.FieldBlockList:
  34734. return m.OldBlockList(ctx)
  34735. case whatsapp.FieldGroupBlockList:
  34736. return m.OldGroupBlockList(ctx)
  34737. }
  34738. return nil, fmt.Errorf("unknown Whatsapp field %s", name)
  34739. }
  34740. // SetField sets the value of a field with the given name. It returns an error if
  34741. // the field is not defined in the schema, or if the type mismatched the field
  34742. // type.
  34743. func (m *WhatsappMutation) SetField(name string, value ent.Value) error {
  34744. switch name {
  34745. case whatsapp.FieldCreatedAt:
  34746. v, ok := value.(time.Time)
  34747. if !ok {
  34748. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34749. }
  34750. m.SetCreatedAt(v)
  34751. return nil
  34752. case whatsapp.FieldUpdatedAt:
  34753. v, ok := value.(time.Time)
  34754. if !ok {
  34755. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34756. }
  34757. m.SetUpdatedAt(v)
  34758. return nil
  34759. case whatsapp.FieldStatus:
  34760. v, ok := value.(uint8)
  34761. if !ok {
  34762. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34763. }
  34764. m.SetStatus(v)
  34765. return nil
  34766. case whatsapp.FieldDeletedAt:
  34767. v, ok := value.(time.Time)
  34768. if !ok {
  34769. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34770. }
  34771. m.SetDeletedAt(v)
  34772. return nil
  34773. case whatsapp.FieldAk:
  34774. v, ok := value.(string)
  34775. if !ok {
  34776. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34777. }
  34778. m.SetAk(v)
  34779. return nil
  34780. case whatsapp.FieldSk:
  34781. v, ok := value.(string)
  34782. if !ok {
  34783. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34784. }
  34785. m.SetSk(v)
  34786. return nil
  34787. case whatsapp.FieldCallback:
  34788. v, ok := value.(string)
  34789. if !ok {
  34790. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34791. }
  34792. m.SetCallback(v)
  34793. return nil
  34794. case whatsapp.FieldAccount:
  34795. v, ok := value.(string)
  34796. if !ok {
  34797. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34798. }
  34799. m.SetAccount(v)
  34800. return nil
  34801. case whatsapp.FieldNickname:
  34802. v, ok := value.(string)
  34803. if !ok {
  34804. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34805. }
  34806. m.SetNickname(v)
  34807. return nil
  34808. case whatsapp.FieldPhone:
  34809. v, ok := value.(string)
  34810. if !ok {
  34811. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34812. }
  34813. m.SetPhone(v)
  34814. return nil
  34815. case whatsapp.FieldOrganizationID:
  34816. v, ok := value.(uint64)
  34817. if !ok {
  34818. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34819. }
  34820. m.SetOrganizationID(v)
  34821. return nil
  34822. case whatsapp.FieldAgentID:
  34823. v, ok := value.(uint64)
  34824. if !ok {
  34825. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34826. }
  34827. m.SetAgentID(v)
  34828. return nil
  34829. case whatsapp.FieldAPIBase:
  34830. v, ok := value.(string)
  34831. if !ok {
  34832. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34833. }
  34834. m.SetAPIBase(v)
  34835. return nil
  34836. case whatsapp.FieldAPIKey:
  34837. v, ok := value.(string)
  34838. if !ok {
  34839. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34840. }
  34841. m.SetAPIKey(v)
  34842. return nil
  34843. case whatsapp.FieldAllowList:
  34844. v, ok := value.([]string)
  34845. if !ok {
  34846. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34847. }
  34848. m.SetAllowList(v)
  34849. return nil
  34850. case whatsapp.FieldGroupAllowList:
  34851. v, ok := value.([]string)
  34852. if !ok {
  34853. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34854. }
  34855. m.SetGroupAllowList(v)
  34856. return nil
  34857. case whatsapp.FieldBlockList:
  34858. v, ok := value.([]string)
  34859. if !ok {
  34860. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34861. }
  34862. m.SetBlockList(v)
  34863. return nil
  34864. case whatsapp.FieldGroupBlockList:
  34865. v, ok := value.([]string)
  34866. if !ok {
  34867. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34868. }
  34869. m.SetGroupBlockList(v)
  34870. return nil
  34871. }
  34872. return fmt.Errorf("unknown Whatsapp field %s", name)
  34873. }
  34874. // AddedFields returns all numeric fields that were incremented/decremented during
  34875. // this mutation.
  34876. func (m *WhatsappMutation) AddedFields() []string {
  34877. var fields []string
  34878. if m.addstatus != nil {
  34879. fields = append(fields, whatsapp.FieldStatus)
  34880. }
  34881. if m.addorganization_id != nil {
  34882. fields = append(fields, whatsapp.FieldOrganizationID)
  34883. }
  34884. if m.addagent_id != nil {
  34885. fields = append(fields, whatsapp.FieldAgentID)
  34886. }
  34887. return fields
  34888. }
  34889. // AddedField returns the numeric value that was incremented/decremented on a field
  34890. // with the given name. The second boolean return value indicates that this field
  34891. // was not set, or was not defined in the schema.
  34892. func (m *WhatsappMutation) AddedField(name string) (ent.Value, bool) {
  34893. switch name {
  34894. case whatsapp.FieldStatus:
  34895. return m.AddedStatus()
  34896. case whatsapp.FieldOrganizationID:
  34897. return m.AddedOrganizationID()
  34898. case whatsapp.FieldAgentID:
  34899. return m.AddedAgentID()
  34900. }
  34901. return nil, false
  34902. }
  34903. // AddField adds the value to the field with the given name. It returns an error if
  34904. // the field is not defined in the schema, or if the type mismatched the field
  34905. // type.
  34906. func (m *WhatsappMutation) AddField(name string, value ent.Value) error {
  34907. switch name {
  34908. case whatsapp.FieldStatus:
  34909. v, ok := value.(int8)
  34910. if !ok {
  34911. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34912. }
  34913. m.AddStatus(v)
  34914. return nil
  34915. case whatsapp.FieldOrganizationID:
  34916. v, ok := value.(int64)
  34917. if !ok {
  34918. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34919. }
  34920. m.AddOrganizationID(v)
  34921. return nil
  34922. case whatsapp.FieldAgentID:
  34923. v, ok := value.(int64)
  34924. if !ok {
  34925. return fmt.Errorf("unexpected type %T for field %s", value, name)
  34926. }
  34927. m.AddAgentID(v)
  34928. return nil
  34929. }
  34930. return fmt.Errorf("unknown Whatsapp numeric field %s", name)
  34931. }
  34932. // ClearedFields returns all nullable fields that were cleared during this
  34933. // mutation.
  34934. func (m *WhatsappMutation) ClearedFields() []string {
  34935. var fields []string
  34936. if m.FieldCleared(whatsapp.FieldStatus) {
  34937. fields = append(fields, whatsapp.FieldStatus)
  34938. }
  34939. if m.FieldCleared(whatsapp.FieldDeletedAt) {
  34940. fields = append(fields, whatsapp.FieldDeletedAt)
  34941. }
  34942. if m.FieldCleared(whatsapp.FieldAk) {
  34943. fields = append(fields, whatsapp.FieldAk)
  34944. }
  34945. if m.FieldCleared(whatsapp.FieldOrganizationID) {
  34946. fields = append(fields, whatsapp.FieldOrganizationID)
  34947. }
  34948. if m.FieldCleared(whatsapp.FieldAPIBase) {
  34949. fields = append(fields, whatsapp.FieldAPIBase)
  34950. }
  34951. if m.FieldCleared(whatsapp.FieldAPIKey) {
  34952. fields = append(fields, whatsapp.FieldAPIKey)
  34953. }
  34954. if m.FieldCleared(whatsapp.FieldAllowList) {
  34955. fields = append(fields, whatsapp.FieldAllowList)
  34956. }
  34957. if m.FieldCleared(whatsapp.FieldGroupAllowList) {
  34958. fields = append(fields, whatsapp.FieldGroupAllowList)
  34959. }
  34960. if m.FieldCleared(whatsapp.FieldBlockList) {
  34961. fields = append(fields, whatsapp.FieldBlockList)
  34962. }
  34963. if m.FieldCleared(whatsapp.FieldGroupBlockList) {
  34964. fields = append(fields, whatsapp.FieldGroupBlockList)
  34965. }
  34966. return fields
  34967. }
  34968. // FieldCleared returns a boolean indicating if a field with the given name was
  34969. // cleared in this mutation.
  34970. func (m *WhatsappMutation) FieldCleared(name string) bool {
  34971. _, ok := m.clearedFields[name]
  34972. return ok
  34973. }
  34974. // ClearField clears the value of the field with the given name. It returns an
  34975. // error if the field is not defined in the schema.
  34976. func (m *WhatsappMutation) ClearField(name string) error {
  34977. switch name {
  34978. case whatsapp.FieldStatus:
  34979. m.ClearStatus()
  34980. return nil
  34981. case whatsapp.FieldDeletedAt:
  34982. m.ClearDeletedAt()
  34983. return nil
  34984. case whatsapp.FieldAk:
  34985. m.ClearAk()
  34986. return nil
  34987. case whatsapp.FieldOrganizationID:
  34988. m.ClearOrganizationID()
  34989. return nil
  34990. case whatsapp.FieldAPIBase:
  34991. m.ClearAPIBase()
  34992. return nil
  34993. case whatsapp.FieldAPIKey:
  34994. m.ClearAPIKey()
  34995. return nil
  34996. case whatsapp.FieldAllowList:
  34997. m.ClearAllowList()
  34998. return nil
  34999. case whatsapp.FieldGroupAllowList:
  35000. m.ClearGroupAllowList()
  35001. return nil
  35002. case whatsapp.FieldBlockList:
  35003. m.ClearBlockList()
  35004. return nil
  35005. case whatsapp.FieldGroupBlockList:
  35006. m.ClearGroupBlockList()
  35007. return nil
  35008. }
  35009. return fmt.Errorf("unknown Whatsapp nullable field %s", name)
  35010. }
  35011. // ResetField resets all changes in the mutation for the field with the given name.
  35012. // It returns an error if the field is not defined in the schema.
  35013. func (m *WhatsappMutation) ResetField(name string) error {
  35014. switch name {
  35015. case whatsapp.FieldCreatedAt:
  35016. m.ResetCreatedAt()
  35017. return nil
  35018. case whatsapp.FieldUpdatedAt:
  35019. m.ResetUpdatedAt()
  35020. return nil
  35021. case whatsapp.FieldStatus:
  35022. m.ResetStatus()
  35023. return nil
  35024. case whatsapp.FieldDeletedAt:
  35025. m.ResetDeletedAt()
  35026. return nil
  35027. case whatsapp.FieldAk:
  35028. m.ResetAk()
  35029. return nil
  35030. case whatsapp.FieldSk:
  35031. m.ResetSk()
  35032. return nil
  35033. case whatsapp.FieldCallback:
  35034. m.ResetCallback()
  35035. return nil
  35036. case whatsapp.FieldAccount:
  35037. m.ResetAccount()
  35038. return nil
  35039. case whatsapp.FieldNickname:
  35040. m.ResetNickname()
  35041. return nil
  35042. case whatsapp.FieldPhone:
  35043. m.ResetPhone()
  35044. return nil
  35045. case whatsapp.FieldOrganizationID:
  35046. m.ResetOrganizationID()
  35047. return nil
  35048. case whatsapp.FieldAgentID:
  35049. m.ResetAgentID()
  35050. return nil
  35051. case whatsapp.FieldAPIBase:
  35052. m.ResetAPIBase()
  35053. return nil
  35054. case whatsapp.FieldAPIKey:
  35055. m.ResetAPIKey()
  35056. return nil
  35057. case whatsapp.FieldAllowList:
  35058. m.ResetAllowList()
  35059. return nil
  35060. case whatsapp.FieldGroupAllowList:
  35061. m.ResetGroupAllowList()
  35062. return nil
  35063. case whatsapp.FieldBlockList:
  35064. m.ResetBlockList()
  35065. return nil
  35066. case whatsapp.FieldGroupBlockList:
  35067. m.ResetGroupBlockList()
  35068. return nil
  35069. }
  35070. return fmt.Errorf("unknown Whatsapp field %s", name)
  35071. }
  35072. // AddedEdges returns all edge names that were set/added in this mutation.
  35073. func (m *WhatsappMutation) AddedEdges() []string {
  35074. edges := make([]string, 0, 0)
  35075. return edges
  35076. }
  35077. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35078. // name in this mutation.
  35079. func (m *WhatsappMutation) AddedIDs(name string) []ent.Value {
  35080. return nil
  35081. }
  35082. // RemovedEdges returns all edge names that were removed in this mutation.
  35083. func (m *WhatsappMutation) RemovedEdges() []string {
  35084. edges := make([]string, 0, 0)
  35085. return edges
  35086. }
  35087. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35088. // the given name in this mutation.
  35089. func (m *WhatsappMutation) RemovedIDs(name string) []ent.Value {
  35090. return nil
  35091. }
  35092. // ClearedEdges returns all edge names that were cleared in this mutation.
  35093. func (m *WhatsappMutation) ClearedEdges() []string {
  35094. edges := make([]string, 0, 0)
  35095. return edges
  35096. }
  35097. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35098. // was cleared in this mutation.
  35099. func (m *WhatsappMutation) EdgeCleared(name string) bool {
  35100. return false
  35101. }
  35102. // ClearEdge clears the value of the edge with the given name. It returns an error
  35103. // if that edge is not defined in the schema.
  35104. func (m *WhatsappMutation) ClearEdge(name string) error {
  35105. return fmt.Errorf("unknown Whatsapp unique edge %s", name)
  35106. }
  35107. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35108. // It returns an error if the edge is not defined in the schema.
  35109. func (m *WhatsappMutation) ResetEdge(name string) error {
  35110. return fmt.Errorf("unknown Whatsapp edge %s", name)
  35111. }
  35112. // WorkExperienceMutation represents an operation that mutates the WorkExperience nodes in the graph.
  35113. type WorkExperienceMutation struct {
  35114. config
  35115. op Op
  35116. typ string
  35117. id *uint64
  35118. created_at *time.Time
  35119. updated_at *time.Time
  35120. deleted_at *time.Time
  35121. start_date *time.Time
  35122. end_date *time.Time
  35123. company *string
  35124. experience *string
  35125. organization_id *uint64
  35126. addorganization_id *int64
  35127. clearedFields map[string]struct{}
  35128. employee *uint64
  35129. clearedemployee bool
  35130. done bool
  35131. oldValue func(context.Context) (*WorkExperience, error)
  35132. predicates []predicate.WorkExperience
  35133. }
  35134. var _ ent.Mutation = (*WorkExperienceMutation)(nil)
  35135. // workexperienceOption allows management of the mutation configuration using functional options.
  35136. type workexperienceOption func(*WorkExperienceMutation)
  35137. // newWorkExperienceMutation creates new mutation for the WorkExperience entity.
  35138. func newWorkExperienceMutation(c config, op Op, opts ...workexperienceOption) *WorkExperienceMutation {
  35139. m := &WorkExperienceMutation{
  35140. config: c,
  35141. op: op,
  35142. typ: TypeWorkExperience,
  35143. clearedFields: make(map[string]struct{}),
  35144. }
  35145. for _, opt := range opts {
  35146. opt(m)
  35147. }
  35148. return m
  35149. }
  35150. // withWorkExperienceID sets the ID field of the mutation.
  35151. func withWorkExperienceID(id uint64) workexperienceOption {
  35152. return func(m *WorkExperienceMutation) {
  35153. var (
  35154. err error
  35155. once sync.Once
  35156. value *WorkExperience
  35157. )
  35158. m.oldValue = func(ctx context.Context) (*WorkExperience, error) {
  35159. once.Do(func() {
  35160. if m.done {
  35161. err = errors.New("querying old values post mutation is not allowed")
  35162. } else {
  35163. value, err = m.Client().WorkExperience.Get(ctx, id)
  35164. }
  35165. })
  35166. return value, err
  35167. }
  35168. m.id = &id
  35169. }
  35170. }
  35171. // withWorkExperience sets the old WorkExperience of the mutation.
  35172. func withWorkExperience(node *WorkExperience) workexperienceOption {
  35173. return func(m *WorkExperienceMutation) {
  35174. m.oldValue = func(context.Context) (*WorkExperience, error) {
  35175. return node, nil
  35176. }
  35177. m.id = &node.ID
  35178. }
  35179. }
  35180. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35181. // executed in a transaction (ent.Tx), a transactional client is returned.
  35182. func (m WorkExperienceMutation) Client() *Client {
  35183. client := &Client{config: m.config}
  35184. client.init()
  35185. return client
  35186. }
  35187. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35188. // it returns an error otherwise.
  35189. func (m WorkExperienceMutation) Tx() (*Tx, error) {
  35190. if _, ok := m.driver.(*txDriver); !ok {
  35191. return nil, errors.New("ent: mutation is not running in a transaction")
  35192. }
  35193. tx := &Tx{config: m.config}
  35194. tx.init()
  35195. return tx, nil
  35196. }
  35197. // SetID sets the value of the id field. Note that this
  35198. // operation is only accepted on creation of WorkExperience entities.
  35199. func (m *WorkExperienceMutation) SetID(id uint64) {
  35200. m.id = &id
  35201. }
  35202. // ID returns the ID value in the mutation. Note that the ID is only available
  35203. // if it was provided to the builder or after it was returned from the database.
  35204. func (m *WorkExperienceMutation) ID() (id uint64, exists bool) {
  35205. if m.id == nil {
  35206. return
  35207. }
  35208. return *m.id, true
  35209. }
  35210. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  35211. // That means, if the mutation is applied within a transaction with an isolation level such
  35212. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  35213. // or updated by the mutation.
  35214. func (m *WorkExperienceMutation) IDs(ctx context.Context) ([]uint64, error) {
  35215. switch {
  35216. case m.op.Is(OpUpdateOne | OpDeleteOne):
  35217. id, exists := m.ID()
  35218. if exists {
  35219. return []uint64{id}, nil
  35220. }
  35221. fallthrough
  35222. case m.op.Is(OpUpdate | OpDelete):
  35223. return m.Client().WorkExperience.Query().Where(m.predicates...).IDs(ctx)
  35224. default:
  35225. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  35226. }
  35227. }
  35228. // SetCreatedAt sets the "created_at" field.
  35229. func (m *WorkExperienceMutation) SetCreatedAt(t time.Time) {
  35230. m.created_at = &t
  35231. }
  35232. // CreatedAt returns the value of the "created_at" field in the mutation.
  35233. func (m *WorkExperienceMutation) CreatedAt() (r time.Time, exists bool) {
  35234. v := m.created_at
  35235. if v == nil {
  35236. return
  35237. }
  35238. return *v, true
  35239. }
  35240. // OldCreatedAt returns the old "created_at" field's value of the WorkExperience entity.
  35241. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35242. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35243. func (m *WorkExperienceMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  35244. if !m.op.Is(OpUpdateOne) {
  35245. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  35246. }
  35247. if m.id == nil || m.oldValue == nil {
  35248. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  35249. }
  35250. oldValue, err := m.oldValue(ctx)
  35251. if err != nil {
  35252. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  35253. }
  35254. return oldValue.CreatedAt, nil
  35255. }
  35256. // ResetCreatedAt resets all changes to the "created_at" field.
  35257. func (m *WorkExperienceMutation) ResetCreatedAt() {
  35258. m.created_at = nil
  35259. }
  35260. // SetUpdatedAt sets the "updated_at" field.
  35261. func (m *WorkExperienceMutation) SetUpdatedAt(t time.Time) {
  35262. m.updated_at = &t
  35263. }
  35264. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  35265. func (m *WorkExperienceMutation) UpdatedAt() (r time.Time, exists bool) {
  35266. v := m.updated_at
  35267. if v == nil {
  35268. return
  35269. }
  35270. return *v, true
  35271. }
  35272. // OldUpdatedAt returns the old "updated_at" field's value of the WorkExperience entity.
  35273. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35274. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35275. func (m *WorkExperienceMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  35276. if !m.op.Is(OpUpdateOne) {
  35277. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  35278. }
  35279. if m.id == nil || m.oldValue == nil {
  35280. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  35281. }
  35282. oldValue, err := m.oldValue(ctx)
  35283. if err != nil {
  35284. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  35285. }
  35286. return oldValue.UpdatedAt, nil
  35287. }
  35288. // ResetUpdatedAt resets all changes to the "updated_at" field.
  35289. func (m *WorkExperienceMutation) ResetUpdatedAt() {
  35290. m.updated_at = nil
  35291. }
  35292. // SetDeletedAt sets the "deleted_at" field.
  35293. func (m *WorkExperienceMutation) SetDeletedAt(t time.Time) {
  35294. m.deleted_at = &t
  35295. }
  35296. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  35297. func (m *WorkExperienceMutation) DeletedAt() (r time.Time, exists bool) {
  35298. v := m.deleted_at
  35299. if v == nil {
  35300. return
  35301. }
  35302. return *v, true
  35303. }
  35304. // OldDeletedAt returns the old "deleted_at" field's value of the WorkExperience entity.
  35305. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35306. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35307. func (m *WorkExperienceMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  35308. if !m.op.Is(OpUpdateOne) {
  35309. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  35310. }
  35311. if m.id == nil || m.oldValue == nil {
  35312. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  35313. }
  35314. oldValue, err := m.oldValue(ctx)
  35315. if err != nil {
  35316. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  35317. }
  35318. return oldValue.DeletedAt, nil
  35319. }
  35320. // ClearDeletedAt clears the value of the "deleted_at" field.
  35321. func (m *WorkExperienceMutation) ClearDeletedAt() {
  35322. m.deleted_at = nil
  35323. m.clearedFields[workexperience.FieldDeletedAt] = struct{}{}
  35324. }
  35325. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  35326. func (m *WorkExperienceMutation) DeletedAtCleared() bool {
  35327. _, ok := m.clearedFields[workexperience.FieldDeletedAt]
  35328. return ok
  35329. }
  35330. // ResetDeletedAt resets all changes to the "deleted_at" field.
  35331. func (m *WorkExperienceMutation) ResetDeletedAt() {
  35332. m.deleted_at = nil
  35333. delete(m.clearedFields, workexperience.FieldDeletedAt)
  35334. }
  35335. // SetEmployeeID sets the "employee_id" field.
  35336. func (m *WorkExperienceMutation) SetEmployeeID(u uint64) {
  35337. m.employee = &u
  35338. }
  35339. // EmployeeID returns the value of the "employee_id" field in the mutation.
  35340. func (m *WorkExperienceMutation) EmployeeID() (r uint64, exists bool) {
  35341. v := m.employee
  35342. if v == nil {
  35343. return
  35344. }
  35345. return *v, true
  35346. }
  35347. // OldEmployeeID returns the old "employee_id" field's value of the WorkExperience entity.
  35348. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35349. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35350. func (m *WorkExperienceMutation) OldEmployeeID(ctx context.Context) (v uint64, err error) {
  35351. if !m.op.Is(OpUpdateOne) {
  35352. return v, errors.New("OldEmployeeID is only allowed on UpdateOne operations")
  35353. }
  35354. if m.id == nil || m.oldValue == nil {
  35355. return v, errors.New("OldEmployeeID requires an ID field in the mutation")
  35356. }
  35357. oldValue, err := m.oldValue(ctx)
  35358. if err != nil {
  35359. return v, fmt.Errorf("querying old value for OldEmployeeID: %w", err)
  35360. }
  35361. return oldValue.EmployeeID, nil
  35362. }
  35363. // ResetEmployeeID resets all changes to the "employee_id" field.
  35364. func (m *WorkExperienceMutation) ResetEmployeeID() {
  35365. m.employee = nil
  35366. }
  35367. // SetStartDate sets the "start_date" field.
  35368. func (m *WorkExperienceMutation) SetStartDate(t time.Time) {
  35369. m.start_date = &t
  35370. }
  35371. // StartDate returns the value of the "start_date" field in the mutation.
  35372. func (m *WorkExperienceMutation) StartDate() (r time.Time, exists bool) {
  35373. v := m.start_date
  35374. if v == nil {
  35375. return
  35376. }
  35377. return *v, true
  35378. }
  35379. // OldStartDate returns the old "start_date" field's value of the WorkExperience entity.
  35380. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35381. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35382. func (m *WorkExperienceMutation) OldStartDate(ctx context.Context) (v time.Time, err error) {
  35383. if !m.op.Is(OpUpdateOne) {
  35384. return v, errors.New("OldStartDate is only allowed on UpdateOne operations")
  35385. }
  35386. if m.id == nil || m.oldValue == nil {
  35387. return v, errors.New("OldStartDate requires an ID field in the mutation")
  35388. }
  35389. oldValue, err := m.oldValue(ctx)
  35390. if err != nil {
  35391. return v, fmt.Errorf("querying old value for OldStartDate: %w", err)
  35392. }
  35393. return oldValue.StartDate, nil
  35394. }
  35395. // ResetStartDate resets all changes to the "start_date" field.
  35396. func (m *WorkExperienceMutation) ResetStartDate() {
  35397. m.start_date = nil
  35398. }
  35399. // SetEndDate sets the "end_date" field.
  35400. func (m *WorkExperienceMutation) SetEndDate(t time.Time) {
  35401. m.end_date = &t
  35402. }
  35403. // EndDate returns the value of the "end_date" field in the mutation.
  35404. func (m *WorkExperienceMutation) EndDate() (r time.Time, exists bool) {
  35405. v := m.end_date
  35406. if v == nil {
  35407. return
  35408. }
  35409. return *v, true
  35410. }
  35411. // OldEndDate returns the old "end_date" field's value of the WorkExperience entity.
  35412. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35413. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35414. func (m *WorkExperienceMutation) OldEndDate(ctx context.Context) (v time.Time, err error) {
  35415. if !m.op.Is(OpUpdateOne) {
  35416. return v, errors.New("OldEndDate is only allowed on UpdateOne operations")
  35417. }
  35418. if m.id == nil || m.oldValue == nil {
  35419. return v, errors.New("OldEndDate requires an ID field in the mutation")
  35420. }
  35421. oldValue, err := m.oldValue(ctx)
  35422. if err != nil {
  35423. return v, fmt.Errorf("querying old value for OldEndDate: %w", err)
  35424. }
  35425. return oldValue.EndDate, nil
  35426. }
  35427. // ResetEndDate resets all changes to the "end_date" field.
  35428. func (m *WorkExperienceMutation) ResetEndDate() {
  35429. m.end_date = nil
  35430. }
  35431. // SetCompany sets the "company" field.
  35432. func (m *WorkExperienceMutation) SetCompany(s string) {
  35433. m.company = &s
  35434. }
  35435. // Company returns the value of the "company" field in the mutation.
  35436. func (m *WorkExperienceMutation) Company() (r string, exists bool) {
  35437. v := m.company
  35438. if v == nil {
  35439. return
  35440. }
  35441. return *v, true
  35442. }
  35443. // OldCompany returns the old "company" field's value of the WorkExperience entity.
  35444. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35445. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35446. func (m *WorkExperienceMutation) OldCompany(ctx context.Context) (v string, err error) {
  35447. if !m.op.Is(OpUpdateOne) {
  35448. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  35449. }
  35450. if m.id == nil || m.oldValue == nil {
  35451. return v, errors.New("OldCompany requires an ID field in the mutation")
  35452. }
  35453. oldValue, err := m.oldValue(ctx)
  35454. if err != nil {
  35455. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  35456. }
  35457. return oldValue.Company, nil
  35458. }
  35459. // ResetCompany resets all changes to the "company" field.
  35460. func (m *WorkExperienceMutation) ResetCompany() {
  35461. m.company = nil
  35462. }
  35463. // SetExperience sets the "experience" field.
  35464. func (m *WorkExperienceMutation) SetExperience(s string) {
  35465. m.experience = &s
  35466. }
  35467. // Experience returns the value of the "experience" field in the mutation.
  35468. func (m *WorkExperienceMutation) Experience() (r string, exists bool) {
  35469. v := m.experience
  35470. if v == nil {
  35471. return
  35472. }
  35473. return *v, true
  35474. }
  35475. // OldExperience returns the old "experience" field's value of the WorkExperience entity.
  35476. // If the WorkExperience object wasn't provided to the builder, the object is fetched from the database.
  35477. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  35478. func (m *WorkExperienceMutation) OldExperience(ctx context.Context) (v string, err error) {
  35479. if !m.op.Is(OpUpdateOne) {
  35480. return v, errors.New("OldExperience is only allowed on UpdateOne operations")
  35481. }
  35482. if m.id == nil || m.oldValue == nil {
  35483. return v, errors.New("OldExperience requires an ID field in the mutation")
  35484. }
  35485. oldValue, err := m.oldValue(ctx)
  35486. if err != nil {
  35487. return v, fmt.Errorf("querying old value for OldExperience: %w", err)
  35488. }
  35489. return oldValue.Experience, nil
  35490. }
  35491. // ResetExperience resets all changes to the "experience" field.
  35492. func (m *WorkExperienceMutation) ResetExperience() {
  35493. m.experience = nil
  35494. }
  35495. // SetOrganizationID sets the "organization_id" field.
  35496. func (m *WorkExperienceMutation) SetOrganizationID(u uint64) {
  35497. m.organization_id = &u
  35498. m.addorganization_id = nil
  35499. }
  35500. // OrganizationID returns the value of the "organization_id" field in the mutation.
  35501. func (m *WorkExperienceMutation) OrganizationID() (r uint64, exists bool) {
  35502. v := m.organization_id
  35503. if v == nil {
  35504. return
  35505. }
  35506. return *v, true
  35507. }
  35508. // OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  35512. if !m.op.Is(OpUpdateOne) {
  35513. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  35514. }
  35515. if m.id == nil || m.oldValue == nil {
  35516. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  35521. }
  35522. return oldValue.OrganizationID, nil
  35523. }
  35524. // AddOrganizationID adds u to the "organization_id" field.
  35525. func (m *WorkExperienceMutation) AddOrganizationID(u int64) {
  35526. if m.addorganization_id != nil {
  35527. *m.addorganization_id += u
  35528. } else {
  35529. m.addorganization_id = &u
  35530. }
  35531. }
  35532. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  35533. func (m *WorkExperienceMutation) AddedOrganizationID() (r int64, exists bool) {
  35534. v := m.addorganization_id
  35535. if v == nil {
  35536. return
  35537. }
  35538. return *v, true
  35539. }
  35540. // ResetOrganizationID resets all changes to the "organization_id" field.
  35541. func (m *WorkExperienceMutation) ResetOrganizationID() {
  35542. m.organization_id = nil
  35543. m.addorganization_id = nil
  35544. }
  35545. // ClearEmployee clears the "employee" edge to the Employee entity.
  35546. func (m *WorkExperienceMutation) ClearEmployee() {
  35547. m.clearedemployee = true
  35548. m.clearedFields[workexperience.FieldEmployeeID] = struct{}{}
  35549. }
  35550. // EmployeeCleared reports if the "employee" edge to the Employee entity was cleared.
  35551. func (m *WorkExperienceMutation) EmployeeCleared() bool {
  35552. return m.clearedemployee
  35553. }
  35554. // EmployeeIDs returns the "employee" edge IDs in the mutation.
  35555. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  35556. // EmployeeID instead. It exists only for internal usage by the builders.
  35557. func (m *WorkExperienceMutation) EmployeeIDs() (ids []uint64) {
  35558. if id := m.employee; id != nil {
  35559. ids = append(ids, *id)
  35560. }
  35561. return
  35562. }
  35563. // ResetEmployee resets all changes to the "employee" edge.
  35564. func (m *WorkExperienceMutation) ResetEmployee() {
  35565. m.employee = nil
  35566. m.clearedemployee = false
  35567. }
  35568. // Where appends a list predicates to the WorkExperienceMutation builder.
  35569. func (m *WorkExperienceMutation) Where(ps ...predicate.WorkExperience) {
  35570. m.predicates = append(m.predicates, ps...)
  35571. }
  35572. // WhereP appends storage-level predicates to the WorkExperienceMutation builder. Using this method,
  35573. // users can use type-assertion to append predicates that do not depend on any generated package.
  35574. func (m *WorkExperienceMutation) WhereP(ps ...func(*sql.Selector)) {
  35575. p := make([]predicate.WorkExperience, len(ps))
  35576. for i := range ps {
  35577. p[i] = ps[i]
  35578. }
  35579. m.Where(p...)
  35580. }
  35581. // Op returns the operation name.
  35582. func (m *WorkExperienceMutation) Op() Op {
  35583. return m.op
  35584. }
  35585. // SetOp allows setting the mutation operation.
  35586. func (m *WorkExperienceMutation) SetOp(op Op) {
  35587. m.op = op
  35588. }
  35589. // Type returns the node type of this mutation (WorkExperience).
  35590. func (m *WorkExperienceMutation) Type() string {
  35591. return m.typ
  35592. }
  35593. // Fields returns all fields that were changed during this mutation. Note that in
  35594. // order to get all numeric fields that were incremented/decremented, call
  35595. // AddedFields().
  35596. func (m *WorkExperienceMutation) Fields() []string {
  35597. fields := make([]string, 0, 9)
  35598. if m.created_at != nil {
  35599. fields = append(fields, workexperience.FieldCreatedAt)
  35600. }
  35601. if m.updated_at != nil {
  35602. fields = append(fields, workexperience.FieldUpdatedAt)
  35603. }
  35604. if m.deleted_at != nil {
  35605. fields = append(fields, workexperience.FieldDeletedAt)
  35606. }
  35607. if m.employee != nil {
  35608. fields = append(fields, workexperience.FieldEmployeeID)
  35609. }
  35610. if m.start_date != nil {
  35611. fields = append(fields, workexperience.FieldStartDate)
  35612. }
  35613. if m.end_date != nil {
  35614. fields = append(fields, workexperience.FieldEndDate)
  35615. }
  35616. if m.company != nil {
  35617. fields = append(fields, workexperience.FieldCompany)
  35618. }
  35619. if m.experience != nil {
  35620. fields = append(fields, workexperience.FieldExperience)
  35621. }
  35622. if m.organization_id != nil {
  35623. fields = append(fields, workexperience.FieldOrganizationID)
  35624. }
  35625. return fields
  35626. }
  35627. // Field returns the value of a field with the given name. The second boolean
  35628. // return value indicates that this field was not set, or was not defined in the
  35629. // schema.
  35630. func (m *WorkExperienceMutation) Field(name string) (ent.Value, bool) {
  35631. switch name {
  35632. case workexperience.FieldCreatedAt:
  35633. return m.CreatedAt()
  35634. case workexperience.FieldUpdatedAt:
  35635. return m.UpdatedAt()
  35636. case workexperience.FieldDeletedAt:
  35637. return m.DeletedAt()
  35638. case workexperience.FieldEmployeeID:
  35639. return m.EmployeeID()
  35640. case workexperience.FieldStartDate:
  35641. return m.StartDate()
  35642. case workexperience.FieldEndDate:
  35643. return m.EndDate()
  35644. case workexperience.FieldCompany:
  35645. return m.Company()
  35646. case workexperience.FieldExperience:
  35647. return m.Experience()
  35648. case workexperience.FieldOrganizationID:
  35649. return m.OrganizationID()
  35650. }
  35651. return nil, false
  35652. }
  35653. // OldField returns the old value of the field from the database. An error is
  35654. // returned if the mutation operation is not UpdateOne, or the query to the
  35655. // database failed.
  35656. func (m *WorkExperienceMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  35657. switch name {
  35658. case workexperience.FieldCreatedAt:
  35659. return m.OldCreatedAt(ctx)
  35660. case workexperience.FieldUpdatedAt:
  35661. return m.OldUpdatedAt(ctx)
  35662. case workexperience.FieldDeletedAt:
  35663. return m.OldDeletedAt(ctx)
  35664. case workexperience.FieldEmployeeID:
  35665. return m.OldEmployeeID(ctx)
  35666. case workexperience.FieldStartDate:
  35667. return m.OldStartDate(ctx)
  35668. case workexperience.FieldEndDate:
  35669. return m.OldEndDate(ctx)
  35670. case workexperience.FieldCompany:
  35671. return m.OldCompany(ctx)
  35672. case workexperience.FieldExperience:
  35673. return m.OldExperience(ctx)
  35674. case workexperience.FieldOrganizationID:
  35675. return m.OldOrganizationID(ctx)
  35676. }
  35677. return nil, fmt.Errorf("unknown WorkExperience field %s", name)
  35678. }
  35679. // SetField sets the value of a field with the given name. It returns an error if
  35680. // the field is not defined in the schema, or if the type mismatched the field
  35681. // type.
  35682. func (m *WorkExperienceMutation) SetField(name string, value ent.Value) error {
  35683. switch name {
  35684. case workexperience.FieldCreatedAt:
  35685. v, ok := value.(time.Time)
  35686. if !ok {
  35687. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35688. }
  35689. m.SetCreatedAt(v)
  35690. return nil
  35691. case workexperience.FieldUpdatedAt:
  35692. v, ok := value.(time.Time)
  35693. if !ok {
  35694. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35695. }
  35696. m.SetUpdatedAt(v)
  35697. return nil
  35698. case workexperience.FieldDeletedAt:
  35699. v, ok := value.(time.Time)
  35700. if !ok {
  35701. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35702. }
  35703. m.SetDeletedAt(v)
  35704. return nil
  35705. case workexperience.FieldEmployeeID:
  35706. v, ok := value.(uint64)
  35707. if !ok {
  35708. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35709. }
  35710. m.SetEmployeeID(v)
  35711. return nil
  35712. case workexperience.FieldStartDate:
  35713. v, ok := value.(time.Time)
  35714. if !ok {
  35715. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35716. }
  35717. m.SetStartDate(v)
  35718. return nil
  35719. case workexperience.FieldEndDate:
  35720. v, ok := value.(time.Time)
  35721. if !ok {
  35722. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35723. }
  35724. m.SetEndDate(v)
  35725. return nil
  35726. case workexperience.FieldCompany:
  35727. v, ok := value.(string)
  35728. if !ok {
  35729. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35730. }
  35731. m.SetCompany(v)
  35732. return nil
  35733. case workexperience.FieldExperience:
  35734. v, ok := value.(string)
  35735. if !ok {
  35736. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35737. }
  35738. m.SetExperience(v)
  35739. return nil
  35740. case workexperience.FieldOrganizationID:
  35741. v, ok := value.(uint64)
  35742. if !ok {
  35743. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35744. }
  35745. m.SetOrganizationID(v)
  35746. return nil
  35747. }
  35748. return fmt.Errorf("unknown WorkExperience field %s", name)
  35749. }
  35750. // AddedFields returns all numeric fields that were incremented/decremented during
  35751. // this mutation.
  35752. func (m *WorkExperienceMutation) AddedFields() []string {
  35753. var fields []string
  35754. if m.addorganization_id != nil {
  35755. fields = append(fields, workexperience.FieldOrganizationID)
  35756. }
  35757. return fields
  35758. }
  35759. // AddedField returns the numeric value that was incremented/decremented on a field
  35760. // with the given name. The second boolean return value indicates that this field
  35761. // was not set, or was not defined in the schema.
  35762. func (m *WorkExperienceMutation) AddedField(name string) (ent.Value, bool) {
  35763. switch name {
  35764. case workexperience.FieldOrganizationID:
  35765. return m.AddedOrganizationID()
  35766. }
  35767. return nil, false
  35768. }
  35769. // AddField adds the value to the field with the given name. It returns an error if
  35770. // the field is not defined in the schema, or if the type mismatched the field
  35771. // type.
  35772. func (m *WorkExperienceMutation) AddField(name string, value ent.Value) error {
  35773. switch name {
  35774. case workexperience.FieldOrganizationID:
  35775. v, ok := value.(int64)
  35776. if !ok {
  35777. return fmt.Errorf("unexpected type %T for field %s", value, name)
  35778. }
  35779. m.AddOrganizationID(v)
  35780. return nil
  35781. }
  35782. return fmt.Errorf("unknown WorkExperience numeric field %s", name)
  35783. }
  35784. // ClearedFields returns all nullable fields that were cleared during this
  35785. // mutation.
  35786. func (m *WorkExperienceMutation) ClearedFields() []string {
  35787. var fields []string
  35788. if m.FieldCleared(workexperience.FieldDeletedAt) {
  35789. fields = append(fields, workexperience.FieldDeletedAt)
  35790. }
  35791. return fields
  35792. }
  35793. // FieldCleared returns a boolean indicating if a field with the given name was
  35794. // cleared in this mutation.
  35795. func (m *WorkExperienceMutation) FieldCleared(name string) bool {
  35796. _, ok := m.clearedFields[name]
  35797. return ok
  35798. }
  35799. // ClearField clears the value of the field with the given name. It returns an
  35800. // error if the field is not defined in the schema.
  35801. func (m *WorkExperienceMutation) ClearField(name string) error {
  35802. switch name {
  35803. case workexperience.FieldDeletedAt:
  35804. m.ClearDeletedAt()
  35805. return nil
  35806. }
  35807. return fmt.Errorf("unknown WorkExperience nullable field %s", name)
  35808. }
  35809. // ResetField resets all changes in the mutation for the field with the given name.
  35810. // It returns an error if the field is not defined in the schema.
  35811. func (m *WorkExperienceMutation) ResetField(name string) error {
  35812. switch name {
  35813. case workexperience.FieldCreatedAt:
  35814. m.ResetCreatedAt()
  35815. return nil
  35816. case workexperience.FieldUpdatedAt:
  35817. m.ResetUpdatedAt()
  35818. return nil
  35819. case workexperience.FieldDeletedAt:
  35820. m.ResetDeletedAt()
  35821. return nil
  35822. case workexperience.FieldEmployeeID:
  35823. m.ResetEmployeeID()
  35824. return nil
  35825. case workexperience.FieldStartDate:
  35826. m.ResetStartDate()
  35827. return nil
  35828. case workexperience.FieldEndDate:
  35829. m.ResetEndDate()
  35830. return nil
  35831. case workexperience.FieldCompany:
  35832. m.ResetCompany()
  35833. return nil
  35834. case workexperience.FieldExperience:
  35835. m.ResetExperience()
  35836. return nil
  35837. case workexperience.FieldOrganizationID:
  35838. m.ResetOrganizationID()
  35839. return nil
  35840. }
  35841. return fmt.Errorf("unknown WorkExperience field %s", name)
  35842. }
  35843. // AddedEdges returns all edge names that were set/added in this mutation.
  35844. func (m *WorkExperienceMutation) AddedEdges() []string {
  35845. edges := make([]string, 0, 1)
  35846. if m.employee != nil {
  35847. edges = append(edges, workexperience.EdgeEmployee)
  35848. }
  35849. return edges
  35850. }
  35851. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  35852. // name in this mutation.
  35853. func (m *WorkExperienceMutation) AddedIDs(name string) []ent.Value {
  35854. switch name {
  35855. case workexperience.EdgeEmployee:
  35856. if id := m.employee; id != nil {
  35857. return []ent.Value{*id}
  35858. }
  35859. }
  35860. return nil
  35861. }
  35862. // RemovedEdges returns all edge names that were removed in this mutation.
  35863. func (m *WorkExperienceMutation) RemovedEdges() []string {
  35864. edges := make([]string, 0, 1)
  35865. return edges
  35866. }
  35867. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  35868. // the given name in this mutation.
  35869. func (m *WorkExperienceMutation) RemovedIDs(name string) []ent.Value {
  35870. return nil
  35871. }
  35872. // ClearedEdges returns all edge names that were cleared in this mutation.
  35873. func (m *WorkExperienceMutation) ClearedEdges() []string {
  35874. edges := make([]string, 0, 1)
  35875. if m.clearedemployee {
  35876. edges = append(edges, workexperience.EdgeEmployee)
  35877. }
  35878. return edges
  35879. }
  35880. // EdgeCleared returns a boolean which indicates if the edge with the given name
  35881. // was cleared in this mutation.
  35882. func (m *WorkExperienceMutation) EdgeCleared(name string) bool {
  35883. switch name {
  35884. case workexperience.EdgeEmployee:
  35885. return m.clearedemployee
  35886. }
  35887. return false
  35888. }
  35889. // ClearEdge clears the value of the edge with the given name. It returns an error
  35890. // if that edge is not defined in the schema.
  35891. func (m *WorkExperienceMutation) ClearEdge(name string) error {
  35892. switch name {
  35893. case workexperience.EdgeEmployee:
  35894. m.ClearEmployee()
  35895. return nil
  35896. }
  35897. return fmt.Errorf("unknown WorkExperience unique edge %s", name)
  35898. }
  35899. // ResetEdge resets all changes to the edge with the given name in this mutation.
  35900. // It returns an error if the edge is not defined in the schema.
  35901. func (m *WorkExperienceMutation) ResetEdge(name string) error {
  35902. switch name {
  35903. case workexperience.EdgeEmployee:
  35904. m.ResetEmployee()
  35905. return nil
  35906. }
  35907. return fmt.Errorf("unknown WorkExperience edge %s", name)
  35908. }
  35909. // WpChatroomMutation represents an operation that mutates the WpChatroom nodes in the graph.
  35910. type WpChatroomMutation struct {
  35911. config
  35912. op Op
  35913. typ string
  35914. id *uint64
  35915. created_at *time.Time
  35916. updated_at *time.Time
  35917. status *uint8
  35918. addstatus *int8
  35919. wx_wxid *string
  35920. chatroom_id *string
  35921. nickname *string
  35922. owner *string
  35923. avatar *string
  35924. member_list *[]string
  35925. appendmember_list []string
  35926. clearedFields map[string]struct{}
  35927. done bool
  35928. oldValue func(context.Context) (*WpChatroom, error)
  35929. predicates []predicate.WpChatroom
  35930. }
  35931. var _ ent.Mutation = (*WpChatroomMutation)(nil)
  35932. // wpchatroomOption allows management of the mutation configuration using functional options.
  35933. type wpchatroomOption func(*WpChatroomMutation)
  35934. // newWpChatroomMutation creates new mutation for the WpChatroom entity.
  35935. func newWpChatroomMutation(c config, op Op, opts ...wpchatroomOption) *WpChatroomMutation {
  35936. m := &WpChatroomMutation{
  35937. config: c,
  35938. op: op,
  35939. typ: TypeWpChatroom,
  35940. clearedFields: make(map[string]struct{}),
  35941. }
  35942. for _, opt := range opts {
  35943. opt(m)
  35944. }
  35945. return m
  35946. }
  35947. // withWpChatroomID sets the ID field of the mutation.
  35948. func withWpChatroomID(id uint64) wpchatroomOption {
  35949. return func(m *WpChatroomMutation) {
  35950. var (
  35951. err error
  35952. once sync.Once
  35953. value *WpChatroom
  35954. )
  35955. m.oldValue = func(ctx context.Context) (*WpChatroom, error) {
  35956. once.Do(func() {
  35957. if m.done {
  35958. err = errors.New("querying old values post mutation is not allowed")
  35959. } else {
  35960. value, err = m.Client().WpChatroom.Get(ctx, id)
  35961. }
  35962. })
  35963. return value, err
  35964. }
  35965. m.id = &id
  35966. }
  35967. }
  35968. // withWpChatroom sets the old WpChatroom of the mutation.
  35969. func withWpChatroom(node *WpChatroom) wpchatroomOption {
  35970. return func(m *WpChatroomMutation) {
  35971. m.oldValue = func(context.Context) (*WpChatroom, error) {
  35972. return node, nil
  35973. }
  35974. m.id = &node.ID
  35975. }
  35976. }
  35977. // Client returns a new `ent.Client` from the mutation. If the mutation was
  35978. // executed in a transaction (ent.Tx), a transactional client is returned.
  35979. func (m WpChatroomMutation) Client() *Client {
  35980. client := &Client{config: m.config}
  35981. client.init()
  35982. return client
  35983. }
  35984. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  35985. // it returns an error otherwise.
  35986. func (m WpChatroomMutation) Tx() (*Tx, error) {
  35987. if _, ok := m.driver.(*txDriver); !ok {
  35988. return nil, errors.New("ent: mutation is not running in a transaction")
  35989. }
  35990. tx := &Tx{config: m.config}
  35991. tx.init()
  35992. return tx, nil
  35993. }
  35994. // SetID sets the value of the id field. Note that this
  35995. // operation is only accepted on creation of WpChatroom entities.
  35996. func (m *WpChatroomMutation) SetID(id uint64) {
  35997. m.id = &id
  35998. }
  35999. // ID returns the ID value in the mutation. Note that the ID is only available
  36000. // if it was provided to the builder or after it was returned from the database.
  36001. func (m *WpChatroomMutation) ID() (id uint64, exists bool) {
  36002. if m.id == nil {
  36003. return
  36004. }
  36005. return *m.id, true
  36006. }
  36007. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36008. // That means, if the mutation is applied within a transaction with an isolation level such
  36009. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36010. // or updated by the mutation.
  36011. func (m *WpChatroomMutation) IDs(ctx context.Context) ([]uint64, error) {
  36012. switch {
  36013. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36014. id, exists := m.ID()
  36015. if exists {
  36016. return []uint64{id}, nil
  36017. }
  36018. fallthrough
  36019. case m.op.Is(OpUpdate | OpDelete):
  36020. return m.Client().WpChatroom.Query().Where(m.predicates...).IDs(ctx)
  36021. default:
  36022. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36023. }
  36024. }
  36025. // SetCreatedAt sets the "created_at" field.
  36026. func (m *WpChatroomMutation) SetCreatedAt(t time.Time) {
  36027. m.created_at = &t
  36028. }
  36029. // CreatedAt returns the value of the "created_at" field in the mutation.
  36030. func (m *WpChatroomMutation) CreatedAt() (r time.Time, exists bool) {
  36031. v := m.created_at
  36032. if v == nil {
  36033. return
  36034. }
  36035. return *v, true
  36036. }
  36037. // OldCreatedAt returns the old "created_at" field's value of the WpChatroom entity.
  36038. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36039. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36040. func (m *WpChatroomMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36041. if !m.op.Is(OpUpdateOne) {
  36042. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36043. }
  36044. if m.id == nil || m.oldValue == nil {
  36045. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36046. }
  36047. oldValue, err := m.oldValue(ctx)
  36048. if err != nil {
  36049. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36050. }
  36051. return oldValue.CreatedAt, nil
  36052. }
  36053. // ResetCreatedAt resets all changes to the "created_at" field.
  36054. func (m *WpChatroomMutation) ResetCreatedAt() {
  36055. m.created_at = nil
  36056. }
  36057. // SetUpdatedAt sets the "updated_at" field.
  36058. func (m *WpChatroomMutation) SetUpdatedAt(t time.Time) {
  36059. m.updated_at = &t
  36060. }
  36061. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36062. func (m *WpChatroomMutation) UpdatedAt() (r time.Time, exists bool) {
  36063. v := m.updated_at
  36064. if v == nil {
  36065. return
  36066. }
  36067. return *v, true
  36068. }
  36069. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroom entity.
  36070. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36072. func (m *WpChatroomMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36073. if !m.op.Is(OpUpdateOne) {
  36074. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36075. }
  36076. if m.id == nil || m.oldValue == nil {
  36077. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36078. }
  36079. oldValue, err := m.oldValue(ctx)
  36080. if err != nil {
  36081. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36082. }
  36083. return oldValue.UpdatedAt, nil
  36084. }
  36085. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36086. func (m *WpChatroomMutation) ResetUpdatedAt() {
  36087. m.updated_at = nil
  36088. }
  36089. // SetStatus sets the "status" field.
  36090. func (m *WpChatroomMutation) SetStatus(u uint8) {
  36091. m.status = &u
  36092. m.addstatus = nil
  36093. }
  36094. // Status returns the value of the "status" field in the mutation.
  36095. func (m *WpChatroomMutation) Status() (r uint8, exists bool) {
  36096. v := m.status
  36097. if v == nil {
  36098. return
  36099. }
  36100. return *v, true
  36101. }
  36102. // OldStatus returns the old "status" field's value of the WpChatroom entity.
  36103. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36104. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36105. func (m *WpChatroomMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36106. if !m.op.Is(OpUpdateOne) {
  36107. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36108. }
  36109. if m.id == nil || m.oldValue == nil {
  36110. return v, errors.New("OldStatus requires an ID field in the mutation")
  36111. }
  36112. oldValue, err := m.oldValue(ctx)
  36113. if err != nil {
  36114. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36115. }
  36116. return oldValue.Status, nil
  36117. }
  36118. // AddStatus adds u to the "status" field.
  36119. func (m *WpChatroomMutation) AddStatus(u int8) {
  36120. if m.addstatus != nil {
  36121. *m.addstatus += u
  36122. } else {
  36123. m.addstatus = &u
  36124. }
  36125. }
  36126. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36127. func (m *WpChatroomMutation) AddedStatus() (r int8, exists bool) {
  36128. v := m.addstatus
  36129. if v == nil {
  36130. return
  36131. }
  36132. return *v, true
  36133. }
  36134. // ClearStatus clears the value of the "status" field.
  36135. func (m *WpChatroomMutation) ClearStatus() {
  36136. m.status = nil
  36137. m.addstatus = nil
  36138. m.clearedFields[wpchatroom.FieldStatus] = struct{}{}
  36139. }
  36140. // StatusCleared returns if the "status" field was cleared in this mutation.
  36141. func (m *WpChatroomMutation) StatusCleared() bool {
  36142. _, ok := m.clearedFields[wpchatroom.FieldStatus]
  36143. return ok
  36144. }
  36145. // ResetStatus resets all changes to the "status" field.
  36146. func (m *WpChatroomMutation) ResetStatus() {
  36147. m.status = nil
  36148. m.addstatus = nil
  36149. delete(m.clearedFields, wpchatroom.FieldStatus)
  36150. }
  36151. // SetWxWxid sets the "wx_wxid" field.
  36152. func (m *WpChatroomMutation) SetWxWxid(s string) {
  36153. m.wx_wxid = &s
  36154. }
  36155. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36156. func (m *WpChatroomMutation) WxWxid() (r string, exists bool) {
  36157. v := m.wx_wxid
  36158. if v == nil {
  36159. return
  36160. }
  36161. return *v, true
  36162. }
  36163. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroom entity.
  36164. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36165. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36166. func (m *WpChatroomMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36167. if !m.op.Is(OpUpdateOne) {
  36168. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36169. }
  36170. if m.id == nil || m.oldValue == nil {
  36171. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36172. }
  36173. oldValue, err := m.oldValue(ctx)
  36174. if err != nil {
  36175. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36176. }
  36177. return oldValue.WxWxid, nil
  36178. }
  36179. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36180. func (m *WpChatroomMutation) ResetWxWxid() {
  36181. m.wx_wxid = nil
  36182. }
  36183. // SetChatroomID sets the "chatroom_id" field.
  36184. func (m *WpChatroomMutation) SetChatroomID(s string) {
  36185. m.chatroom_id = &s
  36186. }
  36187. // ChatroomID returns the value of the "chatroom_id" field in the mutation.
  36188. func (m *WpChatroomMutation) ChatroomID() (r string, exists bool) {
  36189. v := m.chatroom_id
  36190. if v == nil {
  36191. return
  36192. }
  36193. return *v, true
  36194. }
  36195. // OldChatroomID returns the old "chatroom_id" field's value of the WpChatroom entity.
  36196. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36197. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36198. func (m *WpChatroomMutation) OldChatroomID(ctx context.Context) (v string, err error) {
  36199. if !m.op.Is(OpUpdateOne) {
  36200. return v, errors.New("OldChatroomID is only allowed on UpdateOne operations")
  36201. }
  36202. if m.id == nil || m.oldValue == nil {
  36203. return v, errors.New("OldChatroomID requires an ID field in the mutation")
  36204. }
  36205. oldValue, err := m.oldValue(ctx)
  36206. if err != nil {
  36207. return v, fmt.Errorf("querying old value for OldChatroomID: %w", err)
  36208. }
  36209. return oldValue.ChatroomID, nil
  36210. }
  36211. // ResetChatroomID resets all changes to the "chatroom_id" field.
  36212. func (m *WpChatroomMutation) ResetChatroomID() {
  36213. m.chatroom_id = nil
  36214. }
  36215. // SetNickname sets the "nickname" field.
  36216. func (m *WpChatroomMutation) SetNickname(s string) {
  36217. m.nickname = &s
  36218. }
  36219. // Nickname returns the value of the "nickname" field in the mutation.
  36220. func (m *WpChatroomMutation) Nickname() (r string, exists bool) {
  36221. v := m.nickname
  36222. if v == nil {
  36223. return
  36224. }
  36225. return *v, true
  36226. }
  36227. // OldNickname returns the old "nickname" field's value of the WpChatroom entity.
  36228. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36229. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36230. func (m *WpChatroomMutation) OldNickname(ctx context.Context) (v string, err error) {
  36231. if !m.op.Is(OpUpdateOne) {
  36232. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36233. }
  36234. if m.id == nil || m.oldValue == nil {
  36235. return v, errors.New("OldNickname requires an ID field in the mutation")
  36236. }
  36237. oldValue, err := m.oldValue(ctx)
  36238. if err != nil {
  36239. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36240. }
  36241. return oldValue.Nickname, nil
  36242. }
  36243. // ResetNickname resets all changes to the "nickname" field.
  36244. func (m *WpChatroomMutation) ResetNickname() {
  36245. m.nickname = nil
  36246. }
  36247. // SetOwner sets the "owner" field.
  36248. func (m *WpChatroomMutation) SetOwner(s string) {
  36249. m.owner = &s
  36250. }
  36251. // Owner returns the value of the "owner" field in the mutation.
  36252. func (m *WpChatroomMutation) Owner() (r string, exists bool) {
  36253. v := m.owner
  36254. if v == nil {
  36255. return
  36256. }
  36257. return *v, true
  36258. }
  36259. // OldOwner returns the old "owner" field's value of the WpChatroom entity.
  36260. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36261. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36262. func (m *WpChatroomMutation) OldOwner(ctx context.Context) (v string, err error) {
  36263. if !m.op.Is(OpUpdateOne) {
  36264. return v, errors.New("OldOwner is only allowed on UpdateOne operations")
  36265. }
  36266. if m.id == nil || m.oldValue == nil {
  36267. return v, errors.New("OldOwner requires an ID field in the mutation")
  36268. }
  36269. oldValue, err := m.oldValue(ctx)
  36270. if err != nil {
  36271. return v, fmt.Errorf("querying old value for OldOwner: %w", err)
  36272. }
  36273. return oldValue.Owner, nil
  36274. }
  36275. // ResetOwner resets all changes to the "owner" field.
  36276. func (m *WpChatroomMutation) ResetOwner() {
  36277. m.owner = nil
  36278. }
  36279. // SetAvatar sets the "avatar" field.
  36280. func (m *WpChatroomMutation) SetAvatar(s string) {
  36281. m.avatar = &s
  36282. }
  36283. // Avatar returns the value of the "avatar" field in the mutation.
  36284. func (m *WpChatroomMutation) Avatar() (r string, exists bool) {
  36285. v := m.avatar
  36286. if v == nil {
  36287. return
  36288. }
  36289. return *v, true
  36290. }
  36291. // OldAvatar returns the old "avatar" field's value of the WpChatroom entity.
  36292. // If the WpChatroom object wasn't provided to the builder, the object is fetched from the database.
  36293. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36294. func (m *WpChatroomMutation) OldAvatar(ctx context.Context) (v string, err error) {
  36295. if !m.op.Is(OpUpdateOne) {
  36296. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  36297. }
  36298. if m.id == nil || m.oldValue == nil {
  36299. return v, errors.New("OldAvatar requires an ID field in the mutation")
  36300. }
  36301. oldValue, err := m.oldValue(ctx)
  36302. if err != nil {
  36303. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  36304. }
  36305. return oldValue.Avatar, nil
  36306. }
  36307. // ResetAvatar resets all changes to the "avatar" field.
  36308. func (m *WpChatroomMutation) ResetAvatar() {
  36309. m.avatar = nil
  36310. }
  36311. // SetMemberList sets the "member_list" field.
  36312. func (m *WpChatroomMutation) SetMemberList(s []string) {
  36313. m.member_list = &s
  36314. m.appendmember_list = nil
  36315. }
  36316. // MemberList returns the value of the "member_list" field in the mutation.
  36317. func (m *WpChatroomMutation) MemberList() (r []string, exists bool) {
  36318. v := m.member_list
  36319. if v == nil {
  36320. return
  36321. }
  36322. return *v, true
  36323. }
  36324. // OldMemberList returns the old "member_list" 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) OldMemberList(ctx context.Context) (v []string, err error) {
  36328. if !m.op.Is(OpUpdateOne) {
  36329. return v, errors.New("OldMemberList is only allowed on UpdateOne operations")
  36330. }
  36331. if m.id == nil || m.oldValue == nil {
  36332. return v, errors.New("OldMemberList 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 OldMemberList: %w", err)
  36337. }
  36338. return oldValue.MemberList, nil
  36339. }
  36340. // AppendMemberList adds s to the "member_list" field.
  36341. func (m *WpChatroomMutation) AppendMemberList(s []string) {
  36342. m.appendmember_list = append(m.appendmember_list, s...)
  36343. }
  36344. // AppendedMemberList returns the list of values that were appended to the "member_list" field in this mutation.
  36345. func (m *WpChatroomMutation) AppendedMemberList() ([]string, bool) {
  36346. if len(m.appendmember_list) == 0 {
  36347. return nil, false
  36348. }
  36349. return m.appendmember_list, true
  36350. }
  36351. // ResetMemberList resets all changes to the "member_list" field.
  36352. func (m *WpChatroomMutation) ResetMemberList() {
  36353. m.member_list = nil
  36354. m.appendmember_list = nil
  36355. }
  36356. // Where appends a list predicates to the WpChatroomMutation builder.
  36357. func (m *WpChatroomMutation) Where(ps ...predicate.WpChatroom) {
  36358. m.predicates = append(m.predicates, ps...)
  36359. }
  36360. // WhereP appends storage-level predicates to the WpChatroomMutation builder. Using this method,
  36361. // users can use type-assertion to append predicates that do not depend on any generated package.
  36362. func (m *WpChatroomMutation) WhereP(ps ...func(*sql.Selector)) {
  36363. p := make([]predicate.WpChatroom, len(ps))
  36364. for i := range ps {
  36365. p[i] = ps[i]
  36366. }
  36367. m.Where(p...)
  36368. }
  36369. // Op returns the operation name.
  36370. func (m *WpChatroomMutation) Op() Op {
  36371. return m.op
  36372. }
  36373. // SetOp allows setting the mutation operation.
  36374. func (m *WpChatroomMutation) SetOp(op Op) {
  36375. m.op = op
  36376. }
  36377. // Type returns the node type of this mutation (WpChatroom).
  36378. func (m *WpChatroomMutation) Type() string {
  36379. return m.typ
  36380. }
  36381. // Fields returns all fields that were changed during this mutation. Note that in
  36382. // order to get all numeric fields that were incremented/decremented, call
  36383. // AddedFields().
  36384. func (m *WpChatroomMutation) Fields() []string {
  36385. fields := make([]string, 0, 9)
  36386. if m.created_at != nil {
  36387. fields = append(fields, wpchatroom.FieldCreatedAt)
  36388. }
  36389. if m.updated_at != nil {
  36390. fields = append(fields, wpchatroom.FieldUpdatedAt)
  36391. }
  36392. if m.status != nil {
  36393. fields = append(fields, wpchatroom.FieldStatus)
  36394. }
  36395. if m.wx_wxid != nil {
  36396. fields = append(fields, wpchatroom.FieldWxWxid)
  36397. }
  36398. if m.chatroom_id != nil {
  36399. fields = append(fields, wpchatroom.FieldChatroomID)
  36400. }
  36401. if m.nickname != nil {
  36402. fields = append(fields, wpchatroom.FieldNickname)
  36403. }
  36404. if m.owner != nil {
  36405. fields = append(fields, wpchatroom.FieldOwner)
  36406. }
  36407. if m.avatar != nil {
  36408. fields = append(fields, wpchatroom.FieldAvatar)
  36409. }
  36410. if m.member_list != nil {
  36411. fields = append(fields, wpchatroom.FieldMemberList)
  36412. }
  36413. return fields
  36414. }
  36415. // Field returns the value of a field with the given name. The second boolean
  36416. // return value indicates that this field was not set, or was not defined in the
  36417. // schema.
  36418. func (m *WpChatroomMutation) Field(name string) (ent.Value, bool) {
  36419. switch name {
  36420. case wpchatroom.FieldCreatedAt:
  36421. return m.CreatedAt()
  36422. case wpchatroom.FieldUpdatedAt:
  36423. return m.UpdatedAt()
  36424. case wpchatroom.FieldStatus:
  36425. return m.Status()
  36426. case wpchatroom.FieldWxWxid:
  36427. return m.WxWxid()
  36428. case wpchatroom.FieldChatroomID:
  36429. return m.ChatroomID()
  36430. case wpchatroom.FieldNickname:
  36431. return m.Nickname()
  36432. case wpchatroom.FieldOwner:
  36433. return m.Owner()
  36434. case wpchatroom.FieldAvatar:
  36435. return m.Avatar()
  36436. case wpchatroom.FieldMemberList:
  36437. return m.MemberList()
  36438. }
  36439. return nil, false
  36440. }
  36441. // OldField returns the old value of the field from the database. An error is
  36442. // returned if the mutation operation is not UpdateOne, or the query to the
  36443. // database failed.
  36444. func (m *WpChatroomMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  36445. switch name {
  36446. case wpchatroom.FieldCreatedAt:
  36447. return m.OldCreatedAt(ctx)
  36448. case wpchatroom.FieldUpdatedAt:
  36449. return m.OldUpdatedAt(ctx)
  36450. case wpchatroom.FieldStatus:
  36451. return m.OldStatus(ctx)
  36452. case wpchatroom.FieldWxWxid:
  36453. return m.OldWxWxid(ctx)
  36454. case wpchatroom.FieldChatroomID:
  36455. return m.OldChatroomID(ctx)
  36456. case wpchatroom.FieldNickname:
  36457. return m.OldNickname(ctx)
  36458. case wpchatroom.FieldOwner:
  36459. return m.OldOwner(ctx)
  36460. case wpchatroom.FieldAvatar:
  36461. return m.OldAvatar(ctx)
  36462. case wpchatroom.FieldMemberList:
  36463. return m.OldMemberList(ctx)
  36464. }
  36465. return nil, fmt.Errorf("unknown WpChatroom field %s", name)
  36466. }
  36467. // SetField sets the value of a field with the given name. It returns an error if
  36468. // the field is not defined in the schema, or if the type mismatched the field
  36469. // type.
  36470. func (m *WpChatroomMutation) SetField(name string, value ent.Value) error {
  36471. switch name {
  36472. case wpchatroom.FieldCreatedAt:
  36473. v, ok := value.(time.Time)
  36474. if !ok {
  36475. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36476. }
  36477. m.SetCreatedAt(v)
  36478. return nil
  36479. case wpchatroom.FieldUpdatedAt:
  36480. v, ok := value.(time.Time)
  36481. if !ok {
  36482. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36483. }
  36484. m.SetUpdatedAt(v)
  36485. return nil
  36486. case wpchatroom.FieldStatus:
  36487. v, ok := value.(uint8)
  36488. if !ok {
  36489. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36490. }
  36491. m.SetStatus(v)
  36492. return nil
  36493. case wpchatroom.FieldWxWxid:
  36494. v, ok := value.(string)
  36495. if !ok {
  36496. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36497. }
  36498. m.SetWxWxid(v)
  36499. return nil
  36500. case wpchatroom.FieldChatroomID:
  36501. v, ok := value.(string)
  36502. if !ok {
  36503. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36504. }
  36505. m.SetChatroomID(v)
  36506. return nil
  36507. case wpchatroom.FieldNickname:
  36508. v, ok := value.(string)
  36509. if !ok {
  36510. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36511. }
  36512. m.SetNickname(v)
  36513. return nil
  36514. case wpchatroom.FieldOwner:
  36515. v, ok := value.(string)
  36516. if !ok {
  36517. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36518. }
  36519. m.SetOwner(v)
  36520. return nil
  36521. case wpchatroom.FieldAvatar:
  36522. v, ok := value.(string)
  36523. if !ok {
  36524. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36525. }
  36526. m.SetAvatar(v)
  36527. return nil
  36528. case wpchatroom.FieldMemberList:
  36529. v, ok := value.([]string)
  36530. if !ok {
  36531. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36532. }
  36533. m.SetMemberList(v)
  36534. return nil
  36535. }
  36536. return fmt.Errorf("unknown WpChatroom field %s", name)
  36537. }
  36538. // AddedFields returns all numeric fields that were incremented/decremented during
  36539. // this mutation.
  36540. func (m *WpChatroomMutation) AddedFields() []string {
  36541. var fields []string
  36542. if m.addstatus != nil {
  36543. fields = append(fields, wpchatroom.FieldStatus)
  36544. }
  36545. return fields
  36546. }
  36547. // AddedField returns the numeric value that was incremented/decremented on a field
  36548. // with the given name. The second boolean return value indicates that this field
  36549. // was not set, or was not defined in the schema.
  36550. func (m *WpChatroomMutation) AddedField(name string) (ent.Value, bool) {
  36551. switch name {
  36552. case wpchatroom.FieldStatus:
  36553. return m.AddedStatus()
  36554. }
  36555. return nil, false
  36556. }
  36557. // AddField adds the value to the field with the given name. It returns an error if
  36558. // the field is not defined in the schema, or if the type mismatched the field
  36559. // type.
  36560. func (m *WpChatroomMutation) AddField(name string, value ent.Value) error {
  36561. switch name {
  36562. case wpchatroom.FieldStatus:
  36563. v, ok := value.(int8)
  36564. if !ok {
  36565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  36566. }
  36567. m.AddStatus(v)
  36568. return nil
  36569. }
  36570. return fmt.Errorf("unknown WpChatroom numeric field %s", name)
  36571. }
  36572. // ClearedFields returns all nullable fields that were cleared during this
  36573. // mutation.
  36574. func (m *WpChatroomMutation) ClearedFields() []string {
  36575. var fields []string
  36576. if m.FieldCleared(wpchatroom.FieldStatus) {
  36577. fields = append(fields, wpchatroom.FieldStatus)
  36578. }
  36579. return fields
  36580. }
  36581. // FieldCleared returns a boolean indicating if a field with the given name was
  36582. // cleared in this mutation.
  36583. func (m *WpChatroomMutation) FieldCleared(name string) bool {
  36584. _, ok := m.clearedFields[name]
  36585. return ok
  36586. }
  36587. // ClearField clears the value of the field with the given name. It returns an
  36588. // error if the field is not defined in the schema.
  36589. func (m *WpChatroomMutation) ClearField(name string) error {
  36590. switch name {
  36591. case wpchatroom.FieldStatus:
  36592. m.ClearStatus()
  36593. return nil
  36594. }
  36595. return fmt.Errorf("unknown WpChatroom nullable field %s", name)
  36596. }
  36597. // ResetField resets all changes in the mutation for the field with the given name.
  36598. // It returns an error if the field is not defined in the schema.
  36599. func (m *WpChatroomMutation) ResetField(name string) error {
  36600. switch name {
  36601. case wpchatroom.FieldCreatedAt:
  36602. m.ResetCreatedAt()
  36603. return nil
  36604. case wpchatroom.FieldUpdatedAt:
  36605. m.ResetUpdatedAt()
  36606. return nil
  36607. case wpchatroom.FieldStatus:
  36608. m.ResetStatus()
  36609. return nil
  36610. case wpchatroom.FieldWxWxid:
  36611. m.ResetWxWxid()
  36612. return nil
  36613. case wpchatroom.FieldChatroomID:
  36614. m.ResetChatroomID()
  36615. return nil
  36616. case wpchatroom.FieldNickname:
  36617. m.ResetNickname()
  36618. return nil
  36619. case wpchatroom.FieldOwner:
  36620. m.ResetOwner()
  36621. return nil
  36622. case wpchatroom.FieldAvatar:
  36623. m.ResetAvatar()
  36624. return nil
  36625. case wpchatroom.FieldMemberList:
  36626. m.ResetMemberList()
  36627. return nil
  36628. }
  36629. return fmt.Errorf("unknown WpChatroom field %s", name)
  36630. }
  36631. // AddedEdges returns all edge names that were set/added in this mutation.
  36632. func (m *WpChatroomMutation) AddedEdges() []string {
  36633. edges := make([]string, 0, 0)
  36634. return edges
  36635. }
  36636. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  36637. // name in this mutation.
  36638. func (m *WpChatroomMutation) AddedIDs(name string) []ent.Value {
  36639. return nil
  36640. }
  36641. // RemovedEdges returns all edge names that were removed in this mutation.
  36642. func (m *WpChatroomMutation) RemovedEdges() []string {
  36643. edges := make([]string, 0, 0)
  36644. return edges
  36645. }
  36646. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  36647. // the given name in this mutation.
  36648. func (m *WpChatroomMutation) RemovedIDs(name string) []ent.Value {
  36649. return nil
  36650. }
  36651. // ClearedEdges returns all edge names that were cleared in this mutation.
  36652. func (m *WpChatroomMutation) ClearedEdges() []string {
  36653. edges := make([]string, 0, 0)
  36654. return edges
  36655. }
  36656. // EdgeCleared returns a boolean which indicates if the edge with the given name
  36657. // was cleared in this mutation.
  36658. func (m *WpChatroomMutation) EdgeCleared(name string) bool {
  36659. return false
  36660. }
  36661. // ClearEdge clears the value of the edge with the given name. It returns an error
  36662. // if that edge is not defined in the schema.
  36663. func (m *WpChatroomMutation) ClearEdge(name string) error {
  36664. return fmt.Errorf("unknown WpChatroom unique edge %s", name)
  36665. }
  36666. // ResetEdge resets all changes to the edge with the given name in this mutation.
  36667. // It returns an error if the edge is not defined in the schema.
  36668. func (m *WpChatroomMutation) ResetEdge(name string) error {
  36669. return fmt.Errorf("unknown WpChatroom edge %s", name)
  36670. }
  36671. // WpChatroomMemberMutation represents an operation that mutates the WpChatroomMember nodes in the graph.
  36672. type WpChatroomMemberMutation struct {
  36673. config
  36674. op Op
  36675. typ string
  36676. id *uint64
  36677. created_at *time.Time
  36678. updated_at *time.Time
  36679. status *uint8
  36680. addstatus *int8
  36681. wx_wxid *string
  36682. wxid *string
  36683. nickname *string
  36684. avatar *string
  36685. clearedFields map[string]struct{}
  36686. done bool
  36687. oldValue func(context.Context) (*WpChatroomMember, error)
  36688. predicates []predicate.WpChatroomMember
  36689. }
  36690. var _ ent.Mutation = (*WpChatroomMemberMutation)(nil)
  36691. // wpchatroommemberOption allows management of the mutation configuration using functional options.
  36692. type wpchatroommemberOption func(*WpChatroomMemberMutation)
  36693. // newWpChatroomMemberMutation creates new mutation for the WpChatroomMember entity.
  36694. func newWpChatroomMemberMutation(c config, op Op, opts ...wpchatroommemberOption) *WpChatroomMemberMutation {
  36695. m := &WpChatroomMemberMutation{
  36696. config: c,
  36697. op: op,
  36698. typ: TypeWpChatroomMember,
  36699. clearedFields: make(map[string]struct{}),
  36700. }
  36701. for _, opt := range opts {
  36702. opt(m)
  36703. }
  36704. return m
  36705. }
  36706. // withWpChatroomMemberID sets the ID field of the mutation.
  36707. func withWpChatroomMemberID(id uint64) wpchatroommemberOption {
  36708. return func(m *WpChatroomMemberMutation) {
  36709. var (
  36710. err error
  36711. once sync.Once
  36712. value *WpChatroomMember
  36713. )
  36714. m.oldValue = func(ctx context.Context) (*WpChatroomMember, error) {
  36715. once.Do(func() {
  36716. if m.done {
  36717. err = errors.New("querying old values post mutation is not allowed")
  36718. } else {
  36719. value, err = m.Client().WpChatroomMember.Get(ctx, id)
  36720. }
  36721. })
  36722. return value, err
  36723. }
  36724. m.id = &id
  36725. }
  36726. }
  36727. // withWpChatroomMember sets the old WpChatroomMember of the mutation.
  36728. func withWpChatroomMember(node *WpChatroomMember) wpchatroommemberOption {
  36729. return func(m *WpChatroomMemberMutation) {
  36730. m.oldValue = func(context.Context) (*WpChatroomMember, error) {
  36731. return node, nil
  36732. }
  36733. m.id = &node.ID
  36734. }
  36735. }
  36736. // Client returns a new `ent.Client` from the mutation. If the mutation was
  36737. // executed in a transaction (ent.Tx), a transactional client is returned.
  36738. func (m WpChatroomMemberMutation) Client() *Client {
  36739. client := &Client{config: m.config}
  36740. client.init()
  36741. return client
  36742. }
  36743. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  36744. // it returns an error otherwise.
  36745. func (m WpChatroomMemberMutation) Tx() (*Tx, error) {
  36746. if _, ok := m.driver.(*txDriver); !ok {
  36747. return nil, errors.New("ent: mutation is not running in a transaction")
  36748. }
  36749. tx := &Tx{config: m.config}
  36750. tx.init()
  36751. return tx, nil
  36752. }
  36753. // SetID sets the value of the id field. Note that this
  36754. // operation is only accepted on creation of WpChatroomMember entities.
  36755. func (m *WpChatroomMemberMutation) SetID(id uint64) {
  36756. m.id = &id
  36757. }
  36758. // ID returns the ID value in the mutation. Note that the ID is only available
  36759. // if it was provided to the builder or after it was returned from the database.
  36760. func (m *WpChatroomMemberMutation) ID() (id uint64, exists bool) {
  36761. if m.id == nil {
  36762. return
  36763. }
  36764. return *m.id, true
  36765. }
  36766. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  36767. // That means, if the mutation is applied within a transaction with an isolation level such
  36768. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  36769. // or updated by the mutation.
  36770. func (m *WpChatroomMemberMutation) IDs(ctx context.Context) ([]uint64, error) {
  36771. switch {
  36772. case m.op.Is(OpUpdateOne | OpDeleteOne):
  36773. id, exists := m.ID()
  36774. if exists {
  36775. return []uint64{id}, nil
  36776. }
  36777. fallthrough
  36778. case m.op.Is(OpUpdate | OpDelete):
  36779. return m.Client().WpChatroomMember.Query().Where(m.predicates...).IDs(ctx)
  36780. default:
  36781. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  36782. }
  36783. }
  36784. // SetCreatedAt sets the "created_at" field.
  36785. func (m *WpChatroomMemberMutation) SetCreatedAt(t time.Time) {
  36786. m.created_at = &t
  36787. }
  36788. // CreatedAt returns the value of the "created_at" field in the mutation.
  36789. func (m *WpChatroomMemberMutation) CreatedAt() (r time.Time, exists bool) {
  36790. v := m.created_at
  36791. if v == nil {
  36792. return
  36793. }
  36794. return *v, true
  36795. }
  36796. // OldCreatedAt returns the old "created_at" field's value of the WpChatroomMember entity.
  36797. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36798. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36799. func (m *WpChatroomMemberMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  36800. if !m.op.Is(OpUpdateOne) {
  36801. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  36802. }
  36803. if m.id == nil || m.oldValue == nil {
  36804. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  36805. }
  36806. oldValue, err := m.oldValue(ctx)
  36807. if err != nil {
  36808. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  36809. }
  36810. return oldValue.CreatedAt, nil
  36811. }
  36812. // ResetCreatedAt resets all changes to the "created_at" field.
  36813. func (m *WpChatroomMemberMutation) ResetCreatedAt() {
  36814. m.created_at = nil
  36815. }
  36816. // SetUpdatedAt sets the "updated_at" field.
  36817. func (m *WpChatroomMemberMutation) SetUpdatedAt(t time.Time) {
  36818. m.updated_at = &t
  36819. }
  36820. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  36821. func (m *WpChatroomMemberMutation) UpdatedAt() (r time.Time, exists bool) {
  36822. v := m.updated_at
  36823. if v == nil {
  36824. return
  36825. }
  36826. return *v, true
  36827. }
  36828. // OldUpdatedAt returns the old "updated_at" field's value of the WpChatroomMember entity.
  36829. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36830. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36831. func (m *WpChatroomMemberMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  36832. if !m.op.Is(OpUpdateOne) {
  36833. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  36834. }
  36835. if m.id == nil || m.oldValue == nil {
  36836. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  36837. }
  36838. oldValue, err := m.oldValue(ctx)
  36839. if err != nil {
  36840. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  36841. }
  36842. return oldValue.UpdatedAt, nil
  36843. }
  36844. // ResetUpdatedAt resets all changes to the "updated_at" field.
  36845. func (m *WpChatroomMemberMutation) ResetUpdatedAt() {
  36846. m.updated_at = nil
  36847. }
  36848. // SetStatus sets the "status" field.
  36849. func (m *WpChatroomMemberMutation) SetStatus(u uint8) {
  36850. m.status = &u
  36851. m.addstatus = nil
  36852. }
  36853. // Status returns the value of the "status" field in the mutation.
  36854. func (m *WpChatroomMemberMutation) Status() (r uint8, exists bool) {
  36855. v := m.status
  36856. if v == nil {
  36857. return
  36858. }
  36859. return *v, true
  36860. }
  36861. // OldStatus returns the old "status" field's value of the WpChatroomMember entity.
  36862. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36863. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36864. func (m *WpChatroomMemberMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  36865. if !m.op.Is(OpUpdateOne) {
  36866. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  36867. }
  36868. if m.id == nil || m.oldValue == nil {
  36869. return v, errors.New("OldStatus requires an ID field in the mutation")
  36870. }
  36871. oldValue, err := m.oldValue(ctx)
  36872. if err != nil {
  36873. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  36874. }
  36875. return oldValue.Status, nil
  36876. }
  36877. // AddStatus adds u to the "status" field.
  36878. func (m *WpChatroomMemberMutation) AddStatus(u int8) {
  36879. if m.addstatus != nil {
  36880. *m.addstatus += u
  36881. } else {
  36882. m.addstatus = &u
  36883. }
  36884. }
  36885. // AddedStatus returns the value that was added to the "status" field in this mutation.
  36886. func (m *WpChatroomMemberMutation) AddedStatus() (r int8, exists bool) {
  36887. v := m.addstatus
  36888. if v == nil {
  36889. return
  36890. }
  36891. return *v, true
  36892. }
  36893. // ClearStatus clears the value of the "status" field.
  36894. func (m *WpChatroomMemberMutation) ClearStatus() {
  36895. m.status = nil
  36896. m.addstatus = nil
  36897. m.clearedFields[wpchatroommember.FieldStatus] = struct{}{}
  36898. }
  36899. // StatusCleared returns if the "status" field was cleared in this mutation.
  36900. func (m *WpChatroomMemberMutation) StatusCleared() bool {
  36901. _, ok := m.clearedFields[wpchatroommember.FieldStatus]
  36902. return ok
  36903. }
  36904. // ResetStatus resets all changes to the "status" field.
  36905. func (m *WpChatroomMemberMutation) ResetStatus() {
  36906. m.status = nil
  36907. m.addstatus = nil
  36908. delete(m.clearedFields, wpchatroommember.FieldStatus)
  36909. }
  36910. // SetWxWxid sets the "wx_wxid" field.
  36911. func (m *WpChatroomMemberMutation) SetWxWxid(s string) {
  36912. m.wx_wxid = &s
  36913. }
  36914. // WxWxid returns the value of the "wx_wxid" field in the mutation.
  36915. func (m *WpChatroomMemberMutation) WxWxid() (r string, exists bool) {
  36916. v := m.wx_wxid
  36917. if v == nil {
  36918. return
  36919. }
  36920. return *v, true
  36921. }
  36922. // OldWxWxid returns the old "wx_wxid" field's value of the WpChatroomMember entity.
  36923. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36924. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36925. func (m *WpChatroomMemberMutation) OldWxWxid(ctx context.Context) (v string, err error) {
  36926. if !m.op.Is(OpUpdateOne) {
  36927. return v, errors.New("OldWxWxid is only allowed on UpdateOne operations")
  36928. }
  36929. if m.id == nil || m.oldValue == nil {
  36930. return v, errors.New("OldWxWxid requires an ID field in the mutation")
  36931. }
  36932. oldValue, err := m.oldValue(ctx)
  36933. if err != nil {
  36934. return v, fmt.Errorf("querying old value for OldWxWxid: %w", err)
  36935. }
  36936. return oldValue.WxWxid, nil
  36937. }
  36938. // ResetWxWxid resets all changes to the "wx_wxid" field.
  36939. func (m *WpChatroomMemberMutation) ResetWxWxid() {
  36940. m.wx_wxid = nil
  36941. }
  36942. // SetWxid sets the "wxid" field.
  36943. func (m *WpChatroomMemberMutation) SetWxid(s string) {
  36944. m.wxid = &s
  36945. }
  36946. // Wxid returns the value of the "wxid" field in the mutation.
  36947. func (m *WpChatroomMemberMutation) Wxid() (r string, exists bool) {
  36948. v := m.wxid
  36949. if v == nil {
  36950. return
  36951. }
  36952. return *v, true
  36953. }
  36954. // OldWxid returns the old "wxid" field's value of the WpChatroomMember entity.
  36955. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36956. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36957. func (m *WpChatroomMemberMutation) OldWxid(ctx context.Context) (v string, err error) {
  36958. if !m.op.Is(OpUpdateOne) {
  36959. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  36960. }
  36961. if m.id == nil || m.oldValue == nil {
  36962. return v, errors.New("OldWxid requires an ID field in the mutation")
  36963. }
  36964. oldValue, err := m.oldValue(ctx)
  36965. if err != nil {
  36966. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  36967. }
  36968. return oldValue.Wxid, nil
  36969. }
  36970. // ResetWxid resets all changes to the "wxid" field.
  36971. func (m *WpChatroomMemberMutation) ResetWxid() {
  36972. m.wxid = nil
  36973. }
  36974. // SetNickname sets the "nickname" field.
  36975. func (m *WpChatroomMemberMutation) SetNickname(s string) {
  36976. m.nickname = &s
  36977. }
  36978. // Nickname returns the value of the "nickname" field in the mutation.
  36979. func (m *WpChatroomMemberMutation) Nickname() (r string, exists bool) {
  36980. v := m.nickname
  36981. if v == nil {
  36982. return
  36983. }
  36984. return *v, true
  36985. }
  36986. // OldNickname returns the old "nickname" field's value of the WpChatroomMember entity.
  36987. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  36988. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  36989. func (m *WpChatroomMemberMutation) OldNickname(ctx context.Context) (v string, err error) {
  36990. if !m.op.Is(OpUpdateOne) {
  36991. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  36992. }
  36993. if m.id == nil || m.oldValue == nil {
  36994. return v, errors.New("OldNickname requires an ID field in the mutation")
  36995. }
  36996. oldValue, err := m.oldValue(ctx)
  36997. if err != nil {
  36998. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  36999. }
  37000. return oldValue.Nickname, nil
  37001. }
  37002. // ResetNickname resets all changes to the "nickname" field.
  37003. func (m *WpChatroomMemberMutation) ResetNickname() {
  37004. m.nickname = nil
  37005. }
  37006. // SetAvatar sets the "avatar" field.
  37007. func (m *WpChatroomMemberMutation) SetAvatar(s string) {
  37008. m.avatar = &s
  37009. }
  37010. // Avatar returns the value of the "avatar" field in the mutation.
  37011. func (m *WpChatroomMemberMutation) Avatar() (r string, exists bool) {
  37012. v := m.avatar
  37013. if v == nil {
  37014. return
  37015. }
  37016. return *v, true
  37017. }
  37018. // OldAvatar returns the old "avatar" field's value of the WpChatroomMember entity.
  37019. // If the WpChatroomMember object wasn't provided to the builder, the object is fetched from the database.
  37020. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37021. func (m *WpChatroomMemberMutation) OldAvatar(ctx context.Context) (v string, err error) {
  37022. if !m.op.Is(OpUpdateOne) {
  37023. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  37024. }
  37025. if m.id == nil || m.oldValue == nil {
  37026. return v, errors.New("OldAvatar requires an ID field in the mutation")
  37027. }
  37028. oldValue, err := m.oldValue(ctx)
  37029. if err != nil {
  37030. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  37031. }
  37032. return oldValue.Avatar, nil
  37033. }
  37034. // ResetAvatar resets all changes to the "avatar" field.
  37035. func (m *WpChatroomMemberMutation) ResetAvatar() {
  37036. m.avatar = nil
  37037. }
  37038. // Where appends a list predicates to the WpChatroomMemberMutation builder.
  37039. func (m *WpChatroomMemberMutation) Where(ps ...predicate.WpChatroomMember) {
  37040. m.predicates = append(m.predicates, ps...)
  37041. }
  37042. // WhereP appends storage-level predicates to the WpChatroomMemberMutation builder. Using this method,
  37043. // users can use type-assertion to append predicates that do not depend on any generated package.
  37044. func (m *WpChatroomMemberMutation) WhereP(ps ...func(*sql.Selector)) {
  37045. p := make([]predicate.WpChatroomMember, len(ps))
  37046. for i := range ps {
  37047. p[i] = ps[i]
  37048. }
  37049. m.Where(p...)
  37050. }
  37051. // Op returns the operation name.
  37052. func (m *WpChatroomMemberMutation) Op() Op {
  37053. return m.op
  37054. }
  37055. // SetOp allows setting the mutation operation.
  37056. func (m *WpChatroomMemberMutation) SetOp(op Op) {
  37057. m.op = op
  37058. }
  37059. // Type returns the node type of this mutation (WpChatroomMember).
  37060. func (m *WpChatroomMemberMutation) Type() string {
  37061. return m.typ
  37062. }
  37063. // Fields returns all fields that were changed during this mutation. Note that in
  37064. // order to get all numeric fields that were incremented/decremented, call
  37065. // AddedFields().
  37066. func (m *WpChatroomMemberMutation) Fields() []string {
  37067. fields := make([]string, 0, 7)
  37068. if m.created_at != nil {
  37069. fields = append(fields, wpchatroommember.FieldCreatedAt)
  37070. }
  37071. if m.updated_at != nil {
  37072. fields = append(fields, wpchatroommember.FieldUpdatedAt)
  37073. }
  37074. if m.status != nil {
  37075. fields = append(fields, wpchatroommember.FieldStatus)
  37076. }
  37077. if m.wx_wxid != nil {
  37078. fields = append(fields, wpchatroommember.FieldWxWxid)
  37079. }
  37080. if m.wxid != nil {
  37081. fields = append(fields, wpchatroommember.FieldWxid)
  37082. }
  37083. if m.nickname != nil {
  37084. fields = append(fields, wpchatroommember.FieldNickname)
  37085. }
  37086. if m.avatar != nil {
  37087. fields = append(fields, wpchatroommember.FieldAvatar)
  37088. }
  37089. return fields
  37090. }
  37091. // Field returns the value of a field with the given name. The second boolean
  37092. // return value indicates that this field was not set, or was not defined in the
  37093. // schema.
  37094. func (m *WpChatroomMemberMutation) Field(name string) (ent.Value, bool) {
  37095. switch name {
  37096. case wpchatroommember.FieldCreatedAt:
  37097. return m.CreatedAt()
  37098. case wpchatroommember.FieldUpdatedAt:
  37099. return m.UpdatedAt()
  37100. case wpchatroommember.FieldStatus:
  37101. return m.Status()
  37102. case wpchatroommember.FieldWxWxid:
  37103. return m.WxWxid()
  37104. case wpchatroommember.FieldWxid:
  37105. return m.Wxid()
  37106. case wpchatroommember.FieldNickname:
  37107. return m.Nickname()
  37108. case wpchatroommember.FieldAvatar:
  37109. return m.Avatar()
  37110. }
  37111. return nil, false
  37112. }
  37113. // OldField returns the old value of the field from the database. An error is
  37114. // returned if the mutation operation is not UpdateOne, or the query to the
  37115. // database failed.
  37116. func (m *WpChatroomMemberMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  37117. switch name {
  37118. case wpchatroommember.FieldCreatedAt:
  37119. return m.OldCreatedAt(ctx)
  37120. case wpchatroommember.FieldUpdatedAt:
  37121. return m.OldUpdatedAt(ctx)
  37122. case wpchatroommember.FieldStatus:
  37123. return m.OldStatus(ctx)
  37124. case wpchatroommember.FieldWxWxid:
  37125. return m.OldWxWxid(ctx)
  37126. case wpchatroommember.FieldWxid:
  37127. return m.OldWxid(ctx)
  37128. case wpchatroommember.FieldNickname:
  37129. return m.OldNickname(ctx)
  37130. case wpchatroommember.FieldAvatar:
  37131. return m.OldAvatar(ctx)
  37132. }
  37133. return nil, fmt.Errorf("unknown WpChatroomMember field %s", name)
  37134. }
  37135. // SetField sets the value of a field with the given name. It returns an error if
  37136. // the field is not defined in the schema, or if the type mismatched the field
  37137. // type.
  37138. func (m *WpChatroomMemberMutation) SetField(name string, value ent.Value) error {
  37139. switch name {
  37140. case wpchatroommember.FieldCreatedAt:
  37141. v, ok := value.(time.Time)
  37142. if !ok {
  37143. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37144. }
  37145. m.SetCreatedAt(v)
  37146. return nil
  37147. case wpchatroommember.FieldUpdatedAt:
  37148. v, ok := value.(time.Time)
  37149. if !ok {
  37150. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37151. }
  37152. m.SetUpdatedAt(v)
  37153. return nil
  37154. case wpchatroommember.FieldStatus:
  37155. v, ok := value.(uint8)
  37156. if !ok {
  37157. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37158. }
  37159. m.SetStatus(v)
  37160. return nil
  37161. case wpchatroommember.FieldWxWxid:
  37162. v, ok := value.(string)
  37163. if !ok {
  37164. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37165. }
  37166. m.SetWxWxid(v)
  37167. return nil
  37168. case wpchatroommember.FieldWxid:
  37169. v, ok := value.(string)
  37170. if !ok {
  37171. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37172. }
  37173. m.SetWxid(v)
  37174. return nil
  37175. case wpchatroommember.FieldNickname:
  37176. v, ok := value.(string)
  37177. if !ok {
  37178. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37179. }
  37180. m.SetNickname(v)
  37181. return nil
  37182. case wpchatroommember.FieldAvatar:
  37183. v, ok := value.(string)
  37184. if !ok {
  37185. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37186. }
  37187. m.SetAvatar(v)
  37188. return nil
  37189. }
  37190. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37191. }
  37192. // AddedFields returns all numeric fields that were incremented/decremented during
  37193. // this mutation.
  37194. func (m *WpChatroomMemberMutation) AddedFields() []string {
  37195. var fields []string
  37196. if m.addstatus != nil {
  37197. fields = append(fields, wpchatroommember.FieldStatus)
  37198. }
  37199. return fields
  37200. }
  37201. // AddedField returns the numeric value that was incremented/decremented on a field
  37202. // with the given name. The second boolean return value indicates that this field
  37203. // was not set, or was not defined in the schema.
  37204. func (m *WpChatroomMemberMutation) AddedField(name string) (ent.Value, bool) {
  37205. switch name {
  37206. case wpchatroommember.FieldStatus:
  37207. return m.AddedStatus()
  37208. }
  37209. return nil, false
  37210. }
  37211. // AddField adds the value to the field with the given name. It returns an error if
  37212. // the field is not defined in the schema, or if the type mismatched the field
  37213. // type.
  37214. func (m *WpChatroomMemberMutation) AddField(name string, value ent.Value) error {
  37215. switch name {
  37216. case wpchatroommember.FieldStatus:
  37217. v, ok := value.(int8)
  37218. if !ok {
  37219. return fmt.Errorf("unexpected type %T for field %s", value, name)
  37220. }
  37221. m.AddStatus(v)
  37222. return nil
  37223. }
  37224. return fmt.Errorf("unknown WpChatroomMember numeric field %s", name)
  37225. }
  37226. // ClearedFields returns all nullable fields that were cleared during this
  37227. // mutation.
  37228. func (m *WpChatroomMemberMutation) ClearedFields() []string {
  37229. var fields []string
  37230. if m.FieldCleared(wpchatroommember.FieldStatus) {
  37231. fields = append(fields, wpchatroommember.FieldStatus)
  37232. }
  37233. return fields
  37234. }
  37235. // FieldCleared returns a boolean indicating if a field with the given name was
  37236. // cleared in this mutation.
  37237. func (m *WpChatroomMemberMutation) FieldCleared(name string) bool {
  37238. _, ok := m.clearedFields[name]
  37239. return ok
  37240. }
  37241. // ClearField clears the value of the field with the given name. It returns an
  37242. // error if the field is not defined in the schema.
  37243. func (m *WpChatroomMemberMutation) ClearField(name string) error {
  37244. switch name {
  37245. case wpchatroommember.FieldStatus:
  37246. m.ClearStatus()
  37247. return nil
  37248. }
  37249. return fmt.Errorf("unknown WpChatroomMember nullable field %s", name)
  37250. }
  37251. // ResetField resets all changes in the mutation for the field with the given name.
  37252. // It returns an error if the field is not defined in the schema.
  37253. func (m *WpChatroomMemberMutation) ResetField(name string) error {
  37254. switch name {
  37255. case wpchatroommember.FieldCreatedAt:
  37256. m.ResetCreatedAt()
  37257. return nil
  37258. case wpchatroommember.FieldUpdatedAt:
  37259. m.ResetUpdatedAt()
  37260. return nil
  37261. case wpchatroommember.FieldStatus:
  37262. m.ResetStatus()
  37263. return nil
  37264. case wpchatroommember.FieldWxWxid:
  37265. m.ResetWxWxid()
  37266. return nil
  37267. case wpchatroommember.FieldWxid:
  37268. m.ResetWxid()
  37269. return nil
  37270. case wpchatroommember.FieldNickname:
  37271. m.ResetNickname()
  37272. return nil
  37273. case wpchatroommember.FieldAvatar:
  37274. m.ResetAvatar()
  37275. return nil
  37276. }
  37277. return fmt.Errorf("unknown WpChatroomMember field %s", name)
  37278. }
  37279. // AddedEdges returns all edge names that were set/added in this mutation.
  37280. func (m *WpChatroomMemberMutation) AddedEdges() []string {
  37281. edges := make([]string, 0, 0)
  37282. return edges
  37283. }
  37284. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  37285. // name in this mutation.
  37286. func (m *WpChatroomMemberMutation) AddedIDs(name string) []ent.Value {
  37287. return nil
  37288. }
  37289. // RemovedEdges returns all edge names that were removed in this mutation.
  37290. func (m *WpChatroomMemberMutation) RemovedEdges() []string {
  37291. edges := make([]string, 0, 0)
  37292. return edges
  37293. }
  37294. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  37295. // the given name in this mutation.
  37296. func (m *WpChatroomMemberMutation) RemovedIDs(name string) []ent.Value {
  37297. return nil
  37298. }
  37299. // ClearedEdges returns all edge names that were cleared in this mutation.
  37300. func (m *WpChatroomMemberMutation) ClearedEdges() []string {
  37301. edges := make([]string, 0, 0)
  37302. return edges
  37303. }
  37304. // EdgeCleared returns a boolean which indicates if the edge with the given name
  37305. // was cleared in this mutation.
  37306. func (m *WpChatroomMemberMutation) EdgeCleared(name string) bool {
  37307. return false
  37308. }
  37309. // ClearEdge clears the value of the edge with the given name. It returns an error
  37310. // if that edge is not defined in the schema.
  37311. func (m *WpChatroomMemberMutation) ClearEdge(name string) error {
  37312. return fmt.Errorf("unknown WpChatroomMember unique edge %s", name)
  37313. }
  37314. // ResetEdge resets all changes to the edge with the given name in this mutation.
  37315. // It returns an error if the edge is not defined in the schema.
  37316. func (m *WpChatroomMemberMutation) ResetEdge(name string) error {
  37317. return fmt.Errorf("unknown WpChatroomMember edge %s", name)
  37318. }
  37319. // WxMutation represents an operation that mutates the Wx nodes in the graph.
  37320. type WxMutation struct {
  37321. config
  37322. op Op
  37323. typ string
  37324. id *uint64
  37325. created_at *time.Time
  37326. updated_at *time.Time
  37327. status *uint8
  37328. addstatus *int8
  37329. deleted_at *time.Time
  37330. port *string
  37331. process_id *string
  37332. callback *string
  37333. wxid *string
  37334. account *string
  37335. nickname *string
  37336. tel *string
  37337. head_big *string
  37338. organization_id *uint64
  37339. addorganization_id *int64
  37340. api_base *string
  37341. api_key *string
  37342. allow_list *[]string
  37343. appendallow_list []string
  37344. group_allow_list *[]string
  37345. appendgroup_allow_list []string
  37346. block_list *[]string
  37347. appendblock_list []string
  37348. group_block_list *[]string
  37349. appendgroup_block_list []string
  37350. clearedFields map[string]struct{}
  37351. server *uint64
  37352. clearedserver bool
  37353. agent *uint64
  37354. clearedagent bool
  37355. done bool
  37356. oldValue func(context.Context) (*Wx, error)
  37357. predicates []predicate.Wx
  37358. }
  37359. var _ ent.Mutation = (*WxMutation)(nil)
  37360. // wxOption allows management of the mutation configuration using functional options.
  37361. type wxOption func(*WxMutation)
  37362. // newWxMutation creates new mutation for the Wx entity.
  37363. func newWxMutation(c config, op Op, opts ...wxOption) *WxMutation {
  37364. m := &WxMutation{
  37365. config: c,
  37366. op: op,
  37367. typ: TypeWx,
  37368. clearedFields: make(map[string]struct{}),
  37369. }
  37370. for _, opt := range opts {
  37371. opt(m)
  37372. }
  37373. return m
  37374. }
  37375. // withWxID sets the ID field of the mutation.
  37376. func withWxID(id uint64) wxOption {
  37377. return func(m *WxMutation) {
  37378. var (
  37379. err error
  37380. once sync.Once
  37381. value *Wx
  37382. )
  37383. m.oldValue = func(ctx context.Context) (*Wx, error) {
  37384. once.Do(func() {
  37385. if m.done {
  37386. err = errors.New("querying old values post mutation is not allowed")
  37387. } else {
  37388. value, err = m.Client().Wx.Get(ctx, id)
  37389. }
  37390. })
  37391. return value, err
  37392. }
  37393. m.id = &id
  37394. }
  37395. }
  37396. // withWx sets the old Wx of the mutation.
  37397. func withWx(node *Wx) wxOption {
  37398. return func(m *WxMutation) {
  37399. m.oldValue = func(context.Context) (*Wx, error) {
  37400. return node, nil
  37401. }
  37402. m.id = &node.ID
  37403. }
  37404. }
  37405. // Client returns a new `ent.Client` from the mutation. If the mutation was
  37406. // executed in a transaction (ent.Tx), a transactional client is returned.
  37407. func (m WxMutation) Client() *Client {
  37408. client := &Client{config: m.config}
  37409. client.init()
  37410. return client
  37411. }
  37412. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  37413. // it returns an error otherwise.
  37414. func (m WxMutation) Tx() (*Tx, error) {
  37415. if _, ok := m.driver.(*txDriver); !ok {
  37416. return nil, errors.New("ent: mutation is not running in a transaction")
  37417. }
  37418. tx := &Tx{config: m.config}
  37419. tx.init()
  37420. return tx, nil
  37421. }
  37422. // SetID sets the value of the id field. Note that this
  37423. // operation is only accepted on creation of Wx entities.
  37424. func (m *WxMutation) SetID(id uint64) {
  37425. m.id = &id
  37426. }
  37427. // ID returns the ID value in the mutation. Note that the ID is only available
  37428. // if it was provided to the builder or after it was returned from the database.
  37429. func (m *WxMutation) ID() (id uint64, exists bool) {
  37430. if m.id == nil {
  37431. return
  37432. }
  37433. return *m.id, true
  37434. }
  37435. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  37436. // That means, if the mutation is applied within a transaction with an isolation level such
  37437. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  37438. // or updated by the mutation.
  37439. func (m *WxMutation) IDs(ctx context.Context) ([]uint64, error) {
  37440. switch {
  37441. case m.op.Is(OpUpdateOne | OpDeleteOne):
  37442. id, exists := m.ID()
  37443. if exists {
  37444. return []uint64{id}, nil
  37445. }
  37446. fallthrough
  37447. case m.op.Is(OpUpdate | OpDelete):
  37448. return m.Client().Wx.Query().Where(m.predicates...).IDs(ctx)
  37449. default:
  37450. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  37451. }
  37452. }
  37453. // SetCreatedAt sets the "created_at" field.
  37454. func (m *WxMutation) SetCreatedAt(t time.Time) {
  37455. m.created_at = &t
  37456. }
  37457. // CreatedAt returns the value of the "created_at" field in the mutation.
  37458. func (m *WxMutation) CreatedAt() (r time.Time, exists bool) {
  37459. v := m.created_at
  37460. if v == nil {
  37461. return
  37462. }
  37463. return *v, true
  37464. }
  37465. // OldCreatedAt returns the old "created_at" field's value of the Wx entity.
  37466. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37467. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37468. func (m *WxMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  37469. if !m.op.Is(OpUpdateOne) {
  37470. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  37471. }
  37472. if m.id == nil || m.oldValue == nil {
  37473. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  37474. }
  37475. oldValue, err := m.oldValue(ctx)
  37476. if err != nil {
  37477. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  37478. }
  37479. return oldValue.CreatedAt, nil
  37480. }
  37481. // ResetCreatedAt resets all changes to the "created_at" field.
  37482. func (m *WxMutation) ResetCreatedAt() {
  37483. m.created_at = nil
  37484. }
  37485. // SetUpdatedAt sets the "updated_at" field.
  37486. func (m *WxMutation) SetUpdatedAt(t time.Time) {
  37487. m.updated_at = &t
  37488. }
  37489. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  37490. func (m *WxMutation) UpdatedAt() (r time.Time, exists bool) {
  37491. v := m.updated_at
  37492. if v == nil {
  37493. return
  37494. }
  37495. return *v, true
  37496. }
  37497. // OldUpdatedAt returns the old "updated_at" field's value of the Wx entity.
  37498. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37499. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37500. func (m *WxMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  37501. if !m.op.Is(OpUpdateOne) {
  37502. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  37503. }
  37504. if m.id == nil || m.oldValue == nil {
  37505. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  37506. }
  37507. oldValue, err := m.oldValue(ctx)
  37508. if err != nil {
  37509. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  37510. }
  37511. return oldValue.UpdatedAt, nil
  37512. }
  37513. // ResetUpdatedAt resets all changes to the "updated_at" field.
  37514. func (m *WxMutation) ResetUpdatedAt() {
  37515. m.updated_at = nil
  37516. }
  37517. // SetStatus sets the "status" field.
  37518. func (m *WxMutation) SetStatus(u uint8) {
  37519. m.status = &u
  37520. m.addstatus = nil
  37521. }
  37522. // Status returns the value of the "status" field in the mutation.
  37523. func (m *WxMutation) Status() (r uint8, exists bool) {
  37524. v := m.status
  37525. if v == nil {
  37526. return
  37527. }
  37528. return *v, true
  37529. }
  37530. // OldStatus returns the old "status" field's value of the Wx entity.
  37531. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37532. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37533. func (m *WxMutation) OldStatus(ctx context.Context) (v uint8, err error) {
  37534. if !m.op.Is(OpUpdateOne) {
  37535. return v, errors.New("OldStatus is only allowed on UpdateOne operations")
  37536. }
  37537. if m.id == nil || m.oldValue == nil {
  37538. return v, errors.New("OldStatus requires an ID field in the mutation")
  37539. }
  37540. oldValue, err := m.oldValue(ctx)
  37541. if err != nil {
  37542. return v, fmt.Errorf("querying old value for OldStatus: %w", err)
  37543. }
  37544. return oldValue.Status, nil
  37545. }
  37546. // AddStatus adds u to the "status" field.
  37547. func (m *WxMutation) AddStatus(u int8) {
  37548. if m.addstatus != nil {
  37549. *m.addstatus += u
  37550. } else {
  37551. m.addstatus = &u
  37552. }
  37553. }
  37554. // AddedStatus returns the value that was added to the "status" field in this mutation.
  37555. func (m *WxMutation) AddedStatus() (r int8, exists bool) {
  37556. v := m.addstatus
  37557. if v == nil {
  37558. return
  37559. }
  37560. return *v, true
  37561. }
  37562. // ClearStatus clears the value of the "status" field.
  37563. func (m *WxMutation) ClearStatus() {
  37564. m.status = nil
  37565. m.addstatus = nil
  37566. m.clearedFields[wx.FieldStatus] = struct{}{}
  37567. }
  37568. // StatusCleared returns if the "status" field was cleared in this mutation.
  37569. func (m *WxMutation) StatusCleared() bool {
  37570. _, ok := m.clearedFields[wx.FieldStatus]
  37571. return ok
  37572. }
  37573. // ResetStatus resets all changes to the "status" field.
  37574. func (m *WxMutation) ResetStatus() {
  37575. m.status = nil
  37576. m.addstatus = nil
  37577. delete(m.clearedFields, wx.FieldStatus)
  37578. }
  37579. // SetDeletedAt sets the "deleted_at" field.
  37580. func (m *WxMutation) SetDeletedAt(t time.Time) {
  37581. m.deleted_at = &t
  37582. }
  37583. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  37584. func (m *WxMutation) DeletedAt() (r time.Time, exists bool) {
  37585. v := m.deleted_at
  37586. if v == nil {
  37587. return
  37588. }
  37589. return *v, true
  37590. }
  37591. // OldDeletedAt returns the old "deleted_at" field's value of the Wx entity.
  37592. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37593. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37594. func (m *WxMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  37595. if !m.op.Is(OpUpdateOne) {
  37596. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  37597. }
  37598. if m.id == nil || m.oldValue == nil {
  37599. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  37600. }
  37601. oldValue, err := m.oldValue(ctx)
  37602. if err != nil {
  37603. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  37604. }
  37605. return oldValue.DeletedAt, nil
  37606. }
  37607. // ClearDeletedAt clears the value of the "deleted_at" field.
  37608. func (m *WxMutation) ClearDeletedAt() {
  37609. m.deleted_at = nil
  37610. m.clearedFields[wx.FieldDeletedAt] = struct{}{}
  37611. }
  37612. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  37613. func (m *WxMutation) DeletedAtCleared() bool {
  37614. _, ok := m.clearedFields[wx.FieldDeletedAt]
  37615. return ok
  37616. }
  37617. // ResetDeletedAt resets all changes to the "deleted_at" field.
  37618. func (m *WxMutation) ResetDeletedAt() {
  37619. m.deleted_at = nil
  37620. delete(m.clearedFields, wx.FieldDeletedAt)
  37621. }
  37622. // SetServerID sets the "server_id" field.
  37623. func (m *WxMutation) SetServerID(u uint64) {
  37624. m.server = &u
  37625. }
  37626. // ServerID returns the value of the "server_id" field in the mutation.
  37627. func (m *WxMutation) ServerID() (r uint64, exists bool) {
  37628. v := m.server
  37629. if v == nil {
  37630. return
  37631. }
  37632. return *v, true
  37633. }
  37634. // OldServerID returns the old "server_id" field's value of the Wx entity.
  37635. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37636. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37637. func (m *WxMutation) OldServerID(ctx context.Context) (v uint64, err error) {
  37638. if !m.op.Is(OpUpdateOne) {
  37639. return v, errors.New("OldServerID is only allowed on UpdateOne operations")
  37640. }
  37641. if m.id == nil || m.oldValue == nil {
  37642. return v, errors.New("OldServerID requires an ID field in the mutation")
  37643. }
  37644. oldValue, err := m.oldValue(ctx)
  37645. if err != nil {
  37646. return v, fmt.Errorf("querying old value for OldServerID: %w", err)
  37647. }
  37648. return oldValue.ServerID, nil
  37649. }
  37650. // ClearServerID clears the value of the "server_id" field.
  37651. func (m *WxMutation) ClearServerID() {
  37652. m.server = nil
  37653. m.clearedFields[wx.FieldServerID] = struct{}{}
  37654. }
  37655. // ServerIDCleared returns if the "server_id" field was cleared in this mutation.
  37656. func (m *WxMutation) ServerIDCleared() bool {
  37657. _, ok := m.clearedFields[wx.FieldServerID]
  37658. return ok
  37659. }
  37660. // ResetServerID resets all changes to the "server_id" field.
  37661. func (m *WxMutation) ResetServerID() {
  37662. m.server = nil
  37663. delete(m.clearedFields, wx.FieldServerID)
  37664. }
  37665. // SetPort sets the "port" field.
  37666. func (m *WxMutation) SetPort(s string) {
  37667. m.port = &s
  37668. }
  37669. // Port returns the value of the "port" field in the mutation.
  37670. func (m *WxMutation) Port() (r string, exists bool) {
  37671. v := m.port
  37672. if v == nil {
  37673. return
  37674. }
  37675. return *v, true
  37676. }
  37677. // OldPort returns the old "port" field's value of the Wx entity.
  37678. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37679. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37680. func (m *WxMutation) OldPort(ctx context.Context) (v string, err error) {
  37681. if !m.op.Is(OpUpdateOne) {
  37682. return v, errors.New("OldPort is only allowed on UpdateOne operations")
  37683. }
  37684. if m.id == nil || m.oldValue == nil {
  37685. return v, errors.New("OldPort requires an ID field in the mutation")
  37686. }
  37687. oldValue, err := m.oldValue(ctx)
  37688. if err != nil {
  37689. return v, fmt.Errorf("querying old value for OldPort: %w", err)
  37690. }
  37691. return oldValue.Port, nil
  37692. }
  37693. // ResetPort resets all changes to the "port" field.
  37694. func (m *WxMutation) ResetPort() {
  37695. m.port = nil
  37696. }
  37697. // SetProcessID sets the "process_id" field.
  37698. func (m *WxMutation) SetProcessID(s string) {
  37699. m.process_id = &s
  37700. }
  37701. // ProcessID returns the value of the "process_id" field in the mutation.
  37702. func (m *WxMutation) ProcessID() (r string, exists bool) {
  37703. v := m.process_id
  37704. if v == nil {
  37705. return
  37706. }
  37707. return *v, true
  37708. }
  37709. // OldProcessID returns the old "process_id" field's value of the Wx entity.
  37710. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37711. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37712. func (m *WxMutation) OldProcessID(ctx context.Context) (v string, err error) {
  37713. if !m.op.Is(OpUpdateOne) {
  37714. return v, errors.New("OldProcessID is only allowed on UpdateOne operations")
  37715. }
  37716. if m.id == nil || m.oldValue == nil {
  37717. return v, errors.New("OldProcessID requires an ID field in the mutation")
  37718. }
  37719. oldValue, err := m.oldValue(ctx)
  37720. if err != nil {
  37721. return v, fmt.Errorf("querying old value for OldProcessID: %w", err)
  37722. }
  37723. return oldValue.ProcessID, nil
  37724. }
  37725. // ResetProcessID resets all changes to the "process_id" field.
  37726. func (m *WxMutation) ResetProcessID() {
  37727. m.process_id = nil
  37728. }
  37729. // SetCallback sets the "callback" field.
  37730. func (m *WxMutation) SetCallback(s string) {
  37731. m.callback = &s
  37732. }
  37733. // Callback returns the value of the "callback" field in the mutation.
  37734. func (m *WxMutation) Callback() (r string, exists bool) {
  37735. v := m.callback
  37736. if v == nil {
  37737. return
  37738. }
  37739. return *v, true
  37740. }
  37741. // OldCallback returns the old "callback" field's value of the Wx entity.
  37742. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37743. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37744. func (m *WxMutation) OldCallback(ctx context.Context) (v string, err error) {
  37745. if !m.op.Is(OpUpdateOne) {
  37746. return v, errors.New("OldCallback is only allowed on UpdateOne operations")
  37747. }
  37748. if m.id == nil || m.oldValue == nil {
  37749. return v, errors.New("OldCallback requires an ID field in the mutation")
  37750. }
  37751. oldValue, err := m.oldValue(ctx)
  37752. if err != nil {
  37753. return v, fmt.Errorf("querying old value for OldCallback: %w", err)
  37754. }
  37755. return oldValue.Callback, nil
  37756. }
  37757. // ResetCallback resets all changes to the "callback" field.
  37758. func (m *WxMutation) ResetCallback() {
  37759. m.callback = nil
  37760. }
  37761. // SetWxid sets the "wxid" field.
  37762. func (m *WxMutation) SetWxid(s string) {
  37763. m.wxid = &s
  37764. }
  37765. // Wxid returns the value of the "wxid" field in the mutation.
  37766. func (m *WxMutation) Wxid() (r string, exists bool) {
  37767. v := m.wxid
  37768. if v == nil {
  37769. return
  37770. }
  37771. return *v, true
  37772. }
  37773. // OldWxid returns the old "wxid" field's value of the Wx entity.
  37774. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37775. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37776. func (m *WxMutation) OldWxid(ctx context.Context) (v string, err error) {
  37777. if !m.op.Is(OpUpdateOne) {
  37778. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  37779. }
  37780. if m.id == nil || m.oldValue == nil {
  37781. return v, errors.New("OldWxid requires an ID field in the mutation")
  37782. }
  37783. oldValue, err := m.oldValue(ctx)
  37784. if err != nil {
  37785. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  37786. }
  37787. return oldValue.Wxid, nil
  37788. }
  37789. // ResetWxid resets all changes to the "wxid" field.
  37790. func (m *WxMutation) ResetWxid() {
  37791. m.wxid = nil
  37792. }
  37793. // SetAccount sets the "account" field.
  37794. func (m *WxMutation) SetAccount(s string) {
  37795. m.account = &s
  37796. }
  37797. // Account returns the value of the "account" field in the mutation.
  37798. func (m *WxMutation) Account() (r string, exists bool) {
  37799. v := m.account
  37800. if v == nil {
  37801. return
  37802. }
  37803. return *v, true
  37804. }
  37805. // OldAccount returns the old "account" field's value of the Wx entity.
  37806. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37807. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37808. func (m *WxMutation) OldAccount(ctx context.Context) (v string, err error) {
  37809. if !m.op.Is(OpUpdateOne) {
  37810. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  37811. }
  37812. if m.id == nil || m.oldValue == nil {
  37813. return v, errors.New("OldAccount requires an ID field in the mutation")
  37814. }
  37815. oldValue, err := m.oldValue(ctx)
  37816. if err != nil {
  37817. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  37818. }
  37819. return oldValue.Account, nil
  37820. }
  37821. // ResetAccount resets all changes to the "account" field.
  37822. func (m *WxMutation) ResetAccount() {
  37823. m.account = nil
  37824. }
  37825. // SetNickname sets the "nickname" field.
  37826. func (m *WxMutation) SetNickname(s string) {
  37827. m.nickname = &s
  37828. }
  37829. // Nickname returns the value of the "nickname" field in the mutation.
  37830. func (m *WxMutation) Nickname() (r string, exists bool) {
  37831. v := m.nickname
  37832. if v == nil {
  37833. return
  37834. }
  37835. return *v, true
  37836. }
  37837. // OldNickname returns the old "nickname" field's value of the Wx entity.
  37838. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37839. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37840. func (m *WxMutation) OldNickname(ctx context.Context) (v string, err error) {
  37841. if !m.op.Is(OpUpdateOne) {
  37842. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  37843. }
  37844. if m.id == nil || m.oldValue == nil {
  37845. return v, errors.New("OldNickname requires an ID field in the mutation")
  37846. }
  37847. oldValue, err := m.oldValue(ctx)
  37848. if err != nil {
  37849. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  37850. }
  37851. return oldValue.Nickname, nil
  37852. }
  37853. // ResetNickname resets all changes to the "nickname" field.
  37854. func (m *WxMutation) ResetNickname() {
  37855. m.nickname = nil
  37856. }
  37857. // SetTel sets the "tel" field.
  37858. func (m *WxMutation) SetTel(s string) {
  37859. m.tel = &s
  37860. }
  37861. // Tel returns the value of the "tel" field in the mutation.
  37862. func (m *WxMutation) Tel() (r string, exists bool) {
  37863. v := m.tel
  37864. if v == nil {
  37865. return
  37866. }
  37867. return *v, true
  37868. }
  37869. // OldTel returns the old "tel" field's value of the Wx entity.
  37870. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37871. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37872. func (m *WxMutation) OldTel(ctx context.Context) (v string, err error) {
  37873. if !m.op.Is(OpUpdateOne) {
  37874. return v, errors.New("OldTel is only allowed on UpdateOne operations")
  37875. }
  37876. if m.id == nil || m.oldValue == nil {
  37877. return v, errors.New("OldTel requires an ID field in the mutation")
  37878. }
  37879. oldValue, err := m.oldValue(ctx)
  37880. if err != nil {
  37881. return v, fmt.Errorf("querying old value for OldTel: %w", err)
  37882. }
  37883. return oldValue.Tel, nil
  37884. }
  37885. // ResetTel resets all changes to the "tel" field.
  37886. func (m *WxMutation) ResetTel() {
  37887. m.tel = nil
  37888. }
  37889. // SetHeadBig sets the "head_big" field.
  37890. func (m *WxMutation) SetHeadBig(s string) {
  37891. m.head_big = &s
  37892. }
  37893. // HeadBig returns the value of the "head_big" field in the mutation.
  37894. func (m *WxMutation) HeadBig() (r string, exists bool) {
  37895. v := m.head_big
  37896. if v == nil {
  37897. return
  37898. }
  37899. return *v, true
  37900. }
  37901. // OldHeadBig returns the old "head_big" field's value of the Wx entity.
  37902. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37903. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37904. func (m *WxMutation) OldHeadBig(ctx context.Context) (v string, err error) {
  37905. if !m.op.Is(OpUpdateOne) {
  37906. return v, errors.New("OldHeadBig is only allowed on UpdateOne operations")
  37907. }
  37908. if m.id == nil || m.oldValue == nil {
  37909. return v, errors.New("OldHeadBig requires an ID field in the mutation")
  37910. }
  37911. oldValue, err := m.oldValue(ctx)
  37912. if err != nil {
  37913. return v, fmt.Errorf("querying old value for OldHeadBig: %w", err)
  37914. }
  37915. return oldValue.HeadBig, nil
  37916. }
  37917. // ResetHeadBig resets all changes to the "head_big" field.
  37918. func (m *WxMutation) ResetHeadBig() {
  37919. m.head_big = nil
  37920. }
  37921. // SetOrganizationID sets the "organization_id" field.
  37922. func (m *WxMutation) SetOrganizationID(u uint64) {
  37923. m.organization_id = &u
  37924. m.addorganization_id = nil
  37925. }
  37926. // OrganizationID returns the value of the "organization_id" field in the mutation.
  37927. func (m *WxMutation) OrganizationID() (r uint64, exists bool) {
  37928. v := m.organization_id
  37929. if v == nil {
  37930. return
  37931. }
  37932. return *v, true
  37933. }
  37934. // OldOrganizationID returns the old "organization_id" 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) OldOrganizationID(ctx context.Context) (v uint64, err error) {
  37938. if !m.op.Is(OpUpdateOne) {
  37939. return v, errors.New("OldOrganizationID is only allowed on UpdateOne operations")
  37940. }
  37941. if m.id == nil || m.oldValue == nil {
  37942. return v, errors.New("OldOrganizationID 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 OldOrganizationID: %w", err)
  37947. }
  37948. return oldValue.OrganizationID, nil
  37949. }
  37950. // AddOrganizationID adds u to the "organization_id" field.
  37951. func (m *WxMutation) AddOrganizationID(u int64) {
  37952. if m.addorganization_id != nil {
  37953. *m.addorganization_id += u
  37954. } else {
  37955. m.addorganization_id = &u
  37956. }
  37957. }
  37958. // AddedOrganizationID returns the value that was added to the "organization_id" field in this mutation.
  37959. func (m *WxMutation) AddedOrganizationID() (r int64, exists bool) {
  37960. v := m.addorganization_id
  37961. if v == nil {
  37962. return
  37963. }
  37964. return *v, true
  37965. }
  37966. // ClearOrganizationID clears the value of the "organization_id" field.
  37967. func (m *WxMutation) ClearOrganizationID() {
  37968. m.organization_id = nil
  37969. m.addorganization_id = nil
  37970. m.clearedFields[wx.FieldOrganizationID] = struct{}{}
  37971. }
  37972. // OrganizationIDCleared returns if the "organization_id" field was cleared in this mutation.
  37973. func (m *WxMutation) OrganizationIDCleared() bool {
  37974. _, ok := m.clearedFields[wx.FieldOrganizationID]
  37975. return ok
  37976. }
  37977. // ResetOrganizationID resets all changes to the "organization_id" field.
  37978. func (m *WxMutation) ResetOrganizationID() {
  37979. m.organization_id = nil
  37980. m.addorganization_id = nil
  37981. delete(m.clearedFields, wx.FieldOrganizationID)
  37982. }
  37983. // SetAgentID sets the "agent_id" field.
  37984. func (m *WxMutation) SetAgentID(u uint64) {
  37985. m.agent = &u
  37986. }
  37987. // AgentID returns the value of the "agent_id" field in the mutation.
  37988. func (m *WxMutation) AgentID() (r uint64, exists bool) {
  37989. v := m.agent
  37990. if v == nil {
  37991. return
  37992. }
  37993. return *v, true
  37994. }
  37995. // OldAgentID returns the old "agent_id" field's value of the Wx entity.
  37996. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  37997. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  37998. func (m *WxMutation) OldAgentID(ctx context.Context) (v uint64, err error) {
  37999. if !m.op.Is(OpUpdateOne) {
  38000. return v, errors.New("OldAgentID is only allowed on UpdateOne operations")
  38001. }
  38002. if m.id == nil || m.oldValue == nil {
  38003. return v, errors.New("OldAgentID requires an ID field in the mutation")
  38004. }
  38005. oldValue, err := m.oldValue(ctx)
  38006. if err != nil {
  38007. return v, fmt.Errorf("querying old value for OldAgentID: %w", err)
  38008. }
  38009. return oldValue.AgentID, nil
  38010. }
  38011. // ResetAgentID resets all changes to the "agent_id" field.
  38012. func (m *WxMutation) ResetAgentID() {
  38013. m.agent = nil
  38014. }
  38015. // SetAPIBase sets the "api_base" field.
  38016. func (m *WxMutation) SetAPIBase(s string) {
  38017. m.api_base = &s
  38018. }
  38019. // APIBase returns the value of the "api_base" field in the mutation.
  38020. func (m *WxMutation) APIBase() (r string, exists bool) {
  38021. v := m.api_base
  38022. if v == nil {
  38023. return
  38024. }
  38025. return *v, true
  38026. }
  38027. // OldAPIBase returns the old "api_base" field's value of the Wx entity.
  38028. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38029. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38030. func (m *WxMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  38031. if !m.op.Is(OpUpdateOne) {
  38032. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  38033. }
  38034. if m.id == nil || m.oldValue == nil {
  38035. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  38036. }
  38037. oldValue, err := m.oldValue(ctx)
  38038. if err != nil {
  38039. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  38040. }
  38041. return oldValue.APIBase, nil
  38042. }
  38043. // ClearAPIBase clears the value of the "api_base" field.
  38044. func (m *WxMutation) ClearAPIBase() {
  38045. m.api_base = nil
  38046. m.clearedFields[wx.FieldAPIBase] = struct{}{}
  38047. }
  38048. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  38049. func (m *WxMutation) APIBaseCleared() bool {
  38050. _, ok := m.clearedFields[wx.FieldAPIBase]
  38051. return ok
  38052. }
  38053. // ResetAPIBase resets all changes to the "api_base" field.
  38054. func (m *WxMutation) ResetAPIBase() {
  38055. m.api_base = nil
  38056. delete(m.clearedFields, wx.FieldAPIBase)
  38057. }
  38058. // SetAPIKey sets the "api_key" field.
  38059. func (m *WxMutation) SetAPIKey(s string) {
  38060. m.api_key = &s
  38061. }
  38062. // APIKey returns the value of the "api_key" field in the mutation.
  38063. func (m *WxMutation) APIKey() (r string, exists bool) {
  38064. v := m.api_key
  38065. if v == nil {
  38066. return
  38067. }
  38068. return *v, true
  38069. }
  38070. // OldAPIKey returns the old "api_key" field's value of the Wx entity.
  38071. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38072. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38073. func (m *WxMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  38074. if !m.op.Is(OpUpdateOne) {
  38075. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  38076. }
  38077. if m.id == nil || m.oldValue == nil {
  38078. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  38079. }
  38080. oldValue, err := m.oldValue(ctx)
  38081. if err != nil {
  38082. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  38083. }
  38084. return oldValue.APIKey, nil
  38085. }
  38086. // ClearAPIKey clears the value of the "api_key" field.
  38087. func (m *WxMutation) ClearAPIKey() {
  38088. m.api_key = nil
  38089. m.clearedFields[wx.FieldAPIKey] = struct{}{}
  38090. }
  38091. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  38092. func (m *WxMutation) APIKeyCleared() bool {
  38093. _, ok := m.clearedFields[wx.FieldAPIKey]
  38094. return ok
  38095. }
  38096. // ResetAPIKey resets all changes to the "api_key" field.
  38097. func (m *WxMutation) ResetAPIKey() {
  38098. m.api_key = nil
  38099. delete(m.clearedFields, wx.FieldAPIKey)
  38100. }
  38101. // SetAllowList sets the "allow_list" field.
  38102. func (m *WxMutation) SetAllowList(s []string) {
  38103. m.allow_list = &s
  38104. m.appendallow_list = nil
  38105. }
  38106. // AllowList returns the value of the "allow_list" field in the mutation.
  38107. func (m *WxMutation) AllowList() (r []string, exists bool) {
  38108. v := m.allow_list
  38109. if v == nil {
  38110. return
  38111. }
  38112. return *v, true
  38113. }
  38114. // OldAllowList returns the old "allow_list" field's value of the Wx entity.
  38115. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38116. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38117. func (m *WxMutation) OldAllowList(ctx context.Context) (v []string, err error) {
  38118. if !m.op.Is(OpUpdateOne) {
  38119. return v, errors.New("OldAllowList is only allowed on UpdateOne operations")
  38120. }
  38121. if m.id == nil || m.oldValue == nil {
  38122. return v, errors.New("OldAllowList requires an ID field in the mutation")
  38123. }
  38124. oldValue, err := m.oldValue(ctx)
  38125. if err != nil {
  38126. return v, fmt.Errorf("querying old value for OldAllowList: %w", err)
  38127. }
  38128. return oldValue.AllowList, nil
  38129. }
  38130. // AppendAllowList adds s to the "allow_list" field.
  38131. func (m *WxMutation) AppendAllowList(s []string) {
  38132. m.appendallow_list = append(m.appendallow_list, s...)
  38133. }
  38134. // AppendedAllowList returns the list of values that were appended to the "allow_list" field in this mutation.
  38135. func (m *WxMutation) AppendedAllowList() ([]string, bool) {
  38136. if len(m.appendallow_list) == 0 {
  38137. return nil, false
  38138. }
  38139. return m.appendallow_list, true
  38140. }
  38141. // ResetAllowList resets all changes to the "allow_list" field.
  38142. func (m *WxMutation) ResetAllowList() {
  38143. m.allow_list = nil
  38144. m.appendallow_list = nil
  38145. }
  38146. // SetGroupAllowList sets the "group_allow_list" field.
  38147. func (m *WxMutation) SetGroupAllowList(s []string) {
  38148. m.group_allow_list = &s
  38149. m.appendgroup_allow_list = nil
  38150. }
  38151. // GroupAllowList returns the value of the "group_allow_list" field in the mutation.
  38152. func (m *WxMutation) GroupAllowList() (r []string, exists bool) {
  38153. v := m.group_allow_list
  38154. if v == nil {
  38155. return
  38156. }
  38157. return *v, true
  38158. }
  38159. // OldGroupAllowList returns the old "group_allow_list" field's value of the Wx entity.
  38160. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38161. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38162. func (m *WxMutation) OldGroupAllowList(ctx context.Context) (v []string, err error) {
  38163. if !m.op.Is(OpUpdateOne) {
  38164. return v, errors.New("OldGroupAllowList is only allowed on UpdateOne operations")
  38165. }
  38166. if m.id == nil || m.oldValue == nil {
  38167. return v, errors.New("OldGroupAllowList requires an ID field in the mutation")
  38168. }
  38169. oldValue, err := m.oldValue(ctx)
  38170. if err != nil {
  38171. return v, fmt.Errorf("querying old value for OldGroupAllowList: %w", err)
  38172. }
  38173. return oldValue.GroupAllowList, nil
  38174. }
  38175. // AppendGroupAllowList adds s to the "group_allow_list" field.
  38176. func (m *WxMutation) AppendGroupAllowList(s []string) {
  38177. m.appendgroup_allow_list = append(m.appendgroup_allow_list, s...)
  38178. }
  38179. // AppendedGroupAllowList returns the list of values that were appended to the "group_allow_list" field in this mutation.
  38180. func (m *WxMutation) AppendedGroupAllowList() ([]string, bool) {
  38181. if len(m.appendgroup_allow_list) == 0 {
  38182. return nil, false
  38183. }
  38184. return m.appendgroup_allow_list, true
  38185. }
  38186. // ResetGroupAllowList resets all changes to the "group_allow_list" field.
  38187. func (m *WxMutation) ResetGroupAllowList() {
  38188. m.group_allow_list = nil
  38189. m.appendgroup_allow_list = nil
  38190. }
  38191. // SetBlockList sets the "block_list" field.
  38192. func (m *WxMutation) SetBlockList(s []string) {
  38193. m.block_list = &s
  38194. m.appendblock_list = nil
  38195. }
  38196. // BlockList returns the value of the "block_list" field in the mutation.
  38197. func (m *WxMutation) BlockList() (r []string, exists bool) {
  38198. v := m.block_list
  38199. if v == nil {
  38200. return
  38201. }
  38202. return *v, true
  38203. }
  38204. // OldBlockList returns the old "block_list" field's value of the Wx entity.
  38205. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38206. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38207. func (m *WxMutation) OldBlockList(ctx context.Context) (v []string, err error) {
  38208. if !m.op.Is(OpUpdateOne) {
  38209. return v, errors.New("OldBlockList is only allowed on UpdateOne operations")
  38210. }
  38211. if m.id == nil || m.oldValue == nil {
  38212. return v, errors.New("OldBlockList requires an ID field in the mutation")
  38213. }
  38214. oldValue, err := m.oldValue(ctx)
  38215. if err != nil {
  38216. return v, fmt.Errorf("querying old value for OldBlockList: %w", err)
  38217. }
  38218. return oldValue.BlockList, nil
  38219. }
  38220. // AppendBlockList adds s to the "block_list" field.
  38221. func (m *WxMutation) AppendBlockList(s []string) {
  38222. m.appendblock_list = append(m.appendblock_list, s...)
  38223. }
  38224. // AppendedBlockList returns the list of values that were appended to the "block_list" field in this mutation.
  38225. func (m *WxMutation) AppendedBlockList() ([]string, bool) {
  38226. if len(m.appendblock_list) == 0 {
  38227. return nil, false
  38228. }
  38229. return m.appendblock_list, true
  38230. }
  38231. // ResetBlockList resets all changes to the "block_list" field.
  38232. func (m *WxMutation) ResetBlockList() {
  38233. m.block_list = nil
  38234. m.appendblock_list = nil
  38235. }
  38236. // SetGroupBlockList sets the "group_block_list" field.
  38237. func (m *WxMutation) SetGroupBlockList(s []string) {
  38238. m.group_block_list = &s
  38239. m.appendgroup_block_list = nil
  38240. }
  38241. // GroupBlockList returns the value of the "group_block_list" field in the mutation.
  38242. func (m *WxMutation) GroupBlockList() (r []string, exists bool) {
  38243. v := m.group_block_list
  38244. if v == nil {
  38245. return
  38246. }
  38247. return *v, true
  38248. }
  38249. // OldGroupBlockList returns the old "group_block_list" field's value of the Wx entity.
  38250. // If the Wx object wasn't provided to the builder, the object is fetched from the database.
  38251. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  38252. func (m *WxMutation) OldGroupBlockList(ctx context.Context) (v []string, err error) {
  38253. if !m.op.Is(OpUpdateOne) {
  38254. return v, errors.New("OldGroupBlockList is only allowed on UpdateOne operations")
  38255. }
  38256. if m.id == nil || m.oldValue == nil {
  38257. return v, errors.New("OldGroupBlockList requires an ID field in the mutation")
  38258. }
  38259. oldValue, err := m.oldValue(ctx)
  38260. if err != nil {
  38261. return v, fmt.Errorf("querying old value for OldGroupBlockList: %w", err)
  38262. }
  38263. return oldValue.GroupBlockList, nil
  38264. }
  38265. // AppendGroupBlockList adds s to the "group_block_list" field.
  38266. func (m *WxMutation) AppendGroupBlockList(s []string) {
  38267. m.appendgroup_block_list = append(m.appendgroup_block_list, s...)
  38268. }
  38269. // AppendedGroupBlockList returns the list of values that were appended to the "group_block_list" field in this mutation.
  38270. func (m *WxMutation) AppendedGroupBlockList() ([]string, bool) {
  38271. if len(m.appendgroup_block_list) == 0 {
  38272. return nil, false
  38273. }
  38274. return m.appendgroup_block_list, true
  38275. }
  38276. // ResetGroupBlockList resets all changes to the "group_block_list" field.
  38277. func (m *WxMutation) ResetGroupBlockList() {
  38278. m.group_block_list = nil
  38279. m.appendgroup_block_list = nil
  38280. }
  38281. // ClearServer clears the "server" edge to the Server entity.
  38282. func (m *WxMutation) ClearServer() {
  38283. m.clearedserver = true
  38284. m.clearedFields[wx.FieldServerID] = struct{}{}
  38285. }
  38286. // ServerCleared reports if the "server" edge to the Server entity was cleared.
  38287. func (m *WxMutation) ServerCleared() bool {
  38288. return m.ServerIDCleared() || m.clearedserver
  38289. }
  38290. // ServerIDs returns the "server" edge IDs in the mutation.
  38291. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38292. // ServerID instead. It exists only for internal usage by the builders.
  38293. func (m *WxMutation) ServerIDs() (ids []uint64) {
  38294. if id := m.server; id != nil {
  38295. ids = append(ids, *id)
  38296. }
  38297. return
  38298. }
  38299. // ResetServer resets all changes to the "server" edge.
  38300. func (m *WxMutation) ResetServer() {
  38301. m.server = nil
  38302. m.clearedserver = false
  38303. }
  38304. // ClearAgent clears the "agent" edge to the Agent entity.
  38305. func (m *WxMutation) ClearAgent() {
  38306. m.clearedagent = true
  38307. m.clearedFields[wx.FieldAgentID] = struct{}{}
  38308. }
  38309. // AgentCleared reports if the "agent" edge to the Agent entity was cleared.
  38310. func (m *WxMutation) AgentCleared() bool {
  38311. return m.clearedagent
  38312. }
  38313. // AgentIDs returns the "agent" edge IDs in the mutation.
  38314. // Note that IDs always returns len(IDs) <= 1 for unique edges, and you should use
  38315. // AgentID instead. It exists only for internal usage by the builders.
  38316. func (m *WxMutation) AgentIDs() (ids []uint64) {
  38317. if id := m.agent; id != nil {
  38318. ids = append(ids, *id)
  38319. }
  38320. return
  38321. }
  38322. // ResetAgent resets all changes to the "agent" edge.
  38323. func (m *WxMutation) ResetAgent() {
  38324. m.agent = nil
  38325. m.clearedagent = false
  38326. }
  38327. // Where appends a list predicates to the WxMutation builder.
  38328. func (m *WxMutation) Where(ps ...predicate.Wx) {
  38329. m.predicates = append(m.predicates, ps...)
  38330. }
  38331. // WhereP appends storage-level predicates to the WxMutation builder. Using this method,
  38332. // users can use type-assertion to append predicates that do not depend on any generated package.
  38333. func (m *WxMutation) WhereP(ps ...func(*sql.Selector)) {
  38334. p := make([]predicate.Wx, len(ps))
  38335. for i := range ps {
  38336. p[i] = ps[i]
  38337. }
  38338. m.Where(p...)
  38339. }
  38340. // Op returns the operation name.
  38341. func (m *WxMutation) Op() Op {
  38342. return m.op
  38343. }
  38344. // SetOp allows setting the mutation operation.
  38345. func (m *WxMutation) SetOp(op Op) {
  38346. m.op = op
  38347. }
  38348. // Type returns the node type of this mutation (Wx).
  38349. func (m *WxMutation) Type() string {
  38350. return m.typ
  38351. }
  38352. // Fields returns all fields that were changed during this mutation. Note that in
  38353. // order to get all numeric fields that were incremented/decremented, call
  38354. // AddedFields().
  38355. func (m *WxMutation) Fields() []string {
  38356. fields := make([]string, 0, 21)
  38357. if m.created_at != nil {
  38358. fields = append(fields, wx.FieldCreatedAt)
  38359. }
  38360. if m.updated_at != nil {
  38361. fields = append(fields, wx.FieldUpdatedAt)
  38362. }
  38363. if m.status != nil {
  38364. fields = append(fields, wx.FieldStatus)
  38365. }
  38366. if m.deleted_at != nil {
  38367. fields = append(fields, wx.FieldDeletedAt)
  38368. }
  38369. if m.server != nil {
  38370. fields = append(fields, wx.FieldServerID)
  38371. }
  38372. if m.port != nil {
  38373. fields = append(fields, wx.FieldPort)
  38374. }
  38375. if m.process_id != nil {
  38376. fields = append(fields, wx.FieldProcessID)
  38377. }
  38378. if m.callback != nil {
  38379. fields = append(fields, wx.FieldCallback)
  38380. }
  38381. if m.wxid != nil {
  38382. fields = append(fields, wx.FieldWxid)
  38383. }
  38384. if m.account != nil {
  38385. fields = append(fields, wx.FieldAccount)
  38386. }
  38387. if m.nickname != nil {
  38388. fields = append(fields, wx.FieldNickname)
  38389. }
  38390. if m.tel != nil {
  38391. fields = append(fields, wx.FieldTel)
  38392. }
  38393. if m.head_big != nil {
  38394. fields = append(fields, wx.FieldHeadBig)
  38395. }
  38396. if m.organization_id != nil {
  38397. fields = append(fields, wx.FieldOrganizationID)
  38398. }
  38399. if m.agent != nil {
  38400. fields = append(fields, wx.FieldAgentID)
  38401. }
  38402. if m.api_base != nil {
  38403. fields = append(fields, wx.FieldAPIBase)
  38404. }
  38405. if m.api_key != nil {
  38406. fields = append(fields, wx.FieldAPIKey)
  38407. }
  38408. if m.allow_list != nil {
  38409. fields = append(fields, wx.FieldAllowList)
  38410. }
  38411. if m.group_allow_list != nil {
  38412. fields = append(fields, wx.FieldGroupAllowList)
  38413. }
  38414. if m.block_list != nil {
  38415. fields = append(fields, wx.FieldBlockList)
  38416. }
  38417. if m.group_block_list != nil {
  38418. fields = append(fields, wx.FieldGroupBlockList)
  38419. }
  38420. return fields
  38421. }
  38422. // Field returns the value of a field with the given name. The second boolean
  38423. // return value indicates that this field was not set, or was not defined in the
  38424. // schema.
  38425. func (m *WxMutation) Field(name string) (ent.Value, bool) {
  38426. switch name {
  38427. case wx.FieldCreatedAt:
  38428. return m.CreatedAt()
  38429. case wx.FieldUpdatedAt:
  38430. return m.UpdatedAt()
  38431. case wx.FieldStatus:
  38432. return m.Status()
  38433. case wx.FieldDeletedAt:
  38434. return m.DeletedAt()
  38435. case wx.FieldServerID:
  38436. return m.ServerID()
  38437. case wx.FieldPort:
  38438. return m.Port()
  38439. case wx.FieldProcessID:
  38440. return m.ProcessID()
  38441. case wx.FieldCallback:
  38442. return m.Callback()
  38443. case wx.FieldWxid:
  38444. return m.Wxid()
  38445. case wx.FieldAccount:
  38446. return m.Account()
  38447. case wx.FieldNickname:
  38448. return m.Nickname()
  38449. case wx.FieldTel:
  38450. return m.Tel()
  38451. case wx.FieldHeadBig:
  38452. return m.HeadBig()
  38453. case wx.FieldOrganizationID:
  38454. return m.OrganizationID()
  38455. case wx.FieldAgentID:
  38456. return m.AgentID()
  38457. case wx.FieldAPIBase:
  38458. return m.APIBase()
  38459. case wx.FieldAPIKey:
  38460. return m.APIKey()
  38461. case wx.FieldAllowList:
  38462. return m.AllowList()
  38463. case wx.FieldGroupAllowList:
  38464. return m.GroupAllowList()
  38465. case wx.FieldBlockList:
  38466. return m.BlockList()
  38467. case wx.FieldGroupBlockList:
  38468. return m.GroupBlockList()
  38469. }
  38470. return nil, false
  38471. }
  38472. // OldField returns the old value of the field from the database. An error is
  38473. // returned if the mutation operation is not UpdateOne, or the query to the
  38474. // database failed.
  38475. func (m *WxMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  38476. switch name {
  38477. case wx.FieldCreatedAt:
  38478. return m.OldCreatedAt(ctx)
  38479. case wx.FieldUpdatedAt:
  38480. return m.OldUpdatedAt(ctx)
  38481. case wx.FieldStatus:
  38482. return m.OldStatus(ctx)
  38483. case wx.FieldDeletedAt:
  38484. return m.OldDeletedAt(ctx)
  38485. case wx.FieldServerID:
  38486. return m.OldServerID(ctx)
  38487. case wx.FieldPort:
  38488. return m.OldPort(ctx)
  38489. case wx.FieldProcessID:
  38490. return m.OldProcessID(ctx)
  38491. case wx.FieldCallback:
  38492. return m.OldCallback(ctx)
  38493. case wx.FieldWxid:
  38494. return m.OldWxid(ctx)
  38495. case wx.FieldAccount:
  38496. return m.OldAccount(ctx)
  38497. case wx.FieldNickname:
  38498. return m.OldNickname(ctx)
  38499. case wx.FieldTel:
  38500. return m.OldTel(ctx)
  38501. case wx.FieldHeadBig:
  38502. return m.OldHeadBig(ctx)
  38503. case wx.FieldOrganizationID:
  38504. return m.OldOrganizationID(ctx)
  38505. case wx.FieldAgentID:
  38506. return m.OldAgentID(ctx)
  38507. case wx.FieldAPIBase:
  38508. return m.OldAPIBase(ctx)
  38509. case wx.FieldAPIKey:
  38510. return m.OldAPIKey(ctx)
  38511. case wx.FieldAllowList:
  38512. return m.OldAllowList(ctx)
  38513. case wx.FieldGroupAllowList:
  38514. return m.OldGroupAllowList(ctx)
  38515. case wx.FieldBlockList:
  38516. return m.OldBlockList(ctx)
  38517. case wx.FieldGroupBlockList:
  38518. return m.OldGroupBlockList(ctx)
  38519. }
  38520. return nil, fmt.Errorf("unknown Wx field %s", name)
  38521. }
  38522. // SetField sets the value of a field with the given name. It returns an error if
  38523. // the field is not defined in the schema, or if the type mismatched the field
  38524. // type.
  38525. func (m *WxMutation) SetField(name string, value ent.Value) error {
  38526. switch name {
  38527. case wx.FieldCreatedAt:
  38528. v, ok := value.(time.Time)
  38529. if !ok {
  38530. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38531. }
  38532. m.SetCreatedAt(v)
  38533. return nil
  38534. case wx.FieldUpdatedAt:
  38535. v, ok := value.(time.Time)
  38536. if !ok {
  38537. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38538. }
  38539. m.SetUpdatedAt(v)
  38540. return nil
  38541. case wx.FieldStatus:
  38542. v, ok := value.(uint8)
  38543. if !ok {
  38544. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38545. }
  38546. m.SetStatus(v)
  38547. return nil
  38548. case wx.FieldDeletedAt:
  38549. v, ok := value.(time.Time)
  38550. if !ok {
  38551. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38552. }
  38553. m.SetDeletedAt(v)
  38554. return nil
  38555. case wx.FieldServerID:
  38556. v, ok := value.(uint64)
  38557. if !ok {
  38558. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38559. }
  38560. m.SetServerID(v)
  38561. return nil
  38562. case wx.FieldPort:
  38563. v, ok := value.(string)
  38564. if !ok {
  38565. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38566. }
  38567. m.SetPort(v)
  38568. return nil
  38569. case wx.FieldProcessID:
  38570. v, ok := value.(string)
  38571. if !ok {
  38572. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38573. }
  38574. m.SetProcessID(v)
  38575. return nil
  38576. case wx.FieldCallback:
  38577. v, ok := value.(string)
  38578. if !ok {
  38579. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38580. }
  38581. m.SetCallback(v)
  38582. return nil
  38583. case wx.FieldWxid:
  38584. v, ok := value.(string)
  38585. if !ok {
  38586. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38587. }
  38588. m.SetWxid(v)
  38589. return nil
  38590. case wx.FieldAccount:
  38591. v, ok := value.(string)
  38592. if !ok {
  38593. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38594. }
  38595. m.SetAccount(v)
  38596. return nil
  38597. case wx.FieldNickname:
  38598. v, ok := value.(string)
  38599. if !ok {
  38600. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38601. }
  38602. m.SetNickname(v)
  38603. return nil
  38604. case wx.FieldTel:
  38605. v, ok := value.(string)
  38606. if !ok {
  38607. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38608. }
  38609. m.SetTel(v)
  38610. return nil
  38611. case wx.FieldHeadBig:
  38612. v, ok := value.(string)
  38613. if !ok {
  38614. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38615. }
  38616. m.SetHeadBig(v)
  38617. return nil
  38618. case wx.FieldOrganizationID:
  38619. v, ok := value.(uint64)
  38620. if !ok {
  38621. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38622. }
  38623. m.SetOrganizationID(v)
  38624. return nil
  38625. case wx.FieldAgentID:
  38626. v, ok := value.(uint64)
  38627. if !ok {
  38628. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38629. }
  38630. m.SetAgentID(v)
  38631. return nil
  38632. case wx.FieldAPIBase:
  38633. v, ok := value.(string)
  38634. if !ok {
  38635. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38636. }
  38637. m.SetAPIBase(v)
  38638. return nil
  38639. case wx.FieldAPIKey:
  38640. v, ok := value.(string)
  38641. if !ok {
  38642. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38643. }
  38644. m.SetAPIKey(v)
  38645. return nil
  38646. case wx.FieldAllowList:
  38647. v, ok := value.([]string)
  38648. if !ok {
  38649. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38650. }
  38651. m.SetAllowList(v)
  38652. return nil
  38653. case wx.FieldGroupAllowList:
  38654. v, ok := value.([]string)
  38655. if !ok {
  38656. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38657. }
  38658. m.SetGroupAllowList(v)
  38659. return nil
  38660. case wx.FieldBlockList:
  38661. v, ok := value.([]string)
  38662. if !ok {
  38663. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38664. }
  38665. m.SetBlockList(v)
  38666. return nil
  38667. case wx.FieldGroupBlockList:
  38668. v, ok := value.([]string)
  38669. if !ok {
  38670. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38671. }
  38672. m.SetGroupBlockList(v)
  38673. return nil
  38674. }
  38675. return fmt.Errorf("unknown Wx field %s", name)
  38676. }
  38677. // AddedFields returns all numeric fields that were incremented/decremented during
  38678. // this mutation.
  38679. func (m *WxMutation) AddedFields() []string {
  38680. var fields []string
  38681. if m.addstatus != nil {
  38682. fields = append(fields, wx.FieldStatus)
  38683. }
  38684. if m.addorganization_id != nil {
  38685. fields = append(fields, wx.FieldOrganizationID)
  38686. }
  38687. return fields
  38688. }
  38689. // AddedField returns the numeric value that was incremented/decremented on a field
  38690. // with the given name. The second boolean return value indicates that this field
  38691. // was not set, or was not defined in the schema.
  38692. func (m *WxMutation) AddedField(name string) (ent.Value, bool) {
  38693. switch name {
  38694. case wx.FieldStatus:
  38695. return m.AddedStatus()
  38696. case wx.FieldOrganizationID:
  38697. return m.AddedOrganizationID()
  38698. }
  38699. return nil, false
  38700. }
  38701. // AddField adds the value to the field with the given name. It returns an error if
  38702. // the field is not defined in the schema, or if the type mismatched the field
  38703. // type.
  38704. func (m *WxMutation) AddField(name string, value ent.Value) error {
  38705. switch name {
  38706. case wx.FieldStatus:
  38707. v, ok := value.(int8)
  38708. if !ok {
  38709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38710. }
  38711. m.AddStatus(v)
  38712. return nil
  38713. case wx.FieldOrganizationID:
  38714. v, ok := value.(int64)
  38715. if !ok {
  38716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  38717. }
  38718. m.AddOrganizationID(v)
  38719. return nil
  38720. }
  38721. return fmt.Errorf("unknown Wx numeric field %s", name)
  38722. }
  38723. // ClearedFields returns all nullable fields that were cleared during this
  38724. // mutation.
  38725. func (m *WxMutation) ClearedFields() []string {
  38726. var fields []string
  38727. if m.FieldCleared(wx.FieldStatus) {
  38728. fields = append(fields, wx.FieldStatus)
  38729. }
  38730. if m.FieldCleared(wx.FieldDeletedAt) {
  38731. fields = append(fields, wx.FieldDeletedAt)
  38732. }
  38733. if m.FieldCleared(wx.FieldServerID) {
  38734. fields = append(fields, wx.FieldServerID)
  38735. }
  38736. if m.FieldCleared(wx.FieldOrganizationID) {
  38737. fields = append(fields, wx.FieldOrganizationID)
  38738. }
  38739. if m.FieldCleared(wx.FieldAPIBase) {
  38740. fields = append(fields, wx.FieldAPIBase)
  38741. }
  38742. if m.FieldCleared(wx.FieldAPIKey) {
  38743. fields = append(fields, wx.FieldAPIKey)
  38744. }
  38745. return fields
  38746. }
  38747. // FieldCleared returns a boolean indicating if a field with the given name was
  38748. // cleared in this mutation.
  38749. func (m *WxMutation) FieldCleared(name string) bool {
  38750. _, ok := m.clearedFields[name]
  38751. return ok
  38752. }
  38753. // ClearField clears the value of the field with the given name. It returns an
  38754. // error if the field is not defined in the schema.
  38755. func (m *WxMutation) ClearField(name string) error {
  38756. switch name {
  38757. case wx.FieldStatus:
  38758. m.ClearStatus()
  38759. return nil
  38760. case wx.FieldDeletedAt:
  38761. m.ClearDeletedAt()
  38762. return nil
  38763. case wx.FieldServerID:
  38764. m.ClearServerID()
  38765. return nil
  38766. case wx.FieldOrganizationID:
  38767. m.ClearOrganizationID()
  38768. return nil
  38769. case wx.FieldAPIBase:
  38770. m.ClearAPIBase()
  38771. return nil
  38772. case wx.FieldAPIKey:
  38773. m.ClearAPIKey()
  38774. return nil
  38775. }
  38776. return fmt.Errorf("unknown Wx nullable field %s", name)
  38777. }
  38778. // ResetField resets all changes in the mutation for the field with the given name.
  38779. // It returns an error if the field is not defined in the schema.
  38780. func (m *WxMutation) ResetField(name string) error {
  38781. switch name {
  38782. case wx.FieldCreatedAt:
  38783. m.ResetCreatedAt()
  38784. return nil
  38785. case wx.FieldUpdatedAt:
  38786. m.ResetUpdatedAt()
  38787. return nil
  38788. case wx.FieldStatus:
  38789. m.ResetStatus()
  38790. return nil
  38791. case wx.FieldDeletedAt:
  38792. m.ResetDeletedAt()
  38793. return nil
  38794. case wx.FieldServerID:
  38795. m.ResetServerID()
  38796. return nil
  38797. case wx.FieldPort:
  38798. m.ResetPort()
  38799. return nil
  38800. case wx.FieldProcessID:
  38801. m.ResetProcessID()
  38802. return nil
  38803. case wx.FieldCallback:
  38804. m.ResetCallback()
  38805. return nil
  38806. case wx.FieldWxid:
  38807. m.ResetWxid()
  38808. return nil
  38809. case wx.FieldAccount:
  38810. m.ResetAccount()
  38811. return nil
  38812. case wx.FieldNickname:
  38813. m.ResetNickname()
  38814. return nil
  38815. case wx.FieldTel:
  38816. m.ResetTel()
  38817. return nil
  38818. case wx.FieldHeadBig:
  38819. m.ResetHeadBig()
  38820. return nil
  38821. case wx.FieldOrganizationID:
  38822. m.ResetOrganizationID()
  38823. return nil
  38824. case wx.FieldAgentID:
  38825. m.ResetAgentID()
  38826. return nil
  38827. case wx.FieldAPIBase:
  38828. m.ResetAPIBase()
  38829. return nil
  38830. case wx.FieldAPIKey:
  38831. m.ResetAPIKey()
  38832. return nil
  38833. case wx.FieldAllowList:
  38834. m.ResetAllowList()
  38835. return nil
  38836. case wx.FieldGroupAllowList:
  38837. m.ResetGroupAllowList()
  38838. return nil
  38839. case wx.FieldBlockList:
  38840. m.ResetBlockList()
  38841. return nil
  38842. case wx.FieldGroupBlockList:
  38843. m.ResetGroupBlockList()
  38844. return nil
  38845. }
  38846. return fmt.Errorf("unknown Wx field %s", name)
  38847. }
  38848. // AddedEdges returns all edge names that were set/added in this mutation.
  38849. func (m *WxMutation) AddedEdges() []string {
  38850. edges := make([]string, 0, 2)
  38851. if m.server != nil {
  38852. edges = append(edges, wx.EdgeServer)
  38853. }
  38854. if m.agent != nil {
  38855. edges = append(edges, wx.EdgeAgent)
  38856. }
  38857. return edges
  38858. }
  38859. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  38860. // name in this mutation.
  38861. func (m *WxMutation) AddedIDs(name string) []ent.Value {
  38862. switch name {
  38863. case wx.EdgeServer:
  38864. if id := m.server; id != nil {
  38865. return []ent.Value{*id}
  38866. }
  38867. case wx.EdgeAgent:
  38868. if id := m.agent; id != nil {
  38869. return []ent.Value{*id}
  38870. }
  38871. }
  38872. return nil
  38873. }
  38874. // RemovedEdges returns all edge names that were removed in this mutation.
  38875. func (m *WxMutation) RemovedEdges() []string {
  38876. edges := make([]string, 0, 2)
  38877. return edges
  38878. }
  38879. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  38880. // the given name in this mutation.
  38881. func (m *WxMutation) RemovedIDs(name string) []ent.Value {
  38882. return nil
  38883. }
  38884. // ClearedEdges returns all edge names that were cleared in this mutation.
  38885. func (m *WxMutation) ClearedEdges() []string {
  38886. edges := make([]string, 0, 2)
  38887. if m.clearedserver {
  38888. edges = append(edges, wx.EdgeServer)
  38889. }
  38890. if m.clearedagent {
  38891. edges = append(edges, wx.EdgeAgent)
  38892. }
  38893. return edges
  38894. }
  38895. // EdgeCleared returns a boolean which indicates if the edge with the given name
  38896. // was cleared in this mutation.
  38897. func (m *WxMutation) EdgeCleared(name string) bool {
  38898. switch name {
  38899. case wx.EdgeServer:
  38900. return m.clearedserver
  38901. case wx.EdgeAgent:
  38902. return m.clearedagent
  38903. }
  38904. return false
  38905. }
  38906. // ClearEdge clears the value of the edge with the given name. It returns an error
  38907. // if that edge is not defined in the schema.
  38908. func (m *WxMutation) ClearEdge(name string) error {
  38909. switch name {
  38910. case wx.EdgeServer:
  38911. m.ClearServer()
  38912. return nil
  38913. case wx.EdgeAgent:
  38914. m.ClearAgent()
  38915. return nil
  38916. }
  38917. return fmt.Errorf("unknown Wx unique edge %s", name)
  38918. }
  38919. // ResetEdge resets all changes to the edge with the given name in this mutation.
  38920. // It returns an error if the edge is not defined in the schema.
  38921. func (m *WxMutation) ResetEdge(name string) error {
  38922. switch name {
  38923. case wx.EdgeServer:
  38924. m.ResetServer()
  38925. return nil
  38926. case wx.EdgeAgent:
  38927. m.ResetAgent()
  38928. return nil
  38929. }
  38930. return fmt.Errorf("unknown Wx edge %s", name)
  38931. }
  38932. // WxCardMutation represents an operation that mutates the WxCard nodes in the graph.
  38933. type WxCardMutation struct {
  38934. config
  38935. op Op
  38936. typ string
  38937. id *uint64
  38938. created_at *time.Time
  38939. updated_at *time.Time
  38940. deleted_at *time.Time
  38941. user_id *uint64
  38942. adduser_id *int64
  38943. wx_user_id *uint64
  38944. addwx_user_id *int64
  38945. avatar *string
  38946. logo *string
  38947. name *string
  38948. company *string
  38949. address *string
  38950. phone *string
  38951. official_account *string
  38952. wechat_account *string
  38953. email *string
  38954. api_base *string
  38955. api_key *string
  38956. ai_info *string
  38957. intro *string
  38958. clearedFields map[string]struct{}
  38959. done bool
  38960. oldValue func(context.Context) (*WxCard, error)
  38961. predicates []predicate.WxCard
  38962. }
  38963. var _ ent.Mutation = (*WxCardMutation)(nil)
  38964. // wxcardOption allows management of the mutation configuration using functional options.
  38965. type wxcardOption func(*WxCardMutation)
  38966. // newWxCardMutation creates new mutation for the WxCard entity.
  38967. func newWxCardMutation(c config, op Op, opts ...wxcardOption) *WxCardMutation {
  38968. m := &WxCardMutation{
  38969. config: c,
  38970. op: op,
  38971. typ: TypeWxCard,
  38972. clearedFields: make(map[string]struct{}),
  38973. }
  38974. for _, opt := range opts {
  38975. opt(m)
  38976. }
  38977. return m
  38978. }
  38979. // withWxCardID sets the ID field of the mutation.
  38980. func withWxCardID(id uint64) wxcardOption {
  38981. return func(m *WxCardMutation) {
  38982. var (
  38983. err error
  38984. once sync.Once
  38985. value *WxCard
  38986. )
  38987. m.oldValue = func(ctx context.Context) (*WxCard, error) {
  38988. once.Do(func() {
  38989. if m.done {
  38990. err = errors.New("querying old values post mutation is not allowed")
  38991. } else {
  38992. value, err = m.Client().WxCard.Get(ctx, id)
  38993. }
  38994. })
  38995. return value, err
  38996. }
  38997. m.id = &id
  38998. }
  38999. }
  39000. // withWxCard sets the old WxCard of the mutation.
  39001. func withWxCard(node *WxCard) wxcardOption {
  39002. return func(m *WxCardMutation) {
  39003. m.oldValue = func(context.Context) (*WxCard, error) {
  39004. return node, nil
  39005. }
  39006. m.id = &node.ID
  39007. }
  39008. }
  39009. // Client returns a new `ent.Client` from the mutation. If the mutation was
  39010. // executed in a transaction (ent.Tx), a transactional client is returned.
  39011. func (m WxCardMutation) Client() *Client {
  39012. client := &Client{config: m.config}
  39013. client.init()
  39014. return client
  39015. }
  39016. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  39017. // it returns an error otherwise.
  39018. func (m WxCardMutation) Tx() (*Tx, error) {
  39019. if _, ok := m.driver.(*txDriver); !ok {
  39020. return nil, errors.New("ent: mutation is not running in a transaction")
  39021. }
  39022. tx := &Tx{config: m.config}
  39023. tx.init()
  39024. return tx, nil
  39025. }
  39026. // SetID sets the value of the id field. Note that this
  39027. // operation is only accepted on creation of WxCard entities.
  39028. func (m *WxCardMutation) SetID(id uint64) {
  39029. m.id = &id
  39030. }
  39031. // ID returns the ID value in the mutation. Note that the ID is only available
  39032. // if it was provided to the builder or after it was returned from the database.
  39033. func (m *WxCardMutation) ID() (id uint64, exists bool) {
  39034. if m.id == nil {
  39035. return
  39036. }
  39037. return *m.id, true
  39038. }
  39039. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  39040. // That means, if the mutation is applied within a transaction with an isolation level such
  39041. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  39042. // or updated by the mutation.
  39043. func (m *WxCardMutation) IDs(ctx context.Context) ([]uint64, error) {
  39044. switch {
  39045. case m.op.Is(OpUpdateOne | OpDeleteOne):
  39046. id, exists := m.ID()
  39047. if exists {
  39048. return []uint64{id}, nil
  39049. }
  39050. fallthrough
  39051. case m.op.Is(OpUpdate | OpDelete):
  39052. return m.Client().WxCard.Query().Where(m.predicates...).IDs(ctx)
  39053. default:
  39054. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  39055. }
  39056. }
  39057. // SetCreatedAt sets the "created_at" field.
  39058. func (m *WxCardMutation) SetCreatedAt(t time.Time) {
  39059. m.created_at = &t
  39060. }
  39061. // CreatedAt returns the value of the "created_at" field in the mutation.
  39062. func (m *WxCardMutation) CreatedAt() (r time.Time, exists bool) {
  39063. v := m.created_at
  39064. if v == nil {
  39065. return
  39066. }
  39067. return *v, true
  39068. }
  39069. // OldCreatedAt returns the old "created_at" field's value of the WxCard entity.
  39070. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39071. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39072. func (m *WxCardMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  39073. if !m.op.Is(OpUpdateOne) {
  39074. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  39075. }
  39076. if m.id == nil || m.oldValue == nil {
  39077. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  39078. }
  39079. oldValue, err := m.oldValue(ctx)
  39080. if err != nil {
  39081. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  39082. }
  39083. return oldValue.CreatedAt, nil
  39084. }
  39085. // ResetCreatedAt resets all changes to the "created_at" field.
  39086. func (m *WxCardMutation) ResetCreatedAt() {
  39087. m.created_at = nil
  39088. }
  39089. // SetUpdatedAt sets the "updated_at" field.
  39090. func (m *WxCardMutation) SetUpdatedAt(t time.Time) {
  39091. m.updated_at = &t
  39092. }
  39093. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  39094. func (m *WxCardMutation) UpdatedAt() (r time.Time, exists bool) {
  39095. v := m.updated_at
  39096. if v == nil {
  39097. return
  39098. }
  39099. return *v, true
  39100. }
  39101. // OldUpdatedAt returns the old "updated_at" field's value of the WxCard entity.
  39102. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39103. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39104. func (m *WxCardMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  39105. if !m.op.Is(OpUpdateOne) {
  39106. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  39107. }
  39108. if m.id == nil || m.oldValue == nil {
  39109. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  39110. }
  39111. oldValue, err := m.oldValue(ctx)
  39112. if err != nil {
  39113. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  39114. }
  39115. return oldValue.UpdatedAt, nil
  39116. }
  39117. // ResetUpdatedAt resets all changes to the "updated_at" field.
  39118. func (m *WxCardMutation) ResetUpdatedAt() {
  39119. m.updated_at = nil
  39120. }
  39121. // SetDeletedAt sets the "deleted_at" field.
  39122. func (m *WxCardMutation) SetDeletedAt(t time.Time) {
  39123. m.deleted_at = &t
  39124. }
  39125. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  39126. func (m *WxCardMutation) DeletedAt() (r time.Time, exists bool) {
  39127. v := m.deleted_at
  39128. if v == nil {
  39129. return
  39130. }
  39131. return *v, true
  39132. }
  39133. // OldDeletedAt returns the old "deleted_at" field's value of the WxCard entity.
  39134. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39135. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39136. func (m *WxCardMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  39137. if !m.op.Is(OpUpdateOne) {
  39138. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  39139. }
  39140. if m.id == nil || m.oldValue == nil {
  39141. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  39142. }
  39143. oldValue, err := m.oldValue(ctx)
  39144. if err != nil {
  39145. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  39146. }
  39147. return oldValue.DeletedAt, nil
  39148. }
  39149. // ClearDeletedAt clears the value of the "deleted_at" field.
  39150. func (m *WxCardMutation) ClearDeletedAt() {
  39151. m.deleted_at = nil
  39152. m.clearedFields[wxcard.FieldDeletedAt] = struct{}{}
  39153. }
  39154. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  39155. func (m *WxCardMutation) DeletedAtCleared() bool {
  39156. _, ok := m.clearedFields[wxcard.FieldDeletedAt]
  39157. return ok
  39158. }
  39159. // ResetDeletedAt resets all changes to the "deleted_at" field.
  39160. func (m *WxCardMutation) ResetDeletedAt() {
  39161. m.deleted_at = nil
  39162. delete(m.clearedFields, wxcard.FieldDeletedAt)
  39163. }
  39164. // SetUserID sets the "user_id" field.
  39165. func (m *WxCardMutation) SetUserID(u uint64) {
  39166. m.user_id = &u
  39167. m.adduser_id = nil
  39168. }
  39169. // UserID returns the value of the "user_id" field in the mutation.
  39170. func (m *WxCardMutation) UserID() (r uint64, exists bool) {
  39171. v := m.user_id
  39172. if v == nil {
  39173. return
  39174. }
  39175. return *v, true
  39176. }
  39177. // OldUserID returns the old "user_id" field's value of the WxCard entity.
  39178. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39179. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39180. func (m *WxCardMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  39181. if !m.op.Is(OpUpdateOne) {
  39182. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  39183. }
  39184. if m.id == nil || m.oldValue == nil {
  39185. return v, errors.New("OldUserID requires an ID field in the mutation")
  39186. }
  39187. oldValue, err := m.oldValue(ctx)
  39188. if err != nil {
  39189. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  39190. }
  39191. return oldValue.UserID, nil
  39192. }
  39193. // AddUserID adds u to the "user_id" field.
  39194. func (m *WxCardMutation) AddUserID(u int64) {
  39195. if m.adduser_id != nil {
  39196. *m.adduser_id += u
  39197. } else {
  39198. m.adduser_id = &u
  39199. }
  39200. }
  39201. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  39202. func (m *WxCardMutation) AddedUserID() (r int64, exists bool) {
  39203. v := m.adduser_id
  39204. if v == nil {
  39205. return
  39206. }
  39207. return *v, true
  39208. }
  39209. // ClearUserID clears the value of the "user_id" field.
  39210. func (m *WxCardMutation) ClearUserID() {
  39211. m.user_id = nil
  39212. m.adduser_id = nil
  39213. m.clearedFields[wxcard.FieldUserID] = struct{}{}
  39214. }
  39215. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  39216. func (m *WxCardMutation) UserIDCleared() bool {
  39217. _, ok := m.clearedFields[wxcard.FieldUserID]
  39218. return ok
  39219. }
  39220. // ResetUserID resets all changes to the "user_id" field.
  39221. func (m *WxCardMutation) ResetUserID() {
  39222. m.user_id = nil
  39223. m.adduser_id = nil
  39224. delete(m.clearedFields, wxcard.FieldUserID)
  39225. }
  39226. // SetWxUserID sets the "wx_user_id" field.
  39227. func (m *WxCardMutation) SetWxUserID(u uint64) {
  39228. m.wx_user_id = &u
  39229. m.addwx_user_id = nil
  39230. }
  39231. // WxUserID returns the value of the "wx_user_id" field in the mutation.
  39232. func (m *WxCardMutation) WxUserID() (r uint64, exists bool) {
  39233. v := m.wx_user_id
  39234. if v == nil {
  39235. return
  39236. }
  39237. return *v, true
  39238. }
  39239. // OldWxUserID returns the old "wx_user_id" field's value of the WxCard entity.
  39240. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39241. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39242. func (m *WxCardMutation) OldWxUserID(ctx context.Context) (v uint64, err error) {
  39243. if !m.op.Is(OpUpdateOne) {
  39244. return v, errors.New("OldWxUserID is only allowed on UpdateOne operations")
  39245. }
  39246. if m.id == nil || m.oldValue == nil {
  39247. return v, errors.New("OldWxUserID requires an ID field in the mutation")
  39248. }
  39249. oldValue, err := m.oldValue(ctx)
  39250. if err != nil {
  39251. return v, fmt.Errorf("querying old value for OldWxUserID: %w", err)
  39252. }
  39253. return oldValue.WxUserID, nil
  39254. }
  39255. // AddWxUserID adds u to the "wx_user_id" field.
  39256. func (m *WxCardMutation) AddWxUserID(u int64) {
  39257. if m.addwx_user_id != nil {
  39258. *m.addwx_user_id += u
  39259. } else {
  39260. m.addwx_user_id = &u
  39261. }
  39262. }
  39263. // AddedWxUserID returns the value that was added to the "wx_user_id" field in this mutation.
  39264. func (m *WxCardMutation) AddedWxUserID() (r int64, exists bool) {
  39265. v := m.addwx_user_id
  39266. if v == nil {
  39267. return
  39268. }
  39269. return *v, true
  39270. }
  39271. // ClearWxUserID clears the value of the "wx_user_id" field.
  39272. func (m *WxCardMutation) ClearWxUserID() {
  39273. m.wx_user_id = nil
  39274. m.addwx_user_id = nil
  39275. m.clearedFields[wxcard.FieldWxUserID] = struct{}{}
  39276. }
  39277. // WxUserIDCleared returns if the "wx_user_id" field was cleared in this mutation.
  39278. func (m *WxCardMutation) WxUserIDCleared() bool {
  39279. _, ok := m.clearedFields[wxcard.FieldWxUserID]
  39280. return ok
  39281. }
  39282. // ResetWxUserID resets all changes to the "wx_user_id" field.
  39283. func (m *WxCardMutation) ResetWxUserID() {
  39284. m.wx_user_id = nil
  39285. m.addwx_user_id = nil
  39286. delete(m.clearedFields, wxcard.FieldWxUserID)
  39287. }
  39288. // SetAvatar sets the "avatar" field.
  39289. func (m *WxCardMutation) SetAvatar(s string) {
  39290. m.avatar = &s
  39291. }
  39292. // Avatar returns the value of the "avatar" field in the mutation.
  39293. func (m *WxCardMutation) Avatar() (r string, exists bool) {
  39294. v := m.avatar
  39295. if v == nil {
  39296. return
  39297. }
  39298. return *v, true
  39299. }
  39300. // OldAvatar returns the old "avatar" field's value of the WxCard entity.
  39301. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39302. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39303. func (m *WxCardMutation) OldAvatar(ctx context.Context) (v string, err error) {
  39304. if !m.op.Is(OpUpdateOne) {
  39305. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  39306. }
  39307. if m.id == nil || m.oldValue == nil {
  39308. return v, errors.New("OldAvatar requires an ID field in the mutation")
  39309. }
  39310. oldValue, err := m.oldValue(ctx)
  39311. if err != nil {
  39312. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  39313. }
  39314. return oldValue.Avatar, nil
  39315. }
  39316. // ResetAvatar resets all changes to the "avatar" field.
  39317. func (m *WxCardMutation) ResetAvatar() {
  39318. m.avatar = nil
  39319. }
  39320. // SetLogo sets the "logo" field.
  39321. func (m *WxCardMutation) SetLogo(s string) {
  39322. m.logo = &s
  39323. }
  39324. // Logo returns the value of the "logo" field in the mutation.
  39325. func (m *WxCardMutation) Logo() (r string, exists bool) {
  39326. v := m.logo
  39327. if v == nil {
  39328. return
  39329. }
  39330. return *v, true
  39331. }
  39332. // OldLogo returns the old "logo" field's value of the WxCard entity.
  39333. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39334. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39335. func (m *WxCardMutation) OldLogo(ctx context.Context) (v string, err error) {
  39336. if !m.op.Is(OpUpdateOne) {
  39337. return v, errors.New("OldLogo is only allowed on UpdateOne operations")
  39338. }
  39339. if m.id == nil || m.oldValue == nil {
  39340. return v, errors.New("OldLogo requires an ID field in the mutation")
  39341. }
  39342. oldValue, err := m.oldValue(ctx)
  39343. if err != nil {
  39344. return v, fmt.Errorf("querying old value for OldLogo: %w", err)
  39345. }
  39346. return oldValue.Logo, nil
  39347. }
  39348. // ResetLogo resets all changes to the "logo" field.
  39349. func (m *WxCardMutation) ResetLogo() {
  39350. m.logo = nil
  39351. }
  39352. // SetName sets the "name" field.
  39353. func (m *WxCardMutation) SetName(s string) {
  39354. m.name = &s
  39355. }
  39356. // Name returns the value of the "name" field in the mutation.
  39357. func (m *WxCardMutation) Name() (r string, exists bool) {
  39358. v := m.name
  39359. if v == nil {
  39360. return
  39361. }
  39362. return *v, true
  39363. }
  39364. // OldName returns the old "name" field's value of the WxCard entity.
  39365. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39366. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39367. func (m *WxCardMutation) OldName(ctx context.Context) (v string, err error) {
  39368. if !m.op.Is(OpUpdateOne) {
  39369. return v, errors.New("OldName is only allowed on UpdateOne operations")
  39370. }
  39371. if m.id == nil || m.oldValue == nil {
  39372. return v, errors.New("OldName requires an ID field in the mutation")
  39373. }
  39374. oldValue, err := m.oldValue(ctx)
  39375. if err != nil {
  39376. return v, fmt.Errorf("querying old value for OldName: %w", err)
  39377. }
  39378. return oldValue.Name, nil
  39379. }
  39380. // ResetName resets all changes to the "name" field.
  39381. func (m *WxCardMutation) ResetName() {
  39382. m.name = nil
  39383. }
  39384. // SetCompany sets the "company" field.
  39385. func (m *WxCardMutation) SetCompany(s string) {
  39386. m.company = &s
  39387. }
  39388. // Company returns the value of the "company" field in the mutation.
  39389. func (m *WxCardMutation) Company() (r string, exists bool) {
  39390. v := m.company
  39391. if v == nil {
  39392. return
  39393. }
  39394. return *v, true
  39395. }
  39396. // OldCompany returns the old "company" field's value of the WxCard entity.
  39397. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39398. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39399. func (m *WxCardMutation) OldCompany(ctx context.Context) (v string, err error) {
  39400. if !m.op.Is(OpUpdateOne) {
  39401. return v, errors.New("OldCompany is only allowed on UpdateOne operations")
  39402. }
  39403. if m.id == nil || m.oldValue == nil {
  39404. return v, errors.New("OldCompany requires an ID field in the mutation")
  39405. }
  39406. oldValue, err := m.oldValue(ctx)
  39407. if err != nil {
  39408. return v, fmt.Errorf("querying old value for OldCompany: %w", err)
  39409. }
  39410. return oldValue.Company, nil
  39411. }
  39412. // ResetCompany resets all changes to the "company" field.
  39413. func (m *WxCardMutation) ResetCompany() {
  39414. m.company = nil
  39415. }
  39416. // SetAddress sets the "address" field.
  39417. func (m *WxCardMutation) SetAddress(s string) {
  39418. m.address = &s
  39419. }
  39420. // Address returns the value of the "address" field in the mutation.
  39421. func (m *WxCardMutation) Address() (r string, exists bool) {
  39422. v := m.address
  39423. if v == nil {
  39424. return
  39425. }
  39426. return *v, true
  39427. }
  39428. // OldAddress returns the old "address" field's value of the WxCard entity.
  39429. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39430. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39431. func (m *WxCardMutation) OldAddress(ctx context.Context) (v string, err error) {
  39432. if !m.op.Is(OpUpdateOne) {
  39433. return v, errors.New("OldAddress is only allowed on UpdateOne operations")
  39434. }
  39435. if m.id == nil || m.oldValue == nil {
  39436. return v, errors.New("OldAddress requires an ID field in the mutation")
  39437. }
  39438. oldValue, err := m.oldValue(ctx)
  39439. if err != nil {
  39440. return v, fmt.Errorf("querying old value for OldAddress: %w", err)
  39441. }
  39442. return oldValue.Address, nil
  39443. }
  39444. // ResetAddress resets all changes to the "address" field.
  39445. func (m *WxCardMutation) ResetAddress() {
  39446. m.address = nil
  39447. }
  39448. // SetPhone sets the "phone" field.
  39449. func (m *WxCardMutation) SetPhone(s string) {
  39450. m.phone = &s
  39451. }
  39452. // Phone returns the value of the "phone" field in the mutation.
  39453. func (m *WxCardMutation) Phone() (r string, exists bool) {
  39454. v := m.phone
  39455. if v == nil {
  39456. return
  39457. }
  39458. return *v, true
  39459. }
  39460. // OldPhone returns the old "phone" field's value of the WxCard entity.
  39461. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39462. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39463. func (m *WxCardMutation) OldPhone(ctx context.Context) (v string, err error) {
  39464. if !m.op.Is(OpUpdateOne) {
  39465. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  39466. }
  39467. if m.id == nil || m.oldValue == nil {
  39468. return v, errors.New("OldPhone requires an ID field in the mutation")
  39469. }
  39470. oldValue, err := m.oldValue(ctx)
  39471. if err != nil {
  39472. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  39473. }
  39474. return oldValue.Phone, nil
  39475. }
  39476. // ResetPhone resets all changes to the "phone" field.
  39477. func (m *WxCardMutation) ResetPhone() {
  39478. m.phone = nil
  39479. }
  39480. // SetOfficialAccount sets the "official_account" field.
  39481. func (m *WxCardMutation) SetOfficialAccount(s string) {
  39482. m.official_account = &s
  39483. }
  39484. // OfficialAccount returns the value of the "official_account" field in the mutation.
  39485. func (m *WxCardMutation) OfficialAccount() (r string, exists bool) {
  39486. v := m.official_account
  39487. if v == nil {
  39488. return
  39489. }
  39490. return *v, true
  39491. }
  39492. // OldOfficialAccount returns the old "official_account" field's value of the WxCard entity.
  39493. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39494. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39495. func (m *WxCardMutation) OldOfficialAccount(ctx context.Context) (v string, err error) {
  39496. if !m.op.Is(OpUpdateOne) {
  39497. return v, errors.New("OldOfficialAccount is only allowed on UpdateOne operations")
  39498. }
  39499. if m.id == nil || m.oldValue == nil {
  39500. return v, errors.New("OldOfficialAccount requires an ID field in the mutation")
  39501. }
  39502. oldValue, err := m.oldValue(ctx)
  39503. if err != nil {
  39504. return v, fmt.Errorf("querying old value for OldOfficialAccount: %w", err)
  39505. }
  39506. return oldValue.OfficialAccount, nil
  39507. }
  39508. // ResetOfficialAccount resets all changes to the "official_account" field.
  39509. func (m *WxCardMutation) ResetOfficialAccount() {
  39510. m.official_account = nil
  39511. }
  39512. // SetWechatAccount sets the "wechat_account" field.
  39513. func (m *WxCardMutation) SetWechatAccount(s string) {
  39514. m.wechat_account = &s
  39515. }
  39516. // WechatAccount returns the value of the "wechat_account" field in the mutation.
  39517. func (m *WxCardMutation) WechatAccount() (r string, exists bool) {
  39518. v := m.wechat_account
  39519. if v == nil {
  39520. return
  39521. }
  39522. return *v, true
  39523. }
  39524. // OldWechatAccount returns the old "wechat_account" field's value of the WxCard entity.
  39525. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39527. func (m *WxCardMutation) OldWechatAccount(ctx context.Context) (v string, err error) {
  39528. if !m.op.Is(OpUpdateOne) {
  39529. return v, errors.New("OldWechatAccount is only allowed on UpdateOne operations")
  39530. }
  39531. if m.id == nil || m.oldValue == nil {
  39532. return v, errors.New("OldWechatAccount requires an ID field in the mutation")
  39533. }
  39534. oldValue, err := m.oldValue(ctx)
  39535. if err != nil {
  39536. return v, fmt.Errorf("querying old value for OldWechatAccount: %w", err)
  39537. }
  39538. return oldValue.WechatAccount, nil
  39539. }
  39540. // ResetWechatAccount resets all changes to the "wechat_account" field.
  39541. func (m *WxCardMutation) ResetWechatAccount() {
  39542. m.wechat_account = nil
  39543. }
  39544. // SetEmail sets the "email" field.
  39545. func (m *WxCardMutation) SetEmail(s string) {
  39546. m.email = &s
  39547. }
  39548. // Email returns the value of the "email" field in the mutation.
  39549. func (m *WxCardMutation) Email() (r string, exists bool) {
  39550. v := m.email
  39551. if v == nil {
  39552. return
  39553. }
  39554. return *v, true
  39555. }
  39556. // OldEmail returns the old "email" field's value of the WxCard entity.
  39557. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39558. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39559. func (m *WxCardMutation) OldEmail(ctx context.Context) (v string, err error) {
  39560. if !m.op.Is(OpUpdateOne) {
  39561. return v, errors.New("OldEmail is only allowed on UpdateOne operations")
  39562. }
  39563. if m.id == nil || m.oldValue == nil {
  39564. return v, errors.New("OldEmail requires an ID field in the mutation")
  39565. }
  39566. oldValue, err := m.oldValue(ctx)
  39567. if err != nil {
  39568. return v, fmt.Errorf("querying old value for OldEmail: %w", err)
  39569. }
  39570. return oldValue.Email, nil
  39571. }
  39572. // ClearEmail clears the value of the "email" field.
  39573. func (m *WxCardMutation) ClearEmail() {
  39574. m.email = nil
  39575. m.clearedFields[wxcard.FieldEmail] = struct{}{}
  39576. }
  39577. // EmailCleared returns if the "email" field was cleared in this mutation.
  39578. func (m *WxCardMutation) EmailCleared() bool {
  39579. _, ok := m.clearedFields[wxcard.FieldEmail]
  39580. return ok
  39581. }
  39582. // ResetEmail resets all changes to the "email" field.
  39583. func (m *WxCardMutation) ResetEmail() {
  39584. m.email = nil
  39585. delete(m.clearedFields, wxcard.FieldEmail)
  39586. }
  39587. // SetAPIBase sets the "api_base" field.
  39588. func (m *WxCardMutation) SetAPIBase(s string) {
  39589. m.api_base = &s
  39590. }
  39591. // APIBase returns the value of the "api_base" field in the mutation.
  39592. func (m *WxCardMutation) APIBase() (r string, exists bool) {
  39593. v := m.api_base
  39594. if v == nil {
  39595. return
  39596. }
  39597. return *v, true
  39598. }
  39599. // OldAPIBase returns the old "api_base" field's value of the WxCard entity.
  39600. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39601. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39602. func (m *WxCardMutation) OldAPIBase(ctx context.Context) (v string, err error) {
  39603. if !m.op.Is(OpUpdateOne) {
  39604. return v, errors.New("OldAPIBase is only allowed on UpdateOne operations")
  39605. }
  39606. if m.id == nil || m.oldValue == nil {
  39607. return v, errors.New("OldAPIBase requires an ID field in the mutation")
  39608. }
  39609. oldValue, err := m.oldValue(ctx)
  39610. if err != nil {
  39611. return v, fmt.Errorf("querying old value for OldAPIBase: %w", err)
  39612. }
  39613. return oldValue.APIBase, nil
  39614. }
  39615. // ClearAPIBase clears the value of the "api_base" field.
  39616. func (m *WxCardMutation) ClearAPIBase() {
  39617. m.api_base = nil
  39618. m.clearedFields[wxcard.FieldAPIBase] = struct{}{}
  39619. }
  39620. // APIBaseCleared returns if the "api_base" field was cleared in this mutation.
  39621. func (m *WxCardMutation) APIBaseCleared() bool {
  39622. _, ok := m.clearedFields[wxcard.FieldAPIBase]
  39623. return ok
  39624. }
  39625. // ResetAPIBase resets all changes to the "api_base" field.
  39626. func (m *WxCardMutation) ResetAPIBase() {
  39627. m.api_base = nil
  39628. delete(m.clearedFields, wxcard.FieldAPIBase)
  39629. }
  39630. // SetAPIKey sets the "api_key" field.
  39631. func (m *WxCardMutation) SetAPIKey(s string) {
  39632. m.api_key = &s
  39633. }
  39634. // APIKey returns the value of the "api_key" field in the mutation.
  39635. func (m *WxCardMutation) APIKey() (r string, exists bool) {
  39636. v := m.api_key
  39637. if v == nil {
  39638. return
  39639. }
  39640. return *v, true
  39641. }
  39642. // OldAPIKey returns the old "api_key" field's value of the WxCard entity.
  39643. // If the WxCard object wasn't provided to the builder, the object is fetched from the database.
  39644. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  39645. func (m *WxCardMutation) OldAPIKey(ctx context.Context) (v string, err error) {
  39646. if !m.op.Is(OpUpdateOne) {
  39647. return v, errors.New("OldAPIKey is only allowed on UpdateOne operations")
  39648. }
  39649. if m.id == nil || m.oldValue == nil {
  39650. return v, errors.New("OldAPIKey requires an ID field in the mutation")
  39651. }
  39652. oldValue, err := m.oldValue(ctx)
  39653. if err != nil {
  39654. return v, fmt.Errorf("querying old value for OldAPIKey: %w", err)
  39655. }
  39656. return oldValue.APIKey, nil
  39657. }
  39658. // ClearAPIKey clears the value of the "api_key" field.
  39659. func (m *WxCardMutation) ClearAPIKey() {
  39660. m.api_key = nil
  39661. m.clearedFields[wxcard.FieldAPIKey] = struct{}{}
  39662. }
  39663. // APIKeyCleared returns if the "api_key" field was cleared in this mutation.
  39664. func (m *WxCardMutation) APIKeyCleared() bool {
  39665. _, ok := m.clearedFields[wxcard.FieldAPIKey]
  39666. return ok
  39667. }
  39668. // ResetAPIKey resets all changes to the "api_key" field.
  39669. func (m *WxCardMutation) ResetAPIKey() {
  39670. m.api_key = nil
  39671. delete(m.clearedFields, wxcard.FieldAPIKey)
  39672. }
  39673. // SetAiInfo sets the "ai_info" field.
  39674. func (m *WxCardMutation) SetAiInfo(s string) {
  39675. m.ai_info = &s
  39676. }
  39677. // AiInfo returns the value of the "ai_info" field in the mutation.
  39678. func (m *WxCardMutation) AiInfo() (r string, exists bool) {
  39679. v := m.ai_info
  39680. if v == nil {
  39681. return
  39682. }
  39683. return *v, true
  39684. }
  39685. // OldAiInfo returns the old "ai_info" 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) OldAiInfo(ctx context.Context) (v string, err error) {
  39689. if !m.op.Is(OpUpdateOne) {
  39690. return v, errors.New("OldAiInfo is only allowed on UpdateOne operations")
  39691. }
  39692. if m.id == nil || m.oldValue == nil {
  39693. return v, errors.New("OldAiInfo 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 OldAiInfo: %w", err)
  39698. }
  39699. return oldValue.AiInfo, nil
  39700. }
  39701. // ClearAiInfo clears the value of the "ai_info" field.
  39702. func (m *WxCardMutation) ClearAiInfo() {
  39703. m.ai_info = nil
  39704. m.clearedFields[wxcard.FieldAiInfo] = struct{}{}
  39705. }
  39706. // AiInfoCleared returns if the "ai_info" field was cleared in this mutation.
  39707. func (m *WxCardMutation) AiInfoCleared() bool {
  39708. _, ok := m.clearedFields[wxcard.FieldAiInfo]
  39709. return ok
  39710. }
  39711. // ResetAiInfo resets all changes to the "ai_info" field.
  39712. func (m *WxCardMutation) ResetAiInfo() {
  39713. m.ai_info = nil
  39714. delete(m.clearedFields, wxcard.FieldAiInfo)
  39715. }
  39716. // SetIntro sets the "intro" field.
  39717. func (m *WxCardMutation) SetIntro(s string) {
  39718. m.intro = &s
  39719. }
  39720. // Intro returns the value of the "intro" field in the mutation.
  39721. func (m *WxCardMutation) Intro() (r string, exists bool) {
  39722. v := m.intro
  39723. if v == nil {
  39724. return
  39725. }
  39726. return *v, true
  39727. }
  39728. // OldIntro returns the old "intro" 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) OldIntro(ctx context.Context) (v string, err error) {
  39732. if !m.op.Is(OpUpdateOne) {
  39733. return v, errors.New("OldIntro is only allowed on UpdateOne operations")
  39734. }
  39735. if m.id == nil || m.oldValue == nil {
  39736. return v, errors.New("OldIntro 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 OldIntro: %w", err)
  39741. }
  39742. return oldValue.Intro, nil
  39743. }
  39744. // ClearIntro clears the value of the "intro" field.
  39745. func (m *WxCardMutation) ClearIntro() {
  39746. m.intro = nil
  39747. m.clearedFields[wxcard.FieldIntro] = struct{}{}
  39748. }
  39749. // IntroCleared returns if the "intro" field was cleared in this mutation.
  39750. func (m *WxCardMutation) IntroCleared() bool {
  39751. _, ok := m.clearedFields[wxcard.FieldIntro]
  39752. return ok
  39753. }
  39754. // ResetIntro resets all changes to the "intro" field.
  39755. func (m *WxCardMutation) ResetIntro() {
  39756. m.intro = nil
  39757. delete(m.clearedFields, wxcard.FieldIntro)
  39758. }
  39759. // Where appends a list predicates to the WxCardMutation builder.
  39760. func (m *WxCardMutation) Where(ps ...predicate.WxCard) {
  39761. m.predicates = append(m.predicates, ps...)
  39762. }
  39763. // WhereP appends storage-level predicates to the WxCardMutation builder. Using this method,
  39764. // users can use type-assertion to append predicates that do not depend on any generated package.
  39765. func (m *WxCardMutation) WhereP(ps ...func(*sql.Selector)) {
  39766. p := make([]predicate.WxCard, len(ps))
  39767. for i := range ps {
  39768. p[i] = ps[i]
  39769. }
  39770. m.Where(p...)
  39771. }
  39772. // Op returns the operation name.
  39773. func (m *WxCardMutation) Op() Op {
  39774. return m.op
  39775. }
  39776. // SetOp allows setting the mutation operation.
  39777. func (m *WxCardMutation) SetOp(op Op) {
  39778. m.op = op
  39779. }
  39780. // Type returns the node type of this mutation (WxCard).
  39781. func (m *WxCardMutation) Type() string {
  39782. return m.typ
  39783. }
  39784. // Fields returns all fields that were changed during this mutation. Note that in
  39785. // order to get all numeric fields that were incremented/decremented, call
  39786. // AddedFields().
  39787. func (m *WxCardMutation) Fields() []string {
  39788. fields := make([]string, 0, 18)
  39789. if m.created_at != nil {
  39790. fields = append(fields, wxcard.FieldCreatedAt)
  39791. }
  39792. if m.updated_at != nil {
  39793. fields = append(fields, wxcard.FieldUpdatedAt)
  39794. }
  39795. if m.deleted_at != nil {
  39796. fields = append(fields, wxcard.FieldDeletedAt)
  39797. }
  39798. if m.user_id != nil {
  39799. fields = append(fields, wxcard.FieldUserID)
  39800. }
  39801. if m.wx_user_id != nil {
  39802. fields = append(fields, wxcard.FieldWxUserID)
  39803. }
  39804. if m.avatar != nil {
  39805. fields = append(fields, wxcard.FieldAvatar)
  39806. }
  39807. if m.logo != nil {
  39808. fields = append(fields, wxcard.FieldLogo)
  39809. }
  39810. if m.name != nil {
  39811. fields = append(fields, wxcard.FieldName)
  39812. }
  39813. if m.company != nil {
  39814. fields = append(fields, wxcard.FieldCompany)
  39815. }
  39816. if m.address != nil {
  39817. fields = append(fields, wxcard.FieldAddress)
  39818. }
  39819. if m.phone != nil {
  39820. fields = append(fields, wxcard.FieldPhone)
  39821. }
  39822. if m.official_account != nil {
  39823. fields = append(fields, wxcard.FieldOfficialAccount)
  39824. }
  39825. if m.wechat_account != nil {
  39826. fields = append(fields, wxcard.FieldWechatAccount)
  39827. }
  39828. if m.email != nil {
  39829. fields = append(fields, wxcard.FieldEmail)
  39830. }
  39831. if m.api_base != nil {
  39832. fields = append(fields, wxcard.FieldAPIBase)
  39833. }
  39834. if m.api_key != nil {
  39835. fields = append(fields, wxcard.FieldAPIKey)
  39836. }
  39837. if m.ai_info != nil {
  39838. fields = append(fields, wxcard.FieldAiInfo)
  39839. }
  39840. if m.intro != nil {
  39841. fields = append(fields, wxcard.FieldIntro)
  39842. }
  39843. return fields
  39844. }
  39845. // Field returns the value of a field with the given name. The second boolean
  39846. // return value indicates that this field was not set, or was not defined in the
  39847. // schema.
  39848. func (m *WxCardMutation) Field(name string) (ent.Value, bool) {
  39849. switch name {
  39850. case wxcard.FieldCreatedAt:
  39851. return m.CreatedAt()
  39852. case wxcard.FieldUpdatedAt:
  39853. return m.UpdatedAt()
  39854. case wxcard.FieldDeletedAt:
  39855. return m.DeletedAt()
  39856. case wxcard.FieldUserID:
  39857. return m.UserID()
  39858. case wxcard.FieldWxUserID:
  39859. return m.WxUserID()
  39860. case wxcard.FieldAvatar:
  39861. return m.Avatar()
  39862. case wxcard.FieldLogo:
  39863. return m.Logo()
  39864. case wxcard.FieldName:
  39865. return m.Name()
  39866. case wxcard.FieldCompany:
  39867. return m.Company()
  39868. case wxcard.FieldAddress:
  39869. return m.Address()
  39870. case wxcard.FieldPhone:
  39871. return m.Phone()
  39872. case wxcard.FieldOfficialAccount:
  39873. return m.OfficialAccount()
  39874. case wxcard.FieldWechatAccount:
  39875. return m.WechatAccount()
  39876. case wxcard.FieldEmail:
  39877. return m.Email()
  39878. case wxcard.FieldAPIBase:
  39879. return m.APIBase()
  39880. case wxcard.FieldAPIKey:
  39881. return m.APIKey()
  39882. case wxcard.FieldAiInfo:
  39883. return m.AiInfo()
  39884. case wxcard.FieldIntro:
  39885. return m.Intro()
  39886. }
  39887. return nil, false
  39888. }
  39889. // OldField returns the old value of the field from the database. An error is
  39890. // returned if the mutation operation is not UpdateOne, or the query to the
  39891. // database failed.
  39892. func (m *WxCardMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  39893. switch name {
  39894. case wxcard.FieldCreatedAt:
  39895. return m.OldCreatedAt(ctx)
  39896. case wxcard.FieldUpdatedAt:
  39897. return m.OldUpdatedAt(ctx)
  39898. case wxcard.FieldDeletedAt:
  39899. return m.OldDeletedAt(ctx)
  39900. case wxcard.FieldUserID:
  39901. return m.OldUserID(ctx)
  39902. case wxcard.FieldWxUserID:
  39903. return m.OldWxUserID(ctx)
  39904. case wxcard.FieldAvatar:
  39905. return m.OldAvatar(ctx)
  39906. case wxcard.FieldLogo:
  39907. return m.OldLogo(ctx)
  39908. case wxcard.FieldName:
  39909. return m.OldName(ctx)
  39910. case wxcard.FieldCompany:
  39911. return m.OldCompany(ctx)
  39912. case wxcard.FieldAddress:
  39913. return m.OldAddress(ctx)
  39914. case wxcard.FieldPhone:
  39915. return m.OldPhone(ctx)
  39916. case wxcard.FieldOfficialAccount:
  39917. return m.OldOfficialAccount(ctx)
  39918. case wxcard.FieldWechatAccount:
  39919. return m.OldWechatAccount(ctx)
  39920. case wxcard.FieldEmail:
  39921. return m.OldEmail(ctx)
  39922. case wxcard.FieldAPIBase:
  39923. return m.OldAPIBase(ctx)
  39924. case wxcard.FieldAPIKey:
  39925. return m.OldAPIKey(ctx)
  39926. case wxcard.FieldAiInfo:
  39927. return m.OldAiInfo(ctx)
  39928. case wxcard.FieldIntro:
  39929. return m.OldIntro(ctx)
  39930. }
  39931. return nil, fmt.Errorf("unknown WxCard field %s", name)
  39932. }
  39933. // SetField sets the value of a field with the given name. It returns an error if
  39934. // the field is not defined in the schema, or if the type mismatched the field
  39935. // type.
  39936. func (m *WxCardMutation) SetField(name string, value ent.Value) error {
  39937. switch name {
  39938. case wxcard.FieldCreatedAt:
  39939. v, ok := value.(time.Time)
  39940. if !ok {
  39941. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39942. }
  39943. m.SetCreatedAt(v)
  39944. return nil
  39945. case wxcard.FieldUpdatedAt:
  39946. v, ok := value.(time.Time)
  39947. if !ok {
  39948. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39949. }
  39950. m.SetUpdatedAt(v)
  39951. return nil
  39952. case wxcard.FieldDeletedAt:
  39953. v, ok := value.(time.Time)
  39954. if !ok {
  39955. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39956. }
  39957. m.SetDeletedAt(v)
  39958. return nil
  39959. case wxcard.FieldUserID:
  39960. v, ok := value.(uint64)
  39961. if !ok {
  39962. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39963. }
  39964. m.SetUserID(v)
  39965. return nil
  39966. case wxcard.FieldWxUserID:
  39967. v, ok := value.(uint64)
  39968. if !ok {
  39969. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39970. }
  39971. m.SetWxUserID(v)
  39972. return nil
  39973. case wxcard.FieldAvatar:
  39974. v, ok := value.(string)
  39975. if !ok {
  39976. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39977. }
  39978. m.SetAvatar(v)
  39979. return nil
  39980. case wxcard.FieldLogo:
  39981. v, ok := value.(string)
  39982. if !ok {
  39983. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39984. }
  39985. m.SetLogo(v)
  39986. return nil
  39987. case wxcard.FieldName:
  39988. v, ok := value.(string)
  39989. if !ok {
  39990. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39991. }
  39992. m.SetName(v)
  39993. return nil
  39994. case wxcard.FieldCompany:
  39995. v, ok := value.(string)
  39996. if !ok {
  39997. return fmt.Errorf("unexpected type %T for field %s", value, name)
  39998. }
  39999. m.SetCompany(v)
  40000. return nil
  40001. case wxcard.FieldAddress:
  40002. v, ok := value.(string)
  40003. if !ok {
  40004. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40005. }
  40006. m.SetAddress(v)
  40007. return nil
  40008. case wxcard.FieldPhone:
  40009. v, ok := value.(string)
  40010. if !ok {
  40011. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40012. }
  40013. m.SetPhone(v)
  40014. return nil
  40015. case wxcard.FieldOfficialAccount:
  40016. v, ok := value.(string)
  40017. if !ok {
  40018. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40019. }
  40020. m.SetOfficialAccount(v)
  40021. return nil
  40022. case wxcard.FieldWechatAccount:
  40023. v, ok := value.(string)
  40024. if !ok {
  40025. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40026. }
  40027. m.SetWechatAccount(v)
  40028. return nil
  40029. case wxcard.FieldEmail:
  40030. v, ok := value.(string)
  40031. if !ok {
  40032. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40033. }
  40034. m.SetEmail(v)
  40035. return nil
  40036. case wxcard.FieldAPIBase:
  40037. v, ok := value.(string)
  40038. if !ok {
  40039. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40040. }
  40041. m.SetAPIBase(v)
  40042. return nil
  40043. case wxcard.FieldAPIKey:
  40044. v, ok := value.(string)
  40045. if !ok {
  40046. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40047. }
  40048. m.SetAPIKey(v)
  40049. return nil
  40050. case wxcard.FieldAiInfo:
  40051. v, ok := value.(string)
  40052. if !ok {
  40053. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40054. }
  40055. m.SetAiInfo(v)
  40056. return nil
  40057. case wxcard.FieldIntro:
  40058. v, ok := value.(string)
  40059. if !ok {
  40060. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40061. }
  40062. m.SetIntro(v)
  40063. return nil
  40064. }
  40065. return fmt.Errorf("unknown WxCard field %s", name)
  40066. }
  40067. // AddedFields returns all numeric fields that were incremented/decremented during
  40068. // this mutation.
  40069. func (m *WxCardMutation) AddedFields() []string {
  40070. var fields []string
  40071. if m.adduser_id != nil {
  40072. fields = append(fields, wxcard.FieldUserID)
  40073. }
  40074. if m.addwx_user_id != nil {
  40075. fields = append(fields, wxcard.FieldWxUserID)
  40076. }
  40077. return fields
  40078. }
  40079. // AddedField returns the numeric value that was incremented/decremented on a field
  40080. // with the given name. The second boolean return value indicates that this field
  40081. // was not set, or was not defined in the schema.
  40082. func (m *WxCardMutation) AddedField(name string) (ent.Value, bool) {
  40083. switch name {
  40084. case wxcard.FieldUserID:
  40085. return m.AddedUserID()
  40086. case wxcard.FieldWxUserID:
  40087. return m.AddedWxUserID()
  40088. }
  40089. return nil, false
  40090. }
  40091. // AddField adds the value to the field with the given name. It returns an error if
  40092. // the field is not defined in the schema, or if the type mismatched the field
  40093. // type.
  40094. func (m *WxCardMutation) AddField(name string, value ent.Value) error {
  40095. switch name {
  40096. case wxcard.FieldUserID:
  40097. v, ok := value.(int64)
  40098. if !ok {
  40099. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40100. }
  40101. m.AddUserID(v)
  40102. return nil
  40103. case wxcard.FieldWxUserID:
  40104. v, ok := value.(int64)
  40105. if !ok {
  40106. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40107. }
  40108. m.AddWxUserID(v)
  40109. return nil
  40110. }
  40111. return fmt.Errorf("unknown WxCard numeric field %s", name)
  40112. }
  40113. // ClearedFields returns all nullable fields that were cleared during this
  40114. // mutation.
  40115. func (m *WxCardMutation) ClearedFields() []string {
  40116. var fields []string
  40117. if m.FieldCleared(wxcard.FieldDeletedAt) {
  40118. fields = append(fields, wxcard.FieldDeletedAt)
  40119. }
  40120. if m.FieldCleared(wxcard.FieldUserID) {
  40121. fields = append(fields, wxcard.FieldUserID)
  40122. }
  40123. if m.FieldCleared(wxcard.FieldWxUserID) {
  40124. fields = append(fields, wxcard.FieldWxUserID)
  40125. }
  40126. if m.FieldCleared(wxcard.FieldEmail) {
  40127. fields = append(fields, wxcard.FieldEmail)
  40128. }
  40129. if m.FieldCleared(wxcard.FieldAPIBase) {
  40130. fields = append(fields, wxcard.FieldAPIBase)
  40131. }
  40132. if m.FieldCleared(wxcard.FieldAPIKey) {
  40133. fields = append(fields, wxcard.FieldAPIKey)
  40134. }
  40135. if m.FieldCleared(wxcard.FieldAiInfo) {
  40136. fields = append(fields, wxcard.FieldAiInfo)
  40137. }
  40138. if m.FieldCleared(wxcard.FieldIntro) {
  40139. fields = append(fields, wxcard.FieldIntro)
  40140. }
  40141. return fields
  40142. }
  40143. // FieldCleared returns a boolean indicating if a field with the given name was
  40144. // cleared in this mutation.
  40145. func (m *WxCardMutation) FieldCleared(name string) bool {
  40146. _, ok := m.clearedFields[name]
  40147. return ok
  40148. }
  40149. // ClearField clears the value of the field with the given name. It returns an
  40150. // error if the field is not defined in the schema.
  40151. func (m *WxCardMutation) ClearField(name string) error {
  40152. switch name {
  40153. case wxcard.FieldDeletedAt:
  40154. m.ClearDeletedAt()
  40155. return nil
  40156. case wxcard.FieldUserID:
  40157. m.ClearUserID()
  40158. return nil
  40159. case wxcard.FieldWxUserID:
  40160. m.ClearWxUserID()
  40161. return nil
  40162. case wxcard.FieldEmail:
  40163. m.ClearEmail()
  40164. return nil
  40165. case wxcard.FieldAPIBase:
  40166. m.ClearAPIBase()
  40167. return nil
  40168. case wxcard.FieldAPIKey:
  40169. m.ClearAPIKey()
  40170. return nil
  40171. case wxcard.FieldAiInfo:
  40172. m.ClearAiInfo()
  40173. return nil
  40174. case wxcard.FieldIntro:
  40175. m.ClearIntro()
  40176. return nil
  40177. }
  40178. return fmt.Errorf("unknown WxCard nullable field %s", name)
  40179. }
  40180. // ResetField resets all changes in the mutation for the field with the given name.
  40181. // It returns an error if the field is not defined in the schema.
  40182. func (m *WxCardMutation) ResetField(name string) error {
  40183. switch name {
  40184. case wxcard.FieldCreatedAt:
  40185. m.ResetCreatedAt()
  40186. return nil
  40187. case wxcard.FieldUpdatedAt:
  40188. m.ResetUpdatedAt()
  40189. return nil
  40190. case wxcard.FieldDeletedAt:
  40191. m.ResetDeletedAt()
  40192. return nil
  40193. case wxcard.FieldUserID:
  40194. m.ResetUserID()
  40195. return nil
  40196. case wxcard.FieldWxUserID:
  40197. m.ResetWxUserID()
  40198. return nil
  40199. case wxcard.FieldAvatar:
  40200. m.ResetAvatar()
  40201. return nil
  40202. case wxcard.FieldLogo:
  40203. m.ResetLogo()
  40204. return nil
  40205. case wxcard.FieldName:
  40206. m.ResetName()
  40207. return nil
  40208. case wxcard.FieldCompany:
  40209. m.ResetCompany()
  40210. return nil
  40211. case wxcard.FieldAddress:
  40212. m.ResetAddress()
  40213. return nil
  40214. case wxcard.FieldPhone:
  40215. m.ResetPhone()
  40216. return nil
  40217. case wxcard.FieldOfficialAccount:
  40218. m.ResetOfficialAccount()
  40219. return nil
  40220. case wxcard.FieldWechatAccount:
  40221. m.ResetWechatAccount()
  40222. return nil
  40223. case wxcard.FieldEmail:
  40224. m.ResetEmail()
  40225. return nil
  40226. case wxcard.FieldAPIBase:
  40227. m.ResetAPIBase()
  40228. return nil
  40229. case wxcard.FieldAPIKey:
  40230. m.ResetAPIKey()
  40231. return nil
  40232. case wxcard.FieldAiInfo:
  40233. m.ResetAiInfo()
  40234. return nil
  40235. case wxcard.FieldIntro:
  40236. m.ResetIntro()
  40237. return nil
  40238. }
  40239. return fmt.Errorf("unknown WxCard field %s", name)
  40240. }
  40241. // AddedEdges returns all edge names that were set/added in this mutation.
  40242. func (m *WxCardMutation) AddedEdges() []string {
  40243. edges := make([]string, 0, 0)
  40244. return edges
  40245. }
  40246. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  40247. // name in this mutation.
  40248. func (m *WxCardMutation) AddedIDs(name string) []ent.Value {
  40249. return nil
  40250. }
  40251. // RemovedEdges returns all edge names that were removed in this mutation.
  40252. func (m *WxCardMutation) RemovedEdges() []string {
  40253. edges := make([]string, 0, 0)
  40254. return edges
  40255. }
  40256. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  40257. // the given name in this mutation.
  40258. func (m *WxCardMutation) RemovedIDs(name string) []ent.Value {
  40259. return nil
  40260. }
  40261. // ClearedEdges returns all edge names that were cleared in this mutation.
  40262. func (m *WxCardMutation) ClearedEdges() []string {
  40263. edges := make([]string, 0, 0)
  40264. return edges
  40265. }
  40266. // EdgeCleared returns a boolean which indicates if the edge with the given name
  40267. // was cleared in this mutation.
  40268. func (m *WxCardMutation) EdgeCleared(name string) bool {
  40269. return false
  40270. }
  40271. // ClearEdge clears the value of the edge with the given name. It returns an error
  40272. // if that edge is not defined in the schema.
  40273. func (m *WxCardMutation) ClearEdge(name string) error {
  40274. return fmt.Errorf("unknown WxCard unique edge %s", name)
  40275. }
  40276. // ResetEdge resets all changes to the edge with the given name in this mutation.
  40277. // It returns an error if the edge is not defined in the schema.
  40278. func (m *WxCardMutation) ResetEdge(name string) error {
  40279. return fmt.Errorf("unknown WxCard edge %s", name)
  40280. }
  40281. // WxCardUserMutation represents an operation that mutates the WxCardUser nodes in the graph.
  40282. type WxCardUserMutation struct {
  40283. config
  40284. op Op
  40285. typ string
  40286. id *uint64
  40287. created_at *time.Time
  40288. updated_at *time.Time
  40289. deleted_at *time.Time
  40290. wxid *string
  40291. account *string
  40292. avatar *string
  40293. nickname *string
  40294. remark *string
  40295. phone *string
  40296. open_id *string
  40297. union_id *string
  40298. session_key *string
  40299. is_vip *int
  40300. addis_vip *int
  40301. clearedFields map[string]struct{}
  40302. done bool
  40303. oldValue func(context.Context) (*WxCardUser, error)
  40304. predicates []predicate.WxCardUser
  40305. }
  40306. var _ ent.Mutation = (*WxCardUserMutation)(nil)
  40307. // wxcarduserOption allows management of the mutation configuration using functional options.
  40308. type wxcarduserOption func(*WxCardUserMutation)
  40309. // newWxCardUserMutation creates new mutation for the WxCardUser entity.
  40310. func newWxCardUserMutation(c config, op Op, opts ...wxcarduserOption) *WxCardUserMutation {
  40311. m := &WxCardUserMutation{
  40312. config: c,
  40313. op: op,
  40314. typ: TypeWxCardUser,
  40315. clearedFields: make(map[string]struct{}),
  40316. }
  40317. for _, opt := range opts {
  40318. opt(m)
  40319. }
  40320. return m
  40321. }
  40322. // withWxCardUserID sets the ID field of the mutation.
  40323. func withWxCardUserID(id uint64) wxcarduserOption {
  40324. return func(m *WxCardUserMutation) {
  40325. var (
  40326. err error
  40327. once sync.Once
  40328. value *WxCardUser
  40329. )
  40330. m.oldValue = func(ctx context.Context) (*WxCardUser, error) {
  40331. once.Do(func() {
  40332. if m.done {
  40333. err = errors.New("querying old values post mutation is not allowed")
  40334. } else {
  40335. value, err = m.Client().WxCardUser.Get(ctx, id)
  40336. }
  40337. })
  40338. return value, err
  40339. }
  40340. m.id = &id
  40341. }
  40342. }
  40343. // withWxCardUser sets the old WxCardUser of the mutation.
  40344. func withWxCardUser(node *WxCardUser) wxcarduserOption {
  40345. return func(m *WxCardUserMutation) {
  40346. m.oldValue = func(context.Context) (*WxCardUser, error) {
  40347. return node, nil
  40348. }
  40349. m.id = &node.ID
  40350. }
  40351. }
  40352. // Client returns a new `ent.Client` from the mutation. If the mutation was
  40353. // executed in a transaction (ent.Tx), a transactional client is returned.
  40354. func (m WxCardUserMutation) Client() *Client {
  40355. client := &Client{config: m.config}
  40356. client.init()
  40357. return client
  40358. }
  40359. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  40360. // it returns an error otherwise.
  40361. func (m WxCardUserMutation) Tx() (*Tx, error) {
  40362. if _, ok := m.driver.(*txDriver); !ok {
  40363. return nil, errors.New("ent: mutation is not running in a transaction")
  40364. }
  40365. tx := &Tx{config: m.config}
  40366. tx.init()
  40367. return tx, nil
  40368. }
  40369. // SetID sets the value of the id field. Note that this
  40370. // operation is only accepted on creation of WxCardUser entities.
  40371. func (m *WxCardUserMutation) SetID(id uint64) {
  40372. m.id = &id
  40373. }
  40374. // ID returns the ID value in the mutation. Note that the ID is only available
  40375. // if it was provided to the builder or after it was returned from the database.
  40376. func (m *WxCardUserMutation) ID() (id uint64, exists bool) {
  40377. if m.id == nil {
  40378. return
  40379. }
  40380. return *m.id, true
  40381. }
  40382. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  40383. // That means, if the mutation is applied within a transaction with an isolation level such
  40384. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  40385. // or updated by the mutation.
  40386. func (m *WxCardUserMutation) IDs(ctx context.Context) ([]uint64, error) {
  40387. switch {
  40388. case m.op.Is(OpUpdateOne | OpDeleteOne):
  40389. id, exists := m.ID()
  40390. if exists {
  40391. return []uint64{id}, nil
  40392. }
  40393. fallthrough
  40394. case m.op.Is(OpUpdate | OpDelete):
  40395. return m.Client().WxCardUser.Query().Where(m.predicates...).IDs(ctx)
  40396. default:
  40397. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  40398. }
  40399. }
  40400. // SetCreatedAt sets the "created_at" field.
  40401. func (m *WxCardUserMutation) SetCreatedAt(t time.Time) {
  40402. m.created_at = &t
  40403. }
  40404. // CreatedAt returns the value of the "created_at" field in the mutation.
  40405. func (m *WxCardUserMutation) CreatedAt() (r time.Time, exists bool) {
  40406. v := m.created_at
  40407. if v == nil {
  40408. return
  40409. }
  40410. return *v, true
  40411. }
  40412. // OldCreatedAt returns the old "created_at" field's value of the WxCardUser entity.
  40413. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40414. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40415. func (m *WxCardUserMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  40416. if !m.op.Is(OpUpdateOne) {
  40417. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  40418. }
  40419. if m.id == nil || m.oldValue == nil {
  40420. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  40421. }
  40422. oldValue, err := m.oldValue(ctx)
  40423. if err != nil {
  40424. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  40425. }
  40426. return oldValue.CreatedAt, nil
  40427. }
  40428. // ResetCreatedAt resets all changes to the "created_at" field.
  40429. func (m *WxCardUserMutation) ResetCreatedAt() {
  40430. m.created_at = nil
  40431. }
  40432. // SetUpdatedAt sets the "updated_at" field.
  40433. func (m *WxCardUserMutation) SetUpdatedAt(t time.Time) {
  40434. m.updated_at = &t
  40435. }
  40436. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  40437. func (m *WxCardUserMutation) UpdatedAt() (r time.Time, exists bool) {
  40438. v := m.updated_at
  40439. if v == nil {
  40440. return
  40441. }
  40442. return *v, true
  40443. }
  40444. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardUser entity.
  40445. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40446. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40447. func (m *WxCardUserMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  40448. if !m.op.Is(OpUpdateOne) {
  40449. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  40450. }
  40451. if m.id == nil || m.oldValue == nil {
  40452. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  40453. }
  40454. oldValue, err := m.oldValue(ctx)
  40455. if err != nil {
  40456. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  40457. }
  40458. return oldValue.UpdatedAt, nil
  40459. }
  40460. // ResetUpdatedAt resets all changes to the "updated_at" field.
  40461. func (m *WxCardUserMutation) ResetUpdatedAt() {
  40462. m.updated_at = nil
  40463. }
  40464. // SetDeletedAt sets the "deleted_at" field.
  40465. func (m *WxCardUserMutation) SetDeletedAt(t time.Time) {
  40466. m.deleted_at = &t
  40467. }
  40468. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  40469. func (m *WxCardUserMutation) DeletedAt() (r time.Time, exists bool) {
  40470. v := m.deleted_at
  40471. if v == nil {
  40472. return
  40473. }
  40474. return *v, true
  40475. }
  40476. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardUser entity.
  40477. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40478. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40479. func (m *WxCardUserMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  40480. if !m.op.Is(OpUpdateOne) {
  40481. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  40482. }
  40483. if m.id == nil || m.oldValue == nil {
  40484. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  40485. }
  40486. oldValue, err := m.oldValue(ctx)
  40487. if err != nil {
  40488. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  40489. }
  40490. return oldValue.DeletedAt, nil
  40491. }
  40492. // ClearDeletedAt clears the value of the "deleted_at" field.
  40493. func (m *WxCardUserMutation) ClearDeletedAt() {
  40494. m.deleted_at = nil
  40495. m.clearedFields[wxcarduser.FieldDeletedAt] = struct{}{}
  40496. }
  40497. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  40498. func (m *WxCardUserMutation) DeletedAtCleared() bool {
  40499. _, ok := m.clearedFields[wxcarduser.FieldDeletedAt]
  40500. return ok
  40501. }
  40502. // ResetDeletedAt resets all changes to the "deleted_at" field.
  40503. func (m *WxCardUserMutation) ResetDeletedAt() {
  40504. m.deleted_at = nil
  40505. delete(m.clearedFields, wxcarduser.FieldDeletedAt)
  40506. }
  40507. // SetWxid sets the "wxid" field.
  40508. func (m *WxCardUserMutation) SetWxid(s string) {
  40509. m.wxid = &s
  40510. }
  40511. // Wxid returns the value of the "wxid" field in the mutation.
  40512. func (m *WxCardUserMutation) Wxid() (r string, exists bool) {
  40513. v := m.wxid
  40514. if v == nil {
  40515. return
  40516. }
  40517. return *v, true
  40518. }
  40519. // OldWxid returns the old "wxid" field's value of the WxCardUser entity.
  40520. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40521. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40522. func (m *WxCardUserMutation) OldWxid(ctx context.Context) (v string, err error) {
  40523. if !m.op.Is(OpUpdateOne) {
  40524. return v, errors.New("OldWxid is only allowed on UpdateOne operations")
  40525. }
  40526. if m.id == nil || m.oldValue == nil {
  40527. return v, errors.New("OldWxid requires an ID field in the mutation")
  40528. }
  40529. oldValue, err := m.oldValue(ctx)
  40530. if err != nil {
  40531. return v, fmt.Errorf("querying old value for OldWxid: %w", err)
  40532. }
  40533. return oldValue.Wxid, nil
  40534. }
  40535. // ResetWxid resets all changes to the "wxid" field.
  40536. func (m *WxCardUserMutation) ResetWxid() {
  40537. m.wxid = nil
  40538. }
  40539. // SetAccount sets the "account" field.
  40540. func (m *WxCardUserMutation) SetAccount(s string) {
  40541. m.account = &s
  40542. }
  40543. // Account returns the value of the "account" field in the mutation.
  40544. func (m *WxCardUserMutation) Account() (r string, exists bool) {
  40545. v := m.account
  40546. if v == nil {
  40547. return
  40548. }
  40549. return *v, true
  40550. }
  40551. // OldAccount returns the old "account" field's value of the WxCardUser entity.
  40552. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40553. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40554. func (m *WxCardUserMutation) OldAccount(ctx context.Context) (v string, err error) {
  40555. if !m.op.Is(OpUpdateOne) {
  40556. return v, errors.New("OldAccount is only allowed on UpdateOne operations")
  40557. }
  40558. if m.id == nil || m.oldValue == nil {
  40559. return v, errors.New("OldAccount requires an ID field in the mutation")
  40560. }
  40561. oldValue, err := m.oldValue(ctx)
  40562. if err != nil {
  40563. return v, fmt.Errorf("querying old value for OldAccount: %w", err)
  40564. }
  40565. return oldValue.Account, nil
  40566. }
  40567. // ResetAccount resets all changes to the "account" field.
  40568. func (m *WxCardUserMutation) ResetAccount() {
  40569. m.account = nil
  40570. }
  40571. // SetAvatar sets the "avatar" field.
  40572. func (m *WxCardUserMutation) SetAvatar(s string) {
  40573. m.avatar = &s
  40574. }
  40575. // Avatar returns the value of the "avatar" field in the mutation.
  40576. func (m *WxCardUserMutation) Avatar() (r string, exists bool) {
  40577. v := m.avatar
  40578. if v == nil {
  40579. return
  40580. }
  40581. return *v, true
  40582. }
  40583. // OldAvatar returns the old "avatar" field's value of the WxCardUser entity.
  40584. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40585. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40586. func (m *WxCardUserMutation) OldAvatar(ctx context.Context) (v string, err error) {
  40587. if !m.op.Is(OpUpdateOne) {
  40588. return v, errors.New("OldAvatar is only allowed on UpdateOne operations")
  40589. }
  40590. if m.id == nil || m.oldValue == nil {
  40591. return v, errors.New("OldAvatar requires an ID field in the mutation")
  40592. }
  40593. oldValue, err := m.oldValue(ctx)
  40594. if err != nil {
  40595. return v, fmt.Errorf("querying old value for OldAvatar: %w", err)
  40596. }
  40597. return oldValue.Avatar, nil
  40598. }
  40599. // ResetAvatar resets all changes to the "avatar" field.
  40600. func (m *WxCardUserMutation) ResetAvatar() {
  40601. m.avatar = nil
  40602. }
  40603. // SetNickname sets the "nickname" field.
  40604. func (m *WxCardUserMutation) SetNickname(s string) {
  40605. m.nickname = &s
  40606. }
  40607. // Nickname returns the value of the "nickname" field in the mutation.
  40608. func (m *WxCardUserMutation) Nickname() (r string, exists bool) {
  40609. v := m.nickname
  40610. if v == nil {
  40611. return
  40612. }
  40613. return *v, true
  40614. }
  40615. // OldNickname returns the old "nickname" field's value of the WxCardUser entity.
  40616. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40617. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40618. func (m *WxCardUserMutation) OldNickname(ctx context.Context) (v string, err error) {
  40619. if !m.op.Is(OpUpdateOne) {
  40620. return v, errors.New("OldNickname is only allowed on UpdateOne operations")
  40621. }
  40622. if m.id == nil || m.oldValue == nil {
  40623. return v, errors.New("OldNickname requires an ID field in the mutation")
  40624. }
  40625. oldValue, err := m.oldValue(ctx)
  40626. if err != nil {
  40627. return v, fmt.Errorf("querying old value for OldNickname: %w", err)
  40628. }
  40629. return oldValue.Nickname, nil
  40630. }
  40631. // ResetNickname resets all changes to the "nickname" field.
  40632. func (m *WxCardUserMutation) ResetNickname() {
  40633. m.nickname = nil
  40634. }
  40635. // SetRemark sets the "remark" field.
  40636. func (m *WxCardUserMutation) SetRemark(s string) {
  40637. m.remark = &s
  40638. }
  40639. // Remark returns the value of the "remark" field in the mutation.
  40640. func (m *WxCardUserMutation) Remark() (r string, exists bool) {
  40641. v := m.remark
  40642. if v == nil {
  40643. return
  40644. }
  40645. return *v, true
  40646. }
  40647. // OldRemark returns the old "remark" field's value of the WxCardUser entity.
  40648. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40649. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40650. func (m *WxCardUserMutation) OldRemark(ctx context.Context) (v string, err error) {
  40651. if !m.op.Is(OpUpdateOne) {
  40652. return v, errors.New("OldRemark is only allowed on UpdateOne operations")
  40653. }
  40654. if m.id == nil || m.oldValue == nil {
  40655. return v, errors.New("OldRemark requires an ID field in the mutation")
  40656. }
  40657. oldValue, err := m.oldValue(ctx)
  40658. if err != nil {
  40659. return v, fmt.Errorf("querying old value for OldRemark: %w", err)
  40660. }
  40661. return oldValue.Remark, nil
  40662. }
  40663. // ResetRemark resets all changes to the "remark" field.
  40664. func (m *WxCardUserMutation) ResetRemark() {
  40665. m.remark = nil
  40666. }
  40667. // SetPhone sets the "phone" field.
  40668. func (m *WxCardUserMutation) SetPhone(s string) {
  40669. m.phone = &s
  40670. }
  40671. // Phone returns the value of the "phone" field in the mutation.
  40672. func (m *WxCardUserMutation) Phone() (r string, exists bool) {
  40673. v := m.phone
  40674. if v == nil {
  40675. return
  40676. }
  40677. return *v, true
  40678. }
  40679. // OldPhone returns the old "phone" field's value of the WxCardUser entity.
  40680. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40681. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40682. func (m *WxCardUserMutation) OldPhone(ctx context.Context) (v string, err error) {
  40683. if !m.op.Is(OpUpdateOne) {
  40684. return v, errors.New("OldPhone is only allowed on UpdateOne operations")
  40685. }
  40686. if m.id == nil || m.oldValue == nil {
  40687. return v, errors.New("OldPhone requires an ID field in the mutation")
  40688. }
  40689. oldValue, err := m.oldValue(ctx)
  40690. if err != nil {
  40691. return v, fmt.Errorf("querying old value for OldPhone: %w", err)
  40692. }
  40693. return oldValue.Phone, nil
  40694. }
  40695. // ResetPhone resets all changes to the "phone" field.
  40696. func (m *WxCardUserMutation) ResetPhone() {
  40697. m.phone = nil
  40698. }
  40699. // SetOpenID sets the "open_id" field.
  40700. func (m *WxCardUserMutation) SetOpenID(s string) {
  40701. m.open_id = &s
  40702. }
  40703. // OpenID returns the value of the "open_id" field in the mutation.
  40704. func (m *WxCardUserMutation) OpenID() (r string, exists bool) {
  40705. v := m.open_id
  40706. if v == nil {
  40707. return
  40708. }
  40709. return *v, true
  40710. }
  40711. // OldOpenID returns the old "open_id" field's value of the WxCardUser entity.
  40712. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40713. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40714. func (m *WxCardUserMutation) OldOpenID(ctx context.Context) (v string, err error) {
  40715. if !m.op.Is(OpUpdateOne) {
  40716. return v, errors.New("OldOpenID is only allowed on UpdateOne operations")
  40717. }
  40718. if m.id == nil || m.oldValue == nil {
  40719. return v, errors.New("OldOpenID requires an ID field in the mutation")
  40720. }
  40721. oldValue, err := m.oldValue(ctx)
  40722. if err != nil {
  40723. return v, fmt.Errorf("querying old value for OldOpenID: %w", err)
  40724. }
  40725. return oldValue.OpenID, nil
  40726. }
  40727. // ResetOpenID resets all changes to the "open_id" field.
  40728. func (m *WxCardUserMutation) ResetOpenID() {
  40729. m.open_id = nil
  40730. }
  40731. // SetUnionID sets the "union_id" field.
  40732. func (m *WxCardUserMutation) SetUnionID(s string) {
  40733. m.union_id = &s
  40734. }
  40735. // UnionID returns the value of the "union_id" field in the mutation.
  40736. func (m *WxCardUserMutation) UnionID() (r string, exists bool) {
  40737. v := m.union_id
  40738. if v == nil {
  40739. return
  40740. }
  40741. return *v, true
  40742. }
  40743. // OldUnionID returns the old "union_id" field's value of the WxCardUser entity.
  40744. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40745. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40746. func (m *WxCardUserMutation) OldUnionID(ctx context.Context) (v string, err error) {
  40747. if !m.op.Is(OpUpdateOne) {
  40748. return v, errors.New("OldUnionID is only allowed on UpdateOne operations")
  40749. }
  40750. if m.id == nil || m.oldValue == nil {
  40751. return v, errors.New("OldUnionID requires an ID field in the mutation")
  40752. }
  40753. oldValue, err := m.oldValue(ctx)
  40754. if err != nil {
  40755. return v, fmt.Errorf("querying old value for OldUnionID: %w", err)
  40756. }
  40757. return oldValue.UnionID, nil
  40758. }
  40759. // ResetUnionID resets all changes to the "union_id" field.
  40760. func (m *WxCardUserMutation) ResetUnionID() {
  40761. m.union_id = nil
  40762. }
  40763. // SetSessionKey sets the "session_key" field.
  40764. func (m *WxCardUserMutation) SetSessionKey(s string) {
  40765. m.session_key = &s
  40766. }
  40767. // SessionKey returns the value of the "session_key" field in the mutation.
  40768. func (m *WxCardUserMutation) SessionKey() (r string, exists bool) {
  40769. v := m.session_key
  40770. if v == nil {
  40771. return
  40772. }
  40773. return *v, true
  40774. }
  40775. // OldSessionKey returns the old "session_key" field's value of the WxCardUser entity.
  40776. // If the WxCardUser object wasn't provided to the builder, the object is fetched from the database.
  40777. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  40778. func (m *WxCardUserMutation) OldSessionKey(ctx context.Context) (v string, err error) {
  40779. if !m.op.Is(OpUpdateOne) {
  40780. return v, errors.New("OldSessionKey is only allowed on UpdateOne operations")
  40781. }
  40782. if m.id == nil || m.oldValue == nil {
  40783. return v, errors.New("OldSessionKey requires an ID field in the mutation")
  40784. }
  40785. oldValue, err := m.oldValue(ctx)
  40786. if err != nil {
  40787. return v, fmt.Errorf("querying old value for OldSessionKey: %w", err)
  40788. }
  40789. return oldValue.SessionKey, nil
  40790. }
  40791. // ResetSessionKey resets all changes to the "session_key" field.
  40792. func (m *WxCardUserMutation) ResetSessionKey() {
  40793. m.session_key = nil
  40794. }
  40795. // SetIsVip sets the "is_vip" field.
  40796. func (m *WxCardUserMutation) SetIsVip(i int) {
  40797. m.is_vip = &i
  40798. m.addis_vip = nil
  40799. }
  40800. // IsVip returns the value of the "is_vip" field in the mutation.
  40801. func (m *WxCardUserMutation) IsVip() (r int, exists bool) {
  40802. v := m.is_vip
  40803. if v == nil {
  40804. return
  40805. }
  40806. return *v, true
  40807. }
  40808. // OldIsVip returns the old "is_vip" 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) OldIsVip(ctx context.Context) (v int, err error) {
  40812. if !m.op.Is(OpUpdateOne) {
  40813. return v, errors.New("OldIsVip is only allowed on UpdateOne operations")
  40814. }
  40815. if m.id == nil || m.oldValue == nil {
  40816. return v, errors.New("OldIsVip 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 OldIsVip: %w", err)
  40821. }
  40822. return oldValue.IsVip, nil
  40823. }
  40824. // AddIsVip adds i to the "is_vip" field.
  40825. func (m *WxCardUserMutation) AddIsVip(i int) {
  40826. if m.addis_vip != nil {
  40827. *m.addis_vip += i
  40828. } else {
  40829. m.addis_vip = &i
  40830. }
  40831. }
  40832. // AddedIsVip returns the value that was added to the "is_vip" field in this mutation.
  40833. func (m *WxCardUserMutation) AddedIsVip() (r int, exists bool) {
  40834. v := m.addis_vip
  40835. if v == nil {
  40836. return
  40837. }
  40838. return *v, true
  40839. }
  40840. // ResetIsVip resets all changes to the "is_vip" field.
  40841. func (m *WxCardUserMutation) ResetIsVip() {
  40842. m.is_vip = nil
  40843. m.addis_vip = nil
  40844. }
  40845. // Where appends a list predicates to the WxCardUserMutation builder.
  40846. func (m *WxCardUserMutation) Where(ps ...predicate.WxCardUser) {
  40847. m.predicates = append(m.predicates, ps...)
  40848. }
  40849. // WhereP appends storage-level predicates to the WxCardUserMutation builder. Using this method,
  40850. // users can use type-assertion to append predicates that do not depend on any generated package.
  40851. func (m *WxCardUserMutation) WhereP(ps ...func(*sql.Selector)) {
  40852. p := make([]predicate.WxCardUser, len(ps))
  40853. for i := range ps {
  40854. p[i] = ps[i]
  40855. }
  40856. m.Where(p...)
  40857. }
  40858. // Op returns the operation name.
  40859. func (m *WxCardUserMutation) Op() Op {
  40860. return m.op
  40861. }
  40862. // SetOp allows setting the mutation operation.
  40863. func (m *WxCardUserMutation) SetOp(op Op) {
  40864. m.op = op
  40865. }
  40866. // Type returns the node type of this mutation (WxCardUser).
  40867. func (m *WxCardUserMutation) Type() string {
  40868. return m.typ
  40869. }
  40870. // Fields returns all fields that were changed during this mutation. Note that in
  40871. // order to get all numeric fields that were incremented/decremented, call
  40872. // AddedFields().
  40873. func (m *WxCardUserMutation) Fields() []string {
  40874. fields := make([]string, 0, 13)
  40875. if m.created_at != nil {
  40876. fields = append(fields, wxcarduser.FieldCreatedAt)
  40877. }
  40878. if m.updated_at != nil {
  40879. fields = append(fields, wxcarduser.FieldUpdatedAt)
  40880. }
  40881. if m.deleted_at != nil {
  40882. fields = append(fields, wxcarduser.FieldDeletedAt)
  40883. }
  40884. if m.wxid != nil {
  40885. fields = append(fields, wxcarduser.FieldWxid)
  40886. }
  40887. if m.account != nil {
  40888. fields = append(fields, wxcarduser.FieldAccount)
  40889. }
  40890. if m.avatar != nil {
  40891. fields = append(fields, wxcarduser.FieldAvatar)
  40892. }
  40893. if m.nickname != nil {
  40894. fields = append(fields, wxcarduser.FieldNickname)
  40895. }
  40896. if m.remark != nil {
  40897. fields = append(fields, wxcarduser.FieldRemark)
  40898. }
  40899. if m.phone != nil {
  40900. fields = append(fields, wxcarduser.FieldPhone)
  40901. }
  40902. if m.open_id != nil {
  40903. fields = append(fields, wxcarduser.FieldOpenID)
  40904. }
  40905. if m.union_id != nil {
  40906. fields = append(fields, wxcarduser.FieldUnionID)
  40907. }
  40908. if m.session_key != nil {
  40909. fields = append(fields, wxcarduser.FieldSessionKey)
  40910. }
  40911. if m.is_vip != nil {
  40912. fields = append(fields, wxcarduser.FieldIsVip)
  40913. }
  40914. return fields
  40915. }
  40916. // Field returns the value of a field with the given name. The second boolean
  40917. // return value indicates that this field was not set, or was not defined in the
  40918. // schema.
  40919. func (m *WxCardUserMutation) Field(name string) (ent.Value, bool) {
  40920. switch name {
  40921. case wxcarduser.FieldCreatedAt:
  40922. return m.CreatedAt()
  40923. case wxcarduser.FieldUpdatedAt:
  40924. return m.UpdatedAt()
  40925. case wxcarduser.FieldDeletedAt:
  40926. return m.DeletedAt()
  40927. case wxcarduser.FieldWxid:
  40928. return m.Wxid()
  40929. case wxcarduser.FieldAccount:
  40930. return m.Account()
  40931. case wxcarduser.FieldAvatar:
  40932. return m.Avatar()
  40933. case wxcarduser.FieldNickname:
  40934. return m.Nickname()
  40935. case wxcarduser.FieldRemark:
  40936. return m.Remark()
  40937. case wxcarduser.FieldPhone:
  40938. return m.Phone()
  40939. case wxcarduser.FieldOpenID:
  40940. return m.OpenID()
  40941. case wxcarduser.FieldUnionID:
  40942. return m.UnionID()
  40943. case wxcarduser.FieldSessionKey:
  40944. return m.SessionKey()
  40945. case wxcarduser.FieldIsVip:
  40946. return m.IsVip()
  40947. }
  40948. return nil, false
  40949. }
  40950. // OldField returns the old value of the field from the database. An error is
  40951. // returned if the mutation operation is not UpdateOne, or the query to the
  40952. // database failed.
  40953. func (m *WxCardUserMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  40954. switch name {
  40955. case wxcarduser.FieldCreatedAt:
  40956. return m.OldCreatedAt(ctx)
  40957. case wxcarduser.FieldUpdatedAt:
  40958. return m.OldUpdatedAt(ctx)
  40959. case wxcarduser.FieldDeletedAt:
  40960. return m.OldDeletedAt(ctx)
  40961. case wxcarduser.FieldWxid:
  40962. return m.OldWxid(ctx)
  40963. case wxcarduser.FieldAccount:
  40964. return m.OldAccount(ctx)
  40965. case wxcarduser.FieldAvatar:
  40966. return m.OldAvatar(ctx)
  40967. case wxcarduser.FieldNickname:
  40968. return m.OldNickname(ctx)
  40969. case wxcarduser.FieldRemark:
  40970. return m.OldRemark(ctx)
  40971. case wxcarduser.FieldPhone:
  40972. return m.OldPhone(ctx)
  40973. case wxcarduser.FieldOpenID:
  40974. return m.OldOpenID(ctx)
  40975. case wxcarduser.FieldUnionID:
  40976. return m.OldUnionID(ctx)
  40977. case wxcarduser.FieldSessionKey:
  40978. return m.OldSessionKey(ctx)
  40979. case wxcarduser.FieldIsVip:
  40980. return m.OldIsVip(ctx)
  40981. }
  40982. return nil, fmt.Errorf("unknown WxCardUser field %s", name)
  40983. }
  40984. // SetField sets the value of a field with the given name. It returns an error if
  40985. // the field is not defined in the schema, or if the type mismatched the field
  40986. // type.
  40987. func (m *WxCardUserMutation) SetField(name string, value ent.Value) error {
  40988. switch name {
  40989. case wxcarduser.FieldCreatedAt:
  40990. v, ok := value.(time.Time)
  40991. if !ok {
  40992. return fmt.Errorf("unexpected type %T for field %s", value, name)
  40993. }
  40994. m.SetCreatedAt(v)
  40995. return nil
  40996. case wxcarduser.FieldUpdatedAt:
  40997. v, ok := value.(time.Time)
  40998. if !ok {
  40999. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41000. }
  41001. m.SetUpdatedAt(v)
  41002. return nil
  41003. case wxcarduser.FieldDeletedAt:
  41004. v, ok := value.(time.Time)
  41005. if !ok {
  41006. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41007. }
  41008. m.SetDeletedAt(v)
  41009. return nil
  41010. case wxcarduser.FieldWxid:
  41011. v, ok := value.(string)
  41012. if !ok {
  41013. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41014. }
  41015. m.SetWxid(v)
  41016. return nil
  41017. case wxcarduser.FieldAccount:
  41018. v, ok := value.(string)
  41019. if !ok {
  41020. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41021. }
  41022. m.SetAccount(v)
  41023. return nil
  41024. case wxcarduser.FieldAvatar:
  41025. v, ok := value.(string)
  41026. if !ok {
  41027. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41028. }
  41029. m.SetAvatar(v)
  41030. return nil
  41031. case wxcarduser.FieldNickname:
  41032. v, ok := value.(string)
  41033. if !ok {
  41034. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41035. }
  41036. m.SetNickname(v)
  41037. return nil
  41038. case wxcarduser.FieldRemark:
  41039. v, ok := value.(string)
  41040. if !ok {
  41041. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41042. }
  41043. m.SetRemark(v)
  41044. return nil
  41045. case wxcarduser.FieldPhone:
  41046. v, ok := value.(string)
  41047. if !ok {
  41048. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41049. }
  41050. m.SetPhone(v)
  41051. return nil
  41052. case wxcarduser.FieldOpenID:
  41053. v, ok := value.(string)
  41054. if !ok {
  41055. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41056. }
  41057. m.SetOpenID(v)
  41058. return nil
  41059. case wxcarduser.FieldUnionID:
  41060. v, ok := value.(string)
  41061. if !ok {
  41062. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41063. }
  41064. m.SetUnionID(v)
  41065. return nil
  41066. case wxcarduser.FieldSessionKey:
  41067. v, ok := value.(string)
  41068. if !ok {
  41069. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41070. }
  41071. m.SetSessionKey(v)
  41072. return nil
  41073. case wxcarduser.FieldIsVip:
  41074. v, ok := value.(int)
  41075. if !ok {
  41076. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41077. }
  41078. m.SetIsVip(v)
  41079. return nil
  41080. }
  41081. return fmt.Errorf("unknown WxCardUser field %s", name)
  41082. }
  41083. // AddedFields returns all numeric fields that were incremented/decremented during
  41084. // this mutation.
  41085. func (m *WxCardUserMutation) AddedFields() []string {
  41086. var fields []string
  41087. if m.addis_vip != nil {
  41088. fields = append(fields, wxcarduser.FieldIsVip)
  41089. }
  41090. return fields
  41091. }
  41092. // AddedField returns the numeric value that was incremented/decremented on a field
  41093. // with the given name. The second boolean return value indicates that this field
  41094. // was not set, or was not defined in the schema.
  41095. func (m *WxCardUserMutation) AddedField(name string) (ent.Value, bool) {
  41096. switch name {
  41097. case wxcarduser.FieldIsVip:
  41098. return m.AddedIsVip()
  41099. }
  41100. return nil, false
  41101. }
  41102. // AddField adds the value to the field with the given name. It returns an error if
  41103. // the field is not defined in the schema, or if the type mismatched the field
  41104. // type.
  41105. func (m *WxCardUserMutation) AddField(name string, value ent.Value) error {
  41106. switch name {
  41107. case wxcarduser.FieldIsVip:
  41108. v, ok := value.(int)
  41109. if !ok {
  41110. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41111. }
  41112. m.AddIsVip(v)
  41113. return nil
  41114. }
  41115. return fmt.Errorf("unknown WxCardUser numeric field %s", name)
  41116. }
  41117. // ClearedFields returns all nullable fields that were cleared during this
  41118. // mutation.
  41119. func (m *WxCardUserMutation) ClearedFields() []string {
  41120. var fields []string
  41121. if m.FieldCleared(wxcarduser.FieldDeletedAt) {
  41122. fields = append(fields, wxcarduser.FieldDeletedAt)
  41123. }
  41124. return fields
  41125. }
  41126. // FieldCleared returns a boolean indicating if a field with the given name was
  41127. // cleared in this mutation.
  41128. func (m *WxCardUserMutation) FieldCleared(name string) bool {
  41129. _, ok := m.clearedFields[name]
  41130. return ok
  41131. }
  41132. // ClearField clears the value of the field with the given name. It returns an
  41133. // error if the field is not defined in the schema.
  41134. func (m *WxCardUserMutation) ClearField(name string) error {
  41135. switch name {
  41136. case wxcarduser.FieldDeletedAt:
  41137. m.ClearDeletedAt()
  41138. return nil
  41139. }
  41140. return fmt.Errorf("unknown WxCardUser nullable field %s", name)
  41141. }
  41142. // ResetField resets all changes in the mutation for the field with the given name.
  41143. // It returns an error if the field is not defined in the schema.
  41144. func (m *WxCardUserMutation) ResetField(name string) error {
  41145. switch name {
  41146. case wxcarduser.FieldCreatedAt:
  41147. m.ResetCreatedAt()
  41148. return nil
  41149. case wxcarduser.FieldUpdatedAt:
  41150. m.ResetUpdatedAt()
  41151. return nil
  41152. case wxcarduser.FieldDeletedAt:
  41153. m.ResetDeletedAt()
  41154. return nil
  41155. case wxcarduser.FieldWxid:
  41156. m.ResetWxid()
  41157. return nil
  41158. case wxcarduser.FieldAccount:
  41159. m.ResetAccount()
  41160. return nil
  41161. case wxcarduser.FieldAvatar:
  41162. m.ResetAvatar()
  41163. return nil
  41164. case wxcarduser.FieldNickname:
  41165. m.ResetNickname()
  41166. return nil
  41167. case wxcarduser.FieldRemark:
  41168. m.ResetRemark()
  41169. return nil
  41170. case wxcarduser.FieldPhone:
  41171. m.ResetPhone()
  41172. return nil
  41173. case wxcarduser.FieldOpenID:
  41174. m.ResetOpenID()
  41175. return nil
  41176. case wxcarduser.FieldUnionID:
  41177. m.ResetUnionID()
  41178. return nil
  41179. case wxcarduser.FieldSessionKey:
  41180. m.ResetSessionKey()
  41181. return nil
  41182. case wxcarduser.FieldIsVip:
  41183. m.ResetIsVip()
  41184. return nil
  41185. }
  41186. return fmt.Errorf("unknown WxCardUser field %s", name)
  41187. }
  41188. // AddedEdges returns all edge names that were set/added in this mutation.
  41189. func (m *WxCardUserMutation) AddedEdges() []string {
  41190. edges := make([]string, 0, 0)
  41191. return edges
  41192. }
  41193. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41194. // name in this mutation.
  41195. func (m *WxCardUserMutation) AddedIDs(name string) []ent.Value {
  41196. return nil
  41197. }
  41198. // RemovedEdges returns all edge names that were removed in this mutation.
  41199. func (m *WxCardUserMutation) RemovedEdges() []string {
  41200. edges := make([]string, 0, 0)
  41201. return edges
  41202. }
  41203. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41204. // the given name in this mutation.
  41205. func (m *WxCardUserMutation) RemovedIDs(name string) []ent.Value {
  41206. return nil
  41207. }
  41208. // ClearedEdges returns all edge names that were cleared in this mutation.
  41209. func (m *WxCardUserMutation) ClearedEdges() []string {
  41210. edges := make([]string, 0, 0)
  41211. return edges
  41212. }
  41213. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41214. // was cleared in this mutation.
  41215. func (m *WxCardUserMutation) EdgeCleared(name string) bool {
  41216. return false
  41217. }
  41218. // ClearEdge clears the value of the edge with the given name. It returns an error
  41219. // if that edge is not defined in the schema.
  41220. func (m *WxCardUserMutation) ClearEdge(name string) error {
  41221. return fmt.Errorf("unknown WxCardUser unique edge %s", name)
  41222. }
  41223. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41224. // It returns an error if the edge is not defined in the schema.
  41225. func (m *WxCardUserMutation) ResetEdge(name string) error {
  41226. return fmt.Errorf("unknown WxCardUser edge %s", name)
  41227. }
  41228. // WxCardVisitMutation represents an operation that mutates the WxCardVisit nodes in the graph.
  41229. type WxCardVisitMutation struct {
  41230. config
  41231. op Op
  41232. typ string
  41233. id *uint64
  41234. created_at *time.Time
  41235. updated_at *time.Time
  41236. deleted_at *time.Time
  41237. user_id *uint64
  41238. adduser_id *int64
  41239. bot_id *uint64
  41240. addbot_id *int64
  41241. bot_type *uint8
  41242. addbot_type *int8
  41243. clearedFields map[string]struct{}
  41244. done bool
  41245. oldValue func(context.Context) (*WxCardVisit, error)
  41246. predicates []predicate.WxCardVisit
  41247. }
  41248. var _ ent.Mutation = (*WxCardVisitMutation)(nil)
  41249. // wxcardvisitOption allows management of the mutation configuration using functional options.
  41250. type wxcardvisitOption func(*WxCardVisitMutation)
  41251. // newWxCardVisitMutation creates new mutation for the WxCardVisit entity.
  41252. func newWxCardVisitMutation(c config, op Op, opts ...wxcardvisitOption) *WxCardVisitMutation {
  41253. m := &WxCardVisitMutation{
  41254. config: c,
  41255. op: op,
  41256. typ: TypeWxCardVisit,
  41257. clearedFields: make(map[string]struct{}),
  41258. }
  41259. for _, opt := range opts {
  41260. opt(m)
  41261. }
  41262. return m
  41263. }
  41264. // withWxCardVisitID sets the ID field of the mutation.
  41265. func withWxCardVisitID(id uint64) wxcardvisitOption {
  41266. return func(m *WxCardVisitMutation) {
  41267. var (
  41268. err error
  41269. once sync.Once
  41270. value *WxCardVisit
  41271. )
  41272. m.oldValue = func(ctx context.Context) (*WxCardVisit, error) {
  41273. once.Do(func() {
  41274. if m.done {
  41275. err = errors.New("querying old values post mutation is not allowed")
  41276. } else {
  41277. value, err = m.Client().WxCardVisit.Get(ctx, id)
  41278. }
  41279. })
  41280. return value, err
  41281. }
  41282. m.id = &id
  41283. }
  41284. }
  41285. // withWxCardVisit sets the old WxCardVisit of the mutation.
  41286. func withWxCardVisit(node *WxCardVisit) wxcardvisitOption {
  41287. return func(m *WxCardVisitMutation) {
  41288. m.oldValue = func(context.Context) (*WxCardVisit, error) {
  41289. return node, nil
  41290. }
  41291. m.id = &node.ID
  41292. }
  41293. }
  41294. // Client returns a new `ent.Client` from the mutation. If the mutation was
  41295. // executed in a transaction (ent.Tx), a transactional client is returned.
  41296. func (m WxCardVisitMutation) Client() *Client {
  41297. client := &Client{config: m.config}
  41298. client.init()
  41299. return client
  41300. }
  41301. // Tx returns an `ent.Tx` for mutations that were executed in transactions;
  41302. // it returns an error otherwise.
  41303. func (m WxCardVisitMutation) Tx() (*Tx, error) {
  41304. if _, ok := m.driver.(*txDriver); !ok {
  41305. return nil, errors.New("ent: mutation is not running in a transaction")
  41306. }
  41307. tx := &Tx{config: m.config}
  41308. tx.init()
  41309. return tx, nil
  41310. }
  41311. // SetID sets the value of the id field. Note that this
  41312. // operation is only accepted on creation of WxCardVisit entities.
  41313. func (m *WxCardVisitMutation) SetID(id uint64) {
  41314. m.id = &id
  41315. }
  41316. // ID returns the ID value in the mutation. Note that the ID is only available
  41317. // if it was provided to the builder or after it was returned from the database.
  41318. func (m *WxCardVisitMutation) ID() (id uint64, exists bool) {
  41319. if m.id == nil {
  41320. return
  41321. }
  41322. return *m.id, true
  41323. }
  41324. // IDs queries the database and returns the entity ids that match the mutation's predicate.
  41325. // That means, if the mutation is applied within a transaction with an isolation level such
  41326. // as sql.LevelSerializable, the returned ids match the ids of the rows that will be updated
  41327. // or updated by the mutation.
  41328. func (m *WxCardVisitMutation) IDs(ctx context.Context) ([]uint64, error) {
  41329. switch {
  41330. case m.op.Is(OpUpdateOne | OpDeleteOne):
  41331. id, exists := m.ID()
  41332. if exists {
  41333. return []uint64{id}, nil
  41334. }
  41335. fallthrough
  41336. case m.op.Is(OpUpdate | OpDelete):
  41337. return m.Client().WxCardVisit.Query().Where(m.predicates...).IDs(ctx)
  41338. default:
  41339. return nil, fmt.Errorf("IDs is not allowed on %s operations", m.op)
  41340. }
  41341. }
  41342. // SetCreatedAt sets the "created_at" field.
  41343. func (m *WxCardVisitMutation) SetCreatedAt(t time.Time) {
  41344. m.created_at = &t
  41345. }
  41346. // CreatedAt returns the value of the "created_at" field in the mutation.
  41347. func (m *WxCardVisitMutation) CreatedAt() (r time.Time, exists bool) {
  41348. v := m.created_at
  41349. if v == nil {
  41350. return
  41351. }
  41352. return *v, true
  41353. }
  41354. // OldCreatedAt returns the old "created_at" field's value of the WxCardVisit entity.
  41355. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41356. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41357. func (m *WxCardVisitMutation) OldCreatedAt(ctx context.Context) (v time.Time, err error) {
  41358. if !m.op.Is(OpUpdateOne) {
  41359. return v, errors.New("OldCreatedAt is only allowed on UpdateOne operations")
  41360. }
  41361. if m.id == nil || m.oldValue == nil {
  41362. return v, errors.New("OldCreatedAt requires an ID field in the mutation")
  41363. }
  41364. oldValue, err := m.oldValue(ctx)
  41365. if err != nil {
  41366. return v, fmt.Errorf("querying old value for OldCreatedAt: %w", err)
  41367. }
  41368. return oldValue.CreatedAt, nil
  41369. }
  41370. // ResetCreatedAt resets all changes to the "created_at" field.
  41371. func (m *WxCardVisitMutation) ResetCreatedAt() {
  41372. m.created_at = nil
  41373. }
  41374. // SetUpdatedAt sets the "updated_at" field.
  41375. func (m *WxCardVisitMutation) SetUpdatedAt(t time.Time) {
  41376. m.updated_at = &t
  41377. }
  41378. // UpdatedAt returns the value of the "updated_at" field in the mutation.
  41379. func (m *WxCardVisitMutation) UpdatedAt() (r time.Time, exists bool) {
  41380. v := m.updated_at
  41381. if v == nil {
  41382. return
  41383. }
  41384. return *v, true
  41385. }
  41386. // OldUpdatedAt returns the old "updated_at" field's value of the WxCardVisit entity.
  41387. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41388. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41389. func (m *WxCardVisitMutation) OldUpdatedAt(ctx context.Context) (v time.Time, err error) {
  41390. if !m.op.Is(OpUpdateOne) {
  41391. return v, errors.New("OldUpdatedAt is only allowed on UpdateOne operations")
  41392. }
  41393. if m.id == nil || m.oldValue == nil {
  41394. return v, errors.New("OldUpdatedAt requires an ID field in the mutation")
  41395. }
  41396. oldValue, err := m.oldValue(ctx)
  41397. if err != nil {
  41398. return v, fmt.Errorf("querying old value for OldUpdatedAt: %w", err)
  41399. }
  41400. return oldValue.UpdatedAt, nil
  41401. }
  41402. // ResetUpdatedAt resets all changes to the "updated_at" field.
  41403. func (m *WxCardVisitMutation) ResetUpdatedAt() {
  41404. m.updated_at = nil
  41405. }
  41406. // SetDeletedAt sets the "deleted_at" field.
  41407. func (m *WxCardVisitMutation) SetDeletedAt(t time.Time) {
  41408. m.deleted_at = &t
  41409. }
  41410. // DeletedAt returns the value of the "deleted_at" field in the mutation.
  41411. func (m *WxCardVisitMutation) DeletedAt() (r time.Time, exists bool) {
  41412. v := m.deleted_at
  41413. if v == nil {
  41414. return
  41415. }
  41416. return *v, true
  41417. }
  41418. // OldDeletedAt returns the old "deleted_at" field's value of the WxCardVisit entity.
  41419. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41420. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41421. func (m *WxCardVisitMutation) OldDeletedAt(ctx context.Context) (v time.Time, err error) {
  41422. if !m.op.Is(OpUpdateOne) {
  41423. return v, errors.New("OldDeletedAt is only allowed on UpdateOne operations")
  41424. }
  41425. if m.id == nil || m.oldValue == nil {
  41426. return v, errors.New("OldDeletedAt requires an ID field in the mutation")
  41427. }
  41428. oldValue, err := m.oldValue(ctx)
  41429. if err != nil {
  41430. return v, fmt.Errorf("querying old value for OldDeletedAt: %w", err)
  41431. }
  41432. return oldValue.DeletedAt, nil
  41433. }
  41434. // ClearDeletedAt clears the value of the "deleted_at" field.
  41435. func (m *WxCardVisitMutation) ClearDeletedAt() {
  41436. m.deleted_at = nil
  41437. m.clearedFields[wxcardvisit.FieldDeletedAt] = struct{}{}
  41438. }
  41439. // DeletedAtCleared returns if the "deleted_at" field was cleared in this mutation.
  41440. func (m *WxCardVisitMutation) DeletedAtCleared() bool {
  41441. _, ok := m.clearedFields[wxcardvisit.FieldDeletedAt]
  41442. return ok
  41443. }
  41444. // ResetDeletedAt resets all changes to the "deleted_at" field.
  41445. func (m *WxCardVisitMutation) ResetDeletedAt() {
  41446. m.deleted_at = nil
  41447. delete(m.clearedFields, wxcardvisit.FieldDeletedAt)
  41448. }
  41449. // SetUserID sets the "user_id" field.
  41450. func (m *WxCardVisitMutation) SetUserID(u uint64) {
  41451. m.user_id = &u
  41452. m.adduser_id = nil
  41453. }
  41454. // UserID returns the value of the "user_id" field in the mutation.
  41455. func (m *WxCardVisitMutation) UserID() (r uint64, exists bool) {
  41456. v := m.user_id
  41457. if v == nil {
  41458. return
  41459. }
  41460. return *v, true
  41461. }
  41462. // OldUserID returns the old "user_id" field's value of the WxCardVisit entity.
  41463. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41464. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41465. func (m *WxCardVisitMutation) OldUserID(ctx context.Context) (v uint64, err error) {
  41466. if !m.op.Is(OpUpdateOne) {
  41467. return v, errors.New("OldUserID is only allowed on UpdateOne operations")
  41468. }
  41469. if m.id == nil || m.oldValue == nil {
  41470. return v, errors.New("OldUserID requires an ID field in the mutation")
  41471. }
  41472. oldValue, err := m.oldValue(ctx)
  41473. if err != nil {
  41474. return v, fmt.Errorf("querying old value for OldUserID: %w", err)
  41475. }
  41476. return oldValue.UserID, nil
  41477. }
  41478. // AddUserID adds u to the "user_id" field.
  41479. func (m *WxCardVisitMutation) AddUserID(u int64) {
  41480. if m.adduser_id != nil {
  41481. *m.adduser_id += u
  41482. } else {
  41483. m.adduser_id = &u
  41484. }
  41485. }
  41486. // AddedUserID returns the value that was added to the "user_id" field in this mutation.
  41487. func (m *WxCardVisitMutation) AddedUserID() (r int64, exists bool) {
  41488. v := m.adduser_id
  41489. if v == nil {
  41490. return
  41491. }
  41492. return *v, true
  41493. }
  41494. // ClearUserID clears the value of the "user_id" field.
  41495. func (m *WxCardVisitMutation) ClearUserID() {
  41496. m.user_id = nil
  41497. m.adduser_id = nil
  41498. m.clearedFields[wxcardvisit.FieldUserID] = struct{}{}
  41499. }
  41500. // UserIDCleared returns if the "user_id" field was cleared in this mutation.
  41501. func (m *WxCardVisitMutation) UserIDCleared() bool {
  41502. _, ok := m.clearedFields[wxcardvisit.FieldUserID]
  41503. return ok
  41504. }
  41505. // ResetUserID resets all changes to the "user_id" field.
  41506. func (m *WxCardVisitMutation) ResetUserID() {
  41507. m.user_id = nil
  41508. m.adduser_id = nil
  41509. delete(m.clearedFields, wxcardvisit.FieldUserID)
  41510. }
  41511. // SetBotID sets the "bot_id" field.
  41512. func (m *WxCardVisitMutation) SetBotID(u uint64) {
  41513. m.bot_id = &u
  41514. m.addbot_id = nil
  41515. }
  41516. // BotID returns the value of the "bot_id" field in the mutation.
  41517. func (m *WxCardVisitMutation) BotID() (r uint64, exists bool) {
  41518. v := m.bot_id
  41519. if v == nil {
  41520. return
  41521. }
  41522. return *v, true
  41523. }
  41524. // OldBotID returns the old "bot_id" field's value of the WxCardVisit entity.
  41525. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41526. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41527. func (m *WxCardVisitMutation) OldBotID(ctx context.Context) (v uint64, err error) {
  41528. if !m.op.Is(OpUpdateOne) {
  41529. return v, errors.New("OldBotID is only allowed on UpdateOne operations")
  41530. }
  41531. if m.id == nil || m.oldValue == nil {
  41532. return v, errors.New("OldBotID requires an ID field in the mutation")
  41533. }
  41534. oldValue, err := m.oldValue(ctx)
  41535. if err != nil {
  41536. return v, fmt.Errorf("querying old value for OldBotID: %w", err)
  41537. }
  41538. return oldValue.BotID, nil
  41539. }
  41540. // AddBotID adds u to the "bot_id" field.
  41541. func (m *WxCardVisitMutation) AddBotID(u int64) {
  41542. if m.addbot_id != nil {
  41543. *m.addbot_id += u
  41544. } else {
  41545. m.addbot_id = &u
  41546. }
  41547. }
  41548. // AddedBotID returns the value that was added to the "bot_id" field in this mutation.
  41549. func (m *WxCardVisitMutation) AddedBotID() (r int64, exists bool) {
  41550. v := m.addbot_id
  41551. if v == nil {
  41552. return
  41553. }
  41554. return *v, true
  41555. }
  41556. // ResetBotID resets all changes to the "bot_id" field.
  41557. func (m *WxCardVisitMutation) ResetBotID() {
  41558. m.bot_id = nil
  41559. m.addbot_id = nil
  41560. }
  41561. // SetBotType sets the "bot_type" field.
  41562. func (m *WxCardVisitMutation) SetBotType(u uint8) {
  41563. m.bot_type = &u
  41564. m.addbot_type = nil
  41565. }
  41566. // BotType returns the value of the "bot_type" field in the mutation.
  41567. func (m *WxCardVisitMutation) BotType() (r uint8, exists bool) {
  41568. v := m.bot_type
  41569. if v == nil {
  41570. return
  41571. }
  41572. return *v, true
  41573. }
  41574. // OldBotType returns the old "bot_type" field's value of the WxCardVisit entity.
  41575. // If the WxCardVisit object wasn't provided to the builder, the object is fetched from the database.
  41576. // An error is returned if the mutation operation is not UpdateOne, or the database query fails.
  41577. func (m *WxCardVisitMutation) OldBotType(ctx context.Context) (v uint8, err error) {
  41578. if !m.op.Is(OpUpdateOne) {
  41579. return v, errors.New("OldBotType is only allowed on UpdateOne operations")
  41580. }
  41581. if m.id == nil || m.oldValue == nil {
  41582. return v, errors.New("OldBotType requires an ID field in the mutation")
  41583. }
  41584. oldValue, err := m.oldValue(ctx)
  41585. if err != nil {
  41586. return v, fmt.Errorf("querying old value for OldBotType: %w", err)
  41587. }
  41588. return oldValue.BotType, nil
  41589. }
  41590. // AddBotType adds u to the "bot_type" field.
  41591. func (m *WxCardVisitMutation) AddBotType(u int8) {
  41592. if m.addbot_type != nil {
  41593. *m.addbot_type += u
  41594. } else {
  41595. m.addbot_type = &u
  41596. }
  41597. }
  41598. // AddedBotType returns the value that was added to the "bot_type" field in this mutation.
  41599. func (m *WxCardVisitMutation) AddedBotType() (r int8, exists bool) {
  41600. v := m.addbot_type
  41601. if v == nil {
  41602. return
  41603. }
  41604. return *v, true
  41605. }
  41606. // ResetBotType resets all changes to the "bot_type" field.
  41607. func (m *WxCardVisitMutation) ResetBotType() {
  41608. m.bot_type = nil
  41609. m.addbot_type = nil
  41610. }
  41611. // Where appends a list predicates to the WxCardVisitMutation builder.
  41612. func (m *WxCardVisitMutation) Where(ps ...predicate.WxCardVisit) {
  41613. m.predicates = append(m.predicates, ps...)
  41614. }
  41615. // WhereP appends storage-level predicates to the WxCardVisitMutation builder. Using this method,
  41616. // users can use type-assertion to append predicates that do not depend on any generated package.
  41617. func (m *WxCardVisitMutation) WhereP(ps ...func(*sql.Selector)) {
  41618. p := make([]predicate.WxCardVisit, len(ps))
  41619. for i := range ps {
  41620. p[i] = ps[i]
  41621. }
  41622. m.Where(p...)
  41623. }
  41624. // Op returns the operation name.
  41625. func (m *WxCardVisitMutation) Op() Op {
  41626. return m.op
  41627. }
  41628. // SetOp allows setting the mutation operation.
  41629. func (m *WxCardVisitMutation) SetOp(op Op) {
  41630. m.op = op
  41631. }
  41632. // Type returns the node type of this mutation (WxCardVisit).
  41633. func (m *WxCardVisitMutation) Type() string {
  41634. return m.typ
  41635. }
  41636. // Fields returns all fields that were changed during this mutation. Note that in
  41637. // order to get all numeric fields that were incremented/decremented, call
  41638. // AddedFields().
  41639. func (m *WxCardVisitMutation) Fields() []string {
  41640. fields := make([]string, 0, 6)
  41641. if m.created_at != nil {
  41642. fields = append(fields, wxcardvisit.FieldCreatedAt)
  41643. }
  41644. if m.updated_at != nil {
  41645. fields = append(fields, wxcardvisit.FieldUpdatedAt)
  41646. }
  41647. if m.deleted_at != nil {
  41648. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41649. }
  41650. if m.user_id != nil {
  41651. fields = append(fields, wxcardvisit.FieldUserID)
  41652. }
  41653. if m.bot_id != nil {
  41654. fields = append(fields, wxcardvisit.FieldBotID)
  41655. }
  41656. if m.bot_type != nil {
  41657. fields = append(fields, wxcardvisit.FieldBotType)
  41658. }
  41659. return fields
  41660. }
  41661. // Field returns the value of a field with the given name. The second boolean
  41662. // return value indicates that this field was not set, or was not defined in the
  41663. // schema.
  41664. func (m *WxCardVisitMutation) Field(name string) (ent.Value, bool) {
  41665. switch name {
  41666. case wxcardvisit.FieldCreatedAt:
  41667. return m.CreatedAt()
  41668. case wxcardvisit.FieldUpdatedAt:
  41669. return m.UpdatedAt()
  41670. case wxcardvisit.FieldDeletedAt:
  41671. return m.DeletedAt()
  41672. case wxcardvisit.FieldUserID:
  41673. return m.UserID()
  41674. case wxcardvisit.FieldBotID:
  41675. return m.BotID()
  41676. case wxcardvisit.FieldBotType:
  41677. return m.BotType()
  41678. }
  41679. return nil, false
  41680. }
  41681. // OldField returns the old value of the field from the database. An error is
  41682. // returned if the mutation operation is not UpdateOne, or the query to the
  41683. // database failed.
  41684. func (m *WxCardVisitMutation) OldField(ctx context.Context, name string) (ent.Value, error) {
  41685. switch name {
  41686. case wxcardvisit.FieldCreatedAt:
  41687. return m.OldCreatedAt(ctx)
  41688. case wxcardvisit.FieldUpdatedAt:
  41689. return m.OldUpdatedAt(ctx)
  41690. case wxcardvisit.FieldDeletedAt:
  41691. return m.OldDeletedAt(ctx)
  41692. case wxcardvisit.FieldUserID:
  41693. return m.OldUserID(ctx)
  41694. case wxcardvisit.FieldBotID:
  41695. return m.OldBotID(ctx)
  41696. case wxcardvisit.FieldBotType:
  41697. return m.OldBotType(ctx)
  41698. }
  41699. return nil, fmt.Errorf("unknown WxCardVisit field %s", name)
  41700. }
  41701. // SetField sets the value of a field with the given name. It returns an error if
  41702. // the field is not defined in the schema, or if the type mismatched the field
  41703. // type.
  41704. func (m *WxCardVisitMutation) SetField(name string, value ent.Value) error {
  41705. switch name {
  41706. case wxcardvisit.FieldCreatedAt:
  41707. v, ok := value.(time.Time)
  41708. if !ok {
  41709. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41710. }
  41711. m.SetCreatedAt(v)
  41712. return nil
  41713. case wxcardvisit.FieldUpdatedAt:
  41714. v, ok := value.(time.Time)
  41715. if !ok {
  41716. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41717. }
  41718. m.SetUpdatedAt(v)
  41719. return nil
  41720. case wxcardvisit.FieldDeletedAt:
  41721. v, ok := value.(time.Time)
  41722. if !ok {
  41723. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41724. }
  41725. m.SetDeletedAt(v)
  41726. return nil
  41727. case wxcardvisit.FieldUserID:
  41728. v, ok := value.(uint64)
  41729. if !ok {
  41730. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41731. }
  41732. m.SetUserID(v)
  41733. return nil
  41734. case wxcardvisit.FieldBotID:
  41735. v, ok := value.(uint64)
  41736. if !ok {
  41737. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41738. }
  41739. m.SetBotID(v)
  41740. return nil
  41741. case wxcardvisit.FieldBotType:
  41742. v, ok := value.(uint8)
  41743. if !ok {
  41744. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41745. }
  41746. m.SetBotType(v)
  41747. return nil
  41748. }
  41749. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41750. }
  41751. // AddedFields returns all numeric fields that were incremented/decremented during
  41752. // this mutation.
  41753. func (m *WxCardVisitMutation) AddedFields() []string {
  41754. var fields []string
  41755. if m.adduser_id != nil {
  41756. fields = append(fields, wxcardvisit.FieldUserID)
  41757. }
  41758. if m.addbot_id != nil {
  41759. fields = append(fields, wxcardvisit.FieldBotID)
  41760. }
  41761. if m.addbot_type != nil {
  41762. fields = append(fields, wxcardvisit.FieldBotType)
  41763. }
  41764. return fields
  41765. }
  41766. // AddedField returns the numeric value that was incremented/decremented on a field
  41767. // with the given name. The second boolean return value indicates that this field
  41768. // was not set, or was not defined in the schema.
  41769. func (m *WxCardVisitMutation) AddedField(name string) (ent.Value, bool) {
  41770. switch name {
  41771. case wxcardvisit.FieldUserID:
  41772. return m.AddedUserID()
  41773. case wxcardvisit.FieldBotID:
  41774. return m.AddedBotID()
  41775. case wxcardvisit.FieldBotType:
  41776. return m.AddedBotType()
  41777. }
  41778. return nil, false
  41779. }
  41780. // AddField adds the value to the field with the given name. It returns an error if
  41781. // the field is not defined in the schema, or if the type mismatched the field
  41782. // type.
  41783. func (m *WxCardVisitMutation) AddField(name string, value ent.Value) error {
  41784. switch name {
  41785. case wxcardvisit.FieldUserID:
  41786. v, ok := value.(int64)
  41787. if !ok {
  41788. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41789. }
  41790. m.AddUserID(v)
  41791. return nil
  41792. case wxcardvisit.FieldBotID:
  41793. v, ok := value.(int64)
  41794. if !ok {
  41795. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41796. }
  41797. m.AddBotID(v)
  41798. return nil
  41799. case wxcardvisit.FieldBotType:
  41800. v, ok := value.(int8)
  41801. if !ok {
  41802. return fmt.Errorf("unexpected type %T for field %s", value, name)
  41803. }
  41804. m.AddBotType(v)
  41805. return nil
  41806. }
  41807. return fmt.Errorf("unknown WxCardVisit numeric field %s", name)
  41808. }
  41809. // ClearedFields returns all nullable fields that were cleared during this
  41810. // mutation.
  41811. func (m *WxCardVisitMutation) ClearedFields() []string {
  41812. var fields []string
  41813. if m.FieldCleared(wxcardvisit.FieldDeletedAt) {
  41814. fields = append(fields, wxcardvisit.FieldDeletedAt)
  41815. }
  41816. if m.FieldCleared(wxcardvisit.FieldUserID) {
  41817. fields = append(fields, wxcardvisit.FieldUserID)
  41818. }
  41819. return fields
  41820. }
  41821. // FieldCleared returns a boolean indicating if a field with the given name was
  41822. // cleared in this mutation.
  41823. func (m *WxCardVisitMutation) FieldCleared(name string) bool {
  41824. _, ok := m.clearedFields[name]
  41825. return ok
  41826. }
  41827. // ClearField clears the value of the field with the given name. It returns an
  41828. // error if the field is not defined in the schema.
  41829. func (m *WxCardVisitMutation) ClearField(name string) error {
  41830. switch name {
  41831. case wxcardvisit.FieldDeletedAt:
  41832. m.ClearDeletedAt()
  41833. return nil
  41834. case wxcardvisit.FieldUserID:
  41835. m.ClearUserID()
  41836. return nil
  41837. }
  41838. return fmt.Errorf("unknown WxCardVisit nullable field %s", name)
  41839. }
  41840. // ResetField resets all changes in the mutation for the field with the given name.
  41841. // It returns an error if the field is not defined in the schema.
  41842. func (m *WxCardVisitMutation) ResetField(name string) error {
  41843. switch name {
  41844. case wxcardvisit.FieldCreatedAt:
  41845. m.ResetCreatedAt()
  41846. return nil
  41847. case wxcardvisit.FieldUpdatedAt:
  41848. m.ResetUpdatedAt()
  41849. return nil
  41850. case wxcardvisit.FieldDeletedAt:
  41851. m.ResetDeletedAt()
  41852. return nil
  41853. case wxcardvisit.FieldUserID:
  41854. m.ResetUserID()
  41855. return nil
  41856. case wxcardvisit.FieldBotID:
  41857. m.ResetBotID()
  41858. return nil
  41859. case wxcardvisit.FieldBotType:
  41860. m.ResetBotType()
  41861. return nil
  41862. }
  41863. return fmt.Errorf("unknown WxCardVisit field %s", name)
  41864. }
  41865. // AddedEdges returns all edge names that were set/added in this mutation.
  41866. func (m *WxCardVisitMutation) AddedEdges() []string {
  41867. edges := make([]string, 0, 0)
  41868. return edges
  41869. }
  41870. // AddedIDs returns all IDs (to other nodes) that were added for the given edge
  41871. // name in this mutation.
  41872. func (m *WxCardVisitMutation) AddedIDs(name string) []ent.Value {
  41873. return nil
  41874. }
  41875. // RemovedEdges returns all edge names that were removed in this mutation.
  41876. func (m *WxCardVisitMutation) RemovedEdges() []string {
  41877. edges := make([]string, 0, 0)
  41878. return edges
  41879. }
  41880. // RemovedIDs returns all IDs (to other nodes) that were removed for the edge with
  41881. // the given name in this mutation.
  41882. func (m *WxCardVisitMutation) RemovedIDs(name string) []ent.Value {
  41883. return nil
  41884. }
  41885. // ClearedEdges returns all edge names that were cleared in this mutation.
  41886. func (m *WxCardVisitMutation) ClearedEdges() []string {
  41887. edges := make([]string, 0, 0)
  41888. return edges
  41889. }
  41890. // EdgeCleared returns a boolean which indicates if the edge with the given name
  41891. // was cleared in this mutation.
  41892. func (m *WxCardVisitMutation) EdgeCleared(name string) bool {
  41893. return false
  41894. }
  41895. // ClearEdge clears the value of the edge with the given name. It returns an error
  41896. // if that edge is not defined in the schema.
  41897. func (m *WxCardVisitMutation) ClearEdge(name string) error {
  41898. return fmt.Errorf("unknown WxCardVisit unique edge %s", name)
  41899. }
  41900. // ResetEdge resets all changes to the edge with the given name in this mutation.
  41901. // It returns an error if the edge is not defined in the schema.
  41902. func (m *WxCardVisitMutation) ResetEdge(name string) error {
  41903. return fmt.Errorf("unknown WxCardVisit edge %s", name)
  41904. }